Stephen Rothwell | 1970282 | 2005-11-04 16:58:59 +1100 | [diff] [blame] | 1 | #ifndef _ASM_POWERPC_TLBFLUSH_H |
| 2 | #define _ASM_POWERPC_TLBFLUSH_H |
| 3 | /* |
| 4 | * TLB flushing: |
| 5 | * |
| 6 | * - flush_tlb_mm(mm) flushes the specified mm context TLB's |
| 7 | * - flush_tlb_page(vma, vmaddr) flushes one page |
| 8 | * - flush_tlb_page_nohash(vma, vmaddr) flushes one page if SW loaded TLB |
| 9 | * - flush_tlb_range(vma, start, end) flushes a range of pages |
| 10 | * - flush_tlb_kernel_range(start, end) flushes a range of kernel pages |
| 11 | * - flush_tlb_pgtables(mm, start, end) flushes a range of page tables |
| 12 | * |
| 13 | * This program is free software; you can redistribute it and/or |
| 14 | * modify it under the terms of the GNU General Public License |
| 15 | * as published by the Free Software Foundation; either version |
| 16 | * 2 of the License, or (at your option) any later version. |
| 17 | */ |
| 18 | #ifdef __KERNEL__ |
| 19 | |
| 20 | #include <linux/config.h> |
| 21 | |
| 22 | struct mm_struct; |
| 23 | |
| 24 | #ifdef CONFIG_PPC64 |
| 25 | |
| 26 | #include <linux/percpu.h> |
| 27 | #include <asm/page.h> |
| 28 | |
| 29 | #define PPC64_TLB_BATCH_NR 192 |
| 30 | |
| 31 | struct ppc64_tlb_batch { |
| 32 | unsigned long index; |
| 33 | struct mm_struct *mm; |
Benjamin Herrenschmidt | 3c726f8 | 2005-11-07 11:06:55 +1100 | [diff] [blame] | 34 | real_pte_t pte[PPC64_TLB_BATCH_NR]; |
Stephen Rothwell | 1970282 | 2005-11-04 16:58:59 +1100 | [diff] [blame] | 35 | unsigned long vaddr[PPC64_TLB_BATCH_NR]; |
Benjamin Herrenschmidt | 3c726f8 | 2005-11-07 11:06:55 +1100 | [diff] [blame] | 36 | unsigned int psize; |
Stephen Rothwell | 1970282 | 2005-11-04 16:58:59 +1100 | [diff] [blame] | 37 | }; |
| 38 | DECLARE_PER_CPU(struct ppc64_tlb_batch, ppc64_tlb_batch); |
| 39 | |
| 40 | extern void __flush_tlb_pending(struct ppc64_tlb_batch *batch); |
| 41 | |
| 42 | static inline void flush_tlb_pending(void) |
| 43 | { |
| 44 | struct ppc64_tlb_batch *batch = &get_cpu_var(ppc64_tlb_batch); |
| 45 | |
| 46 | if (batch->index) |
| 47 | __flush_tlb_pending(batch); |
| 48 | put_cpu_var(ppc64_tlb_batch); |
| 49 | } |
| 50 | |
Benjamin Herrenschmidt | 3c726f8 | 2005-11-07 11:06:55 +1100 | [diff] [blame] | 51 | extern void flush_hash_page(unsigned long va, real_pte_t pte, int psize, |
| 52 | int local); |
| 53 | extern void flush_hash_range(unsigned long number, int local); |
Stephen Rothwell | 1970282 | 2005-11-04 16:58:59 +1100 | [diff] [blame] | 54 | |
| 55 | #else /* CONFIG_PPC64 */ |
| 56 | |
| 57 | #include <linux/mm.h> |
| 58 | |
| 59 | extern void _tlbie(unsigned long address); |
| 60 | extern void _tlbia(void); |
| 61 | |
| 62 | /* |
| 63 | * TODO: (CONFIG_FSL_BOOKE) determine if flush_tlb_range & |
| 64 | * flush_tlb_kernel_range are best implemented as tlbia vs |
| 65 | * specific tlbie's |
| 66 | */ |
| 67 | |
| 68 | #if (defined(CONFIG_4xx) && !defined(CONFIG_44x)) || defined(CONFIG_8xx) |
| 69 | #define flush_tlb_pending() asm volatile ("tlbia; sync" : : : "memory") |
| 70 | #elif defined(CONFIG_4xx) || defined(CONFIG_FSL_BOOKE) |
| 71 | #define flush_tlb_pending() _tlbia() |
| 72 | #endif |
| 73 | |
| 74 | /* |
| 75 | * This gets called at the end of handling a page fault, when |
| 76 | * the kernel has put a new PTE into the page table for the process. |
| 77 | * We use it to ensure coherency between the i-cache and d-cache |
| 78 | * for the page which has just been mapped in. |
| 79 | * On machines which use an MMU hash table, we use this to put a |
| 80 | * corresponding HPTE into the hash table ahead of time, instead of |
| 81 | * waiting for the inevitable extra hash-table miss exception. |
| 82 | */ |
| 83 | extern void update_mmu_cache(struct vm_area_struct *, unsigned long, pte_t); |
| 84 | |
| 85 | #endif /* CONFIG_PPC64 */ |
| 86 | |
| 87 | #if defined(CONFIG_PPC64) || defined(CONFIG_4xx) || \ |
| 88 | defined(CONFIG_FSL_BOOKE) || defined(CONFIG_8xx) |
| 89 | |
| 90 | static inline void flush_tlb_mm(struct mm_struct *mm) |
| 91 | { |
| 92 | flush_tlb_pending(); |
| 93 | } |
| 94 | |
| 95 | static inline void flush_tlb_page(struct vm_area_struct *vma, |
| 96 | unsigned long vmaddr) |
| 97 | { |
| 98 | #ifdef CONFIG_PPC64 |
| 99 | flush_tlb_pending(); |
| 100 | #else |
| 101 | _tlbie(vmaddr); |
| 102 | #endif |
| 103 | } |
| 104 | |
| 105 | static inline void flush_tlb_page_nohash(struct vm_area_struct *vma, |
| 106 | unsigned long vmaddr) |
| 107 | { |
| 108 | #ifndef CONFIG_PPC64 |
| 109 | _tlbie(vmaddr); |
| 110 | #endif |
| 111 | } |
| 112 | |
| 113 | static inline void flush_tlb_range(struct vm_area_struct *vma, |
| 114 | unsigned long start, unsigned long end) |
| 115 | { |
| 116 | flush_tlb_pending(); |
| 117 | } |
| 118 | |
| 119 | static inline void flush_tlb_kernel_range(unsigned long start, |
| 120 | unsigned long end) |
| 121 | { |
| 122 | flush_tlb_pending(); |
| 123 | } |
| 124 | |
| 125 | #else /* 6xx, 7xx, 7xxx cpus */ |
| 126 | |
| 127 | extern void flush_tlb_mm(struct mm_struct *mm); |
| 128 | extern void flush_tlb_page(struct vm_area_struct *vma, unsigned long vmaddr); |
| 129 | extern void flush_tlb_page_nohash(struct vm_area_struct *vma, unsigned long addr); |
| 130 | extern void flush_tlb_range(struct vm_area_struct *vma, unsigned long start, |
| 131 | unsigned long end); |
| 132 | extern void flush_tlb_kernel_range(unsigned long start, unsigned long end); |
| 133 | |
| 134 | #endif |
| 135 | |
| 136 | /* |
| 137 | * This is called in munmap when we have freed up some page-table |
| 138 | * pages. We don't need to do anything here, there's nothing special |
| 139 | * about our page-table pages. -- paulus |
| 140 | */ |
| 141 | static inline void flush_tlb_pgtables(struct mm_struct *mm, |
| 142 | unsigned long start, unsigned long end) |
| 143 | { |
| 144 | } |
| 145 | |
| 146 | #endif /*__KERNEL__ */ |
| 147 | #endif /* _ASM_POWERPC_TLBFLUSH_H */ |