@@ -260,17 +260,28 @@ int __init dma_declare_contiguous(struct device *dev, phys_addr_t size,
goto err;
}
} else {
+ phys_addr_t addr;
+
+ if (memblock_direction_bottom_up()) {
+ addr = memblock_alloc_bottom_up(
+ MEMBLOCK_ALLOC_ACCESSIBLE,
+ limit, size, alignment);
+ if (addr)
+ goto success;
+ }
+
/*
* Use __memblock_alloc_base() since
* memblock_alloc_base() panic()s.
*/
- phys_addr_t addr = __memblock_alloc_base(size, alignment, limit);
+ addr = __memblock_alloc_base(size, alignment, limit);
if (!addr) {
base = -ENOMEM;
goto err;
- } else {
- base = addr;
}
+
+success:
+ base = addr;
}
/*