blob: d770da3f8b6fb2adcc43f6e3bda134b5baa4ef68 [file] [log] [blame]
Andrew Scullb4b6d4a2019-01-02 15:54:55 +00001/* SPDX-License-Identifier: GPL-2.0 */
2#ifndef __ASM_SH_PGALLOC_H
3#define __ASM_SH_PGALLOC_H
4
Andrew Scullb4b6d4a2019-01-02 15:54:55 +00005#include <asm/page.h>
David Brazdil0f672f62019-12-10 10:32:29 +00006#include <asm-generic/pgalloc.h>
Andrew Scullb4b6d4a2019-01-02 15:54:55 +00007
8extern pgd_t *pgd_alloc(struct mm_struct *);
9extern void pgd_free(struct mm_struct *mm, pgd_t *pgd);
10
11#if PAGETABLE_LEVELS > 2
12extern void pud_populate(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd);
13extern pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long address);
14extern void pmd_free(struct mm_struct *mm, pmd_t *pmd);
Olivier Deprez0e641232021-09-23 10:07:05 +020015#define __pmd_free_tlb(tlb, pmdp, addr) pmd_free((tlb)->mm, (pmdp))
Andrew Scullb4b6d4a2019-01-02 15:54:55 +000016#endif
17
18static inline void pmd_populate_kernel(struct mm_struct *mm, pmd_t *pmd,
19 pte_t *pte)
20{
21 set_pmd(pmd, __pmd((unsigned long)pte));
22}
23
24static inline void pmd_populate(struct mm_struct *mm, pmd_t *pmd,
25 pgtable_t pte)
26{
27 set_pmd(pmd, __pmd((unsigned long)page_address(pte)));
28}
29#define pmd_pgtable(pmd) pmd_page(pmd)
30
Andrew Scullb4b6d4a2019-01-02 15:54:55 +000031#define __pte_free_tlb(tlb,pte,addr) \
32do { \
David Brazdil0f672f62019-12-10 10:32:29 +000033 pgtable_pte_page_dtor(pte); \
Andrew Scullb4b6d4a2019-01-02 15:54:55 +000034 tlb_remove_page((tlb), (pte)); \
35} while (0)
36
Andrew Scullb4b6d4a2019-01-02 15:54:55 +000037#endif /* __ASM_SH_PGALLOC_H */