[PATCH v2 3/3] mem: add flush callback to sync caches for execution

Ahmad Fatoum a.fatoum at pengutronix.de
Tue Apr 14 01:06:30 PDT 2026


From: Ahmad Fatoum <a.fatoum at 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 at 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




More information about the barebox mailing list