[U-Boot] [PATCH 10/18] ARC: cache: move slc status check into slc_entire_op and slc_rgn_op

Eugeniy Paltsev Eugeniy.Paltsev at synopsys.com
Tue Feb 13 17:34:43 UTC 2018


As of today we check slc status before each call of __slc_rgn_op
or __slc_entire_op. So move status check into __slc_rgn_op
and __slc_entire_op.

As we need to check status before *each* function call and we
slc_entire_op and slc_rgn_op functions from different places we add
this check directly into slc entire/line functions instead of
their callers to avoid code duplication.

Signed-off-by: Eugeniy Paltsev <Eugeniy.Paltsev at synopsys.com>
---
 arch/arc/lib/cache.c | 22 +++++++++++++++++-----
 1 file changed, 17 insertions(+), 5 deletions(-)

diff --git a/arch/arc/lib/cache.c b/arch/arc/lib/cache.c
index eac3d66..8633ba5 100644
--- a/arch/arc/lib/cache.c
+++ b/arch/arc/lib/cache.c
@@ -63,10 +63,19 @@ void read_decode_mmu_bcr(void)
 #endif /* (CONFIG_ARC_MMU_VER >= 4) */
 }
 
+static inline bool slc_status(void)
+{
+	/* TODO: HS 3.0 supports SLC disable so we need to check it here */
+	return slc_exists;
+}
+
 static void __slc_entire_op(const int op)
 {
 	unsigned int ctrl;
 
+	if (!slc_status())
+		return;
+
 	ctrl = read_aux_reg(ARC_AUX_SLC_CTRL);
 
 	if (!(op & OP_FLUSH))		/* i.e. OP_INV */
@@ -103,6 +112,9 @@ static void __slc_rgn_op(unsigned long paddr, unsigned long sz, const int op)
 	unsigned int ctrl;
 	unsigned long end;
 
+	if (!slc_status())
+		return;
+
 	/*
 	 * The Region Flush operation is specified by CTRL.RGN_OP[11..9]
 	 *  - b'000 (default) is Flush,
@@ -284,7 +296,7 @@ void invalidate_icache_all(void)
 {
 	__ic_entire_invalidate();
 
-	if (is_isa_arcv2() && slc_exists)
+	if (is_isa_arcv2())
 		__slc_entire_op(OP_INV);
 }
 
@@ -405,7 +417,7 @@ void invalidate_dcache_range(unsigned long start, unsigned long end)
 	if (!is_isa_arcv2() || !ioc_exists)
 		__dc_line_op(start, end - start, OP_INV);
 
-	if (is_isa_arcv2() && slc_exists && !ioc_exists)
+	if (is_isa_arcv2() && !ioc_exists)
 		__slc_rgn_op(start, end - start, OP_INV);
 }
 
@@ -422,7 +434,7 @@ void flush_dcache_range(unsigned long start, unsigned long end)
 	if (!is_isa_arcv2() || !ioc_exists)
 		__dc_line_op(start, end - start, OP_FLUSH);
 
-	if (is_isa_arcv2() && slc_exists && !ioc_exists)
+	if (is_isa_arcv2() && !ioc_exists)
 		__slc_rgn_op(start, end - start, OP_FLUSH);
 }
 
@@ -441,7 +453,7 @@ void flush_n_invalidate_dcache_all(void)
 {
 	__dc_entire_op(OP_FLUSH_N_INV);
 
-	if (is_isa_arcv2() && slc_exists)
+	if (is_isa_arcv2())
 		__slc_entire_op(OP_FLUSH_N_INV);
 }
 
@@ -449,6 +461,6 @@ void flush_dcache_all(void)
 {
 	__dc_entire_op(OP_FLUSH);
 
-	if (is_isa_arcv2() && slc_exists)
+	if (is_isa_arcv2())
 		__slc_entire_op(OP_FLUSH);
 }
-- 
2.9.3



More information about the U-Boot mailing list