Thread (17 messages) 17 messages, 4 authors, 2021-07-15

Re: [RFC v4 1/7] PCI: Introduce domain_nr in pci_host_bridge

From: Arnd Bergmann <arnd@arndb.de>
Date: 2021-07-15 19:38:20
Also in: linux-arm-kernel, linux-hyperv, lkml

On Thu, Jul 15, 2021 at 7:30 PM Boqun Feng [off-list ref] wrote:
On Wed, Jul 14, 2021 at 02:33:19PM -0500, Bjorn Helgaas wrote:
quoted
On Wed, Jul 14, 2021 at 06:27:31PM +0800, Boqun Feng wrote:
quoted
 #ifdef CONFIG_PCI_DOMAINS_GENERIC
-   bus->domain_nr = pci_bus_find_domain_nr(bus, parent);
+   if (bridge->domain_nr == PCI_DOMAIN_NR_NOT_SET)
+           bus->domain_nr = pci_bus_find_domain_nr(bus, parent);
+   else
+           bus->domain_nr = bridge->domain_nr;
The domain_nr in struct pci_bus is really only used by
pci_domain_nr().  It seems like it really belongs in the struct
pci_host_bridge and probably doesn't need to be duplicated in the
struct pci_bus.  But that's probably a project for the future.
+1
Agreed. Maybe we can define pci_bus_domain_nr() as:

        static inline int pci_domain_nr(struct pci_bus *bus)
        {
                struct device *bridge = bus->bridge;
                struct pci_host_bridge *b = container_of(bridge, struct pci_host_bridge, dev);

                return b->domain_nr;
        }

but apart from corretness (e.g. should we use get_device() for
bus->bridge?), it makes more sense if ->domain_nr of pci_host_bridge
is used (as a way to set domain number at probing time) for most of
drivers and archs. ;-)
It needs to be "pci_find_host_bridge(bus)" instead of bus->bridge
and container_of().

Then again, if we get pci_domain_nr() to be completely generic, I'd
prefer to change most callers to just open-code the bridge->domain_nr
access, as most of them will already have a pointer to the pci_host_bridge
when calling this.

       Arnd
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help