Commit 1bd14a66 authored by Atish Patra's avatar Atish Patra Committed by Palmer Dabbelt

RISC-V: Remove any memblock representing unusable memory area

RISC-V limits the physical memory size by -PAGE_OFFSET. Any memory beyond
that size from DRAM start is unusable. Just remove any memblock pointing
to those memory region without worrying about computing the maximum size.
Signed-off-by: default avatarAtish Patra <atish.patra@wdc.com>
Reviewed-by: default avatarMike Rapoport <rppt@linux.ibm.com>
Signed-off-by: default avatarPalmer Dabbelt <palmerdabbelt@google.com>
parent 9d750c75
...@@ -154,9 +154,8 @@ static void __init setup_initrd(void) ...@@ -154,9 +154,8 @@ static void __init setup_initrd(void)
void __init setup_bootmem(void) void __init setup_bootmem(void)
{ {
phys_addr_t mem_size = 0; phys_addr_t mem_start = 0;
phys_addr_t total_mem = 0; phys_addr_t start, end = 0;
phys_addr_t mem_start, start, end = 0;
phys_addr_t vmlinux_end = __pa_symbol(&_end); phys_addr_t vmlinux_end = __pa_symbol(&_end);
phys_addr_t vmlinux_start = __pa_symbol(&_start); phys_addr_t vmlinux_start = __pa_symbol(&_start);
u64 i; u64 i;
...@@ -164,21 +163,18 @@ void __init setup_bootmem(void) ...@@ -164,21 +163,18 @@ void __init setup_bootmem(void)
/* Find the memory region containing the kernel */ /* Find the memory region containing the kernel */
for_each_mem_range(i, &start, &end) { for_each_mem_range(i, &start, &end) {
phys_addr_t size = end - start; phys_addr_t size = end - start;
if (!total_mem) if (!mem_start)
mem_start = start; mem_start = start;
if (start <= vmlinux_start && vmlinux_end <= end) if (start <= vmlinux_start && vmlinux_end <= end)
BUG_ON(size == 0); BUG_ON(size == 0);
total_mem = total_mem + size;
} }
/* /*
* Remove memblock from the end of usable area to the * The maximal physical memory size is -PAGE_OFFSET.
* end of region * Make sure that any memory beyond mem_start + (-PAGE_OFFSET) is removed
* as it is unusable by kernel.
*/ */
mem_size = min(total_mem, (phys_addr_t)-PAGE_OFFSET); memblock_enforce_memory_limit(mem_start - PAGE_OFFSET);
if (mem_start + mem_size < end)
memblock_remove(mem_start + mem_size,
end - mem_start - mem_size);
/* Reserve from the start of the kernel to the end of the kernel */ /* Reserve from the start of the kernel to the end of the kernel */
memblock_reserve(vmlinux_start, vmlinux_end - vmlinux_start); memblock_reserve(vmlinux_start, vmlinux_end - vmlinux_start);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment