mirror of
https://github.com/torvalds/linux.git
synced 2024-11-08 21:21:47 +00:00
2cd6975a4f
x86 has two kinds of PCI root bus scanning: (1) ACPI-based, using _CRS resources. This used pci_create_bus(), not pci_scan_bus(), because ACPI hotplug needed to split the pci_bus_add_devices() into a separate host bridge .start() method. This patch parses the _CRS resources earlier, so we can build a list of resources and pass it to pci_create_root_bus(). Note that as before, we parse the _CRS even if we aren't going to use it so we can print it for debugging purposes. (2) All other, which used either default resources (ioport_resource and iomem_resource) or information read from the hardware via amd_bus.c or similar. This used pci_scan_bus(). This patch converts x86_pci_root_bus_res_quirks() (previously called from pcibios_fixup_bus()) to x86_pci_root_bus_resources(), which builds a list of resources before we call pci_scan_root_bus(). We also use x86_pci_root_bus_resources() if we have ACPI but are ignoring _CRS. CC: Yinghai Lu <yinghai.lu@oracle.com> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com> Signed-off-by: Jesse Barnes <jbarnes@virtuousgeek.org>
107 lines
2.2 KiB
C
107 lines
2.2 KiB
C
#include <linux/init.h>
|
|
#include <linux/pci.h>
|
|
#include <linux/range.h>
|
|
|
|
#include "bus_numa.h"
|
|
|
|
int pci_root_num;
|
|
struct pci_root_info pci_root_info[PCI_ROOT_NR];
|
|
|
|
void x86_pci_root_bus_resources(int bus, struct list_head *resources)
|
|
{
|
|
int i;
|
|
int j;
|
|
struct pci_root_info *info;
|
|
|
|
if (!pci_root_num)
|
|
goto default_resources;
|
|
|
|
for (i = 0; i < pci_root_num; i++) {
|
|
if (pci_root_info[i].bus_min == bus)
|
|
break;
|
|
}
|
|
|
|
if (i == pci_root_num)
|
|
goto default_resources;
|
|
|
|
printk(KERN_DEBUG "PCI: root bus %02x: hardware-probed resources\n",
|
|
bus);
|
|
|
|
info = &pci_root_info[i];
|
|
for (j = 0; j < info->res_num; j++) {
|
|
struct resource *res;
|
|
struct resource *root;
|
|
|
|
res = &info->res[j];
|
|
pci_add_resource(resources, res);
|
|
if (res->flags & IORESOURCE_IO)
|
|
root = &ioport_resource;
|
|
else
|
|
root = &iomem_resource;
|
|
insert_resource(root, res);
|
|
}
|
|
return;
|
|
|
|
default_resources:
|
|
/*
|
|
* We don't have any host bridge aperture information from the
|
|
* "native host bridge drivers," e.g., amd_bus or broadcom_bus,
|
|
* so fall back to the defaults historically used by pci_create_bus().
|
|
*/
|
|
printk(KERN_DEBUG "PCI: root bus %02x: using default resources\n", bus);
|
|
pci_add_resource(resources, &ioport_resource);
|
|
pci_add_resource(resources, &iomem_resource);
|
|
}
|
|
|
|
void __devinit update_res(struct pci_root_info *info, resource_size_t start,
|
|
resource_size_t end, unsigned long flags, int merge)
|
|
{
|
|
int i;
|
|
struct resource *res;
|
|
|
|
if (start > end)
|
|
return;
|
|
|
|
if (start == MAX_RESOURCE)
|
|
return;
|
|
|
|
if (!merge)
|
|
goto addit;
|
|
|
|
/* try to merge it with old one */
|
|
for (i = 0; i < info->res_num; i++) {
|
|
resource_size_t final_start, final_end;
|
|
resource_size_t common_start, common_end;
|
|
|
|
res = &info->res[i];
|
|
if (res->flags != flags)
|
|
continue;
|
|
|
|
common_start = max(res->start, start);
|
|
common_end = min(res->end, end);
|
|
if (common_start > common_end + 1)
|
|
continue;
|
|
|
|
final_start = min(res->start, start);
|
|
final_end = max(res->end, end);
|
|
|
|
res->start = final_start;
|
|
res->end = final_end;
|
|
return;
|
|
}
|
|
|
|
addit:
|
|
|
|
/* need to add that */
|
|
if (info->res_num >= RES_NUM)
|
|
return;
|
|
|
|
res = &info->res[info->res_num];
|
|
res->name = info->name;
|
|
res->flags = flags;
|
|
res->start = start;
|
|
res->end = end;
|
|
res->child = NULL;
|
|
info->res_num++;
|
|
}
|