cache-smp-flush.c 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. /* Functions for global dcache flush when writeback 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_dcache_flush - Globally flush data cache
  16. *
  17. * Flush the data cache on all CPUs.
  18. */
  19. void mn10300_dcache_flush(void)
  20. {
  21. unsigned long flags;
  22. flags = smp_lock_cache();
  23. mn10300_local_dcache_flush();
  24. smp_cache_call(SMP_DCACHE_FLUSH, 0, 0);
  25. smp_unlock_cache(flags);
  26. }
  27. /**
  28. * mn10300_dcache_flush_page - Globally flush a page of data cache
  29. * @start: The address of the page of memory to be flushed.
  30. *
  31. * Flush a range of addresses in the data cache on all CPUs covering
  32. * the page that includes the given address.
  33. */
  34. void mn10300_dcache_flush_page(unsigned long start)
  35. {
  36. unsigned long flags;
  37. start &= ~(PAGE_SIZE-1);
  38. flags = smp_lock_cache();
  39. mn10300_local_dcache_flush_page(start);
  40. smp_cache_call(SMP_DCACHE_FLUSH_RANGE, start, start + PAGE_SIZE);
  41. smp_unlock_cache(flags);
  42. }
  43. /**
  44. * mn10300_dcache_flush_range - Globally flush range of data cache
  45. * @start: The start address of the region to be flushed.
  46. * @end: The end address of the region to be flushed.
  47. *
  48. * Flush a range of addresses in the data cache on all CPUs, between start and
  49. * end-1 inclusive.
  50. */
  51. void mn10300_dcache_flush_range(unsigned long start, unsigned long end)
  52. {
  53. unsigned long flags;
  54. flags = smp_lock_cache();
  55. mn10300_local_dcache_flush_range(start, end);
  56. smp_cache_call(SMP_DCACHE_FLUSH_RANGE, start, end);
  57. smp_unlock_cache(flags);
  58. }
  59. /**
  60. * mn10300_dcache_flush_range2 - Globally flush range of data cache
  61. * @start: The start address of the region to be flushed.
  62. * @size: The size of the region to be flushed.
  63. *
  64. * Flush a range of addresses in the data cache on all CPUs, between start and
  65. * start+size-1 inclusive.
  66. */
  67. void mn10300_dcache_flush_range2(unsigned long start, unsigned long size)
  68. {
  69. unsigned long flags;
  70. flags = smp_lock_cache();
  71. mn10300_local_dcache_flush_range2(start, size);
  72. smp_cache_call(SMP_DCACHE_FLUSH_RANGE, start, start + size);
  73. smp_unlock_cache(flags);
  74. }
  75. /**
  76. * mn10300_dcache_flush_inv - Globally flush and invalidate data cache
  77. *
  78. * Flush and invalidate the data cache on all CPUs.
  79. */
  80. void mn10300_dcache_flush_inv(void)
  81. {
  82. unsigned long flags;
  83. flags = smp_lock_cache();
  84. mn10300_local_dcache_flush_inv();
  85. smp_cache_call(SMP_DCACHE_FLUSH_INV, 0, 0);
  86. smp_unlock_cache(flags);
  87. }
  88. /**
  89. * mn10300_dcache_flush_inv_page - Globally flush and invalidate a page of data
  90. * cache
  91. * @start: The address of the page of memory to be flushed and invalidated.
  92. *
  93. * Flush and invalidate a range of addresses in the data cache on all CPUs
  94. * covering the page that includes the given address.
  95. */
  96. void mn10300_dcache_flush_inv_page(unsigned long start)
  97. {
  98. unsigned long flags;
  99. start &= ~(PAGE_SIZE-1);
  100. flags = smp_lock_cache();
  101. mn10300_local_dcache_flush_inv_page(start);
  102. smp_cache_call(SMP_DCACHE_FLUSH_INV_RANGE, start, start + PAGE_SIZE);
  103. smp_unlock_cache(flags);
  104. }
  105. /**
  106. * mn10300_dcache_flush_inv_range - Globally flush and invalidate range of data
  107. * cache
  108. * @start: The start address of the region to be flushed and invalidated.
  109. * @end: The end address of the region to be flushed and invalidated.
  110. *
  111. * Flush and invalidate a range of addresses in the data cache on all CPUs,
  112. * between start and end-1 inclusive.
  113. */
  114. void mn10300_dcache_flush_inv_range(unsigned long start, unsigned long end)
  115. {
  116. unsigned long flags;
  117. flags = smp_lock_cache();
  118. mn10300_local_dcache_flush_inv_range(start, end);
  119. smp_cache_call(SMP_DCACHE_FLUSH_INV_RANGE, start, end);
  120. smp_unlock_cache(flags);
  121. }
  122. /**
  123. * mn10300_dcache_flush_inv_range2 - Globally flush and invalidate range of data
  124. * cache
  125. * @start: The start address of the region to be flushed and invalidated.
  126. * @size: The size of the region to be flushed and invalidated.
  127. *
  128. * Flush and invalidate a range of addresses in the data cache on all CPUs,
  129. * between start and start+size-1 inclusive.
  130. */
  131. void mn10300_dcache_flush_inv_range2(unsigned long start, unsigned long size)
  132. {
  133. unsigned long flags;
  134. flags = smp_lock_cache();
  135. mn10300_local_dcache_flush_inv_range2(start, size);
  136. smp_cache_call(SMP_DCACHE_FLUSH_INV_RANGE, start, start + size);
  137. smp_unlock_cache(flags);
  138. }