1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _MOTOROLA_PGALLOC_H
3 #define _MOTOROLA_PGALLOC_H
6 #include <asm/tlbflush.h>
8 extern pmd_t
*get_pointer_table(void);
9 extern int free_pointer_table(pmd_t
*);
11 static inline pte_t
*pte_alloc_one_kernel(struct mm_struct
*mm
)
15 pte
= (pte_t
*)__get_free_page(GFP_KERNEL
|__GFP_ZERO
);
17 __flush_page_to_ram(pte
);
18 flush_tlb_kernel_page(pte
);
25 static inline void pte_free_kernel(struct mm_struct
*mm
, pte_t
*pte
)
28 free_page((unsigned long) pte
);
31 static inline pgtable_t
pte_alloc_one(struct mm_struct
*mm
)
36 page
= alloc_pages(GFP_KERNEL
|__GFP_ZERO
, 0);
39 if (!pgtable_pte_page_ctor(page
)) {
45 __flush_page_to_ram(pte
);
46 flush_tlb_kernel_page(pte
);
52 static inline void pte_free(struct mm_struct
*mm
, pgtable_t page
)
54 pgtable_pte_page_dtor(page
);
55 cache_page(kmap(page
));
60 static inline void __pte_free_tlb(struct mmu_gather
*tlb
, pgtable_t page
,
61 unsigned long address
)
63 pgtable_pte_page_dtor(page
);
64 cache_page(kmap(page
));
70 static inline pmd_t
*pmd_alloc_one(struct mm_struct
*mm
, unsigned long address
)
72 return get_pointer_table();
75 static inline int pmd_free(struct mm_struct
*mm
, pmd_t
*pmd
)
77 return free_pointer_table(pmd
);
80 static inline int __pmd_free_tlb(struct mmu_gather
*tlb
, pmd_t
*pmd
,
81 unsigned long address
)
83 return free_pointer_table(pmd
);
87 static inline void pgd_free(struct mm_struct
*mm
, pgd_t
*pgd
)
89 pmd_free(mm
, (pmd_t
*)pgd
);
92 static inline pgd_t
*pgd_alloc(struct mm_struct
*mm
)
94 return (pgd_t
*)get_pointer_table();
98 static inline void pmd_populate_kernel(struct mm_struct
*mm
, pmd_t
*pmd
, pte_t
*pte
)
103 static inline void pmd_populate(struct mm_struct
*mm
, pmd_t
*pmd
, pgtable_t page
)
105 pmd_set(pmd
, page_address(page
));
107 #define pmd_pgtable(pmd) pmd_page(pmd)
109 static inline void pud_populate(struct mm_struct
*mm
, pud_t
*pud
, pmd_t
*pmd
)
114 #endif /* _MOTOROLA_PGALLOC_H */