blob: 23d351ca0303492f699f5e630668339a6b28effb [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 +1000106#define __HAVE_ARCH_ENTER_LAZY_MMU_MODE
107
108static inline void arch_enter_lazy_mmu_mode(void)
Stephen Rothwell19702822005-11-04 16:58:59 +1100109{
Christoph Lameter69111ba2014-10-21 15:23:25 -0500110 struct ppc64_tlb_batch *batch = this_cpu_ptr(&ppc64_tlb_batch);
Benjamin Herrenschmidta741e672007-04-10 17:09:37 +1000111
112 batch->active = 1;
113}
114
115static inline void arch_leave_lazy_mmu_mode(void)
116{
Christoph Lameter69111ba2014-10-21 15:23:25 -0500117 struct ppc64_tlb_batch *batch = this_cpu_ptr(&ppc64_tlb_batch);
Stephen Rothwell19702822005-11-04 16:58:59 +1100118
119 if (batch->index)
120 __flush_tlb_pending(batch);
Benjamin Herrenschmidta741e672007-04-10 17:09:37 +1000121 batch->active = 0;
Stephen Rothwell19702822005-11-04 16:58:59 +1100122}
123
Benjamin Herrenschmidta741e672007-04-10 17:09:37 +1000124#define arch_flush_lazy_mmu_mode() do {} while (0)
125
126
Aneesh Kumar K.V5524a272012-09-10 02:52:50 +0000127extern void flush_hash_page(unsigned long vpn, real_pte_t pte, int psize,
Aneesh Kumar K.Vaefa5682014-12-04 11:00:14 +0530128 int ssize, unsigned long flags);
Benjamin Herrenschmidt3c726f82005-11-07 11:06:55 +1100129extern void flush_hash_range(unsigned long number, int local);
Aneesh Kumar K.Vf1581bf2014-11-02 21:15:27 +0530130extern void flush_hash_hugepage(unsigned long vsid, unsigned long addr,
Aneesh Kumar K.Vd557b092014-11-02 21:15:28 +0530131 pmd_t *pmdp, unsigned int psize, int ssize,
Aneesh Kumar K.Vaefa5682014-12-04 11:00:14 +0530132 unsigned long flags);
Stephen Rothwell19702822005-11-04 16:58:59 +1100133
Benjamin Herrenschmidtf048aac2008-12-18 19:13:38 +0000134static inline void local_flush_tlb_mm(struct mm_struct *mm)
135{
136}
137
David Gibson62102302007-04-24 13:09:12 +1000138static inline void flush_tlb_mm(struct mm_struct *mm)
139{
140}
Stephen Rothwell19702822005-11-04 16:58:59 +1100141
Benjamin Herrenschmidtf048aac2008-12-18 19:13:38 +0000142static inline void local_flush_tlb_page(struct vm_area_struct *vma,
143 unsigned long vmaddr)
Kumar Galadf3b8612008-11-19 05:53:24 +0000144{
145}
146
David Gibson62102302007-04-24 13:09:12 +1000147static inline void flush_tlb_page(struct vm_area_struct *vma,
148 unsigned long vmaddr)
149{
150}
Stephen Rothwell19702822005-11-04 16:58:59 +1100151
David Gibson62102302007-04-24 13:09:12 +1000152static inline void flush_tlb_page_nohash(struct vm_area_struct *vma,
153 unsigned long vmaddr)
154{
155}
Stephen Rothwell19702822005-11-04 16:58:59 +1100156
David Gibson62102302007-04-24 13:09:12 +1000157static inline void flush_tlb_range(struct vm_area_struct *vma,
158 unsigned long start, unsigned long end)
159{
160}
161
162static inline void flush_tlb_kernel_range(unsigned long start,
163 unsigned long end)
164{
165}
166
Benjamin Herrenschmidt3d5134e2007-06-04 15:15:36 +1000167/* Private function for use by PCI IO mapping code */
168extern void __flush_hash_table_range(struct mm_struct *mm, unsigned long start,
169 unsigned long end);
Aneesh Kumar K.V074c2ea2013-06-20 14:30:15 +0530170extern void flush_tlb_pmd_range(struct mm_struct *mm, pmd_t *pmd,
171 unsigned long addr);
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 */