Skip to contentSkip to conversation

mem: add flush callback to sync caches for execution

PATCH Applied Ahmad Fatoum 2 participants 3 messages Apr 13 – Apr 14 Char and misc drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mem: add flush callback to sync caches for execution

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

---
 drivers/misc/mem.c | 8 ++++++++
 1 file changed, 8 insertions(+)
drivers/misc/mem.c +8 -0
index 0cf021cf97ba..b356c6eab389 100644
@@ -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)
Signature · 1 line
2.47.3
Applied
#1 lore raw
Quoted 8 lines · Ahmad Fatoum

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

[...]

Applied, thanks!

[1/1] mem: add flush callback to sync caches for execution
https://git.pengutronix.de/cgit/barebox/commit/?id=4f0cf6a66d84 (link may not be stable)

Best regards,

Signature · 1 line
Sascha Hauer <[email protected]>
#2 lore raw
In reply to Ahmad Fatoum
Quoted 11 lines · Ahmad Fatoum

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

---
 drivers/misc/mem.c | 8 ++++++++
 1 file changed, 8 insertions(+)

Reverted this one. It breaks compilation on riscv:

In file included from drivers/misc/mem.c:9:
arch/riscv/include/asm/cache.h: In function 'local_flush_icache_all':
arch/riscv/include/asm/cache.h:25:9: error: implicit declaration of function 'riscv_vendor_id' [-Werror=implicit-function-declaration]
25 | switch(riscv_vendor_id()) {

And PowerPC:

powerpc-603e-linux-gnu-ld: drivers/misc/mem.o: in function `mem_flush':
drivers/misc/mem.c:13:(.text.mem_flush+0xc): undefined reference to `sync_caches_for_execution' make[1]: *** [Makefile:1099: barebox] Error 1

Sascha

Signature · 4 lines
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |