[PATCH 02/11] PCI: Try to allocate mem64 above 4G at first
From: Yinghai Lu
Date: Wed May 23 2012 - 02:34:57 EST
and will fall back to below 4g if it can not find any above 4g.
Signed-off-by: Yinghai Lu <yinghai@xxxxxxxxxx>
---
drivers/pci/bus.c | 16 +++++++++++++---
1 files changed, 13 insertions(+), 3 deletions(-)
diff --git a/drivers/pci/bus.c b/drivers/pci/bus.c
index 4ce5ef2..2429f1f 100644
--- a/drivers/pci/bus.c
+++ b/drivers/pci/bus.c
@@ -122,13 +122,17 @@ pci_bus_alloc_resource(struct pci_bus *bus, struct resource *res,
int i, ret = -ENOMEM;
struct resource *r;
resource_size_t max = -1;
+ resource_size_t bottom = PCIBIOS_MAX_MEM_32 + 1ULL;
type_mask |= IORESOURCE_IO | IORESOURCE_MEM;
/* don't allocate too high if the pref mem doesn't support 64bit*/
- if (!(res->flags & IORESOURCE_MEM_64))
+ if (!(res->flags & IORESOURCE_MEM_64)) {
max = PCIBIOS_MAX_MEM_32;
+ bottom = 0;
+ }
+again:
pci_bus_for_each_resource(bus, r, i) {
if (!r)
continue;
@@ -145,12 +149,18 @@ pci_bus_alloc_resource(struct pci_bus *bus, struct resource *res,
/* Ok, try it out.. */
ret = allocate_resource(r, res, size,
- r->start ? : min,
+ max(bottom, r->start ? : min),
max, align,
alignf, alignf_data);
if (ret == 0)
- break;
+ return 0;
}
+
+ if (bottom != 0) {
+ bottom = 0;
+ goto again;
+ }
+
return ret;
}
--
1.7.7
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/