提交 a187177a 编写于 作者: B Bjorn Helgaas

Merge branch 'topic/kong-acpiphp-remove' into next

* topic/kong-acpiphp-remove:
  PCI: acpiphp: remove all functions in slot, even without ACPI _EJx
  PCI: acpiphp: fix function 0 leak when disabling a slot
...@@ -878,6 +878,24 @@ static void disable_bridges(struct pci_bus *bus) ...@@ -878,6 +878,24 @@ static void disable_bridges(struct pci_bus *bus)
} }
} }
/* return first device in slot, acquiring a reference on it */
static struct pci_dev *dev_in_slot(struct acpiphp_slot *slot)
{
struct pci_bus *bus = slot->bridge->pci_bus;
struct pci_dev *dev;
struct pci_dev *ret = NULL;
down_read(&pci_bus_sem);
list_for_each_entry(dev, &bus->devices, bus_list)
if (PCI_SLOT(dev->devfn) == slot->device) {
ret = pci_dev_get(dev);
break;
}
up_read(&pci_bus_sem);
return ret;
}
/** /**
* disable_device - disable a slot * disable_device - disable a slot
* @slot: ACPI PHP slot * @slot: ACPI PHP slot
...@@ -893,6 +911,7 @@ static int disable_device(struct acpiphp_slot *slot) ...@@ -893,6 +911,7 @@ static int disable_device(struct acpiphp_slot *slot)
pdev = pci_get_slot(bus, PCI_DEVFN(slot->device, 0)); pdev = pci_get_slot(bus, PCI_DEVFN(slot->device, 0));
if (!pdev) if (!pdev)
goto err_exit; goto err_exit;
pci_dev_put(pdev);
list_for_each_entry(func, &slot->funcs, sibling) { list_for_each_entry(func, &slot->funcs, sibling) {
if (func->bridge) { if (func->bridge) {
...@@ -901,18 +920,22 @@ static int disable_device(struct acpiphp_slot *slot) ...@@ -901,18 +920,22 @@ static int disable_device(struct acpiphp_slot *slot)
(u32)1, NULL, NULL); (u32)1, NULL, NULL);
func->bridge = NULL; func->bridge = NULL;
} }
}
pdev = pci_get_slot(slot->bridge->pci_bus, /*
PCI_DEVFN(slot->device, func->function)); * enable_device() enumerates all functions in this device via
if (pdev) { * pci_scan_slot(), whether they have associated ACPI hotplug
pci_stop_bus_device(pdev); * methods (_EJ0, etc.) or not. Therefore, we remove all functions
if (pdev->subordinate) { * here.
disable_bridges(pdev->subordinate); */
pci_disable_device(pdev); while ((pdev = dev_in_slot(slot))) {
} pci_stop_bus_device(pdev);
__pci_remove_bus_device(pdev); if (pdev->subordinate) {
pci_dev_put(pdev); disable_bridges(pdev->subordinate);
pci_disable_device(pdev);
} }
__pci_remove_bus_device(pdev);
pci_dev_put(pdev);
} }
list_for_each_entry(func, &slot->funcs, sibling) { list_for_each_entry(func, &slot->funcs, sibling) {
......
...@@ -15,6 +15,8 @@ ...@@ -15,6 +15,8 @@
#include "pci.h" #include "pci.h"
DECLARE_RWSEM(pci_bus_sem); DECLARE_RWSEM(pci_bus_sem);
EXPORT_SYMBOL_GPL(pci_bus_sem);
/* /*
* find the upstream PCIe-to-PCI bridge of a PCI device * find the upstream PCIe-to-PCI bridge of a PCI device
* if the device is PCIE, return NULL * if the device is PCIE, return NULL
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册