[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAL_JsqKJ6bfPuOofo4grVm3qW_WOpUzcS1juZvHxZdFyyF_19A@mail.gmail.com>
Date: Fri, 26 Sep 2014 16:53:26 -0500
From: Rob Herring <robherring2@...il.com>
To: Rob Herring <robherring2@...il.com>,
Liviu Dudau <Liviu.Dudau@....com>,
Bjorn Helgaas <bhelgaas@...gle.com>,
Arnd Bergmann <arnd@...db.de>,
Rob Herring <robh+dt@...nel.org>,
Jason Gunthorpe <jgunthorpe@...idianresearch.com>,
Benjamin Herrenschmidt <benh@...nel.crashing.org>,
Catalin Marinas <catalin.marinas@....com>,
Will Deacon <Will.Deacon@....com>,
Russell King <linux@....linux.org.uk>,
linux-pci <linux-pci@...r.kernel.org>,
Linus Walleij <linus.walleij@...aro.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>,
linux-arch <linux-arch@...r.kernel.org>,
LKML <linux-kernel@...r.kernel.org>,
Device Tree ML <devicetree@...r.kernel.org>,
LAKML <linux-arm-kernel@...ts.infradead.org>,
Grant Likely <grant.likely@...aro.org>
Subject: Re: [PATCH v12 08/12] PCI: OF: Introduce helper function for
retrieving PCI domain numbers
On Fri, Sep 26, 2014 at 4:20 PM, <liviu@...au.co.uk> wrote:
> On Fri, Sep 26, 2014 at 01:20:39PM -0500, Rob Herring wrote:
>> On Tue, Sep 23, 2014 at 2:01 PM, Liviu Dudau <Liviu.Dudau@....com> wrote:
>> > Add pci_get_new_domain_nr() to allocate a new domain number
>> > and of_get_pci_domain_nr() to retrieve the PCI domain number
>> > of a given device from DT. Host bridge drivers or architecture
>> > specific code can choose to implement their PCI domain number
>> > policy using these two functions.
>> >
>> > Using of_get_pci_domain_nr() guarantees a stable PCI domain
>> > number on every boot provided that all host bridge controllers
>> > are assigned a number in the device tree using "linux,pci-domain"
>> > property. Mix use of pci_get_new_domain_nr() and of_get_pci_domain_nr()
>> > is not recommended as it can lead to potentially conflicting
>> > domain numbers being assigned to root busses behind different
>> > host bridges.
>> >
>> > Cc: Bjorn Helgaas <bhelgaas@...gle.com>
>> > Cc: Arnd Bergmann <arnd@...db.de>
>> > Cc: Grant Likely <grant.likely@...aro.org>
>> > Cc: Rob Herring <robh+dt@...nel.org>
>> > Cc: Catalin Marinas <catalin.marinas@....com>
>> > Signed-off-by: Liviu Dudau <Liviu.Dudau@....com>
>>
>> Looks pretty good, but a couple of comments that can be addressed as
>> follow-up patches.
>>
>> > ---
>> > drivers/of/of_pci.c | 25 +++++++++++++++++++++++++
>> > drivers/pci/pci.c | 9 +++++++++
>> > include/linux/of_pci.h | 7 +++++++
>> > include/linux/pci.h | 3 +++
>> > 4 files changed, 44 insertions(+)
>> >
>> > diff --git a/drivers/of/of_pci.c b/drivers/of/of_pci.c
>> > index 8481996..82d172f 100644
>> > --- a/drivers/of/of_pci.c
>> > +++ b/drivers/of/of_pci.c
>> > @@ -89,6 +89,31 @@ int of_pci_parse_bus_range(struct device_node *node, struct resource *res)
>> > }
>> > EXPORT_SYMBOL_GPL(of_pci_parse_bus_range);
>> >
>> > +/**
>> > + * This function will try to obtain the host bridge domain number by
>> > + * finding a property called "linux,pci-domain" of the given device node.
>> > + *
>> > + * @node: device tree node with the domain information
>> > + *
>> > + * Returns the associated domain number from DT in the range [0-0xffff], or
>> > + * a negative value if the required property is not found.
>> > + */
>> > +int of_get_pci_domain_nr(struct device_node *node)
>> > +{
>> > + const __be32 *value;
>> > + int len;
>> > + u16 domain;
>> > +
>> > + value = of_get_property(node, "linux,pci-domain", &len);
>>
>> This needs to be documented.
>
> I would say needs agreed on *and* documented.
I thought Bjorn already applied the series. Who's agreement are you
waiting for specifically.
>>
>> > + if (!value || len < sizeof(*value))
>> > + return -EINVAL;
>> > +
>> > + domain = (u16)be32_to_cpup(value);
>>
>> of_property_read_u32 would not work here?
>
> It should, I guess, but I want to limit the domain number range to 16 bits.
Okay, but it would still be fewer lines to use of_property_read_u32
and then cast it. You could use the u16 variant and make the property
be defined to be 16-bit in the documentation.
Rob
--
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