]>
Commit | Line | Data |
---|---|---|
1da177e4 LT |
1 | #ifndef __ASM_SH_TLB_H |
2 | #define __ASM_SH_TLB_H | |
3 | ||
959f7d58 | 4 | #ifdef CONFIG_SUPERH64 |
a1ce3928 | 5 | # include <asm/tlb_64.h> |
959f7d58 PM |
6 | #endif |
7 | ||
8 | #ifndef __ASSEMBLY__ | |
c2035184 PM |
9 | #include <linux/pagemap.h> |
10 | ||
11 | #ifdef CONFIG_MMU | |
194cd8df | 12 | #include <linux/swap.h> |
c2035184 PM |
13 | #include <asm/pgalloc.h> |
14 | #include <asm/tlbflush.h> | |
24ef7fc4 | 15 | #include <asm/mmu_context.h> |
c2035184 PM |
16 | |
17 | /* | |
18 | * TLB handling. This allows us to remove pages from the page | |
19 | * tables, and efficiently handle the TLB issues. | |
20 | */ | |
21 | struct mmu_gather { | |
22 | struct mm_struct *mm; | |
23 | unsigned int fullmm; | |
24 | unsigned long start, end; | |
25 | }; | |
959f7d58 | 26 | |
c2035184 PM |
27 | static inline void init_tlb_gather(struct mmu_gather *tlb) |
28 | { | |
29 | tlb->start = TASK_SIZE; | |
30 | tlb->end = 0; | |
1da177e4 | 31 | |
c2035184 PM |
32 | if (tlb->fullmm) { |
33 | tlb->start = 0; | |
34 | tlb->end = TASK_SIZE; | |
35 | } | |
36 | } | |
37 | ||
1e56a564 | 38 | static inline void |
2b047252 | 39 | tlb_gather_mmu(struct mmu_gather *tlb, struct mm_struct *mm, unsigned long start, unsigned long end) |
c2035184 | 40 | { |
c2035184 | 41 | tlb->mm = mm; |
2b047252 LT |
42 | tlb->start = start; |
43 | tlb->end = end; | |
44 | tlb->fullmm = !(start | (end+1)); | |
c2035184 PM |
45 | |
46 | init_tlb_gather(tlb); | |
c2035184 PM |
47 | } |
48 | ||
49 | static inline void | |
50 | tlb_finish_mmu(struct mmu_gather *tlb, unsigned long start, unsigned long end) | |
51 | { | |
52 | if (tlb->fullmm) | |
53 | flush_tlb_mm(tlb->mm); | |
54 | ||
55 | /* keep the page table cache within bounds */ | |
56 | check_pgt_cache(); | |
c2035184 PM |
57 | } |
58 | ||
59 | static inline void | |
60 | tlb_remove_tlb_entry(struct mmu_gather *tlb, pte_t *ptep, unsigned long address) | |
61 | { | |
62 | if (tlb->start > address) | |
63 | tlb->start = address; | |
64 | if (tlb->end < address + PAGE_SIZE) | |
65 | tlb->end = address + PAGE_SIZE; | |
66 | } | |
1da177e4 | 67 | |
b528e4b6 AK |
68 | #define tlb_remove_huge_tlb_entry(h, tlb, ptep, address) \ |
69 | tlb_remove_tlb_entry(tlb, ptep, address) | |
70 | ||
1da177e4 | 71 | /* |
c2035184 PM |
72 | * In the case of tlb vma handling, we can optimise these away in the |
73 | * case where we're doing a full MM flush. When we're doing a munmap, | |
74 | * the vmas are adjusted to only cover the region to be torn down. | |
1da177e4 | 75 | */ |
c2035184 PM |
76 | static inline void |
77 | tlb_start_vma(struct mmu_gather *tlb, struct vm_area_struct *vma) | |
78 | { | |
79 | if (!tlb->fullmm) | |
80 | flush_cache_range(vma, vma->vm_start, vma->vm_end); | |
81 | } | |
82 | ||
83 | static inline void | |
84 | tlb_end_vma(struct mmu_gather *tlb, struct vm_area_struct *vma) | |
85 | { | |
86 | if (!tlb->fullmm && tlb->end) { | |
87 | flush_tlb_range(vma, tlb->start, tlb->end); | |
88 | init_tlb_gather(tlb); | |
89 | } | |
90 | } | |
91 | ||
1cf35d47 LT |
92 | static inline void tlb_flush_mmu_tlbonly(struct mmu_gather *tlb) |
93 | { | |
94 | } | |
95 | ||
96 | static inline void tlb_flush_mmu_free(struct mmu_gather *tlb) | |
97 | { | |
98 | } | |
99 | ||
1e56a564 PZ |
100 | static inline void tlb_flush_mmu(struct mmu_gather *tlb) |
101 | { | |
102 | } | |
103 | ||
104 | static inline int __tlb_remove_page(struct mmu_gather *tlb, struct page *page) | |
105 | { | |
106 | free_page_and_swap_cache(page); | |
e9d55e15 | 107 | return false; /* avoid calling tlb_flush_mmu */ |
1e56a564 PZ |
108 | } |
109 | ||
110 | static inline void tlb_remove_page(struct mmu_gather *tlb, struct page *page) | |
111 | { | |
112 | __tlb_remove_page(tlb, page); | |
113 | } | |
114 | ||
e77b0852 AK |
115 | static inline bool __tlb_remove_page_size(struct mmu_gather *tlb, |
116 | struct page *page, int page_size) | |
117 | { | |
118 | return __tlb_remove_page(tlb, page); | |
119 | } | |
120 | ||
e9d55e15 AK |
121 | static inline bool __tlb_remove_pte_page(struct mmu_gather *tlb, |
122 | struct page *page) | |
123 | { | |
124 | return __tlb_remove_page(tlb, page); | |
125 | } | |
126 | ||
e77b0852 AK |
127 | static inline void tlb_remove_page_size(struct mmu_gather *tlb, |
128 | struct page *page, int page_size) | |
129 | { | |
130 | return tlb_remove_page(tlb, page); | |
131 | } | |
132 | ||
07e32661 AK |
133 | #define tlb_remove_check_page_size_change tlb_remove_check_page_size_change |
134 | static inline void tlb_remove_check_page_size_change(struct mmu_gather *tlb, | |
135 | unsigned int page_size) | |
136 | { | |
137 | } | |
138 | ||
9e1b32ca BH |
139 | #define pte_free_tlb(tlb, ptep, addr) pte_free((tlb)->mm, ptep) |
140 | #define pmd_free_tlb(tlb, pmdp, addr) pmd_free((tlb)->mm, pmdp) | |
141 | #define pud_free_tlb(tlb, pudp, addr) pud_free((tlb)->mm, pudp) | |
c2035184 PM |
142 | |
143 | #define tlb_migrate_finish(mm) do { } while (0) | |
144 | ||
bb29c677 | 145 | #if defined(CONFIG_CPU_SH4) || defined(CONFIG_SUPERH64) |
8eda5514 MF |
146 | extern void tlb_wire_entry(struct vm_area_struct *, unsigned long, pte_t); |
147 | extern void tlb_unwire_entry(void); | |
148 | #else | |
149 | static inline void tlb_wire_entry(struct vm_area_struct *vma , | |
150 | unsigned long addr, pte_t pte) | |
151 | { | |
152 | BUG(); | |
153 | } | |
154 | ||
155 | static inline void tlb_unwire_entry(void) | |
156 | { | |
157 | BUG(); | |
158 | } | |
bb29c677 | 159 | #endif |
8eda5514 | 160 | |
c2035184 PM |
161 | #else /* CONFIG_MMU */ |
162 | ||
163 | #define tlb_start_vma(tlb, vma) do { } while (0) | |
164 | #define tlb_end_vma(tlb, vma) do { } while (0) | |
165 | #define __tlb_remove_tlb_entry(tlb, pte, address) do { } while (0) | |
166 | #define tlb_flush(tlb) do { } while (0) | |
1da177e4 LT |
167 | |
168 | #include <asm-generic/tlb.h> | |
959f7d58 | 169 | |
c2035184 | 170 | #endif /* CONFIG_MMU */ |
959f7d58 PM |
171 | #endif /* __ASSEMBLY__ */ |
172 | #endif /* __ASM_SH_TLB_H */ |