diff options
author | Yinghai Lu <yinghai@kernel.org> | 2012-01-21 05:08:22 -0500 |
---|---|---|
committer | Jesse Barnes <jbarnes@virtuousgeek.org> | 2012-02-14 11:44:53 -0500 |
commit | 2f320521a0d2d11fb857be09d05e2fbbf3ef8c13 (patch) | |
tree | 9b8d91f3d64f383405511c33fd4d9c5d4aaa20c2 | |
parent | 8424d7592eab8245b51051ee458e598213bca3b2 (diff) |
PCI: Make rescan bus increase bridge resource size if needed
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>
-rw-r--r-- | drivers/pci/pci-sysfs.c | 5 | ||||
-rw-r--r-- | drivers/pci/probe.c | 25 | ||||
-rw-r--r-- | include/linux/pci.h | 1 |
3 files changed, 30 insertions, 1 deletions
diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c index a3cd8cad532a..d9723039e99a 100644 --- a/drivers/pci/pci-sysfs.c +++ b/drivers/pci/pci-sysfs.c | |||
@@ -366,7 +366,10 @@ dev_bus_rescan_store(struct device *dev, struct device_attribute *attr, | |||
366 | 366 | ||
367 | if (val) { | 367 | if (val) { |
368 | mutex_lock(&pci_remove_rescan_mutex); | 368 | mutex_lock(&pci_remove_rescan_mutex); |
369 | pci_rescan_bus(bus); | 369 | if (!pci_is_root_bus(bus) && list_empty(&bus->devices)) |
370 | pci_rescan_bus_bridge_resize(bus->self); | ||
371 | else | ||
372 | pci_rescan_bus(bus); | ||
370 | mutex_unlock(&pci_remove_rescan_mutex); | 373 | mutex_unlock(&pci_remove_rescan_mutex); |
371 | } | 374 | } |
372 | return count; | 375 | return count; |
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c index 71eac9cd724d..0e84e8c2a6d0 100644 --- a/drivers/pci/probe.c +++ b/drivers/pci/probe.c | |||
@@ -1667,6 +1667,31 @@ EXPORT_SYMBOL(pci_scan_bus); | |||
1667 | 1667 | ||
1668 | #ifdef CONFIG_HOTPLUG | 1668 | #ifdef CONFIG_HOTPLUG |
1669 | /** | 1669 | /** |
1670 | * pci_rescan_bus_bridge_resize - scan a PCI bus for devices. | ||
1671 | * @bridge: PCI bridge for the bus to scan | ||
1672 | * | ||
1673 | * Scan a PCI bus and child buses for new devices, add them, | ||
1674 | * and enable them, resizing bridge mmio/io resource if necessary | ||
1675 | * and possible. The caller must ensure the child devices are already | ||
1676 | * removed for resizing to occur. | ||
1677 | * | ||
1678 | * Returns the max number of subordinate bus discovered. | ||
1679 | */ | ||
1680 | unsigned int __ref pci_rescan_bus_bridge_resize(struct pci_dev *bridge) | ||
1681 | { | ||
1682 | unsigned int max; | ||
1683 | struct pci_bus *bus = bridge->subordinate; | ||
1684 | |||
1685 | max = pci_scan_child_bus(bus); | ||
1686 | |||
1687 | pci_assign_unassigned_bridge_resources(bridge); | ||
1688 | |||
1689 | pci_bus_add_devices(bus); | ||
1690 | |||
1691 | return max; | ||
1692 | } | ||
1693 | |||
1694 | /** | ||
1670 | * pci_rescan_bus - scan a PCI bus for devices. | 1695 | * pci_rescan_bus - scan a PCI bus for devices. |
1671 | * @bus: PCI bus to scan | 1696 | * @bus: PCI bus to scan |
1672 | * | 1697 | * |
diff --git a/include/linux/pci.h b/include/linux/pci.h index f44276049f4a..87507aadf9a2 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h | |||
@@ -882,6 +882,7 @@ void set_pcie_hotplug_bridge(struct pci_dev *pdev); | |||
882 | /* Functions for PCI Hotplug drivers to use */ | 882 | /* Functions for PCI Hotplug drivers to use */ |
883 | int pci_bus_find_capability(struct pci_bus *bus, unsigned int devfn, int cap); | 883 | int pci_bus_find_capability(struct pci_bus *bus, unsigned int devfn, int cap); |
884 | #ifdef CONFIG_HOTPLUG | 884 | #ifdef CONFIG_HOTPLUG |
885 | unsigned int pci_rescan_bus_bridge_resize(struct pci_dev *bridge); | ||
885 | unsigned int pci_rescan_bus(struct pci_bus *bus); | 886 | unsigned int pci_rescan_bus(struct pci_bus *bus); |
886 | #endif | 887 | #endif |
887 | 888 | ||