LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Andy Shevchenko <andy.shevchenko@gmail.com>
To: "Ong, Boon Leong" <boon.leong.ong@intel.com>
Cc: "Bryan O'Donoghue" <pure.logic@nexus-software.ie>,
	"tglx@linutronix.de" <tglx@linutronix.de>,
	"mingo@redhat.com" <mingo@redhat.com>,
	"hpa@zytor.com" <hpa@zytor.com>,
	"x86@kernel.org" <x86@kernel.org>,
	"dvhart@infradead.org" <dvhart@infradead.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v2 1/1] x86: Add Isolated Memory Regions for Quark X1000
Date: Sat, 24 Jan 2015 13:02:28 +0200	[thread overview]
Message-ID: <CAHp75VcCcpUZ7AuKk96-aVUd6Vykfc8_yod+8T_at2DMuTve3Q@mail.gmail.com> (raw)
In-Reply-To: <AF233D1473C1364ABD51D28909A1B1B73270D4C5@PGSMSX105.gar.corp.intel.com>

On Sat, Jan 24, 2015 at 3:48 AM, Ong, Boon Leong
<boon.leong.ong@intel.com> wrote:

>>+static int imr_enabled(struct imr_regs *imr)
> Do we want to make it inline perhaps since it is 1 liner?

Since it is declared static I would even suggest the new name is_imr_enabled().

[]

>>+int imr_remove_range(int reg, unsigned long base, unsigned long size)
>>+{
>>+      struct imr_regs imr;
>>+      int found = 0, i, ret = 0;
> Please make each of the defined variables as individual line here..

I would suggest to type i as unsigned int and found as bool.

[]

>>+              if (!imr_enabled(&imr) || imr.addr_lo & IMR_LOCK) {
>>+                      ret = -ENODEV;
>>+                      goto done;
>>+              }
>>+              found = 1;
>>+

Redundant empty line.

>>+      } else {
>>+              /* Search for match based on address range */
>>+              for (i = 0; i < imr_dev.max_imr; i++) {
>>+                      ret = imr_read(reg, &imr);
> A serious bug here.... 'reg' should be 'i' . We enter this branch if reg=-1
> Is there a miss in your test case?
>
>>+                      if (ret)
>>+                              goto done;
>>+
>>+                      if (!imr_enabled(&imr) || imr.addr_lo & IMR_LOCK)
>>+                              continue;
>>+
>>+                      if ((imr_to_phys(imr.addr_lo) == base) &&
>>+                          (imr_to_phys(imr.addr_hi) == max)) {
> I think we need to take care of the size that has been fix-up here ...
>
>>+                              found = 1;
>>+                              reg = i;

According to your comment this line becomes redundant.

[]

>>+static void __init imr_fixup_memmap(void)
>>+{
>>+      unsigned long base  = virt_to_phys(&_text);
>>+      unsigned long size = virt_to_phys(&__end_rodata) - base;
> What about the size fixup to be consistent?
> We should not guard more than it is needed .....
>
>>+      int i, ret;
> Two int declaration line here.

unsigned int i; ?

-- 
With Best Regards,
Andy Shevchenko

  reply	other threads:[~2015-01-24 11:02 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-21 18:46 [PATCH v2 0/1] x86: Add IMR support to Quark/Galileo Bryan O'Donoghue
2015-01-21 18:46 ` [PATCH v2 1/1] x86: Add Isolated Memory Regions for Quark X1000 Bryan O'Donoghue
2015-01-21 20:57   ` Andy Shevchenko
2015-01-22  1:27     ` Bryan O'Donoghue
2015-01-22  8:59       ` Andy Shevchenko
2015-01-22  9:43         ` Bryan O'Donoghue
2015-01-22 11:24   ` Thomas Gleixner
2015-01-22 11:38     ` Bryan O'Donoghue
2015-01-22 15:02       ` Bryan O'Donoghue
2015-01-22 15:15         ` Bryan O'Donoghue
2015-01-22 16:28           ` Darren Hart
2015-01-22 19:50           ` Thomas Gleixner
2015-01-24  1:48   ` Ong, Boon Leong
2015-01-24 11:02     ` Andy Shevchenko [this message]
2015-01-24 21:56       ` Bryan O'Donoghue
2015-01-24 21:58         ` Bryan O'Donoghue
2015-01-24 19:52     ` Bryan O'Donoghue

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAHp75VcCcpUZ7AuKk96-aVUd6Vykfc8_yod+8T_at2DMuTve3Q@mail.gmail.com \
    --to=andy.shevchenko@gmail.com \
    --cc=boon.leong.ong@intel.com \
    --cc=dvhart@infradead.org \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=pure.logic@nexus-software.ie \
    --cc=tglx@linutronix.de \
    --cc=x86@kernel.org \
    --subject='Re: [PATCH v2 1/1] x86: Add Isolated Memory Regions for Quark X1000' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).