Hi Peng,
I did meet an issue with specific HW.
With this specific HW, we had SDHCI for interfacing with MMC.
On initialization, the first SD_CMD_APP_SEND_SCR command failed with a CRC 
error, indicated by SDHCI, probably related to HW issue or HW initialization 
issue.
After the first CRC error, no errors occurred anymore and everything worked 
fine.

The fix in this patch is for the retry mechanism, which is relevant only if an 
error occurs in the first place, not for the initial CRC error.

The issue with the retry mechanism for SD_CMD_APP_SEND_SCR is that it didn't 
take into account that both {MMC_CMD_APP_CMD, SD_CMD_APP_SEND_SCR} have to be 
sent in sequence on retry attempts.
So with the existing implementation the MMC didn't interpret 
SD_CMD_APP_SEND_SCR as application specific command in the retry attempts.

Thanks,
Yanir Levin
________________________________
From: Peng Fan <[email protected]>
Sent: 13 January 2026 09:54
To: Yanir Levin <[email protected]>
Cc: [email protected] <[email protected]>; [email protected] 
<[email protected]>; [email protected] <[email protected]>; Eran Moshe 
<[email protected]>
Subject: Re: [PATCH] mmc: Fix retry logic in sd_get_capabilities

Hi Yanir,

On Sun, Jan 11, 2026 at 08:21:13AM +0000, Yanir Levin wrote:
>In sd_get_capabilities an ACMD is sent (SD_CMD_APP_SEND_SCR),
>which requires sending APP_CMD (MMC_CMD_APP_CMD) before.
>
>Currently, the ACMD is retried on error, however APP_CMD isn't.
>In this case, when the ACMD fails and it is tried again,
>the retry attempts will not be handled as ACMD, which is wrong.
>
>The fix performs the retry attempts on the sequence of
>APP_CMD and the ACMD together.

Did you meet any issues, or is this just code inspection?

Thanks,
Peng

>
>Signed-off-by: Yanir Levin <[email protected]>
>Reviewed-by: Eran Moshe <[email protected]>
>---
> drivers/mmc/mmc.c | 41 ++++++++++++++++++++++-------------------
> 1 file changed, 22 insertions(+), 19 deletions(-)
>
>diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c
>index bf82c515600..c1146ab3648 100644
>--- a/drivers/mmc/mmc.c
>+++ b/drivers/mmc/mmc.c
>@@ -1389,25 +1389,28 @@ static int sd_get_capabilities(struct mmc *mmc)
>                return 0;
>
>        /* Read the SCR to find out if this card supports higher speeds */
>-       cmd.cmdidx = MMC_CMD_APP_CMD;
>-       cmd.resp_type = MMC_RSP_R1;
>-       cmd.cmdarg = mmc->rca << 16;
>-
>-       err = mmc_send_cmd(mmc, &cmd, NULL);
>-
>-       if (err)
>-               return err;
>-
>-       cmd.cmdidx = SD_CMD_APP_SEND_SCR;
>-       cmd.resp_type = MMC_RSP_R1;
>-       cmd.cmdarg = 0;
>-
>-       data.dest = (char *)scr;
>-       data.blocksize = 8;
>-       data.blocks = 1;
>-       data.flags = MMC_DATA_READ;
>-
>-       err = mmc_send_cmd_retry(mmc, &cmd, &data, 3);
>+       uint retries = 3;
>+       do {
>+               cmd.cmdidx = MMC_CMD_APP_CMD;
>+               cmd.resp_type = MMC_RSP_R1;
>+               cmd.cmdarg = mmc->rca << 16;
>+
>+               err = mmc_send_cmd(mmc, &cmd, NULL);
>+
>+               if (err)
>+                       continue;
>+
>+               cmd.cmdidx = SD_CMD_APP_SEND_SCR;
>+               cmd.resp_type = MMC_RSP_R1;
>+               cmd.cmdarg = 0;
>+
>+               data.dest = (char *)scr;
>+               data.blocksize = 8;
>+               data.blocks = 1;
>+               data.flags = MMC_DATA_READ;
>+
>+               err = mmc_send_cmd(mmc, &cmd, &data);
>+       } while (err && retries--);
>
>        if (err)
>                return err;
>--
>2.43.0
>
>

Reply via email to