* [PATCH v2 0/2] mmc: msm_sdhci: drop the 1 ms delay after every command
@ 2026-11-23 8:57 Igor Opaniuk
2026-11-23 8:57 ` [PATCH v2 1/2] mmc: sdhci: delay the status clear after a response without CRC Igor Opaniuk
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Igor Opaniuk @ 2026-11-23 8:57 UTC (permalink / raw)
To: Sumit Garg, Peng Fan, Jaehoon Chung, Tanmay Kathpalia,
u-boot-qcom, u-boot
Cc: Casey Connolly, Neil Armstrong, Tom Rini, Stephan Gerhold,
Sam Day, Jorge Ramirez-Ortiz, Dzmitry Sankouski,
Varadarajan Narayanan, Aswin Murugan, Balaji Selvanathan,
Igor Opaniuk
msm_sdhci sets SDHCI_QUIRK_WAIT_SEND_CMD, a 1 ms sleep after most
commands. It costs 2 ms per multi-block read and caps USB mass storage
on an Arduino UNO Q at 46 MB/s instead of 201 MB/s.
v1 only dropped the quirk. Stephan Gerhold found that this breaks SD
card detection on DB410c, DB820c and RB3 Gen 2: the CMD55 after the
first ACMD41 fails with a response CRC error.
Root cause:
The same failure exists on eMMC, where MMC_QUIRK_RETRY_SEND_CID hides
it: the CMD2 after the last CMD1 fails on its first status read with
INT_STATUS 0x00028000. Both cases are a CRC-checked command that
follows an R3 response.
After an R3 response the controller keeps a latent command CRC error:
- it is not visible: INT_STATUS reads 0 before the next command;
- it does not expire: the next command fails even 10 ms later;
- it is removed by a status clear issued a few SD clock cycles after
the R3 command has completed. The clear sdhci_send_command() does at
completion is too early.
The quirk worked because it delayed that clear by 1 ms.
Testing results:
Arduino UNO Q (QRB2210, qcom,sdhci-msm-v5, eMMC, ADMA). A status trace
was added to sdhci_send_command(); the identification clock is
188 kHz, 5.3 us per cycle. Each line is the first CMD2 of "mmc rescan"
with the quirk dropped:
Without patch 1 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 patch 1 (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
The 1 ms case has the gap of the SD ACMD41 loop. With patch 1 the CMD2
is sent once per initialisation, without the retry.
Both patches, no trace:
eMMC mode HS400 (200 MHz)
1 GiB "mmc read" 302 MiB/s
CRC32 of the first 128 MiB same in U-Boot and Linux
Linux boot from the eMMC ok
Not tested:
- SD cards: the UNO Q has no slot, so it is not confirmed that patch 1
fixes the reported failure. Stephan's alternative, retrying that
CMD55 through MMC_QUIRK_RETRY_APP_CMD, works on his boards and can be
added if needed.
- v4 controllers.
- Other SDHCI hosts: patch 1 is in the common sdhci.c.
---
Changes in v2:
- New patch 1: delay the status clear after a response without CRC
(SD detection failure reported by Stephan).
- Patch 2: commit message reworded ("after most commands", Tanmay) and
shortened. The code is unchanged.
- The Reviewed-by tags from Aswin and Tanmay are not carried over: the
patch now depends on a new sdhci.c change that they have not seen.
- Rebased on snapdragon/qcom-next.
- Cc the maintainers of the boards that use the driver.
- Link to v1: https://lore.kernel.org/r/20261030-msm-sdhci-wait-send-cmd-v1-1-6ef678db1585@oss.qualcomm.com
---
Igor Opaniuk (2):
mmc: sdhci: delay the status clear after a response without CRC
mmc: msm_sdhci: drop SDHCI_QUIRK_WAIT_SEND_CMD
drivers/mmc/msm_sdhci.c | 2 +-
drivers/mmc/sdhci.c | 13 +++++++++++++
2 files changed, 14 insertions(+), 1 deletion(-)
---
base-commit: 36d2b7b46c77b44021f0a6f36684a123e5560492
change-id: 20261030-msm-sdhci-wait-send-cmd-4383f2792022
Best regards,
--
Igor Opaniuk <igor.opaniuk@oss.qualcomm.com>
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH v2 1/2] mmc: sdhci: delay the status clear after a response without CRC
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 ` Igor Opaniuk
2026-11-23 13:27 ` Stephan Gerhold
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
2 siblings, 1 reply; 5+ messages in thread
From: Igor Opaniuk @ 2026-11-23 8:57 UTC (permalink / raw)
To: Sumit Garg, Peng Fan, Jaehoon Chung, Tanmay Kathpalia,
u-boot-qcom, u-boot
Cc: Casey Connolly, Neil Armstrong, Tom Rini, Stephan Gerhold,
Sam Day, Jorge Ramirez-Ortiz, Dzmitry Sankouski,
Varadarajan Narayanan, Aswin Murugan, Balaji Selvanathan,
Igor Opaniuk
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));
+
stat = sdhci_readl(host, SDHCI_INT_STATUS);
sdhci_writel(host, SDHCI_INT_ALL_MASK, SDHCI_INT_STATUS);
if (!ret) {
--
2.53.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH v2 2/2] mmc: msm_sdhci: drop SDHCI_QUIRK_WAIT_SEND_CMD
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 8:57 ` Igor Opaniuk
2026-11-23 13:25 ` [PATCH v2 0/2] mmc: msm_sdhci: drop the 1 ms delay after every command Stephan Gerhold
2 siblings, 0 replies; 5+ messages in thread
From: Igor Opaniuk @ 2026-11-23 8:57 UTC (permalink / raw)
To: Sumit Garg, Peng Fan, Jaehoon Chung, Tanmay Kathpalia,
u-boot-qcom, u-boot
Cc: Casey Connolly, Neil Armstrong, Tom Rini, Stephan Gerhold,
Sam Day, Jorge Ramirez-Ortiz, Dzmitry Sankouski,
Varadarajan Narayanan, Aswin Murugan, Balaji Selvanathan,
Igor Opaniuk
SDHCI_QUIRK_WAIT_SEND_CMD makes sdhci_send_command() sleep for 1 ms
after most commands (R1b commands without data return earlier because
of SDHCI_QUIRK_BROKEN_R1B). The Linux sdhci-msm driver has no such
delay.
This delay postponed the final status clear, which is what removed the
stale CRC error left by an R3 response.
The previous patch does that for the affected commands only,
so the quirk is no longer needed.
The quirk is costly: a multi-block read is CMD18 + CMD12, so every read
pays 2 ms, while a 128 KiB read from an eMMC in HS400 takes about
0.4 ms. USB mass storage reads in 128 KiB chunks; on the Arduino UNO Q:
Test results:
ums read, 1 GiB
with the quirk 46 MB/s
without 201 MB/s
Signed-off-by: Igor Opaniuk <igor.opaniuk@oss.qualcomm.com>
---
drivers/mmc/msm_sdhci.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/mmc/msm_sdhci.c b/drivers/mmc/msm_sdhci.c
index 9cc11a5e269..ab217393a54 100644
--- a/drivers/mmc/msm_sdhci.c
+++ b/drivers/mmc/msm_sdhci.c
@@ -198,7 +198,7 @@ static int msm_sdc_probe(struct udevice *dev)
udelay(200);
}
- host->quirks = SDHCI_QUIRK_WAIT_SEND_CMD | SDHCI_QUIRK_BROKEN_R1B;
+ host->quirks = SDHCI_QUIRK_BROKEN_R1B;
host->max_clk = 0;
--
2.53.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH v2 0/2] mmc: msm_sdhci: drop the 1 ms delay after every command
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 8:57 ` [PATCH v2 2/2] mmc: msm_sdhci: drop SDHCI_QUIRK_WAIT_SEND_CMD Igor Opaniuk
@ 2026-11-23 13:25 ` Stephan Gerhold
2 siblings, 0 replies; 5+ messages in thread
From: Stephan Gerhold @ 2026-11-23 13:25 UTC (permalink / raw)
To: Igor Opaniuk
Cc: Sumit Garg, Peng Fan, Jaehoon Chung, Tanmay Kathpalia,
u-boot-qcom, u-boot, Casey Connolly, Neil Armstrong, Tom Rini,
Sam Day, Jorge Ramirez-Ortiz, Dzmitry Sankouski,
Varadarajan Narayanan, Aswin Murugan, Balaji Selvanathan
On Mon, Nov 23, 2026 at 09:57:00AM +0100, Igor Opaniuk wrote:
> msm_sdhci sets SDHCI_QUIRK_WAIT_SEND_CMD, a 1 ms sleep after most
> commands. It costs 2 ms per multi-block read and caps USB mass storage
> on an Arduino UNO Q at 46 MB/s instead of 201 MB/s.
>
> v1 only dropped the quirk. Stephan Gerhold found that this breaks SD
> card detection on DB410c, DB820c and RB3 Gen 2: the CMD55 after the
> first ACMD41 fails with a response CRC error.
>
> Root cause:
>
> The same failure exists on eMMC, where MMC_QUIRK_RETRY_SEND_CID hides
> it: the CMD2 after the last CMD1 fails on its first status read with
> INT_STATUS 0x00028000. Both cases are a CRC-checked command that
> follows an R3 response.
>
> After an R3 response the controller keeps a latent command CRC error:
>
> - it is not visible: INT_STATUS reads 0 before the next command;
> - it does not expire: the next command fails even 10 ms later;
> - it is removed by a status clear issued a few SD clock cycles after
> the R3 command has completed. The clear sdhci_send_command() does at
> completion is too early.
>
> The quirk worked because it delayed that clear by 1 ms.
>
> Testing results:
>
> Arduino UNO Q (QRB2210, qcom,sdhci-msm-v5, eMMC, ADMA). A status trace
> was added to sdhci_send_command(); the identification clock is
> 188 kHz, 5.3 us per cycle. Each line is the first CMD2 of "mmc rescan"
> with the quirk dropped:
>
> Without patch 1 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 patch 1 (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
>
> The 1 ms case has the gap of the SD ACMD41 loop. With patch 1 the CMD2
> is sent once per initialisation, without the retry.
>
> Both patches, no trace:
>
> eMMC mode HS400 (200 MHz)
> 1 GiB "mmc read" 302 MiB/s
> CRC32 of the first 128 MiB same in U-Boot and Linux
> Linux boot from the eMMC ok
>
> Not tested:
>
> - SD cards: the UNO Q has no slot, so it is not confirmed that patch 1
> fixes the reported failure. Stephan's alternative, retrying that
> CMD55 through MMC_QUIRK_RETRY_APP_CMD, works on his boards and can be
> added if needed.
> - v4 controllers.
> - Other SDHCI hosts: patch 1 is in the common sdhci.c.
>
> ---
> Changes in v2:
> - New patch 1: delay the status clear after a response without CRC
> (SD detection failure reported by Stephan).
> - Patch 2: commit message reworded ("after most commands", Tanmay) and
> shortened. The code is unchanged.
> - The Reviewed-by tags from Aswin and Tanmay are not carried over: the
> patch now depends on a new sdhci.c change that they have not seen.
> - Rebased on snapdragon/qcom-next.
> - Cc the maintainers of the boards that use the driver.
> - Link to v1: https://lore.kernel.org/r/20261030-msm-sdhci-wait-send-cmd-v1-1-6ef678db1585@oss.qualcomm.com
>
> ---
> Igor Opaniuk (2):
> mmc: sdhci: delay the status clear after a response without CRC
> mmc: msm_sdhci: drop SDHCI_QUIRK_WAIT_SEND_CMD
>
> drivers/mmc/msm_sdhci.c | 2 +-
> drivers/mmc/sdhci.c | 13 +++++++++++++
> 2 files changed, 14 insertions(+), 1 deletion(-)
> ---
> base-commit: 36d2b7b46c77b44021f0a6f36684a123e5560492
> change-id: 20261030-msm-sdhci-wait-send-cmd-4383f2792022
>
Not 100% sure if this is the best way to fix it, but it works fine in my
tests and is certainly better than the unconditional 1ms delay we had
before so FWIW:
Tested-by: Stephan Gerhold <stephan.gerhold@linaro.org> # DB410c eMMC/SD
Thanks,
Stephan
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2 1/2] mmc: sdhci: delay the status clear after a response without CRC
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
0 siblings, 0 replies; 5+ messages in thread
From: Stephan Gerhold @ 2026-11-23 13:27 UTC (permalink / raw)
To: Igor Opaniuk
Cc: Sumit Garg, Peng Fan, Jaehoon Chung, Tanmay Kathpalia,
u-boot-qcom, u-boot, Casey Connolly, Neil Armstrong, Tom Rini,
Sam Day, Jorge Ramirez-Ortiz, Dzmitry Sankouski,
Varadarajan Narayanan, Aswin Murugan, Balaji Selvanathan
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
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2026-11-23 13:27 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
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
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox