[RFC,08/11] PCI: Allow expanding the bridges
diff mbox series

Message ID 20191024172157.878735-9-s.miroshnichenko@yadro.com
State New
Delegated to: Bjorn Helgaas
Headers show
Series
  • PCI: hotplug: Movable bus numbers
Related show

Commit Message

Sergei Miroshnichenko Oct. 24, 2019, 5:21 p.m. UTC
When hotplugging a bridge, the parent bus may not have [enough] reserved
bus numbers. So before rescanning the bus, set its subordinate number to
the maximum possible value: it is 255 when there is only one root bridge
in the domain.

During the PCI rescan, the subordinate bus number of every bus will be
contracted to the actual value.

Signed-off-by: Sergey Miroshnichenko <s.miroshnichenko@yadro.com>
---
 drivers/pci/probe.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

Patch
diff mbox series

diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index 539f5d39bb6d..3494b5d265d5 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -3195,20 +3195,22 @@  static unsigned int pci_dev_count_res_mask(struct pci_dev *dev)
 	return res_mask;
 }
 
-static void pci_bus_rescan_prepare(struct pci_bus *bus)
+static void pci_bus_rescan_prepare(struct pci_bus *bus, int last_bus_number)
 {
 	struct pci_dev *dev;
 
 	if (bus->self)
 		pci_config_pm_runtime_get(bus->self);
 
+	bus->busn_res.end = last_bus_number;
+
 	list_for_each_entry(dev, &bus->devices, bus_list) {
 		struct pci_bus *child = dev->subordinate;
 
 		dev->res_mask = pci_dev_count_res_mask(dev);
 
 		if (child)
-			pci_bus_rescan_prepare(child);
+			pci_bus_rescan_prepare(child, last_bus_number);
 
 		if (dev->driver &&
 		    dev->driver->rescan_prepare)
@@ -3439,7 +3441,7 @@  unsigned int pci_rescan_bus(struct pci_bus *bus)
 
 	if (pci_can_move_bars) {
 		pcibios_root_bus_rescan_prepare(root);
-		pci_bus_rescan_prepare(root);
+		pci_bus_rescan_prepare(root, root->busn_res.end);
 		pci_bus_update_immovable_range(root);
 		pci_bus_release_root_bridge_resources(root);