Skip to contentSkip to conversation

sdhci-iproc CMD timeouts

RFC In review Nicolas Saenz Julienne 2 participants 4 messages Feb 25, 2021 – Mar 9, 2021

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

cover sdhci-iproc CMD timeouts

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(+)
Signature · 1 line
2.30.1
#1 lore raw

RFC 1/2 ARM: dts: Fix-up EMMC2 controller's frequency

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.

---
 arch/arm/boot/dts/bcm2711-rpi-4-b.dts | 6 ++++++
 1 file changed, 6 insertions(+)
arch/arm/boot/dts/bcm2711-rpi-4-b.dts +6 -0
index 3b4ab947492a..9aa8408d9960 100644
@@ -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";
 };
 
Signature · 1 line
2.30.1
#2 lore raw

RFC 2/2 mmc: sdhci-iproc: Set clock frequency as per DT

In reply to 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.

---
 drivers/mmc/host/sdhci-iproc.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
drivers/mmc/host/sdhci-iproc.c +10 -0
index ddeaf8e1f72f..536c382e2486 100644
@@ -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");
Signature · 1 line
2.30.1
#3 lore raw
In reply to Nicolas Saenz Julienne
Quoted 6 lines · 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:

Quoted 8 lines

- 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

Quoted 28 lines

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