blob: 8c39b27c1ed7e9fbd5a2da1a0e24e878cd8a0d1b [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 Herrenschmidtf048aac2008-12-18 19:13:38 +00009 * - 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
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 Herrenschmidte701d262007-10-30 09:46:06 +110032#include <linux/mm.h>
33
Benjamin Herrenschmidt2ca8cf72008-12-18 19:13:29 +000034#define MMU_NO_CONTEXT ((unsigned int)-1)
35
Kumar Gala0ba34182008-07-15 16:12:25 -050036extern void _tlbil_all(void);
37extern void _tlbil_pid(unsigned int pid);
38extern void _tlbil_va(unsigned long address, unsigned int pid);
Benjamin Herrenschmidtf048aac2008-12-18 19:13:38 +000039extern void _tlbivax_bcast(unsigned long address, unsigned int pid);
David Gibson62102302007-04-24 13:09:12 +100040
41#if defined(CONFIG_40x) || defined(CONFIG_8xx)
42#define _tlbia() asm volatile ("tlbia; sync" : : : "memory")
43#else /* CONFIG_44x || CONFIG_FSL_BOOKE */
44extern void _tlbia(void);
45#endif
46
Benjamin Herrenschmidtf048aac2008-12-18 19:13:38 +000047extern void flush_tlb_range(struct vm_area_struct *vma, unsigned long start,
48 unsigned long end);
49extern void flush_tlb_kernel_range(unsigned long start, unsigned long end);
Benjamin Herrenschmidt1a37a3f2008-12-14 19:44:24 +000050
Benjamin Herrenschmidtf048aac2008-12-18 19:13:38 +000051extern void local_flush_tlb_mm(struct mm_struct *mm);
52extern void local_flush_tlb_page(struct vm_area_struct *vma, unsigned long vmaddr);
David Gibson62102302007-04-24 13:09:12 +100053
Benjamin Herrenschmidtf048aac2008-12-18 19:13:38 +000054#ifdef CONFIG_SMP
55extern void flush_tlb_mm(struct mm_struct *mm);
56extern 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)
Kumar Galadf3b8612008-11-19 05:53:24 +000062
Benjamin Herrenschmidtf048aac2008-12-18 19:13:38 +000063#elif defined(CONFIG_PPC_STD_MMU_32)
David Gibson62102302007-04-24 13:09:12 +100064
David Gibson62102302007-04-24 13:09:12 +100065/*
Benjamin Herrenschmidtf048aac2008-12-18 19:13:38 +000066 * TLB flushing for "classic" hash-MMU 32-bit CPUs, 6xx, 7xx, 7xxx
David Gibson62102302007-04-24 13:09:12 +100067 */
68extern void _tlbie(unsigned long address);
69extern void _tlbia(void);
70
71extern void flush_tlb_mm(struct mm_struct *mm);
72extern void flush_tlb_page(struct vm_area_struct *vma, unsigned long vmaddr);
73extern void flush_tlb_page_nohash(struct vm_area_struct *vma, unsigned long addr);
74extern void flush_tlb_range(struct vm_area_struct *vma, unsigned long start,
75 unsigned long end);
76extern void flush_tlb_kernel_range(unsigned long start, unsigned long end);
Benjamin Herrenschmidtf048aac2008-12-18 19:13:38 +000077static inline void local_flush_tlb_page(struct vm_area_struct *vma,
78 unsigned long vmaddr)
Kumar Galadf3b8612008-11-19 05:53:24 +000079{
Benjamin Herrenschmidtf048aac2008-12-18 19:13:38 +000080 flush_tlb_page(vma, vmaddr);
81}
82static inline void local_flush_tlb_mm(struct mm_struct *mm)
83{
84 flush_tlb_mm(mm);
Kumar Galadf3b8612008-11-19 05:53:24 +000085}
David Gibson62102302007-04-24 13:09:12 +100086
Benjamin Herrenschmidtf048aac2008-12-18 19:13:38 +000087#elif defined(CONFIG_PPC_STD_MMU_64)
88
David Gibson62102302007-04-24 13:09:12 +100089/*
Benjamin Herrenschmidtf048aac2008-12-18 19:13:38 +000090 * TLB flushing for 64-bit hash-MMU CPUs
David Gibson62102302007-04-24 13:09:12 +100091 */
Stephen Rothwell19702822005-11-04 16:58:59 +110092
93#include <linux/percpu.h>
94#include <asm/page.h>
95
96#define PPC64_TLB_BATCH_NR 192
97
98struct ppc64_tlb_batch {
Benjamin Herrenschmidta741e672007-04-10 17:09:37 +100099 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;
Paul Mackerras1189be62007-10-11 20:37:10 +1000105 int ssize;
Stephen Rothwell19702822005-11-04 16:58:59 +1100106};
107DECLARE_PER_CPU(struct ppc64_tlb_batch, ppc64_tlb_batch);
108
109extern void __flush_tlb_pending(struct ppc64_tlb_batch *batch);
110
Benjamin Herrenschmidta741e672007-04-10 17:09:37 +1000111extern void hpte_need_flush(struct mm_struct *mm, unsigned long addr,
112 pte_t *ptep, unsigned long pte, int huge);
113
114#define __HAVE_ARCH_ENTER_LAZY_MMU_MODE
115
116static inline void arch_enter_lazy_mmu_mode(void)
Stephen Rothwell19702822005-11-04 16:58:59 +1100117{
Benjamin Herrenschmidta741e672007-04-10 17:09:37 +1000118 struct ppc64_tlb_batch *batch = &__get_cpu_var(ppc64_tlb_batch);
119
120 batch->active = 1;
121}
122
123static inline void arch_leave_lazy_mmu_mode(void)
124{
125 struct ppc64_tlb_batch *batch = &__get_cpu_var(ppc64_tlb_batch);
Stephen Rothwell19702822005-11-04 16:58:59 +1100126
127 if (batch->index)
128 __flush_tlb_pending(batch);
Benjamin Herrenschmidta741e672007-04-10 17:09:37 +1000129 batch->active = 0;
Stephen Rothwell19702822005-11-04 16:58:59 +1100130}
131
Benjamin Herrenschmidta741e672007-04-10 17:09:37 +1000132#define arch_flush_lazy_mmu_mode() do {} while (0)
133
134
Benjamin Herrenschmidt3c726f82005-11-07 11:06:55 +1100135extern void flush_hash_page(unsigned long va, real_pte_t pte, int psize,
Paul Mackerras1189be62007-10-11 20:37:10 +1000136 int ssize, int local);
Benjamin Herrenschmidt3c726f82005-11-07 11:06:55 +1100137extern void flush_hash_range(unsigned long number, int local);
Stephen Rothwell19702822005-11-04 16:58:59 +1100138
Stephen Rothwell19702822005-11-04 16:58:59 +1100139
Benjamin Herrenschmidtf048aac2008-12-18 19:13:38 +0000140static inline void local_flush_tlb_mm(struct mm_struct *mm)
141{
142}
143
David Gibson62102302007-04-24 13:09:12 +1000144static inline void flush_tlb_mm(struct mm_struct *mm)
145{
146}
Stephen Rothwell19702822005-11-04 16:58:59 +1100147
Benjamin Herrenschmidtf048aac2008-12-18 19:13:38 +0000148static inline void local_flush_tlb_page(struct vm_area_struct *vma,
149 unsigned long vmaddr)
Kumar Galadf3b8612008-11-19 05:53:24 +0000150{
151}
152
David Gibson62102302007-04-24 13:09:12 +1000153static inline void flush_tlb_page(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_page_nohash(struct vm_area_struct *vma,
159 unsigned long vmaddr)
160{
161}
Stephen Rothwell19702822005-11-04 16:58:59 +1100162
David Gibson62102302007-04-24 13:09:12 +1000163static inline void flush_tlb_range(struct vm_area_struct *vma,
164 unsigned long start, unsigned long end)
165{
166}
167
168static inline void flush_tlb_kernel_range(unsigned long start,
169 unsigned long end)
170{
171}
172
Benjamin Herrenschmidt3d5134e2007-06-04 15:15:36 +1000173/* Private function for use by PCI IO mapping code */
174extern void __flush_hash_table_range(struct mm_struct *mm, unsigned long start,
175 unsigned long end);
176
Benjamin Herrenschmidtf048aac2008-12-18 19:13:38 +0000177#else
178#error Unsupported MMU type
Stephen Rothwell19702822005-11-04 16:58:59 +1100179#endif
180
Stephen Rothwell19702822005-11-04 16:58:59 +1100181#endif /*__KERNEL__ */
182#endif /* _ASM_POWERPC_TLBFLUSH_H */