Skip to content

Commit 6ff8ca3

Browse files
PanQLpalmer-dabbelt
authored andcommitted
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 <[email protected]> Reviewed-by: Andrew Jones <[email protected]> Reviewed-by: Alexandre Ghiti <[email protected]> Tested-by: Alexandre Ghiti <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Palmer Dabbelt <[email protected]>
1 parent 61b2f0b commit 6ff8ca3

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

arch/riscv/mm/init.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -673,10 +673,11 @@ void __init create_pgd_mapping(pgd_t *pgdp,
673673
static uintptr_t __init best_map_size(phys_addr_t base, phys_addr_t size)
674674
{
675675
/* Upgrade to PMD_SIZE mappings whenever possible */
676-
if ((base & (PMD_SIZE - 1)) || (size & (PMD_SIZE - 1)))
677-
return PAGE_SIZE;
676+
base &= PMD_SIZE - 1;
677+
if (!base && size >= PMD_SIZE)
678+
return PMD_SIZE;
678679

679-
return PMD_SIZE;
680+
return PAGE_SIZE;
680681
}
681682

682683
#ifdef CONFIG_XIP_KERNEL
@@ -1111,9 +1112,9 @@ static void __init setup_vm_final(void)
11111112
if (end >= __pa(PAGE_OFFSET) + memory_limit)
11121113
end = __pa(PAGE_OFFSET) + memory_limit;
11131114

1114-
map_size = best_map_size(start, end - start);
11151115
for (pa = start; pa < end; pa += map_size) {
11161116
va = (uintptr_t)__va(pa);
1117+
map_size = best_map_size(pa, end - pa);
11171118

11181119
create_pgd_mapping(swapper_pg_dir, va, pa, map_size,
11191120
pgprot_from_va(va));

0 commit comments

Comments
 (0)