Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | #ifndef _CRIS_PGALLOC_H |
| 2 | #define _CRIS_PGALLOC_H |
| 3 | |
| 4 | #include <linux/threads.h> |
| 5 | #include <linux/mm.h> |
| 6 | |
| 7 | #define pmd_populate_kernel(mm, pmd, pte) pmd_set(pmd, pte) |
| 8 | #define pmd_populate(mm, pmd, pte) pmd_set(pmd, page_address(pte)) |
Martin Schwidefsky | 2f569af | 2008-02-08 04:22:04 -0800 | [diff] [blame] | 9 | #define pmd_pgtable(pmd) pmd_page(pmd) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 10 | |
| 11 | /* |
| 12 | * Allocate and free page tables. |
| 13 | */ |
| 14 | |
Adrian Bunk | d9b5444 | 2005-11-07 00:58:44 -0800 | [diff] [blame] | 15 | static inline pgd_t *pgd_alloc (struct mm_struct *mm) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 16 | { |
| 17 | return (pgd_t *)get_zeroed_page(GFP_KERNEL); |
| 18 | } |
| 19 | |
Benjamin Herrenschmidt | 5e54197 | 2008-02-04 22:29:14 -0800 | [diff] [blame] | 20 | static inline void pgd_free(struct mm_struct *mm, pgd_t *pgd) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 21 | { |
| 22 | free_page((unsigned long)pgd); |
| 23 | } |
| 24 | |
Adrian Bunk | d9b5444 | 2005-11-07 00:58:44 -0800 | [diff] [blame] | 25 | static inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm, unsigned long address) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 26 | { |
| 27 | pte_t *pte = (pte_t *)__get_free_page(GFP_KERNEL|__GFP_REPEAT|__GFP_ZERO); |
| 28 | return pte; |
| 29 | } |
| 30 | |
Martin Schwidefsky | 2f569af | 2008-02-08 04:22:04 -0800 | [diff] [blame] | 31 | static inline pgtable_t pte_alloc_one(struct mm_struct *mm, unsigned long address) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 32 | { |
| 33 | struct page *pte; |
| 34 | pte = alloc_pages(GFP_KERNEL|__GFP_REPEAT|__GFP_ZERO, 0); |
Kirill A. Shutemov | 26db390 | 2013-11-14 14:31:17 -0800 | [diff] [blame] | 35 | if (!pte) |
| 36 | return NULL; |
Kirill A. Shutemov | 0da5303 | 2013-11-14 14:31:29 -0800 | [diff] [blame] | 37 | if (!pgtable_page_ctor(pte)) { |
| 38 | __free_page(pte); |
| 39 | return NULL; |
| 40 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 41 | return pte; |
| 42 | } |
| 43 | |
Benjamin Herrenschmidt | 5e54197 | 2008-02-04 22:29:14 -0800 | [diff] [blame] | 44 | static inline void pte_free_kernel(struct mm_struct *mm, pte_t *pte) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 45 | { |
| 46 | free_page((unsigned long)pte); |
| 47 | } |
| 48 | |
Martin Schwidefsky | 2f569af | 2008-02-08 04:22:04 -0800 | [diff] [blame] | 49 | static inline void pte_free(struct mm_struct *mm, pgtable_t pte) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 50 | { |
Martin Schwidefsky | 2f569af | 2008-02-08 04:22:04 -0800 | [diff] [blame] | 51 | pgtable_page_dtor(pte); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 52 | __free_page(pte); |
| 53 | } |
| 54 | |
Benjamin Herrenschmidt | 9e1b32c | 2009-07-22 15:44:28 +1000 | [diff] [blame] | 55 | #define __pte_free_tlb(tlb,pte,address) \ |
Martin Schwidefsky | 2f569af | 2008-02-08 04:22:04 -0800 | [diff] [blame] | 56 | do { \ |
| 57 | pgtable_page_dtor(pte); \ |
| 58 | tlb_remove_page((tlb), pte); \ |
| 59 | } while (0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 60 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 61 | #define check_pgt_cache() do { } while (0) |
| 62 | |
| 63 | #endif |