tlbflush.h 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  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. * - local_flush_tlb_mm(mm) flushes the specified mm context on
  9. * the local processor
  10. * - local_flush_tlb_page(vma, vmaddr) flushes one page on the local processor
  11. * - flush_tlb_page_nohash(vma, vmaddr) flushes one page if SW loaded TLB
  12. * - flush_tlb_range(vma, start, end) flushes a range of pages
  13. * - flush_tlb_kernel_range(start, end) flushes a range of kernel pages
  14. *
  15. * This program is free software; you can redistribute it and/or
  16. * modify it under the terms of the GNU General Public License
  17. * as published by the Free Software Foundation; either version
  18. * 2 of the License, or (at your option) any later version.
  19. */
  20. #ifdef __KERNEL__
  21. #ifdef CONFIG_PPC_MMU_NOHASH
  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. #include <linux/mm.h>
  30. #define MMU_NO_CONTEXT ((unsigned int)-1)
  31. extern void _tlbil_all(void);
  32. extern void _tlbil_pid(unsigned int pid);
  33. extern void _tlbil_va(unsigned long address, unsigned int pid);
  34. extern void _tlbivax_bcast(unsigned long address, unsigned int pid);
  35. #if defined(CONFIG_40x) || defined(CONFIG_8xx)
  36. #define _tlbia() asm volatile ("tlbia; sync" : : : "memory")
  37. #else /* CONFIG_44x || CONFIG_FSL_BOOKE */
  38. extern void _tlbia(void);
  39. #endif
  40. extern void flush_tlb_range(struct vm_area_struct *vma, unsigned long start,
  41. unsigned long end);
  42. extern void flush_tlb_kernel_range(unsigned long start, unsigned long end);
  43. extern void local_flush_tlb_mm(struct mm_struct *mm);
  44. extern void local_flush_tlb_page(struct vm_area_struct *vma, unsigned long vmaddr);
  45. #ifdef CONFIG_SMP
  46. extern void flush_tlb_mm(struct mm_struct *mm);
  47. extern void flush_tlb_page(struct vm_area_struct *vma, unsigned long vmaddr);
  48. #else
  49. #define flush_tlb_mm(mm) local_flush_tlb_mm(mm)
  50. #define flush_tlb_page(vma,addr) local_flush_tlb_page(vma,addr)
  51. #endif
  52. #define flush_tlb_page_nohash(vma,addr) flush_tlb_page(vma,addr)
  53. #elif defined(CONFIG_PPC_STD_MMU_32)
  54. /*
  55. * TLB flushing for "classic" hash-MMU 32-bit CPUs, 6xx, 7xx, 7xxx
  56. */
  57. extern void _tlbie(unsigned long address);
  58. extern void _tlbia(void);
  59. extern void flush_tlb_mm(struct mm_struct *mm);
  60. extern void flush_tlb_page(struct vm_area_struct *vma, unsigned long vmaddr);
  61. extern void flush_tlb_page_nohash(struct vm_area_struct *vma, unsigned long addr);
  62. extern void flush_tlb_range(struct vm_area_struct *vma, unsigned long start,
  63. unsigned long end);
  64. extern void flush_tlb_kernel_range(unsigned long start, unsigned long end);
  65. static inline void local_flush_tlb_page(struct vm_area_struct *vma,
  66. unsigned long vmaddr)
  67. {
  68. flush_tlb_page(vma, vmaddr);
  69. }
  70. static inline void local_flush_tlb_mm(struct mm_struct *mm)
  71. {
  72. flush_tlb_mm(mm);
  73. }
  74. #elif defined(CONFIG_PPC_STD_MMU_64)
  75. /*
  76. * TLB flushing for 64-bit hash-MMU CPUs
  77. */
  78. #include <linux/percpu.h>
  79. #include <asm/page.h>
  80. #define PPC64_TLB_BATCH_NR 192
  81. struct ppc64_tlb_batch {
  82. int active;
  83. unsigned long index;
  84. struct mm_struct *mm;
  85. real_pte_t pte[PPC64_TLB_BATCH_NR];
  86. unsigned long vaddr[PPC64_TLB_BATCH_NR];
  87. unsigned int psize;
  88. int ssize;
  89. };
  90. DECLARE_PER_CPU(struct ppc64_tlb_batch, ppc64_tlb_batch);
  91. extern void __flush_tlb_pending(struct ppc64_tlb_batch *batch);
  92. extern void hpte_need_flush(struct mm_struct *mm, unsigned long addr,
  93. pte_t *ptep, unsigned long pte, int huge);
  94. #define __HAVE_ARCH_ENTER_LAZY_MMU_MODE
  95. static inline void arch_enter_lazy_mmu_mode(void)
  96. {
  97. struct ppc64_tlb_batch *batch = &__get_cpu_var(ppc64_tlb_batch);
  98. batch->active = 1;
  99. }
  100. static inline void arch_leave_lazy_mmu_mode(void)
  101. {
  102. struct ppc64_tlb_batch *batch = &__get_cpu_var(ppc64_tlb_batch);
  103. if (batch->index)
  104. __flush_tlb_pending(batch);
  105. batch->active = 0;
  106. }
  107. #define arch_flush_lazy_mmu_mode() do {} while (0)
  108. extern void flush_hash_page(unsigned long va, real_pte_t pte, int psize,
  109. int ssize, int local);
  110. extern void flush_hash_range(unsigned long number, int local);
  111. static inline void local_flush_tlb_mm(struct mm_struct *mm)
  112. {
  113. }
  114. static inline void flush_tlb_mm(struct mm_struct *mm)
  115. {
  116. }
  117. static inline void local_flush_tlb_page(struct vm_area_struct *vma,
  118. unsigned long vmaddr)
  119. {
  120. }
  121. static inline void flush_tlb_page(struct vm_area_struct *vma,
  122. unsigned long vmaddr)
  123. {
  124. }
  125. static inline void flush_tlb_page_nohash(struct vm_area_struct *vma,
  126. unsigned long vmaddr)
  127. {
  128. }
  129. static inline void flush_tlb_range(struct vm_area_struct *vma,
  130. unsigned long start, unsigned long end)
  131. {
  132. }
  133. static inline void flush_tlb_kernel_range(unsigned long start,
  134. unsigned long end)
  135. {
  136. }
  137. /* Private function for use by PCI IO mapping code */
  138. extern void __flush_hash_table_range(struct mm_struct *mm, unsigned long start,
  139. unsigned long end);
  140. #else
  141. #error Unsupported MMU type
  142. #endif
  143. #endif /*__KERNEL__ */
  144. #endif /* _ASM_POWERPC_TLBFLUSH_H */