Skip to content

Commit 10a9574

Browse files
jiangliubjorn-helgaas
authored andcommitted
PCI: Add pcibios hooks for adding and removing PCI buses
On ACPI-based platforms, the pci_slot driver creates PCI slot devices according to information from ACPI tables by registering an ACPI PCI subdriver. The ACPI PCI subdriver will only be called when creating/ destroying PCI root buses, and it won't be called when hot-plugging P2P bridges. It may cause stale PCI slot devices after hot-removing a P2P bridge if that bridge has associated PCI slots. And the acpiphp driver has the same issue too. This patch introduces two hook points into the PCI core, which will be invoked when creating/destroying PCI buses for PCI host and P2P bridges. They could be used to setup/destroy platform dependent stuff in a unified way, both at boot time and for PCI hotplug operations. Signed-off-by: Jiang Liu <jiang.liu@huawei.com> Signed-off-by: Yijing Wang <wangyijing@huawei.com> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com> Reviewed-by: Yinghai Lu <yinghai@kernel.org> Cc: "Rafael J. Wysocki" <rafael.j.wysocki@intel.com> Cc: Toshi Kani <toshi.kani@hp.com> Cc: Tony Luck <tony.luck@intel.com> Cc: Fenghua Yu <fenghua.yu@intel.com> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Ingo Molnar <mingo@redhat.com> Cc: "H. Peter Anvin" <hpa@zytor.com> Cc: Myron Stowe <myron.stowe@redhat.com>
1 parent ce15d87 commit 10a9574

3 files changed

Lines changed: 15 additions & 0 deletions

File tree

‎drivers/pci/probe.c‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -673,6 +673,8 @@ static struct pci_bus *pci_alloc_child_bus(struct pci_bus *parent,
673673
ret = device_register(&child->dev);
674674
WARN_ON(ret < 0);
675675

676+
pcibios_add_bus(child);
677+
676678
/* Create legacy_io and legacy_mem files for this bus */
677679
pci_create_legacy_files(child);
678680

@@ -1660,6 +1662,14 @@ int __weak pcibios_root_bridge_prepare(struct pci_host_bridge *bridge)
16601662
return 0;
16611663
}
16621664

1665+
void __weak pcibios_add_bus(struct pci_bus *bus)
1666+
{
1667+
}
1668+
1669+
void __weak pcibios_remove_bus(struct pci_bus *bus)
1670+
{
1671+
}
1672+
16631673
struct pci_bus *pci_create_root_bus(struct device *parent, int bus,
16641674
struct pci_ops *ops, void *sysdata, struct list_head *resources)
16651675
{
@@ -1714,6 +1724,8 @@ struct pci_bus *pci_create_root_bus(struct device *parent, int bus,
17141724
if (error)
17151725
goto class_dev_reg_err;
17161726

1727+
pcibios_add_bus(b);
1728+
17171729
/* Create legacy_io and legacy_mem files for this bus */
17181730
pci_create_legacy_files(b);
17191731

‎drivers/pci/remove.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ void pci_remove_bus(struct pci_bus *bus)
5151
pci_bus_release_busn_res(bus);
5252
up_write(&pci_bus_sem);
5353
pci_remove_legacy_files(bus);
54+
pcibios_remove_bus(bus);
5455
device_unregister(&bus->dev);
5556
}
5657
EXPORT_SYMBOL(pci_remove_bus);

‎include/linux/pci.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -678,6 +678,8 @@ extern struct list_head pci_root_buses; /* list of all known PCI buses */
678678
extern int no_pci_devices(void);
679679

680680
void pcibios_resource_survey_bus(struct pci_bus *bus);
681+
void pcibios_add_bus(struct pci_bus *bus);
682+
void pcibios_remove_bus(struct pci_bus *bus);
681683
void pcibios_fixup_bus(struct pci_bus *);
682684
int __must_check pcibios_enable_device(struct pci_dev *, int mask);
683685
/* Architecture specific versions may override this (weak) */

0 commit comments

Comments
 (0)