linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: oza.oza@broadcom.com (Oza Oza)
To: linux-arm-kernel@lists.infradead.org
Subject: [RFC/RFT PATCH 03/18] PCI: Introduce pci_scan_root_bus_bridge()
Date: Tue, 30 May 2017 16:46:26 +0530	[thread overview]
Message-ID: <CAMSpPPeX9zta8hNYqV_F1QzEBPEm--eiUfpGVqsnNJEOK7X6CA@mail.gmail.com> (raw)
In-Reply-To: <20170526130748.GB27131@red-moon>

On Fri, May 26, 2017 at 6:37 PM, Lorenzo Pieralisi
<lorenzo.pieralisi@arm.com> wrote:
> On Thu, May 25, 2017 at 03:56:43PM -0500, Bjorn Helgaas wrote:
>> [+cc Ray, Scott, Jon]
>>
>> On Tue, May 02, 2017 at 06:15:01PM +0100, Lorenzo Pieralisi wrote:
>> > On Fri, Apr 28, 2017 at 02:28:38PM +0200, Arnd Bergmann wrote:
>> > > On Wed, Apr 26, 2017 at 1:17 PM, Lorenzo Pieralisi
>> > > <lorenzo.pieralisi@arm.com> wrote:
>> > > > Current pci_scan_root_bus() interface is made up of two main
>> > > > code paths:
>> > > >
>> > > > - pci_create_root_bus()
>> > > > - pci_scan_child_bus()
>> > > >
>> > > > pci_create_root_bus() is a wrapper function that allows to create
>> > > > a struct pci_host_bridge structure, initialize it with the passed
>> > > > parameters and register it with the kernel.
>> > > >
>> > > > As the struct pci_host_bridge require additional struct members,
>> > > > pci_create_root_bus() parameters list has grown in time, making
>> > > > it unwieldy to add further parameters to it in case the struct
>> > > > pci_host_bridge gains more members fields to augment its functionality.
>> > > >
>> > > > Since PCI core code provides functions to allocate struct
>> > > > pci_host_bridge, instead of forcing the pci_create_root_bus() interface
>> > > > to add new parameters to cater for new struct pci_host_bridge
>> > > > functionality, it is more suitable to add an interface in PCI
>> > > > core code to scan a PCI bus straight from a struct pci_host_bridge
>> > > > created and customized by each specific PCI host controller driver.
>> > > >
>> > > > Add a pci_scan_root_bus_bridge() function to allow PCI host controller
>> > > > drivers to create and initialize struct pci_host_bridge and scan
>> > > > the resulting bus.
>> > > >
>> > > > Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
>> > > > Cc: Arnd Bergmann <arnd@arndb.de>
>> > > > Cc: Bjorn Helgaas <bhelgaas@google.com>
>> > >
>> > > Good idea, yes. To avoid growing the number of interfaces too
>> > > much, should we change the existing users of pci_register_host_bridge
>> > > in host drivers over to this entry point, and make the other one
>> > > local to probe.c then?
>> >
>> > Yes, the problem is that there are drivers (ie pcie-iproc.c) that
>> > require the struct pci_bus (created by pci_register_host_bridge())
>> > to fiddle with it to check link status and THEN scan the bus (so
>> > the pci_register_host_bridge() call can't be embedded in the scan
>> > interface - the driver requires struct pci_bus for pci_ops to work
>> > before scanning the bus itself).
>>
>> I think code like iproc_pcie_check_link() that requires a struct
>> pci_bus before we even scan the bus is lame.  I think the driver
>> should be able to bring up the link before telling the PCI core about
>> the bridge.  Aardvark uses a typical pattern:
>>
>>   advk_pcie_probe
>>     advk_pcie_setup_hw
>>       advk_pcie_wait_for_link
>>     pci_scan_root_bus
>>
>> I would rather see iproc restructured along that line than add a
>> callback.
>>
>> That would require replacing the pci_bus_read_config uses in
>> iproc_pcie_check_link() with something different, maybe iproc-internal
>> accessors.  Slightly messy, but I think doable.
>
> I agree with you, it probably requires some cfg space accessors copy
> and paste though but that's doable. I can write the patch myself but
> I can't test it so help is appreciated here.
>
> Thanks,
> Lorenzo
>
>> > I will see how I can accommodate this change because you definitely
>> > have a point.
>> >
>> > > > diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
>> > > > index 7e4ffc4..c7a7f72 100644
>> > > > --- a/drivers/pci/probe.c
>> > > > +++ b/drivers/pci/probe.c
>> > > > @@ -2412,6 +2412,44 @@ void pci_bus_release_busn_res(struct pci_bus *b)
>> > > >                         res, ret ? "can not be" : "is");
>> > > >  }
>> > > >
>> > > > +int pci_scan_root_bus_bridge(struct pci_host_bridge *bridge)
>> > > > +{
>> > > > +       struct resource_entry *window;
>> > > > +       bool found = false;
>> > > > +       struct pci_bus *b;
>> > > > +       int max, bus, ret;
>> > > > +
>> > > > +       if (!bridge)
>> > > > +               return -EINVAL;
>> > > > +
>> > > > +       resource_list_for_each_entry(window, &bridge->windows)
>> > > > +               if (window->res->flags & IORESOURCE_BUS) {
>> > > > +                       found = true;
>> > > > +                       break;
>> > > > +               }
>> > > > +
>> > > > +       ret = pci_register_host_bridge(bridge);
>> > > > +       if (ret < 0)
>> > > > +               return ret;
>> > > > +
>> > > > +       b = bridge->bus;
>> > > > +       bus = bridge->busnr;
>> > > > +
>> > > > +       if (!found) {
>> > > > +               dev_info(&b->dev,
>> > > > +                "No busn resource found for root bus, will use [bus %02x-ff]\n",
>> > > > +                       bus);
>> > > > +               pci_bus_insert_busn_res(b, bus, 255);
>> > > > +       }
>> > > > +
>> > > > +       max = pci_scan_child_bus(b);
>> > > > +
>> > > > +       if (!found)
>> > > > +               pci_bus_update_busn_res_end(b, max);
>> > > > +
>> > > > +       return 0;
>> > > > +}
>> > > > +
>> > >
>> > > We probably want an EXPORT_SYMBOL() here as well.
>> >
>> > Yep, sure.
>> >
>> > Thanks for having a look !
>> >
>> > Lorenzo
>> >
>> > _______________________________________________
>> > linux-arm-kernel mailing list
>> > linux-arm-kernel at lists.infradead.org
>> > http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
>
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel


Hi,

This is good idea,
because the following patch of mine attempts to add inbound windows,
and I had to create another API pci_create_root_bus2

[PATCH v7 2/3] PCI: Add support for PCI inbound windows resources

Lorenzo : Once this API is ready, please send it across.
I can test it with respect to inbound resources and IOVA reservation
on our platform.

Regards,
Oza.

  parent reply	other threads:[~2017-05-30 11:16 UTC|newest]

Thread overview: 50+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-26 11:17 [RFC/RFT PATCH 00/18] PCI: ARM/ARM64: remove pci_fixup_irqs() usage Lorenzo Pieralisi
2017-04-26 11:17 ` [RFC/RFT PATCH 01/18] PCI: Initialize bridge release function at bridge allocation Lorenzo Pieralisi
2017-04-28 12:13   ` Arnd Bergmann
2017-04-26 11:17 ` [RFC/RFT PATCH 02/18] PCI: Add pci_free_host_bridge interface Lorenzo Pieralisi
2017-04-28 12:14   ` Arnd Bergmann
2017-04-26 11:17 ` [RFC/RFT PATCH 03/18] PCI: Introduce pci_scan_root_bus_bridge() Lorenzo Pieralisi
2017-04-28 12:28   ` Arnd Bergmann
2017-05-02 17:15     ` Lorenzo Pieralisi
2017-05-02 19:36       ` Arnd Bergmann
2017-05-25 20:56       ` Bjorn Helgaas
2017-05-26 13:07         ` Lorenzo Pieralisi
2017-05-26 17:29           ` Ray Jui
2017-05-31 10:20             ` Lorenzo Pieralisi
2017-05-30 11:16           ` Oza Oza [this message]
2017-05-31 11:13         ` Lorenzo Pieralisi
2017-04-26 11:17 ` [RFC/RFT PATCH 04/18] ARM: PCI: bios32: Convert PCI scan API to pci_scan_root_bus_bridge() Lorenzo Pieralisi
2017-04-28 12:41   ` Arnd Bergmann
2017-04-26 11:17 ` [RFC/RFT PATCH 05/18] ARM: PCI: dove: " Lorenzo Pieralisi
2017-04-28 12:38   ` Arnd Bergmann
2017-04-28 12:52     ` Arnd Bergmann
2017-05-03 10:31     ` Lorenzo Pieralisi
2017-05-03 12:02       ` Arnd Bergmann
2017-04-26 11:17 ` [RFC/RFT PATCH 06/18] ARM: PCI: iop13xx: " Lorenzo Pieralisi
2017-04-26 11:17 ` [RFC/RFT PATCH 07/18] ARM: PCI: orion5x: " Lorenzo Pieralisi
2017-04-26 15:12   ` Andrew Lunn
2017-04-26 16:13     ` Lorenzo Pieralisi
2017-04-26 18:53       ` Andrew Lunn
2017-04-27 10:40         ` Lorenzo Pieralisi
2017-04-26 11:17 ` [RFC/RFT PATCH 08/18] PCI: designware: " Lorenzo Pieralisi
2017-04-28 13:13   ` Arnd Bergmann
2017-05-03 10:16     ` Lorenzo Pieralisi
2017-06-02 11:49     ` Lorenzo Pieralisi
2017-06-02 13:12       ` Arnd Bergmann
2017-06-02 13:56         ` Lorenzo Pieralisi
2017-06-02 14:44           ` Arnd Bergmann
2017-04-26 11:18 ` [RFC/RFT PATCH 09/18] PCI: aardvark: " Lorenzo Pieralisi
2017-04-26 11:18 ` [RFC/RFT PATCH 10/18] PCI: rcar: " Lorenzo Pieralisi
2017-04-28 12:53   ` Arnd Bergmann
2017-04-26 11:18 ` [RFC/RFT PATCH 11/18] PCI: Remove pci_scan_root_bus_msi() Lorenzo Pieralisi
2017-04-26 11:18 ` [RFC/RFT PATCH 12/18] PCI: Build setup-irq.o on all arches Lorenzo Pieralisi
2017-04-26 11:18 ` [RFC/RFT PATCH 13/18] PCI: Add IRQ mapping function pointers to pci_host_bridge struct Lorenzo Pieralisi
2017-04-26 11:18 ` [RFC/RFT PATCH 14/18] PCI: Add pci_assign_irq() function and have pci_fixup_irqs() use it Lorenzo Pieralisi
2017-04-26 11:18 ` [RFC/RFT PATCH 15/18] OF/PCI: Update of_irq_parse_and_map_pci() comment Lorenzo Pieralisi
2017-04-26 11:18 ` [RFC/RFT PATCH 16/18] PCI: Add a call to pci_assign_irq() in pci_device_probe() Lorenzo Pieralisi
2017-04-26 11:18 ` [RFC/RFT PATCH 17/18] ARM: PCI: Remove pci_fixup_irqs() call for bios32 host controllers Lorenzo Pieralisi
2017-04-26 11:18 ` [RFC/RFT PATCH 18/18] ARM/ARM64: PCI: Drop pci_fixup_irqs() usage for DT based " Lorenzo Pieralisi
2017-04-28 13:05   ` Arnd Bergmann
2017-05-03 10:51     ` Lorenzo Pieralisi
2017-04-27 20:06 ` [RFC/RFT PATCH 00/18] PCI: ARM/ARM64: remove pci_fixup_irqs() usage Thierry Reding
2017-05-03 10:34   ` Lorenzo Pieralisi

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=CAMSpPPeX9zta8hNYqV_F1QzEBPEm--eiUfpGVqsnNJEOK7X6CA@mail.gmail.com \
    --to=oza.oza@broadcom.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    /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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).