Commit 6db45b76 authored by Bjorn Helgaas's avatar Bjorn Helgaas Committed by Jesse Barnes

Revert "PCI: allocate bus resources from the top down"

This reverts commit b126b470.

We're going back to the old behavior of allocating from bus resources
in _CRS order.
Acked-by: default avatarH. Peter Anvin <hpa@zytor.com>
Signed-off-by: default avatarBjorn Helgaas <bjorn.helgaas@hp.com>
Signed-off-by: default avatarJesse Barnes <jbarnes@virtuousgeek.org>
parent d14125ec
...@@ -64,49 +64,6 @@ void pci_bus_remove_resources(struct pci_bus *bus) ...@@ -64,49 +64,6 @@ void pci_bus_remove_resources(struct pci_bus *bus)
} }
} }
/*
* Find the highest-address bus resource below the cursor "res". If the
* cursor is NULL, return the highest resource.
*/
static struct resource *pci_bus_find_resource_prev(struct pci_bus *bus,
unsigned int type,
struct resource *res)
{
struct resource *r, *prev = NULL;
int i;
pci_bus_for_each_resource(bus, r, i) {
if (!r)
continue;
if ((r->flags & IORESOURCE_TYPE_BITS) != type)
continue;
/* If this resource is at or past the cursor, skip it */
if (res) {
if (r == res)
continue;
if (r->end > res->end)
continue;
if (r->end == res->end && r->start > res->start)
continue;
}
if (!prev)
prev = r;
/*
* A small resource is higher than a large one that ends at
* the same address.
*/
if (r->end > prev->end ||
(r->end == prev->end && r->start > prev->start))
prev = r;
}
return prev;
}
/** /**
* pci_bus_alloc_resource - allocate a resource from a parent bus * pci_bus_alloc_resource - allocate a resource from a parent bus
* @bus: PCI bus * @bus: PCI bus
...@@ -132,10 +89,9 @@ pci_bus_alloc_resource(struct pci_bus *bus, struct resource *res, ...@@ -132,10 +89,9 @@ pci_bus_alloc_resource(struct pci_bus *bus, struct resource *res,
resource_size_t), resource_size_t),
void *alignf_data) void *alignf_data)
{ {
int ret = -ENOMEM; int i, ret = -ENOMEM;
struct resource *r; struct resource *r;
resource_size_t max = -1; resource_size_t max = -1;
unsigned int type = res->flags & IORESOURCE_TYPE_BITS;
type_mask |= IORESOURCE_IO | IORESOURCE_MEM; type_mask |= IORESOURCE_IO | IORESOURCE_MEM;
...@@ -143,9 +99,10 @@ pci_bus_alloc_resource(struct pci_bus *bus, struct resource *res, ...@@ -143,9 +99,10 @@ pci_bus_alloc_resource(struct pci_bus *bus, struct resource *res,
if (!(res->flags & IORESOURCE_MEM_64)) if (!(res->flags & IORESOURCE_MEM_64))
max = PCIBIOS_MAX_MEM_32; max = PCIBIOS_MAX_MEM_32;
/* Look for space at highest addresses first */ pci_bus_for_each_resource(bus, r, i) {
r = pci_bus_find_resource_prev(bus, type, NULL); if (!r)
for ( ; r; r = pci_bus_find_resource_prev(bus, type, r)) { continue;
/* type_mask must match */ /* type_mask must match */
if ((res->flags ^ r->flags) & type_mask) if ((res->flags ^ r->flags) & type_mask)
continue; continue;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment