aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pci/hotplug
diff options
context:
space:
mode:
authorAmos Kong <kongjianjun@gmail.com>2012-05-23 12:20:35 -0400
committerBjorn Helgaas <bhelgaas@google.com>2012-06-13 18:38:10 -0400
commitce29ca3ea40744f24c2b5d88431e8ac566d257cc (patch)
treef5b56902875f1f9e4e9ea9baa0dfc35e22d54b05 /drivers/pci/hotplug
parent638f293307b5787b69bf0a0bc915aed491efbec9 (diff)
PCI: acpiphp: remove all functions in slot, even without ACPI _EJx
When we add a device with acpiphp, we enumerate all functions in the slot with pci_scan_slot(), regardless of whether they have associated ACPI methods such as _EJ0. When removing the device, we previously removed only the functions with those ACPI methods. This patch makes the remove symmetric with the add: we remove all functions in the slot, whether they have associated ACPI methods or not. With qemu-kvm and SeaBIOS, we can build a multi-function device where only function 0 has _EJ0 and _ADR (see bugzilla below). Removing and re-adding that slot (including all functions of the device) works correctly with Windows guests. This patch makes it also work in Linux guests. [bhelgaas: restructure loop iteration, pull out of slot->funcs loop] Reference: https://bugzilla.kernel.org/show_bug.cgi?id=43219 Signed-off-by: Amos Kong <kongjianjun@gmail.com> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Diffstat (limited to 'drivers/pci/hotplug')
-rw-r--r--drivers/pci/hotplug/acpiphp_glue.c42
1 files changed, 32 insertions, 10 deletions
diff --git a/drivers/pci/hotplug/acpiphp_glue.c b/drivers/pci/hotplug/acpiphp_glue.c
index c8f99910276..73af3374e91 100644
--- a/drivers/pci/hotplug/acpiphp_glue.c
+++ b/drivers/pci/hotplug/acpiphp_glue.c
@@ -878,6 +878,24 @@ static void disable_bridges(struct pci_bus *bus)
878 } 878 }
879} 879}
880 880
881/* return first device in slot, acquiring a reference on it */
882static struct pci_dev *dev_in_slot(struct acpiphp_slot *slot)
883{
884 struct pci_bus *bus = slot->bridge->pci_bus;
885 struct pci_dev *dev;
886 struct pci_dev *ret = NULL;
887
888 down_read(&pci_bus_sem);
889 list_for_each_entry(dev, &bus->devices, bus_list)
890 if (PCI_SLOT(dev->devfn) == slot->device) {
891 ret = pci_dev_get(dev);
892 break;
893 }
894 up_read(&pci_bus_sem);
895
896 return ret;
897}
898
881/** 899/**
882 * disable_device - disable a slot 900 * disable_device - disable a slot
883 * @slot: ACPI PHP slot 901 * @slot: ACPI PHP slot
@@ -902,18 +920,22 @@ static int disable_device(struct acpiphp_slot *slot)
902 (u32)1, NULL, NULL); 920 (u32)1, NULL, NULL);
903 func->bridge = NULL; 921 func->bridge = NULL;
904 } 922 }
923 }
905 924
906 pdev = pci_get_slot(slot->bridge->pci_bus, 925 /*
907 PCI_DEVFN(slot->device, func->function)); 926 * enable_device() enumerates all functions in this device via
908 if (pdev) { 927 * pci_scan_slot(), whether they have associated ACPI hotplug
909 pci_stop_bus_device(pdev); 928 * methods (_EJ0, etc.) or not. Therefore, we remove all functions
910 if (pdev->subordinate) { 929 * here.
911 disable_bridges(pdev->subordinate); 930 */
912 pci_disable_device(pdev); 931 while ((pdev = dev_in_slot(slot))) {
913 } 932 pci_stop_bus_device(pdev);
914 __pci_remove_bus_device(pdev); 933 if (pdev->subordinate) {
915 pci_dev_put(pdev); 934 disable_bridges(pdev->subordinate);
935 pci_disable_device(pdev);
916 } 936 }
937 __pci_remove_bus_device(pdev);
938 pci_dev_put(pdev);
917 } 939 }
918 940
919 list_for_each_entry(func, &slot->funcs, sibling) { 941 list_for_each_entry(func, &slot->funcs, sibling) {