tlbflush.h 2.6 KB

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