linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [RFC 0/2] sdhci-iproc CMD timeouts
@ 2021-02-25  9:52 Nicolas Saenz Julienne
  2021-02-25  9:52 ` [RFC 1/2] ARM: dts: Fix-up EMMC2 controller's frequency Nicolas Saenz Julienne
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Nicolas Saenz Julienne @ 2021-02-25  9:52 UTC (permalink / raw)
  To: linux-arm-kernel, linux-mmc, devicetree,
	bcm-kernel-feedback-list, linux-rpi-kernel
  Cc: f.fainelli, tim.gover, sbranden, alcooperx, adrian.hunter,
	linux-kernel, phil, Nicolas Saenz Julienne

I'm seeing a rather odd behavior from sdhci-iproc's integration in BCM2711
(Raspberry Pi 4's SoC), and would appreciate some opinions.

The controller will timeout on SDHCI CMDs under the following conditions:

 - No SD card plugged in (the card polling thread is running, CD irq disabled).
 - BCM2711's VPU clock[1] configured at 500MHz or more, lower clocks are OK.

There is no specific command that will time out, it seems random.

Here's what I found out. The SDHCI controller runs at 100MHz, by bumping the
frequency to 150MHz the issue disapears. Might be pure luck, or maybe I hit the
nail and it's proper interference. Can't say.

Regards,
Nicolas

---

[1] For those who are not aware, here's the relationship between VPU's clock
    and emmc2's:

	 osc                                    54000000
	    plld                              3000000091
	       plld_per                        750000023
		  emmc2                        149882908
	    pllc                              2999999988
	       pllc_core0                      999999996
		  vpu                          499999998

Nicolas Saenz Julienne (2):
  ARM: dts: Fix-up EMMC2 controller's frequency
  mmc: sdhci-iproc: Set clock frequency as per DT

 arch/arm/boot/dts/bcm2711-rpi-4-b.dts |  6 ++++++
 drivers/mmc/host/sdhci-iproc.c        | 10 ++++++++++
 2 files changed, 16 insertions(+)

-- 
2.30.1


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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [RFC 1/2] ARM: dts: Fix-up EMMC2 controller's frequency
  2021-02-25  9:52 [RFC 0/2] sdhci-iproc CMD timeouts Nicolas Saenz Julienne
@ 2021-02-25  9:52 ` Nicolas Saenz Julienne
  2021-02-25  9:52 ` [RFC 2/2] mmc: sdhci-iproc: Set clock frequency as per DT Nicolas Saenz Julienne
  2021-03-09  8:14 ` [RFC 0/2] sdhci-iproc CMD timeouts Ulf Hansson
  2 siblings, 0 replies; 4+ messages in thread
From: Nicolas Saenz Julienne @ 2021-02-25  9:52 UTC (permalink / raw)
  To: linux-arm-kernel, linux-mmc, devicetree,
	bcm-kernel-feedback-list, linux-rpi-kernel, Rob Herring,
	Nicolas Saenz Julienne
  Cc: f.fainelli, tim.gover, sbranden, alcooperx, adrian.hunter,
	linux-kernel, phil

Force emmc2's frequency to 150MHz as the default 100MHz (set by FW)
seems to interfere with the VPU clock when setup at frequencies bigger
than 500MHz, causing unwarranted SDHCI CMD hangs when no SD card is
present.

Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
---
 arch/arm/boot/dts/bcm2711-rpi-4-b.dts | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/arch/arm/boot/dts/bcm2711-rpi-4-b.dts b/arch/arm/boot/dts/bcm2711-rpi-4-b.dts
index 3b4ab947492a..9aa8408d9960 100644
--- a/arch/arm/boot/dts/bcm2711-rpi-4-b.dts
+++ b/arch/arm/boot/dts/bcm2711-rpi-4-b.dts
@@ -257,6 +257,12 @@ &emmc2 {
 	vqmmc-supply = <&sd_io_1v8_reg>;
 	vmmc-supply = <&sd_vcc_reg>;
 	broken-cd;
+	/*
+	 * Force the frequency to 150MHz as the default 100MHz seems to
+	 * interfere with the VPU clock when setup at frequencies bigger than
+	 * 500MHz, causing unwarranted CMD hangs.
+	 */
+	clock-frequency = <150000000>;
 	status = "okay";
 };
 
-- 
2.30.1


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

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [RFC 2/2] mmc: sdhci-iproc: Set clock frequency as per DT
  2021-02-25  9:52 [RFC 0/2] sdhci-iproc CMD timeouts Nicolas Saenz Julienne
  2021-02-25  9:52 ` [RFC 1/2] ARM: dts: Fix-up EMMC2 controller's frequency Nicolas Saenz Julienne
@ 2021-02-25  9:52 ` Nicolas Saenz Julienne
  2021-03-09  8:14 ` [RFC 0/2] sdhci-iproc CMD timeouts Ulf Hansson
  2 siblings, 0 replies; 4+ messages in thread
From: Nicolas Saenz Julienne @ 2021-02-25  9:52 UTC (permalink / raw)
  To: linux-arm-kernel, linux-mmc, devicetree,
	bcm-kernel-feedback-list, linux-rpi-kernel, Adrian Hunter,
	Ray Jui, Scott Branden
  Cc: Ulf Hansson, f.fainelli, tim.gover, alcooperx, linux-kernel,
	phil, Nicolas Saenz Julienne

devicetree might request a clock frequency different from whatever is
set-up by the bootloader. Make sure to setup the new rate.

Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
---
 drivers/mmc/host/sdhci-iproc.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/drivers/mmc/host/sdhci-iproc.c b/drivers/mmc/host/sdhci-iproc.c
index ddeaf8e1f72f..536c382e2486 100644
--- a/drivers/mmc/host/sdhci-iproc.c
+++ b/drivers/mmc/host/sdhci-iproc.c
@@ -358,6 +358,16 @@ static int sdhci_iproc_probe(struct platform_device *pdev)
 			ret = PTR_ERR(pltfm_host->clk);
 			goto err;
 		}
+
+		if (pltfm_host->clock) {
+			ret = clk_set_rate(pltfm_host->clk, pltfm_host->clock);
+			if (ret) {
+				dev_err(dev, "failed to set host clk at %u Hz\n",
+					pltfm_host->clock);
+				goto err;
+			}
+		}
+
 		ret = clk_prepare_enable(pltfm_host->clk);
 		if (ret) {
 			dev_err(dev, "failed to enable host clk\n");
-- 
2.30.1


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

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [RFC 0/2] sdhci-iproc CMD timeouts
  2021-02-25  9:52 [RFC 0/2] sdhci-iproc CMD timeouts Nicolas Saenz Julienne
  2021-02-25  9:52 ` [RFC 1/2] ARM: dts: Fix-up EMMC2 controller's frequency Nicolas Saenz Julienne
  2021-02-25  9:52 ` [RFC 2/2] mmc: sdhci-iproc: Set clock frequency as per DT Nicolas Saenz Julienne
@ 2021-03-09  8:14 ` Ulf Hansson
  2 siblings, 0 replies; 4+ messages in thread
From: Ulf Hansson @ 2021-03-09  8:14 UTC (permalink / raw)
  To: Nicolas Saenz Julienne
  Cc: Linux ARM, linux-mmc, DTML, BCM Kernel Feedback,
	moderated list:BROADCOM BCM2835...,
	Florian Fainelli, phil, tim.gover, Adrian Hunter, Scott Branden,
	Al Cooper, Linux Kernel Mailing List

On Thu, 25 Feb 2021 at 10:53, Nicolas Saenz Julienne
<nsaenzjulienne@suse.de> wrote:
>
> I'm seeing a rather odd behavior from sdhci-iproc's integration in BCM2711
> (Raspberry Pi 4's SoC), and would appreciate some opinions.
>
> The controller will timeout on SDHCI CMDs under the following conditions:
>
>  - No SD card plugged in (the card polling thread is running, CD irq disabled).
>  - BCM2711's VPU clock[1] configured at 500MHz or more, lower clocks are OK.
>
> There is no specific command that will time out, it seems random.
>
> Here's what I found out. The SDHCI controller runs at 100MHz, by bumping the
> frequency to 150MHz the issue disapears. Might be pure luck, or maybe I hit the
> nail and it's proper interference. Can't say.

As you probably know, I don't have the in-depth knowledge about this
HW. Although, let me provide a very vague guess. Could be that the
controller needs a higher clock rate to stay within some spec, for an
OPP/voltage domain for example?

In any case, assuming you get some confirmation from the Broadcom
folkz that this makes sense, you  need to update the DT doc bindings
to add the clock-frequency property. In regards to this, please take
the opportunity to convert from legacy DT doc format
(brcm,sdhci-iproc.txt) into the new yaml format.

Kind regards
Uffe

>
> Regards,
> Nicolas
>
> ---
>
> [1] For those who are not aware, here's the relationship between VPU's clock
>     and emmc2's:
>
>          osc                                    54000000
>             plld                              3000000091
>                plld_per                        750000023
>                   emmc2                        149882908
>             pllc                              2999999988
>                pllc_core0                      999999996
>                   vpu                          499999998
>
> Nicolas Saenz Julienne (2):
>   ARM: dts: Fix-up EMMC2 controller's frequency
>   mmc: sdhci-iproc: Set clock frequency as per DT
>
>  arch/arm/boot/dts/bcm2711-rpi-4-b.dts |  6 ++++++
>  drivers/mmc/host/sdhci-iproc.c        | 10 ++++++++++
>  2 files changed, 16 insertions(+)
>
> --
> 2.30.1
>

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-03-09  8:17 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-25  9:52 [RFC 0/2] sdhci-iproc CMD timeouts Nicolas Saenz Julienne
2021-02-25  9:52 ` [RFC 1/2] ARM: dts: Fix-up EMMC2 controller's frequency Nicolas Saenz Julienne
2021-02-25  9:52 ` [RFC 2/2] mmc: sdhci-iproc: Set clock frequency as per DT Nicolas Saenz Julienne
2021-03-09  8:14 ` [RFC 0/2] sdhci-iproc CMD timeouts Ulf Hansson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).