xref: /openbmc/linux/arch/sh/include/asm/pgalloc.h (revision 1355c31eeb7ea61a7f2f2937d17cd4e343a6b5af)
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 
5f15cbe6fSPaul Mundt #include <asm/page.h>
6*1355c31eSMike Rapoport 
7*1355c31eSMike Rapoport #define __HAVE_ARCH_PMD_ALLOC_ONE
8*1355c31eSMike Rapoport #define __HAVE_ARCH_PMD_FREE
96fb12766SMike Rapoport #include <asm-generic/pgalloc.h>
10f15cbe6fSPaul Mundt 
112a5eaccaSMatt Fleming extern pgd_t *pgd_alloc(struct mm_struct *);
122a5eaccaSMatt Fleming extern void pgd_free(struct mm_struct *mm, pgd_t *pgd);
132a5eaccaSMatt Fleming 
14782bb5a5SPaul Mundt #if PAGETABLE_LEVELS > 2
152a5eaccaSMatt Fleming extern void pud_populate(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd);
162a5eaccaSMatt Fleming extern pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long address);
172a5eaccaSMatt Fleming extern void pmd_free(struct mm_struct *mm, pmd_t *pmd);
18c7bcbc8aSPeter Zijlstra #define __pmd_free_tlb(tlb, pmdp, addr)		pmd_free((tlb)->mm, (pmdp))
195d9b4b19SMatt Fleming #endif
20b73c8063SMatt Fleming 
21f15cbe6fSPaul Mundt static inline void pmd_populate_kernel(struct mm_struct *mm, pmd_t *pmd,
22f15cbe6fSPaul Mundt 				       pte_t *pte)
23f15cbe6fSPaul Mundt {
24f15cbe6fSPaul Mundt 	set_pmd(pmd, __pmd((unsigned long)pte));
25f15cbe6fSPaul Mundt }
26f15cbe6fSPaul Mundt 
27f15cbe6fSPaul Mundt static inline void pmd_populate(struct mm_struct *mm, pmd_t *pmd,
28f15cbe6fSPaul Mundt 				pgtable_t pte)
29f15cbe6fSPaul Mundt {
30f15cbe6fSPaul Mundt 	set_pmd(pmd, __pmd((unsigned long)page_address(pte)));
31f15cbe6fSPaul Mundt }
32f15cbe6fSPaul Mundt #define pmd_pgtable(pmd) pmd_page(pmd)
33f15cbe6fSPaul Mundt 
349e1b32caSBenjamin Herrenschmidt #define __pte_free_tlb(tlb,pte,addr)			\
35f15cbe6fSPaul Mundt do {							\
36b4ed71f5SMark Rutland 	pgtable_pte_page_dtor(pte);			\
37f15cbe6fSPaul Mundt 	tlb_remove_page((tlb), (pte));			\
38f15cbe6fSPaul Mundt } while (0)
39f15cbe6fSPaul Mundt 
40f15cbe6fSPaul Mundt #endif /* __ASM_SH_PGALLOC_H */
41