diff options
author | David Gibson <david@gibson.dropbear.id.au> | 2007-04-30 02:30:56 -0400 |
---|---|---|
committer | Paul Mackerras <paulus@samba.org> | 2007-05-02 06:04:30 -0400 |
commit | f88df14b1f15cdeffa060580a40c1ce3e13bb79e (patch) | |
tree | 0619f32c2be79a85792537ad4410cc8d729f4f75 /include/asm-powerpc/pgalloc-64.h | |
parent | 69d48b409cac747cc0707b05b769e38488a6ad35 (diff) |
[POWERPC] Remove arch/powerpc's dependence on asm-ppc/pg{alloc,table}.h
Currently, all 32-bit powerpc platforms use asm-ppc/pgtable.h and
asm-ppc/pgalloc.h, even when otherwise compiled with ARCH=powerpc.
Those asm-ppc files are a fairly nasty tangle of #ifdefs including a
bunch of things which shouldn't be necessary any more in arch/powerpc.
Cleaning up that mess is going to take a while, but this patch is a
first step. It separates the asm-powerpc/pg{alloc,table}.h into 64
bit and 32 bit versions in asm-powerpc, which the basic .h files in
asm-powerpc select based on config. We make a few tiny tweaks to the
innards of the files along the way, making the outermost ifdefs
(double-inclusion protection and __KERNEL__) a little cleaner, and
#including asm-generic/pgtable.h from the top-level
asm-powerpc/pgtable.h (since both the old 32-bit and 64-bit versions
ended with such an #include).
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Paul Mackerras <paulus@samba.org>
Diffstat (limited to 'include/asm-powerpc/pgalloc-64.h')
-rw-r--r-- | include/asm-powerpc/pgalloc-64.h | 152 |
1 files changed, 152 insertions, 0 deletions
diff --git a/include/asm-powerpc/pgalloc-64.h b/include/asm-powerpc/pgalloc-64.h new file mode 100644 index 000000000000..30b50cf56e2c --- /dev/null +++ b/include/asm-powerpc/pgalloc-64.h | |||
@@ -0,0 +1,152 @@ | |||
1 | #ifndef _ASM_POWERPC_PGALLOC_64_H | ||
2 | #define _ASM_POWERPC_PGALLOC_64_H | ||
3 | /* | ||
4 | * This program is free software; you can redistribute it and/or | ||
5 | * modify it under the terms of the GNU General Public License | ||
6 | * as published by the Free Software Foundation; either version | ||
7 | * 2 of the License, or (at your option) any later version. | ||
8 | */ | ||
9 | |||
10 | #include <linux/mm.h> | ||
11 | #include <linux/slab.h> | ||
12 | #include <linux/cpumask.h> | ||
13 | #include <linux/percpu.h> | ||
14 | |||
15 | extern struct kmem_cache *pgtable_cache[]; | ||
16 | |||
17 | #ifdef CONFIG_PPC_64K_PAGES | ||
18 | #define PTE_CACHE_NUM 0 | ||
19 | #define PMD_CACHE_NUM 1 | ||
20 | #define PGD_CACHE_NUM 2 | ||
21 | #define HUGEPTE_CACHE_NUM 3 | ||
22 | #else | ||
23 | #define PTE_CACHE_NUM 0 | ||
24 | #define PMD_CACHE_NUM 1 | ||
25 | #define PUD_CACHE_NUM 1 | ||
26 | #define PGD_CACHE_NUM 0 | ||
27 | #define HUGEPTE_CACHE_NUM 2 | ||
28 | #endif | ||
29 | |||
30 | static inline pgd_t *pgd_alloc(struct mm_struct *mm) | ||
31 | { | ||
32 | return kmem_cache_alloc(pgtable_cache[PGD_CACHE_NUM], GFP_KERNEL); | ||
33 | } | ||
34 | |||
35 | static inline void pgd_free(pgd_t *pgd) | ||
36 | { | ||
37 | kmem_cache_free(pgtable_cache[PGD_CACHE_NUM], pgd); | ||
38 | } | ||
39 | |||
40 | #ifndef CONFIG_PPC_64K_PAGES | ||
41 | |||
42 | #define pgd_populate(MM, PGD, PUD) pgd_set(PGD, PUD) | ||
43 | |||
44 | static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long addr) | ||
45 | { | ||
46 | return kmem_cache_alloc(pgtable_cache[PUD_CACHE_NUM], | ||
47 | GFP_KERNEL|__GFP_REPEAT); | ||
48 | } | ||
49 | |||
50 | static inline void pud_free(pud_t *pud) | ||
51 | { | ||
52 | kmem_cache_free(pgtable_cache[PUD_CACHE_NUM], pud); | ||
53 | } | ||
54 | |||
55 | static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd) | ||
56 | { | ||
57 | pud_set(pud, (unsigned long)pmd); | ||
58 | } | ||
59 | |||
60 | #define pmd_populate(mm, pmd, pte_page) \ | ||
61 | pmd_populate_kernel(mm, pmd, page_address(pte_page)) | ||
62 | #define pmd_populate_kernel(mm, pmd, pte) pmd_set(pmd, (unsigned long)(pte)) | ||
63 | |||
64 | |||
65 | #else /* CONFIG_PPC_64K_PAGES */ | ||
66 | |||
67 | #define pud_populate(mm, pud, pmd) pud_set(pud, (unsigned long)pmd) | ||
68 | |||
69 | static inline void pmd_populate_kernel(struct mm_struct *mm, pmd_t *pmd, | ||
70 | pte_t *pte) | ||
71 | { | ||
72 | pmd_set(pmd, (unsigned long)pte); | ||
73 | } | ||
74 | |||
75 | #define pmd_populate(mm, pmd, pte_page) \ | ||
76 | pmd_populate_kernel(mm, pmd, page_address(pte_page)) | ||
77 | |||
78 | #endif /* CONFIG_PPC_64K_PAGES */ | ||
79 | |||
80 | static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long addr) | ||
81 | { | ||
82 | return kmem_cache_alloc(pgtable_cache[PMD_CACHE_NUM], | ||
83 | GFP_KERNEL|__GFP_REPEAT); | ||
84 | } | ||
85 | |||
86 | static inline void pmd_free(pmd_t *pmd) | ||
87 | { | ||
88 | kmem_cache_free(pgtable_cache[PMD_CACHE_NUM], pmd); | ||
89 | } | ||
90 | |||
91 | static inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm, | ||
92 | unsigned long address) | ||
93 | { | ||
94 | return kmem_cache_alloc(pgtable_cache[PTE_CACHE_NUM], | ||
95 | GFP_KERNEL|__GFP_REPEAT); | ||
96 | } | ||
97 | |||
98 | static inline struct page *pte_alloc_one(struct mm_struct *mm, | ||
99 | unsigned long address) | ||
100 | { | ||
101 | return virt_to_page(pte_alloc_one_kernel(mm, address)); | ||
102 | } | ||
103 | |||
104 | static inline void pte_free_kernel(pte_t *pte) | ||
105 | { | ||
106 | kmem_cache_free(pgtable_cache[PTE_CACHE_NUM], pte); | ||
107 | } | ||
108 | |||
109 | static inline void pte_free(struct page *ptepage) | ||
110 | { | ||
111 | pte_free_kernel(page_address(ptepage)); | ||
112 | } | ||
113 | |||
114 | #define PGF_CACHENUM_MASK 0x3 | ||
115 | |||
116 | typedef struct pgtable_free { | ||
117 | unsigned long val; | ||
118 | } pgtable_free_t; | ||
119 | |||
120 | static inline pgtable_free_t pgtable_free_cache(void *p, int cachenum, | ||
121 | unsigned long mask) | ||
122 | { | ||
123 | BUG_ON(cachenum > PGF_CACHENUM_MASK); | ||
124 | |||
125 | return (pgtable_free_t){.val = ((unsigned long) p & ~mask) | cachenum}; | ||
126 | } | ||
127 | |||
128 | static inline void pgtable_free(pgtable_free_t pgf) | ||
129 | { | ||
130 | void *p = (void *)(pgf.val & ~PGF_CACHENUM_MASK); | ||
131 | int cachenum = pgf.val & PGF_CACHENUM_MASK; | ||
132 | |||
133 | kmem_cache_free(pgtable_cache[cachenum], p); | ||
134 | } | ||
135 | |||
136 | extern void pgtable_free_tlb(struct mmu_gather *tlb, pgtable_free_t pgf); | ||
137 | |||
138 | #define __pte_free_tlb(tlb, ptepage) \ | ||
139 | pgtable_free_tlb(tlb, pgtable_free_cache(page_address(ptepage), \ | ||
140 | PTE_CACHE_NUM, PTE_TABLE_SIZE-1)) | ||
141 | #define __pmd_free_tlb(tlb, pmd) \ | ||
142 | pgtable_free_tlb(tlb, pgtable_free_cache(pmd, \ | ||
143 | PMD_CACHE_NUM, PMD_TABLE_SIZE-1)) | ||
144 | #ifndef CONFIG_PPC_64K_PAGES | ||
145 | #define __pud_free_tlb(tlb, pud) \ | ||
146 | pgtable_free_tlb(tlb, pgtable_free_cache(pud, \ | ||
147 | PUD_CACHE_NUM, PUD_TABLE_SIZE-1)) | ||
148 | #endif /* CONFIG_PPC_64K_PAGES */ | ||
149 | |||
150 | #define check_pgt_cache() do { } while (0) | ||
151 | |||
152 | #endif /* _ASM_POWERPC_PGALLOC_64_H */ | ||