blob: fc02d1dee95519e152169d4c90ca222b7799132a [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
Benjamin Herrenschmidtd4e167d2009-07-23 23:15:24 +00009 * - local_flush_tlb_mm(mm, full) flushes the specified mm context on
Benjamin Herrenschmidtf048aac2008-12-18 19:13:38 +000010 * the local processor
11 * - local_flush_tlb_page(vma, vmaddr) flushes one page on the local processor
Stephen Rothwell19702822005-11-04 16:58:59 +110012 * - 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
Stephen Rothwell19702822005-11-04 16:58:59 +110015 *
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.
20 */
21#ifdef __KERNEL__
22
Benjamin Herrenschmidtf048aac2008-12-18 19:13:38 +000023#ifdef CONFIG_PPC_MMU_NOHASH
David Gibson62102302007-04-24 13:09:12 +100024/*
25 * TLB flushing for software loaded TLB chips
26 *
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
30 */
31
Benjamin Herrenschmidtd4e167d2009-07-23 23:15:24 +000032struct vm_area_struct;
33struct mm_struct;
Benjamin Herrenschmidte701d262007-10-30 09:46:06 +110034
Benjamin Herrenschmidt2ca8cf72008-12-18 19:13:29 +000035#define MMU_NO_CONTEXT ((unsigned int)-1)
36
Benjamin Herrenschmidtf048aac2008-12-18 19:13:38 +000037extern void flush_tlb_range(struct vm_area_struct *vma, unsigned long start,
38 unsigned long end);
39extern void flush_tlb_kernel_range(unsigned long start, unsigned long end);
Benjamin Herrenschmidt1a37a3f2008-12-14 19:44:24 +000040
Benjamin Herrenschmidtf048aac2008-12-18 19:13:38 +000041extern void local_flush_tlb_mm(struct mm_struct *mm);
42extern void local_flush_tlb_page(struct vm_area_struct *vma, unsigned long vmaddr);
David Gibson62102302007-04-24 13:09:12 +100043
Benjamin Herrenschmidtd4e167d2009-07-23 23:15:24 +000044extern void __local_flush_tlb_page(struct mm_struct *mm, unsigned long vmaddr,
45 int tsize, int ind);
46
Benjamin Herrenschmidtf048aac2008-12-18 19:13:38 +000047#ifdef CONFIG_SMP
48extern void flush_tlb_mm(struct mm_struct *mm);
49extern void flush_tlb_page(struct vm_area_struct *vma, unsigned long vmaddr);
Benjamin Herrenschmidtd4e167d2009-07-23 23:15:24 +000050extern void __flush_tlb_page(struct mm_struct *mm, unsigned long vmaddr,
51 int tsize, int ind);
Benjamin Herrenschmidtf048aac2008-12-18 19:13:38 +000052#else
53#define flush_tlb_mm(mm) local_flush_tlb_mm(mm)
54#define flush_tlb_page(vma,addr) local_flush_tlb_page(vma,addr)
Benjamin Herrenschmidtd4e167d2009-07-23 23:15:24 +000055#define __flush_tlb_page(mm,addr,p,i) __local_flush_tlb_page(mm,addr,p,i)
Benjamin Herrenschmidtf048aac2008-12-18 19:13:38 +000056#endif
57#define flush_tlb_page_nohash(vma,addr) flush_tlb_page(vma,addr)
Kumar Galadf3b8612008-11-19 05:53:24 +000058
Benjamin Herrenschmidtf048aac2008-12-18 19:13:38 +000059#elif defined(CONFIG_PPC_STD_MMU_32)
David Gibson62102302007-04-24 13:09:12 +100060
David Gibson62102302007-04-24 13:09:12 +100061/*
Benjamin Herrenschmidtf048aac2008-12-18 19:13:38 +000062 * TLB flushing for "classic" hash-MMU 32-bit CPUs, 6xx, 7xx, 7xxx
David Gibson62102302007-04-24 13:09:12 +100063 */
David Gibson62102302007-04-24 13:09:12 +100064extern void flush_tlb_mm(struct mm_struct *mm);
65extern void flush_tlb_page(struct vm_area_struct *vma, unsigned long vmaddr);
66extern void flush_tlb_page_nohash(struct vm_area_struct *vma, unsigned long addr);
67extern void flush_tlb_range(struct vm_area_struct *vma, unsigned long start,
68 unsigned long end);
69extern void flush_tlb_kernel_range(unsigned long start, unsigned long end);
Benjamin Herrenschmidtf048aac2008-12-18 19:13:38 +000070static inline void local_flush_tlb_page(struct vm_area_struct *vma,
71 unsigned long vmaddr)
Kumar Galadf3b8612008-11-19 05:53:24 +000072{
Benjamin Herrenschmidtf048aac2008-12-18 19:13:38 +000073 flush_tlb_page(vma, vmaddr);
74}
75static inline void local_flush_tlb_mm(struct mm_struct *mm)
76{
77 flush_tlb_mm(mm);
Kumar Galadf3b8612008-11-19 05:53:24 +000078}
David Gibson62102302007-04-24 13:09:12 +100079
Benjamin Herrenschmidtf048aac2008-12-18 19:13:38 +000080#elif defined(CONFIG_PPC_STD_MMU_64)
81
Michael Ellerman5e8e7b42011-04-12 19:00:04 +000082#define MMU_NO_CONTEXT 0
83
David Gibson62102302007-04-24 13:09:12 +100084/*
Benjamin Herrenschmidtf048aac2008-12-18 19:13:38 +000085 * TLB flushing for 64-bit hash-MMU CPUs
David Gibson62102302007-04-24 13:09:12 +100086 */
Stephen Rothwell19702822005-11-04 16:58:59 +110087
88#include <linux/percpu.h>
89#include <asm/page.h>
90
91#define PPC64_TLB_BATCH_NR 192
92
93struct ppc64_tlb_batch {
Benjamin Herrenschmidta741e672007-04-10 17:09:37 +100094 int active;
95 unsigned long index;
96 struct mm_struct *mm;
97 real_pte_t pte[PPC64_TLB_BATCH_NR];
Aneesh Kumar K.V5524a272012-09-10 02:52:50 +000098 unsigned long vpn[PPC64_TLB_BATCH_NR];
Benjamin Herrenschmidta741e672007-04-10 17:09:37 +100099 unsigned int psize;
Paul Mackerras1189be62007-10-11 20:37:10 +1000100 int ssize;
Stephen Rothwell19702822005-11-04 16:58:59 +1100101};
102DECLARE_PER_CPU(struct ppc64_tlb_batch, ppc64_tlb_batch);
103
104extern void __flush_tlb_pending(struct ppc64_tlb_batch *batch);
105
Benjamin Herrenschmidta741e672007-04-10 17:09:37 +1000106extern void hpte_need_flush(struct mm_struct *mm, unsigned long addr,
107 pte_t *ptep, unsigned long pte, int huge);
108
109#define __HAVE_ARCH_ENTER_LAZY_MMU_MODE
110
111static inline void arch_enter_lazy_mmu_mode(void)
Stephen Rothwell19702822005-11-04 16:58:59 +1100112{
Benjamin Herrenschmidta741e672007-04-10 17:09:37 +1000113 struct ppc64_tlb_batch *batch = &__get_cpu_var(ppc64_tlb_batch);
114
115 batch->active = 1;
116}
117
118static inline void arch_leave_lazy_mmu_mode(void)
119{
120 struct ppc64_tlb_batch *batch = &__get_cpu_var(ppc64_tlb_batch);
Stephen Rothwell19702822005-11-04 16:58:59 +1100121
122 if (batch->index)
123 __flush_tlb_pending(batch);
Benjamin Herrenschmidta741e672007-04-10 17:09:37 +1000124 batch->active = 0;
Stephen Rothwell19702822005-11-04 16:58:59 +1100125}
126
Benjamin Herrenschmidta741e672007-04-10 17:09:37 +1000127#define arch_flush_lazy_mmu_mode() do {} while (0)
128
129
Aneesh Kumar K.V5524a272012-09-10 02:52:50 +0000130extern void flush_hash_page(unsigned long vpn, real_pte_t pte, int psize,
Paul Mackerras1189be62007-10-11 20:37:10 +1000131 int ssize, int local);
Benjamin Herrenschmidt3c726f82005-11-07 11:06:55 +1100132extern void flush_hash_range(unsigned long number, int local);
Stephen Rothwell19702822005-11-04 16:58:59 +1100133
Stephen Rothwell19702822005-11-04 16:58:59 +1100134
Benjamin Herrenschmidtf048aac2008-12-18 19:13:38 +0000135static inline void local_flush_tlb_mm(struct mm_struct *mm)
136{
137}
138
David Gibson62102302007-04-24 13:09:12 +1000139static inline void flush_tlb_mm(struct mm_struct *mm)
140{
141}
Stephen Rothwell19702822005-11-04 16:58:59 +1100142
Benjamin Herrenschmidtf048aac2008-12-18 19:13:38 +0000143static inline void local_flush_tlb_page(struct vm_area_struct *vma,
144 unsigned long vmaddr)
Kumar Galadf3b8612008-11-19 05:53:24 +0000145{
146}
147
David Gibson62102302007-04-24 13:09:12 +1000148static inline void flush_tlb_page(struct vm_area_struct *vma,
149 unsigned long vmaddr)
150{
151}
Stephen Rothwell19702822005-11-04 16:58:59 +1100152
David Gibson62102302007-04-24 13:09:12 +1000153static inline void flush_tlb_page_nohash(struct vm_area_struct *vma,
154 unsigned long vmaddr)
155{
156}
Stephen Rothwell19702822005-11-04 16:58:59 +1100157
David Gibson62102302007-04-24 13:09:12 +1000158static inline void flush_tlb_range(struct vm_area_struct *vma,
159 unsigned long start, unsigned long end)
160{
161}
162
163static inline void flush_tlb_kernel_range(unsigned long start,
164 unsigned long end)
165{
166}
167
Benjamin Herrenschmidt3d5134e2007-06-04 15:15:36 +1000168/* Private function for use by PCI IO mapping code */
169extern void __flush_hash_table_range(struct mm_struct *mm, unsigned long start,
170 unsigned long end);
171
Benjamin Herrenschmidtf048aac2008-12-18 19:13:38 +0000172#else
173#error Unsupported MMU type
Stephen Rothwell19702822005-11-04 16:58:59 +1100174#endif
175
Stephen Rothwell19702822005-11-04 16:58:59 +1100176#endif /*__KERNEL__ */
177#endif /* _ASM_POWERPC_TLBFLUSH_H */