acpi: unneccessary to scan the PCI bus already scanned
[sfrench/cifs-2.6.git] / arch / x86 / pci / acpi.c
index 2d88f7c6d6ac901a3f2f2ffe2f64f680706b435a..378136fb50447b86e9257655bddfe34578b94405 100644 (file)
@@ -13,7 +13,7 @@ static int __devinit can_skip_ioresource_align(const struct dmi_system_id *d)
        return 0;
 }
 
-static struct dmi_system_id acpi_pciprobe_dmi_table[] = {
+static struct dmi_system_id acpi_pciprobe_dmi_table[] __devinitdata = {
 /*
  * Systems where PCI IO resource ISA alignment can be skipped
  * when the ISA enable bit in the bridge control is not set
@@ -77,6 +77,9 @@ count_resource(struct acpi_resource *acpi_res, void *data)
        struct acpi_resource_address64 addr;
        acpi_status status;
 
+       if (info->res_num >= PCI_BUS_NUM_RESOURCES)
+               return AE_OK;
+
        status = resource_to_addr(acpi_res, &addr);
        if (ACPI_SUCCESS(status))
                info->res_num++;
@@ -93,6 +96,9 @@ setup_resource(struct acpi_resource *acpi_res, void *data)
        unsigned long flags;
        struct resource *root;
 
+       if (info->res_num >= PCI_BUS_NUM_RESOURCES)
+               return AE_OK;
+
        status = resource_to_addr(acpi_res, &addr);
        if (!ACPI_SUCCESS(status))
                return AE_OK;
@@ -213,8 +219,21 @@ struct pci_bus * __devinit pci_acpi_scan_root(struct acpi_device *device, int do
        if (pxm >= 0)
                sd->node = pxm_to_node(pxm);
 #endif
+       /*
+        * Maybe the desired pci bus has been already scanned. In such case
+        * it is unnecessary to scan the pci bus with the given domain,busnum.
+        */
+       bus = pci_find_bus(domain, busnum);
+       if (bus) {
+               /*
+                * If the desired bus exits, the content of bus->sysdata will
+                * be replaced by sd.
+                */
+               memcpy(bus->sysdata, sd, sizeof(*sd));
+               kfree(sd);
+       } else
+               bus = pci_scan_bus_parented(NULL, busnum, &pci_root_ops, sd);
 
-       bus = pci_scan_bus_parented(NULL, busnum, &pci_root_ops, sd);
        if (!bus)
                kfree(sd);
 
@@ -222,7 +241,7 @@ struct pci_bus * __devinit pci_acpi_scan_root(struct acpi_device *device, int do
        if (bus != NULL) {
                if (pxm >= 0) {
                        printk("bus %d -> pxm %d -> node %d\n",
-                               busnum, pxm, sd->node);
+                               busnum, pxm, pxm_to_node(pxm));
                }
        }
 #endif