@@ -31,6 +31,7 @@
void cache_init(void);
void flush_n_invalidate_dcache_all(void);
+void sync_icache_dcache_all(void);
static const inline int is_ioc_enabled(void)
{
@@ -491,3 +491,13 @@ void flush_dcache_all(void)
if (is_isa_arcv2())
__slc_entire_op(OP_FLUSH);
}
+
+/*
+ * This is function for making I/D Caches consistent when modifying u-boot code
+ * (relocation, etc...)
+ */
+void sync_icache_dcache_all(void)
+{
+ __dc_entire_op(OP_FLUSH);
+ __ic_entire_invalidate();
+}
@@ -4,14 +4,14 @@
* SPDX-License-Identifier: GPL-2.0+
*/
+#include <asm/cache.h>
#include <common.h>
DECLARE_GLOBAL_DATA_PTR;
int init_cache_f_r(void)
{
-#ifndef CONFIG_SYS_DCACHE_OFF
- flush_dcache_all();
-#endif
+ sync_icache_dcache_all();
+
return 0;
}
As of today we call flush_dcache_all before relocation, to sync I/D caches so there are two problems: * We also flush SLC (on ARCv2) - this is overhead as SLC is shared for data and instructions. * We don't invalidate I$ - this can be dangerous if have some valid lines in I$ in relocation area for some reason. Fix this by implementing specialized sync_icache_dcache_all function. Signed-off-by: Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com> --- arch/arc/include/asm/cache.h | 1 + arch/arc/lib/cache.c | 10 ++++++++++ arch/arc/lib/init_helpers.c | 6 +++--- 3 files changed, 14 insertions(+), 3 deletions(-)