From patchwork Tue Feb 13 17:34:42 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eugeniy Paltsev X-Patchwork-Id: 873058 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 3zgqdC3sscz9sNr for ; Wed, 14 Feb 2018 04:43:11 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 3F1E2C21FBE; Tue, 13 Feb 2018 17:37:09 +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 46C5DC21FAB; Tue, 13 Feb 2018 17:35:42 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 7687BC21F8A; Tue, 13 Feb 2018 17:35:14 +0000 (UTC) Received: from smtprelay.synopsys.com (smtprelay.synopsys.com [198.182.60.111]) by lists.denx.de (Postfix) with ESMTPS id EEB45C21FB6 for ; Tue, 13 Feb 2018 17:35:10 +0000 (UTC) Received: from mailhost.synopsys.com (mailhost2.synopsys.com [10.13.184.66]) by smtprelay.synopsys.com (Postfix) with ESMTP id 9E70F10C02AE for ; Tue, 13 Feb 2018 09:35:09 -0800 (PST) Received: from localhost.internal.synopsys.com (unknown [10.121.3.43]) by mailhost.synopsys.com (Postfix) with ESMTP id 74F4F2A5; Tue, 13 Feb 2018 09:35:08 -0800 (PST) From: Eugeniy Paltsev To: uboot-snps-arc@synopsys.com Date: Tue, 13 Feb 2018 20:34:42 +0300 Message-Id: <20180213173451.6317-10-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 09/18] ARC: cache: Use is_isa_arcv2() instead of CONFIG_ISA_ARCV2 ifdef 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" Use is_isa_arcv2() function instead of CONFIG_ISA_ARCV2 define check to make code clear at the same time keeping pretty much the same functionality - code in branches under "if (is_isa_arcv2())" won't be compiled if CONFIG_ISA_ARCV2 is not defined. Signed-off-by: Eugeniy Paltsev --- arch/arc/lib/cache.c | 51 +++++++++++++++++++++------------------------------ 1 file changed, 21 insertions(+), 30 deletions(-) diff --git a/arch/arc/lib/cache.c b/arch/arc/lib/cache.c index f566528..eac3d66 100644 --- a/arch/arc/lib/cache.c +++ b/arch/arc/lib/cache.c @@ -43,7 +43,6 @@ bool icache_exists __section(".data") = false; #define CACHE_LINE_MASK (~(l1_line_sz - 1)) -#ifdef CONFIG_ISA_ARCV2 int slc_line_sz __section(".data"); bool slc_exists __section(".data") = false; bool ioc_exists __section(".data") = false; @@ -173,9 +172,7 @@ static void arc_ioc_setup(void) write_aux_reg(ARC_AUX_IO_COH_PARTIAL, 1); write_aux_reg(ARC_AUX_IO_COH_ENABLE, 1); } -#endif /* CONFIG_ISA_ARCV2 */ -#ifdef CONFIG_ISA_ARCV2 static void read_decode_cache_bcr_arcv2(void) { union bcr_slc_cfg slc_cfg; @@ -193,7 +190,6 @@ static void read_decode_cache_bcr_arcv2(void) if (cbcr.fields.c && ioc_enable) ioc_exists = true; } -#endif void read_decode_cache_bcr(void) { @@ -224,10 +220,10 @@ void cache_init(void) { read_decode_cache_bcr(); -#ifdef CONFIG_ISA_ARCV2 - read_decode_cache_bcr_arcv2(); + if (is_isa_arcv2()) + read_decode_cache_bcr_arcv2(); - if (ioc_exists) + if (is_isa_arcv2() && ioc_exists) arc_ioc_setup(); read_decode_mmu_bcr(); @@ -237,9 +233,8 @@ void cache_init(void) * only if PAE exists in current HW. So we had to check pae_exist * before using them. */ - if (slc_exists && pae_exists) + if (is_isa_arcv2() && slc_exists && pae_exists) slc_upper_region_init(); -#endif /* CONFIG_ISA_ARCV2 */ } int icache_status(void) @@ -289,10 +284,8 @@ void invalidate_icache_all(void) { __ic_entire_invalidate(); -#ifdef CONFIG_ISA_ARCV2 - if (slc_exists) + if (is_isa_arcv2() && slc_exists) __slc_entire_op(OP_INV); -#endif } int dcache_status(void) @@ -404,15 +397,16 @@ void invalidate_dcache_range(unsigned long start, unsigned long end) if (start >= end) return; -#ifdef CONFIG_ISA_ARCV2 - if (!ioc_exists) -#endif + /* + * ARCv1 -> call __dc_line_op + * ARCv2 && no IOC -> call __dc_line_op; call __slc_rgn_op + * ARCv2 && IOC enabled -> nothing + */ + if (!is_isa_arcv2() || !ioc_exists) __dc_line_op(start, end - start, OP_INV); -#ifdef CONFIG_ISA_ARCV2 - if (slc_exists && !ioc_exists) + if (is_isa_arcv2() && slc_exists && !ioc_exists) __slc_rgn_op(start, end - start, OP_INV); -#endif } void flush_dcache_range(unsigned long start, unsigned long end) @@ -420,15 +414,16 @@ void flush_dcache_range(unsigned long start, unsigned long end) if (start >= end) return; -#ifdef CONFIG_ISA_ARCV2 - if (!ioc_exists) -#endif + /* + * ARCv1 -> call __dc_line_op + * ARCv2 && no IOC -> call __dc_line_op; call __slc_rgn_op + * ARCv2 && IOC enabled -> nothing + */ + if (!is_isa_arcv2() || !ioc_exists) __dc_line_op(start, end - start, OP_FLUSH); -#ifdef CONFIG_ISA_ARCV2 - if (slc_exists && !ioc_exists) + if (is_isa_arcv2() && slc_exists && !ioc_exists) __slc_rgn_op(start, end - start, OP_FLUSH); -#endif } void flush_cache(unsigned long start, unsigned long size) @@ -446,18 +441,14 @@ void flush_n_invalidate_dcache_all(void) { __dc_entire_op(OP_FLUSH_N_INV); -#ifdef CONFIG_ISA_ARCV2 - if (slc_exists) + if (is_isa_arcv2() && slc_exists) __slc_entire_op(OP_FLUSH_N_INV); -#endif } void flush_dcache_all(void) { __dc_entire_op(OP_FLUSH); -#ifdef CONFIG_ISA_ARCV2 - if (slc_exists) + if (is_isa_arcv2() && slc_exists) __slc_entire_op(OP_FLUSH); -#endif }