Skip to contentSkip to conversation

m68k: Implement a default flush_dcache_all

PATCH In review Tom Rini 4 participants 16 messages Jun 19, 2024 – Sep 10, 2024

Subsystems (4)
lore
Share & tools
lore

Tom Rini

author
#0 lore raw

PATCH 1/7 m68k: Implement a default flush_dcache_all

Implement a weak default version of flush_dcache_all which is based on the ARM default, which is to flush the entire range via flush_dcache_range(...).

---
Cc: Huan Wang <[email protected]>
Cc: Angelo Dureghello <[email protected]>

---
 arch/m68k/lib/cache.c | 9 +++++++++
 1 file changed, 9 insertions(+)
arch/m68k/lib/cache.c +9 -0
index de04124404cf..dab834c1cbd8 100644
@@ -134,6 +134,15 @@ void dcache_invalid(void)
 #endif
 }
 
+/*
+ * Default implementation:
+ * do a range flush for the entire range
+ */
+__weak void flush_dcache_all(void)
+{
+	flush_dcache_range(0, ~0);
+}
+
 __weak void invalidate_dcache_range(unsigned long start, unsigned long stop)
 {
 	/* An empty stub, real implementation should be in platform code */
Signature · 1 line
2.34.1
author
#1 lore raw

PATCH 2/7 m68k: Rename icache_invalid to invalidate_icache_all

The implementation of icache_invalid appears to be doing what other architectures call invalidate_icache_all so rename to match.

---
Huan Wang <[email protected]>
Angelo Dureghello <[email protected]>

---
 arch/m68k/include/asm/cache.h | 1 -
 arch/m68k/lib/cache.c         | 6 +++---
 drivers/net/mcffec.c          | 5 +++--
 3 files changed, 6 insertions(+), 6 deletions(-)
arch/m68k/include/asm/cache.h +0 -1
index 6ef7f7be1af8..aa8d2edb40ba 100644
@@ -185,7 +185,6 @@
 
 #ifndef __ASSEMBLY__		/* put C only stuff in this section */
 
-void icache_invalid(void);
 void dcache_invalid(void);
 
 #endif
arch/m68k/lib/cache.c +3 -3
index dab834c1cbd8..370ad40f1423 100644
@@ -29,7 +29,7 @@ int dcache_status(void)
 
 void icache_enable(void)
 {
-	icache_invalid();
+	invalidate_icache_all();
 
 	*cf_icache_status = 1;
 
@@ -53,7 +53,7 @@ void icache_disable(void)
 	u32 temp = 0;
 
 	*cf_icache_status = 0;
-	icache_invalid();
+	invalidate_icache_all();
 
 #if defined(CONFIG_CF_V4) || defined(CFG_CF_V4E)
 	__asm__ __volatile__("movec %0, %%acr2"::"r"(temp));
@@ -68,7 +68,7 @@ void icache_disable(void)
 #endif
 }
 
-void icache_invalid(void)
+void invalidate_icache_all(void)
 {
 	u32 temp;
 
drivers/net/mcffec.c +3 -2
index 04b711e4f650..7e53492733ed 100644
@@ -11,6 +11,7 @@
  */
 
 #include <config.h>
+#include <cpu_func.h>
 #include <env.h>
 #include <hang.h>
 #include <malloc.h>
@@ -399,7 +400,7 @@ static int mcffec_send(struct udevice *dev, void *packet, int length)
 #endif
 
 #ifdef CONFIG_SYS_UNIFY_CACHE
-	icache_invalid();
+	invalidate_icache_all();
 #endif
 
 	j = 0;
@@ -433,7 +434,7 @@ static int mcffec_recv(struct udevice *dev, int flags, uchar **packetp)
 
 	for (;;) {
 #ifdef CONFIG_SYS_UNIFY_CACHE
-		icache_invalid();
+		invalidate_icache_all();
 #endif
 		/* If nothing received - leave for() loop */
 		if (info->rxbd[info->rx_idx].cbd_sc & BD_ENET_RX_EMPTY)
Signature · 1 line
2.34.1
Reviewed-by on v1 2/7
#2 lore raw

Re: [PATCH 2/7] m68k: Rename icache_invalid to invalidate_icache_all

Quoted 88 lines · Tom Rini

The implementation of icache_invalid appears to be doing what other architectures call invalidate_icache_all so rename to match.

---
Huan Wang <[email protected]>
Angelo Dureghello <[email protected]>

---
 arch/m68k/include/asm/cache.h | 1 -
 arch/m68k/lib/cache.c         | 6 +++---
 drivers/net/mcffec.c          | 5 +++--
 3 files changed, 6 insertions(+), 6 deletions(-)
arch/m68k/include/asm/cache.h +0 -1
index 6ef7f7be1af8..aa8d2edb40ba 100644
@@ -185,7 +185,6 @@
 
 #ifndef __ASSEMBLY__           /* put C only stuff in this section */
 
-void icache_invalid(void);
 void dcache_invalid(void);
 
 #endif
arch/m68k/lib/cache.c +3 -3
index dab834c1cbd8..370ad40f1423 100644
@@ -29,7 +29,7 @@ int dcache_status(void)
 
 void icache_enable(void)
 {
-       icache_invalid();
+       invalidate_icache_all();
 
        *cf_icache_status = 1;
 
@@ -53,7 +53,7 @@ void icache_disable(void)
        u32 temp = 0;
 
        *cf_icache_status = 0;
-       icache_invalid();
+       invalidate_icache_all();
 
 #if defined(CONFIG_CF_V4) || defined(CFG_CF_V4E)
        __asm__ __volatile__("movec %0, %%acr2"::"r"(temp));
@@ -68,7 +68,7 @@ void icache_disable(void)
 #endif
 }
 
-void icache_invalid(void)
+void invalidate_icache_all(void)
 {
        u32 temp;
 
drivers/net/mcffec.c +3 -3
index 04b711e4f650..7e53492733ed 100644
@@ -11,6 +11,7 @@
  */
 
 #include <config.h>
+#include <cpu_func.h>
 #include <env.h>
 #include <hang.h>
 #include <malloc.h>
@@ -399,7 +400,7 @@ static int mcffec_send(struct udevice *dev, void *packet, int length)
 #endif
 
 #ifdef CONFIG_SYS_UNIFY_CACHE
-       icache_invalid();
+       invalidate_icache_all();
 #endif
 
        j = 0;
@@ -433,7 +434,7 @@ static int mcffec_recv(struct udevice *dev, int flags, uchar **packetp)
 
        for (;;) {
 #ifdef CONFIG_SYS_UNIFY_CACHE
-               icache_invalid();
+               invalidate_icache_all();
 #endif
                /* If nothing received - leave for() loop */
                if (info->rxbd[info->rx_idx].cbd_sc & BD_ENET_RX_EMPTY)
--
Quoted 2 lines

2.34.1

author
#3 lore raw

PATCH 3/7 sh: Implement a default flush_dcache_all

In reply to Tom Rini

Implement a weak default version of flush_dcache_all which is based on the ARM default, which is to flush the entire range via flush_dcache_range(...).

---
Cc: Marek Vasut <[email protected]>
Cc: Nobuhiro Iwamatsu <[email protected]>

---
 arch/sh/cpu/sh4/cache.c | 9 +++++++++
 1 file changed, 9 insertions(+)
arch/sh/cpu/sh4/cache.c +9 -0
index 8c1839935ca1..f0cb39d6a923 100644
@@ -65,6 +65,15 @@ void flush_dcache_range(unsigned long start, unsigned long end)
 	}
 }
 
+/*
+ * Default implementation:
+ * do a range flush for the entire range
+ */
+void flush_dcache_all(void)
+{
+	flush_dcache_range(0, ~0);
+}
+
 void invalidate_dcache_range(unsigned long start, unsigned long end)
 {
 	u32 v;
Signature · 1 line
2.34.1
Acked-by on v1 3/7
#4 lore raw

Re: [PATCH 3/7] sh: Implement a default flush_dcache_all

Quoted 34 lines · Tom Rini

Implement a weak default version of flush_dcache_all which is based on the ARM default, which is to flush the entire range via flush_dcache_range(...).

---
Cc: Marek Vasut <[email protected]>
Cc: Nobuhiro Iwamatsu <[email protected]>

---
 arch/sh/cpu/sh4/cache.c | 9 +++++++++
 1 file changed, 9 insertions(+)
arch/sh/cpu/sh4/cache.c +9 -1
index 8c1839935ca1..f0cb39d6a923 100644
@@ -65,6 +65,15 @@ void flush_dcache_range(unsigned long start, unsigned long end)
        }
 }
 
+/*
+ * Default implementation:
+ * do a range flush for the entire range
+ */
+void flush_dcache_all(void)
+{
+       flush_dcache_range(0, ~0);
+}
+
 void invalidate_dcache_range(unsigned long start, unsigned long end)
 {
        u32 v;
--
Quoted 2 lines

2.34.1

#5 lore raw

Re: [PATCH 3/7] sh: Implement a default flush_dcache_all

In reply to Tom Rini
Quoted 18 lines · Tom Rini

Implement a weak default version of flush_dcache_all which is based on the ARM default, which is to flush the entire range via flush_dcache_range(...).

---
Cc: Marek Vasut <[email protected]>
Cc: Nobuhiro Iwamatsu <[email protected]>

---
  arch/sh/cpu/sh4/cache.c | 9 +++++++++
  1 file changed, 9 insertions(+)
arch/sh/cpu/sh4/cache.c +0 -0
index 8c1839935ca1..f0cb39d6a923 100644
@@ -65,6 +65,15 @@ void flush_dcache_range(unsigned long start, unsigned long end)
  	}

arch/sh/cpu/sh4/cache.c void flush_dcache_range(unsigned long start, unsigned long end) · line 75

Quoted 10 lines
arch/sh/cpu/sh4/cache.c +8 -0
  }
 
+/*
+ * Default implementation:
+ * do a range flush for the entire range
+ */
+void flush_dcache_all(void)
+{
+	flush_dcache_range(0, ~0);
+}

The current implementation that is in tree should be fine, thanks.

author
#6 lore raw

PATCH 4/7 sh: Add the old invalidate_icache_all function

In reply to Tom Rini

Add the old invalidate_icache_all function that prints a warning that was previously found in cmd/cache.c

---
Cc: Marek Vasut <[email protected]>
Cc: Nobuhiro Iwamatsu <[email protected]>

---
 arch/sh/cpu/sh4/cache.c | 6 ++++++
 1 file changed, 6 insertions(+)
arch/sh/cpu/sh4/cache.c +6 -0
index f0cb39d6a923..d3c480e79ed2 100644
@@ -6,6 +6,7 @@
 
 #include <command.h>
 #include <cpu_func.h>
+#include <stdio.h>
 #include <asm/cache.h>
 #include <asm/io.h>
 #include <asm/processor.h>
@@ -100,6 +101,11 @@ void icache_disable(void)
 	cache_control(CACHE_DISABLE);
 }
 
+void invalidate_icache_all(void)
+{
+	puts("No arch specific invalidate_icache_all available!\n");
+}
+
 int icache_status(void)
 {
 	return 0;
Signature · 1 line
2.34.1
#7 lore raw

Re: [PATCH 4/7] sh: Add the old invalidate_icache_all function

Quoted 25 lines · Tom Rini

Add the old invalidate_icache_all function that prints a warning that was previously found in cmd/cache.c

---
Cc: Marek Vasut <[email protected]>
Cc: Nobuhiro Iwamatsu <[email protected]>

---
  arch/sh/cpu/sh4/cache.c | 6 ++++++
  1 file changed, 6 insertions(+)
arch/sh/cpu/sh4/cache.c +1 -0
index f0cb39d6a923..d3c480e79ed2 100644
@@ -6,6 +6,7 @@
 
  #include <command.h>
  #include <cpu_func.h>
+#include <stdio.h>
  #include <asm/cache.h>
  #include <asm/io.h>
  #include <asm/processor.h>
@@ -100,6 +101,11 @@ void icache_disable(void)
  	cache_control(CACHE_DISABLE);

arch/sh/cpu/sh4/cache.c void icache_disable(void) · line 111

Quoted 10 lines
arch/sh/cpu/sh4/cache.c +5 -0
  }
 
+void invalidate_icache_all(void)
+{
+	puts("No arch specific invalidate_icache_all available!\n");
+}
+
  int icache_status(void)
  {
  	return 0;

I just posted

sh: cache: Fill in invalidate_icache_all()

author
#8 lore raw

PATCH 5/7 powerpc: Implement a default flush_dcache_all

In reply to Tom Rini

Implement a weak default version of flush_dcache_all which is based on the ARM default, which is to flush the entire range via flush_dcache_range(...).

---
 arch/powerpc/lib/cache.c | 9 +++++++++
 1 file changed, 9 insertions(+)
arch/powerpc/lib/cache.c +9 -0
index e480b2696494..130318d745aa 100644
@@ -43,3 +43,12 @@ void flush_cache(ulong start_addr, ulong size)
 	/* flush prefetch queue */
 	asm volatile("isync" : : : "memory");
 }
+
+/*
+ * Default implementation:
+ * do a range flush for the entire range
+ */
+void flush_dcache_all(void)
+{
+	flush_dcache_range(0, ~0);
+}
Signature · 1 line
2.34.1
Acked-by on v1 5/7
#9 lore raw

Re: [PATCH 5/7] powerpc: Implement a default flush_dcache_all

Quoted 28 lines · Tom Rini

Implement a weak default version of flush_dcache_all which is based on the ARM default, which is to flush the entire range via flush_dcache_range(...).

---
 arch/powerpc/lib/cache.c | 9 +++++++++
 1 file changed, 9 insertions(+)
arch/powerpc/lib/cache.c +9 -1
index e480b2696494..130318d745aa 100644
@@ -43,3 +43,12 @@ void flush_cache(ulong start_addr, ulong size)
        /* flush prefetch queue */
        asm volatile("isync" : : : "memory");
 }
+
+/*
+ * Default implementation:
+ * do a range flush for the entire range
+ */
+void flush_dcache_all(void)
+{
+       flush_dcache_range(0, ~0);
+}
--
Quoted 2 lines

2.34.1

author
#10 lore raw

PATCH 6/7 powerpc: Add the old invalidate_icache_all function

In reply to Tom Rini

Add the old invalidate_icache_all function that prints a warning that was previously found in cmd/cache.c

---
 arch/powerpc/lib/cache.c | 6 ++++++
 1 file changed, 6 insertions(+)
arch/powerpc/lib/cache.c +6 -0
index 130318d745aa..a9cd7b8d30ac 100644
@@ -5,6 +5,7 @@
  */
 
 #include <cpu_func.h>
+#include <stdio.h>
 #include <asm/cache.h>
 #include <watchdog.h>
 
@@ -52,3 +53,8 @@ void flush_dcache_all(void)
 {
 	flush_dcache_range(0, ~0);
 }
+
+void invalidate_icache_all(void)
+{
+	puts("No arch specific invalidate_icache_all available!\n");
+}
Signature · 1 line
2.34.1
author
#11 lore raw

PATCH 7/7 cmd: cache: Remove weak functions

In reply to Tom Rini

It should be up to an architecture to decide how to implement cache functions, and if they need to use weak functions or not. Allowing the cache command to be built without cache functionality implemented is unhelpful. Further, guard the call to noncached_set_region with CONFIG_SYS_NONCACHED_MEMORY as that's when it's implemented and again is an architecture specific detail.

---
This patch series is intended to replace
https://patchwork.ozlabs.org/project/uboot/patch/[email protected]/

---
 cmd/cache.c | 18 ++----------------
 1 file changed, 2 insertions(+), 16 deletions(-)
cmd/cache.c +2 -16
index 0254ff17f9b2..7a2068296ef1 100644
@@ -13,16 +13,6 @@
 
 static int parse_argv(const char *);
 
-void __weak invalidate_icache_all(void)
-{
-	/* please define arch specific invalidate_icache_all */
-	puts("No arch specific invalidate_icache_all available!\n");
-}
-
-__weak void noncached_set_region(void)
-{
-}
-
 static int do_icache(struct cmd_tbl *cmdtp, int flag, int argc,
 		     char *const argv[])
 {
@@ -52,12 +42,6 @@ static int do_icache(struct cmd_tbl *cmdtp, int flag, int argc,
 	return 0;
 }
 
-void __weak flush_dcache_all(void)
-{
-	puts("No arch specific flush_dcache_all available!\n");
-	/* please define arch specific flush_dcache_all */
-}
-
 static int do_dcache(struct cmd_tbl *cmdtp, int flag, int argc,
 		     char *const argv[])
 {
@@ -69,7 +53,9 @@ static int do_dcache(struct cmd_tbl *cmdtp, int flag, int argc,
 			break;
 		case 1:
 			dcache_enable();
+#ifdef CONFIG_SYS_NONCACHED_MEMORY
 			noncached_set_region();
+#endif
 			break;
 		case 2:
 			flush_dcache_all();
Signature · 1 line
2.34.1
Reviewed-by on v1 7/7
#12 lore raw

Re: [PATCH 7/7] cmd: cache: Remove weak functions

Quoted 61 lines · Tom Rini

It should be up to an architecture to decide how to implement cache functions, and if they need to use weak functions or not. Allowing the cache command to be built without cache functionality implemented is unhelpful. Further, guard the call to noncached_set_region with CONFIG_SYS_NONCACHED_MEMORY as that's when it's implemented and again is an architecture specific detail.

---
This patch series is intended to replace
https://patchwork.ozlabs.org/project/uboot/patch/[email protected]/

---
 cmd/cache.c | 18 ++----------------
 1 file changed, 2 insertions(+), 16 deletions(-)
cmd/cache.c +2 -17
index 0254ff17f9b2..7a2068296ef1 100644
@@ -13,16 +13,6 @@
 
 static int parse_argv(const char *);
 
-void __weak invalidate_icache_all(void)
-{
-       /* please define arch specific invalidate_icache_all */
-       puts("No arch specific invalidate_icache_all available!\n");
-}
-
-__weak void noncached_set_region(void)
-{
-}
-
 static int do_icache(struct cmd_tbl *cmdtp, int flag, int argc,
                     char *const argv[])
 {
@@ -52,12 +42,6 @@ static int do_icache(struct cmd_tbl *cmdtp, int flag, int argc,
        return 0;
 }
 
-void __weak flush_dcache_all(void)
-{
-       puts("No arch specific flush_dcache_all available!\n");
-       /* please define arch specific flush_dcache_all */
-}
-
 static int do_dcache(struct cmd_tbl *cmdtp, int flag, int argc,
                     char *const argv[])
 {
@@ -69,7 +53,9 @@ static int do_dcache(struct cmd_tbl *cmdtp, int flag, int argc,
                        break;
                case 1:
                        dcache_enable();
+#ifdef CONFIG_SYS_NONCACHED_MEMORY
                        noncached_set_region();
+#endif
                        break;
                case 2:
                        flush_dcache_all();
--
Quoted 2 lines

2.34.1

Acked-by on v1 1/7
#13 lore raw

Acked

In reply to Tom Rini

Hi Tom,

thanks,
angelo

Quoted 32 lines · Tom Rini

Implement a weak default version of flush_dcache_all which is based on the ARM default, which is to flush the entire range via flush_dcache_range(...).

---
Cc: Huan Wang <[email protected]>
Cc: Angelo Dureghello <[email protected]>

---
  arch/m68k/lib/cache.c | 9 +++++++++
  1 file changed, 9 insertions(+)
arch/m68k/lib/cache.c +9 -0
index de04124404cf..dab834c1cbd8 100644
@@ -134,6 +134,15 @@ void dcache_invalid(void)
  #endif
  }
 
+/*
+ * Default implementation:
+ * do a range flush for the entire range
+ */
+__weak void flush_dcache_all(void)
+{
+	flush_dcache_range(0, ~0);
+}
+
  __weak void invalidate_dcache_range(unsigned long start, unsigned long stop)
  {
  	/* An empty stub, real implementation should be in platform code */
Acked-by on v1 1/7
#14 lore raw
In reply to Tom Rini
Quoted 34 lines · Tom Rini

Implement a weak default version of flush_dcache_all which is based on the ARM default, which is to flush the entire range via flush_dcache_range(...).

---
Cc: Huan Wang <[email protected]>
Cc: Angelo Dureghello <[email protected]>

---
 arch/m68k/lib/cache.c | 9 +++++++++
 1 file changed, 9 insertions(+)
arch/m68k/lib/cache.c +9 -1
index de04124404cf..dab834c1cbd8 100644
@@ -134,6 +134,15 @@ void dcache_invalid(void)
 #endif
 }
 
+/*
+ * Default implementation:
+ * do a range flush for the entire range
+ */
+__weak void flush_dcache_all(void)
+{
+       flush_dcache_range(0, ~0);
+}
+
 __weak void invalidate_dcache_range(unsigned long start, unsigned long stop)
 {
        /* An empty stub, real implementation should be in platform code */
--
Quoted 2 lines

2.34.1

author
#15 lore raw
In reply to Tom Rini
Quoted 5 lines · Tom Rini

Implement a weak default version of flush_dcache_all which is based on the ARM default, which is to flush the entire range via flush_dcache_range(...).

Applied to u-boot/master, thanks!

Signature · 1 line
Tom