Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | #ifndef __ASM_SH_PGALLOC_H |
| 2 | #define __ASM_SH_PGALLOC_H |
| 3 | |
Paul Mundt | 5f8c990 | 2007-05-08 11:55:21 +0900 | [diff] [blame] | 4 | #include <linux/quicklist.h> |
| 5 | #include <asm/page.h> |
| 6 | |
Paul Mundt | 5f8c990 | 2007-05-08 11:55:21 +0900 | [diff] [blame] | 7 | #define QUICK_PT 1 /* Other page table pages that are zero on free */ |
| 8 | |
Matt Fleming | b73c806 | 2009-11-25 22:00:08 +0000 | [diff] [blame^] | 9 | #include <asm/pgalloc_nopmd.h> |
| 10 | |
Stuart Menefy | 99a596f | 2006-11-21 15:38:05 +0900 | [diff] [blame] | 11 | static inline void pmd_populate_kernel(struct mm_struct *mm, pmd_t *pmd, |
| 12 | pte_t *pte) |
| 13 | { |
| 14 | set_pmd(pmd, __pmd((unsigned long)pte)); |
| 15 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 16 | |
| 17 | static inline void pmd_populate(struct mm_struct *mm, pmd_t *pmd, |
Martin Schwidefsky | 2f569af | 2008-02-08 04:22:04 -0800 | [diff] [blame] | 18 | pgtable_t pte) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 19 | { |
Stuart Menefy | 99a596f | 2006-11-21 15:38:05 +0900 | [diff] [blame] | 20 | set_pmd(pmd, __pmd((unsigned long)page_address(pte))); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 21 | } |
Martin Schwidefsky | 2f569af | 2008-02-08 04:22:04 -0800 | [diff] [blame] | 22 | #define pmd_pgtable(pmd) pmd_page(pmd) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 23 | |
| 24 | /* |
| 25 | * Allocate and free page tables. |
| 26 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 27 | static inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm, |
| 28 | unsigned long address) |
| 29 | { |
Paul Mundt | 1039b9a | 2007-05-08 12:07:21 +0900 | [diff] [blame] | 30 | return quicklist_alloc(QUICK_PT, GFP_KERNEL | __GFP_REPEAT, NULL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 31 | } |
| 32 | |
Martin Schwidefsky | 2f569af | 2008-02-08 04:22:04 -0800 | [diff] [blame] | 33 | static inline pgtable_t pte_alloc_one(struct mm_struct *mm, |
| 34 | unsigned long address) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 35 | { |
Martin Schwidefsky | 2f569af | 2008-02-08 04:22:04 -0800 | [diff] [blame] | 36 | struct page *page; |
| 37 | void *pg; |
| 38 | |
| 39 | pg = quicklist_alloc(QUICK_PT, GFP_KERNEL | __GFP_REPEAT, NULL); |
| 40 | if (!pg) |
| 41 | return NULL; |
| 42 | page = virt_to_page(pg); |
| 43 | pgtable_page_ctor(page); |
| 44 | return page; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 45 | } |
| 46 | |
Benjamin Herrenschmidt | 5e54197 | 2008-02-04 22:29:14 -0800 | [diff] [blame] | 47 | 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] | 48 | { |
Paul Mundt | 5f8c990 | 2007-05-08 11:55:21 +0900 | [diff] [blame] | 49 | quicklist_free(QUICK_PT, NULL, pte); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 50 | } |
| 51 | |
Martin Schwidefsky | 2f569af | 2008-02-08 04:22:04 -0800 | [diff] [blame] | 52 | static inline void pte_free(struct mm_struct *mm, pgtable_t pte) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 53 | { |
Martin Schwidefsky | 2f569af | 2008-02-08 04:22:04 -0800 | [diff] [blame] | 54 | pgtable_page_dtor(pte); |
Paul Mundt | 5f8c990 | 2007-05-08 11:55:21 +0900 | [diff] [blame] | 55 | quicklist_free_page(QUICK_PT, NULL, pte); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 56 | } |
| 57 | |
Benjamin Herrenschmidt | 9e1b32c | 2009-07-22 15:44:28 +1000 | [diff] [blame] | 58 | #define __pte_free_tlb(tlb,pte,addr) \ |
Martin Schwidefsky | 2f569af | 2008-02-08 04:22:04 -0800 | [diff] [blame] | 59 | do { \ |
| 60 | pgtable_page_dtor(pte); \ |
| 61 | tlb_remove_page((tlb), (pte)); \ |
| 62 | } while (0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 63 | |
Paul Mundt | 5f8c990 | 2007-05-08 11:55:21 +0900 | [diff] [blame] | 64 | static inline void check_pgt_cache(void) |
| 65 | { |
Matt Fleming | b73c806 | 2009-11-25 22:00:08 +0000 | [diff] [blame^] | 66 | __check_pgt_cache(); |
Paul Mundt | 5f8c990 | 2007-05-08 11:55:21 +0900 | [diff] [blame] | 67 | quicklist_trim(QUICK_PT, NULL, 25, 16); |
| 68 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 69 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 70 | #endif /* __ASM_SH_PGALLOC_H */ |