powerpc/mm: Add SMP support to no-hash TLB handling
[linux-2.6/libata-dev.git] / arch / powerpc / include / asm / tlbflush.h
blob8c39b27c1ed7e9fbd5a2da1a0e24e878cd8a0d1b
1 #ifndef _ASM_POWERPC_TLBFLUSH_H
2 #define _ASM_POWERPC_TLBFLUSH_H
4 /*
5 * TLB flushing:
7 * - flush_tlb_mm(mm) flushes the specified mm context TLB's
8 * - flush_tlb_page(vma, vmaddr) flushes one page
9 * - local_flush_tlb_mm(mm) flushes the specified mm context on
10 * the local processor
11 * - local_flush_tlb_page(vma, vmaddr) flushes one page on the local processor
12 * - flush_tlb_page_nohash(vma, vmaddr) flushes one page if SW loaded TLB
13 * - flush_tlb_range(vma, start, end) flushes a range of pages
14 * - flush_tlb_kernel_range(start, end) flushes a range of kernel pages
16 * This program is free software; you can redistribute it and/or
17 * modify it under the terms of the GNU General Public License
18 * as published by the Free Software Foundation; either version
19 * 2 of the License, or (at your option) any later version.
21 #ifdef __KERNEL__
23 #ifdef CONFIG_PPC_MMU_NOHASH
25 * TLB flushing for software loaded TLB chips
27 * TODO: (CONFIG_FSL_BOOKE) determine if flush_tlb_range &
28 * flush_tlb_kernel_range are best implemented as tlbia vs
29 * specific tlbie's
32 #include <linux/mm.h>
34 #define MMU_NO_CONTEXT ((unsigned int)-1)
36 extern void _tlbil_all(void);
37 extern void _tlbil_pid(unsigned int pid);
38 extern void _tlbil_va(unsigned long address, unsigned int pid);
39 extern void _tlbivax_bcast(unsigned long address, unsigned int pid);
41 #if defined(CONFIG_40x) || defined(CONFIG_8xx)
42 #define _tlbia() asm volatile ("tlbia; sync" : : : "memory")
43 #else /* CONFIG_44x || CONFIG_FSL_BOOKE */
44 extern void _tlbia(void);
45 #endif
47 extern void flush_tlb_range(struct vm_area_struct *vma, unsigned long start,
48 unsigned long end);
49 extern void flush_tlb_kernel_range(unsigned long start, unsigned long end);
51 extern void local_flush_tlb_mm(struct mm_struct *mm);
52 extern void local_flush_tlb_page(struct vm_area_struct *vma, unsigned long vmaddr);
54 #ifdef CONFIG_SMP
55 extern void flush_tlb_mm(struct mm_struct *mm);
56 extern void flush_tlb_page(struct vm_area_struct *vma, unsigned long vmaddr);
57 #else
58 #define flush_tlb_mm(mm) local_flush_tlb_mm(mm)
59 #define flush_tlb_page(vma,addr) local_flush_tlb_page(vma,addr)
60 #endif
61 #define flush_tlb_page_nohash(vma,addr) flush_tlb_page(vma,addr)
63 #elif defined(CONFIG_PPC_STD_MMU_32)
66 * TLB flushing for "classic" hash-MMU 32-bit CPUs, 6xx, 7xx, 7xxx
68 extern void _tlbie(unsigned long address);
69 extern void _tlbia(void);
71 extern void flush_tlb_mm(struct mm_struct *mm);
72 extern void flush_tlb_page(struct vm_area_struct *vma, unsigned long vmaddr);
73 extern void flush_tlb_page_nohash(struct vm_area_struct *vma, unsigned long addr);
74 extern void flush_tlb_range(struct vm_area_struct *vma, unsigned long start,
75 unsigned long end);
76 extern void flush_tlb_kernel_range(unsigned long start, unsigned long end);
77 static inline void local_flush_tlb_page(struct vm_area_struct *vma,
78 unsigned long vmaddr)
80 flush_tlb_page(vma, vmaddr);
82 static inline void local_flush_tlb_mm(struct mm_struct *mm)
84 flush_tlb_mm(mm);
87 #elif defined(CONFIG_PPC_STD_MMU_64)
90 * TLB flushing for 64-bit hash-MMU CPUs
93 #include <linux/percpu.h>
94 #include <asm/page.h>
96 #define PPC64_TLB_BATCH_NR 192
98 struct ppc64_tlb_batch {
99 int active;
100 unsigned long index;
101 struct mm_struct *mm;
102 real_pte_t pte[PPC64_TLB_BATCH_NR];
103 unsigned long vaddr[PPC64_TLB_BATCH_NR];
104 unsigned int psize;
105 int ssize;
107 DECLARE_PER_CPU(struct ppc64_tlb_batch, ppc64_tlb_batch);
109 extern void __flush_tlb_pending(struct ppc64_tlb_batch *batch);
111 extern void hpte_need_flush(struct mm_struct *mm, unsigned long addr,
112 pte_t *ptep, unsigned long pte, int huge);
114 #define __HAVE_ARCH_ENTER_LAZY_MMU_MODE
116 static inline void arch_enter_lazy_mmu_mode(void)
118 struct ppc64_tlb_batch *batch = &__get_cpu_var(ppc64_tlb_batch);
120 batch->active = 1;
123 static inline void arch_leave_lazy_mmu_mode(void)
125 struct ppc64_tlb_batch *batch = &__get_cpu_var(ppc64_tlb_batch);
127 if (batch->index)
128 __flush_tlb_pending(batch);
129 batch->active = 0;
132 #define arch_flush_lazy_mmu_mode() do {} while (0)
135 extern void flush_hash_page(unsigned long va, real_pte_t pte, int psize,
136 int ssize, int local);
137 extern void flush_hash_range(unsigned long number, int local);
140 static inline void local_flush_tlb_mm(struct mm_struct *mm)
144 static inline void flush_tlb_mm(struct mm_struct *mm)
148 static inline void local_flush_tlb_page(struct vm_area_struct *vma,
149 unsigned long vmaddr)
153 static inline void flush_tlb_page(struct vm_area_struct *vma,
154 unsigned long vmaddr)
158 static inline void flush_tlb_page_nohash(struct vm_area_struct *vma,
159 unsigned long vmaddr)
163 static inline void flush_tlb_range(struct vm_area_struct *vma,
164 unsigned long start, unsigned long end)
168 static inline void flush_tlb_kernel_range(unsigned long start,
169 unsigned long end)
173 /* Private function for use by PCI IO mapping code */
174 extern void __flush_hash_table_range(struct mm_struct *mm, unsigned long start,
175 unsigned long end);
177 #else
178 #error Unsupported MMU type
179 #endif
181 #endif /*__KERNEL__ */
182 #endif /* _ASM_POWERPC_TLBFLUSH_H */