[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20140702132042.GG2173@e106497-lin.cambridge.arm.com>
Date: Wed, 2 Jul 2014 14:20:42 +0100
From: Liviu Dudau <Liviu.Dudau@....com>
To: Arnd Bergmann <arnd@...db.de>
Cc: linux-pci <linux-pci@...r.kernel.org>,
Bjorn Helgaas <bhelgaas@...gle.com>,
Catalin Marinas <Catalin.Marinas@....com>,
Will Deacon <Will.Deacon@....com>,
Benjamin Herrenschmidt <benh@...nel.crashing.org>,
linaro-kernel <linaro-kernel@...ts.linaro.org>,
Tanmay Inamdar <tinamdar@....com>,
Grant Likely <grant.likely@...retlab.ca>,
Sinan Kaya <okaya@...eaurora.org>,
Jingoo Han <jg1.han@...sung.com>,
Kukjin Kim <kgene.kim@...sung.com>,
Suravee Suthikulanit <suravee.suthikulpanit@....com>,
LKML <linux-kernel@...r.kernel.org>,
Device Tree ML <devicetree@...r.kernel.org>,
LAKML <linux-arm-kernel@...ts.infradead.org>
Subject: Re: [PATCH v8 3/9] pci: Introduce pci_register_io_range() helper
function.
On Wed, Jul 02, 2014 at 01:38:04PM +0100, Arnd Bergmann wrote:
> Some more detailed comments now
>
> On Tuesday 01 July 2014 19:43:28 Liviu Dudau wrote:
> > +/*
> > + * Record the PCI IO range (expressed as CPU physical address + size).
> > + * Return a negative value if an error has occured, zero otherwise
> > + */
> > +int __weak pci_register_io_range(phys_addr_t addr, resource_size_t size)
> > +{
> > +#ifdef PCI_IOBASE
> > + struct io_range *res;
>
> I was confused by the variable naming here: A variable named 'res' is
> normally a 'struct resource'. Maybe better call this 'range'.
>
> > + resource_size_t allocated_size = 0;
> > +
> > + /* check if the range hasn't been previously recorded */
> > + list_for_each_entry(res, &io_range_list, list) {
> > + if (addr >= res->start && addr + size <= res->start + size)
> > + return 0;
> > + allocated_size += res->size;
> > + }
>
> A spin_lock around the list lookup should be sufficient to get around
> the race that Will mentioned.
>
> > + /* range not registed yet, check for available space */
> > + if (allocated_size + size - 1 > IO_SPACE_LIMIT)
> > + return -E2BIG;
>
> It might be better to limit the size to 64K if it doesn't fit at first.
Thanks Arnd for review. Will update and post a new patch soon if I don't
get any other comments.
Best regards,
Liviu
>
>
> Arnd
>
>
--
====================
| I would like to |
| fix the world, |
| but they're not |
| giving me the |
\ source code! /
---------------
¯\_(ツ)_/¯
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists