All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Christian Kohlschütter" <christian@kohlschutter.com>
To: Robin Murphy <robin.murphy@arm.com>, wens@kernel.org
Cc: "Markus Reichl" <m.reichl@fivetechno.de>,
	"Heiko Stübner" <heiko@sntech.de>,
	linux-arm-kernel <linux-arm-kernel@lists.infradead.org>,
	"open list:ARM/Rockchip SoC..."
	<linux-rockchip@lists.infradead.org>,
	linux-kernel <linux-kernel@vger.kernel.org>,
	"Linux MMC List" <linux-mmc@vger.kernel.org>
Subject: Re: [PATCH v2] arm64: dts: rockchip: Fix SD card init on rk3399-nanopi4
Date: Thu, 14 Jul 2022 19:57:31 +0200	[thread overview]
Message-ID: <3DC86B72-41E7-47C2-8401-D511B8818972@kohlschutter.com> (raw)
In-Reply-To: <5ca9bd94-54d9-04f8-0098-a56ffb6f5fe1@arm.com>

Am 14.07.2022 um 19:35 schrieb Robin Murphy <robin.murphy@arm.com>:
> 
> On 14/07/2022 6:02 pm, Chen-Yu Tsai wrote:
>> On Fri, Jul 15, 2022 at 12:27 AM Christian Kohlschütter
>> <christian@kohlschutter.com> wrote:
>>> 
>>> mmc/SD-card initialization may fail on NanoPi r4s with
>>> "mmc1: problem reading SD Status register" /
>>> "mmc1: error -110 whilst initialising SD card"
>>> 
>>> Moreover, rebooting would also sometimes hang.
>>> 
>>> This is caused by the gpio entry for the vcc3v0-sd regulator;
>>> even though it appears to be the correct GPIO pin, the presence
>>> of the binding causes these errors.
>>> 
>>> Fix the regulator to drop the gpio binding and add a comment
>>> to prevent accidental reintroduction of that entry.
>>> 
>>> Signed-off-by: Christian Kohlschütter <christian@kohlschutter.com>
>>> ---
>>>  arch/arm64/boot/dts/rockchip/rk3399-nanopi4.dtsi | 2 +-
>>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>> 
>>> diff --git a/arch/arm64/boot/dts/rockchip/rk3399-nanopi4.dtsi b/arch/arm64/boot/dts/rockchip/rk3399-nanopi4.dtsi
>>> index 8c0ff6c96e03..d5f8a62e01be 100644
>>> --- a/arch/arm64/boot/dts/rockchip/rk3399-nanopi4.dtsi
>>> +++ b/arch/arm64/boot/dts/rockchip/rk3399-nanopi4.dtsi
>>> @@ -67,7 +67,7 @@ vcc1v8_s3: vcc1v8-s3 {
>>>         vcc3v0_sd: vcc3v0-sd {
>>>                 compatible = "regulator-fixed";
>>>                 enable-active-high;
>>> -               gpio = <&gpio0 RK_PA1 GPIO_ACTIVE_HIGH>;
>>> +               // gpio = <&gpio0 RK_PA1 GPIO_ACTIVE_HIGH>; // breaks SDHC card support
>> This change only means that the regulator no longer gets cycled when
>> it probes. It's not a proper fix. You're leaving the kernel without
>> any control over SD card power, and with whatever state the bootloader
>> left the GPIO in. If the bootloader left the GPIO low, then you don't
>> get to use the SD card, ever.

This is the current situation in the mainline kernel (regulator-always-on is there and unchanged), but yes, you are correct that's a bug.

See below for my results with your proposed changes.

>> It cycles because of the lack of regulator-boot-on, so the driver
>> requests the GPIO with initial low state, and then drives it
>> high to enable the regulator.
> 
> Hmm, that's a good point - by the time we get to Linux, we should have control over the VCC_SDIO regulator and the I/O domain as well, so a full clean reset should really be no problem :/
> 
> The "Tinkerboard problem" I was thinking of is when the SD card is the boot medium, VCC_SDIO stays at 1.8V over a reboot but the I/O domain gets reset back to 3.3V mode, thus cannot see a logic high on any of the I/O lines, thus the boot ROM gives up after failing to detect the card. If we're still able to boot as far as Linux, it's probably a different thing. Apologies for the confusion.

I believe it's that problem you describe.

In my case, I boot off the mmc card with u-boot mainline v2022.07, which invokes IPXE that boots the kernel (5.18.10 mainline) + rk3399-nanopi-r4s dtb over the network. 
This lets me quickly test kernel changes without juggling sd-cards.

> 
>>>                 pinctrl-names = "default";
>>>                 pinctrl-0 = <&sdmmc0_pwr_h>;
>>>                 regulator-always-on;
>> I think dropping "regulator-always-on" so that Linux can cycle power
>> and properly reset the SD card is the proper fix to the card being
>> stuck in UHS and not responding.
>> Also, the regulator used is RT9193, according to the schematics. That
>> chip has an enable delay under 50 micro-seconds. If that needs to be
>> modeled, then add regulator-enable-ramp-delay.
> 
> Indeed, if it's a slow regulator and we're simply trying to probe the card too soon before its supply voltage has actually stabilised, that sounds entirely plausible, particularly if the failure is only intermittent.

With
> gpio = <&gpio0 RK_PA1 GPIO_ACTIVE_HIGH>;
> // regulator-always-on;
> regulator-enable-ramp-delay = <50>;
I'm still not getting the reset going. It looks the MMC gets detected reliably upon cold start, but I cannot test reboot/warm start.

It looks like there's one issue upon start (which MAY be fixed by these changes), but there's another issue upon restart ("suspend" in device tree lingo?).
I tried both

> regulator-state-mem {
>         regulator-off-in-suspend;
> };    
and
> regulator-state-mem {
>         regulator-on-in-suspend;
> };
to no avail (no difference; reboot still hangs).

What are we missing?

Best,
Christian


WARNING: multiple messages have this Message-ID (diff)
From: "Christian Kohlschütter" <christian@kohlschutter.com>
To: Robin Murphy <robin.murphy@arm.com>, wens@kernel.org
Cc: "Markus Reichl" <m.reichl@fivetechno.de>,
	"Heiko Stübner" <heiko@sntech.de>,
	linux-arm-kernel <linux-arm-kernel@lists.infradead.org>,
	"open list:ARM/Rockchip SoC..."
	<linux-rockchip@lists.infradead.org>,
	linux-kernel <linux-kernel@vger.kernel.org>,
	"Linux MMC List" <linux-mmc@vger.kernel.org>
Subject: Re: [PATCH v2] arm64: dts: rockchip: Fix SD card init on rk3399-nanopi4
Date: Thu, 14 Jul 2022 19:57:31 +0200	[thread overview]
Message-ID: <3DC86B72-41E7-47C2-8401-D511B8818972@kohlschutter.com> (raw)
In-Reply-To: <5ca9bd94-54d9-04f8-0098-a56ffb6f5fe1@arm.com>

Am 14.07.2022 um 19:35 schrieb Robin Murphy <robin.murphy@arm.com>:
> 
> On 14/07/2022 6:02 pm, Chen-Yu Tsai wrote:
>> On Fri, Jul 15, 2022 at 12:27 AM Christian Kohlschütter
>> <christian@kohlschutter.com> wrote:
>>> 
>>> mmc/SD-card initialization may fail on NanoPi r4s with
>>> "mmc1: problem reading SD Status register" /
>>> "mmc1: error -110 whilst initialising SD card"
>>> 
>>> Moreover, rebooting would also sometimes hang.
>>> 
>>> This is caused by the gpio entry for the vcc3v0-sd regulator;
>>> even though it appears to be the correct GPIO pin, the presence
>>> of the binding causes these errors.
>>> 
>>> Fix the regulator to drop the gpio binding and add a comment
>>> to prevent accidental reintroduction of that entry.
>>> 
>>> Signed-off-by: Christian Kohlschütter <christian@kohlschutter.com>
>>> ---
>>>  arch/arm64/boot/dts/rockchip/rk3399-nanopi4.dtsi | 2 +-
>>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>> 
>>> diff --git a/arch/arm64/boot/dts/rockchip/rk3399-nanopi4.dtsi b/arch/arm64/boot/dts/rockchip/rk3399-nanopi4.dtsi
>>> index 8c0ff6c96e03..d5f8a62e01be 100644
>>> --- a/arch/arm64/boot/dts/rockchip/rk3399-nanopi4.dtsi
>>> +++ b/arch/arm64/boot/dts/rockchip/rk3399-nanopi4.dtsi
>>> @@ -67,7 +67,7 @@ vcc1v8_s3: vcc1v8-s3 {
>>>         vcc3v0_sd: vcc3v0-sd {
>>>                 compatible = "regulator-fixed";
>>>                 enable-active-high;
>>> -               gpio = <&gpio0 RK_PA1 GPIO_ACTIVE_HIGH>;
>>> +               // gpio = <&gpio0 RK_PA1 GPIO_ACTIVE_HIGH>; // breaks SDHC card support
>> This change only means that the regulator no longer gets cycled when
>> it probes. It's not a proper fix. You're leaving the kernel without
>> any control over SD card power, and with whatever state the bootloader
>> left the GPIO in. If the bootloader left the GPIO low, then you don't
>> get to use the SD card, ever.

This is the current situation in the mainline kernel (regulator-always-on is there and unchanged), but yes, you are correct that's a bug.

See below for my results with your proposed changes.

>> It cycles because of the lack of regulator-boot-on, so the driver
>> requests the GPIO with initial low state, and then drives it
>> high to enable the regulator.
> 
> Hmm, that's a good point - by the time we get to Linux, we should have control over the VCC_SDIO regulator and the I/O domain as well, so a full clean reset should really be no problem :/
> 
> The "Tinkerboard problem" I was thinking of is when the SD card is the boot medium, VCC_SDIO stays at 1.8V over a reboot but the I/O domain gets reset back to 3.3V mode, thus cannot see a logic high on any of the I/O lines, thus the boot ROM gives up after failing to detect the card. If we're still able to boot as far as Linux, it's probably a different thing. Apologies for the confusion.

I believe it's that problem you describe.

In my case, I boot off the mmc card with u-boot mainline v2022.07, which invokes IPXE that boots the kernel (5.18.10 mainline) + rk3399-nanopi-r4s dtb over the network. 
This lets me quickly test kernel changes without juggling sd-cards.

> 
>>>                 pinctrl-names = "default";
>>>                 pinctrl-0 = <&sdmmc0_pwr_h>;
>>>                 regulator-always-on;
>> I think dropping "regulator-always-on" so that Linux can cycle power
>> and properly reset the SD card is the proper fix to the card being
>> stuck in UHS and not responding.
>> Also, the regulator used is RT9193, according to the schematics. That
>> chip has an enable delay under 50 micro-seconds. If that needs to be
>> modeled, then add regulator-enable-ramp-delay.
> 
> Indeed, if it's a slow regulator and we're simply trying to probe the card too soon before its supply voltage has actually stabilised, that sounds entirely plausible, particularly if the failure is only intermittent.

With
> gpio = <&gpio0 RK_PA1 GPIO_ACTIVE_HIGH>;
> // regulator-always-on;
> regulator-enable-ramp-delay = <50>;
I'm still not getting the reset going. It looks the MMC gets detected reliably upon cold start, but I cannot test reboot/warm start.

It looks like there's one issue upon start (which MAY be fixed by these changes), but there's another issue upon restart ("suspend" in device tree lingo?).
I tried both

> regulator-state-mem {
>         regulator-off-in-suspend;
> };    
and
> regulator-state-mem {
>         regulator-on-in-suspend;
> };
to no avail (no difference; reboot still hangs).

What are we missing?

Best,
Christian


_______________________________________________
Linux-rockchip mailing list
Linux-rockchip@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-rockchip

WARNING: multiple messages have this Message-ID (diff)
From: "Christian Kohlschütter" <christian@kohlschutter.com>
To: Robin Murphy <robin.murphy@arm.com>, wens@kernel.org
Cc: "Markus Reichl" <m.reichl@fivetechno.de>,
	"Heiko Stübner" <heiko@sntech.de>,
	linux-arm-kernel <linux-arm-kernel@lists.infradead.org>,
	"open list:ARM/Rockchip SoC..."
	<linux-rockchip@lists.infradead.org>,
	linux-kernel <linux-kernel@vger.kernel.org>,
	"Linux MMC List" <linux-mmc@vger.kernel.org>
Subject: Re: [PATCH v2] arm64: dts: rockchip: Fix SD card init on rk3399-nanopi4
Date: Thu, 14 Jul 2022 19:57:31 +0200	[thread overview]
Message-ID: <3DC86B72-41E7-47C2-8401-D511B8818972@kohlschutter.com> (raw)
In-Reply-To: <5ca9bd94-54d9-04f8-0098-a56ffb6f5fe1@arm.com>

Am 14.07.2022 um 19:35 schrieb Robin Murphy <robin.murphy@arm.com>:
> 
> On 14/07/2022 6:02 pm, Chen-Yu Tsai wrote:
>> On Fri, Jul 15, 2022 at 12:27 AM Christian Kohlschütter
>> <christian@kohlschutter.com> wrote:
>>> 
>>> mmc/SD-card initialization may fail on NanoPi r4s with
>>> "mmc1: problem reading SD Status register" /
>>> "mmc1: error -110 whilst initialising SD card"
>>> 
>>> Moreover, rebooting would also sometimes hang.
>>> 
>>> This is caused by the gpio entry for the vcc3v0-sd regulator;
>>> even though it appears to be the correct GPIO pin, the presence
>>> of the binding causes these errors.
>>> 
>>> Fix the regulator to drop the gpio binding and add a comment
>>> to prevent accidental reintroduction of that entry.
>>> 
>>> Signed-off-by: Christian Kohlschütter <christian@kohlschutter.com>
>>> ---
>>>  arch/arm64/boot/dts/rockchip/rk3399-nanopi4.dtsi | 2 +-
>>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>> 
>>> diff --git a/arch/arm64/boot/dts/rockchip/rk3399-nanopi4.dtsi b/arch/arm64/boot/dts/rockchip/rk3399-nanopi4.dtsi
>>> index 8c0ff6c96e03..d5f8a62e01be 100644
>>> --- a/arch/arm64/boot/dts/rockchip/rk3399-nanopi4.dtsi
>>> +++ b/arch/arm64/boot/dts/rockchip/rk3399-nanopi4.dtsi
>>> @@ -67,7 +67,7 @@ vcc1v8_s3: vcc1v8-s3 {
>>>         vcc3v0_sd: vcc3v0-sd {
>>>                 compatible = "regulator-fixed";
>>>                 enable-active-high;
>>> -               gpio = <&gpio0 RK_PA1 GPIO_ACTIVE_HIGH>;
>>> +               // gpio = <&gpio0 RK_PA1 GPIO_ACTIVE_HIGH>; // breaks SDHC card support
>> This change only means that the regulator no longer gets cycled when
>> it probes. It's not a proper fix. You're leaving the kernel without
>> any control over SD card power, and with whatever state the bootloader
>> left the GPIO in. If the bootloader left the GPIO low, then you don't
>> get to use the SD card, ever.

This is the current situation in the mainline kernel (regulator-always-on is there and unchanged), but yes, you are correct that's a bug.

See below for my results with your proposed changes.

>> It cycles because of the lack of regulator-boot-on, so the driver
>> requests the GPIO with initial low state, and then drives it
>> high to enable the regulator.
> 
> Hmm, that's a good point - by the time we get to Linux, we should have control over the VCC_SDIO regulator and the I/O domain as well, so a full clean reset should really be no problem :/
> 
> The "Tinkerboard problem" I was thinking of is when the SD card is the boot medium, VCC_SDIO stays at 1.8V over a reboot but the I/O domain gets reset back to 3.3V mode, thus cannot see a logic high on any of the I/O lines, thus the boot ROM gives up after failing to detect the card. If we're still able to boot as far as Linux, it's probably a different thing. Apologies for the confusion.

I believe it's that problem you describe.

In my case, I boot off the mmc card with u-boot mainline v2022.07, which invokes IPXE that boots the kernel (5.18.10 mainline) + rk3399-nanopi-r4s dtb over the network. 
This lets me quickly test kernel changes without juggling sd-cards.

> 
>>>                 pinctrl-names = "default";
>>>                 pinctrl-0 = <&sdmmc0_pwr_h>;
>>>                 regulator-always-on;
>> I think dropping "regulator-always-on" so that Linux can cycle power
>> and properly reset the SD card is the proper fix to the card being
>> stuck in UHS and not responding.
>> Also, the regulator used is RT9193, according to the schematics. That
>> chip has an enable delay under 50 micro-seconds. If that needs to be
>> modeled, then add regulator-enable-ramp-delay.
> 
> Indeed, if it's a slow regulator and we're simply trying to probe the card too soon before its supply voltage has actually stabilised, that sounds entirely plausible, particularly if the failure is only intermittent.

With
> gpio = <&gpio0 RK_PA1 GPIO_ACTIVE_HIGH>;
> // regulator-always-on;
> regulator-enable-ramp-delay = <50>;
I'm still not getting the reset going. It looks the MMC gets detected reliably upon cold start, but I cannot test reboot/warm start.

It looks like there's one issue upon start (which MAY be fixed by these changes), but there's another issue upon restart ("suspend" in device tree lingo?).
I tried both

> regulator-state-mem {
>         regulator-off-in-suspend;
> };    
and
> regulator-state-mem {
>         regulator-on-in-suspend;
> };
to no avail (no difference; reboot still hangs).

What are we missing?

Best,
Christian


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  reply	other threads:[~2022-07-14 17:57 UTC|newest]

Thread overview: 87+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-13 22:22 [PATCH] arm64: dts: rockchip: Fix SD card init on rk3399-nanopi4 Christian Kohlschütter
2022-07-13 22:22 ` Christian Kohlschütter
2022-07-13 22:22 ` Christian Kohlschütter
2022-07-13 23:41 ` Heiko Stübner
2022-07-13 23:41   ` Heiko Stübner
2022-07-13 23:41   ` Heiko Stübner
2022-07-14 11:41   ` Robin Murphy
2022-07-14 11:41     ` Robin Murphy
2022-07-14 11:41     ` Robin Murphy
2022-07-14 12:14     ` Christian Kohlschütter
2022-07-14 12:14       ` Christian Kohlschütter
2022-07-14 12:14       ` Christian Kohlschütter
2022-07-14 13:14       ` Markus Reichl
2022-07-14 13:14         ` Markus Reichl
2022-07-14 13:14         ` Markus Reichl
2022-07-14 13:50       ` Robin Murphy
2022-07-14 13:50         ` Robin Murphy
2022-07-14 13:50         ` Robin Murphy
2022-07-14 16:24         ` Christian Kohlschütter
2022-07-14 16:24           ` Christian Kohlschütter
2022-07-14 16:24           ` Christian Kohlschütter
2022-07-14 16:26           ` [PATCH v2] " Christian Kohlschütter
2022-07-14 16:26             ` Christian Kohlschütter
2022-07-14 16:26             ` Christian Kohlschütter
2022-07-14 16:44             ` Christian Loehle
2022-07-14 16:44               ` Christian Loehle
2022-07-14 16:44               ` Christian Loehle
2022-07-14 17:20               ` Christian Kohlschütter
2022-07-14 17:20                 ` Christian Kohlschütter
2022-07-14 17:20                 ` Christian Kohlschütter
2022-07-15 17:02                 ` Christian Loehle
2022-07-15 17:02                   ` Christian Loehle
2022-07-15 17:02                   ` Christian Loehle
2022-07-14 17:02             ` Chen-Yu Tsai
2022-07-14 17:02               ` Chen-Yu Tsai
2022-07-14 17:02               ` Chen-Yu Tsai
2022-07-14 17:35               ` Robin Murphy
2022-07-14 17:35                 ` Robin Murphy
2022-07-14 17:35                 ` Robin Murphy
2022-07-14 17:57                 ` Christian Kohlschütter [this message]
2022-07-14 17:57                   ` Christian Kohlschütter
2022-07-14 17:57                   ` Christian Kohlschütter
2022-07-14 23:44                 ` Robin Murphy
2022-07-14 23:44                   ` Robin Murphy
2022-07-14 23:44                   ` Robin Murphy
2022-07-15 17:01                   ` [PATCH v3] " Christian Kohlschütter
2022-07-15 17:01                     ` Christian Kohlschütter
2022-07-15 17:01                     ` Christian Kohlschütter
2022-07-15 17:12                     ` [PATCH v4] " Christian Kohlschütter
2022-07-15 17:12                       ` Christian Kohlschütter
2022-07-15 17:12                       ` Christian Kohlschütter
2022-07-15 17:16                       ` Christian Kohlschütter
2022-07-15 17:16                         ` Christian Kohlschütter
2022-07-15 17:16                         ` Christian Kohlschütter
2022-07-15 18:11                         ` Robin Murphy
2022-07-15 18:11                           ` Robin Murphy
2022-07-15 18:11                           ` Robin Murphy
2022-07-15 18:57                           ` Christian Kohlschütter
2022-07-15 18:57                             ` Christian Kohlschütter
2022-07-15 18:57                             ` Christian Kohlschütter
2022-07-15 18:57                           ` Robin Murphy
2022-07-15 18:57                             ` Robin Murphy
2022-07-15 18:57                             ` Robin Murphy
2022-07-15 19:04                             ` Christian Kohlschütter
2022-07-15 19:04                               ` Christian Kohlschütter
2022-07-15 19:04                               ` Christian Kohlschütter
2022-07-15 19:38                               ` Robin Murphy
2022-07-15 19:38                                 ` Robin Murphy
2022-07-15 19:38                                 ` Robin Murphy
2022-07-15 22:33                                 ` Christian Kohlschütter
2022-07-15 22:33                                   ` Christian Kohlschütter
2022-07-15 22:33                                   ` Christian Kohlschütter
2022-07-16  0:24                                   ` Christian Kohlschütter
2022-07-16  0:24                                     ` Christian Kohlschütter
2022-07-16  0:24                                     ` Christian Kohlschütter
2022-07-16 19:43                                     ` [PATCH v5] " Christian Kohlschütter
2022-07-16 19:43                                       ` Christian Kohlschütter
2022-07-16 19:43                                       ` Christian Kohlschütter
2022-07-18 12:04                                       ` [PATCH v6] " Christian Kohlschütter
2022-07-18 12:04                                         ` Christian Kohlschütter
2022-07-18 12:04                                         ` Christian Kohlschütter
2022-07-18 12:05                                         ` Christian Kohlschütter
2022-07-18 12:05                                           ` Christian Kohlschütter
2022-07-18 12:05                                           ` Christian Kohlschütter
2022-07-18 21:04                                           ` Christian Kohlschütter
2022-07-18 21:04                                             ` Christian Kohlschütter
2022-07-18 21:04                                             ` Christian Kohlschütter

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3DC86B72-41E7-47C2-8401-D511B8818972@kohlschutter.com \
    --to=christian@kohlschutter.com \
    --cc=heiko@sntech.de \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mmc@vger.kernel.org \
    --cc=linux-rockchip@lists.infradead.org \
    --cc=m.reichl@fivetechno.de \
    --cc=robin.murphy@arm.com \
    --cc=wens@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.