tlbflush.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. /* MN10300 TLB flushing functions
  2. *
  3. * Copyright (C) 2007 Red Hat, Inc. All Rights Reserved.
  4. * Written by David Howells (dhowells@redhat.com)
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU General Public Licence
  8. * as published by the Free Software Foundation; either version
  9. * 2 of the Licence, or (at your option) any later version.
  10. */
  11. #ifndef _ASM_TLBFLUSH_H
  12. #define _ASM_TLBFLUSH_H
  13. #include <linux/mm.h>
  14. #include <asm/processor.h>
  15. struct tlb_state {
  16. struct mm_struct *active_mm;
  17. int state;
  18. };
  19. DECLARE_PER_CPU_SHARED_ALIGNED(struct tlb_state, cpu_tlbstate);
  20. /**
  21. * local_flush_tlb - Flush the current MM's entries from the local CPU's TLBs
  22. */
  23. static inline void local_flush_tlb(void)
  24. {
  25. int w;
  26. asm volatile(
  27. " mov %1,%0 \n"
  28. " or %2,%0 \n"
  29. " mov %0,%1 \n"
  30. : "=d"(w)
  31. : "m"(MMUCTR), "i"(MMUCTR_IIV|MMUCTR_DIV)
  32. : "cc", "memory");
  33. }
  34. /**
  35. * local_flush_tlb_all - Flush all entries from the local CPU's TLBs
  36. */
  37. static inline void local_flush_tlb_all(void)
  38. {
  39. local_flush_tlb();
  40. }
  41. /**
  42. * local_flush_tlb_one - Flush one entry from the local CPU's TLBs
  43. */
  44. static inline void local_flush_tlb_one(unsigned long addr)
  45. {
  46. local_flush_tlb();
  47. }
  48. /**
  49. * local_flush_tlb_page - Flush a page's entry from the local CPU's TLBs
  50. * @mm: The MM to flush for
  51. * @addr: The address of the target page in RAM (not its page struct)
  52. */
  53. static inline
  54. void local_flush_tlb_page(struct mm_struct *mm, unsigned long addr)
  55. {
  56. unsigned long pteu, flags, cnx;
  57. addr &= PAGE_MASK;
  58. local_irq_save(flags);
  59. cnx = 1;
  60. #ifdef CONFIG_MN10300_TLB_USE_PIDR
  61. cnx = mm->context.tlbpid[smp_processor_id()];
  62. #endif
  63. if (cnx) {
  64. pteu = addr;
  65. #ifdef CONFIG_MN10300_TLB_USE_PIDR
  66. pteu |= cnx & xPTEU_PID;
  67. #endif
  68. IPTEU = pteu;
  69. DPTEU = pteu;
  70. if (IPTEL & xPTEL_V)
  71. IPTEL = 0;
  72. if (DPTEL & xPTEL_V)
  73. DPTEL = 0;
  74. }
  75. local_irq_restore(flags);
  76. }
  77. /*
  78. * TLB flushing:
  79. *
  80. * - flush_tlb() flushes the current mm struct TLBs
  81. * - flush_tlb_all() flushes all processes TLBs
  82. * - flush_tlb_mm(mm) flushes the specified mm context TLB's
  83. * - flush_tlb_page(vma, vmaddr) flushes one page
  84. * - flush_tlb_range(mm, start, end) flushes a range of pages
  85. * - flush_tlb_pgtables(mm, start, end) flushes a range of page tables
  86. */
  87. #ifdef CONFIG_SMP
  88. #include <asm/smp.h>
  89. extern void flush_tlb_all(void);
  90. extern void flush_tlb_current_task(void);
  91. extern void flush_tlb_mm(struct mm_struct *);
  92. extern void flush_tlb_page(struct vm_area_struct *, unsigned long);
  93. #define flush_tlb() flush_tlb_current_task()
  94. static inline void flush_tlb_range(struct vm_area_struct *vma,
  95. unsigned long start, unsigned long end)
  96. {
  97. flush_tlb_mm(vma->vm_mm);
  98. }
  99. #else /* CONFIG_SMP */
  100. static inline void flush_tlb_all(void)
  101. {
  102. preempt_disable();
  103. local_flush_tlb_all();
  104. preempt_enable();
  105. }
  106. static inline void flush_tlb_mm(struct mm_struct *mm)
  107. {
  108. preempt_disable();
  109. local_flush_tlb_all();
  110. preempt_enable();
  111. }
  112. static inline void flush_tlb_range(struct vm_area_struct *vma,
  113. unsigned long start, unsigned long end)
  114. {
  115. preempt_disable();
  116. local_flush_tlb_all();
  117. preempt_enable();
  118. }
  119. #define flush_tlb_page(vma, addr) local_flush_tlb_page((vma)->vm_mm, addr)
  120. #define flush_tlb() flush_tlb_all()
  121. #endif /* CONFIG_SMP */
  122. static inline void flush_tlb_kernel_range(unsigned long start,
  123. unsigned long end)
  124. {
  125. flush_tlb_all();
  126. }
  127. static inline void flush_tlb_pgtables(struct mm_struct *mm,
  128. unsigned long start, unsigned long end)
  129. {
  130. }
  131. #endif /* _ASM_TLBFLUSH_H */