summaryrefslogtreecommitdiffstats
path: root/arch/kvx
diff options
context:
space:
mode:
authorYann Sionneau <ysionneau@kalray.eu>2021-03-05 19:33:24 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2021-03-17 11:55:30 +0100
commitb329e641e71f438bfd338b20c30b0c810b671225 (patch)
tree48e7d58f971e175fc3fc6414ad10acead008e9c2 /arch/kvx
parented120cf6c2d92ffaeb2a75e5205ec68cd28123b5 (diff)
downloadbarebox-b329e641e71f438bfd338b20c30b0c810b671225.tar.gz
barebox-b329e641e71f438bfd338b20c30b0c810b671225.tar.xz
kvx: Implement dcache invalidation primitive
Signed-off-by: Jules Maselbas <jmaselbas@kalray.eu> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'arch/kvx')
-rw-r--r--arch/kvx/Kconfig1
-rw-r--r--arch/kvx/include/asm/cache.h13
-rw-r--r--arch/kvx/lib/Makefile2
-rw-r--r--arch/kvx/lib/cache.c25
4 files changed, 40 insertions, 1 deletions
diff --git a/arch/kvx/Kconfig b/arch/kvx/Kconfig
index 8483ae6e65..4e02613ec7 100644
--- a/arch/kvx/Kconfig
+++ b/arch/kvx/Kconfig
@@ -12,6 +12,7 @@ config KVX
select FLEXIBLE_BOOTARGS
select GENERIC_FIND_NEXT_BIT
select HAS_ARCH_SJLJ
+ select HAS_CACHE
select LIBFDT
select MFD_SYSCON
select OF_BAREBOX_DRIVERS
diff --git a/arch/kvx/include/asm/cache.h b/arch/kvx/include/asm/cache.h
index 3be1767250..0bf3c8f06e 100644
--- a/arch/kvx/include/asm/cache.h
+++ b/arch/kvx/include/asm/cache.h
@@ -8,6 +8,8 @@
#include <linux/types.h>
+void invalidate_dcache_range(unsigned long addr, unsigned long stop);
+
static inline void sync_caches_for_execution(void)
{
__builtin_kvx_fence();
@@ -15,4 +17,15 @@ static inline void sync_caches_for_execution(void)
__builtin_kvx_barrier();
}
+static inline void sync_dcache_icache(void)
+{
+ sync_caches_for_execution();
+}
+
+static inline void dcache_inval(void)
+{
+ __builtin_kvx_fence();
+ __builtin_kvx_dinval();
+}
+
#endif /* __KVX_CACHE_H */
diff --git a/arch/kvx/lib/Makefile b/arch/kvx/lib/Makefile
index cee08b0fa7..d271ebccfa 100644
--- a/arch/kvx/lib/Makefile
+++ b/arch/kvx/lib/Makefile
@@ -3,4 +3,4 @@
# Copyright (C) 2019 Kalray Inc.
#
-obj-y += cpuinfo.o board.o dtb.o poweroff.o bootm.o setjmp.o
+obj-y += cpuinfo.o board.o dtb.o poweroff.o bootm.o setjmp.o cache.o
diff --git a/arch/kvx/lib/cache.c b/arch/kvx/lib/cache.c
new file mode 100644
index 0000000000..bd074de79b
--- /dev/null
+++ b/arch/kvx/lib/cache.c
@@ -0,0 +1,25 @@
+// SPDX-License-Identifier: GPL-2.0-only
+// SPDX-FileCopyrightText: 2021 Yann Sionneau <ysionneau@kalray.eu>, Kalray Inc.
+
+#include <asm/cache.h>
+#include <linux/kernel.h>
+
+#define KVX_DCACHE_LINE_SIZE (64)
+#define KVX_DCACHE_SIZE (128*1024)
+
+void invalidate_dcache_range(unsigned long addr, unsigned long stop)
+{
+ long size;
+
+ addr = ALIGN_DOWN(addr, KVX_DCACHE_LINE_SIZE);
+ size = stop - addr;
+
+ if (size < KVX_DCACHE_SIZE) {
+ while (addr < stop) {
+ __builtin_kvx_dinvall((void *)addr);
+ addr += KVX_DCACHE_LINE_SIZE;
+ }
+ } else {
+ __builtin_kvx_dinval();
+ }
+}