PCI: acpiphp: Add is_hotplug_bridge detection
authorYinghai Lu <yinghai@kernel.org>
Mon, 21 Jan 2013 21:20:42 +0000 (13:20 -0800)
committerBjorn Helgaas <bhelgaas@google.com>
Fri, 25 Jan 2013 18:30:47 +0000 (11:30 -0700)
When system support hotplug bridge with children hotplug slots, we need
to make sure that parent bridge get preallocated resource so later when
device is plugged into children slot, those children devices will get
resource allocated.

We do not meet this problem, because for PCIe hotplug card, when acpiphp
is used, pci_scan_bridge will set that for us when detect hotplug bit in
slot cap.

Reported-and-tested-by: Jason Baron <jbaron@redhat.com>
Signed-off-by: Yinghai Lu <yinghai@kernel.org>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Jason Baron <jbaron@redhat.com>
Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
drivers/pci/hotplug/acpiphp_glue.c

index 9e2b1f6dbe41a01cd0e6e571e1b859e6b963069f..b94879d20630d770b9167b1ae73d51ab948502ff 100644 (file)
@@ -797,6 +797,29 @@ static void acpiphp_set_acpi_region(struct acpiphp_slot *slot)
        }
 }
 
+static void check_hotplug_bridge(struct acpiphp_slot *slot, struct pci_dev *dev)
+{
+       struct acpiphp_func *func;
+
+       if (!dev->subordinate)
+               return;
+
+       /* quirk, or pcie could set it already */
+       if (dev->is_hotplug_bridge)
+               return;
+
+       if (PCI_SLOT(dev->devfn) != slot->device)
+               return;
+
+       list_for_each_entry(func, &slot->funcs, sibling) {
+               if (PCI_FUNC(dev->devfn) == func->function) {
+                       /* check if this bridge has ejectable slots */
+                       if ((detect_ejectable_slots(func->handle) > 0))
+                               dev->is_hotplug_bridge = 1;
+                       break;
+               }
+       }
+}
 /**
  * enable_device - enable, configure a slot
  * @slot: slot to be enabled
@@ -831,8 +854,10 @@ static int __ref enable_device(struct acpiphp_slot *slot)
                        if (dev->hdr_type == PCI_HEADER_TYPE_BRIDGE ||
                            dev->hdr_type == PCI_HEADER_TYPE_CARDBUS) {
                                max = pci_scan_bridge(bus, dev, max, pass);
-                               if (pass && dev->subordinate)
+                               if (pass && dev->subordinate) {
+                                       check_hotplug_bridge(slot, dev);
                                        pci_bus_size_bridges(dev->subordinate);
+                               }
                        }
                }
        }