[PATCH 12/13] mmc: renesas_sdhi: Fix SDIO manual tap correction in SDR104 mode

From: Lee Jones

Date: Mon Nov 23 2026 - 14:18:50 EST


Commit 30fa7d53afd4 ("mmc: host: renesas_sdhi: Fix incorrect auto
retuning for an SDIO card") switched SDIO cards from automatic to manual
SCC tap correction so that DAT1 SDIO interrupts would not spuriously
shift the sampling tap, but exposed two logic errors in the manual
correction path:

1. renesas_sdhi_manual_correction() checks !priv->card_is_sdio instead
of priv->card_is_sdio before ignoring DAT1 mismatches, so the SDIO
DAT1 check never executes for SDIO cards.

2. renesas_sdhi_check_scc_error() already returns early when running in
4-tap HS400 mode, yet still passes the hs400_4taps quirk flag as
use_4tap to renesas_sdhi_manual_correction(), halving the 8-tap
SDR104 and HS200 tap index when writing SH_MOBILE_SDHI_SCC_TAPSET on
SoCs with hs400_4taps.

Check priv->card_is_sdio without negation and drop the unused 4-tap
division from renesas_sdhi_manual_correction().

Fixes: 30fa7d53afd4 ("mmc: host: renesas_sdhi: Fix incorrect auto retuning for an SDIO card")
Closes: https://sashiko.dev/#/bug/linux-735317da-fe00-4630-b954-5dcc1052aaa8
Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: Lee Jones <lee@xxxxxxxxxx>
---
drivers/mmc/host/renesas_sdhi_core.c | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/drivers/mmc/host/renesas_sdhi_core.c b/drivers/mmc/host/renesas_sdhi_core.c
index cb35360239bf..497c7c75f966 100644
--- a/drivers/mmc/host/renesas_sdhi_core.c
+++ b/drivers/mmc/host/renesas_sdhi_core.c
@@ -741,7 +741,7 @@ static int renesas_sdhi_execute_tuning(struct mmc_host *mmc, u32 opcode)
return ret;
}

-static bool renesas_sdhi_manual_correction(struct tmio_mmc_host *host, bool use_4tap)
+static bool renesas_sdhi_manual_correction(struct tmio_mmc_host *host)
{
struct renesas_sdhi *priv = host_to_priv(host);
unsigned int new_tap = priv->tap_set, error_tap = priv->tap_set;
@@ -783,7 +783,7 @@ static bool renesas_sdhi_manual_correction(struct tmio_mmc_host *host, bool use_
if (bad_taps & BIT(new_tap % priv->tap_num))
return test_bit(error_tap % priv->tap_num, priv->smpcmp);
} else {
- if (!priv->card_is_sdio &&
+ if (priv->card_is_sdio &&
!(val & SH_MOBILE_SDHI_SCC_RVSREQ_RVSERR)) {
u32 smpcmp = sd_scc_read32(host, priv, SH_MOBILE_SDHI_SCC_SMPCMP);

@@ -802,8 +802,7 @@ static bool renesas_sdhi_manual_correction(struct tmio_mmc_host *host, bool use_
}

priv->tap_set = (new_tap % priv->tap_num);
- sd_scc_write32(host, priv, SH_MOBILE_SDHI_SCC_TAPSET,
- priv->tap_set / (use_4tap ? 2 : 1));
+ sd_scc_write32(host, priv, SH_MOBILE_SDHI_SCC_TAPSET, priv->tap_set);

return false;
}
@@ -854,7 +853,7 @@ static bool renesas_sdhi_check_scc_error(struct tmio_mmc_host *host,
SH_MOBILE_SDHI_SCC_RVSCNTL_RVSEN)
ret |= renesas_sdhi_auto_correction(host);
else
- ret |= renesas_sdhi_manual_correction(host, use_4tap);
+ ret |= renesas_sdhi_manual_correction(host);

return ret;
}
--
2.56.1.750.gf70dc682cf-goog