浏览代码

ARC: Implement a function to sync and cleanup caches

Implement specialized function to clenup caches (and therefore
sync instruction and data caches) which can be used for cleanup before linux
launch or to sync caches during U-Boot self-relocation.

Signed-off-by: Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>
Signed-off-by: Alexey Brodkin <abrodkin@synopsys.com>
Eugeniy Paltsev 7 年之前
父节点
当前提交
375945bac2
共有 4 个文件被更改,包括 29 次插入5 次删除
  1. 1 0
      arch/arc/include/asm/cache.h
  2. 2 2
      arch/arc/lib/bootm.c
  3. 23 0
      arch/arc/lib/cache.c
  4. 3 3
      arch/arc/lib/init_helpers.c

+ 1 - 0
arch/arc/include/asm/cache.h

@@ -31,6 +31,7 @@
 
 
 void cache_init(void);
 void cache_init(void);
 void flush_n_invalidate_dcache_all(void);
 void flush_n_invalidate_dcache_all(void);
+void sync_n_cleanup_cache_all(void);
 
 
 static const inline int is_ioc_enabled(void)
 static const inline int is_ioc_enabled(void)
 {
 {

+ 2 - 2
arch/arc/lib/bootm.c

@@ -4,6 +4,7 @@
  * SPDX-License-Identifier:	GPL-2.0+
  * SPDX-License-Identifier:	GPL-2.0+
  */
  */
 
 
+#include <asm/cache.h>
 #include <common.h>
 #include <common.h>
 
 
 DECLARE_GLOBAL_DATA_PTR;
 DECLARE_GLOBAL_DATA_PTR;
@@ -40,8 +41,7 @@ void arch_lmb_reserve(struct lmb *lmb)
 static int cleanup_before_linux(void)
 static int cleanup_before_linux(void)
 {
 {
 	disable_interrupts();
 	disable_interrupts();
-	flush_dcache_all();
-	invalidate_icache_all();
+	sync_n_cleanup_cache_all();
 
 
 	return 0;
 	return 0;
 }
 }

+ 23 - 0
arch/arc/lib/cache.c

@@ -591,3 +591,26 @@ void flush_dcache_all(void)
 	if (is_isa_arcv2() && !slc_data_bypass())
 	if (is_isa_arcv2() && !slc_data_bypass())
 		__slc_entire_op(OP_FLUSH);
 		__slc_entire_op(OP_FLUSH);
 }
 }
+
+/*
+ * This is function to cleanup all caches (and therefore sync I/D caches) which
+ * can be used for cleanup before linux launch or to sync caches during
+ * relocation.
+ */
+void sync_n_cleanup_cache_all(void)
+{
+	__dc_entire_op(OP_FLUSH_N_INV);
+
+	/*
+	 * If SL$ is bypassed for data it is used only for instructions,
+	 * and we shouldn't flush it. So invalidate it instead of flush_n_inv.
+	 */
+	if (is_isa_arcv2()) {
+		if (slc_data_bypass())
+			__slc_entire_op(OP_INV);
+		else
+			__slc_entire_op(OP_FLUSH_N_INV);
+	}
+
+	__ic_entire_invalidate();
+}

+ 3 - 3
arch/arc/lib/init_helpers.c

@@ -4,14 +4,14 @@
  * SPDX-License-Identifier:	GPL-2.0+
  * SPDX-License-Identifier:	GPL-2.0+
  */
  */
 
 
+#include <asm/cache.h>
 #include <common.h>
 #include <common.h>
 
 
 DECLARE_GLOBAL_DATA_PTR;
 DECLARE_GLOBAL_DATA_PTR;
 
 
 int init_cache_f_r(void)
 int init_cache_f_r(void)
 {
 {
-#ifndef CONFIG_SYS_DCACHE_OFF
-	flush_dcache_all();
-#endif
+	sync_n_cleanup_cache_all();
+
 	return 0;
 	return 0;
 }
 }