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 BF329C433EF for ; Tue, 31 May 2022 18:16:10 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 49E378426A; Tue, 31 May 2022 20:15:33 +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="EN05PJzw"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 681FF83E43; Tue, 31 May 2022 20:15:20 +0200 (CEST) Received: from mail-wr1-x435.google.com (mail-wr1-x435.google.com [IPv6:2a00:1450:4864:20::435]) (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 76FB6840D8 for ; Tue, 31 May 2022 20:14: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-wr1-x435.google.com with SMTP id q7so8808972wrg.5 for ; Tue, 31 May 2022 11:14: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=1vHwzUwHB2p+h4S0N9c2IvqIdzTihq56z1usdErBgsg=; b=EN05PJzwfPPF+DHVms742z9JWBkqsDsDCJQY8pViUrIN2i4nZPTRoWi+ID35ZskwaD YUeTywt42Dje6su9lGVG2CBFDALkQQZ+tuWKPnxZhhxS5tW7qGnqMaM9xw8nqcQN/YcL gHA6TP33BiKTnokMRpifnY+XrzoawxCzlTWSXrrCRybr+Am3DywULez2BSncmNCwmdmr /CGmWE2UxNS92dh5WSz5uxU7AlI9MvBEFqOs0OVL0U9q5MO5Fs3T/Z4CfRKFE+IJSHQe O4fmoZE/IobQsXUxbWkmWnTDnX1UMQMCMSWzS61JgxoBUx43iQdf3GIwskxNJHoOwT3G MKCA== 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=1vHwzUwHB2p+h4S0N9c2IvqIdzTihq56z1usdErBgsg=; b=uANdVnbXSQedfUpxufqxsO6FqdM3v1ZfDWW6KCekIesFE99Geq3CM/u4tFpqGR8DYX EF1NaTo5RCBsGLfqrNFNUdlUyZj5Q8JqCiCygNNXBt5Ri1Mx+WnAqfYcS4pQwEPNx1hJ +LSOHroVEFC2QpGvBZ2ZBSo7gVvj0L5Q02H8Zek6WAivug+Sg7Rf/lMbd1qeLMGFh4qn NO5xT8KVjmBxC8Vx3ezvVrW5pTyPzWyvV5UkekaRLchRGq54yAVDZy/1vsA47h8W72KN OM3ZCcGBlrbWqBfFyCT3wbigWCkKRJqPHxCHpVzrbUDml7NRqMPF9EdJdgacFbXVBw9B Q07g== X-Gm-Message-State: AOAM531F3csaBzcyiiEHmvhQvnoCyS/b0Tc9xmaIAYZpj56euD2tZX8p uyaIdvdNHxMP80yD8/Aawl4AOVUkDV0= X-Google-Smtp-Source: ABdhPJzdRwPM6lN5IlE2K+PP0RL4jj5xAuqvJRNZZoINVgkK5+bYH3r4fx+Z3dl1pk/K6vcRCKVGlQ== X-Received: by 2002:a5d:4611:0:b0:210:2e15:7f69 with SMTP id t17-20020a5d4611000000b002102e157f69mr12058794wrq.441.1654020894087; Tue, 31 May 2022 11:14:54 -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.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 May 2022 11:14:53 -0700 (PDT) From: Ovidiu Panait To: u-boot@lists.denx.de Cc: monstr@monstr.eu, Ovidiu Panait , Alexandru Gagniuc , Marek Vasut , Michal Simek , Simon Glass Subject: [PATCH v2 05/14] microblaze: cache: improve dcache Kconfig options Date: Tue, 31 May 2022 21:14:26 +0300 Message-Id: <20220531181435.3473549-5-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 Replace CONFIG_DCACHE with a Kconfig option more limited in scope - XILINX_MICROBLAZE0_USE_WDC. It should be enabled if the processor supports the "wdc" (Write to Data Cache) instruction. It will be used to guard "wdc" invocations in microblaze cache code. Also, drop all ifdefs around flush_cache() calls and only keep one CONFIG_IS_ENABLED() guard within flush_cache() itself. Signed-off-by: Ovidiu Panait --- Changes in v2: - added CONFIG_SPL_XILINX_MICROBLAZE0_USE_WDC symbol arch/microblaze/Kconfig | 4 ---- arch/microblaze/cpu/cache.c | 15 ++++++++++----- arch/microblaze/lib/bootm.c | 2 -- board/xilinx/microblaze-generic/Kconfig | 11 +++++++++++ 4 files changed, 21 insertions(+), 11 deletions(-) diff --git a/arch/microblaze/Kconfig b/arch/microblaze/Kconfig index d7d1b21970..5a2e91104f 100644 --- a/arch/microblaze/Kconfig +++ b/arch/microblaze/Kconfig @@ -25,10 +25,6 @@ config TARGET_MICROBLAZE_GENERIC endchoice -config DCACHE - bool "Enable dcache support" - default y - config ICACHE bool "Enable icache support" default y diff --git a/arch/microblaze/cpu/cache.c b/arch/microblaze/cpu/cache.c index b6126de194..4e8e228a22 100644 --- a/arch/microblaze/cpu/cache.c +++ b/arch/microblaze/cpu/cache.c @@ -49,26 +49,31 @@ void dcache_enable(void) void dcache_disable(void) { -#ifdef CONFIG_DCACHE flush_cache(0, XILINX_DCACHE_BYTE_SIZE); -#endif + MSRCLR(0x80); } void flush_cache(ulong addr, ulong size) { int i; - for (i = 0; i < size; i += 4) + for (i = 0; i < size; i += 4) { asm volatile ( #ifdef CONFIG_ICACHE "wic %0, r0;" #endif "nop;" -#ifdef CONFIG_DCACHE + : + : "r" (addr + i) + : "memory"); + + if (CONFIG_IS_ENABLED(XILINX_MICROBLAZE0_USE_WDC)) { + asm volatile ( "wdc.flush %0, r0;" -#endif "nop;" : : "r" (addr + i) : "memory"); + } + } } diff --git a/arch/microblaze/lib/bootm.c b/arch/microblaze/lib/bootm.c index b652d2767a..dba6226ce5 100644 --- a/arch/microblaze/lib/bootm.c +++ b/arch/microblaze/lib/bootm.c @@ -57,9 +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"); -#ifdef CONFIG_DCACHE flush_cache(0, XILINX_DCACHE_BYTE_SIZE); -#endif if (!fake) { /* diff --git a/board/xilinx/microblaze-generic/Kconfig b/board/xilinx/microblaze-generic/Kconfig index 117b476f3f..b00ce6f59a 100644 --- a/board/xilinx/microblaze-generic/Kconfig +++ b/board/xilinx/microblaze-generic/Kconfig @@ -63,4 +63,15 @@ config XILINX_MICROBLAZE0_VECTOR_BASE_ADDR Memory address location of the exception vector table. It is configurable via the C_BASE_VECTORS hdl parameter. +config XILINX_MICROBLAZE0_USE_WDC + bool "MicroBlaze wdc instruction support" + default y + help + Enable this option if the MicroBlaze processor is configured with + support for the "wdc" (Write to Data Cache) instruction. + +config SPL_XILINX_MICROBLAZE0_USE_WDC + bool + default XILINX_MICROBLAZE0_USE_WDC + endif -- 2.25.1