]> git.openfabrics.org - ~shefty/rdma-dev.git/commitdiff
PCI: Make rescan bus increase bridge resource size if needed
authorYinghai Lu <yinghai@kernel.org>
Sat, 21 Jan 2012 10:08:22 +0000 (02:08 -0800)
committerJesse Barnes <jbarnes@virtuousgeek.org>
Tue, 14 Feb 2012 16:44:53 +0000 (08:44 -0800)
Current rescan will not touch bridge MMIO and IO.

Try to reuse pci_assign_unassigned_bridge_resources(bridge) to update bridge
resources, if child devices need more resources.

Only do that for bridges whose children are all removed already; i.e. don't
release resources that could already be in use by drivers on child devices.

Signed-off-by: Yinghai Lu <yinghai@kernel.org>
Signed-off-by: Jesse Barnes <jbarnes@virtuousgeek.org>
drivers/pci/pci-sysfs.c
drivers/pci/probe.c
include/linux/pci.h

index a3cd8cad532ac218c2b1055f21e27d6e2bec696e..d9723039e99ae32407f04398f51ed978082d4fe8 100644 (file)
@@ -366,7 +366,10 @@ dev_bus_rescan_store(struct device *dev, struct device_attribute *attr,
 
        if (val) {
                mutex_lock(&pci_remove_rescan_mutex);
-               pci_rescan_bus(bus);
+               if (!pci_is_root_bus(bus) && list_empty(&bus->devices))
+                       pci_rescan_bus_bridge_resize(bus->self);
+               else
+                       pci_rescan_bus(bus);
                mutex_unlock(&pci_remove_rescan_mutex);
        }
        return count;
index 71eac9cd724d7b12c77d68cc0eb68a3b50a9f287..0e84e8c2a6d0357bf355f40fcedc1314281d8ca8 100644 (file)
@@ -1666,6 +1666,31 @@ struct pci_bus * __devinit pci_scan_bus(int bus, struct pci_ops *ops,
 EXPORT_SYMBOL(pci_scan_bus);
 
 #ifdef CONFIG_HOTPLUG
+/**
+ * pci_rescan_bus_bridge_resize - scan a PCI bus for devices.
+ * @bridge: PCI bridge for the bus to scan
+ *
+ * Scan a PCI bus and child buses for new devices, add them,
+ * and enable them, resizing bridge mmio/io resource if necessary
+ * and possible.  The caller must ensure the child devices are already
+ * removed for resizing to occur.
+ *
+ * Returns the max number of subordinate bus discovered.
+ */
+unsigned int __ref pci_rescan_bus_bridge_resize(struct pci_dev *bridge)
+{
+       unsigned int max;
+       struct pci_bus *bus = bridge->subordinate;
+
+       max = pci_scan_child_bus(bus);
+
+       pci_assign_unassigned_bridge_resources(bridge);
+
+       pci_bus_add_devices(bus);
+
+       return max;
+}
+
 /**
  * pci_rescan_bus - scan a PCI bus for devices.
  * @bus: PCI bus to scan
index f44276049f4a9391dd5535822f632b8fa74d3e2f..87507aadf9a248b68573e42d9ef5e12d4e41d1a7 100644 (file)
@@ -882,6 +882,7 @@ void set_pcie_hotplug_bridge(struct pci_dev *pdev);
 /* Functions for PCI Hotplug drivers to use */
 int pci_bus_find_capability(struct pci_bus *bus, unsigned int devfn, int cap);
 #ifdef CONFIG_HOTPLUG
+unsigned int pci_rescan_bus_bridge_resize(struct pci_dev *bridge);
 unsigned int pci_rescan_bus(struct pci_bus *bus);
 #endif