On Wed, May 31, 2023 at 2:00 AM Wolfram Sang <wsa+renesas@xxxxxxxxxxxxxxxxxxxx> wrote: > > Some SD cards failed to tune SDR104 occasionally. Adding a delay between > tuning commands makes the cards work although it is not yet known why. > It seems to be host dependent, only a few need such a delay (I found AMD > SDHCI and Freescale eSDHC so far). 25us is not enough, 50us never failed > up to now, so let's double that value until we know what is going on. > Extra thank you to Adam for sending me a problematic SD card to test. > > Reported-by: Adam Ford <aford173@xxxxxxxxx> > Closes: https://lore.kernel.org/all/CAHCN7xK_fr_gREVsOzN=atcS08mwufr-=7q1JAN=CCyVk_k-dA@xxxxxxxxxxxxxx/ > Signed-off-by: Wolfram Sang <wsa+renesas@xxxxxxxxxxxxxxxxxxxx> > --- > > This is one of the patches which look simple but took quite a while to > come up with. Part of it was identifying the issue, part of it was > trying to understand the issue. But I am stuck now, so I need help: > > @Adam: could you kindly test this patch with your setup? First, we need > to make sure it helps your case as well. I am testing this on a 5.10 kernel based on the Renesas RZ linux kernel branch. The good news is that the card doesn't hang like it used to on the older 4.19 kernel, but it still does not enumerate to SDR104 speeds. [ 5.222863] mmc0: tuning execution failed: -5 [ 5.308026] mmc0: new high speed SDHC card at address 59b4 [ 5.314397] mmcblk0: mmc0:59b4 USD00 29.5 GiB [ 5.320745] mmcblk0: p1 p2 # cat /sys/kernel/debug/mmc0/ios clock: 50000000 Hz actual clock: 49999998 Hz vdd: 21 (3.3 ~ 3.4 V) bus mode: 2 (push-pull) chip select: 0 (don't care) power mode: 2 (on) bus width: 2 (4 bits) timing spec: 2 (sd high-speed) signal voltage: 0 (3.30 V) driver type: 0 (driver type B) On other platforms, this same card registers 200MHz at SDR104 speeds. I'll try again on the latest 6.4 RC branch to see if there is some progress there. adam > > @Shimoda: If it helps for Adam's case, maybe we could ask the HW team if > they see a reason for this delay? I already scanned the SD/MMC/SDHI specs > without finding any trace, Marek helped as well. My gut feeling says it > is host controller specific. But first, let's hope it works for Adam. > > drivers/mmc/host/renesas_sdhi_core.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/drivers/mmc/host/renesas_sdhi_core.c b/drivers/mmc/host/renesas_sdhi_core.c > index 345934e4f59e..6088cf94e1d3 100644 > --- a/drivers/mmc/host/renesas_sdhi_core.c > +++ b/drivers/mmc/host/renesas_sdhi_core.c > @@ -711,6 +711,9 @@ static int renesas_sdhi_execute_tuning(struct mmc_host *mmc, u32 opcode) > > if (cmd_error) > mmc_send_abort_tuning(mmc, opcode); > + > + /* FIXME: Needed for some SD cards. The reason is not known yet */ > + usleep_range(100, 250); > } > > ret = renesas_sdhi_select_tuning(host); > -- > 2.30.2 >