From: Stephan Gerhold <stephan.gerhold@linaro.org>
To: Igor Opaniuk <igor.opaniuk@oss.qualcomm.com>
Cc: Sumit Garg <sumit.garg@kernel.org>,
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>,
Peng Fan <peng.fan@nxp.com>,
Jaehoon Chung <jh80.chung@samsung.com>,
Tom Rini <trini@konsulko.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] mmc: msm_sdhci: drop SDHCI_QUIRK_WAIT_SEND_CMD
Date: Mon, 23 Nov 2026 14:31:46 +0100 [thread overview]
Message-ID: <awRAQoPoRP6gAm9E@linaro.org> (raw)
In-Reply-To: <CAPzfCAZik7_3hBzyMuZ76JG2WjOGTaaRLSec21HLYHWEDk_TEA@mail.gmail.com>
On Mon, Nov 23, 2026 at 09:47:32AM +0100, Igor Opaniuk wrote:
> On Fri, Nov 20, 2026 at 9:08 PM Stephan Gerhold
> <stephan.gerhold@linaro.org> wrote:
> >
> > 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.
>
> Sorry about that (I relied too much on get_maintaners script),
> and thanks a lot for testing on three boards anyway. v2 has you and
> the other board maintainers on Cc.
>
> >
> > 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.
>
> I looked into it. The UNO Q has no SD slot, but the same thing happens
> on its eMMC, only hidden - on every mmc rescan the first CMD2 after
> the last CMD1 fails on the first status read with INT_STATUS
> 0x00028000 and then passes on the MMC_QUIRK_RETRY_SEND_CID retry. So
> the common factor is a CRC-checked command that follows an R3 response
> (CMD1 here, ACMD41 in your case).
>
> With a status trace in sdhci_send_command() (card clock 188 kHz):
>
> 1. INT_STATUS reads 0 right before the failing command, even 10 ms after
> the R3 response, so clearing unhandled errors before the next command
> would not see anything;
> 2. Waiting before that command does not help (50 us to 10 ms, all fail);
> 3. Delaying the final status clear of the R3 command itself does: 8 us
> still fails 6/6, 12 us and more pass 6/6.
>
> So the R3 response seems to leave a latent CRC error that only a status
> clear a few SD clock cycles after completion removes, and the clear
> done right at completion comes too early. That is what
> SDHCI_QUIRK_WAIT_SEND_CMD was hiding with its 1 ms.
>
> In v2 I'll add a patch that waits 16 SD clock periods before the final status
> clear when the response carries no CRC (CMD1 and ACMD41 only). With it
> the CMD2 passes 50/50 here and is sent only once.
>
> Unfortuantely I cannot test the SD case now. Could you try v2 on one of your
> boards? It does not include your CMD55 retry you shared, and if the delay
> does not cover SD, I will add the retry you mentioned in v3.
>
Thanks, I replied directly to v2 (works fine for eMMC/SD on DB410c).
> >
> > 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).
>
> I would do that as a separate patch if you don't mind once I have run an erase
> test here, since R1b commands then wait for the data-end interrupt.
FWIW, I did a couple of erase tests on DB410c and the data-end interrupt
was triggered just fine in all cases.
Thanks,
Stephan
prev parent reply other threads:[~2026-11-23 13:31 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
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
2026-11-23 8:47 ` Igor Opaniuk
2026-11-23 13:31 ` Stephan Gerhold [this message]
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=awRAQoPoRP6gAm9E@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=igor.opaniuk@oss.qualcomm.com \
--cc=jh80.chung@samsung.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 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.