From patchwork Sat Feb 17 12:34:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonas Karlman X-Patchwork-Id: 1900462 X-Patchwork-Delegate: ykai007@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=kwiboo.se header.i=@kwiboo.se header.a=rsa-sha256 header.s=fe-e1b5cab7be header.b=o1HZC9TJ; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4TcStJ0bNNz23hy for ; Sat, 17 Feb 2024 23:34:47 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 6227887C5D; Sat, 17 Feb 2024 13:34:37 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=kwiboo.se 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; secure) header.d=kwiboo.se header.i=@kwiboo.se header.b="o1HZC9TJ"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id E437787C5D; Sat, 17 Feb 2024 13:34:30 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.2 Received: from smtp.forwardemail.net (smtp.forwardemail.net [149.28.215.223]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 4049F879F0 for ; Sat, 17 Feb 2024 13:34:22 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=kwiboo.se Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=SRS0=f1ab=J3=kwiboo.se=jonas@fe-bounces.kwiboo.se DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kwiboo.se; h=Content-Transfer-Encoding: MIME-Version: Message-ID: Date: Subject: Cc: To: From; q=dns/txt; s=fe-e1b5cab7be; t=1708173253; bh=Tzkoo4JP4dz5CnhxqFGyjBD+YiTlOH6ZGP+JBMA49Ck=; b=o1HZC9TJwb91kkHYzpRMNgfh+LcmcwEyvPAZGoXc5SXN8r32SRYUJMGKvUninpB07ikeeMBW7 ge8YxcqH+4AltQpjPj5DHy98idGH1xZlnTLkmxP3dvXJIvshvqxHwQtQN+kLkD523FhUHJGN14p t25N+5knlLsGkAnmkbdfJhvXzcYtgUTAaFHdPSDqyGLlTZouHlBSr7TjZDitLExbpSNdVdbeVTO kbg751woRsb0g5Knq3bGZzJ/WaxCoVMKzOI0gqYzJ6BlBGWr6oKNy0+Up+LnDU6o62FFWQR+ust 2I2yDXUjKSCDl+0/cuYzOaVrlTgBvEr7takdyB0JlnvA== From: Jonas Karlman To: Kever Yang , Simon Glass , Philipp Tomsich , Tom Rini Cc: Jagan Teki , u-boot@lists.denx.de, Jonas Karlman Subject: [PATCH v4] rockchip: spl: Enable caches to speed up checksum validation Date: Sat, 17 Feb 2024 12:34:04 +0000 Message-ID: <20240217123406.2461548-1-jonas@kwiboo.se> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 X-Report-Abuse-To: abuse@forwardemail.net X-Report-Abuse: abuse@forwardemail.net X-Complaints-To: abuse@forwardemail.net X-ForwardEmail-Version: 0.4.40 X-ForwardEmail-Sender: rfc822; jonas@kwiboo.se, smtp.forwardemail.net, 149.28.215.223 X-ForwardEmail-ID: 65d0a7c30d665f4554622c06 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.8 at phobos.denx.de X-Virus-Status: Clean FIT checksum validation is very slow in SPL due to D-cache not being enabled. Enable caches in SPL on ARM64 SoCs to speed up FIT checksum validation, from seconds to milliseconds. This change enables caches in SPL on all Rockchip ARM64 boards, the Kconfig options SPL_SYS_ICACHE_OFF and SPL_SYS_DCACHE_OFF can be used to disable caches for a specific board or SoC if needed. Signed-off-by: Jonas Karlman Reviewed-by: Kever Yang --- Changes in v4: - Include cpu_func.h to fix build on armv7 - Remove common.h include Changes in v3: - Limit to ARM64 SoCs - Fix build with SPL_SYS_ICACHE_OFF or SPL_SYS_DCACHE_OFF enabled - Use cleanup_before_linux() in spl_board_prepare_for_boot() to disable caches before jumping from SPL to next stage - Collect r-b tag Changes in v2: - None This has been tested on multiple RK3328, RK3399, RK356x and RK3588 boards without any issues, vendor U-Boot also enables caches in SPL for all SoCs. This only worked on RK3288 because the default enable_caches() that does not enable caches was being used. Trying to enable caches on my RK3288 froze my boards in mmu_setup(). So v3 limits the enable_caches() call to only include ARM64 SoCs. Link to RFC: https://patchwork.ozlabs.org/patch/1802303/ Link to v2: https://patchwork.ozlabs.org/patch/1889319/ Link to v3: https://patchwork.ozlabs.org/patch/1891025/ --- arch/arm/mach-rockchip/spl.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/arch/arm/mach-rockchip/spl.c b/arch/arm/mach-rockchip/spl.c index 87280e2ba7cc..1586a093fc37 100644 --- a/arch/arm/mach-rockchip/spl.c +++ b/arch/arm/mach-rockchip/spl.c @@ -3,7 +3,7 @@ * (C) Copyright 2019 Rockchip Electronics Co., Ltd */ -#include +#include #include #include #include @@ -136,6 +136,20 @@ void board_init_f(ulong dummy) } gd->ram_top = gd->ram_base + get_effective_memsize(); gd->ram_top = board_get_usable_ram_top(gd->ram_size); + + if (IS_ENABLED(CONFIG_ARM64) && !CONFIG_IS_ENABLED(SYS_DCACHE_OFF)) { + gd->relocaddr = gd->ram_top; + arch_reserve_mmu(); + enable_caches(); + } #endif preloader_console_init(); } + +void spl_board_prepare_for_boot(void) +{ + if (!IS_ENABLED(CONFIG_ARM64) || CONFIG_IS_ENABLED(SYS_DCACHE_OFF)) + return; + + cleanup_before_linux(); +}