Linux 3.11-rc3
[cris-mirror.git] / arch / arm / kernel / smp_tlb.c
bloba98b62dca2faf9bbce7fbcb786d4c325513f7231
1 /*
2 * linux/arch/arm/kernel/smp_tlb.c
4 * Copyright (C) 2002 ARM Limited, All Rights Reserved.
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 */
10 #include <linux/preempt.h>
11 #include <linux/smp.h>
13 #include <asm/smp_plat.h>
14 #include <asm/tlbflush.h>
15 #include <asm/mmu_context.h>
17 /**********************************************************************/
20 * TLB operations
22 struct tlb_args {
23 struct vm_area_struct *ta_vma;
24 unsigned long ta_start;
25 unsigned long ta_end;
28 static inline void ipi_flush_tlb_all(void *ignored)
30 local_flush_tlb_all();
33 static inline void ipi_flush_tlb_mm(void *arg)
35 struct mm_struct *mm = (struct mm_struct *)arg;
37 local_flush_tlb_mm(mm);
40 static inline void ipi_flush_tlb_page(void *arg)
42 struct tlb_args *ta = (struct tlb_args *)arg;
44 local_flush_tlb_page(ta->ta_vma, ta->ta_start);
47 static inline void ipi_flush_tlb_kernel_page(void *arg)
49 struct tlb_args *ta = (struct tlb_args *)arg;
51 local_flush_tlb_kernel_page(ta->ta_start);
54 static inline void ipi_flush_tlb_range(void *arg)
56 struct tlb_args *ta = (struct tlb_args *)arg;
58 local_flush_tlb_range(ta->ta_vma, ta->ta_start, ta->ta_end);
61 static inline void ipi_flush_tlb_kernel_range(void *arg)
63 struct tlb_args *ta = (struct tlb_args *)arg;
65 local_flush_tlb_kernel_range(ta->ta_start, ta->ta_end);
68 static inline void ipi_flush_bp_all(void *ignored)
70 local_flush_bp_all();
73 #ifdef CONFIG_ARM_ERRATA_798181
74 static int erratum_a15_798181(void)
76 unsigned int midr = read_cpuid_id();
78 /* Cortex-A15 r0p0..r3p2 affected */
79 if ((midr & 0xff0ffff0) != 0x410fc0f0 || midr > 0x413fc0f2)
80 return 0;
81 return 1;
83 #else
84 static int erratum_a15_798181(void)
86 return 0;
88 #endif
90 static void ipi_flush_tlb_a15_erratum(void *arg)
92 dmb();
95 static void broadcast_tlb_a15_erratum(void)
97 if (!erratum_a15_798181())
98 return;
100 dummy_flush_tlb_a15_erratum();
101 smp_call_function(ipi_flush_tlb_a15_erratum, NULL, 1);
104 static void broadcast_tlb_mm_a15_erratum(struct mm_struct *mm)
106 int this_cpu;
107 cpumask_t mask = { CPU_BITS_NONE };
109 if (!erratum_a15_798181())
110 return;
112 dummy_flush_tlb_a15_erratum();
113 this_cpu = get_cpu();
114 a15_erratum_get_cpumask(this_cpu, mm, &mask);
115 smp_call_function_many(&mask, ipi_flush_tlb_a15_erratum, NULL, 1);
116 put_cpu();
119 void flush_tlb_all(void)
121 if (tlb_ops_need_broadcast())
122 on_each_cpu(ipi_flush_tlb_all, NULL, 1);
123 else
124 local_flush_tlb_all();
125 broadcast_tlb_a15_erratum();
128 void flush_tlb_mm(struct mm_struct *mm)
130 if (tlb_ops_need_broadcast())
131 on_each_cpu_mask(mm_cpumask(mm), ipi_flush_tlb_mm, mm, 1);
132 else
133 local_flush_tlb_mm(mm);
134 broadcast_tlb_mm_a15_erratum(mm);
137 void flush_tlb_page(struct vm_area_struct *vma, unsigned long uaddr)
139 if (tlb_ops_need_broadcast()) {
140 struct tlb_args ta;
141 ta.ta_vma = vma;
142 ta.ta_start = uaddr;
143 on_each_cpu_mask(mm_cpumask(vma->vm_mm), ipi_flush_tlb_page,
144 &ta, 1);
145 } else
146 local_flush_tlb_page(vma, uaddr);
147 broadcast_tlb_mm_a15_erratum(vma->vm_mm);
150 void flush_tlb_kernel_page(unsigned long kaddr)
152 if (tlb_ops_need_broadcast()) {
153 struct tlb_args ta;
154 ta.ta_start = kaddr;
155 on_each_cpu(ipi_flush_tlb_kernel_page, &ta, 1);
156 } else
157 local_flush_tlb_kernel_page(kaddr);
158 broadcast_tlb_a15_erratum();
161 void flush_tlb_range(struct vm_area_struct *vma,
162 unsigned long start, unsigned long end)
164 if (tlb_ops_need_broadcast()) {
165 struct tlb_args ta;
166 ta.ta_vma = vma;
167 ta.ta_start = start;
168 ta.ta_end = end;
169 on_each_cpu_mask(mm_cpumask(vma->vm_mm), ipi_flush_tlb_range,
170 &ta, 1);
171 } else
172 local_flush_tlb_range(vma, start, end);
173 broadcast_tlb_mm_a15_erratum(vma->vm_mm);
176 void flush_tlb_kernel_range(unsigned long start, unsigned long end)
178 if (tlb_ops_need_broadcast()) {
179 struct tlb_args ta;
180 ta.ta_start = start;
181 ta.ta_end = end;
182 on_each_cpu(ipi_flush_tlb_kernel_range, &ta, 1);
183 } else
184 local_flush_tlb_kernel_range(start, end);
185 broadcast_tlb_a15_erratum();
188 void flush_bp_all(void)
190 if (tlb_ops_need_broadcast())
191 on_each_cpu(ipi_flush_bp_all, NULL, 1);
192 else
193 local_flush_bp_all();