From mboxrd@z Thu Jan 1 00:00:00 1970 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 E8551C433F5 for ; Tue, 31 May 2022 18:16:35 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 2BB34842AD; Tue, 31 May 2022 20:15:43 +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="O4EIl4qB"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id A20A28421F; Tue, 31 May 2022 20:15:24 +0200 (CEST) Received: from mail-wm1-x334.google.com (mail-wm1-x334.google.com [IPv6:2a00:1450:4864:20::334]) (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 B40E684269 for ; Tue, 31 May 2022 20:14: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-wm1-x334.google.com with SMTP id p19so8475223wmg.2 for ; Tue, 31 May 2022 11:14: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=PVkdy26RYP1JkSLLH6z58vx/LQacd8jmwv8jC2c0grk=; b=O4EIl4qByVCCqCJ0/ZU3M0se2BcgZaU1cWZtYqLfXq23VJJIa8Ik6HNrSDHJevuT8p TAUNzrg8yafn30CVldYhj0qA5j10tsXkbpccXMo1hz/vHw3VeuidlTuaFNeFIcBCRlJf Qb1Wa+E+1o4U+msCC3V8kyzr4eNGkLcbHIUf8y746h1hQIwl8znMnH2FCk4ZUPx34OEx Db+zc+fsJdo/IL+5LkQ43St2zeq65f6I95CrZK8FKPuVhhpvmMZ0hYTfoofxVjpRQh32 Ft24lFmu+NSyTnHLHnue3Dk2m3cqkFVVd3HzAHqMq+Gr7y9WMcvgTGOGf+nuAXoGj/+S cAtQ== 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=PVkdy26RYP1JkSLLH6z58vx/LQacd8jmwv8jC2c0grk=; b=hY+Q7rRRQTXUBeDG54j2i9/y1T1AhwcfPxCZthJtYw8cO6WdCMIfo25GrF/3GaqRDV y00yiGRshxxVbqEYSF3xI8p1DWalAkq9sm3iwTEKWeT4T5cX/0/vO27AzuwxKGVSCSXd ixjYY8zEuKY8YpXfw7vQgxu+3IpnbNuY0TFW6mx4E4HFJuaHAmKOc4CEHwKDjtL3IHxe F0UnpfhmunWwhHyfPfpX0z0OianIZivmMWUEo3xVb6bDavoR8/7pZKl0q+QmJgEdYO/L /kSAKWVzQd79jZM2Lkl3I0tSgm+2y3cORL7X/45mdY+3RUMAyNw3WgAkZZ2fLNHMwfvL VkJw== X-Gm-Message-State: AOAM531DAoSAvFuOCbLIxP7NJSHEomKMpaSXtlCHhNcNX7zRK9ALotrS JeHP0yk5b5cdYt/nrhsh2jEtQbyNqQ4= X-Google-Smtp-Source: ABdhPJxMvRN4yF7ItMCM63smaLew+jZk89Kt4Bw0xyWRmumEMXLGNywZSKIp55ey4glxnpV0Q5EMEw== X-Received: by 2002:a05:600c:4fd2:b0:39b:893e:ff79 with SMTP id o18-20020a05600c4fd200b0039b893eff79mr12263833wmq.73.1654020896268; Tue, 31 May 2022 11:14:56 -0700 (PDT) Received: from localhost.localdomain ([2a02:2f0e:c003:7c00:45d1:29c0:7802:f752]) by smtp.gmail.com with ESMTPSA id l3-20020a1c7903000000b003974027722csm2682980wme.47.2022.05.31.11.14.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 May 2022 11:14:55 -0700 (PDT) From: Ovidiu Panait To: u-boot@lists.denx.de Cc: monstr@monstr.eu, Ovidiu Panait , Michal Simek Subject: [PATCH v2 07/14] microblaze: cache: split flush_cache() function Date: Tue, 31 May 2022 21:14:28 +0300 Message-Id: <20220531181435.3473549-7-ovpanait@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220531181435.3473549-1-ovpanait@gmail.com> References: <20220531181435.3473549-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 Factor out icache/dcache components from flush_cache() function. Call the newly added __flush_icache()/__flush_dcache() functions inside icache_disable() and dcache_disable(), respectively. There is no need to flush both caches when disabling a particular cache type. Signed-off-by: Ovidiu Panait --- (no changes since v1) arch/microblaze/cpu/cache.c | 55 ++++++++++++++++++++++--------------- 1 file changed, 33 insertions(+), 22 deletions(-) diff --git a/arch/microblaze/cpu/cache.c b/arch/microblaze/cpu/cache.c index b6bbc215b3..e362a34a79 100644 --- a/arch/microblaze/cpu/cache.c +++ b/arch/microblaze/cpu/cache.c @@ -10,6 +10,34 @@ #include #include +static void __invalidate_icache(ulong addr, ulong size) +{ + if (CONFIG_IS_ENABLED(XILINX_MICROBLAZE0_USE_WIC)) { + for (int i = 0; i < size; i += 4) { + asm volatile ( + "wic %0, r0;" + "nop;" + : + : "r" (addr + i) + : "memory"); + } + } +} + +static void __flush_dcache(ulong addr, ulong size) +{ + if (CONFIG_IS_ENABLED(XILINX_MICROBLAZE0_USE_WDC)) { + for (int i = 0; i < size; i += 4) { + asm volatile ( + "wdc.flush %0, r0;" + "nop;" + : + : "r" (addr + i) + : "memory"); + } + } +} + int dcache_status(void) { int i = 0; @@ -38,7 +66,8 @@ void icache_enable(void) void icache_disable(void) { /* we are not generate ICACHE size -> flush whole cache */ - flush_cache(0, 32768); + __invalidate_icache(0, 32768); + MSRCLR(0x20); } @@ -49,31 +78,13 @@ void dcache_enable(void) void dcache_disable(void) { - flush_cache(0, XILINX_DCACHE_BYTE_SIZE); + __flush_dcache(0, XILINX_DCACHE_BYTE_SIZE); MSRCLR(0x80); } void flush_cache(ulong addr, ulong size) { - int i; - for (i = 0; i < size; i += 4) { - if (CONFIG_IS_ENABLED(XILINX_MICROBLAZE0_USE_WIC)) { - asm volatile ( - "wic %0, r0;" - "nop;" - : - : "r" (addr + i) - : "memory"); - } - - if (CONFIG_IS_ENABLED(XILINX_MICROBLAZE0_USE_WDC)) { - asm volatile ( - "wdc.flush %0, r0;" - "nop;" - : - : "r" (addr + i) - : "memory"); - } - } + __invalidate_icache(addr, size); + __flush_dcache(addr, size); } -- 2.25.1