diff options
author | Qinglin Pan <panqinglin2020@iscas.ac.cn> | 2022-11-28 05:36:43 +0300 |
---|---|---|
committer | Palmer Dabbelt <palmer@rivosinc.com> | 2022-12-10 00:42:26 +0300 |
commit | 6ff8ca3f93d3cd2a77f051d2d971cf3638d39546 (patch) | |
tree | 80ec1366fc40f0c3a7bc25f6a994c7ea01599e94 /arch | |
parent | 61b2f0bdaa3c7e6956fdac0a7c1e8284b9b81d1d (diff) | |
download | linux-6ff8ca3f93d3cd2a77f051d2d971cf3638d39546.tar.xz |
riscv: mm: call best_map_size many times during linear-mapping
Modify the best_map_size function to give map_size many times instead
of only once, so a memory region can be mapped by both PMD_SIZE and
PAGE_SIZE.
Signed-off-by: Qinglin Pan <panqinglin2020@iscas.ac.cn>
Reviewed-by: Andrew Jones <ajones@ventanamicro.com>
Reviewed-by: Alexandre Ghiti <alexghiti@rivosinc.com>
Tested-by: Alexandre Ghiti <alexghiti@rivosinc.com>
Link: https://lore.kernel.org/r/20221128023643.329091-1-panqinglin2020@iscas.ac.cn
Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
Diffstat (limited to 'arch')
-rw-r--r-- | arch/riscv/mm/init.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/arch/riscv/mm/init.c b/arch/riscv/mm/init.c index 7d59516ce6b3..bb0028c07ef3 100644 --- a/arch/riscv/mm/init.c +++ b/arch/riscv/mm/init.c @@ -673,10 +673,11 @@ void __init create_pgd_mapping(pgd_t *pgdp, static uintptr_t __init best_map_size(phys_addr_t base, phys_addr_t size) { /* Upgrade to PMD_SIZE mappings whenever possible */ - if ((base & (PMD_SIZE - 1)) || (size & (PMD_SIZE - 1))) - return PAGE_SIZE; + base &= PMD_SIZE - 1; + if (!base && size >= PMD_SIZE) + return PMD_SIZE; - return PMD_SIZE; + return PAGE_SIZE; } #ifdef CONFIG_XIP_KERNEL @@ -1111,9 +1112,9 @@ static void __init setup_vm_final(void) if (end >= __pa(PAGE_OFFSET) + memory_limit) end = __pa(PAGE_OFFSET) + memory_limit; - map_size = best_map_size(start, end - start); for (pa = start; pa < end; pa += map_size) { va = (uintptr_t)__va(pa); + map_size = best_map_size(pa, end - pa); create_pgd_mapping(swapper_pg_dir, va, pa, map_size, pgprot_from_va(va)); |