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.
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 /**********************************************************************/
23 struct vm_area_struct
*ta_vma
;
24 unsigned long ta_start
;
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
)
73 #ifdef CONFIG_ARM_ERRATA_798181
74 bool (*erratum_a15_798181_handler
)(void);
76 static bool erratum_a15_798181_partial(void)
78 asm("mcr p15, 0, %0, c8, c3, 1" : : "r" (0));
83 static bool erratum_a15_798181_broadcast(void)
85 asm("mcr p15, 0, %0, c8, c3, 1" : : "r" (0));
90 void erratum_a15_798181_init(void)
92 unsigned int midr
= read_cpuid_id();
93 unsigned int revidr
= read_cpuid(CPUID_REVIDR
);
95 /* Cortex-A15 r0p0..r3p2 w/o ECO fix affected */
96 if ((midr
& 0xff0ffff0) != 0x410fc0f0 || midr
> 0x413fc0f2 ||
97 (revidr
& 0x210) == 0x210) {
101 erratum_a15_798181_handler
= erratum_a15_798181_partial
;
103 erratum_a15_798181_handler
= erratum_a15_798181_broadcast
;
107 static void ipi_flush_tlb_a15_erratum(void *arg
)
112 static void broadcast_tlb_a15_erratum(void)
114 if (!erratum_a15_798181())
117 smp_call_function(ipi_flush_tlb_a15_erratum
, NULL
, 1);
120 static void broadcast_tlb_mm_a15_erratum(struct mm_struct
*mm
)
123 cpumask_t mask
= { CPU_BITS_NONE
};
125 if (!erratum_a15_798181())
128 this_cpu
= get_cpu();
129 a15_erratum_get_cpumask(this_cpu
, mm
, &mask
);
130 smp_call_function_many(&mask
, ipi_flush_tlb_a15_erratum
, NULL
, 1);
134 void flush_tlb_all(void)
136 if (tlb_ops_need_broadcast())
137 on_each_cpu(ipi_flush_tlb_all
, NULL
, 1);
140 broadcast_tlb_a15_erratum();
143 void flush_tlb_mm(struct mm_struct
*mm
)
145 if (tlb_ops_need_broadcast())
146 on_each_cpu_mask(mm_cpumask(mm
), ipi_flush_tlb_mm
, mm
, 1);
149 broadcast_tlb_mm_a15_erratum(mm
);
152 void flush_tlb_page(struct vm_area_struct
*vma
, unsigned long uaddr
)
154 if (tlb_ops_need_broadcast()) {
158 on_each_cpu_mask(mm_cpumask(vma
->vm_mm
), ipi_flush_tlb_page
,
161 __flush_tlb_page(vma
, uaddr
);
162 broadcast_tlb_mm_a15_erratum(vma
->vm_mm
);
165 void flush_tlb_kernel_page(unsigned long kaddr
)
167 if (tlb_ops_need_broadcast()) {
170 on_each_cpu(ipi_flush_tlb_kernel_page
, &ta
, 1);
172 __flush_tlb_kernel_page(kaddr
);
173 broadcast_tlb_a15_erratum();
176 void flush_tlb_range(struct vm_area_struct
*vma
,
177 unsigned long start
, unsigned long end
)
179 if (tlb_ops_need_broadcast()) {
184 on_each_cpu_mask(mm_cpumask(vma
->vm_mm
), ipi_flush_tlb_range
,
187 local_flush_tlb_range(vma
, start
, end
);
188 broadcast_tlb_mm_a15_erratum(vma
->vm_mm
);
191 void flush_tlb_kernel_range(unsigned long start
, unsigned long end
)
193 if (tlb_ops_need_broadcast()) {
197 on_each_cpu(ipi_flush_tlb_kernel_range
, &ta
, 1);
199 local_flush_tlb_kernel_range(start
, end
);
200 broadcast_tlb_a15_erratum();
203 void flush_bp_all(void)
205 if (tlb_ops_need_broadcast())
206 on_each_cpu(ipi_flush_bp_all
, NULL
, 1);