cache-smp-inv.c 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. /* Functions for global i/dcache invalidation when caching in SMP
  2. *
  3. * Copyright (C) 2010 Red Hat, Inc. All Rights Reserved.
  4. * Written by David Howells (dhowells@redhat.com)
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU General Public Licence
  8. * as published by the Free Software Foundation; either version
  9. * 2 of the Licence, or (at your option) any later version.
  10. */
  11. #include <linux/mm.h>
  12. #include <asm/cacheflush.h>
  13. #include "cache-smp.h"
  14. /**
  15. * mn10300_icache_inv - Globally invalidate instruction cache
  16. *
  17. * Invalidate the instruction cache on all CPUs.
  18. */
  19. void mn10300_icache_inv(void)
  20. {
  21. unsigned long flags;
  22. flags = smp_lock_cache();
  23. mn10300_local_icache_inv();
  24. smp_cache_call(SMP_ICACHE_INV, 0, 0);
  25. smp_unlock_cache(flags);
  26. }
  27. /**
  28. * mn10300_icache_inv_page - Globally invalidate a page of instruction cache
  29. * @start: The address of the page of memory to be invalidated.
  30. *
  31. * Invalidate a range of addresses in the instruction cache on all CPUs
  32. * covering the page that includes the given address.
  33. */
  34. void mn10300_icache_inv_page(unsigned long start)
  35. {
  36. unsigned long flags;
  37. start &= ~(PAGE_SIZE-1);
  38. flags = smp_lock_cache();
  39. mn10300_local_icache_inv_page(start);
  40. smp_cache_call(SMP_ICACHE_INV_RANGE, start, start + PAGE_SIZE);
  41. smp_unlock_cache(flags);
  42. }
  43. /**
  44. * mn10300_icache_inv_range - Globally invalidate range of instruction cache
  45. * @start: The start address of the region to be invalidated.
  46. * @end: The end address of the region to be invalidated.
  47. *
  48. * Invalidate a range of addresses in the instruction cache on all CPUs,
  49. * between start and end-1 inclusive.
  50. */
  51. void mn10300_icache_inv_range(unsigned long start, unsigned long end)
  52. {
  53. unsigned long flags;
  54. flags = smp_lock_cache();
  55. mn10300_local_icache_inv_range(start, end);
  56. smp_cache_call(SMP_ICACHE_INV_RANGE, start, end);
  57. smp_unlock_cache(flags);
  58. }
  59. /**
  60. * mn10300_icache_inv_range2 - Globally invalidate range of instruction cache
  61. * @start: The start address of the region to be invalidated.
  62. * @size: The size of the region to be invalidated.
  63. *
  64. * Invalidate a range of addresses in the instruction cache on all CPUs,
  65. * between start and start+size-1 inclusive.
  66. */
  67. void mn10300_icache_inv_range2(unsigned long start, unsigned long size)
  68. {
  69. unsigned long flags;
  70. flags = smp_lock_cache();
  71. mn10300_local_icache_inv_range2(start, size);
  72. smp_cache_call(SMP_ICACHE_INV_RANGE, start, start + size);
  73. smp_unlock_cache(flags);
  74. }
  75. /**
  76. * mn10300_dcache_inv - Globally invalidate data cache
  77. *
  78. * Invalidate the data cache on all CPUs.
  79. */
  80. void mn10300_dcache_inv(void)
  81. {
  82. unsigned long flags;
  83. flags = smp_lock_cache();
  84. mn10300_local_dcache_inv();
  85. smp_cache_call(SMP_DCACHE_INV, 0, 0);
  86. smp_unlock_cache(flags);
  87. }
  88. /**
  89. * mn10300_dcache_inv_page - Globally invalidate a page of data cache
  90. * @start: The address of the page of memory to be invalidated.
  91. *
  92. * Invalidate a range of addresses in the data cache on all CPUs covering the
  93. * page that includes the given address.
  94. */
  95. void mn10300_dcache_inv_page(unsigned long start)
  96. {
  97. unsigned long flags;
  98. start &= ~(PAGE_SIZE-1);
  99. flags = smp_lock_cache();
  100. mn10300_local_dcache_inv_page(start);
  101. smp_cache_call(SMP_DCACHE_INV_RANGE, start, start + PAGE_SIZE);
  102. smp_unlock_cache(flags);
  103. }
  104. /**
  105. * mn10300_dcache_inv_range - Globally invalidate range of data cache
  106. * @start: The start address of the region to be invalidated.
  107. * @end: The end address of the region to be invalidated.
  108. *
  109. * Invalidate a range of addresses in the data cache on all CPUs, between start
  110. * and end-1 inclusive.
  111. */
  112. void mn10300_dcache_inv_range(unsigned long start, unsigned long end)
  113. {
  114. unsigned long flags;
  115. flags = smp_lock_cache();
  116. mn10300_local_dcache_inv_range(start, end);
  117. smp_cache_call(SMP_DCACHE_INV_RANGE, start, end);
  118. smp_unlock_cache(flags);
  119. }
  120. /**
  121. * mn10300_dcache_inv_range2 - Globally invalidate range of data cache
  122. * @start: The start address of the region to be invalidated.
  123. * @size: The size of the region to be invalidated.
  124. *
  125. * Invalidate a range of addresses in the data cache on all CPUs, between start
  126. * and start+size-1 inclusive.
  127. */
  128. void mn10300_dcache_inv_range2(unsigned long start, unsigned long size)
  129. {
  130. unsigned long flags;
  131. flags = smp_lock_cache();
  132. mn10300_local_dcache_inv_range2(start, size);
  133. smp_cache_call(SMP_DCACHE_INV_RANGE, start, start + size);
  134. smp_unlock_cache(flags);
  135. }