mfd: wm8350-i2c: Make sure the i2c regmap functions are compiled
[linux/fpc-iii.git] / arch / x86 / include / asm / tlbflush.h
blob5e4b0cc54e4337bf5f52ca29476484fd052240f3
1 #ifndef _ASM_X86_TLBFLUSH_H
2 #define _ASM_X86_TLBFLUSH_H
4 #include <linux/mm.h>
5 #include <linux/sched.h>
7 #include <asm/processor.h>
8 #include <asm/special_insns.h>
10 #ifdef CONFIG_PARAVIRT
11 #include <asm/paravirt.h>
12 #else
13 #define __flush_tlb() __native_flush_tlb()
14 #define __flush_tlb_global() __native_flush_tlb_global()
15 #define __flush_tlb_single(addr) __native_flush_tlb_single(addr)
16 #endif
18 static inline void __native_flush_tlb(void)
21 * If current->mm == NULL then we borrow a mm which may change during a
22 * task switch and therefore we must not be preempted while we write CR3
23 * back:
25 preempt_disable();
26 native_write_cr3(native_read_cr3());
27 preempt_enable();
30 static inline void __native_flush_tlb_global_irq_disabled(void)
32 unsigned long cr4;
34 cr4 = native_read_cr4();
35 /* clear PGE */
36 native_write_cr4(cr4 & ~X86_CR4_PGE);
37 /* write old PGE again and flush TLBs */
38 native_write_cr4(cr4);
41 static inline void __native_flush_tlb_global(void)
43 unsigned long flags;
46 * Read-modify-write to CR4 - protect it from preemption and
47 * from interrupts. (Use the raw variant because this code can
48 * be called from deep inside debugging code.)
50 raw_local_irq_save(flags);
52 __native_flush_tlb_global_irq_disabled();
54 raw_local_irq_restore(flags);
57 static inline void __native_flush_tlb_single(unsigned long addr)
59 asm volatile("invlpg (%0)" ::"r" (addr) : "memory");
62 static inline void __flush_tlb_all(void)
64 if (cpu_has_pge)
65 __flush_tlb_global();
66 else
67 __flush_tlb();
70 static inline void __flush_tlb_one(unsigned long addr)
72 count_vm_tlb_event(NR_TLB_LOCAL_FLUSH_ONE);
73 __flush_tlb_single(addr);
76 #define TLB_FLUSH_ALL -1UL
79 * TLB flushing:
81 * - flush_tlb() flushes the current mm struct TLBs
82 * - flush_tlb_all() flushes all processes TLBs
83 * - flush_tlb_mm(mm) flushes the specified mm context TLB's
84 * - flush_tlb_page(vma, vmaddr) flushes one page
85 * - flush_tlb_range(vma, start, end) flushes a range of pages
86 * - flush_tlb_kernel_range(start, end) flushes a range of kernel pages
87 * - flush_tlb_others(cpumask, mm, start, end) flushes TLBs on other cpus
89 * ..but the i386 has somewhat limited tlb flushing capabilities,
90 * and page-granular flushes are available only on i486 and up.
93 #ifndef CONFIG_SMP
95 /* "_up" is for UniProcessor.
97 * This is a helper for other header functions. *Not* intended to be called
98 * directly. All global TLB flushes need to either call this, or to bump the
99 * vm statistics themselves.
101 static inline void __flush_tlb_up(void)
103 count_vm_tlb_event(NR_TLB_LOCAL_FLUSH_ALL);
104 __flush_tlb();
107 static inline void flush_tlb_all(void)
109 count_vm_tlb_event(NR_TLB_LOCAL_FLUSH_ALL);
110 __flush_tlb_all();
113 static inline void flush_tlb(void)
115 __flush_tlb_up();
118 static inline void local_flush_tlb(void)
120 __flush_tlb_up();
123 static inline void flush_tlb_mm(struct mm_struct *mm)
125 if (mm == current->active_mm)
126 __flush_tlb_up();
129 static inline void flush_tlb_page(struct vm_area_struct *vma,
130 unsigned long addr)
132 if (vma->vm_mm == current->active_mm)
133 __flush_tlb_one(addr);
136 static inline void flush_tlb_range(struct vm_area_struct *vma,
137 unsigned long start, unsigned long end)
139 if (vma->vm_mm == current->active_mm)
140 __flush_tlb_up();
143 static inline void flush_tlb_mm_range(struct mm_struct *mm,
144 unsigned long start, unsigned long end, unsigned long vmflag)
146 if (mm == current->active_mm)
147 __flush_tlb_up();
150 static inline void native_flush_tlb_others(const struct cpumask *cpumask,
151 struct mm_struct *mm,
152 unsigned long start,
153 unsigned long end)
157 static inline void reset_lazy_tlbstate(void)
161 static inline void flush_tlb_kernel_range(unsigned long start,
162 unsigned long end)
164 flush_tlb_all();
167 #else /* SMP */
169 #include <asm/smp.h>
171 #define local_flush_tlb() __flush_tlb()
173 #define flush_tlb_mm(mm) flush_tlb_mm_range(mm, 0UL, TLB_FLUSH_ALL, 0UL)
175 #define flush_tlb_range(vma, start, end) \
176 flush_tlb_mm_range(vma->vm_mm, start, end, vma->vm_flags)
178 extern void flush_tlb_all(void);
179 extern void flush_tlb_current_task(void);
180 extern void flush_tlb_page(struct vm_area_struct *, unsigned long);
181 extern void flush_tlb_mm_range(struct mm_struct *mm, unsigned long start,
182 unsigned long end, unsigned long vmflag);
183 extern void flush_tlb_kernel_range(unsigned long start, unsigned long end);
185 #define flush_tlb() flush_tlb_current_task()
187 void native_flush_tlb_others(const struct cpumask *cpumask,
188 struct mm_struct *mm,
189 unsigned long start, unsigned long end);
191 #define TLBSTATE_OK 1
192 #define TLBSTATE_LAZY 2
194 struct tlb_state {
195 struct mm_struct *active_mm;
196 int state;
198 DECLARE_PER_CPU_SHARED_ALIGNED(struct tlb_state, cpu_tlbstate);
200 static inline void reset_lazy_tlbstate(void)
202 this_cpu_write(cpu_tlbstate.state, 0);
203 this_cpu_write(cpu_tlbstate.active_mm, &init_mm);
206 #endif /* SMP */
208 #ifndef CONFIG_PARAVIRT
209 #define flush_tlb_others(mask, mm, start, end) \
210 native_flush_tlb_others(mask, mm, start, end)
211 #endif
213 #endif /* _ASM_X86_TLBFLUSH_H */