Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
| 2 | #ifndef _ALPHA_PGALLOC_H |
| 3 | #define _ALPHA_PGALLOC_H |
| 4 | |
| 5 | #include <linux/mm.h> |
| 6 | #include <linux/mmzone.h> |
| 7 | |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 8 | #include <asm-generic/pgalloc.h> /* for pte_{alloc,free}_one */ |
| 9 | |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 10 | /* |
| 11 | * Allocate and free page tables. The xxx_kernel() versions are |
| 12 | * used to allocate a kernel page table - this turns on ASN bits |
| 13 | * if any. |
| 14 | */ |
| 15 | |
| 16 | static inline void |
| 17 | pmd_populate(struct mm_struct *mm, pmd_t *pmd, pgtable_t pte) |
| 18 | { |
| 19 | pmd_set(pmd, (pte_t *)(page_to_pa(pte) + PAGE_OFFSET)); |
| 20 | } |
| 21 | #define pmd_pgtable(pmd) pmd_page(pmd) |
| 22 | |
| 23 | static inline void |
| 24 | pmd_populate_kernel(struct mm_struct *mm, pmd_t *pmd, pte_t *pte) |
| 25 | { |
| 26 | pmd_set(pmd, pte); |
| 27 | } |
| 28 | |
| 29 | static inline void |
| 30 | pgd_populate(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmd) |
| 31 | { |
| 32 | pgd_set(pgd, pmd); |
| 33 | } |
| 34 | |
| 35 | extern pgd_t *pgd_alloc(struct mm_struct *mm); |
| 36 | |
| 37 | static inline void |
| 38 | pgd_free(struct mm_struct *mm, pgd_t *pgd) |
| 39 | { |
| 40 | free_page((unsigned long)pgd); |
| 41 | } |
| 42 | |
| 43 | static inline pmd_t * |
| 44 | pmd_alloc_one(struct mm_struct *mm, unsigned long address) |
| 45 | { |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 46 | pmd_t *ret = (pmd_t *)__get_free_page(GFP_PGTABLE_USER); |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 47 | return ret; |
| 48 | } |
| 49 | |
| 50 | static inline void |
| 51 | pmd_free(struct mm_struct *mm, pmd_t *pmd) |
| 52 | { |
| 53 | free_page((unsigned long)pmd); |
| 54 | } |
| 55 | |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 56 | #endif /* _ALPHA_PGALLOC_H */ |