Skip to content

Commit 0fdc636

Browse files
zongboxpaul-walmsley-sifive
authored andcommitted
riscv: Use PMD_SIZE to replace PTE_PARENT_SIZE
The PMD_SIZE is equal to PGDIR_SIZE when __PAGETABLE_PMD_FOLDED is defined. Signed-off-by: Zong Li <[email protected]> Reviewed-by: Anup Patel <[email protected]> Reviewed-by: Christoph Hellwig <[email protected]> [[email protected]: fixed spelling in commit summary] Signed-off-by: Paul Walmsley <[email protected]>
1 parent a99d808 commit 0fdc636

File tree

1 file changed

+4
-9
lines changed

1 file changed

+4
-9
lines changed

arch/riscv/mm/init.c

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -273,15 +273,13 @@ static void __init create_pmd_mapping(pmd_t *pmdp,
273273
#define get_pgd_next_virt(__pa) get_pmd_virt(__pa)
274274
#define create_pgd_next_mapping(__nextp, __va, __pa, __sz, __prot) \
275275
create_pmd_mapping(__nextp, __va, __pa, __sz, __prot)
276-
#define PTE_PARENT_SIZE PMD_SIZE
277276
#define fixmap_pgd_next fixmap_pmd
278277
#else
279278
#define pgd_next_t pte_t
280279
#define alloc_pgd_next(__va) alloc_pte(__va)
281280
#define get_pgd_next_virt(__pa) get_pte_virt(__pa)
282281
#define create_pgd_next_mapping(__nextp, __va, __pa, __sz, __prot) \
283282
create_pte_mapping(__nextp, __va, __pa, __sz, __prot)
284-
#define PTE_PARENT_SIZE PGDIR_SIZE
285283
#define fixmap_pgd_next fixmap_pte
286284
#endif
287285

@@ -314,14 +312,11 @@ static void __init create_pgd_mapping(pgd_t *pgdp,
314312

315313
static uintptr_t __init best_map_size(phys_addr_t base, phys_addr_t size)
316314
{
317-
uintptr_t map_size = PAGE_SIZE;
315+
/* Upgrade to PMD_SIZE mappings whenever possible */
316+
if ((base & (PMD_SIZE - 1)) || (size & (PMD_SIZE - 1)))
317+
return PAGE_SIZE;
318318

319-
/* Upgrade to PMD/PGDIR mappings whenever possible */
320-
if (!(base & (PTE_PARENT_SIZE - 1)) &&
321-
!(size & (PTE_PARENT_SIZE - 1)))
322-
map_size = PTE_PARENT_SIZE;
323-
324-
return map_size;
319+
return PMD_SIZE;
325320
}
326321

327322
/*

0 commit comments

Comments
 (0)