aboutsummaryrefslogtreecommitdiffstats
path: root/arch/sh/mm/cache-sh4.c
diff options
context:
space:
mode:
authorPaul Mundt <lethal@linux-sh.org>2009-08-24 09:49:17 -0400
committerPaul Mundt <lethal@linux-sh.org>2009-08-24 09:49:17 -0400
commit12cceb6251c2cd23e936b25eca66be99ba41b081 (patch)
treeb7f62853e67b305519c375162760422fbfc81b8e /arch/sh/mm/cache-sh4.c
parentf13327864f94c3a0e6acca923df537d20059639f (diff)
parent05ecd5a1f76c183cca381705b3adb7d77c9a0439 (diff)
Merge branch 'sh/st-integration'
Diffstat (limited to 'arch/sh/mm/cache-sh4.c')
-rw-r--r--arch/sh/mm/cache-sh4.c45
1 files changed, 45 insertions, 0 deletions
diff --git a/arch/sh/mm/cache-sh4.c b/arch/sh/mm/cache-sh4.c
index 5cfe08dbb59e..397c1030c7a6 100644
--- a/arch/sh/mm/cache-sh4.c
+++ b/arch/sh/mm/cache-sh4.c
@@ -581,6 +581,31 @@ static void __flush_cache_4096(unsigned long addr, unsigned long phys,
581 * Break the 1, 2 and 4 way variants of this out into separate functions to 581 * Break the 1, 2 and 4 way variants of this out into separate functions to
582 * avoid nearly all the overhead of having the conditional stuff in the function 582 * avoid nearly all the overhead of having the conditional stuff in the function
583 * bodies (+ the 1 and 2 way cases avoid saving any registers too). 583 * bodies (+ the 1 and 2 way cases avoid saving any registers too).
584 *
585 * We want to eliminate unnecessary bus transactions, so this code uses
586 * a non-obvious technique.
587 *
588 * Loop over a cache way sized block of, one cache line at a time. For each
589 * line, use movca.a to cause the current cache line contents to be written
590 * back, but without reading anything from main memory. However this has the
591 * side effect that the cache is now caching that memory location. So follow
592 * this with a cache invalidate to mark the cache line invalid. And do all
593 * this with interrupts disabled, to avoid the cache line being accidently
594 * evicted while it is holding garbage.
595 *
596 * This also breaks in a number of circumstances:
597 * - if there are modifications to the region of memory just above
598 * empty_zero_page (for example because a breakpoint has been placed
599 * there), then these can be lost.
600 *
601 * This is because the the memory address which the cache temporarily
602 * caches in the above description is empty_zero_page. So the
603 * movca.l hits the cache (it is assumed that it misses, or at least
604 * isn't dirty), modifies the line and then invalidates it, losing the
605 * required change.
606 *
607 * - If caches are disabled or configured in write-through mode, then
608 * the movca.l writes garbage directly into memory.
584 */ 609 */
585static void __flush_dcache_segment_1way(unsigned long start, 610static void __flush_dcache_segment_1way(unsigned long start,
586 unsigned long extent_per_way) 611 unsigned long extent_per_way)
@@ -630,6 +655,25 @@ static void __flush_dcache_segment_1way(unsigned long start,
630 } while (a0 < a0e); 655 } while (a0 < a0e);
631} 656}
632 657
658#ifdef CONFIG_CACHE_WRITETHROUGH
659/* This method of cache flushing avoids the problems discussed
660 * in the comment above if writethrough caches are enabled. */
661static void __flush_dcache_segment_2way(unsigned long start,
662 unsigned long extent_per_way)
663{
664 unsigned long array_addr;
665
666 array_addr = CACHE_OC_ADDRESS_ARRAY |
667 (start & cpu_data->dcache.entry_mask);
668
669 while (extent_per_way) {
670 ctrl_outl(0, array_addr);
671 ctrl_outl(0, array_addr + cpu_data->dcache.way_incr);
672 array_addr += cpu_data->dcache.linesz;
673 extent_per_way -= cpu_data->dcache.linesz;
674 }
675}
676#else
633static void __flush_dcache_segment_2way(unsigned long start, 677static void __flush_dcache_segment_2way(unsigned long start,
634 unsigned long extent_per_way) 678 unsigned long extent_per_way)
635{ 679{
@@ -688,6 +732,7 @@ static void __flush_dcache_segment_2way(unsigned long start,
688 a1 += linesz; 732 a1 += linesz;
689 } while (a0 < a0e); 733 } while (a0 < a0e);
690} 734}
735#endif
691 736
692static void __flush_dcache_segment_4way(unsigned long start, 737static void __flush_dcache_segment_4way(unsigned long start,
693 unsigned long extent_per_way) 738 unsigned long extent_per_way)