Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp602635imw; Thu, 14 Jul 2022 07:28:01 -0700 (PDT) X-Google-Smtp-Source: AGRyM1t5/+/VY961t38g6GeqziXY+ZTmZnIz9at2BJLYAnTdqQDy5LD8LkfPtIVbT6y6L/pTHbB6 X-Received: by 2002:a05:6402:540c:b0:434:d965:f8a with SMTP id ev12-20020a056402540c00b00434d9650f8amr12911570edb.30.1657808880945; Thu, 14 Jul 2022 07:28:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657808880; cv=none; d=google.com; s=arc-20160816; b=UXtp7e9yAZvfN/ubEacxvkLLsnEGBjf7ASSLU0D+WkFIfsIOO+ca+xlIPL48e2o73s C3h9VCgoFYQo0+sRq9vlCv9m2j2LzAKHmKsHdEkHHkFtHxZijb4pOo/97aSVBAO/ELOt bV6o9hPJZfGAXcROH7qVo/OhjAvlgMDu+qq8f8bsCGuA/Ljjn60j72B4GoDCgVC9KGP7 OK7plkLis0DiKgwlpifFTelwF8ox94WlvPryTqQpwyB/EP7ooMPsLRMFlffziq0gTkOP ZORHMI3A/Ll0M2eXZIadkm8bIvD9iUYifzZcKTEjaaLYLQjnllHyGOz/+boYZ5i5v3+v Aghg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id; bh=PwHYE55ZkVqDkZMOWEORojPBX4PkR655qYc05aKuulY=; b=Melox0dOEQIHNhNWQyX48EELiwmOj61WfYxjkkzzH/Tmi1hN64JzjnvjLHBIsUwwET 1+dqf/1h1u6izeV7EgAC645xWsJlEmieepAKtGVhOMULdfLH3r+IZUaQeKxSdiWfrRMA 93zbD9k1rWadV+t/6wyid2PgvCD/v1DPGfiMaDRpk8uwQYc87X6aSThUK+wz53OT0QFx G5Jz7tpcKBQWu91uUELBVoyd0A5/epy/3aeKUr2LiUtXJUrAzoOuqJ5d2n9N965KVC/N we8cc3J4SW0ChjZyGASeLRePeSYyjXlGXSFj+P3neFm+2chBw7OoQsP2qwpFMLNTtRrG dnXw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id sb13-20020a1709076d8d00b0072ac1a55095si2827023ejc.6.2022.07.14.07.27.26; Thu, 14 Jul 2022 07:28:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239960AbiGNNvE (ORCPT + 99 others); Thu, 14 Jul 2022 09:51:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46610 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240066AbiGNNuZ (ORCPT ); Thu, 14 Jul 2022 09:50:25 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 834295A2CB; Thu, 14 Jul 2022 06:50:17 -0700 (PDT) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 8C99F1D13; Thu, 14 Jul 2022 06:50:17 -0700 (PDT) Received: from [10.57.86.49] (unknown [10.57.86.49]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id E9D093F73D; Thu, 14 Jul 2022 06:50:15 -0700 (PDT) Message-ID: <590f7a08-a6ca-be54-4254-363343642a52@arm.com> Date: Thu, 14 Jul 2022 14:50:10 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; rv:91.0) Gecko/20100101 Thunderbird/91.11.0 Subject: Re: [PATCH] arm64: dts: rockchip: Fix SD card init on rk3399-nanopi4 Content-Language: en-GB To: =?UTF-8?Q?Christian_Kohlsch=c3=bctter?= Cc: =?UTF-8?Q?Heiko_St=c3=bcbner?= , linux-arm-kernel@lists.infradead.org, linux-rockchip@lists.infradead.org, linux-kernel@vger.kernel.org, Linux MMC List References: <12878108.O9o76ZdvQC@diego> <103b714c-b07c-f016-1062-84bd94786b22@arm.com> <9AF1E75F-5947-49B0-887D-82C426527B99@kohlschutter.com> From: Robin Murphy In-Reply-To: <9AF1E75F-5947-49B0-887D-82C426527B99@kohlschutter.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_DNSWL_HI,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2022-07-14 13:14, Christian Kohlschütter wrote: >> Am 14.07.2022 um 13:41 schrieb Robin Murphy : >> >> On 2022-07-14 00:41, Heiko Stübner wrote: >>> Hi Christian, >>> Am Donnerstag, 14. Juli 2022, 00:22:23 CEST schrieb Christian Kohlschütter: >>>> mmc/SD-card initialization may sometimes fail on NanoPi r4s with >>>> "mmc1: problem reading SD Status register" / >>>> "mmc1: error -110 whilst initialising SD card" >>>> >>>> Moreover, rebooting would also sometimes hang. >>>> >>> Nit: here the commit message should continue with something like: >>> ----- >>> This is caused by the vcc3v0-sd regulator referencing the wrong gpio. >>> Fix the regulator to use the correct pin and drop the always-on property. >>> ----- >>>> Signed-off-by: Christian Kohlschütter >>>> --- >>>> arch/arm64/boot/dts/rockchip/rk3399-nanopi4.dtsi | 6 +++--- >>>> 1 file changed, 3 insertions(+), 3 deletions(-) >>>> >>>> diff --git a/arch/arm64/boot/dts/rockchip/rk3399-nanopi4.dtsi b/arch/arm64/boot/dts/rockchip/rk3399-nanopi4.dtsi >>>> index 8c0ff6c96e03..91789801ab03 100644 >>>> --- a/arch/arm64/boot/dts/rockchip/rk3399-nanopi4.dtsi >>>> +++ b/arch/arm64/boot/dts/rockchip/rk3399-nanopi4.dtsi >>>> @@ -67,10 +67,10 @@ vcc1v8_s3: vcc1v8-s3 { >>>> vcc3v0_sd: vcc3v0-sd { >>>> compatible = "regulator-fixed"; >>>> enable-active-high; >>>> - gpio = <&gpio0 RK_PA1 GPIO_ACTIVE_HIGH>; >>>> + gpio = <&gpio0 RK_PD6 GPIO_ACTIVE_HIGH>; >>> The interesting question would be how nano-pi-specific that gpio is. >>> I.e. this is the rk3399-nanopi4.dtsi that is shared by multiple board types, >>> so can you check in schematics if gpio0-d6 is always used on all of them? >> >> On the R4S schematic, this is GPIO0_A1 same as the others. GPIO0 doesn't even have a bank D on RK3399, it only goes up to B5 :/ >> >>> Thanks >>> Heiko >>>> pinctrl-names = "default"; >>>> pinctrl-0 = <&sdmmc0_pwr_h>; >>>> - regulator-always-on; >>>> + regulator-boot-on; >>>> regulator-min-microvolt = <3000000>; >>>> regulator-max-microvolt = <3000000>; >>>> regulator-name = "vcc3v0_sd"; >>>> @@ -580,7 +580,7 @@ wifi_reg_on_h: wifi-reg_on-h { >>>> sdmmc { >>>> sdmmc0_det_l: sdmmc0-det-l { >>>> - rockchip,pins = <0 RK_PA7 RK_FUNC_GPIO &pcfg_pull_up>; >>>> + rockchip,pins = <0 RK_PD6 RK_FUNC_GPIO &pcfg_pull_up>; >> >> ...and claiming the card detect is on the same non-existent pin as the regulator enable is clearly even more wrong. >> >> Is this another case where a UHS card is involved, such that VCC_SDIO gets left at 1.8V after a reboot, so subsequent attempts to do the initial handshake where the card is expecting 3V logic levels fail? (AKA the Tinkerboard problem). Hobbling the regulator such that Linux can never actually turn VCC3V0_SD off, thus the card never gets reset, might appear to "work", but isn't the right thing to do. >> >> Robin. > > Right, this is all very strange. > > Indeed, I have a UHS card and the problem you describe. > I've actually looked into the other RK3399 dts files to come up with that patch (e.g. rk3399-roc-pc.dtsi, which does this; also see [1]) That patch is simply adding a description of the VCC3V0_SD regulator which is correct for that board (at least according to the roc-rk3399-pc-plus schematic that I could find); very different from breaking an existing already-correct description. > I understand that we should do the right thing, but I am by no means sure what the "right" thing for this problem is. > That said, I wished someone with expertise and authority in the mmc/rockchip community would fix this for good. > > There are several patches around this 1.8V/3V voltage dance that do work, get used by several distributions but didn't get merged to mainline because, well, there could be a better right thing to do (like [2], which is also still needed when using mainline u-boot). > > Given the state of this issue, at least aligning the code to match another board's fix — which already is in the mainline kernel — seems a sensible approach to me. It unblocks users like me who would perhaps otherwise just give up on using these devices. Indeed it's an unfortunate situation, and I'd like to see the "proper" solution too, but my point is more that this patch isn't even the correct way to do what this patch actually achieves. Tricking Linux into toggling a non-existent pin prevents it from turning this regulator off (or on, so we're already hoping that someone else has done that); however that's what the "regulator-always-on" property should already imply, so the patch should at least explain why we're taking this more drastic measure instead of trying to fix whatever causes the always-on property to apparently not be honoured. Furthermore, if it is justified to remove Linux's ability to control the regulator at all, then making up a bogus GPIO is still nonsensical (just remove it completely), and changing regulator-always-on to regulator-boot-on (saying that Linux *is* permitted to try to do the thing you're actively preventing it from doing) even more so. The other concern I have is whether this is really a sufficiently robust workaround anyway. I'm not familiar enough to know whether a soft-reset at potentially the wrong I/O voltage is something that all cards are going to handle reliably and without risk of damage. Furthermore, if a card reset happens anyway for any other reason, e.g. the user physically swaps cards during the reboot, then it's still not going to work. Thanks, Robin. > [1] https://lore.kernel.org/linux-mmc/3364813.APbW32NlgJ@phil/T/#m1b23cd2c43b600b5a6f084461ae53e482ad65316 > [2] https://patchwork.kernel.org/project/linux-mmc/patch/AM3PR03MB09664161A7FA2BD68B2800A7AC620@AM3PR03MB0966.eurprd03.prod.outlook.com/ >