Re: [PATCH v2 04/16] PCI: Simplify resource setup code in setup_device()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Andrey.

On Sat, Jan 12, 2019 at 12:49:17PM -0800, Andrey Smirnov wrote:
> On Sat, Jan 12, 2019 at 3:00 AM Sam Ravnborg <sam@xxxxxxxxxxxx> wrote:
> >
> > Hi Andrey.
> >
> > > ---
> > >  drivers/pci/pci.c | 99 ++++++++++++++++++++---------------------------
> > >  1 file changed, 42 insertions(+), 57 deletions(-)
> > >
> > > diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
> > > index b8089207a4..666b457257 100644
> > > --- a/drivers/pci/pci.c
> > > +++ b/drivers/pci/pci.c
> > > @@ -169,8 +169,11 @@ static void setup_device(struct pci_dev *dev, int max_bar)
> > >                             cmd & ~(PCI_COMMAND_IO | PCI_COMMAND_MEMORY));
> > >
> > >       for (bar = 0; bar < max_bar; bar++) {
> > > -             resource_size_t last_addr;
> > > +             resource_size_t *last;
> > >               u32 orig, mask, size;
> > > +             unsigned long flags;
> > > +             const char *kind;
> > > +             int r;
> > A more descriptine name than "r" would maybe improve readability.
> >
> 
> It's just an index of an array, so single letter name seemed
> reasonable. However, if you give me concrete suggestions, I am more
> than happy to change it.
busres - is this is the type of bus resource we deal with?

> 
> > > @@ -183,67 +186,49 @@ static void setup_device(struct pci_dev *dev, int max_bar)
> > >               if (mask & PCI_BASE_ADDRESS_SPACE_IO) { /* IO */
> > > -                     last_io = ALIGN(last_io, size);
> > > -                     last_addr = last_io;
> > >               } else if ((mask & PCI_BASE_ADDRESS_MEM_PREFETCH) &&
> > >                          last_mem_pref) /* prefetchable MEM */ {
> > > -                     last_mem_pref = ALIGN(last_mem_pref, size);
> > > -                                                IORESOURCE_PREFETCH;
> > > -                     last_addr = last_mem_pref;
> > >               } else { /* non-prefetch MEM */
> > > -                     last_mem = ALIGN(last_mem, size);
> > > -                     last_addr = last_mem;
> > >               }
> > >
> 
> You omitted
> 
> -               dev->resource[bar].start = last_addr;
> 
> here, which would make things a bit more clear since it make easier to
> see that "dev->resource[bar].start" and "last_addr" are
> interchangeable.

Missed that - thanks.

> 
> > > -             dev->resource[bar].end = last_addr + size - 1;
> > > +             dev->resource[bar].start = *last;
> > > +             dev->resource[bar].end = dev->resource[bar].start + size - 1;
> > > +
> > > +             pr_debug("pbar%d: allocated at %pa\n", bar, last);
> > > +
> > > +             *last += size;
> >
> > I could not see that dev->resource[bar].end was assigned the
> > same value with the new code.
> > Maybe I just missed it because I did not follow *last?
> >
> 
> Yes, "*last" should have the same value as "last_addr" (I probably
> should've kept the name). Also
> 
> dev->resource[bar].end = dev->resource[bar].start + size - 1;
> 
> should always be true, just by definition, so as long as
> dev->resource[bar].start is the same (and it is) the value of .end
> should be OK.
> 
> > I think it is worth to double check it.
> >
> 
> I did compare debug outputs before/after when I was writing the patch,
> and AFAICT they matched.
Good!

You can add my:

Reviewed-by: Sam Ravnborg <sam@xxxxxxxxxxxx>

if you spin a new version.

	Sam

_______________________________________________
barebox mailing list
barebox@xxxxxxxxxxxxxxxxxxx
http://lists.infradead.org/mailman/listinfo/barebox



[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux