From patchwork Wed Mar 21 12:59:02 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eugeniy Paltsev X-Patchwork-Id: 888837 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=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=synopsys.com Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 405qvv5TGcz9s02 for ; Thu, 22 Mar 2018 00:12:11 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 2B63CC21E0D; Wed, 21 Mar 2018 13:03:18 +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_DNSWL_BLOCKED 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 941BEC21E15; Wed, 21 Mar 2018 13:00:26 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id E6196C21E6A; Wed, 21 Mar 2018 12:59:40 +0000 (UTC) Received: from smtprelay.synopsys.com (us01smtprelay-2.synopsys.com [198.182.47.9]) by lists.denx.de (Postfix) with ESMTPS id 40F11C21E63 for ; Wed, 21 Mar 2018 12:59:37 +0000 (UTC) Received: from mailhost.synopsys.com (mailhost3.synopsys.com [10.12.238.238]) by smtprelay.synopsys.com (Postfix) with ESMTP id 0143024E0D85 for ; Wed, 21 Mar 2018 05:59:36 -0700 (PDT) Received: from mailhost.synopsys.com (localhost [127.0.0.1]) by mailhost.synopsys.com (Postfix) with ESMTP id DA09D339D; Wed, 21 Mar 2018 05:59:35 -0700 (PDT) Received: from paltsev-e7480.internal.synopsys.com (unknown [10.121.8.67]) by mailhost.synopsys.com (Postfix) with ESMTP id AD55F339B; Wed, 21 Mar 2018 05:59:34 -0700 (PDT) From: Eugeniy Paltsev To: uboot-snps-arc@synopsys.com Date: Wed, 21 Mar 2018 15:59:02 +0300 Message-Id: <20180321125905.14897-18-Eugeniy.Paltsev@synopsys.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180321125905.14897-1-Eugeniy.Paltsev@synopsys.com> References: <20180321125905.14897-1-Eugeniy.Paltsev@synopsys.com> Cc: u-boot@lists.denx.de, Alexey Brodkin , Eugeniy Paltsev Subject: [U-Boot] [PATCH v2 17/20] ARC: implement function to sync and cleanup caches 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" Implement specialized function to clenup caches (and therefore sync I/D caches) which can be used for cleanup before linux launch or to sync caches during uboot relocation. Signed-off-by: Eugeniy Paltsev --- arch/arc/include/asm/cache.h | 1 + arch/arc/lib/bootm.c | 4 ++-- arch/arc/lib/cache.c | 23 +++++++++++++++++++++++ arch/arc/lib/init_helpers.c | 6 +++--- 4 files changed, 29 insertions(+), 5 deletions(-) diff --git a/arch/arc/include/asm/cache.h b/arch/arc/include/asm/cache.h index fe75409b5c..2269183615 100644 --- a/arch/arc/include/asm/cache.h +++ b/arch/arc/include/asm/cache.h @@ -31,6 +31,7 @@ void cache_init(void); void flush_n_invalidate_dcache_all(void); +void sync_n_cleanup_cache_all(void); static const inline int is_ioc_enabled(void) { diff --git a/arch/arc/lib/bootm.c b/arch/arc/lib/bootm.c index 9eef7070cf..c6800cb0ec 100644 --- a/arch/arc/lib/bootm.c +++ b/arch/arc/lib/bootm.c @@ -4,6 +4,7 @@ * SPDX-License-Identifier: GPL-2.0+ */ +#include #include DECLARE_GLOBAL_DATA_PTR; @@ -45,8 +46,7 @@ int arch_fixup_fdt(void *blob) static int cleanup_before_linux(void) { disable_interrupts(); - flush_dcache_all(); - invalidate_icache_all(); + sync_n_cleanup_cache_all(); return 0; } diff --git a/arch/arc/lib/cache.c b/arch/arc/lib/cache.c index a5aae3d232..5d7583d868 100644 --- a/arch/arc/lib/cache.c +++ b/arch/arc/lib/cache.c @@ -591,3 +591,26 @@ void flush_dcache_all(void) if (is_isa_arcv2() && !slc_data_bypass()) __slc_entire_op(OP_FLUSH); } + +/* + * This is function to cleanup all caches (and therefore sync I/D caches) which + * can be used for cleanup before linux launch or to sync caches during + * relocation. + */ +void sync_n_cleanup_cache_all(void) +{ + __dc_entire_op(OP_FLUSH_N_INV); + + /* + * If SL$ is bypassed for data it is used only for instructions, + * and we shouldn't flush it. So invalidate it instead of flush_n_inv. + */ + if (is_isa_arcv2()) { + if (slc_data_bypass()) + __slc_entire_op(OP_INV); + else + __slc_entire_op(OP_FLUSH_N_INV); + } + + __ic_entire_invalidate(); +} diff --git a/arch/arc/lib/init_helpers.c b/arch/arc/lib/init_helpers.c index dbc8d68ffb..435fe96ef4 100644 --- a/arch/arc/lib/init_helpers.c +++ b/arch/arc/lib/init_helpers.c @@ -4,14 +4,14 @@ * SPDX-License-Identifier: GPL-2.0+ */ +#include #include DECLARE_GLOBAL_DATA_PTR; int init_cache_f_r(void) { -#ifndef CONFIG_SYS_DCACHE_OFF - flush_dcache_all(); -#endif + sync_n_cleanup_cache_all(); + return 0; }