Skip to contentSkip to conversation

m68k: fix ColdFire clear cache operation

PATCH Superseded [email protected] 2 participants 3 messages Jul 10, 2012 m68k architecture

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 m68k: fix ColdFire clear cache operation

From: Greg Ungerer <[email protected]>

The code for clearing (invalidating) the ColdFire cache is actually performing a push operation. Add functions to clear the cache, and fix cache_clear() to call the appropriate clear cache function.

---
 arch/m68k/include/asm/cacheflush_mm.h |   41 +++++++++++++++++++++++++++++++++
 arch/m68k/mm/memory.c                 |    2 +-
 2 files changed, 42 insertions(+), 1 deletions(-)
arch/m68k/include/asm/cacheflush_mm.h +41 -0
index 8104bd8..a32ffc9 100644
@@ -17,6 +17,47 @@
 #define DCACHE_SETMASK	0
 #endif
 
+/*
+ * ColdFire architecture has no way to clear individual cache lines, so we
+ * are stuck invalidating all the cache entries when we want a clear operation.
+ */
+static inline void clear_cf_icache(unsigned long start, unsigned long end)
+{
+	__asm__ __volatile__ (
+		"movel	%0,%%d0\n\t"
+		"movec	%%d0,%%cacr\n\t"
+		"nop\n\t"
+		:
+		: "i" (CACHE_MODE | CACR_ICINVA | CACR_BCINVA)
+		: "d0");
+}
+
+static inline void clear_cf_dcache(unsigned long start, unsigned long end)
+{
+	__asm__ __volatile__ (
+		"movel	%0,%%d0\n\t"
+		"movec	%%d0,%%cacr\n\t"
+		"nop\n\t"
+		:
+		: "i" (CACHE_MODE | CACR_DCINVA)
+		: "d0");
+}
+
+static inline void clear_cf_bcache(unsigned long start, unsigned long end)
+{
+	__asm__ __volatile__ (
+		"movel	%0,%%d0\n\t"
+		"movec	%%d0,%%cacr\n\t"
+		"nop\n\t"
+		:
+		: "i" (CACHE_MODE | CACR_ICINVA | CACR_BCINVA | CACR_DCINVA)
+		: "d0");
+}
+
+/*
+ * Use the ColdFire cpushl instruction to push (and invalidate) cache lines.
+ * The start and end addresses are cache line numbers not memory addresses.
+ */
 static inline void flush_cf_icache(unsigned long start, unsigned long end)
 {
 	unsigned long set;
arch/m68k/mm/memory.c +1 -1
index 250b8b7..51bc9d2 100644
@@ -203,7 +203,7 @@ static inline void pushcl040(unsigned long paddr)
 void cache_clear (unsigned long paddr, int len)
 {
     if (CPU_IS_COLDFIRE) {
-	flush_cf_bcache(0, DCACHE_MAX_ADDR);
+	clear_cf_bcache(0, DCACHE_MAX_ADDR);
     } else if (CPU_IS_040_OR_060) {
 	int tmp;
 
Signature · 1 line
1.7.0.4
#1 lore raw

arch/m68k/include/asm/cacheflush_mm.h line 31

Quoted 8 lines · <[email protected]> writes:
arch/m68k/include/asm/cacheflush_mm.h +8 -0
+static inline void clear_cf_icache(unsigned long start, unsigned long end)
+{
+	__asm__ __volatile__ (
+		"movel	%0,%%d0\n\t"
+		"movec	%%d0,%%cacr\n\t"
+		"nop\n\t"
+		:
+		: "i" (CACHE_MODE | CACR_ICINVA | CACR_BCINVA)

Why not "r"?

Andreas.

Signature · 3 lines
Andreas Schwab, [email protected]
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."
#2 lore raw

Hi Andreas,

Quoted 12 lines · Andreas Schwab

arch/m68k/include/asm/cacheflush_mm.h line 31

Quoted 8 lines · <[email protected]> writes:
arch/m68k/include/asm/cacheflush_mm.h +8 -0
+static inline void clear_cf_icache(unsigned long start, unsigned long end)
+{
+	__asm__ __volatile__ (
+		"movel	%0,%%d0\n\t"
+		"movec	%%d0,%%cacr\n\t"
+		"nop\n\t"
+		:
+		: "i" (CACHE_MODE | CACR_ICINVA | CACR_BCINVA)

Why not "r"?

Yes, that is better. I will revise and repost.

Thanks
Greg

------------------------------------------------------------------------

Greg Ungerer  --  Principal Engineer        EMAIL:     [email protected]
SnapGear Group, McAfee                      PHONE:       +61 7 3435 2888
8 Gardner Close,                            FAX:         +61 7 3891 3630
Milton, QLD, 4064, Australia                WEB: http://www.SnapGear.com