* [PATCH] mmc: msm_sdhci: drop SDHCI_QUIRK_WAIT_SEND_CMD
@ 2026-10-30 13:57 Igor Opaniuk
2026-10-31 15:03 ` Aswin Murugan
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Igor Opaniuk @ 2026-10-30 13:57 UTC (permalink / raw)
To: Sumit Garg, Tanmay Kathpalia, u-boot-qcom, u-boot
Cc: Casey Connolly, Neil Armstrong, Peng Fan, Jaehoon Chung, Tom Rini,
Varadarajan Narayanan, Aswin Murugan, Balaji Selvanathan,
Igor Opaniuk
SDHCI_QUIRK_WAIT_SEND_CMD makes sdhci_send_command() sleep for 1 ms
after every command. msm_sdhci has set it since the driver was added
for APQ8016, back when it only did PIO; the commit gives no reason for
it, and the Linux sdhci-msm driver has no such delay.
The delay is invisible for large reads but dominates small ones. A
multi-block read is CMD18 followed by CMD12, so every read pays 2 ms
on top of the transfer. With the eMMC in HS400 a 128 KiB read takes
about 0.4 ms, so USB mass storage, which reads in 128 KiB (FSG_BUFLEN)
chunks, spent most of its time in udelay(). On the Arduino UNO Q,
reading 1 GiB from "ums 0 mmc 0" on a USB 3 host
(dd if=/dev/sdX of=/dev/null bs=4M count=256):
host throughput time in eMMC reads (10.6k reads)
with the quirk 46 MB/s 26.8 s (~2.5 ms per read)
without 201 MB/s 4.5 s (~0.4 ms per read)
A single 128 MiB "mmc read" runs at 255.6 MiB/s either way.
Drop the quirk and keep SDHCI_QUIRK_BROKEN_R1B.
Tested on the Arduino UNO Q (QRB2210, qcom,sdhci-msm-v5, ADMA):
- on main (eMMC in DDR52): 128 MiB "mmc read" at 75 MiB/s as before,
the CRC32 of the first 128 MiB read in U-Boot matches the one Linux
computes from the same blocks, and Linux boots from the eMMC;
- with the "qcom: Enable HS200/HS400 eMMC modes" series and the
mass_storage SuperSpeed descriptor patch applied (eMMC in HS400):
the ums numbers above, same CRC32 check and Linux boot.
Not tested on v4 controllers or on the boards that use the driver in
PIO mode (qcom_dragonboard410c, qcom_dragonboard820c, hmibsc).
Signed-off-by: Igor Opaniuk <igor.opaniuk@oss.qualcomm.com>
---
Drop the 1 ms delay msm_sdhci adds after every SD command. It costs
2 ms per multi-block read, which capped ums on an Arduino UNO Q at
46 MB/s; without it the same read runs at 201 MB/s.
Testing on APQ8016/APQ8096 (PIO mode) would be welcome.
---
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;
---
base-commit: 3973f3c4d24df75ca90d7c0a9f03e5e5c9b48f32
change-id: 20261030-msm-sdhci-wait-send-cmd-4383f2792022
Best regards,
--
Igor Opaniuk <igor.opaniuk@oss.qualcomm.com>
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] mmc: msm_sdhci: drop SDHCI_QUIRK_WAIT_SEND_CMD
2026-10-30 13:57 [PATCH] mmc: msm_sdhci: drop SDHCI_QUIRK_WAIT_SEND_CMD Igor Opaniuk
@ 2026-10-31 15:03 ` Aswin Murugan
2026-11-01 9:17 ` Kathpalia, Tanmay
2026-11-20 20:08 ` Stephan Gerhold
2 siblings, 0 replies; 4+ messages in thread
From: Aswin Murugan @ 2026-10-31 15:03 UTC (permalink / raw)
To: Igor Opaniuk, Sumit Garg, Tanmay Kathpalia, u-boot-qcom, u-boot
Cc: Casey Connolly, Neil Armstrong, Peng Fan, Jaehoon Chung, Tom Rini,
Varadarajan Narayanan, Balaji Selvanathan
On 10/30/2026 7:27 PM, Igor Opaniuk wrote:
> SDHCI_QUIRK_WAIT_SEND_CMD makes sdhci_send_command() sleep for 1 ms
> after every command. msm_sdhci has set it since the driver was added
> for APQ8016, back when it only did PIO; the commit gives no reason for
> it, and the Linux sdhci-msm driver has no such delay.
>
> The delay is invisible for large reads but dominates small ones. A
> multi-block read is CMD18 followed by CMD12, so every read pays 2 ms
> on top of the transfer. With the eMMC in HS400 a 128 KiB read takes
> about 0.4 ms, so USB mass storage, which reads in 128 KiB (FSG_BUFLEN)
> chunks, spent most of its time in udelay(). On the Arduino UNO Q,
> reading 1 GiB from "ums 0 mmc 0" on a USB 3 host
> (dd if=/dev/sdX of=/dev/null bs=4M count=256):
>
> host throughput time in eMMC reads (10.6k reads)
> with the quirk 46 MB/s 26.8 s (~2.5 ms per read)
> without 201 MB/s 4.5 s (~0.4 ms per read)
>
> A single 128 MiB "mmc read" runs at 255.6 MiB/s either way.
>
> Drop the quirk and keep SDHCI_QUIRK_BROKEN_R1B.
>
> Tested on the Arduino UNO Q (QRB2210, qcom,sdhci-msm-v5, ADMA):
> - on main (eMMC in DDR52): 128 MiB "mmc read" at 75 MiB/s as before,
> the CRC32 of the first 128 MiB read in U-Boot matches the one Linux
> computes from the same blocks, and Linux boots from the eMMC;
> - with the "qcom: Enable HS200/HS400 eMMC modes" series and the
> mass_storage SuperSpeed descriptor patch applied (eMMC in HS400):
> the ums numbers above, same CRC32 check and Linux boot.
> Not tested on v4 controllers or on the boards that use the driver in
> PIO mode (qcom_dragonboard410c, qcom_dragonboard820c, hmibsc).
>
> Signed-off-by: Igor Opaniuk <igor.opaniuk@oss.qualcomm.com>
> ---
> Drop the 1 ms delay msm_sdhci adds after every SD command. It costs
> 2 ms per multi-block read, which capped ums on an Arduino UNO Q at
> 46 MB/s; without it the same read runs at 201 MB/s.
>
> Testing on APQ8016/APQ8096 (PIO mode) would be welcome.
> ---
> 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;
>
>
> ---
> base-commit: 3973f3c4d24df75ca90d7c0a9f03e5e5c9b48f32
> change-id: 20261030-msm-sdhci-wait-send-cmd-4383f2792022
>
> Best regards,
Reviewed-by: Aswin Murugan <aswin.murugan@oss.qualcomm.com>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] mmc: msm_sdhci: drop SDHCI_QUIRK_WAIT_SEND_CMD
2026-10-30 13:57 [PATCH] mmc: msm_sdhci: drop SDHCI_QUIRK_WAIT_SEND_CMD Igor Opaniuk
2026-10-31 15:03 ` Aswin Murugan
@ 2026-11-01 9:17 ` Kathpalia, Tanmay
2026-11-20 20:08 ` Stephan Gerhold
2 siblings, 0 replies; 4+ messages in thread
From: Kathpalia, Tanmay @ 2026-11-01 9:17 UTC (permalink / raw)
To: Igor Opaniuk, Sumit Garg, u-boot-qcom, u-boot
Cc: Casey Connolly, Neil Armstrong, Peng Fan, Jaehoon Chung, Tom Rini,
Varadarajan Narayanan, Aswin Murugan, Balaji Selvanathan
On 30-10-2026 19:27, Igor Opaniuk wrote:
> SDHCI_QUIRK_WAIT_SEND_CMD makes sdhci_send_command() sleep for 1 ms
> after every command.
Nit: "after every command" is slightly broad - with
SDHCI_QUIRK_BROKEN_R1B also set (as msm_sdhci does), busy-response
commands without data already return early in sdhci_send_command()
before reaching this udelay(), so they never paid it. Might be worth
rephrasing to "after most commands" or similar.
Not a blocker, a commit-message polish.
> msm_sdhci has set it since the driver was added
> for APQ8016, back when it only did PIO; the commit gives no reason for
> it, and the Linux sdhci-msm driver has no such delay.
>
> The delay is invisible for large reads but dominates small ones. A
> multi-block read is CMD18 followed by CMD12, so every read pays 2 ms
> on top of the transfer. With the eMMC in HS400 a 128 KiB read takes
> about 0.4 ms, so USB mass storage, which reads in 128 KiB (FSG_BUFLEN)
> chunks, spent most of its time in udelay(). On the Arduino UNO Q,
> reading 1 GiB from "ums 0 mmc 0" on a USB 3 host
> (dd if=/dev/sdX of=/dev/null bs=4M count=256):
>
> host throughput time in eMMC reads (10.6k reads)
> with the quirk 46 MB/s 26.8 s (~2.5 ms per read)
> without 201 MB/s 4.5 s (~0.4 ms per read)
>
> A single 128 MiB "mmc read" runs at 255.6 MiB/s either way.
>
> Drop the quirk and keep SDHCI_QUIRK_BROKEN_R1B.
>
> Tested on the Arduino UNO Q (QRB2210, qcom,sdhci-msm-v5, ADMA):
> - on main (eMMC in DDR52): 128 MiB "mmc read" at 75 MiB/s as before,
> the CRC32 of the first 128 MiB read in U-Boot matches the one Linux
> computes from the same blocks, and Linux boots from the eMMC;
> - with the "qcom: Enable HS200/HS400 eMMC modes" series and the
> mass_storage SuperSpeed descriptor patch applied (eMMC in HS400):
> the ums numbers above, same CRC32 check and Linux boot.
> Not tested on v4 controllers or on the boards that use the driver in
> PIO mode (qcom_dragonboard410c, qcom_dragonboard820c, hmibsc).
>
> Signed-off-by: Igor Opaniuk <igor.opaniuk@oss.qualcomm.com>
Reviewed-by: Tanmay Kathpalia <tanmay.kathpalia@altera.com>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] mmc: msm_sdhci: drop SDHCI_QUIRK_WAIT_SEND_CMD
2026-10-30 13:57 [PATCH] mmc: msm_sdhci: drop SDHCI_QUIRK_WAIT_SEND_CMD Igor Opaniuk
2026-10-31 15:03 ` Aswin Murugan
2026-11-01 9:17 ` Kathpalia, Tanmay
@ 2026-11-20 20:08 ` Stephan Gerhold
2 siblings, 0 replies; 4+ messages in thread
From: Stephan Gerhold @ 2026-11-20 20:08 UTC (permalink / raw)
To: Igor Opaniuk
Cc: Sumit Garg, Tanmay Kathpalia, u-boot-qcom, u-boot, Casey Connolly,
Neil Armstrong, Peng Fan, Jaehoon Chung, Tom Rini,
Varadarajan Narayanan, Aswin Murugan, Balaji Selvanathan
On Fri, Oct 30, 2026 at 02:57:00PM +0100, Igor Opaniuk wrote:
> SDHCI_QUIRK_WAIT_SEND_CMD makes sdhci_send_command() sleep for 1 ms
> after every command. msm_sdhci has set it since the driver was added
> for APQ8016, back when it only did PIO; the commit gives no reason for
> it, and the Linux sdhci-msm driver has no such delay.
>
> The delay is invisible for large reads but dominates small ones. A
> multi-block read is CMD18 followed by CMD12, so every read pays 2 ms
> on top of the transfer. With the eMMC in HS400 a 128 KiB read takes
> about 0.4 ms, so USB mass storage, which reads in 128 KiB (FSG_BUFLEN)
> chunks, spent most of its time in udelay(). On the Arduino UNO Q,
> reading 1 GiB from "ums 0 mmc 0" on a USB 3 host
> (dd if=/dev/sdX of=/dev/null bs=4M count=256):
>
> host throughput time in eMMC reads (10.6k reads)
> with the quirk 46 MB/s 26.8 s (~2.5 ms per read)
> without 201 MB/s 4.5 s (~0.4 ms per read)
>
> A single 128 MiB "mmc read" runs at 255.6 MiB/s either way.
>
> Drop the quirk and keep SDHCI_QUIRK_BROKEN_R1B.
>
> Tested on the Arduino UNO Q (QRB2210, qcom,sdhci-msm-v5, ADMA):
> - on main (eMMC in DDR52): 128 MiB "mmc read" at 75 MiB/s as before,
> the CRC32 of the first 128 MiB read in U-Boot matches the one Linux
> computes from the same blocks, and Linux boots from the eMMC;
> - with the "qcom: Enable HS200/HS400 eMMC modes" series and the
> mass_storage SuperSpeed descriptor patch applied (eMMC in HS400):
> the ums numbers above, same CRC32 check and Linux boot.
> Not tested on v4 controllers or on the boards that use the driver in
> PIO mode (qcom_dragonboard410c, qcom_dragonboard820c, hmibsc).
>
> Signed-off-by: Igor Opaniuk <igor.opaniuk@oss.qualcomm.com>
> ---
> Drop the 1 ms delay msm_sdhci adds after every SD command. It costs
> 2 ms per multi-block read, which capped ums on an Arduino UNO Q at
> 46 MB/s; without it the same read runs at 201 MB/s.
>
> Testing on APQ8016/APQ8096 (PIO mode) would be welcome.
Please Cc the board maintainers (me, for DB410c/APQ8016) if you are
looking for feedback for these boards. I found this patch on the mailing
list only by coincidence.
The fact that APQ8016/APQ8096 use PIO instead of ADMA is a relic from
before ADMA support was introduced. ADMA works just fine in my tests on
these boards and makes no difference for the following test results.
This patch works for the eMMC, but it seems to break SD card detection
on all QC boards I tested.
DB410c (APQ8016):
- eMMC: works
- SD: broken, CMD55 response CRC error
DB820c (APQ8096):
- eMMC: N/A
- SD: broken, CMD55 response CRC error
RB3Gen2 (QCS6490):
- eMMC: N/A
- SD: broken, CMD55 response CRC error
The symptom is that the SD card is simply silently not detected at all,
I added some more logging to find the CMD55 response CRC error. AFAICT
(without investigating in detail), the following happens:
1. In drivers/mmc/mmc.c sd_send_op_cond() U-Boot sends MMC_CMD_APP_CMD
(CMD55), followed by SD_CMD_APP_SEND_OP_COND (ACMD41).
2. The first CMD55 and ACMD41 succeed, cmd.response[0] is 0x00ff8000
so BIT(31) (OCR_BUSY) isn't set yet so it polls again with the same
commands after 1ms.
3. The second CMD55 fails immediately (too early to come from the SD
card with a CRC error).
The CRC error seems to origin from the previous ACMD41. With
SDHCI_QUIRK_WAIT_SEND_CMD we wait long enough after sending the previous
command to clear the CRC error before the next command sees it.
There different options to fix this:
- A retry of CMD55 in case of an error seems to work.
- Maybe we could check and clear unhandled errors in
sdhci_send_command() before sending another command.
This extra diff that implements a retry works for example:
--- a/drivers/mmc/mmc.c
+++ b/drivers/mmc/mmc.c
@@ -674,7 +674,8 @@
cmd.resp_type = MMC_RSP_R1;
cmd.cmdarg = 0;
- err = mmc_send_cmd(mmc, &cmd, NULL);
+ err = mmc_send_cmd_quirks(mmc, &cmd, NULL,
+ MMC_QUIRK_RETRY_APP_CMD, 3);
if (err)
return err;
The real question though is why we are reliably getting this CRC error.
It might be worth to investigate that further. I would expect you can
reproduce this on any QC board with a SD card if you want to test this
further.
SDHCI_QUIRK_BROKEN_R1B on the other hand made no difference in my
testing, I think we could drop that one (Linux does not seem to do this
either).
Thanks,
Stephan
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-11-20 20:08 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-30 13:57 [PATCH] mmc: msm_sdhci: drop SDHCI_QUIRK_WAIT_SEND_CMD Igor Opaniuk
2026-10-31 15:03 ` Aswin Murugan
2026-11-01 9:17 ` Kathpalia, Tanmay
2026-11-20 20:08 ` Stephan Gerhold
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.