From patchwork Tue Feb 13 17:34:41 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eugeniy Paltsev X-Patchwork-Id: 873076 X-Patchwork-Delegate: alexey.brodkin@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 3zgqn41wJDz9rxj for ; Wed, 14 Feb 2018 04:49:59 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 5364AC21FBF; Tue, 13 Feb 2018 17:38:58 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=-0.0 required=5.0 tests=RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id DC38EC21F9C; Tue, 13 Feb 2018 17:36:14 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 036F3C21FAE; Tue, 13 Feb 2018 17:35:12 +0000 (UTC) Received: from smtprelay.synopsys.com (us01smtprelay-2.synopsys.com [198.182.60.111]) by lists.denx.de (Postfix) with ESMTPS id 632E3C21FA5 for ; Tue, 13 Feb 2018 17:35:09 +0000 (UTC) Received: from mailhost.synopsys.com (mailhost2.synopsys.com [10.13.184.66]) by smtprelay.synopsys.com (Postfix) with ESMTP id 1F86A10C0027 for ; Tue, 13 Feb 2018 09:35:08 -0800 (PST) Received: from localhost.internal.synopsys.com (unknown [10.121.3.43]) by mailhost.synopsys.com (Postfix) with ESMTP id E8D78286; Tue, 13 Feb 2018 09:35:06 -0800 (PST) From: Eugeniy Paltsev To: uboot-snps-arc@synopsys.com Date: Tue, 13 Feb 2018 20:34:41 +0300 Message-Id: <20180213173451.6317-9-Eugeniy.Paltsev@synopsys.com> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20180213173451.6317-1-Eugeniy.Paltsev@synopsys.com> References: <20180213173451.6317-1-Eugeniy.Paltsev@synopsys.com> Cc: u-boot@lists.denx.de, Alexey Brodkin , Eugeniy Paltsev Subject: [U-Boot] [PATCH 08/18] ARC: cache: allways check dcache status before entire/line operations X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" 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 --- 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) DC_CTRL_CACHE_DISABLE); } -#ifndef CONFIG_SYS_DCACHE_OFF /* 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; + __before_dc_op(cacheop); 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; + __before_dc_op(cacheop); __dcache_line_loop(paddr, sz, cacheop); __after_dc_op(cacheop); } -#else -#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) {