[PATCH 03/10] microblaze: cache: improve dcache Kconfig options

Ovidiu Panait ovpanait at gmail.com
Mon Apr 11 18:26:27 CEST 2022


Replace CONFIG_DCACHE with a Kconfig option more limited in scope -
XILINX_MICROBLAZE0_USE_WDC. It should be enabled if the processor supports
the "wdc" (Write to Data Cache) instruction. It will be used to guard
"wdc" invocations in microblaze cache code.

Also, drop all ifdefs around flush_cache() calls and only keep one
CONFIG_IS_ENABLED() guard within flush_cache() itself.

Signed-off-by: Ovidiu Panait <ovpanait at gmail.com>
---

 arch/microblaze/Kconfig                 |  4 ----
 arch/microblaze/cpu/cache.c             | 15 ++++++++++-----
 arch/microblaze/lib/bootm.c             |  2 --
 board/xilinx/microblaze-generic/Kconfig |  7 +++++++
 4 files changed, 17 insertions(+), 11 deletions(-)

diff --git a/arch/microblaze/Kconfig b/arch/microblaze/Kconfig
index d7d1b21970..5a2e91104f 100644
--- a/arch/microblaze/Kconfig
+++ b/arch/microblaze/Kconfig
@@ -25,10 +25,6 @@ config TARGET_MICROBLAZE_GENERIC
 
 endchoice
 
-config DCACHE
-	bool "Enable dcache support"
-	default y
-
 config ICACHE
 	bool "Enable icache support"
 	default y
diff --git a/arch/microblaze/cpu/cache.c b/arch/microblaze/cpu/cache.c
index b6126de194..4e8e228a22 100644
--- a/arch/microblaze/cpu/cache.c
+++ b/arch/microblaze/cpu/cache.c
@@ -49,26 +49,31 @@ void dcache_enable(void)
 
 void dcache_disable(void)
 {
-#ifdef CONFIG_DCACHE
 	flush_cache(0, XILINX_DCACHE_BYTE_SIZE);
-#endif
+
 	MSRCLR(0x80);
 }
 
 void flush_cache(ulong addr, ulong size)
 {
 	int i;
-	for (i = 0; i < size; i += 4)
+	for (i = 0; i < size; i += 4) {
 		asm volatile (
 #ifdef CONFIG_ICACHE
 				"wic	%0, r0;"
 #endif
 				"nop;"
-#ifdef CONFIG_DCACHE
+				:
+				: "r" (addr + i)
+				: "memory");
+
+		if (CONFIG_IS_ENABLED(XILINX_MICROBLAZE0_USE_WDC)) {
+			asm volatile (
 				"wdc.flush	%0, r0;"
-#endif
 				"nop;"
 				:
 				: "r" (addr + i)
 				: "memory");
+		}
+	}
 }
diff --git a/arch/microblaze/lib/bootm.c b/arch/microblaze/lib/bootm.c
index b652d2767a..dba6226ce5 100644
--- a/arch/microblaze/lib/bootm.c
+++ b/arch/microblaze/lib/bootm.c
@@ -57,9 +57,7 @@ static void boot_jump_linux(bootm_headers_t *images, int flag)
 	       "(fake run for tracing)" : "");
 	bootstage_mark_name(BOOTSTAGE_ID_BOOTM_HANDOFF, "start_kernel");
 
-#ifdef CONFIG_DCACHE
 	flush_cache(0, XILINX_DCACHE_BYTE_SIZE);
-#endif
 
 	if (!fake) {
 		/*
diff --git a/board/xilinx/microblaze-generic/Kconfig b/board/xilinx/microblaze-generic/Kconfig
index 117b476f3f..0d756ac7ba 100644
--- a/board/xilinx/microblaze-generic/Kconfig
+++ b/board/xilinx/microblaze-generic/Kconfig
@@ -63,4 +63,11 @@ config XILINX_MICROBLAZE0_VECTOR_BASE_ADDR
 	  Memory address location of the exception vector table. It is
 	  configurable via the C_BASE_VECTORS hdl parameter.
 
+config XILINX_MICROBLAZE0_USE_WDC
+	bool "MicroBlaze wdc instruction support"
+	default y
+	help
+	  Enable this option if the MicroBlaze processor is configured with
+	  support for the "wdc" (Write to Data Cache) instruction.
+
 endif
-- 
2.25.1



More information about the U-Boot mailing list