Skip to content

Commit 6db45b7

Browse files
Bjorn Helgaasjbarnes993
authored andcommitted
Revert "PCI: allocate bus resources from the top down"
This reverts commit b126b47. We're going back to the old behavior of allocating from bus resources in _CRS order. Acked-by: H. Peter Anvin <hpa@zytor.com> Signed-off-by: Bjorn Helgaas <bjorn.helgaas@hp.com> Signed-off-by: Jesse Barnes <jbarnes@virtuousgeek.org>
1 parent d14125e commit 6db45b7

1 file changed

Lines changed: 5 additions & 48 deletions

File tree

‎drivers/pci/bus.c‎

Lines changed: 5 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -64,49 +64,6 @@ void pci_bus_remove_resources(struct pci_bus *bus)
6464
}
6565
}
6666

67-
/*
68-
* Find the highest-address bus resource below the cursor "res". If the
69-
* cursor is NULL, return the highest resource.
70-
*/
71-
static struct resource *pci_bus_find_resource_prev(struct pci_bus *bus,
72-
unsigned int type,
73-
struct resource *res)
74-
{
75-
struct resource *r, *prev = NULL;
76-
int i;
77-
78-
pci_bus_for_each_resource(bus, r, i) {
79-
if (!r)
80-
continue;
81-
82-
if ((r->flags & IORESOURCE_TYPE_BITS) != type)
83-
continue;
84-
85-
/* If this resource is at or past the cursor, skip it */
86-
if (res) {
87-
if (r == res)
88-
continue;
89-
if (r->end > res->end)
90-
continue;
91-
if (r->end == res->end && r->start > res->start)
92-
continue;
93-
}
94-
95-
if (!prev)
96-
prev = r;
97-
98-
/*
99-
* A small resource is higher than a large one that ends at
100-
* the same address.
101-
*/
102-
if (r->end > prev->end ||
103-
(r->end == prev->end && r->start > prev->start))
104-
prev = r;
105-
}
106-
107-
return prev;
108-
}
109-
11067
/**
11168
* pci_bus_alloc_resource - allocate a resource from a parent bus
11269
* @bus: PCI bus
@@ -132,20 +89,20 @@ pci_bus_alloc_resource(struct pci_bus *bus, struct resource *res,
13289
resource_size_t),
13390
void *alignf_data)
13491
{
135-
int ret = -ENOMEM;
92+
int i, ret = -ENOMEM;
13693
struct resource *r;
13794
resource_size_t max = -1;
138-
unsigned int type = res->flags & IORESOURCE_TYPE_BITS;
13995

14096
type_mask |= IORESOURCE_IO | IORESOURCE_MEM;
14197

14298
/* don't allocate too high if the pref mem doesn't support 64bit*/
14399
if (!(res->flags & IORESOURCE_MEM_64))
144100
max = PCIBIOS_MAX_MEM_32;
145101

146-
/* Look for space at highest addresses first */
147-
r = pci_bus_find_resource_prev(bus, type, NULL);
148-
for ( ; r; r = pci_bus_find_resource_prev(bus, type, r)) {
102+
pci_bus_for_each_resource(bus, r, i) {
103+
if (!r)
104+
continue;
105+
149106
/* type_mask must match */
150107
if ((res->flags ^ r->flags) & type_mask)
151108
continue;

0 commit comments

Comments
 (0)