--- v1
+++ v3
@@ -1,30 +1,72 @@
-Part of the conversions to replace pgtable constructor/destructors with
-ptdesc equivalents. Also cleans up some spacing issues.
+As part of the conversions to replace pgtable constructor/destructors with
+ptdesc equivalents, convert various page table functions to use ptdescs.
+
+Some of the functions use the *get*page*() helper functions. Convert
+these to use pagetable_alloc() and ptdesc_address() instead to help
+standardize page tables further.
Signed-off-by: Vishal Moola (Oracle) <vishal.moola@gmail.com>
+Acked-by: Palmer Dabbelt <palmer@rivosinc.com>
---
- arch/sh/include/asm/pgalloc.h | 8 ++++----
- 1 file changed, 4 insertions(+), 4 deletions(-)
+ arch/riscv/include/asm/pgalloc.h | 8 ++++----
+ arch/riscv/mm/init.c | 16 ++++++----------
+ 2 files changed, 10 insertions(+), 14 deletions(-)
-diff --git a/arch/sh/include/asm/pgalloc.h b/arch/sh/include/asm/pgalloc.h
-index a9e98233c4d4..30e1823d2347 100644
---- a/arch/sh/include/asm/pgalloc.h
-+++ b/arch/sh/include/asm/pgalloc.h
-@@ -31,10 +31,10 @@ static inline void pmd_populate(struct mm_struct *mm, pmd_t *pmd,
- set_pmd(pmd, __pmd((unsigned long)page_address(pte)));
+diff --git a/arch/riscv/include/asm/pgalloc.h b/arch/riscv/include/asm/pgalloc.h
+index 59dc12b5b7e8..d169a4f41a2e 100644
+--- a/arch/riscv/include/asm/pgalloc.h
++++ b/arch/riscv/include/asm/pgalloc.h
+@@ -153,10 +153,10 @@ static inline pgd_t *pgd_alloc(struct mm_struct *mm)
+
+ #endif /* __PAGETABLE_PMD_FOLDED */
+
+-#define __pte_free_tlb(tlb, pte, buf) \
+-do { \
+- pgtable_pte_page_dtor(pte); \
+- tlb_remove_page((tlb), pte); \
++#define __pte_free_tlb(tlb, pte, buf) \
++do { \
++ pagetable_pte_dtor(page_ptdesc(pte)); \
++ tlb_remove_page_ptdesc((tlb), page_ptdesc(pte));\
+ } while (0)
+ #endif /* CONFIG_MMU */
+
+diff --git a/arch/riscv/mm/init.c b/arch/riscv/mm/init.c
+index 2f7a7c345a6a..2fe6ca1b1f95 100644
+--- a/arch/riscv/mm/init.c
++++ b/arch/riscv/mm/init.c
+@@ -353,12 +353,10 @@ static inline phys_addr_t __init alloc_pte_fixmap(uintptr_t va)
+
+ static phys_addr_t __init alloc_pte_late(uintptr_t va)
+ {
+- unsigned long vaddr;
+-
+- vaddr = __get_free_page(GFP_KERNEL);
+- BUG_ON(!vaddr || !pgtable_pte_page_ctor(virt_to_page((void *)vaddr)));
++ struct ptdesc *ptdesc = pagetable_alloc(GFP_KERNEL, 0);
+
+- return __pa(vaddr);
++ BUG_ON(!ptdesc || !pagetable_pte_ctor(ptdesc));
++ return __pa((pte_t *)ptdesc_address(ptdesc));
}
--#define __pte_free_tlb(tlb,pte,addr) \
--do { \
-- pgtable_pte_page_dtor(pte); \
-- tlb_remove_page((tlb), (pte)); \
-+#define __pte_free_tlb(tlb, pte, addr) \
-+do { \
-+ ptdesc_pte_dtor(page_ptdesc(pte)); \
-+ tlb_remove_page_ptdesc((tlb), (page_ptdesc(pte))); \
- } while (0)
+ static void __init create_pte_mapping(pte_t *ptep,
+@@ -436,12 +434,10 @@ static phys_addr_t __init alloc_pmd_fixmap(uintptr_t va)
- #endif /* __ASM_SH_PGALLOC_H */
+ static phys_addr_t __init alloc_pmd_late(uintptr_t va)
+ {
+- unsigned long vaddr;
+-
+- vaddr = __get_free_page(GFP_KERNEL);
+- BUG_ON(!vaddr || !pgtable_pmd_page_ctor(virt_to_page((void *)vaddr)));
++ struct ptdesc *ptdesc = pagetable_alloc(GFP_KERNEL, 0);
+
+- return __pa(vaddr);
++ BUG_ON(!ptdesc || !pagetable_pmd_ctor(ptdesc));
++ return __pa((pmd_t *)ptdesc_address(ptdesc));
+ }
+
+ static void __init create_pmd_mapping(pmd_t *pmdp,
--
-2.39.2
+2.40.1