tlbflush.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef _PARISC_TLBFLUSH_H
  3. #define _PARISC_TLBFLUSH_H
  4. /* TLB flushing routines.... */
  5. #include <linux/mm.h>
  6. #include <linux/sched.h>
  7. #include <asm/mmu_context.h>
  8. /* This is for the serialisation of PxTLB broadcasts. At least on the
  9. * N class systems, only one PxTLB inter processor broadcast can be
  10. * active at any one time on the Merced bus. This tlb purge
  11. * synchronisation is fairly lightweight and harmless so we activate
  12. * it on all systems not just the N class.
  13. * It is also used to ensure PTE updates are atomic and consistent
  14. * with the TLB.
  15. */
  16. extern spinlock_t pa_tlb_lock;
  17. #define purge_tlb_start(flags) spin_lock_irqsave(&pa_tlb_lock, flags)
  18. #define purge_tlb_end(flags) spin_unlock_irqrestore(&pa_tlb_lock, flags)
  19. extern void flush_tlb_all(void);
  20. extern void flush_tlb_all_local(void *);
  21. #define smp_flush_tlb_all() flush_tlb_all()
  22. int __flush_tlb_range(unsigned long sid,
  23. unsigned long start, unsigned long end);
  24. #define flush_tlb_range(vma, start, end) \
  25. __flush_tlb_range((vma)->vm_mm->context, start, end)
  26. #define flush_tlb_kernel_range(start, end) \
  27. __flush_tlb_range(0, start, end)
  28. /*
  29. * flush_tlb_mm()
  30. *
  31. * The code to switch to a new context is NOT valid for processes
  32. * which play with the space id's. Thus, we have to preserve the
  33. * space and just flush the entire tlb. However, the compilers,
  34. * dynamic linker, etc, do not manipulate space id's, so there
  35. * could be a significant performance benefit in switching contexts
  36. * and not flushing the whole tlb.
  37. */
  38. static inline void flush_tlb_mm(struct mm_struct *mm)
  39. {
  40. BUG_ON(mm == &init_mm); /* Should never happen */
  41. #if 1 || defined(CONFIG_SMP)
  42. /* Except for very small threads, flushing the whole TLB is
  43. * faster than using __flush_tlb_range. The pdtlb and pitlb
  44. * instructions are very slow because of the TLB broadcast.
  45. * It might be faster to do local range flushes on all CPUs
  46. * on PA 2.0 systems.
  47. */
  48. flush_tlb_all();
  49. #else
  50. /* FIXME: currently broken, causing space id and protection ids
  51. * to go out of sync, resulting in faults on userspace accesses.
  52. * This approach needs further investigation since running many
  53. * small applications (e.g., GCC testsuite) is faster on HP-UX.
  54. */
  55. if (mm) {
  56. if (mm->context != 0)
  57. free_sid(mm->context);
  58. mm->context = alloc_sid();
  59. if (mm == current->active_mm)
  60. load_context(mm->context);
  61. }
  62. #endif
  63. }
  64. static inline void flush_tlb_page(struct vm_area_struct *vma,
  65. unsigned long addr)
  66. {
  67. unsigned long flags, sid;
  68. sid = vma->vm_mm->context;
  69. purge_tlb_start(flags);
  70. mtsp(sid, 1);
  71. pdtlb(addr);
  72. if (unlikely(split_tlb))
  73. pitlb(addr);
  74. purge_tlb_end(flags);
  75. }
  76. #endif