mirror of
https://github.com/team-infusion-developers/android_kernel_samsung_msm8976.git
synced 2024-11-01 02:21:16 +00:00
memblock: Reimplement memblock_enforce_memory_limit() using __memblock_remove()
With recent updates, the basic memblock operations are robust enough that there's no reason for memblock_enfore_memory_limit() to directly manipulate memblock region arrays. Reimplement it using __memblock_remove(). Signed-off-by: Tejun Heo <tj@kernel.org> Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org> Cc: Yinghai Lu <yinghai@kernel.org>
This commit is contained in:
parent
eb18f1b5bf
commit
c0ce8fef55
1 changed files with 13 additions and 29 deletions
|
@ -804,44 +804,28 @@ phys_addr_t __init_memblock memblock_end_of_DRAM(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* You must call memblock_analyze() after this. */
|
/* You must call memblock_analyze() after this. */
|
||||||
void __init memblock_enforce_memory_limit(phys_addr_t memory_limit)
|
void __init memblock_enforce_memory_limit(phys_addr_t limit)
|
||||||
{
|
{
|
||||||
unsigned long i;
|
unsigned long i;
|
||||||
phys_addr_t limit;
|
phys_addr_t max_addr = (phys_addr_t)ULLONG_MAX;
|
||||||
struct memblock_region *p;
|
|
||||||
|
|
||||||
if (!memory_limit)
|
if (!limit)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* Truncate the memblock regions to satisfy the memory limit. */
|
/* find out max address */
|
||||||
limit = memory_limit;
|
|
||||||
for (i = 0; i < memblock.memory.cnt; i++) {
|
for (i = 0; i < memblock.memory.cnt; i++) {
|
||||||
if (limit > memblock.memory.regions[i].size) {
|
struct memblock_region *r = &memblock.memory.regions[i];
|
||||||
limit -= memblock.memory.regions[i].size;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
memblock.memory.regions[i].size = limit;
|
if (limit <= r->size) {
|
||||||
memblock.memory.cnt = i + 1;
|
max_addr = r->base + limit;
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
limit -= r->size;
|
||||||
}
|
}
|
||||||
|
|
||||||
memory_limit = memblock_end_of_DRAM();
|
/* truncate both memory and reserved regions */
|
||||||
|
__memblock_remove(&memblock.memory, max_addr, (phys_addr_t)ULLONG_MAX);
|
||||||
/* And truncate any reserves above the limit also. */
|
__memblock_remove(&memblock.reserved, max_addr, (phys_addr_t)ULLONG_MAX);
|
||||||
for (i = 0; i < memblock.reserved.cnt; i++) {
|
|
||||||
p = &memblock.reserved.regions[i];
|
|
||||||
|
|
||||||
if (p->base > memory_limit)
|
|
||||||
p->size = 0;
|
|
||||||
else if ((p->base + p->size) > memory_limit)
|
|
||||||
p->size = memory_limit - p->base;
|
|
||||||
|
|
||||||
if (p->size == 0) {
|
|
||||||
memblock_remove_region(&memblock.reserved, i);
|
|
||||||
i--;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int __init_memblock memblock_search(struct memblock_type *type, phys_addr_t addr)
|
static int __init_memblock memblock_search(struct memblock_type *type, phys_addr_t addr)
|
||||||
|
|
Loading…
Reference in a new issue