blob: d50a380b2b6fd8604285264f0dc3054986e0c6bc [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
David Gibson62102302007-04-24 13:09:12 +100082/*
Benjamin Herrenschmidtf048aac2008-12-18 19:13:38 +000083 * TLB flushing for 64-bit hash-MMU CPUs
David Gibson62102302007-04-24 13:09:12 +100084 */
Stephen Rothwell19702822005-11-04 16:58:59 +110085
86#include <linux/percpu.h>
87#include <asm/page.h>
88
89#define PPC64_TLB_BATCH_NR 192
90
91struct ppc64_tlb_batch {
Benjamin Herrenschmidta741e672007-04-10 17:09:37 +100092 int active;
93 unsigned long index;
94 struct mm_struct *mm;
95 real_pte_t pte[PPC64_TLB_BATCH_NR];
96 unsigned long vaddr[PPC64_TLB_BATCH_NR];
97 unsigned int psize;
Paul Mackerras1189be62007-10-11 20:37:10 +100098 int ssize;
Stephen Rothwell19702822005-11-04 16:58:59 +110099};
100DECLARE_PER_CPU(struct ppc64_tlb_batch, ppc64_tlb_batch);
101
102extern void __flush_tlb_pending(struct ppc64_tlb_batch *batch);
103
Benjamin Herrenschmidta741e672007-04-10 17:09:37 +1000104extern void hpte_need_flush(struct mm_struct *mm, unsigned long addr,
105 pte_t *ptep, unsigned long pte, int huge);
106
107#define __HAVE_ARCH_ENTER_LAZY_MMU_MODE
108
109static inline void arch_enter_lazy_mmu_mode(void)
Stephen Rothwell19702822005-11-04 16:58:59 +1100110{
Benjamin Herrenschmidta741e672007-04-10 17:09:37 +1000111 struct ppc64_tlb_batch *batch = &__get_cpu_var(ppc64_tlb_batch);
112
113 batch->active = 1;
114}
115
116static inline void arch_leave_lazy_mmu_mode(void)
117{
118 struct ppc64_tlb_batch *batch = &__get_cpu_var(ppc64_tlb_batch);
Stephen Rothwell19702822005-11-04 16:58:59 +1100119
120 if (batch->index)
121 __flush_tlb_pending(batch);
Benjamin Herrenschmidta741e672007-04-10 17:09:37 +1000122 batch->active = 0;
Stephen Rothwell19702822005-11-04 16:58:59 +1100123}
124
Benjamin Herrenschmidta741e672007-04-10 17:09:37 +1000125#define arch_flush_lazy_mmu_mode() do {} while (0)
126
127
Benjamin Herrenschmidt3c726f82005-11-07 11:06:55 +1100128extern void flush_hash_page(unsigned long va, real_pte_t pte, int psize,
Paul Mackerras1189be62007-10-11 20:37:10 +1000129 int ssize, int local);
Benjamin Herrenschmidt3c726f82005-11-07 11:06:55 +1100130extern void flush_hash_range(unsigned long number, int local);
Stephen Rothwell19702822005-11-04 16:58:59 +1100131
Stephen Rothwell19702822005-11-04 16:58:59 +1100132
Benjamin Herrenschmidtf048aac2008-12-18 19:13:38 +0000133static inline void local_flush_tlb_mm(struct mm_struct *mm)
134{
135}
136
David Gibson62102302007-04-24 13:09:12 +1000137static inline void flush_tlb_mm(struct mm_struct *mm)
138{
139}
Stephen Rothwell19702822005-11-04 16:58:59 +1100140
Benjamin Herrenschmidtf048aac2008-12-18 19:13:38 +0000141static inline void local_flush_tlb_page(struct vm_area_struct *vma,
142 unsigned long vmaddr)
Kumar Galadf3b8612008-11-19 05:53:24 +0000143{
144}
145
David Gibson62102302007-04-24 13:09:12 +1000146static inline void flush_tlb_page(struct vm_area_struct *vma,
147 unsigned long vmaddr)
148{
149}
Stephen Rothwell19702822005-11-04 16:58:59 +1100150
David Gibson62102302007-04-24 13:09:12 +1000151static inline void flush_tlb_page_nohash(struct vm_area_struct *vma,
152 unsigned long vmaddr)
153{
154}
Stephen Rothwell19702822005-11-04 16:58:59 +1100155
David Gibson62102302007-04-24 13:09:12 +1000156static inline void flush_tlb_range(struct vm_area_struct *vma,
157 unsigned long start, unsigned long end)
158{
159}
160
161static inline void flush_tlb_kernel_range(unsigned long start,
162 unsigned long end)
163{
164}
165
Benjamin Herrenschmidt3d5134e2007-06-04 15:15:36 +1000166/* Private function for use by PCI IO mapping code */
167extern void __flush_hash_table_range(struct mm_struct *mm, unsigned long start,
168 unsigned long end);
169
Benjamin Herrenschmidtf048aac2008-12-18 19:13:38 +0000170#else
171#error Unsupported MMU type
Stephen Rothwell19702822005-11-04 16:58:59 +1100172#endif
173
Stephen Rothwell19702822005-11-04 16:58:59 +1100174#endif /*__KERNEL__ */
175#endif /* _ASM_POWERPC_TLBFLUSH_H */