Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 07A37C433F5 for ; Mon, 11 Apr 2022 16:28:30 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 17AB583E70; Mon, 11 Apr 2022 18:27:31 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="bQK8MXPx"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id ACB3A83E43; Mon, 11 Apr 2022 18:27:03 +0200 (CEST) Received: from mail-ed1-x531.google.com (mail-ed1-x531.google.com [IPv6:2a00:1450:4864:20::531]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 4526C80A4E for ; Mon, 11 Apr 2022 18:26:56 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=ovpanait@gmail.com Received: by mail-ed1-x531.google.com with SMTP id c64so6966837edf.11 for ; Mon, 11 Apr 2022 09:26:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=WGeOfPI+PeV+I8leDodxak+xYqncW36c9TGnpsh3xZs=; b=bQK8MXPxyaM/5xliORbpBfuAtfBETWlnco1U7vPolxs+zRw0UTAJIpzksO0/50y+tG U7GakEmq4ZZXmC2mdHTtUOlBRZqebslpnL/xJNDM7e4z1ipX2A5VCAeha3BfsPeyLOaW mss8d+/ft34+3nRoJEXWwAK2HnUXHfCXpCRWsvI6UW3NMwIzuOooBj2hK+jjqBr8lECS 6bc7zHq/j9BKdkQ1Eq7e1M6a0lI84KrSSqr6ZT+Zl1yfpNABJbd8RcflptG6F+a91FbU crY3nxtAM2Tu8M5Pie1uwmxeoYoqTe02tcQR6VcvMPxAgJL3cW0z9J9uhOZXSaDik3ZS vWkQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=WGeOfPI+PeV+I8leDodxak+xYqncW36c9TGnpsh3xZs=; b=CUUOtUcX6cfW5fcswmssyeIf2DrNRx1xcqxvAPuR8wcW3TS8tJK33vHgXGY+ZHvcEk eqv2SjRLCZTJKrM0LMt5dZqem1+4e53KB60Io7P5IWhkEIu4u/mUTjYvuwbT/tfaoMoJ 7EB+ktyFJSQm8t9Tqk8u7/rSze4fFc2UUrPudsmRpAsiH6pnbhv5r72ivCYPWMunuggd 8FTD/VAtT9nszRyePj018xLlNPuPezhNfVyhLePG3AwWSD5cZw1xnRmMakuScIIoa6X2 cMEUxdb9h2CeHE8vD6mo5Iy3Lh0+S79RcXCSNMf9qRG67C91glb+nioSjd/2hfqa3jqn gUbw== X-Gm-Message-State: AOAM533s7j565YXtrXRTs14NjuzmI6S+ChmzFz1EvXEnykvc++M8AsGn xHTYcr0MPrxOiq6bP9RiB4h0sdJLiAqkFg== X-Google-Smtp-Source: ABdhPJxYk/dKEVkh9arZxUtrM/boAIUb/Ba+F+4d7oYebKgEMJT0G/fIjiGG3+wVjU8U/e9zp7YX0A== X-Received: by 2002:a05:6402:22b5:b0:41d:7637:98b8 with SMTP id cx21-20020a05640222b500b0041d763798b8mr9237700edb.69.1649694415958; Mon, 11 Apr 2022 09:26:55 -0700 (PDT) Received: from wsdell.corp.ad.wrs.com ([2a02:2f0e:c41b:f600:4ab1:7aea:1e9:311a]) by smtp.gmail.com with ESMTPSA id y26-20020a1709063a9a00b006e0c272e263sm12111417ejd.71.2022.04.11.09.26.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Apr 2022 09:26:55 -0700 (PDT) From: Ovidiu Panait To: u-boot@lists.denx.de Cc: Ovidiu Panait , Alexandru Gagniuc , Marek Vasut , Michal Simek , Michal Simek , Simon Glass Subject: [PATCH 07/10] microblaze: cache: introduce flush_cache_all() Date: Mon, 11 Apr 2022 19:26:31 +0300 Message-Id: <20220411162634.69647-7-ovpanait@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220411162634.69647-1-ovpanait@gmail.com> References: <20220411162634.69647-1-ovpanait@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.5 at phobos.denx.de X-Virus-Status: Clean All flush_cache() calls in microblaze code are supposed to flush the entire instruction and data caches, so introduce flush_cache_all() helper to handle this. Also, provide implementations for flush_dcache_all() and invalidate_icache_all() so that icache and dcache u-boot commands can work. Signed-off-by: Ovidiu Panait --- arch/microblaze/cpu/cache.c | 20 ++++++++++++++++++-- arch/microblaze/cpu/start.S | 8 ++------ arch/microblaze/include/asm/cache.h | 5 +++++ arch/microblaze/lib/bootm.c | 2 +- 4 files changed, 26 insertions(+), 9 deletions(-) diff --git a/arch/microblaze/cpu/cache.c b/arch/microblaze/cpu/cache.c index 2814c1dc07..60b6d549d7 100644 --- a/arch/microblaze/cpu/cache.c +++ b/arch/microblaze/cpu/cache.c @@ -24,6 +24,11 @@ static void __invalidate_icache(ulong addr, ulong size) } } +void invalidate_icache_all(void) +{ + __invalidate_icache(0, CONFIG_XILINX_MICROBLAZE0_DEFAULT_CACHE_SIZE); +} + static void __flush_dcache(ulong addr, ulong size) { if (CONFIG_IS_ENABLED(XILINX_MICROBLAZE0_USE_WDC)) { @@ -38,6 +43,11 @@ static void __flush_dcache(ulong addr, ulong size) } } +void flush_dcache_all(void) +{ + __flush_dcache(0, CONFIG_XILINX_MICROBLAZE0_DEFAULT_CACHE_SIZE); +} + int dcache_status(void) { int i = 0; @@ -65,7 +75,7 @@ void icache_enable(void) void icache_disable(void) { - __invalidate_icache(0, CONFIG_XILINX_MICROBLAZE0_DEFAULT_CACHE_SIZE); + invalidate_icache_all(); MSRCLR(0x20); } @@ -77,7 +87,7 @@ void dcache_enable(void) void dcache_disable(void) { - __flush_dcache(0, CONFIG_XILINX_MICROBLAZE0_DEFAULT_CACHE_SIZE); + flush_dcache_all(); MSRCLR(0x80); } @@ -87,3 +97,9 @@ void flush_cache(ulong addr, ulong size) __invalidate_icache(addr, size); __flush_dcache(addr, size); } + +void flush_cache_all(void) +{ + invalidate_icache_all(); + flush_dcache_all(); +} diff --git a/arch/microblaze/cpu/start.S b/arch/microblaze/cpu/start.S index 94984148de..7f7b5f5cb5 100644 --- a/arch/microblaze/cpu/start.S +++ b/arch/microblaze/cpu/start.S @@ -52,9 +52,7 @@ _start: #endif /* Flush cache before enable cache */ - addik r5, r0, 0 - addik r6, r0, CONFIG_XILINX_MICROBLAZE0_DEFAULT_CACHE_SIZE - bralid r15, flush_cache + bralid r15, flush_cache_all nop /* enable instruction and data cache */ @@ -283,9 +281,7 @@ relocate_code: addk r20, r20, r23 /* Flush caches to ensure consistency */ - addik r5, r0, 0 - addik r6, r0, CONFIG_XILINX_MICROBLAZE0_DEFAULT_CACHE_SIZE - bralid r15, flush_cache + bralid r15, flush_cache_all nop 2: addi r5, r31, 0 /* gd is initialized in board_r.c */ diff --git a/arch/microblaze/include/asm/cache.h b/arch/microblaze/include/asm/cache.h index baee01a0e2..c39b66dd7d 100644 --- a/arch/microblaze/include/asm/cache.h +++ b/arch/microblaze/include/asm/cache.h @@ -18,4 +18,9 @@ #define ARCH_DMA_MINALIGN 16 #endif +/** + * flush_cache_all - flush the entire instruction/data caches + */ +void flush_cache_all(void); + #endif /* __MICROBLAZE_CACHE_H__ */ diff --git a/arch/microblaze/lib/bootm.c b/arch/microblaze/lib/bootm.c index 59b757c857..af946b8642 100644 --- a/arch/microblaze/lib/bootm.c +++ b/arch/microblaze/lib/bootm.c @@ -57,7 +57,7 @@ static void boot_jump_linux(bootm_headers_t *images, int flag) "(fake run for tracing)" : ""); bootstage_mark_name(BOOTSTAGE_ID_BOOTM_HANDOFF, "start_kernel"); - flush_cache(0, CONFIG_XILINX_MICROBLAZE0_DEFAULT_CACHE_SIZE); + flush_cache_all(); if (!fake) { /* -- 2.25.1