diff options
author | Pali Rohár <pali@kernel.org> | 2022-07-14 20:41:30 +0200 |
---|---|---|
committer | Bjorn Helgaas <bhelgaas@google.com> | 2022-11-08 11:14:18 -0600 |
commit | c14f7ccc9f5dcf9d06ddeec706f85405b2c80600 (patch) | |
tree | 993fc5f8ea8c459ad14955273185733d5bcc09b2 /drivers/pci/remove.c | |
parent | 44e985938e85503d0a69ec538e15fd33c1a4df05 (diff) | |
download | linux-c14f7ccc9f5dcf9d06ddeec706f85405b2c80600.tar.gz linux-c14f7ccc9f5dcf9d06ddeec706f85405b2c80600.tar.bz2 linux-c14f7ccc9f5dcf9d06ddeec706f85405b2c80600.zip |
PCI: Assign PCI domain IDs by ida_alloc()
Replace assignment of PCI domain IDs from atomic_inc_return() to
ida_alloc().
Use two IDAs, one for static domain allocations (those which are defined in
device tree) and second for dynamic allocations (all other).
During removal of root bus / host bridge, also release the domain ID. The
released ID can be reused again, for example when dynamically loading and
unloading native PCI host bridge drivers.
This change also allows to mix static device tree assignment and dynamic by
kernel as all static allocations are reserved in dynamic pool.
[bhelgaas: set "err" if "bus->domain_nr < 0"]
Link: https://lore.kernel.org/r/20220714184130.5436-1-pali@kernel.org
Signed-off-by: Pali Rohár <pali@kernel.org>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Diffstat (limited to 'drivers/pci/remove.c')
-rw-r--r-- | drivers/pci/remove.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/drivers/pci/remove.c b/drivers/pci/remove.c index 4c54c75050dc..0145aef1b930 100644 --- a/drivers/pci/remove.c +++ b/drivers/pci/remove.c @@ -160,6 +160,12 @@ void pci_remove_root_bus(struct pci_bus *bus) pci_remove_bus(bus); host_bridge->bus = NULL; +#ifdef CONFIG_PCI_DOMAINS_GENERIC + /* Release domain_nr if it was dynamically allocated */ + if (host_bridge->domain_nr == PCI_DOMAIN_NR_NOT_SET) + pci_bus_release_domain_nr(bus, host_bridge->dev.parent); +#endif + /* remove the host bridge */ device_del(&host_bridge->dev); } |