tlbflush.h 2.6 KB

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