xref: /openbmc/linux/arch/sh/include/asm/pgalloc.h (revision c900529f3d9161bfde5cca0754f83b4d3c3e0220)
1b2441318SGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 */
2f15cbe6fSPaul Mundt #ifndef __ASM_SH_PGALLOC_H
3f15cbe6fSPaul Mundt #define __ASM_SH_PGALLOC_H
4f15cbe6fSPaul Mundt 
5*bb3be388SVishal Moola (Oracle) #include <linux/mm.h>
6f15cbe6fSPaul Mundt #include <asm/page.h>
71355c31eSMike Rapoport 
81355c31eSMike Rapoport #define __HAVE_ARCH_PMD_ALLOC_ONE
91355c31eSMike Rapoport #define __HAVE_ARCH_PMD_FREE
10f9cb654cSMike Rapoport #define __HAVE_ARCH_PGD_FREE
116fb12766SMike Rapoport #include <asm-generic/pgalloc.h>
12f15cbe6fSPaul Mundt 
132a5eaccaSMatt Fleming extern pgd_t *pgd_alloc(struct mm_struct *);
142a5eaccaSMatt Fleming extern void pgd_free(struct mm_struct *mm, pgd_t *pgd);
152a5eaccaSMatt Fleming 
16782bb5a5SPaul Mundt #if PAGETABLE_LEVELS > 2
172a5eaccaSMatt Fleming extern void pud_populate(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd);
182a5eaccaSMatt Fleming extern pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long address);
192a5eaccaSMatt Fleming extern void pmd_free(struct mm_struct *mm, pmd_t *pmd);
20c7bcbc8aSPeter Zijlstra #define __pmd_free_tlb(tlb, pmdp, addr)		pmd_free((tlb)->mm, (pmdp))
215d9b4b19SMatt Fleming #endif
22b73c8063SMatt Fleming 
pmd_populate_kernel(struct mm_struct * mm,pmd_t * pmd,pte_t * pte)23f15cbe6fSPaul Mundt static inline void pmd_populate_kernel(struct mm_struct *mm, pmd_t *pmd,
24f15cbe6fSPaul Mundt 				       pte_t *pte)
25f15cbe6fSPaul Mundt {
26f15cbe6fSPaul Mundt 	set_pmd(pmd, __pmd((unsigned long)pte));
27f15cbe6fSPaul Mundt }
28f15cbe6fSPaul Mundt 
pmd_populate(struct mm_struct * mm,pmd_t * pmd,pgtable_t pte)29f15cbe6fSPaul Mundt static inline void pmd_populate(struct mm_struct *mm, pmd_t *pmd,
30f15cbe6fSPaul Mundt 				pgtable_t pte)
31f15cbe6fSPaul Mundt {
32f15cbe6fSPaul Mundt 	set_pmd(pmd, __pmd((unsigned long)page_address(pte)));
33f15cbe6fSPaul Mundt }
34f15cbe6fSPaul Mundt 
359e1b32caSBenjamin Herrenschmidt #define __pte_free_tlb(tlb, pte, addr)				\
36f15cbe6fSPaul Mundt do {								\
37*bb3be388SVishal Moola (Oracle) 	pagetable_pte_dtor(page_ptdesc(pte));			\
38*bb3be388SVishal Moola (Oracle) 	tlb_remove_page_ptdesc((tlb), (page_ptdesc(pte)));	\
39f15cbe6fSPaul Mundt } while (0)
40f15cbe6fSPaul Mundt 
41f15cbe6fSPaul Mundt #endif /* __ASM_SH_PGALLOC_H */
42