blob: 93716a9f4e162783ba5700c37f87a641da07fbfd [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
32extern void _tlbie(unsigned long address, unsigned int pid);
Kumar Gala0ba34182008-07-15 16:12:25 -050033extern void _tlbil_all(void);
34extern void _tlbil_pid(unsigned int pid);
35extern void _tlbil_va(unsigned long address, unsigned int pid);
David Gibson62102302007-04-24 13:09:12 +100036
37#if defined(CONFIG_40x) || defined(CONFIG_8xx)
38#define _tlbia() asm volatile ("tlbia; sync" : : : "memory")
39#else /* CONFIG_44x || CONFIG_FSL_BOOKE */
40extern void _tlbia(void);
41#endif
42
43static inline void flush_tlb_mm(struct mm_struct *mm)
44{
Kumar Gala0ba34182008-07-15 16:12:25 -050045 _tlbil_pid(mm->context.id);
David Gibson62102302007-04-24 13:09:12 +100046}
47
Kumar Galadf3b8612008-11-19 05:53:24 +000048static inline void local_flush_tlb_page(unsigned long vmaddr)
49{
50 _tlbil_va(vmaddr, 0);
51}
52
David Gibson62102302007-04-24 13:09:12 +100053static inline void flush_tlb_page(struct vm_area_struct *vma,
54 unsigned long vmaddr)
55{
Kumar Gala0ba34182008-07-15 16:12:25 -050056 _tlbil_va(vmaddr, vma ? vma->vm_mm->context.id : 0);
David Gibson62102302007-04-24 13:09:12 +100057}
58
59static inline void flush_tlb_page_nohash(struct vm_area_struct *vma,
60 unsigned long vmaddr)
61{
Kumar Gala0ba34182008-07-15 16:12:25 -050062 flush_tlb_page(vma, vmaddr);
David Gibson62102302007-04-24 13:09:12 +100063}
64
65static inline void flush_tlb_range(struct vm_area_struct *vma,
66 unsigned long start, unsigned long end)
67{
Kumar Gala0ba34182008-07-15 16:12:25 -050068 _tlbil_pid(vma->vm_mm->context.id);
David Gibson62102302007-04-24 13:09:12 +100069}
70
71static inline void flush_tlb_kernel_range(unsigned long start,
72 unsigned long end)
73{
Kumar Gala0ba34182008-07-15 16:12:25 -050074 _tlbil_pid(0);
David Gibson62102302007-04-24 13:09:12 +100075}
76
77#elif defined(CONFIG_PPC32)
78/*
79 * TLB flushing for "classic" hash-MMMU 32-bit CPUs, 6xx, 7xx, 7xxx
80 */
81extern void _tlbie(unsigned long address);
82extern void _tlbia(void);
83
84extern void flush_tlb_mm(struct mm_struct *mm);
85extern void flush_tlb_page(struct vm_area_struct *vma, unsigned long vmaddr);
86extern void flush_tlb_page_nohash(struct vm_area_struct *vma, unsigned long addr);
87extern void flush_tlb_range(struct vm_area_struct *vma, unsigned long start,
88 unsigned long end);
89extern void flush_tlb_kernel_range(unsigned long start, unsigned long end);
Kumar Galadf3b8612008-11-19 05:53:24 +000090static inline void local_flush_tlb_page(unsigned long vmaddr)
91{
92 flush_tlb_page(NULL, vmaddr);
93}
David Gibson62102302007-04-24 13:09:12 +100094
95#else
96/*
97 * TLB flushing for 64-bit has-MMU CPUs
98 */
Stephen Rothwell19702822005-11-04 16:58:59 +110099
100#include <linux/percpu.h>
101#include <asm/page.h>
102
103#define PPC64_TLB_BATCH_NR 192
104
105struct ppc64_tlb_batch {
Benjamin Herrenschmidta741e672007-04-10 17:09:37 +1000106 int active;
107 unsigned long index;
108 struct mm_struct *mm;
109 real_pte_t pte[PPC64_TLB_BATCH_NR];
110 unsigned long vaddr[PPC64_TLB_BATCH_NR];
111 unsigned int psize;
Paul Mackerras1189be62007-10-11 20:37:10 +1000112 int ssize;
Stephen Rothwell19702822005-11-04 16:58:59 +1100113};
114DECLARE_PER_CPU(struct ppc64_tlb_batch, ppc64_tlb_batch);
115
116extern void __flush_tlb_pending(struct ppc64_tlb_batch *batch);
117
Benjamin Herrenschmidta741e672007-04-10 17:09:37 +1000118extern void hpte_need_flush(struct mm_struct *mm, unsigned long addr,
119 pte_t *ptep, unsigned long pte, int huge);
120
121#define __HAVE_ARCH_ENTER_LAZY_MMU_MODE
122
123static inline void arch_enter_lazy_mmu_mode(void)
Stephen Rothwell19702822005-11-04 16:58:59 +1100124{
Benjamin Herrenschmidta741e672007-04-10 17:09:37 +1000125 struct ppc64_tlb_batch *batch = &__get_cpu_var(ppc64_tlb_batch);
126
127 batch->active = 1;
128}
129
130static inline void arch_leave_lazy_mmu_mode(void)
131{
132 struct ppc64_tlb_batch *batch = &__get_cpu_var(ppc64_tlb_batch);
Stephen Rothwell19702822005-11-04 16:58:59 +1100133
134 if (batch->index)
135 __flush_tlb_pending(batch);
Benjamin Herrenschmidta741e672007-04-10 17:09:37 +1000136 batch->active = 0;
Stephen Rothwell19702822005-11-04 16:58:59 +1100137}
138
Benjamin Herrenschmidta741e672007-04-10 17:09:37 +1000139#define arch_flush_lazy_mmu_mode() do {} while (0)
140
141
Benjamin Herrenschmidt3c726f82005-11-07 11:06:55 +1100142extern void flush_hash_page(unsigned long va, real_pte_t pte, int psize,
Paul Mackerras1189be62007-10-11 20:37:10 +1000143 int ssize, int local);
Benjamin Herrenschmidt3c726f82005-11-07 11:06:55 +1100144extern void flush_hash_range(unsigned long number, int local);
Stephen Rothwell19702822005-11-04 16:58:59 +1100145
Stephen Rothwell19702822005-11-04 16:58:59 +1100146
David Gibson62102302007-04-24 13:09:12 +1000147static inline void flush_tlb_mm(struct mm_struct *mm)
148{
149}
Stephen Rothwell19702822005-11-04 16:58:59 +1100150
Kumar Galadf3b8612008-11-19 05:53:24 +0000151static inline void local_flush_tlb_page(unsigned long vmaddr)
152{
153}
154
David Gibson62102302007-04-24 13:09:12 +1000155static inline void flush_tlb_page(struct vm_area_struct *vma,
156 unsigned long vmaddr)
157{
158}
Stephen Rothwell19702822005-11-04 16:58:59 +1100159
David Gibson62102302007-04-24 13:09:12 +1000160static inline void flush_tlb_page_nohash(struct vm_area_struct *vma,
161 unsigned long vmaddr)
162{
163}
Stephen Rothwell19702822005-11-04 16:58:59 +1100164
David Gibson62102302007-04-24 13:09:12 +1000165static inline void flush_tlb_range(struct vm_area_struct *vma,
166 unsigned long start, unsigned long end)
167{
168}
169
170static inline void flush_tlb_kernel_range(unsigned long start,
171 unsigned long end)
172{
173}
174
Benjamin Herrenschmidt3d5134e2007-06-04 15:15:36 +1000175/* Private function for use by PCI IO mapping code */
176extern void __flush_hash_table_range(struct mm_struct *mm, unsigned long start,
177 unsigned long end);
178
179
Stephen Rothwell19702822005-11-04 16:58:59 +1100180#endif
181
Stephen Rothwell19702822005-11-04 16:58:59 +1100182#endif /*__KERNEL__ */
183#endif /* _ASM_POWERPC_TLBFLUSH_H */