From: Stephan Gerhold <stephan.gerhold@linaro.org>
To: Igor Opaniuk <igor.opaniuk@oss.qualcomm.com>
Cc: Sumit Garg <sumit.garg@kernel.org>, Peng Fan <peng.fan@nxp.com>,
Jaehoon Chung <jh80.chung@samsung.com>,
Tanmay Kathpalia <tanmay.kathpalia@altera.com>,
u-boot-qcom@groups.io, u-boot@lists.u-boot-project.org,
Casey Connolly <casey.connolly@linaro.org>,
Neil Armstrong <neil.armstrong@linaro.org>,
Tom Rini <trini@konsulko.com>, Sam Day <me@samcday.com>,
Jorge Ramirez-Ortiz <jorge.ramirez.ortiz@gmail.com>,
Dzmitry Sankouski <dsankouski@gmail.com>,
Varadarajan Narayanan <varadarajan.narayanan@oss.qualcomm.com>,
Aswin Murugan <aswin.murugan@oss.qualcomm.com>,
Balaji Selvanathan <balaji.selvanathan@oss.qualcomm.com>
Subject: Re: [PATCH v2 1/2] mmc: sdhci: delay the status clear after a response without CRC
Date: Mon, 23 Nov 2026 14:27:47 +0100 [thread overview]
Message-ID: <awQ_U60Q5mJbTJVj@linaro.org> (raw)
In-Reply-To: <20261123-msm-sdhci-wait-send-cmd-v2-1-5de53eb34ff6@oss.qualcomm.com>
On Mon, Nov 23, 2026 at 09:57:01AM +0100, Igor Opaniuk wrote:
> The issue was observer on Qualcomm SDHCI controllers, where the
> first CRC-checked command after an R3 response (CMD1, ACMD41)
> fails at once with a command CRC error:
>
> - SD: the CMD55 after the first ACMD41 fails, the card is not detected;
> - eMMC: the CMD2 after the last CMD1 fails and only passes on the
> MMC_QUIRK_RETRY_SEND_CID retry.
>
> The R3 response leaves a latent CRC error in the controller. It does
> not show in the interrupt status and does not go away with time. It is
> removed only by a status clear issued a few SD clock cycles after the
> command has completed, and the clear in sdhci_send_command() comes
> earlier than that.
>
> msm_sdhci hides the problem with SDHCI_QUIRK_WAIT_SEND_CMD, which
> delays that clear by 1 ms for every command.
>
> Wait 16 SD clock periods before the final status clear of a command
> whose response carries no CRC. Only CMD1 and ACMD41 are affected.
>
> Tested on the Arduino UNO Q (QRB2210, eMMC, identification clock
> 188 kHz), with a status trace in sdhci_send_command() and without
> SDHCI_QUIRK_WAIT_SEND_CMD. First CMD2 of "mmc rescan":
>
> Without this patch CMD2 result
> as is fails 6/6
> 50 us .. 10 ms wait before the CMD2 fails 3/3 each
> final clear of the CMD1 delayed by 1 .. 8 us fails 6/6 each
> final clear of the CMD1 delayed by 12 .. 32 us passes 6/6 each
>
> With this patch (85 us at this clock)
> as is passes 30/30
> 1 ms wait before the CMD2 passes 10/10
> 10 ms wait before the CMD2 passes 10/10
>
> Reported-by: Stephan Gerhold <stephan.gerhold@linaro.org>
> Signed-off-by: Igor Opaniuk <igor.opaniuk@oss.qualcomm.com>
> ---
> drivers/mmc/sdhci.c | 13 +++++++++++++
> 1 file changed, 13 insertions(+)
>
> diff --git a/drivers/mmc/sdhci.c b/drivers/mmc/sdhci.c
> index 97de02c262c..ba355096761 100644
> --- a/drivers/mmc/sdhci.c
> +++ b/drivers/mmc/sdhci.c
> @@ -346,6 +346,19 @@ static int sdhci_send_command(struct mmc *mmc, struct mmc_cmd *cmd,
> if (host->quirks & SDHCI_QUIRK_WAIT_SEND_CMD)
> udelay(1000);
>
> + /*
> + * A response without CRC (R3) can leave a latent response CRC error
> + * in the controller a few SD clock cycles after the command has
> + * completed. It is not visible in the interrupt status, but unless
> + * the status is cleared after it has settled, the next command that
> + * checks the CRC fails with it at once (seen on Qualcomm SDHCI). Give
> + * it a few clock periods before the final clear below. Such commands
> + * are only sent while the card is being identified.
> + */
> + if (!ret && (cmd->resp_type & MMC_RSP_PRESENT) &&
> + !(cmd->resp_type & MMC_RSP_CRC) && mmc->clock)
> + udelay(DIV_ROUND_UP(16 * 1000000U, mmc->clock));
Nitpick: Maybe you should put this into an "else if" of the above
if (host->quirks & SDHCI_QUIRK_WAIT_SEND_CMD) check so it doesn't wait
twice for platforms still using the quirk.
I'm also not sure if we should make this conditional to QC platforms (or
another quirk), although presumably the application of the new delay is
fairly limited and fairly short.
Thanks,
Stephan
next prev parent reply other threads:[~2026-11-23 13:27 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-23 8:57 [PATCH v2 0/2] mmc: msm_sdhci: drop the 1 ms delay after every command Igor Opaniuk
2026-11-23 8:57 ` [PATCH v2 1/2] mmc: sdhci: delay the status clear after a response without CRC Igor Opaniuk
2026-11-23 13:27 ` Stephan Gerhold [this message]
2026-11-23 8:57 ` [PATCH v2 2/2] mmc: msm_sdhci: drop SDHCI_QUIRK_WAIT_SEND_CMD Igor Opaniuk
2026-11-23 13:25 ` [PATCH v2 0/2] mmc: msm_sdhci: drop the 1 ms delay after every command Stephan Gerhold
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=awQ_U60Q5mJbTJVj@linaro.org \
--to=stephan.gerhold@linaro.org \
--cc=aswin.murugan@oss.qualcomm.com \
--cc=balaji.selvanathan@oss.qualcomm.com \
--cc=casey.connolly@linaro.org \
--cc=dsankouski@gmail.com \
--cc=igor.opaniuk@oss.qualcomm.com \
--cc=jh80.chung@samsung.com \
--cc=jorge.ramirez.ortiz@gmail.com \
--cc=me@samcday.com \
--cc=neil.armstrong@linaro.org \
--cc=peng.fan@nxp.com \
--cc=sumit.garg@kernel.org \
--cc=tanmay.kathpalia@altera.com \
--cc=trini@konsulko.com \
--cc=u-boot-qcom@groups.io \
--cc=u-boot@lists.u-boot-project.org \
--cc=varadarajan.narayanan@oss.qualcomm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox