smp_tlb.c 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. /*
  2. * linux/arch/arm/kernel/smp_tlb.c
  3. *
  4. * Copyright (C) 2002 ARM Limited, All Rights Reserved.
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License version 2 as
  8. * published by the Free Software Foundation.
  9. */
  10. #include <linux/preempt.h>
  11. #include <linux/smp.h>
  12. #include <asm/smp_plat.h>
  13. #include <asm/tlbflush.h>
  14. static void on_each_cpu_mask(void (*func)(void *), void *info, int wait,
  15. const struct cpumask *mask)
  16. {
  17. preempt_disable();
  18. smp_call_function_many(mask, func, info, wait);
  19. if (cpumask_test_cpu(smp_processor_id(), mask))
  20. func(info);
  21. preempt_enable();
  22. }
  23. /**********************************************************************/
  24. /*
  25. * TLB operations
  26. */
  27. struct tlb_args {
  28. struct vm_area_struct *ta_vma;
  29. unsigned long ta_start;
  30. unsigned long ta_end;
  31. };
  32. static inline void ipi_flush_tlb_all(void *ignored)
  33. {
  34. local_flush_tlb_all();
  35. }
  36. static inline void ipi_flush_tlb_mm(void *arg)
  37. {
  38. struct mm_struct *mm = (struct mm_struct *)arg;
  39. local_flush_tlb_mm(mm);
  40. }
  41. static inline void ipi_flush_tlb_page(void *arg)
  42. {
  43. struct tlb_args *ta = (struct tlb_args *)arg;
  44. local_flush_tlb_page(ta->ta_vma, ta->ta_start);
  45. }
  46. static inline void ipi_flush_tlb_kernel_page(void *arg)
  47. {
  48. struct tlb_args *ta = (struct tlb_args *)arg;
  49. local_flush_tlb_kernel_page(ta->ta_start);
  50. }
  51. static inline void ipi_flush_tlb_range(void *arg)
  52. {
  53. struct tlb_args *ta = (struct tlb_args *)arg;
  54. local_flush_tlb_range(ta->ta_vma, ta->ta_start, ta->ta_end);
  55. }
  56. static inline void ipi_flush_tlb_kernel_range(void *arg)
  57. {
  58. struct tlb_args *ta = (struct tlb_args *)arg;
  59. local_flush_tlb_kernel_range(ta->ta_start, ta->ta_end);
  60. }
  61. void flush_tlb_all(void)
  62. {
  63. if (tlb_ops_need_broadcast())
  64. on_each_cpu(ipi_flush_tlb_all, NULL, 1);
  65. else
  66. local_flush_tlb_all();
  67. }
  68. void flush_tlb_mm(struct mm_struct *mm)
  69. {
  70. if (tlb_ops_need_broadcast())
  71. on_each_cpu_mask(ipi_flush_tlb_mm, mm, 1, mm_cpumask(mm));
  72. else
  73. local_flush_tlb_mm(mm);
  74. }
  75. void flush_tlb_page(struct vm_area_struct *vma, unsigned long uaddr)
  76. {
  77. if (tlb_ops_need_broadcast()) {
  78. struct tlb_args ta;
  79. ta.ta_vma = vma;
  80. ta.ta_start = uaddr;
  81. on_each_cpu_mask(ipi_flush_tlb_page, &ta, 1, mm_cpumask(vma->vm_mm));
  82. } else
  83. local_flush_tlb_page(vma, uaddr);
  84. }
  85. void flush_tlb_kernel_page(unsigned long kaddr)
  86. {
  87. if (tlb_ops_need_broadcast()) {
  88. struct tlb_args ta;
  89. ta.ta_start = kaddr;
  90. on_each_cpu(ipi_flush_tlb_kernel_page, &ta, 1);
  91. } else
  92. local_flush_tlb_kernel_page(kaddr);
  93. }
  94. void flush_tlb_range(struct vm_area_struct *vma,
  95. unsigned long start, unsigned long end)
  96. {
  97. if (tlb_ops_need_broadcast()) {
  98. struct tlb_args ta;
  99. ta.ta_vma = vma;
  100. ta.ta_start = start;
  101. ta.ta_end = end;
  102. on_each_cpu_mask(ipi_flush_tlb_range, &ta, 1, mm_cpumask(vma->vm_mm));
  103. } else
  104. local_flush_tlb_range(vma, start, end);
  105. }
  106. void flush_tlb_kernel_range(unsigned long start, unsigned long end)
  107. {
  108. if (tlb_ops_need_broadcast()) {
  109. struct tlb_args ta;
  110. ta.ta_start = start;
  111. ta.ta_end = end;
  112. on_each_cpu(ipi_flush_tlb_kernel_range, &ta, 1);
  113. } else
  114. local_flush_tlb_kernel_range(start, end);
  115. }