Re: [PATCH 1/2] mmc: core: sdio: retry without UHS if UHS init fails
From: Shawn Lin
Date: Sun Oct 25 2026 - 20:58:57 EST
在 2026/10/24 星期六 7:28, Deomid rojer Ryabkov 写道:
If mmc_sdio_init_uhs_card() fails, typically because tuning finds no
working sample phase, card initialisation fails and the card is not
usable at all, even though it would work fine in high-speed mode.
This happens for example on the FriendlyElec NanoPi R2S Plus when the
SDIO pins of the RTL8822CS Wi-Fi module are left at their default 4 mA
drive strength:
dwmmc_rockchip ff5f0000.mmc: All phases bad!
mmc2: tuning execution failed: -5
mmc2: error -5 whilst initialising SDIO card
[... repeated for every init frequency ...]
mmc2: Failed to initialize a non-removable card
There is already a fallback for a failure to read the CCCR in UHS mode:
power-cycle the card and restart the init sequence without
Nit: It doesn't power-cycle the card but soft-reset it.
Otherwise it looks good to me,
Reviewed-by: Shawn Lin <shawn.lin@xxxxxxxxxxxxxx>
R4_18V_PRESENT. Do the same when UHS init fails, so that the card comes
up in high-speed mode instead:
mmc2: UHS init failed (-5), retrying without UHS
mmc2: Skipping voltage switch
mmc2: new high speed SDIO card at address 0001
The fallback is taken at most once, as the retry doesn't request UHS.
Signed-off-by: Deomid rojer Ryabkov <rojer@xxxxxxxx>
---
drivers/mmc/core/sdio.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/drivers/mmc/core/sdio.c b/drivers/mmc/core/sdio.c
index 83085e7648..6787fdf1c5 100644
--- a/drivers/mmc/core/sdio.c
+++ b/drivers/mmc/core/sdio.c
@@ -867,8 +867,14 @@ static int mmc_sdio_init_card(struct mmc_host *host, u32 ocr,
/* Only if card supports 1.8v and UHS signaling */
if ((ocr & R4_18V_PRESENT) && card->sw_caps.sd3_bus_mode) {
err = mmc_sdio_init_uhs_card(card);
- if (err)
- goto remove;
+ if (err) {
+ pr_warn("%s: UHS init failed (%d), retrying without UHS\n",
+ mmc_hostname(host), err);
+ mmc_sdio_pre_init(host, ocr_card,
+ card != oldcard ? card : NULL);
+ retries = 0;
+ goto try_again;
+ }
} else {
/*
* Switch to high-speed (if supported).