mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH v2 1/3] ppc: define sync_caches_for_execution only for MPC85xx
@ 2026-04-14  8:06 Ahmad Fatoum
  2026-04-14  8:06 ` [PATCH v2 2/3] riscv: make header self-contained Ahmad Fatoum
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Ahmad Fatoum @ 2026-04-14  8:06 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

From: Ahmad Fatoum <a.fatoum@barebox.org>

In preparation for adding a call to sync_caches_for_execution() into
common code, make sure PowerPC configurations without an out-of-line
definition fallback to the inline no-op definition.

Signed-off-by: Ahmad Fatoum <a.fatoum@barebox.org>
---
v1 -> v2:
  - new commit to fix CI breakage (Sascha)
---
 arch/powerpc/include/asm/cache.h | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/arch/powerpc/include/asm/cache.h b/arch/powerpc/include/asm/cache.h
index 2edf11de2ef8..29746fd1945f 100644
--- a/arch/powerpc/include/asm/cache.h
+++ b/arch/powerpc/include/asm/cache.h
@@ -35,8 +35,10 @@ extern void clean_dcache_range(unsigned long start, unsigned long stop);
 extern void invalidate_dcache_range(unsigned long start, unsigned long stop);
 extern void flush_dcache(void);
 extern void invalidate_icache(void);
+#ifdef CONFIG_ARCH_MPC85XX
 #define sync_caches_for_execution sync_caches_for_execution
 extern void sync_caches_for_execution(void);
+#endif
 #ifdef CFG_INIT_RAM_LOCK
 extern void unlock_ram_in_cache(void);
 #endif /* CFG_INIT_RAM_LOCK */
@@ -88,4 +90,6 @@ extern void unlock_ram_in_cache(void);
 #define DC_LES		0x20000000	/* Caches are little endian mode */
 #endif /* CONFIG_8xx */
 
+#include <asm-generic/cache.h>
+
 #endif
-- 
2.47.3




^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH v2 2/3] riscv: make header self-contained
  2026-04-14  8:06 [PATCH v2 1/3] ppc: define sync_caches_for_execution only for MPC85xx Ahmad Fatoum
@ 2026-04-14  8:06 ` Ahmad Fatoum
  2026-04-14  8:06 ` [PATCH v2 3/3] mem: add flush callback to sync caches for execution Ahmad Fatoum
  2026-04-15  6:30 ` [PATCH v2 1/3] ppc: define sync_caches_for_execution only for MPC85xx Sascha Hauer
  2 siblings, 0 replies; 4+ messages in thread
From: Ahmad Fatoum @ 2026-04-14  8:06 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

From: Ahmad Fatoum <a.fatoum@barebox.org>

In preparation for adding a call to sync_caches_for_execution() into
common code, make sure inclusion of asm/cache.h on RISC-V doesn't
require any extra headers to be included beforehand.

Signed-off-by: Ahmad Fatoum <a.fatoum@barebox.org>
---
v1 -> v2:
  - new commit to fix CI breakage (Sascha)
---
 arch/riscv/include/asm/cache.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/riscv/include/asm/cache.h b/arch/riscv/include/asm/cache.h
index 8c3cde669c30..55a34354c526 100644
--- a/arch/riscv/include/asm/cache.h
+++ b/arch/riscv/include/asm/cache.h
@@ -6,6 +6,7 @@
 #ifndef _ASM_RISCV_CACHE_H
 #define _ASM_RISCV_CACHE_H
 
+#include <asm/system.h>
 #include <asm/vendorid_list.h>
 
 static inline void thead_local_flush_icache_all(void)
-- 
2.47.3




^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH v2 3/3] mem: add flush callback to sync caches for execution
  2026-04-14  8:06 [PATCH v2 1/3] ppc: define sync_caches_for_execution only for MPC85xx Ahmad Fatoum
  2026-04-14  8:06 ` [PATCH v2 2/3] riscv: make header self-contained Ahmad Fatoum
@ 2026-04-14  8:06 ` Ahmad Fatoum
  2026-04-15  6:30 ` [PATCH v2 1/3] ppc: define sync_caches_for_execution only for MPC85xx Sascha Hauer
  2 siblings, 0 replies; 4+ messages in thread
From: Ahmad Fatoum @ 2026-04-14  8:06 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

From: Ahmad Fatoum <a.fatoum@barebox.org>

barebox always calls sync_caches_for_execution() on boot, but it can be
useful to trigger it manually when testing:

- memcpy -s /dev/zero -d /dev/mem 0 $TFA_REGION_BASE $TFA_REGION_SIZE
- sync /dev/mem # flush D$ and invalidate I$
- smc -i        # check if PSCI monitor is still usable

Signed-off-by: Ahmad Fatoum <a.fatoum@barebox.org>
---
v1 -> v2:
  - no change
---
 drivers/misc/mem.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/drivers/misc/mem.c b/drivers/misc/mem.c
index 0cf021cf97ba..b356c6eab389 100644
--- a/drivers/misc/mem.c
+++ b/drivers/misc/mem.c
@@ -6,11 +6,19 @@
 #include <common.h>
 #include <driver.h>
 #include <init.h>
+#include <asm/cache.h>
+
+static int mem_flush(struct cdev *cdev)
+{
+	sync_caches_for_execution();
+	return 0;
+}
 
 static struct cdev_operations memops = {
 	.read  = mem_read,
 	.write = mem_write,
 	.memmap = generic_memmap_rw,
+	.flush = mem_flush,
 };
 
 static int mem_probe(struct device *dev)
-- 
2.47.3




^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2 1/3] ppc: define sync_caches_for_execution only for MPC85xx
  2026-04-14  8:06 [PATCH v2 1/3] ppc: define sync_caches_for_execution only for MPC85xx Ahmad Fatoum
  2026-04-14  8:06 ` [PATCH v2 2/3] riscv: make header self-contained Ahmad Fatoum
  2026-04-14  8:06 ` [PATCH v2 3/3] mem: add flush callback to sync caches for execution Ahmad Fatoum
@ 2026-04-15  6:30 ` Sascha Hauer
  2 siblings, 0 replies; 4+ messages in thread
From: Sascha Hauer @ 2026-04-15  6:30 UTC (permalink / raw)
  To: barebox, Ahmad Fatoum; +Cc: Ahmad Fatoum


On Tue, 14 Apr 2026 10:06:28 +0200, Ahmad Fatoum wrote:
> In preparation for adding a call to sync_caches_for_execution() into
> common code, make sure PowerPC configurations without an out-of-line
> definition fallback to the inline no-op definition.
> 
> 

Applied, thanks!

[1/3] ppc: define sync_caches_for_execution only for MPC85xx
      https://git.pengutronix.de/cgit/barebox/commit/?id=586caca9efd2 (link may not be stable)
[2/3] riscv: make header self-contained
      https://git.pengutronix.de/cgit/barebox/commit/?id=54449e5c2c1e (link may not be stable)
[3/3] mem: add flush callback to sync caches for execution
      https://git.pengutronix.de/cgit/barebox/commit/?id=eca53ad82a74 (link may not be stable)

Best regards,
-- 
Sascha Hauer <s.hauer@pengutronix.de>




^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-04-15  6:31 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-04-14  8:06 [PATCH v2 1/3] ppc: define sync_caches_for_execution only for MPC85xx Ahmad Fatoum
2026-04-14  8:06 ` [PATCH v2 2/3] riscv: make header self-contained Ahmad Fatoum
2026-04-14  8:06 ` [PATCH v2 3/3] mem: add flush callback to sync caches for execution Ahmad Fatoum
2026-04-15  6:30 ` [PATCH v2 1/3] ppc: define sync_caches_for_execution only for MPC85xx Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox