aboutsummaryrefslogtreecommitdiffstats
path: root/mm/memblock.c
diff options
context:
space:
mode:
Diffstat (limited to 'mm/memblock.c')
-rw-r--r--mm/memblock.c20
1 files changed, 9 insertions, 11 deletions
diff --git a/mm/memblock.c b/mm/memblock.c
index a925866e145..c1d2060e213 100644
--- a/mm/memblock.c
+++ b/mm/memblock.c
@@ -309,8 +309,8 @@ static phys_addr_t memblock_align_up(phys_addr_t addr, phys_addr_t size)
309 return (addr + (size - 1)) & ~(size - 1); 309 return (addr + (size - 1)) & ~(size - 1);
310} 310}
311 311
312static phys_addr_t __init memblock_alloc_region(phys_addr_t start, phys_addr_t end, 312static phys_addr_t __init memblock_find_region(phys_addr_t start, phys_addr_t end,
313 phys_addr_t size, phys_addr_t align) 313 phys_addr_t size, phys_addr_t align)
314{ 314{
315 phys_addr_t base, res_base; 315 phys_addr_t base, res_base;
316 long j; 316 long j;
@@ -318,12 +318,8 @@ static phys_addr_t __init memblock_alloc_region(phys_addr_t start, phys_addr_t e
318 base = memblock_align_down((end - size), align); 318 base = memblock_align_down((end - size), align);
319 while (start <= base) { 319 while (start <= base) {
320 j = memblock_overlaps_region(&memblock.reserved, base, size); 320 j = memblock_overlaps_region(&memblock.reserved, base, size);
321 if (j < 0) { 321 if (j < 0)
322 /* this area isn't reserved, take it */
323 if (memblock_add_region(&memblock.reserved, base, size) < 0)
324 base = ~(phys_addr_t)0;
325 return base; 322 return base;
326 }
327 res_base = memblock.reserved.regions[j].base; 323 res_base = memblock.reserved.regions[j].base;
328 if (res_base < size) 324 if (res_base < size)
329 break; 325 break;
@@ -356,8 +352,9 @@ static phys_addr_t __init memblock_alloc_nid_region(struct memblock_region *mp,
356 352
357 this_end = memblock_nid_range(start, end, &this_nid); 353 this_end = memblock_nid_range(start, end, &this_nid);
358 if (this_nid == nid) { 354 if (this_nid == nid) {
359 phys_addr_t ret = memblock_alloc_region(start, this_end, size, align); 355 phys_addr_t ret = memblock_find_region(start, this_end, size, align);
360 if (ret != ~(phys_addr_t)0) 356 if (ret != ~(phys_addr_t)0 &&
357 memblock_add_region(&memblock.reserved, ret, size) >= 0)
361 return ret; 358 return ret;
362 } 359 }
363 start = this_end; 360 start = this_end;
@@ -432,8 +429,9 @@ phys_addr_t __init __memblock_alloc_base(phys_addr_t size, phys_addr_t align, ph
432 if (memblocksize < size) 429 if (memblocksize < size)
433 continue; 430 continue;
434 base = min(memblockbase + memblocksize, max_addr); 431 base = min(memblockbase + memblocksize, max_addr);
435 res_base = memblock_alloc_region(memblockbase, base, size, align); 432 res_base = memblock_find_region(memblockbase, base, size, align);
436 if (res_base != ~(phys_addr_t)0) 433 if (res_base != ~(phys_addr_t)0 &&
434 memblock_add_region(&memblock.reserved, res_base, size) >= 0)
437 return res_base; 435 return res_base;
438 } 436 }
439 return 0; 437 return 0;