tlbflush.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. #ifndef _PARISC_TLBFLUSH_H
  2. #define _PARISC_TLBFLUSH_H
  3. /* TLB flushing routines.... */
  4. #include <linux/mm.h>
  5. #include <asm/mmu_context.h>
  6. /* This is for the serialisation of PxTLB broadcasts. At least on the
  7. * N class systems, only one PxTLB inter processor broadcast can be
  8. * active at any one time on the Merced bus. This tlb purge
  9. * synchronisation is fairly lightweight and harmless so we activate
  10. * it on all SMP systems not just the N class. We also need to have
  11. * preemption disabled on uniprocessor machines, and spin_lock does that
  12. * nicely.
  13. */
  14. extern spinlock_t pa_tlb_lock;
  15. #define purge_tlb_start(x) spin_lock(&pa_tlb_lock)
  16. #define purge_tlb_end(x) spin_unlock(&pa_tlb_lock)
  17. extern void flush_tlb_all(void);
  18. extern void flush_tlb_all_local(void *);
  19. /*
  20. * flush_tlb_mm()
  21. *
  22. * XXX This code is NOT valid for HP-UX compatibility processes,
  23. * (although it will probably work 99% of the time). HP-UX
  24. * processes are free to play with the space id's and save them
  25. * over long periods of time, etc. so we have to preserve the
  26. * space and just flush the entire tlb. We need to check the
  27. * personality in order to do that, but the personality is not
  28. * currently being set correctly.
  29. *
  30. * Of course, Linux processes could do the same thing, but
  31. * we don't support that (and the compilers, dynamic linker,
  32. * etc. do not do that).
  33. */
  34. static inline void flush_tlb_mm(struct mm_struct *mm)
  35. {
  36. BUG_ON(mm == &init_mm); /* Should never happen */
  37. #ifdef CONFIG_SMP
  38. flush_tlb_all();
  39. #else
  40. if (mm) {
  41. if (mm->context != 0)
  42. free_sid(mm->context);
  43. mm->context = alloc_sid();
  44. if (mm == current->active_mm)
  45. load_context(mm->context);
  46. }
  47. #endif
  48. }
  49. extern __inline__ void flush_tlb_pgtables(struct mm_struct *mm, unsigned long start, unsigned long end)
  50. {
  51. }
  52. static inline void flush_tlb_page(struct vm_area_struct *vma,
  53. unsigned long addr)
  54. {
  55. /* For one page, it's not worth testing the split_tlb variable */
  56. mb();
  57. mtsp(vma->vm_mm->context,1);
  58. purge_tlb_start();
  59. pdtlb(addr);
  60. pitlb(addr);
  61. purge_tlb_end();
  62. }
  63. static inline void flush_tlb_range(struct vm_area_struct *vma,
  64. unsigned long start, unsigned long end)
  65. {
  66. unsigned long npages;
  67. npages = ((end - (start & PAGE_MASK)) + (PAGE_SIZE - 1)) >> PAGE_SHIFT;
  68. if (npages >= 512) /* 2MB of space: arbitrary, should be tuned */
  69. flush_tlb_all();
  70. else {
  71. mtsp(vma->vm_mm->context,1);
  72. purge_tlb_start();
  73. if (split_tlb) {
  74. while (npages--) {
  75. pdtlb(start);
  76. pitlb(start);
  77. start += PAGE_SIZE;
  78. }
  79. } else {
  80. while (npages--) {
  81. pdtlb(start);
  82. start += PAGE_SIZE;
  83. }
  84. }
  85. purge_tlb_end();
  86. }
  87. }
  88. #define flush_tlb_kernel_range(start, end) flush_tlb_all()
  89. #endif