diff options
author | Akira Takeuchi <takeuchi.akr@jp.panasonic.com> | 2010-10-27 12:28:51 -0400 |
---|---|---|
committer | David Howells <dhowells@redhat.com> | 2010-10-27 12:28:51 -0400 |
commit | 965ea4bbb9ae926358273368144ba838c561bc38 (patch) | |
tree | c6ee08f2f2970bb500ccc7cf58de6beea870e4f8 /arch/mn10300/include | |
parent | dccbf4853a31a3f774f38c402209d23388d99f52 (diff) |
MN10300: SMP TLB flushing
Implement global TLB flushing for MN10300. This will be used by the AM34 which
is SMP capable.
Signed-off-by: Akira Takeuchi <takeuchi.akr@jp.panasonic.com>
Signed-off-by: Kiyoshi Owada <owada.kiyoshi@jp.panasonic.com>
Signed-off-by: David Howells <dhowells@redhat.com>
Diffstat (limited to 'arch/mn10300/include')
-rw-r--r-- | arch/mn10300/include/asm/mmu_context.h | 22 | ||||
-rw-r--r-- | arch/mn10300/include/asm/tlbflush.h | 81 |
2 files changed, 74 insertions, 29 deletions
diff --git a/arch/mn10300/include/asm/mmu_context.h b/arch/mn10300/include/asm/mmu_context.h index 5fb3648968ae..c8f6c82672ad 100644 --- a/arch/mn10300/include/asm/mmu_context.h +++ b/arch/mn10300/include/asm/mmu_context.h | |||
@@ -36,6 +36,22 @@ | |||
36 | 36 | ||
37 | #define enter_lazy_tlb(mm, tsk) do {} while (0) | 37 | #define enter_lazy_tlb(mm, tsk) do {} while (0) |
38 | 38 | ||
39 | static inline void cpu_ran_vm(int cpu, struct mm_struct *mm) | ||
40 | { | ||
41 | #ifdef CONFIG_SMP | ||
42 | cpumask_set_cpu(cpu, mm_cpumask(mm)); | ||
43 | #endif | ||
44 | } | ||
45 | |||
46 | static inline bool cpu_maybe_ran_vm(int cpu, struct mm_struct *mm) | ||
47 | { | ||
48 | #ifdef CONFIG_SMP | ||
49 | return cpumask_test_and_set_cpu(cpu, mm_cpumask(mm)); | ||
50 | #else | ||
51 | return true; | ||
52 | #endif | ||
53 | } | ||
54 | |||
39 | #ifdef CONFIG_MN10300_TLB_USE_PIDR | 55 | #ifdef CONFIG_MN10300_TLB_USE_PIDR |
40 | extern unsigned long mmu_context_cache[NR_CPUS]; | 56 | extern unsigned long mmu_context_cache[NR_CPUS]; |
41 | #define mm_context(mm) (mm->context.tlbpid[smp_processor_id()]) | 57 | #define mm_context(mm) (mm->context.tlbpid[smp_processor_id()]) |
@@ -127,7 +143,13 @@ static inline void activate_context(struct mm_struct *mm) | |||
127 | static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next, | 143 | static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next, |
128 | struct task_struct *tsk) | 144 | struct task_struct *tsk) |
129 | { | 145 | { |
146 | int cpu = smp_processor_id(); | ||
147 | |||
130 | if (prev != next) { | 148 | if (prev != next) { |
149 | #ifdef CONFIG_SMP | ||
150 | per_cpu(cpu_tlbstate, cpu).active_mm = next; | ||
151 | #endif | ||
152 | cpu_ran_vm(cpu, next); | ||
131 | PTBR = (unsigned long) next->pgd; | 153 | PTBR = (unsigned long) next->pgd; |
132 | activate_context(next); | 154 | activate_context(next); |
133 | } | 155 | } |
diff --git a/arch/mn10300/include/asm/tlbflush.h b/arch/mn10300/include/asm/tlbflush.h index c3c194d4031e..efddd6e1adea 100644 --- a/arch/mn10300/include/asm/tlbflush.h +++ b/arch/mn10300/include/asm/tlbflush.h | |||
@@ -11,6 +11,7 @@ | |||
11 | #ifndef _ASM_TLBFLUSH_H | 11 | #ifndef _ASM_TLBFLUSH_H |
12 | #define _ASM_TLBFLUSH_H | 12 | #define _ASM_TLBFLUSH_H |
13 | 13 | ||
14 | #include <linux/mm.h> | ||
14 | #include <asm/processor.h> | 15 | #include <asm/processor.h> |
15 | 16 | ||
16 | struct tlb_state { | 17 | struct tlb_state { |
@@ -93,39 +94,61 @@ void local_flush_tlb_page(struct mm_struct *mm, unsigned long addr) | |||
93 | * - flush_tlb_range(mm, start, end) flushes a range of pages | 94 | * - flush_tlb_range(mm, start, end) flushes a range of pages |
94 | * - flush_tlb_pgtables(mm, start, end) flushes a range of page tables | 95 | * - flush_tlb_pgtables(mm, start, end) flushes a range of page tables |
95 | */ | 96 | */ |
96 | #define flush_tlb_all() \ | 97 | #ifdef CONFIG_SMP |
97 | do { \ | 98 | |
98 | preempt_disable(); \ | 99 | #include <asm/smp.h> |
99 | local_flush_tlb_all(); \ | 100 | |
100 | preempt_enable(); \ | 101 | extern void flush_tlb_all(void); |
101 | } while (0) | 102 | extern void flush_tlb_current_task(void); |
102 | 103 | extern void flush_tlb_mm(struct mm_struct *); | |
103 | #define flush_tlb_mm(mm) \ | 104 | extern void flush_tlb_page(struct vm_area_struct *, unsigned long); |
104 | do { \ | 105 | |
105 | preempt_disable(); \ | 106 | #define flush_tlb() flush_tlb_current_task() |
106 | local_flush_tlb_all(); \ | 107 | |
107 | preempt_enable(); \ | 108 | static inline void flush_tlb_range(struct vm_area_struct *vma, |
108 | } while (0) | 109 | unsigned long start, unsigned long end) |
109 | 110 | { | |
110 | #define flush_tlb_range(vma, start, end) \ | 111 | flush_tlb_mm(vma->vm_mm); |
111 | do { \ | 112 | } |
112 | unsigned long __s __attribute__((unused)) = (start); \ | 113 | |
113 | unsigned long __e __attribute__((unused)) = (end); \ | 114 | #else /* CONFIG_SMP */ |
114 | preempt_disable(); \ | 115 | |
115 | local_flush_tlb_all(); \ | 116 | static inline void flush_tlb_all(void) |
116 | preempt_enable(); \ | 117 | { |
117 | } while (0) | 118 | preempt_disable(); |
119 | local_flush_tlb_all(); | ||
120 | preempt_enable(); | ||
121 | } | ||
122 | |||
123 | static inline void flush_tlb_mm(struct mm_struct *mm) | ||
124 | { | ||
125 | preempt_disable(); | ||
126 | local_flush_tlb_all(); | ||
127 | preempt_enable(); | ||
128 | } | ||
129 | |||
130 | static inline void flush_tlb_range(struct vm_area_struct *vma, | ||
131 | unsigned long start, unsigned long end) | ||
132 | { | ||
133 | preempt_disable(); | ||
134 | local_flush_tlb_all(); | ||
135 | preempt_enable(); | ||
136 | } | ||
118 | 137 | ||
119 | #define flush_tlb_page(vma, addr) local_flush_tlb_page((vma)->vm_mm, addr) | 138 | #define flush_tlb_page(vma, addr) local_flush_tlb_page((vma)->vm_mm, addr) |
120 | #define flush_tlb() flush_tlb_all() | 139 | #define flush_tlb() flush_tlb_all() |
121 | 140 | ||
122 | #define flush_tlb_kernel_range(start, end) \ | 141 | #endif /* CONFIG_SMP */ |
123 | do { \ | ||
124 | unsigned long __s __attribute__((unused)) = (start); \ | ||
125 | unsigned long __e __attribute__((unused)) = (end); \ | ||
126 | flush_tlb_all(); \ | ||
127 | } while (0) | ||
128 | 142 | ||
129 | #define flush_tlb_pgtables(mm, start, end) do {} while (0) | 143 | static inline void flush_tlb_kernel_range(unsigned long start, |
144 | unsigned long end) | ||
145 | { | ||
146 | flush_tlb_all(); | ||
147 | } | ||
148 | |||
149 | static inline void flush_tlb_pgtables(struct mm_struct *mm, | ||
150 | unsigned long start, unsigned long end) | ||
151 | { | ||
152 | } | ||
130 | 153 | ||
131 | #endif /* _ASM_TLBFLUSH_H */ | 154 | #endif /* _ASM_TLBFLUSH_H */ |