aboutsummaryrefslogtreecommitdiffstats
path: root/mm/memblock.c
diff options
context:
space:
mode:
authorBenjamin Herrenschmidt <benh@kernel.crashing.org>2010-07-06 18:39:14 -0400
committerBenjamin Herrenschmidt <benh@kernel.crashing.org>2010-08-04 22:56:21 -0400
commitd2cd563ba82c424083b78e0ce97d68bfb04d1242 (patch)
treeff4ab6de8b6906a6c955aa51c4ee53868dfafc0a /mm/memblock.c
parent142b45a72e221537c1bb1995497fef7cdc439e26 (diff)
memblock: Add arch function to control coalescing of memblock memory regions
Some archs such as ARM want to avoid coalescing accross things such as the lowmem/highmem boundary or similar. This provides the option to control it via an arch callback for which a weak default is provided which always allows coalescing. Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Diffstat (limited to 'mm/memblock.c')
-rw-r--r--mm/memblock.c19
1 files changed, 18 insertions, 1 deletions
diff --git a/mm/memblock.c b/mm/memblock.c
index 0787790b1ce0..8715f09434df 100644
--- a/mm/memblock.c
+++ b/mm/memblock.c
@@ -241,6 +241,12 @@ static int memblock_double_array(struct memblock_type *type)
241 return 0; 241 return 0;
242} 242}
243 243
244extern int __weak memblock_memory_can_coalesce(phys_addr_t addr1, phys_addr_t size1,
245 phys_addr_t addr2, phys_addr_t size2)
246{
247 return 1;
248}
249
244static long memblock_add_region(struct memblock_type *type, phys_addr_t base, phys_addr_t size) 250static long memblock_add_region(struct memblock_type *type, phys_addr_t base, phys_addr_t size)
245{ 251{
246 unsigned long coalesced = 0; 252 unsigned long coalesced = 0;
@@ -262,6 +268,10 @@ static long memblock_add_region(struct memblock_type *type, phys_addr_t base, ph
262 return 0; 268 return 0;
263 269
264 adjacent = memblock_addrs_adjacent(base, size, rgnbase, rgnsize); 270 adjacent = memblock_addrs_adjacent(base, size, rgnbase, rgnsize);
271 /* Check if arch allows coalescing */
272 if (adjacent != 0 && type == &memblock.memory &&
273 !memblock_memory_can_coalesce(base, size, rgnbase, rgnsize))
274 break;
265 if (adjacent > 0) { 275 if (adjacent > 0) {
266 type->regions[i].base -= size; 276 type->regions[i].base -= size;
267 type->regions[i].size += size; 277 type->regions[i].size += size;
@@ -274,7 +284,14 @@ static long memblock_add_region(struct memblock_type *type, phys_addr_t base, ph
274 } 284 }
275 } 285 }
276 286
277 if ((i < type->cnt - 1) && memblock_regions_adjacent(type, i, i+1)) { 287 /* If we plugged a hole, we may want to also coalesce with the
288 * next region
289 */
290 if ((i < type->cnt - 1) && memblock_regions_adjacent(type, i, i+1) &&
291 ((type != &memblock.memory || memblock_memory_can_coalesce(type->regions[i].base,
292 type->regions[i].size,
293 type->regions[i+1].base,
294 type->regions[i+1].size)))) {
278 memblock_coalesce_regions(type, i, i+1); 295 memblock_coalesce_regions(type, i, i+1);
279 coalesced++; 296 coalesced++;
280 } 297 }