ARM: 8637/1: Adjust memory boundaries after reservations
adjust_lowmem_bounds is responsible for setting up the boundary for lowmem/highmem. This needs to be setup before memblock reservations can occur. At the time memblock reservations can occur, memory can also be removed from the system. The lowmem/highmem boundary and end of memory may be affected by this but it is currently not recalculated. On some systems this may be harmless, on others this may result in incorrect ranges being passed to the main memory allocator. Correct this by recalculating the lowmem/highmem boundary after all reservations have been made. Tested-by: Magnus Lilja <lilja.magnus@gmail.com> Signed-off-by: Laura Abbott <labbott@redhat.com> Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
This commit is contained in:
parent
374d446d25
commit
985626564e
|
@ -1093,8 +1093,14 @@ void __init setup_arch(char **cmdline_p)
|
||||||
setup_dma_zone(mdesc);
|
setup_dma_zone(mdesc);
|
||||||
xen_early_init();
|
xen_early_init();
|
||||||
efi_init();
|
efi_init();
|
||||||
|
/*
|
||||||
|
* Make sure the calculation for lowmem/highmem is set appropriately
|
||||||
|
* before reserving/allocating any mmeory
|
||||||
|
*/
|
||||||
adjust_lowmem_bounds();
|
adjust_lowmem_bounds();
|
||||||
arm_memblock_init(mdesc);
|
arm_memblock_init(mdesc);
|
||||||
|
/* Memory may have been removed so recalculate the bounds. */
|
||||||
|
adjust_lowmem_bounds();
|
||||||
|
|
||||||
early_ioremap_reset();
|
early_ioremap_reset();
|
||||||
|
|
||||||
|
|
|
@ -1157,6 +1157,7 @@ void __init adjust_lowmem_bounds(void)
|
||||||
phys_addr_t memblock_limit = 0;
|
phys_addr_t memblock_limit = 0;
|
||||||
u64 vmalloc_limit;
|
u64 vmalloc_limit;
|
||||||
struct memblock_region *reg;
|
struct memblock_region *reg;
|
||||||
|
phys_addr_t lowmem_limit = 0;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Let's use our own (unoptimized) equivalent of __pa() that is
|
* Let's use our own (unoptimized) equivalent of __pa() that is
|
||||||
|
@ -1172,14 +1173,14 @@ void __init adjust_lowmem_bounds(void)
|
||||||
phys_addr_t block_end = reg->base + reg->size;
|
phys_addr_t block_end = reg->base + reg->size;
|
||||||
|
|
||||||
if (reg->base < vmalloc_limit) {
|
if (reg->base < vmalloc_limit) {
|
||||||
if (block_end > arm_lowmem_limit)
|
if (block_end > lowmem_limit)
|
||||||
/*
|
/*
|
||||||
* Compare as u64 to ensure vmalloc_limit does
|
* Compare as u64 to ensure vmalloc_limit does
|
||||||
* not get truncated. block_end should always
|
* not get truncated. block_end should always
|
||||||
* fit in phys_addr_t so there should be no
|
* fit in phys_addr_t so there should be no
|
||||||
* issue with assignment.
|
* issue with assignment.
|
||||||
*/
|
*/
|
||||||
arm_lowmem_limit = min_t(u64,
|
lowmem_limit = min_t(u64,
|
||||||
vmalloc_limit,
|
vmalloc_limit,
|
||||||
block_end);
|
block_end);
|
||||||
|
|
||||||
|
@ -1200,12 +1201,14 @@ void __init adjust_lowmem_bounds(void)
|
||||||
if (!IS_ALIGNED(block_start, PMD_SIZE))
|
if (!IS_ALIGNED(block_start, PMD_SIZE))
|
||||||
memblock_limit = block_start;
|
memblock_limit = block_start;
|
||||||
else if (!IS_ALIGNED(block_end, PMD_SIZE))
|
else if (!IS_ALIGNED(block_end, PMD_SIZE))
|
||||||
memblock_limit = arm_lowmem_limit;
|
memblock_limit = lowmem_limit;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
arm_lowmem_limit = lowmem_limit;
|
||||||
|
|
||||||
high_memory = __va(arm_lowmem_limit - 1) + 1;
|
high_memory = __va(arm_lowmem_limit - 1) + 1;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
Loading…
Reference in New Issue