From patchwork Tue Nov 5 17:21:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Quentin Schulz X-Patchwork-Id: 2007027 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; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (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 4XjZsK38XBz1xxN for ; Wed, 6 Nov 2024 04:22:29 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 707CC88D09; Tue, 5 Nov 2024 18:22:14 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=0leil.net Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by phobos.denx.de (Postfix, from userid 109) id D0696891DD; Tue, 5 Nov 2024 18:22:13 +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.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED,RCVD_IN_VALIDITY_RPBL_BLOCKED, SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from smtp-bc0d.mail.infomaniak.ch (smtp-bc0d.mail.infomaniak.ch [45.157.188.13]) (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 80E7D8919A for ; Tue, 5 Nov 2024 18:22:10 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=0leil.net Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=foss+uboot@0leil.net Received: from smtp-4-0000.mail.infomaniak.ch (smtp-4-0000.mail.infomaniak.ch [10.7.10.107]) by smtp-4-3000.mail.infomaniak.ch (Postfix) with ESMTPS id 4XjZry1GRZzVsf; Tue, 5 Nov 2024 18:22:10 +0100 (CET) Received: from unknown by smtp-4-0000.mail.infomaniak.ch (Postfix) with ESMTPA id 4XjZrx4ThHzyF7; Tue, 5 Nov 2024 18:22:09 +0100 (CET) From: Quentin Schulz Date: Tue, 05 Nov 2024 18:21:55 +0100 Subject: [PATCH next RFC 1/5] ram: rk3399: allow to fail DRAM init if pctl_start fails MIME-Version: 1.0 Message-Id: <20241105-rk3399-dram-init-v1-1-1e29acdf0966@cherry.de> References: <20241105-rk3399-dram-init-v1-0-1e29acdf0966@cherry.de> In-Reply-To: <20241105-rk3399-dram-init-v1-0-1e29acdf0966@cherry.de> To: Simon Glass , Philipp Tomsich , Kever Yang , Tom Rini Cc: u-boot@lists.denx.de, Dragan Simic , Quentin Schulz X-Mailer: b4 0.14.2 X-Infomaniak-Routing: alpha 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 From: Quentin Schulz pctl_start() can fail but how this is handled currently is by calling hang() directly in the driver instead of propagating the error and letting other code handling it. This prepares for a future commit which removes the hang() in favor of letting Rockchip's arch code handle it in a common place. No change in behavior expected in this commit. Signed-off-by: Quentin Schulz --- drivers/ram/rockchip/sdram_rk3399.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/drivers/ram/rockchip/sdram_rk3399.c b/drivers/ram/rockchip/sdram_rk3399.c index 6fa8f268770d1c6d69431857e115264957d75703..63d7852555cea3296b7cd9eed422c4d5d1c9776b 100644 --- a/drivers/ram/rockchip/sdram_rk3399.c +++ b/drivers/ram/rockchip/sdram_rk3399.c @@ -791,9 +791,9 @@ static void set_ds_odt(const struct chan_info *chan, phy_io_config(denali_phy, denali_ctl, params, mr5); } -static void pctl_start(struct dram_info *dram, - struct rk3399_sdram_params *params, - u32 channel_mask) +static int pctl_start(struct dram_info *dram, + struct rk3399_sdram_params *params, + u32 channel_mask) { const struct chan_info *chan_0 = &dram->chan[0]; const struct chan_info *chan_1 = &dram->chan[1]; @@ -892,6 +892,8 @@ static void pctl_start(struct dram_info *dram, params->phy_regs.denali_phy[937] & 0xFF); } + + return 0; } static int pctl_cfg(struct dram_info *dram, const struct chan_info *chan, @@ -2940,7 +2942,8 @@ static int sdram_init(struct dram_info *dram, } /* start to trigger initialization */ - pctl_start(dram, params, 3); + if (pctl_start(dram, params, 3)) + return -EINVAL; /* LPDDR2/LPDDR3 need to wait DAI complete, max 10us */ if (dramtype == LPDDR3) From patchwork Tue Nov 5 17:21:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Quentin Schulz X-Patchwork-Id: 2007028 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; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (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 4XjZsN5D36z1xxN for ; Wed, 6 Nov 2024 04:22:32 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id C20F4891B2; Tue, 5 Nov 2024 18:22:14 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=0leil.net Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by phobos.denx.de (Postfix, from userid 109) id E03348919A; Tue, 5 Nov 2024 18:22:13 +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.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from smtp-bc0b.mail.infomaniak.ch (smtp-bc0b.mail.infomaniak.ch [IPv6:2001:1600:7:10::bc0b]) (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 603A7891C0 for ; Tue, 5 Nov 2024 18:22:11 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=0leil.net Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=foss+uboot@0leil.net Received: from smtp-4-0000.mail.infomaniak.ch (unknown [IPv6:2001:1600:7:10:40ca:feff:fe05:0]) by smtp-4-3000.mail.infomaniak.ch (Postfix) with ESMTPS id 4XjZrz09ZTzXjw; Tue, 5 Nov 2024 18:22:11 +0100 (CET) Received: from unknown by smtp-4-0000.mail.infomaniak.ch (Postfix) with ESMTPA id 4XjZry18Qjzxlq; Tue, 5 Nov 2024 18:22:10 +0100 (CET) From: Quentin Schulz Date: Tue, 05 Nov 2024 18:21:56 +0100 Subject: [PATCH next RFC 2/5] ram: rk3399: fail probe if DRAM init failed MIME-Version: 1.0 Message-Id: <20241105-rk3399-dram-init-v1-2-1e29acdf0966@cherry.de> References: <20241105-rk3399-dram-init-v1-0-1e29acdf0966@cherry.de> In-Reply-To: <20241105-rk3399-dram-init-v1-0-1e29acdf0966@cherry.de> To: Simon Glass , Philipp Tomsich , Kever Yang , Tom Rini Cc: u-boot@lists.denx.de, Dragan Simic , Quentin Schulz X-Mailer: b4 0.14.2 X-Infomaniak-Routing: alpha 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 From: Quentin Schulz We should fail the probe of the DRAM device if the DRAM init failed so let's return a negative error-code if rk3399_dmc_init returns non-zero. Signed-off-by: Quentin Schulz --- drivers/ram/rockchip/sdram_rk3399.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/ram/rockchip/sdram_rk3399.c b/drivers/ram/rockchip/sdram_rk3399.c index 63d7852555cea3296b7cd9eed422c4d5d1c9776b..5a82c7ccbdf161526f0d1450dde6881441e59543 100644 --- a/drivers/ram/rockchip/sdram_rk3399.c +++ b/drivers/ram/rockchip/sdram_rk3399.c @@ -3157,7 +3157,7 @@ static int rk3399_dmc_probe(struct udevice *dev) priv->pmugrf = syscon_get_first_range(ROCKCHIP_SYSCON_PMUGRF); debug("%s: pmugrf = %p\n", __func__, priv->pmugrf); if (phase_sdram_init() && rk3399_dmc_init(dev)) - return 0; + return -EINVAL; /* * There is no point in checking the SDRAM size in TPL as it is not From patchwork Tue Nov 5 17:21:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Quentin Schulz X-Patchwork-Id: 2007029 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; 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 4XjZsY2dXnz1xxN for ; Wed, 6 Nov 2024 04:22:41 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 228B4891C7; Tue, 5 Nov 2024 18:22:15 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=0leil.net Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by phobos.denx.de (Postfix, from userid 109) id F1D70891A6; Tue, 5 Nov 2024 18:22:13 +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.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H2, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED,RCVD_IN_VALIDITY_RPBL_BLOCKED, SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from smtp-42af.mail.infomaniak.ch (smtp-42af.mail.infomaniak.ch [84.16.66.175]) (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 EE1F2881E7 for ; Tue, 5 Nov 2024 18:22:11 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=0leil.net Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=foss+uboot@0leil.net Received: from smtp-4-0000.mail.infomaniak.ch (smtp-4-0000.mail.infomaniak.ch [10.7.10.107]) by smtp-4-3000.mail.infomaniak.ch (Postfix) with ESMTPS id 4XjZrz4c3HzVhD; Tue, 5 Nov 2024 18:22:11 +0100 (CET) Received: from unknown by smtp-4-0000.mail.infomaniak.ch (Postfix) with ESMTPA id 4XjZrz03B7zxWn; Tue, 5 Nov 2024 18:22:10 +0100 (CET) From: Quentin Schulz Date: Tue, 05 Nov 2024 18:21:57 +0100 Subject: [PATCH next RFC 3/5] rockchip: spl/tpl: panic when DRAM init failed MIME-Version: 1.0 Message-Id: <20241105-rk3399-dram-init-v1-3-1e29acdf0966@cherry.de> References: <20241105-rk3399-dram-init-v1-0-1e29acdf0966@cherry.de> In-Reply-To: <20241105-rk3399-dram-init-v1-0-1e29acdf0966@cherry.de> To: Simon Glass , Philipp Tomsich , Kever Yang , Tom Rini Cc: u-boot@lists.denx.de, Dragan Simic , Quentin Schulz X-Mailer: b4 0.14.2 X-Infomaniak-Routing: alpha 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 From: Quentin Schulz A failed DRAM init is synonym with a broken board, so let's panic instead of silently skipping the rest of the xPL stage and making it fail later in some other code parts. This also has the benefit of (by default) resetting the CPU which could help recover the device without human intervention were the DRAM init issue related to not-100%-reproducibly fail the DRAM init. Signed-off-by: Quentin Schulz --- arch/arm/mach-rockchip/spl.c | 7 +++---- arch/arm/mach-rockchip/tpl.c | 6 ++---- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/arch/arm/mach-rockchip/spl.c b/arch/arm/mach-rockchip/spl.c index f4d29bbdd17e8b57dc0b2fdd90a8600fba6ee866..9b2d7023fb862bf696ad376b6f0b30e834aa41be 100644 --- a/arch/arm/mach-rockchip/spl.c +++ b/arch/arm/mach-rockchip/spl.c @@ -112,10 +112,9 @@ void board_init_f(ulong dummy) #if !defined(CONFIG_TPL) || defined(CONFIG_SPL_RAM) debug("\nspl:init dram\n"); ret = dram_init(); - if (ret) { - printf("DRAM init failed: %d\n", ret); - return; - } + if (ret) + panic("DRAM init failed: %d\n", ret); + gd->ram_top = gd->ram_base + get_effective_memsize(); gd->ram_top = board_get_usable_ram_top(gd->ram_size); diff --git a/arch/arm/mach-rockchip/tpl.c b/arch/arm/mach-rockchip/tpl.c index bbb9329e725af79ea4c4049aa7890a4a143e7df5..5da23913c147cab18377f09b566f28b0bee4e935 100644 --- a/arch/arm/mach-rockchip/tpl.c +++ b/arch/arm/mach-rockchip/tpl.c @@ -55,10 +55,8 @@ void board_init_f(ulong dummy) timer_init(); ret = uclass_get_device(UCLASS_RAM, 0, &dev); - if (ret) { - printf("DRAM init failed: %d\n", ret); - return; - } + if (ret) + panic("DRAM init failed: %d\n", ret); } int board_return_to_bootrom(struct spl_image_info *spl_image, From patchwork Tue Nov 5 17:21:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Quentin Schulz X-Patchwork-Id: 2007030 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; 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 4XjZsk2fJrz1xxN for ; Wed, 6 Nov 2024 04:22:50 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 89582891CF; Tue, 5 Nov 2024 18:22:16 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=0leil.net Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by phobos.denx.de (Postfix, from userid 109) id C0AF8891DD; Tue, 5 Nov 2024 18:22:15 +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.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from smtp-8fa9.mail.infomaniak.ch (smtp-8fa9.mail.infomaniak.ch [IPv6:2001:1600:7:10::8fa9]) (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 87BE288C44 for ; Tue, 5 Nov 2024 18:22:12 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=0leil.net Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=foss+uboot@0leil.net Received: from smtp-4-0000.mail.infomaniak.ch (smtp-4-0000.mail.infomaniak.ch [10.7.10.107]) by smtp-4-3000.mail.infomaniak.ch (Postfix) with ESMTPS id 4XjZs01RBHzW2F; Tue, 5 Nov 2024 18:22:12 +0100 (CET) Received: from unknown by smtp-4-0000.mail.infomaniak.ch (Postfix) with ESMTPA id 4XjZrz4YJWz14Q; Tue, 5 Nov 2024 18:22:11 +0100 (CET) From: Quentin Schulz Date: Tue, 05 Nov 2024 18:21:58 +0100 Subject: [PATCH next RFC 4/5] ram: rk3399: merge two consecutive ifs with same condition MIME-Version: 1.0 Message-Id: <20241105-rk3399-dram-init-v1-4-1e29acdf0966@cherry.de> References: <20241105-rk3399-dram-init-v1-0-1e29acdf0966@cherry.de> In-Reply-To: <20241105-rk3399-dram-init-v1-0-1e29acdf0966@cherry.de> To: Simon Glass , Philipp Tomsich , Kever Yang , Tom Rini Cc: u-boot@lists.denx.de, Dragan Simic , Quentin Schulz X-Mailer: b4 0.14.2 X-Infomaniak-Routing: alpha 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 From: Quentin Schulz Nothing changes channel_mask in the first if block of the same condition so it is safe to merge the two if blocks with the same condition into one. No intended change in behavior. Signed-off-by: Quentin Schulz --- drivers/ram/rockchip/sdram_rk3399.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/drivers/ram/rockchip/sdram_rk3399.c b/drivers/ram/rockchip/sdram_rk3399.c index 5a82c7ccbdf161526f0d1450dde6881441e59543..d953dda13cd3daa689fa362dc511c372db454064 100644 --- a/drivers/ram/rockchip/sdram_rk3399.c +++ b/drivers/ram/rockchip/sdram_rk3399.c @@ -811,9 +811,7 @@ static int pctl_start(struct dram_info *dram, if (channel_mask & 1) { writel(0x01000000, &ddrc0_con_0); clrsetbits_le32(&denali_phy_0[957], 0x3 << 24, 0x2 << 24); - } - if (channel_mask & 1) { count = 0; while (!(readl(&denali_ctl_0[203]) & (1 << 3))) { if (count > 1000) { @@ -849,8 +847,7 @@ static int pctl_start(struct dram_info *dram, if (channel_mask & 2) { writel(0x01000000, &ddrc1_con_0); clrsetbits_le32(&denali_phy_1[957], 0x3 << 24, 0x2 << 24); - } - if (channel_mask & 2) { + count = 0; while (!(readl(&denali_ctl_1[203]) & (1 << 3))) { if (count > 1000) { From patchwork Tue Nov 5 17:21:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Quentin Schulz X-Patchwork-Id: 2007031 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; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (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 4XjZsw1dZNz1xxN for ; Wed, 6 Nov 2024 04:23:00 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id E1309891E4; Tue, 5 Nov 2024 18:22:16 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=0leil.net Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by phobos.denx.de (Postfix, from userid 109) id 089A488C44; Tue, 5 Nov 2024 18:22:16 +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.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H2, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED,RCVD_IN_VALIDITY_RPBL_BLOCKED, SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from smtp-8faf.mail.infomaniak.ch (smtp-8faf.mail.infomaniak.ch [83.166.143.175]) (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 26D1A891D4 for ; Tue, 5 Nov 2024 18:22:13 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=0leil.net Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=foss+uboot@0leil.net Received: from smtp-4-0000.mail.infomaniak.ch (unknown [IPv6:2001:1600:7:10:40ca:feff:fe05:0]) by smtp-4-3000.mail.infomaniak.ch (Postfix) with ESMTPS id 4XjZs05yPkzXgJ; Tue, 5 Nov 2024 18:22:12 +0100 (CET) Received: from unknown by smtp-4-0000.mail.infomaniak.ch (Postfix) with ESMTPA id 4XjZs01K16zxB5; Tue, 5 Nov 2024 18:22:12 +0100 (CET) From: Quentin Schulz Date: Tue, 05 Nov 2024 18:21:59 +0100 Subject: [PATCH next RFC 5/5] ram: rk3399: fail DRAM init when pctl channel init fails instead of hanging MIME-Version: 1.0 Message-Id: <20241105-rk3399-dram-init-v1-5-1e29acdf0966@cherry.de> References: <20241105-rk3399-dram-init-v1-0-1e29acdf0966@cherry.de> In-Reply-To: <20241105-rk3399-dram-init-v1-0-1e29acdf0966@cherry.de> To: Simon Glass , Philipp Tomsich , Kever Yang , Tom Rini Cc: u-boot@lists.denx.de, Dragan Simic , Quentin Schulz X-Mailer: b4 0.14.2 X-Infomaniak-Routing: alpha 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 From: Quentin Schulz Instead of hanging via an infinite while loop, propagate the fail to the caller and let it handle the fail. For RK3399, this means that panic() will be called, (by default) resetting the CPU and giving another chance at doing a DRAM init. Signed-off-by: Quentin Schulz --- drivers/ram/rockchip/sdram_rk3399.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/ram/rockchip/sdram_rk3399.c b/drivers/ram/rockchip/sdram_rk3399.c index d953dda13cd3daa689fa362dc511c372db454064..591e1469afb25ba606d8f7e44f63e50905b4ab31 100644 --- a/drivers/ram/rockchip/sdram_rk3399.c +++ b/drivers/ram/rockchip/sdram_rk3399.c @@ -817,8 +817,7 @@ static int pctl_start(struct dram_info *dram, if (count > 1000) { printf("%s: Failed to init pctl channel 0\n", __func__); - while (1) - ; + return -1; } udelay(1); count++; @@ -853,8 +852,7 @@ static int pctl_start(struct dram_info *dram, if (count > 1000) { printf("%s: Failed to init pctl channel 1\n", __func__); - while (1) - ; + return -2; } udelay(1); count++;