blob: 9ed363d3de44e21db44576c2be526451331e3dbd [file] [log] [blame]
Stephen Rothwell19702822005-11-04 16:58:59 +11001#ifndef _ASM_POWERPC_TLBFLUSH_H
2#define _ASM_POWERPC_TLBFLUSH_H
Benjamin Herrenschmidte701d262007-10-30 09:46:06 +11003
Stephen Rothwell19702822005-11-04 16:58:59 +11004/*
5 * TLB flushing:
6 *
7 * - flush_tlb_mm(mm) flushes the specified mm context TLB's
8 * - flush_tlb_page(vma, vmaddr) flushes one page
Kumar Galadf3b8612008-11-19 05:53:24 +00009 * - local_flush_tlb_page(vmaddr) flushes one page on the local processor
Stephen Rothwell19702822005-11-04 16:58:59 +110010 * - flush_tlb_page_nohash(vma, vmaddr) flushes one page if SW loaded TLB
11 * - flush_tlb_range(vma, start, end) flushes a range of pages
12 * - flush_tlb_kernel_range(start, end) flushes a range of kernel pages
Stephen Rothwell19702822005-11-04 16:58:59 +110013 *
14 * This program is free software; you can redistribute it and/or
15 * modify it under the terms of the GNU General Public License
16 * as published by the Free Software Foundation; either version
17 * 2 of the License, or (at your option) any later version.
18 */
19#ifdef __KERNEL__
20
David Gibson62102302007-04-24 13:09:12 +100021#if defined(CONFIG_4xx) || defined(CONFIG_8xx) || defined(CONFIG_FSL_BOOKE)
22/*
23 * TLB flushing for software loaded TLB chips
24 *
25 * TODO: (CONFIG_FSL_BOOKE) determine if flush_tlb_range &
26 * flush_tlb_kernel_range are best implemented as tlbia vs
27 * specific tlbie's
28 */
29
Benjamin Herrenschmidte701d262007-10-30 09:46:06 +110030#include <linux/mm.h>
31
Benjamin Herrenschmidt2ca8cf72008-12-18 19:13:29 +000032#define MMU_NO_CONTEXT ((unsigned int)-1)
33
Benjamin Herrenschmidte701d262007-10-30 09:46:06 +110034extern void _tlbie(unsigned long address, unsigned int pid);
Kumar Gala0ba34182008-07-15 16:12:25 -050035extern void _tlbil_all(void);
36extern void _tlbil_pid(unsigned int pid);
37extern void _tlbil_va(unsigned long address, unsigned int pid);
David Gibson62102302007-04-24 13:09:12 +100038
39#if defined(CONFIG_40x) || defined(CONFIG_8xx)
40#define _tlbia() asm volatile ("tlbia; sync" : : : "memory")
41#else /* CONFIG_44x || CONFIG_FSL_BOOKE */
42extern void _tlbia(void);
43#endif
44
Benjamin Herrenschmidt1a37a3f2008-12-14 19:44:24 +000045static inline void local_flush_tlb_mm(struct mm_struct *mm)
46{
47 _tlbil_pid(mm->context.id);
48}
49
David Gibson62102302007-04-24 13:09:12 +100050static inline void flush_tlb_mm(struct mm_struct *mm)
51{
Kumar Gala0ba34182008-07-15 16:12:25 -050052 _tlbil_pid(mm->context.id);
David Gibson62102302007-04-24 13:09:12 +100053}
54
Kumar Galadf3b8612008-11-19 05:53:24 +000055static inline void local_flush_tlb_page(unsigned long vmaddr)
56{
57 _tlbil_va(vmaddr, 0);
58}
59
David Gibson62102302007-04-24 13:09:12 +100060static inline void flush_tlb_page(struct vm_area_struct *vma,
61 unsigned long vmaddr)
62{
Kumar Gala0ba34182008-07-15 16:12:25 -050063 _tlbil_va(vmaddr, vma ? vma->vm_mm->context.id : 0);
David Gibson62102302007-04-24 13:09:12 +100064}
65
66static inline void flush_tlb_page_nohash(struct vm_area_struct *vma,
67 unsigned long vmaddr)
68{
Kumar Gala0ba34182008-07-15 16:12:25 -050069 flush_tlb_page(vma, vmaddr);
David Gibson62102302007-04-24 13:09:12 +100070}
71
72static inline void flush_tlb_range(struct vm_area_struct *vma,
73 unsigned long start, unsigned long end)
74{
Kumar Gala0ba34182008-07-15 16:12:25 -050075 _tlbil_pid(vma->vm_mm->context.id);
David Gibson62102302007-04-24 13:09:12 +100076}
77
78static inline void flush_tlb_kernel_range(unsigned long start,
79 unsigned long end)
80{
Kumar Gala0ba34182008-07-15 16:12:25 -050081 _tlbil_pid(0);
David Gibson62102302007-04-24 13:09:12 +100082}
83
84#elif defined(CONFIG_PPC32)
85/*
86 * TLB flushing for "classic" hash-MMMU 32-bit CPUs, 6xx, 7xx, 7xxx
87 */
88extern void _tlbie(unsigned long address);
89extern void _tlbia(void);
90
91extern void flush_tlb_mm(struct mm_struct *mm);
92extern void flush_tlb_page(struct vm_area_struct *vma, unsigned long vmaddr);
93extern void flush_tlb_page_nohash(struct vm_area_struct *vma, unsigned long addr);
94extern void flush_tlb_range(struct vm_area_struct *vma, unsigned long start,
95 unsigned long end);
96extern void flush_tlb_kernel_range(unsigned long start, unsigned long end);
Kumar Galadf3b8612008-11-19 05:53:24 +000097static inline void local_flush_tlb_page(unsigned long vmaddr)
98{
99 flush_tlb_page(NULL, vmaddr);
100}
David Gibson62102302007-04-24 13:09:12 +1000101
102#else
103/*
104 * TLB flushing for 64-bit has-MMU CPUs
105 */
Stephen Rothwell19702822005-11-04 16:58:59 +1100106
107#include <linux/percpu.h>
108#include <asm/page.h>
109
110#define PPC64_TLB_BATCH_NR 192
111
112struct ppc64_tlb_batch {
Benjamin Herrenschmidta741e672007-04-10 17:09:37 +1000113 int active;
114 unsigned long index;
115 struct mm_struct *mm;
116 real_pte_t pte[PPC64_TLB_BATCH_NR];
117 unsigned long vaddr[PPC64_TLB_BATCH_NR];
118 unsigned int psize;
Paul Mackerras1189be62007-10-11 20:37:10 +1000119 int ssize;
Stephen Rothwell19702822005-11-04 16:58:59 +1100120};
121DECLARE_PER_CPU(struct ppc64_tlb_batch, ppc64_tlb_batch);
122
123extern void __flush_tlb_pending(struct ppc64_tlb_batch *batch);
124
Benjamin Herrenschmidta741e672007-04-10 17:09:37 +1000125extern void hpte_need_flush(struct mm_struct *mm, unsigned long addr,
126 pte_t *ptep, unsigned long pte, int huge);
127
128#define __HAVE_ARCH_ENTER_LAZY_MMU_MODE
129
130static inline void arch_enter_lazy_mmu_mode(void)
Stephen Rothwell19702822005-11-04 16:58:59 +1100131{
Benjamin Herrenschmidta741e672007-04-10 17:09:37 +1000132 struct ppc64_tlb_batch *batch = &__get_cpu_var(ppc64_tlb_batch);
133
134 batch->active = 1;
135}
136
137static inline void arch_leave_lazy_mmu_mode(void)
138{
139 struct ppc64_tlb_batch *batch = &__get_cpu_var(ppc64_tlb_batch);
Stephen Rothwell19702822005-11-04 16:58:59 +1100140
141 if (batch->index)
142 __flush_tlb_pending(batch);
Benjamin Herrenschmidta741e672007-04-10 17:09:37 +1000143 batch->active = 0;
Stephen Rothwell19702822005-11-04 16:58:59 +1100144}
145
Benjamin Herrenschmidta741e672007-04-10 17:09:37 +1000146#define arch_flush_lazy_mmu_mode() do {} while (0)
147
148
Benjamin Herrenschmidt3c726f82005-11-07 11:06:55 +1100149extern void flush_hash_page(unsigned long va, real_pte_t pte, int psize,
Paul Mackerras1189be62007-10-11 20:37:10 +1000150 int ssize, int local);
Benjamin Herrenschmidt3c726f82005-11-07 11:06:55 +1100151extern void flush_hash_range(unsigned long number, int local);
Stephen Rothwell19702822005-11-04 16:58:59 +1100152
Stephen Rothwell19702822005-11-04 16:58:59 +1100153
David Gibson62102302007-04-24 13:09:12 +1000154static inline void flush_tlb_mm(struct mm_struct *mm)
155{
156}
Stephen Rothwell19702822005-11-04 16:58:59 +1100157
Kumar Galadf3b8612008-11-19 05:53:24 +0000158static inline void local_flush_tlb_page(unsigned long vmaddr)
159{
160}
161
David Gibson62102302007-04-24 13:09:12 +1000162static inline void flush_tlb_page(struct vm_area_struct *vma,
163 unsigned long vmaddr)
164{
165}
Stephen Rothwell19702822005-11-04 16:58:59 +1100166
David Gibson62102302007-04-24 13:09:12 +1000167static inline void flush_tlb_page_nohash(struct vm_area_struct *vma,
168 unsigned long vmaddr)
169{
170}
Stephen Rothwell19702822005-11-04 16:58:59 +1100171
David Gibson62102302007-04-24 13:09:12 +1000172static inline void flush_tlb_range(struct vm_area_struct *vma,
173 unsigned long start, unsigned long end)
174{
175}
176
177static inline void flush_tlb_kernel_range(unsigned long start,
178 unsigned long end)
179{
180}
181
Benjamin Herrenschmidt3d5134e2007-06-04 15:15:36 +1000182/* Private function for use by PCI IO mapping code */
183extern void __flush_hash_table_range(struct mm_struct *mm, unsigned long start,
184 unsigned long end);
185
186
Stephen Rothwell19702822005-11-04 16:58:59 +1100187#endif
188
Stephen Rothwell19702822005-11-04 16:58:59 +1100189#endif /*__KERNEL__ */
190#endif /* _ASM_POWERPC_TLBFLUSH_H */