[U-Boot,08/18] ARC: cache: allways check dcache status before entire/line operations

Message ID 20180213173451.6317-9-Eugeniy.Paltsev@synopsys.com
State Superseded
Delegated to: Alexey Brodkin
Headers show
  • ARC: cache subsystem improvement/refactoring
Related show

Commit Message

Eugeniy Paltsev Feb. 13, 2018, 5:34 p.m.
As we are planning to get rid of dozens of ifdef's in cache.c we
would better check dcache status before each entire/line operation
then check CONFIG_SYS_DCACHE_OFF config option.

This makes the code clear.
Another advantage is that the dcache entire/line functions
remain functional even if we enable dcache in runtime.

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

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


diff --git a/arch/arc/lib/cache.c b/arch/arc/lib/cache.c
index a743063..f566528 100644
--- a/arch/arc/lib/cache.c
+++ b/arch/arc/lib/cache.c
@@ -324,7 +324,6 @@  void dcache_disable(void)
 /* Common Helper for Line Operations on D-cache */
 static inline void __dcache_line_loop(unsigned long paddr, unsigned long sz,
 				      const int cacheop)
@@ -374,6 +373,9 @@  static inline void __dc_entire_op(const int cacheop)
 	int aux;
+	if (!dcache_status())
+		return;
 	if (cacheop & OP_INV)	/* Inv or flush-n-inv use same cmd reg */
@@ -389,14 +391,13 @@  static inline void __dc_entire_op(const int cacheop)
 static inline void __dc_line_op(unsigned long paddr, unsigned long sz,
 				const int cacheop)
+	if (!dcache_status())
+		return;
 	__dcache_line_loop(paddr, sz, cacheop);
-#define __dc_entire_op(cacheop)
-#define __dc_line_op(paddr, sz, cacheop)
-#endif /* !CONFIG_SYS_DCACHE_OFF */
 void invalidate_dcache_range(unsigned long start, unsigned long end)