[PATCH 3/4] kvx: add D-cache inval and I-cache sync

Clement Leger cleger at kalray.eu
Tue Jun 23 15:35:05 EDT 2020


Before booting, we must make sure the I-cache is synchronized with the
D-cache to execute loaded instructions. In order to do that, add a
function which execute a fence to ensure every memory accesses have
been committed out of processor pipeline to memory and then invalidate
I-cache to reload from memory. Moreover add a D-cache invalidation
routine to cleanup cache before booting.

Signed-off-by: Clement Leger <cleger at kalray.eu>
---
 arch/kvx/include/asm/cache.h | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)
 create mode 100644 arch/kvx/include/asm/cache.h

diff --git a/arch/kvx/include/asm/cache.h b/arch/kvx/include/asm/cache.h
new file mode 100644
index 000000000..efda37ebd
--- /dev/null
+++ b/arch/kvx/include/asm/cache.h
@@ -0,0 +1,24 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+/*
+ * Copyright (C) 2019 Kalray Inc.
+ */
+
+#ifndef __KVX_CACHE_H
+#define __KVX_CACHE_H
+
+#include <linux/types.h>
+
+static inline void sync_dcache_icache(void)
+{
+	__builtin_kvx_fence();
+	__builtin_kvx_iinval();
+	__builtin_kvx_barrier();
+}
+
+static inline void dcache_inval(void)
+{
+	__builtin_kvx_fence();
+	__builtin_kvx_dinval();
+}
+
+#endif /* __KVX_CACHE_H */
-- 
2.17.1




More information about the barebox mailing list