diff options
author | Atish Patra <atish.patra@wdc.com> | 2020-10-07 14:51:59 -0700 |
---|---|---|
committer | Palmer Dabbelt <palmerdabbelt@google.com> | 2020-11-05 09:56:17 -0800 |
commit | 1bd14a66ee5200d6a24419cbd2e0a0fccd4da36f (patch) | |
tree | 41ae3dc2bf7ac062e0d5878cb03f3731d85ba025 /arch | |
parent | 9d750c75bd2c3fcf20a3c15378d1bc6b2d4ec31f (diff) | |
download | linux-stable-1bd14a66ee5200d6a24419cbd2e0a0fccd4da36f.tar.gz linux-stable-1bd14a66ee5200d6a24419cbd2e0a0fccd4da36f.tar.bz2 linux-stable-1bd14a66ee5200d6a24419cbd2e0a0fccd4da36f.zip |
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: Atish Patra <atish.patra@wdc.com>
Reviewed-by: Mike Rapoport <rppt@linux.ibm.com>
Signed-off-by: Palmer Dabbelt <palmerdabbelt@google.com>
Diffstat (limited to 'arch')
-rw-r--r-- | arch/riscv/mm/init.c | 18 |
1 files changed, 7 insertions, 11 deletions
diff --git a/arch/riscv/mm/init.c b/arch/riscv/mm/init.c index ea933b789a88..42c14eb6bc43 100644 --- a/arch/riscv/mm/init.c +++ b/arch/riscv/mm/init.c @@ -154,9 +154,8 @@ disable: void __init setup_bootmem(void) { - phys_addr_t mem_size = 0; - phys_addr_t total_mem = 0; - phys_addr_t mem_start, start, end = 0; + phys_addr_t mem_start = 0; + phys_addr_t start, end = 0; phys_addr_t vmlinux_end = __pa_symbol(&_end); phys_addr_t vmlinux_start = __pa_symbol(&_start); u64 i; @@ -164,21 +163,18 @@ void __init setup_bootmem(void) /* Find the memory region containing the kernel */ for_each_mem_range(i, &start, &end) { phys_addr_t size = end - start; - if (!total_mem) + if (!mem_start) mem_start = start; if (start <= vmlinux_start && vmlinux_end <= end) BUG_ON(size == 0); - total_mem = total_mem + size; } /* - * Remove memblock from the end of usable area to the - * end of region + * The maximal physical memory size is -PAGE_OFFSET. + * 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); - if (mem_start + mem_size < end) - memblock_remove(mem_start + mem_size, - end - mem_start - mem_size); + memblock_enforce_memory_limit(mem_start - PAGE_OFFSET); /* Reserve from the start of the kernel to the end of the kernel */ memblock_reserve(vmlinux_start, vmlinux_end - vmlinux_start); |