summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephen Rothwell <sfr@canb.auug.org.au>2010-02-16 18:16:39 +1100
committerStephen Rothwell <sfr@canb.auug.org.au>2010-02-16 18:16:39 +1100
commit4836d02cce0a6a54d8cac2211435d5a410fe4cce (patch)
tree0bf7cc735d3979570a26e434f2998dba1e4c804a
parentb766a27a403e5961d27febf13347bbf8ebed2b8d (diff)
Revert "PCI: replace bus resource table with a list"
This reverts commit 94a8887c501b22a2818ee58197864e9eab983510.
-rw-r--r--arch/alpha/kernel/pci.c5
-rw-r--r--arch/ia64/pci/pci.c20
-rw-r--r--arch/mn10300/unit-asb2305/pci.c7
-rw-r--r--arch/powerpc/kernel/pci-common.c26
-rw-r--r--arch/powerpc/kernel/pci_64.c18
-rw-r--r--arch/powerpc/kernel/pci_of_scan.c7
-rw-r--r--arch/powerpc/platforms/fsl_uli1575.c15
-rw-r--r--arch/x86/pci/acpi.c33
-rw-r--r--arch/x86/pci/bus_numa.c9
-rw-r--r--arch/x86/pci/bus_numa.h3
-rw-r--r--drivers/eisa/pci_eisa.c4
-rw-r--r--drivers/pci/bus.c50
-rw-r--r--drivers/pci/hotplug/shpchp_sysfs.c15
-rw-r--r--drivers/pci/pci.c6
-rw-r--r--drivers/pci/probe.c35
-rw-r--r--drivers/pci/setup-bus.c111
-rw-r--r--drivers/pcmcia/rsrc_nonstatic.c7
-rw-r--r--drivers/pcmcia/yenta_socket.c7
-rw-r--r--include/linux/pci.h16
19 files changed, 175 insertions, 219 deletions
diff --git a/arch/alpha/kernel/pci.c b/arch/alpha/kernel/pci.c
index e4bb1f380b61..c9ab94ee1ca8 100644
--- a/arch/alpha/kernel/pci.c
+++ b/arch/alpha/kernel/pci.c
@@ -292,9 +292,8 @@ pcibios_fixup_bus(struct pci_bus *bus)
u32 sg_base = hose->sg_pci ? hose->sg_pci->dma_base : ~0;
unsigned long end;
- pci_bus_remove_resources(bus);
- pci_bus_add_resource(bus, hose->io_space, 0);
- pci_bus_add_resource(bus, hose->mem_space, 0);
+ bus->resource[0] = hose->io_space;
+ bus->resource[1] = hose->mem_space;
/* Adjust hose mem_space limit to prevent PCI allocations
in the iommu windows. */
diff --git a/arch/ia64/pci/pci.c b/arch/ia64/pci/pci.c
index ad6455446a91..783c83bb2b49 100644
--- a/arch/ia64/pci/pci.c
+++ b/arch/ia64/pci/pci.c
@@ -320,9 +320,9 @@ static __devinit acpi_status add_window(struct acpi_resource *res, void *data)
static void __devinit
pcibios_setup_root_windows(struct pci_bus *bus, struct pci_controller *ctrl)
{
- int i;
+ int i, j;
- pci_bus_remove_resources(bus);
+ j = 0;
for (i = 0; i < ctrl->windows; i++) {
struct resource *res = &ctrl->window[i].resource;
/* HP's firmware has a hack to work around a Windows bug.
@@ -330,7 +330,13 @@ pcibios_setup_root_windows(struct pci_bus *bus, struct pci_controller *ctrl)
if ((res->flags & IORESOURCE_MEM) &&
(res->end - res->start < 16))
continue;
- pci_bus_add_resource(bus, res, 0);
+ if (j >= PCI_BUS_NUM_RESOURCES) {
+ dev_warn(&bus->dev,
+ "ignoring host bridge window %pR (no space)\n",
+ res);
+ continue;
+ }
+ bus->resource[j++] = res;
}
}
@@ -445,15 +451,13 @@ EXPORT_SYMBOL(pcibios_bus_to_resource);
static int __devinit is_valid_resource(struct pci_dev *dev, int idx)
{
- unsigned int type_mask = IORESOURCE_IO | IORESOURCE_MEM;
+ unsigned int i, type_mask = IORESOURCE_IO | IORESOURCE_MEM;
struct resource *devr = &dev->resource[idx];
- struct pci_bus_resource *bus_res;
if (!dev->bus)
return 0;
-
- list_for_each_entry(bus_res, &dev->bus->resources, list) {
- struct resource *busr = bus_res->res;
+ for (i=0; i<PCI_BUS_NUM_RESOURCES; i++) {
+ struct resource *busr = dev->bus->resource[i];
if (!busr || ((busr->flags ^ devr->flags) & type_mask))
continue;
diff --git a/arch/mn10300/unit-asb2305/pci.c b/arch/mn10300/unit-asb2305/pci.c
index 187adccec963..2cb7e75ba1c0 100644
--- a/arch/mn10300/unit-asb2305/pci.c
+++ b/arch/mn10300/unit-asb2305/pci.c
@@ -332,13 +332,12 @@ static int __devinit is_valid_resource(struct pci_dev *dev, int idx)
{
unsigned int i, type_mask = IORESOURCE_IO | IORESOURCE_MEM;
struct resource *devr = &dev->resource[idx];
- struct pci_bus_resource *bus_res;
if (dev->bus) {
- list_for_each_entry(bus_res, &dev->bus->resources, list) {
- struct resource *busr = bus_res->res;
+ for (i = 0; i < PCI_BUS_NUM_RESOURCES; i++) {
+ struct resource *busr = dev->bus->resource[i];
- if ((busr->flags ^ devr->flags) & type_mask)
+ if (!busr || (busr->flags ^ devr->flags) & type_mask)
continue;
if (devr->start &&
diff --git a/arch/powerpc/kernel/pci-common.c b/arch/powerpc/kernel/pci-common.c
index d75546eb15ec..e640810e813f 100644
--- a/arch/powerpc/kernel/pci-common.c
+++ b/arch/powerpc/kernel/pci-common.c
@@ -1042,15 +1042,14 @@ static int __devinit pcibios_uninitialized_bridge_resource(struct pci_bus *bus,
/* Fixup resources of a PCI<->PCI bridge */
static void __devinit pcibios_fixup_bridge(struct pci_bus *bus)
{
- struct pci_bus_resource *bus_res;
struct resource *res;
- int i = -1;
+ int i;
struct pci_dev *dev = bus->self;
- list_for_each_entry(bus_res, &bus->resources, list) {
- i++;
- res = bus_res->res;
+ for (i = 0; i < PCI_BUS_NUM_RESOURCES; ++i) {
+ if ((res = bus->resource[i]) == NULL)
+ continue;
if (!res->flags)
continue;
if (i >= 3 && bus->self->transparent)
@@ -1272,17 +1271,15 @@ static int reparent_resources(struct resource *parent,
void pcibios_allocate_bus_resources(struct pci_bus *bus)
{
struct pci_bus *b;
- int i = -1;
- struct pci_bus_resource *bus_res;
+ int i;
struct resource *res, *pr;
pr_debug("PCI: Allocating bus resources for %04x:%02x...\n",
pci_domain_nr(bus), bus->number);
- list_for_each_entry(bus_res, &bus->resources, list) {
- i++;
- res = bus_res->res;
- if (!res->flags || res->start > res->end || res->parent)
+ for (i = 0; i < PCI_BUS_NUM_RESOURCES; ++i) {
+ if ((res = bus->resource[i]) == NULL || !res->flags
+ || res->start > res->end || res->parent)
continue;
if (bus->parent == NULL)
pr = (res->flags & IORESOURCE_IO) ?
@@ -1582,11 +1579,8 @@ void __devinit pcibios_setup_phb_resources(struct pci_controller *hose)
struct resource *res;
int i;
- pci_bus_remove_resources(bus);
-
/* Hookup PHB IO resource */
- res = &hose->io_resource;
- pci_bus_add_resource(bus, res, 0);
+ bus->resource[0] = res = &hose->io_resource;
if (!res->flags) {
printk(KERN_WARNING "PCI: I/O resource not set for host"
@@ -1621,7 +1615,7 @@ void __devinit pcibios_setup_phb_resources(struct pci_controller *hose)
res->flags = IORESOURCE_MEM;
#endif /* CONFIG_PPC32 */
}
- pci_bus_add_resource(bus, res, 0);
+ bus->resource[i+1] = res;
pr_debug("PCI: PHB MEM resource %d = %016llx-%016llx [%lx]\n", i,
(unsigned long long)res->start,
diff --git a/arch/powerpc/kernel/pci_64.c b/arch/powerpc/kernel/pci_64.c
index 1bd881b613bd..d43fc65749c1 100644
--- a/arch/powerpc/kernel/pci_64.c
+++ b/arch/powerpc/kernel/pci_64.c
@@ -82,7 +82,6 @@ subsys_initcall(pcibios_init);
int pcibios_unmap_io_space(struct pci_bus *bus)
{
- struct pci_dev *bridge = bus->self;
struct pci_controller *hose;
WARN_ON(bus == NULL);
@@ -97,13 +96,13 @@ int pcibios_unmap_io_space(struct pci_bus *bus)
* Note: If we ever support P2P hotplug on Book3E, we'll have
* to do an appropriate TLB flush here too
*/
- if (bridge) {
+ if (bus->self) {
#ifdef CONFIG_PPC_STD_MMU_64
- struct resource *res = &bridge->resource[PCI_BRIDGE_RESOURCES + 0];
+ struct resource *res = bus->resource[0];
#endif
pr_debug("IO unmapping for PCI-PCI bridge %s\n",
- pci_name(bridge));
+ pci_name(bus->self));
#ifdef CONFIG_PPC_STD_MMU_64
__flush_hash_table_range(&init_mm, res->start + _IO_BASE,
@@ -133,7 +132,6 @@ EXPORT_SYMBOL_GPL(pcibios_unmap_io_space);
int __devinit pcibios_map_io_space(struct pci_bus *bus)
{
- struct pci_dev *bridge = bus->self;
struct vm_struct *area;
unsigned long phys_page;
unsigned long size_page;
@@ -145,14 +143,12 @@ int __devinit pcibios_map_io_space(struct pci_bus *bus)
/* If this not a PHB, nothing to do, page tables still exist and
* thus HPTEs will be faulted in when needed
*/
- if (bridge) {
- struct resource *res = &bridge->resource[PCI_BRIDGE_RESOURCES + 0];
-
+ if (bus->self) {
pr_debug("IO mapping for PCI-PCI bridge %s\n",
- pci_name(bridge));
+ pci_name(bus->self));
pr_debug(" virt=0x%016llx...0x%016llx\n",
- res->start + _IO_BASE,
- res->end + _IO_BASE);
+ bus->resource[0]->start + _IO_BASE,
+ bus->resource[0]->end + _IO_BASE);
return 0;
}
diff --git a/arch/powerpc/kernel/pci_of_scan.c b/arch/powerpc/kernel/pci_of_scan.c
index a4f8b68bb2ef..cd11d5ca80df 100644
--- a/arch/powerpc/kernel/pci_of_scan.c
+++ b/arch/powerpc/kernel/pci_of_scan.c
@@ -242,11 +242,10 @@ void __devinit of_scan_pci_bridge(struct device_node *node,
/* parse ranges property */
/* PCI #address-cells == 3 and #size-cells == 2 always */
- pci_bus_remove_resources(bus);
res = &dev->resource[PCI_BRIDGE_RESOURCES];
for (i = 0; i < PCI_NUM_RESOURCES - PCI_BRIDGE_RESOURCES; ++i) {
res->flags = 0;
- pci_bus_add_resource(bus, res, PCI_POSITIVE_DECODE);
+ bus->resource[i] = res;
++res;
}
i = 1;
@@ -256,7 +255,7 @@ void __devinit of_scan_pci_bridge(struct device_node *node,
if (flags == 0 || size == 0)
continue;
if (flags & IORESOURCE_IO) {
- res = &dev->resource[PCI_BRIDGE_RESOURCES + 0];
+ res = bus->resource[0];
if (res->flags) {
printk(KERN_ERR "PCI: ignoring extra I/O range"
" for bridge %s\n", node->full_name);
@@ -268,7 +267,7 @@ void __devinit of_scan_pci_bridge(struct device_node *node,
" for bridge %s\n", node->full_name);
continue;
}
- res = &dev->resource[PCI_BRIDGE_RESOURCES + i];
+ res = bus->resource[i];
++i;
}
res->start = of_read_number(&ranges[1], 2);
diff --git a/arch/powerpc/platforms/fsl_uli1575.c b/arch/powerpc/platforms/fsl_uli1575.c
index 04c546f67e02..fd23a1d4b39d 100644
--- a/arch/powerpc/platforms/fsl_uli1575.c
+++ b/arch/powerpc/platforms/fsl_uli1575.c
@@ -222,8 +222,6 @@ static void __devinit quirk_final_uli5249(struct pci_dev *dev)
int i;
u8 *dummy;
struct pci_bus *bus = dev->bus;
- struct pci_bus_resource *bus_res;
- struct resource *res;
resource_size_t end = 0;
for (i = PCI_BRIDGE_RESOURCES; i < PCI_BRIDGE_RESOURCES+3; i++) {
@@ -232,14 +230,13 @@ static void __devinit quirk_final_uli5249(struct pci_dev *dev)
end = pci_resource_end(dev, i);
}
- list_for_each_entry(bus_res, &bus->resources, list) {
- res = bus_res->res;
-
- if (res->flags & IORESOURCE_MEM) {
- if (res->end == end)
- dummy = ioremap(res->start, 0x4);
+ for (i = 0; i < PCI_BUS_NUM_RESOURCES; i++) {
+ if ((bus->resource[i]) &&
+ (bus->resource[i]->flags & IORESOURCE_MEM)) {
+ if (bus->resource[i]->end == end)
+ dummy = ioremap(bus->resource[i]->start, 0x4);
else
- dummy = ioremap(res->end - 3, 0x4);
+ dummy = ioremap(bus->resource[i]->end - 3, 0x4);
if (dummy) {
in_8(dummy);
iounmap(dummy);
diff --git a/arch/x86/pci/acpi.c b/arch/x86/pci/acpi.c
index a2f8cdb8c1d5..959e548a7039 100644
--- a/arch/x86/pci/acpi.c
+++ b/arch/x86/pci/acpi.c
@@ -45,6 +45,20 @@ count_resource(struct acpi_resource *acpi_res, void *data)
return AE_OK;
}
+static int
+bus_has_transparent_bridge(struct pci_bus *bus)
+{
+ struct pci_dev *dev;
+
+ list_for_each_entry(dev, &bus->devices, bus_list) {
+ u16 class = dev->class >> 8;
+
+ if (class == PCI_CLASS_BRIDGE_PCI && dev->transparent)
+ return true;
+ }
+ return false;
+}
+
static void
align_resource(struct acpi_device *bridge, struct resource *res)
{
@@ -78,8 +92,12 @@ setup_resource(struct acpi_resource *acpi_res, void *data)
acpi_status status;
unsigned long flags;
struct resource *root;
+ int max_root_bus_resources = PCI_BUS_NUM_RESOURCES;
u64 start, end;
+ if (bus_has_transparent_bridge(info->bus))
+ max_root_bus_resources -= 3;
+
status = resource_to_addr(acpi_res, &addr);
if (!ACPI_SUCCESS(status))
return AE_OK;
@@ -97,6 +115,15 @@ setup_resource(struct acpi_resource *acpi_res, void *data)
start = addr.minimum + addr.translation_offset;
end = start + addr.address_length - 1;
+ if (info->res_num >= max_root_bus_resources) {
+ if (pci_probe & PCI_USE__CRS)
+ printk(KERN_WARNING "PCI: Failed to allocate "
+ "0x%lx-0x%lx from %s for %s due to _CRS "
+ "returning more than %d resource descriptors\n",
+ (unsigned long) start, (unsigned long) end,
+ root->name, info->name, max_root_bus_resources);
+ return AE_OK;
+ }
res = &info->res[info->res_num];
res->name = info->name;
@@ -116,7 +143,7 @@ setup_resource(struct acpi_resource *acpi_res, void *data)
dev_err(&info->bridge->dev,
"can't allocate host bridge window %pR\n", res);
} else {
- pci_bus_add_resource(info->bus, res, 0);
+ info->bus->resource[info->res_num] = res;
info->res_num++;
if (addr.translation_offset)
dev_info(&info->bridge->dev, "host bridge window %pR "
@@ -137,9 +164,7 @@ get_current_resources(struct acpi_device *device, int busnum,
struct pci_root_info info;
size_t size;
- if (pci_probe & PCI_USE__CRS)
- pci_bus_remove_resources(bus);
- else
+ if (!(pci_probe & PCI_USE__CRS))
dev_info(&device->dev,
"ignoring host bridge windows from ACPI; "
"boot with \"pci=use_crs\" to use them\n");
diff --git a/arch/x86/pci/bus_numa.c b/arch/x86/pci/bus_numa.c
index 6999970ca753..f939d603adfa 100644
--- a/arch/x86/pci/bus_numa.c
+++ b/arch/x86/pci/bus_numa.c
@@ -12,12 +12,10 @@ void x86_pci_root_bus_res_quirks(struct pci_bus *b)
int i;
int j;
struct pci_root_info *info;
- struct pci_bus_resource *bus_res;
/* don't go for it if _CRS is used already */
- bus_res = list_first_entry(&b->resources, struct pci_bus_resource,
- list);
- if (bus_res->res != &ioport_resource)
+ if (b->resource[0] != &ioport_resource ||
+ b->resource[1] != &iomem_resource)
return;
if (!pci_root_num)
@@ -38,14 +36,13 @@ void x86_pci_root_bus_res_quirks(struct pci_bus *b)
printk(KERN_DEBUG "PCI: peer root bus %02x res updated from pci conf\n",
b->number);
- pci_bus_remove_resources(b);
info = &pci_root_info[i];
for (j = 0; j < info->res_num; j++) {
struct resource *res;
struct resource *root;
res = &info->res[j];
- pci_bus_add_resource(b, res, 0);
+ b->resource[j] = res;
if (res->flags & IORESOURCE_IO)
root = &ioport_resource;
else
diff --git a/arch/x86/pci/bus_numa.h b/arch/x86/pci/bus_numa.h
index 731b64ee8d84..adbc23fe82ac 100644
--- a/arch/x86/pci/bus_numa.h
+++ b/arch/x86/pci/bus_numa.h
@@ -2,7 +2,8 @@
/*
* sub bus (transparent) will use entres from 3 to store extra from
- * root, so need to make sure we have enough slot there.
+ * root, so need to make sure we have enough slot there, Should we
+ * increase PCI_BUS_NUM_RESOURCES?
*/
#define RES_NUM 16
struct pci_root_info {
diff --git a/drivers/eisa/pci_eisa.c b/drivers/eisa/pci_eisa.c
index 562eaa4464d7..0dd0f633b18d 100644
--- a/drivers/eisa/pci_eisa.c
+++ b/drivers/eisa/pci_eisa.c
@@ -31,8 +31,8 @@ static int __init pci_eisa_init(struct pci_dev *pdev,
}
pci_eisa_root.dev = &pdev->dev;
- pci_eisa_root.res = &pdev->resource[PCI_BRIDGE_RESOURCES + 0];
- pci_eisa_root.bus_base_addr = pdev->resource[PCI_BRIDGE_RESOURCES + 0].start;
+ pci_eisa_root.res = pdev->bus->resource[0];
+ pci_eisa_root.bus_base_addr = pdev->bus->resource[0]->start;
pci_eisa_root.slots = EISA_MAX_SLOTS;
pci_eisa_root.dma_mask = pdev->dma_mask;
dev_set_drvdata(pci_eisa_root.dev, &pci_eisa_root);
diff --git a/drivers/pci/bus.c b/drivers/pci/bus.c
index 27bd0e395fe3..4688eaddae6b 100644
--- a/drivers/pci/bus.c
+++ b/drivers/pci/bus.c
@@ -17,49 +17,6 @@
#include "pci.h"
-void pci_bus_add_resource(struct pci_bus *bus, struct resource *res,
- unsigned int flags)
-{
- struct pci_bus_resource *bus_res;
-
- bus_res = kzalloc(sizeof(struct pci_bus_resource), GFP_KERNEL);
- if (!bus_res) {
- dev_err(&bus->dev, "can't add %pR resource\n", res);
- return;
- }
-
- bus_res->res = res;
- bus_res->flags = flags;
- list_add_tail(&bus_res->list, &bus->resources);
-}
-
-struct resource *pci_bus_get_resource(struct pci_bus *bus, unsigned long flags,
- int num)
-{
- struct pci_bus_resource *bus_res;
- struct resource *res;
-
- list_for_each_entry(bus_res, &bus->resources, list) {
- if (!(bus_res->flags & PCI_POSITIVE_DECODE))
- continue;
-
- res = bus_res->res;
- if (((res->flags & flags) == flags) && num-- == 0)
- return res;
- }
- return NULL;
-}
-
-void pci_bus_remove_resources(struct pci_bus *bus)
-{
- struct pci_bus_resource *bus_res, *tmp;
-
- list_for_each_entry_safe(bus_res, tmp, &bus->resources, list) {
- list_del(&bus_res->list);
- kfree(bus_res);
- }
-}
-
/**
* pci_bus_alloc_resource - allocate a resource from a parent bus
* @bus: PCI bus
@@ -85,8 +42,7 @@ pci_bus_alloc_resource(struct pci_bus *bus, struct resource *res,
resource_size_t),
void *alignf_data)
{
- int ret = -ENOMEM;
- struct pci_bus_resource *bus_res;
+ int i, ret = -ENOMEM;
resource_size_t max = -1;
type_mask |= IORESOURCE_IO | IORESOURCE_MEM;
@@ -95,8 +51,8 @@ pci_bus_alloc_resource(struct pci_bus *bus, struct resource *res,
if (!(res->flags & IORESOURCE_MEM_64))
max = PCIBIOS_MAX_MEM_32;
- list_for_each_entry(bus_res, &bus->resources, list) {
- struct resource *r = bus_res->res;
+ for (i = 0; i < PCI_BUS_NUM_RESOURCES; i++) {
+ struct resource *r = bus->resource[i];
if (!r)
continue;
diff --git a/drivers/pci/hotplug/shpchp_sysfs.c b/drivers/pci/hotplug/shpchp_sysfs.c
index e1a9d6ab8395..29fa9d26adae 100644
--- a/drivers/pci/hotplug/shpchp_sysfs.c
+++ b/drivers/pci/hotplug/shpchp_sysfs.c
@@ -39,17 +39,16 @@ static ssize_t show_ctrl (struct device *dev, struct device_attribute *attr, cha
{
struct pci_dev *pdev;
char * out = buf;
- int busnr;
+ int index, busnr;
struct resource *res;
struct pci_bus *bus;
- struct pci_bus_resource *bus_res;
pdev = container_of (dev, struct pci_dev, dev);
bus = pdev->subordinate;
out += sprintf(buf, "Free resources: memory\n");
- list_for_each_entry(bus_res, &bus->resources, list) {
- res = bus_res->res;
+ for (index = 0; index < PCI_BUS_NUM_RESOURCES; index++) {
+ res = bus->resource[index];
if (res && (res->flags & IORESOURCE_MEM) &&
!(res->flags & IORESOURCE_PREFETCH)) {
out += sprintf(out, "start = %8.8llx, "
@@ -59,8 +58,8 @@ static ssize_t show_ctrl (struct device *dev, struct device_attribute *attr, cha
}
}
out += sprintf(out, "Free resources: prefetchable memory\n");
- list_for_each_entry(bus_res, &bus->resources, list) {
- res = bus_res->res;
+ for (index = 0; index < PCI_BUS_NUM_RESOURCES; index++) {
+ res = bus->resource[index];
if (res && (res->flags & IORESOURCE_MEM) &&
(res->flags & IORESOURCE_PREFETCH)) {
out += sprintf(out, "start = %8.8llx, "
@@ -70,8 +69,8 @@ static ssize_t show_ctrl (struct device *dev, struct device_attribute *attr, cha
}
}
out += sprintf(out, "Free resources: IO\n");
- list_for_each_entry(bus_res, &bus->resources, list) {
- res = bus_res->res;
+ for (index = 0; index < PCI_BUS_NUM_RESOURCES; index++) {
+ res = bus->resource[index];
if (res && (res->flags & IORESOURCE_IO)) {
out += sprintf(out, "start = %8.8llx, "
"length = %8.8llx\n",
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index 29a798e72e64..c1accd36a6c6 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -385,11 +385,11 @@ struct resource *
pci_find_parent_resource(const struct pci_dev *dev, struct resource *res)
{
const struct pci_bus *bus = dev->bus;
- struct pci_bus_resource *bus_res;
+ int i;
struct resource *best = NULL;
- list_for_each_entry(bus_res, &bus->resources, list) {
- struct resource *r = bus_res->res;
+ for(i = 0; i < PCI_BUS_NUM_RESOURCES; i++) {
+ struct resource *r = bus->resource[i];
if (!r)
continue;
if (res->start && !(res->start >= r->start && res->end <= r->end))
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index dd6e4ac93e46..c01adeb123b7 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -89,7 +89,6 @@ static void release_pcibus_dev(struct device *dev)
if (pci_bus->bridge)
put_device(pci_bus->bridge);
- pci_bus_remove_resources(pci_bus);
kfree(pci_bus);
}
@@ -289,8 +288,7 @@ static void __devinit pci_read_bridge_io(struct pci_bus *child)
unsigned long base, limit;
struct resource *res;
- res = &dev->resource[PCI_BRIDGE_RESOURCES + 0];
-
+ res = child->resource[0];
pci_read_config_byte(dev, PCI_IO_BASE, &io_base_lo);
pci_read_config_byte(dev, PCI_IO_LIMIT, &io_limit_lo);
base = (io_base_lo & PCI_IO_RANGE_MASK) << 8;
@@ -325,8 +323,7 @@ static void __devinit pci_read_bridge_mmio(struct pci_bus *child)
unsigned long base, limit;
struct resource *res;
- res = &dev->resource[PCI_BRIDGE_RESOURCES + 1];
-
+ res = child->resource[1];
pci_read_config_word(dev, PCI_MEMORY_BASE, &mem_base_lo);
pci_read_config_word(dev, PCI_MEMORY_LIMIT, &mem_limit_lo);
base = (mem_base_lo & PCI_MEMORY_RANGE_MASK) << 16;
@@ -350,8 +347,7 @@ static void __devinit pci_read_bridge_mmio_pref(struct pci_bus *child)
unsigned long base, limit;
struct resource *res;
- res = &dev->resource[PCI_BRIDGE_RESOURCES + 2];
-
+ res = child->resource[2];
pci_read_config_word(dev, PCI_PREF_MEMORY_BASE, &mem_base_lo);
pci_read_config_word(dev, PCI_PREF_MEMORY_LIMIT, &mem_limit_lo);
base = (mem_base_lo & PCI_PREF_RANGE_MASK) << 16;
@@ -398,7 +394,7 @@ static void __devinit pci_read_bridge_mmio_pref(struct pci_bus *child)
void __devinit pci_read_bridge_bases(struct pci_bus *child)
{
struct pci_dev *dev = child->self;
- struct pci_bus_resource *bus_res;
+ int i;
if (pci_is_root_bus(child)) /* It's a host bus, nothing to read */
return;
@@ -412,11 +408,12 @@ void __devinit pci_read_bridge_bases(struct pci_bus *child)
pci_read_bridge_mmio_pref(child);
if (dev->transparent) {
- list_for_each_entry(bus_res, &child->parent->resources, list) {
- pci_bus_add_resource(child, bus_res->res, 0);
- dev_printk(KERN_DEBUG, &dev->dev,
- " bridge window %pR (subtractive decode)\n",
- bus_res->res);
+ for (i = 3; i < PCI_BUS_NUM_RESOURCES; i++) {
+ child->resource[i] = child->parent->resource[i - 3];
+ if (child->resource[i])
+ dev_printk(KERN_DEBUG, &dev->dev,
+ " bridge window %pR (subtractive decode)\n",
+ child->resource[i]);
}
}
}
@@ -431,7 +428,6 @@ static struct pci_bus * pci_alloc_bus(void)
INIT_LIST_HEAD(&b->children);
INIT_LIST_HEAD(&b->devices);
INIT_LIST_HEAD(&b->slots);
- INIT_LIST_HEAD(&b->resources);
b->max_bus_speed = PCI_SPEED_UNKNOWN;
b->cur_bus_speed = PCI_SPEED_UNKNOWN;
}
@@ -577,7 +573,6 @@ static struct pci_bus *pci_alloc_child_bus(struct pci_bus *parent,
{
struct pci_bus *child;
int i;
- struct resource *res;
/*
* Allocate a new bus, and inherit stuff from the parent..
@@ -616,11 +611,9 @@ static struct pci_bus *pci_alloc_child_bus(struct pci_bus *parent,
/* Set up default resource pointers and names.. */
for (i = 0; i < PCI_BRIDGE_RESOURCE_NUM; i++) {
- res = &bridge->resource[PCI_BRIDGE_RESOURCES + i];
- res->name = child->name;
- pci_bus_add_resource(child, res, PCI_POSITIVE_DECODE);
+ child->resource[i] = &bridge->resource[PCI_BRIDGE_RESOURCES+i];
+ child->resource[i]->name = child->name;
}
-
bridge->subordinate = child;
return child;
@@ -1453,8 +1446,8 @@ struct pci_bus * pci_create_bus(struct device *parent,
pci_create_legacy_files(b);
b->number = b->secondary = bus;
- pci_bus_add_resource(b, &ioport_resource, 0);
- pci_bus_add_resource(b, &iomem_resource, 0);
+ b->resource[0] = &ioport_resource;
+ b->resource[1] = &iomem_resource;
return b;
diff --git a/drivers/pci/setup-bus.c b/drivers/pci/setup-bus.c
index 8a3b512cc3e5..743ed8c48b9c 100644
--- a/drivers/pci/setup-bus.c
+++ b/drivers/pci/setup-bus.c
@@ -138,53 +138,58 @@ static void pbus_assign_resources_sorted(const struct pci_bus *bus,
__assign_resources_sorted(&head, fail_head);
}
-static void pci_setup_cardbus_window(struct pci_dev *bridge, char *type, int n,
- struct resource *res, int base_reg, int limit_reg)
+void pci_setup_cardbus(struct pci_bus *bus)
{
+ struct pci_dev *bridge = bus->self;
+ struct resource *res;
struct pci_bus_region region;
- u32 base, limit;
- if (!res) {
+ dev_info(&bridge->dev, "CardBus bridge to [bus %02x-%02x]\n",
+ bus->secondary, bus->subordinate);
+
+ res = bus->resource[0];
+ pcibios_resource_to_bus(bridge, &region, res);
+ if (res->flags & IORESOURCE_IO) {
/*
- * Maybe we should disable the window, but the previous
- * code left it alone.
+ * The IO resource is allocated a range twice as large as it
+ * would normally need. This allows us to set both IO regs.
*/
- pci_read_config_dword(bridge, base_reg, &base);
- pci_read_config_dword(bridge, limit_reg, &limit);
- dev_info(&bridge->dev, " no %s%d resource, leaving bridge programmed with base %#08x limit %#08x\n",
- type, n, base, limit);
- return;
+ dev_info(&bridge->dev, " bridge window %pR\n", res);
+ pci_write_config_dword(bridge, PCI_CB_IO_BASE_0,
+ region.start);
+ pci_write_config_dword(bridge, PCI_CB_IO_LIMIT_0,
+ region.end);
}
+ res = bus->resource[1];
pcibios_resource_to_bus(bridge, &region, res);
- pci_write_config_dword(bridge, base_reg, region.start);
- pci_write_config_dword(bridge, limit_reg, region.end);
- dev_info(&bridge->dev, " bridge window %pR\n", res);
-}
-
-void pci_setup_cardbus(struct pci_bus *bus)
-{
- struct pci_dev *bridge = bus->self;
+ if (res->flags & IORESOURCE_IO) {
+ dev_info(&bridge->dev, " bridge window %pR\n", res);
+ pci_write_config_dword(bridge, PCI_CB_IO_BASE_1,
+ region.start);
+ pci_write_config_dword(bridge, PCI_CB_IO_LIMIT_1,
+ region.end);
+ }
- dev_info(&bridge->dev, "CardBus bridge to [bus %02x-%02x]\n",
- bus->secondary, bus->subordinate);
+ res = bus->resource[2];
+ pcibios_resource_to_bus(bridge, &region, res);
+ if (res->flags & IORESOURCE_MEM) {
+ dev_info(&bridge->dev, " bridge window %pR\n", res);
+ pci_write_config_dword(bridge, PCI_CB_MEMORY_BASE_0,
+ region.start);
+ pci_write_config_dword(bridge, PCI_CB_MEMORY_LIMIT_0,
+ region.end);
+ }
- /*
- * The IO resource is allocated a range twice as large as it
- * would normally need. This allows us to set both IO regs.
- */
- pci_setup_cardbus_window(bridge, "io", 0,
- pci_bus_get_resource(bus, IORESOURCE_IO, 0),
- PCI_CB_IO_BASE_0, PCI_CB_IO_LIMIT_0);
- pci_setup_cardbus_window(bridge, "io", 1,
- pci_bus_get_resource(bus, IORESOURCE_IO, 1),
- PCI_CB_IO_BASE_1, PCI_CB_IO_LIMIT_1);
- pci_setup_cardbus_window(bridge, "mem", 0,
- pci_bus_get_resource(bus, IORESOURCE_MEM, 0),
- PCI_CB_MEMORY_BASE_0, PCI_CB_MEMORY_LIMIT_0);
- pci_setup_cardbus_window(bridge, "mem", 1,
- pci_bus_get_resource(bus, IORESOURCE_MEM, 1),
- PCI_CB_MEMORY_BASE_1, PCI_CB_MEMORY_LIMIT_1);
+ res = bus->resource[3];
+ pcibios_resource_to_bus(bridge, &region, res);
+ if (res->flags & IORESOURCE_MEM) {
+ dev_info(&bridge->dev, " bridge window %pR\n", res);
+ pci_write_config_dword(bridge, PCI_CB_MEMORY_BASE_1,
+ region.start);
+ pci_write_config_dword(bridge, PCI_CB_MEMORY_LIMIT_1,
+ region.end);
+ }
}
EXPORT_SYMBOL(pci_setup_cardbus);
@@ -207,9 +212,9 @@ static void pci_setup_bridge_io(struct pci_bus *bus)
u32 l, io_upper16;
/* Set up the top and bottom of the PCI I/O segment for this bus. */
- res = pci_bus_get_resource(bus, IORESOURCE_IO, 0);
- if (res) {
- pcibios_resource_to_bus(bridge, &region, res);
+ res = bus->resource[0];
+ pcibios_resource_to_bus(bridge, &region, res);
+ if (res->flags & IORESOURCE_IO) {
pci_read_config_dword(bridge, PCI_IO_BASE, &l);
l &= 0xffff0000;
l |= (region.start >> 8) & 0x00f0;
@@ -239,9 +244,9 @@ static void pci_setup_bridge_mmio(struct pci_bus *bus)
u32 l;
/* Set up the top and bottom of the PCI Memory segment for this bus. */
- res = pci_bus_get_resource(bus, IORESOURCE_MEM, 0);
- if (res) {
- pcibios_resource_to_bus(bridge, &region, res);
+ res = bus->resource[1];
+ pcibios_resource_to_bus(bridge, &region, res);
+ if (res->flags & IORESOURCE_MEM) {
l = (region.start >> 16) & 0xfff0;
l |= region.end & 0xfff00000;
dev_info(&bridge->dev, " bridge window %pR\n", res);
@@ -266,9 +271,9 @@ static void pci_setup_bridge_mmio_pref(struct pci_bus *bus)
/* Set up PREF base/limit. */
bu = lu = 0;
- res = pci_bus_get_resource(bus, IORESOURCE_MEM | IORESOURCE_PREFETCH, 0);
- if (res) {
- pcibios_resource_to_bus(bridge, &region, res);
+ res = bus->resource[2];
+ pcibios_resource_to_bus(bridge, &region, res);
+ if (res->flags & IORESOURCE_PREFETCH) {
l = (region.start >> 16) & 0xfff0;
l |= region.end & 0xfff00000;
if (res->flags & IORESOURCE_MEM_64) {
@@ -377,13 +382,13 @@ static void pci_bridge_check_ranges(struct pci_bus *bus)
have non-NULL parent resource). */
static struct resource *find_free_bus_resource(struct pci_bus *bus, unsigned long type)
{
- struct pci_bus_resource *bus_res;
+ int i;
struct resource *r;
unsigned long type_mask = IORESOURCE_IO | IORESOURCE_MEM |
IORESOURCE_PREFETCH;
- list_for_each_entry(bus_res, &bus->resources, list) {
- r = bus_res->res;
+ for (i = 0; i < PCI_BUS_NUM_RESOURCES; i++) {
+ r = bus->resource[i];
if (r == &ioport_resource || r == &iomem_resource)
continue;
if (r && (r->flags & type_mask) == type && !r->parent)
@@ -798,15 +803,15 @@ static void __ref pci_bus_release_bridge_resources(struct pci_bus *bus,
static void pci_bus_dump_res(struct pci_bus *bus)
{
- struct pci_bus_resource *bus_res;
+ int i;
- list_for_each_entry(bus_res, &bus->resources, list) {
- struct resource *res = bus_res->res;
+ for (i = 0; i < PCI_BUS_NUM_RESOURCES; i++) {
+ struct resource *res = bus->resource[i];
if (!res || !res->end || !res->flags)
continue;
- dev_printk(KERN_DEBUG, &bus->dev, "resource %pR\n", res);
+ dev_printk(KERN_DEBUG, &bus->dev, "resource %d %pR\n", i, res);
}
}
diff --git a/drivers/pcmcia/rsrc_nonstatic.c b/drivers/pcmcia/rsrc_nonstatic.c
index d22daa6d9c37..08913a230a9a 100644
--- a/drivers/pcmcia/rsrc_nonstatic.c
+++ b/drivers/pcmcia/rsrc_nonstatic.c
@@ -821,9 +821,8 @@ static int adjust_io(struct pcmcia_socket *s, unsigned int action, unsigned long
#ifdef CONFIG_PCI
static int nonstatic_autoadd_resources(struct pcmcia_socket *s)
{
- struct pci_bus_resource *bus_res;
struct resource *res;
- int done = 0;
+ int i, done = 0;
if (!s->cb_dev || !s->cb_dev->bus)
return -ENODEV;
@@ -839,8 +838,8 @@ static int nonstatic_autoadd_resources(struct pcmcia_socket *s)
return -EINVAL;
#endif
- list_for_each_entry(bus_res, &s->cb_dev->bus->resources, list) {
- res = bus_res->res;
+ for (i = 0; i < PCI_BUS_NUM_RESOURCES; i++) {
+ res = s->cb_dev->bus->resource[i];
if (!res)
continue;
diff --git a/drivers/pcmcia/yenta_socket.c b/drivers/pcmcia/yenta_socket.c
index 9e831871d92a..041a75a7e55e 100644
--- a/drivers/pcmcia/yenta_socket.c
+++ b/drivers/pcmcia/yenta_socket.c
@@ -654,10 +654,9 @@ static int yenta_search_one_res(struct resource *root, struct resource *res,
static int yenta_search_res(struct yenta_socket *socket, struct resource *res,
u32 min)
{
- struct pci_bus_resource *bus_res;
-
- list_for_each_entry(bus_res, &socket->dev->bus->resources, list) {
- struct resource *root = bus_res->res;
+ int i;
+ for (i = 0; i < PCI_BUS_NUM_RESOURCES; i++) {
+ struct resource *root = socket->dev->bus->resource[i];
if (!root)
continue;
diff --git a/include/linux/pci.h b/include/linux/pci.h
index e41cade18aba..b50875957e41 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -364,13 +364,9 @@ static inline void pci_add_saved_cap(struct pci_dev *pci_dev,
hlist_add_head(&new_cap->next, &pci_dev->saved_cap_space);
}
-#define PCI_POSITIVE_DECODE 1
-
-struct pci_bus_resource {
- struct list_head list;
- struct resource *res;
- unsigned int flags;
-};
+#ifndef PCI_BUS_NUM_RESOURCES
+#define PCI_BUS_NUM_RESOURCES 16
+#endif
#define PCI_REGION_FLAG_MASK 0x0fU /* These bits of resource flags tell us the PCI region flags */
@@ -381,7 +377,8 @@ struct pci_bus {
struct list_head devices; /* list of devices on this bus */
struct pci_dev *self; /* bridge device as seen by parent */
struct list_head slots; /* list of slots on this bus */
- struct list_head resources; /* address space routed to this bus */
+ struct resource *resource[PCI_BUS_NUM_RESOURCES];
+ /* address space routed to this bus */
struct pci_ops *ops; /* configuration access functions */
void *sysdata; /* hook for sys-specific extension */
@@ -836,9 +833,6 @@ int pci_request_selected_regions_exclusive(struct pci_dev *, int, const char *);
void pci_release_selected_regions(struct pci_dev *, int);
/* drivers/pci/bus.c */
-void pci_bus_add_resource(struct pci_bus *bus, struct resource *res, unsigned int flags);
-struct resource *pci_bus_get_resource(struct pci_bus *bus, unsigned long flags, int num);
-void pci_bus_remove_resources(struct pci_bus *bus);
int __must_check pci_bus_alloc_resource(struct pci_bus *bus,
struct resource *res, resource_size_t size,
resource_size_t align, resource_size_t min,