Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | #ifndef _SPARC64_PGALLOC_H |
| 2 | #define _SPARC64_PGALLOC_H |
| 3 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4 | #include <linux/kernel.h> |
| 5 | #include <linux/sched.h> |
| 6 | #include <linux/mm.h> |
David S. Miller | 3c93646 | 2006-01-31 18:30:27 -0800 | [diff] [blame] | 7 | #include <linux/slab.h> |
David Miller | 3a2cba9 | 2007-05-06 14:49:51 -0700 | [diff] [blame] | 8 | #include <linux/quicklist.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 9 | |
| 10 | #include <asm/spitfire.h> |
| 11 | #include <asm/cpudata.h> |
| 12 | #include <asm/cacheflush.h> |
David S. Miller | 6a9b490 | 2005-09-19 20:11:57 -0700 | [diff] [blame] | 13 | #include <asm/page.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 14 | |
| 15 | /* Page table allocation/freeing. */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 16 | |
David S. Miller | 3c93646 | 2006-01-31 18:30:27 -0800 | [diff] [blame] | 17 | static inline pgd_t *pgd_alloc(struct mm_struct *mm) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 18 | { |
David Miller | 3a2cba9 | 2007-05-06 14:49:51 -0700 | [diff] [blame] | 19 | return quicklist_alloc(0, GFP_KERNEL, NULL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 20 | } |
| 21 | |
Benjamin Herrenschmidt | 5e54197 | 2008-02-04 22:29:14 -0800 | [diff] [blame] | 22 | static inline void pgd_free(struct mm_struct *mm, pgd_t *pgd) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 23 | { |
David Miller | 3a2cba9 | 2007-05-06 14:49:51 -0700 | [diff] [blame] | 24 | quicklist_free(0, NULL, pgd); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 25 | } |
| 26 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 27 | #define pud_populate(MM, PUD, PMD) pud_set(PUD, PMD) |
| 28 | |
David S. Miller | 3c93646 | 2006-01-31 18:30:27 -0800 | [diff] [blame] | 29 | static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long addr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 30 | { |
David Miller | 3a2cba9 | 2007-05-06 14:49:51 -0700 | [diff] [blame] | 31 | return quicklist_alloc(0, GFP_KERNEL, NULL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 32 | } |
| 33 | |
Benjamin Herrenschmidt | 5e54197 | 2008-02-04 22:29:14 -0800 | [diff] [blame] | 34 | static inline void pmd_free(struct mm_struct *mm, pmd_t *pmd) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 35 | { |
David Miller | 3a2cba9 | 2007-05-06 14:49:51 -0700 | [diff] [blame] | 36 | quicklist_free(0, NULL, pmd); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 37 | } |
| 38 | |
David S. Miller | 3c93646 | 2006-01-31 18:30:27 -0800 | [diff] [blame] | 39 | static inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm, |
| 40 | unsigned long address) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 41 | { |
David Miller | 3a2cba9 | 2007-05-06 14:49:51 -0700 | [diff] [blame] | 42 | return quicklist_alloc(0, GFP_KERNEL, NULL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 43 | } |
| 44 | |
Martin Schwidefsky | 2f569af | 2008-02-08 04:22:04 -0800 | [diff] [blame] | 45 | static inline pgtable_t pte_alloc_one(struct mm_struct *mm, |
| 46 | unsigned long address) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 47 | { |
Martin Schwidefsky | 2f569af | 2008-02-08 04:22:04 -0800 | [diff] [blame] | 48 | struct page *page; |
| 49 | void *pg; |
| 50 | |
| 51 | pg = quicklist_alloc(0, GFP_KERNEL, NULL); |
| 52 | if (!pg) |
| 53 | return NULL; |
| 54 | page = virt_to_page(pg); |
| 55 | pgtable_page_ctor(page); |
| 56 | return page; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 57 | } |
David S. Miller | 3c93646 | 2006-01-31 18:30:27 -0800 | [diff] [blame] | 58 | |
Benjamin Herrenschmidt | 5e54197 | 2008-02-04 22:29:14 -0800 | [diff] [blame] | 59 | static inline void pte_free_kernel(struct mm_struct *mm, pte_t *pte) |
David S. Miller | 3c93646 | 2006-01-31 18:30:27 -0800 | [diff] [blame] | 60 | { |
David Miller | 3a2cba9 | 2007-05-06 14:49:51 -0700 | [diff] [blame] | 61 | quicklist_free(0, NULL, pte); |
David S. Miller | 3c93646 | 2006-01-31 18:30:27 -0800 | [diff] [blame] | 62 | } |
| 63 | |
Martin Schwidefsky | 2f569af | 2008-02-08 04:22:04 -0800 | [diff] [blame] | 64 | static inline void pte_free(struct mm_struct *mm, pgtable_t ptepage) |
David S. Miller | 3c93646 | 2006-01-31 18:30:27 -0800 | [diff] [blame] | 65 | { |
Martin Schwidefsky | 2f569af | 2008-02-08 04:22:04 -0800 | [diff] [blame] | 66 | pgtable_page_dtor(ptepage); |
David Miller | 3a2cba9 | 2007-05-06 14:49:51 -0700 | [diff] [blame] | 67 | quicklist_free_page(0, NULL, ptepage); |
David S. Miller | 3c93646 | 2006-01-31 18:30:27 -0800 | [diff] [blame] | 68 | } |
| 69 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 70 | |
| 71 | #define pmd_populate_kernel(MM, PMD, PTE) pmd_set(PMD, PTE) |
| 72 | #define pmd_populate(MM,PMD,PTE_PAGE) \ |
| 73 | pmd_populate_kernel(MM,PMD,page_address(PTE_PAGE)) |
Martin Schwidefsky | 2f569af | 2008-02-08 04:22:04 -0800 | [diff] [blame] | 74 | #define pmd_pgtable(pmd) pmd_page(pmd) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 75 | |
David Miller | 3a2cba9 | 2007-05-06 14:49:51 -0700 | [diff] [blame] | 76 | static inline void check_pgt_cache(void) |
| 77 | { |
| 78 | quicklist_trim(0, NULL, 25, 16); |
| 79 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 80 | |
| 81 | #endif /* _SPARC64_PGALLOC_H */ |