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 9CEA3C433F5 for ; Mon, 11 Apr 2022 16:27:49 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id BE2A683E4B; Mon, 11 Apr 2022 18:27:23 +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="Lw2zE1Fo"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 0277483E45; Mon, 11 Apr 2022 18:26:58 +0200 (CEST) Received: from mail-ej1-x633.google.com (mail-ej1-x633.google.com [IPv6:2a00:1450:4864:20::633]) (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 0D8BA83E41 for ; Mon, 11 Apr 2022 18:26:54 +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-ej1-x633.google.com with SMTP id s18so9537660ejr.0 for ; Mon, 11 Apr 2022 09:26:54 -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=YGhU3RKP3xwfJMgZOTRp+kt+ZeAy5ShdluI/mdGPz5E=; b=Lw2zE1FoygfFgAkpwRTC6F6GAOLPW9V0Sf01BDvhlu6cw5msA4AvYEVcvGAsiBoxZw iUE8+RhnDvptexwS9XNg5JHzwG6c8aFkwfcF9c7J0wVN/6Xx+DM8OonZTkOmZrBlvl0p ULGO14ZktMg1EBvib3MIu+XZh6mHYsqeIRjMlqAGBnMTepFmIm9c+njLS/O4r1ZIdzEt h/1ze4yMbwO8jLLp4UFMhoAZm6kXy59w43w/V4XEHpy+mAscp3MrGdMGcia1MmceIGM0 FOlK+oA+XlYrR8igDGobwW0Kyz5Spl+4L7JyYuBbmddxlk0DIIouhz6cwMX5oQJBCm4e 2poQ== 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=YGhU3RKP3xwfJMgZOTRp+kt+ZeAy5ShdluI/mdGPz5E=; b=dzMQkc7LNUWFGUyvNAOv5826KqowEXLi7RaE9EBgcyaNFRh/Olx6fz1ua8fK7MXMy/ Sj0zG4ARmH6CJ7+FBnb2z91H56jSKubg3zA+dRiRFL7A0hatRx3Vm+InKrXBOytvdxzJ sVHLrHqbXuOwjZzLYbO2tyhArMcmI8SWoF5XDMEDBzYBV2IU4w4Mmtq3ZRq51ioosWTU gOuxH3z8+b920tP+j+35IRgT5cW9IFM5H3z+lTz3D+VfEhK4ck8tAhuajTc+9bVDM9rC d4BJiMTKvIitt0zjuNzEpfKFL9VxzsGyRtCCrKhAhpJrRyaEZFm+ZW9qbgWYJO+leI6s Tt4Q== X-Gm-Message-State: AOAM531cNCzadFm336cWTWYCHhZ6Tg9Rz9EV/0wnZqnbXYh/s5pwFLHA 2WaquzpvBNRJ6MqPLoJAyPe8hxsfMwHRsQ== X-Google-Smtp-Source: ABdhPJy1Yy5Js5Tx+giCs7/vZC+kFO3ixM8wFENbCwY9T/HXkAabijQy1HCqypLmUxDHRYMPC4P3Wg== X-Received: by 2002:a17:907:ea5:b0:6e7:fc88:14f7 with SMTP id ho37-20020a1709070ea500b006e7fc8814f7mr31226286ejc.337.1649694413705; Mon, 11 Apr 2022 09:26:53 -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.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Apr 2022 09:26:53 -0700 (PDT) From: Ovidiu Panait To: u-boot@lists.denx.de Cc: Ovidiu Panait , Michal Simek , Michal Simek Subject: [PATCH 05/10] microblaze: cache: split flush_cache() function Date: Mon, 11 Apr 2022 19:26:29 +0300 Message-Id: <20220411162634.69647-5-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 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 --- 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