Re: [PATCH v4 1/3] mmc: sdhci-cadence: abort failed tuning command on SD6HC

From: Adrian Hunter

Date: Wed Dec 02 2026 - 02:50:45 EST


On 19/11/2026 11:45, tze.yee.ng@xxxxxxxxxx wrote:
> From: Tze Yee Ng <tze.yee.ng@xxxxxxxxxx>
>
> SD6HC uses a software tuning loop that calls mmc_send_tuning() for every
> tap but never aborts a command that fails. When a CMD21 fails with a
> command error the eMMC can remain in the Data state and reject the next
> command, so the CMD6 that mmc_select_hs400() issues right after tuning
> times out.
>
> Request the command error from mmc_send_tuning() and, on a command
> error, abort the tuning command with mmc_send_abort_tuning(). This
> matches the generic sdhci tuning path. SD is unaffected because
> mmc_send_abort_tuning() only acts on the CMD21 tuning command and is a
> no-op for the SD CMD19 one.
>
> sdhci_cdns_execute_tuning() is shared with SD4HC, so limit the abort to
> SD6HC (SDHCI_SPEC_420 and later); only SD6HC has been tested and SD4HC
> can opt in once validated.
>
> Suggested-by: Tanmay Kathpalia <tanmay.kathpalia@xxxxxxxxxx>
> Signed-off-by: Tze Yee Ng <tze.yee.ng@xxxxxxxxxx>
> Reviewed-by: Tanmay Kathpalia <tanmay.kathpalia@xxxxxxxxxx>

The comment could use a tweak - see below. Nevertheless:

Acked-by: Adrian Hunter <adrian.hunter@xxxxxxxxx>

> ---
> Changes in v4:
> - Limited the abort to SD6HC (host->version >= SDHCI_SPEC_420)
> because sdhci_cdns_execute_tuning() is shared with SD4HC, which has
> not been tested; reworded the commit message accordingly.
> - Added Tanmay's Reviewed-by.
>
> Changes in v3:
> - New patch replacing the v2 1/4 PHY settle: abort the failed tuning
> command (mmc_send_abort_tuning(), a no-op for SD) instead of masking
> the post-tuning command timeout with a settle delay. (Tanmay Kathpalia)
> ---
> drivers/mmc/host/sdhci-cadence-core.c | 12 +++++++++++-
> 1 file changed, 11 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/mmc/host/sdhci-cadence-core.c b/drivers/mmc/host/sdhci-cadence-core.c
> index 745455743b01..5e5a74ca25ce 100644
> --- a/drivers/mmc/host/sdhci-cadence-core.c
> +++ b/drivers/mmc/host/sdhci-cadence-core.c
> @@ -330,9 +330,19 @@ static int sdhci_cdns_execute_tuning(struct sdhci_host *host, u32 opcode)
> }
>
> for (i = 0; i < SDHCI_CDNS_MAX_TUNING_LOOP; i++) {
> + int cmd_error = 0;
> +
> if (sdhci_cdns_set_tune_val(host, i) ||
> - mmc_send_tuning(host->mmc, opcode, NULL)) { /* bad */
> + mmc_send_tuning(host->mmc, opcode, &cmd_error)) { /* bad */
> cur_streak = 0;
> + /*
> + * Abort a failed tuning command so an eMMC does not
> + * stay in the Data state and reject the next command.
> + * Restrict to SD6HC; the shared path also serves the
> + * untested SD4HC. A no-op for SD in any case.

"Restrict to SD6HC; the shared path also serves the untested SD4HC"
is AI generated and doesn't make sense.

"A no-op for SD in any case"
is not relevant

Could just be:

"Restrict to SD6HC for now because it is untested with SD4HC"

but why not test SD4HC?

> + */
> + if (cmd_error && host->version >= SDHCI_SPEC_420)
> + mmc_send_abort_tuning(host->mmc, opcode);
> } else { /* good */
> cur_streak++;
> if (cur_streak > max_streak) {
>