From: "Kathpalia, Tanmay" <tanmay.kathpalia@altera.com>
To: Eric Chung <eric.chung@riscstar.com>,
u-boot-spacemit@groups.io, u-boot@lists.denx.de
Cc: Tom Rini <trini@konsulko.com>, Peng Fan <peng.fan@nxp.com>,
Huan Zhou <pericycle.cc@gmail.com>,
Raymond Mao <raymond.mao@riscstar.com>,
Jaehoon Chung <jh80.chung@samsung.com>,
Bhimeswararao Matsa <bhimeswararao.matsa@gmail.com>,
Kaustabh Chakraborty <kauschluss@disroot.org>,
Han Xu <han.xu@nxp.com>, Yanir Levin <yanir.levin@tandemg.com>,
Christoph Stoidner <c.stoidner@phytec.de>,
Balsundar Ponnusamy <balsundar.ponnusamy@altera.com>,
Daniel Palmer <daniel@thingy.jp>, Anshul Dalal <anshuld@ti.com>,
Bastien Curutchet <bastien.curutchet@bootlin.com>,
Angelo Dureghello <angelo@kernel-space.org>,
Johan Jonker <jbx6244@gmail.com>, Rick Chen <rick@andestech.com>,
Leo <ycliang@andestech.com>,
Sam Protsenko <semen.protsenko@linaro.org>,
Guodong Xu <guodong.xu@riscstar.com>,
Tim Ouyang <tim609@andestech.com>,
Leo Liang <leo.liang@sifive.com>
Subject: Re: [PATCH v3 3/9] mmc: sdhci: enable CMD23 for multi-block transfers
Date: Sun, 5 Jul 2026 15:21:56 +0530 [thread overview]
Message-ID: <52987597-bb11-4193-a28e-223eeab093eb@altera.com> (raw)
In-Reply-To: <20260705-m4-v3-3-5a9bc7f25fc5@riscstar.com>
On 7/5/2026 11:37 AM, Eric Chung wrote:
> Enable the host controller's support for the CMD23 (SET_BLOCK_COUNT)
> command to manage multi-block read/write operations. This allows the
> MMC core to use CMD23 in preference to the legacy CMD18/CMD25 plus
> CMD12 sequence, reducing command overhead and improving I/O
> performance on multi-block transfers.
The commit message claims this enables "host controller" support, but the
changes are entirely in the MMC core (mmc.c) and header. No SDHCI host
driver sets MMC_CAP_CMD23 in this patch. mmc_write_blocks() in
mmc_write.c is not touched. CMD25 still always follows with CMD12.
>
> Signed-off-by: Eric Chung <eric.chung@riscstar.com>
>
> ---
> v3:
> - Avoid to use quirk to enable CMD23. Use capability instead.
> ---
> drivers/mmc/mmc.c | 18 ++++++++++++++----
> include/mmc.h | 6 +++++-
> 2 files changed, 19 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c
> index f0e38efb262..bc8e9ee6d1c 100644
> --- a/drivers/mmc/mmc.c
> +++ b/drivers/mmc/mmc.c
> @@ -461,6 +461,14 @@ static int mmc_read_blocks(struct mmc *mmc, void *dst, lbaint_t start,
> struct mmc_cmd cmd;
> struct mmc_data data;
>
> + if (mmc->host_caps & MMC_CAP_CMD23) {
> + cmd.cmdidx = MMC_CMD_SET_BLOCK_COUNT;
> + cmd.cmdarg = blkcnt & 0x0000ffff;
> + cmd.resp_type = MMC_RSP_R1;
> + if (mmc_send_cmd(mmc, &cmd, NULL))
> + return 0;
> + }
> +
CMD23 is only meaningful before CMD18 (multi-block read). Sending it before
CMD17 (single block, blkcnt == 1) is undefined per the SD spec, which
states: "SET_BLOCK_COUNT - Specify block count for CMD18 and CMD25."
The guard must be:
if (blkcnt > 1 && (mmc->host_caps & MMC_CAP_CMD23)) {
> if (blkcnt > 1)
> cmd.cmdidx = MMC_CMD_READ_MULTIPLE_BLOCK;
> else
> @@ -481,7 +489,7 @@ static int mmc_read_blocks(struct mmc *mmc, void *dst, lbaint_t start,
> if (mmc_send_cmd(mmc, &cmd, &data))
> return 0;
>
> - if (blkcnt > 1) {
> + if (blkcnt > 1 && !(mmc->host_caps & MMC_CAP_CMD23)) {
> if (mmc_send_stop_transmission(mmc, false)) {
> #if !defined(CONFIG_XPL_BUILD) || defined(CONFIG_SPL_LIBCOMMON_SUPPORT)
> log_err("mmc fail to send stop cmd\n");
> @@ -1436,6 +1444,8 @@ static int sd_get_capabilities(struct mmc *mmc)
>
> if (mmc->scr[0] & SD_DATA_4BIT)
> mmc->card_caps |= MMC_MODE_4BIT;
> + if (!(mmc->scr[0] & SD_SCR_CMD23_SUPPORT))
> + mmc->host_caps &= ~MMC_CAP_CMD23;
Clearing CMD23 capability when the card does not advertise support via
SCR[33] only for SD cards via sd_get_capabilities()but for eMMC the
MMC_CAP_CMD23 flag set by the host driver will remain unconditionally.
Similar handing should be done in mmc_get_capabilities().
>
> /* Version 1.0 doesn't support switching */
> if (mmc->version == SD_VERSION_1_0)
> @@ -2963,9 +2973,9 @@ int mmc_get_op_cond(struct mmc *mmc, bool quiet)
> return err;
>
> #ifdef CONFIG_MMC_QUIRKS
> - mmc->quirks = MMC_QUIRK_RETRY_SET_BLOCKLEN |
> - MMC_QUIRK_RETRY_SEND_CID |
> - MMC_QUIRK_RETRY_APP_CMD;
> + mmc->quirks |= MMC_QUIRK_RETRY_SET_BLOCKLEN |
> + MMC_QUIRK_RETRY_SEND_CID |
> + MMC_QUIRK_RETRY_APP_CMD;
Unrelated to CMD23 support.
> #endif
>
> err = mmc_power_cycle(mmc);
> diff --git a/include/mmc.h b/include/mmc.h
> index 9509c9e9543..b663da71019 100644
> --- a/include/mmc.h
> +++ b/include/mmc.h
> @@ -67,6 +67,7 @@ struct bd_info;
> #define MMC_CAP_NONREMOVABLE BIT(14)
> #define MMC_CAP_NEEDS_POLL BIT(15)
> #define MMC_CAP_CD_ACTIVE_HIGH BIT(16)
> +#define MMC_CAP_CMD23 BIT(17)
>
> #define MMC_MODE_8BIT BIT(30)
> #define MMC_MODE_4BIT BIT(29)
> @@ -141,6 +142,8 @@ static inline bool mmc_is_tuning_cmd(uint cmdidx)
> #define SD_HIGHSPEED_BUSY 0x00020000
> #define SD_HIGHSPEED_SUPPORTED 0x00020000
>
> +#define SD_SCR_CMD23_SUPPORT BIT(1)
> +
> #define UHS_SDR12_BUS_SPEED 0
> #define HIGH_SPEED_BUS_SPEED 1
> #define UHS_SDR25_BUS_SPEED 1
> @@ -343,7 +346,8 @@ static inline bool mmc_is_tuning_cmd(uint cmdidx)
>
> #define MMC_QUIRK_RETRY_SEND_CID BIT(0)
> #define MMC_QUIRK_RETRY_SET_BLOCKLEN BIT(1)
> -#define MMC_QUIRK_RETRY_APP_CMD BIT(2)
> +#define MMC_QUIRK_RETRY_APP_CMD BIT(2)
> +#define MMC_QUIRK_BLK_CMD23 BIT(3)
BLK_CMD23 quirk leftover from the previous patch
Regards,
Tanmay Kathpalia
next prev parent reply other threads:[~2026-07-05 9:52 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-05 6:07 [PATCH v3 0/9] spacemit mmc driver Eric Chung
2026-07-05 6:07 ` [PATCH v3 1/9] spacemit: k1: select boot device via config registers Eric Chung
2026-07-05 6:07 ` [PATCH v3 2/9] pinctrl: k1: add IO power domain configuration support Eric Chung
2026-07-05 6:07 ` [PATCH v3 3/9] mmc: sdhci: enable CMD23 for multi-block transfers Eric Chung
2026-07-05 9:51 ` Kathpalia, Tanmay [this message]
2026-07-05 15:21 ` Eric Chung
2026-07-05 18:28 ` Kathpalia, Tanmay
2026-07-05 6:07 ` [PATCH v3 4/9] mmc: k1: add sdhci platform driver Eric Chung
2026-07-05 10:20 ` Kathpalia, Tanmay
2026-07-05 6:07 ` [PATCH v3 5/9] dts: k1: add SD card support in u-boot overlay Eric Chung
2026-07-05 6:07 ` [PATCH v3 6/9] configs: k1: enable SD and eMMC support Eric Chung
2026-07-05 6:07 ` [PATCH v3 7/9] doc: spacemit: flash on K1 SoC based boards Eric Chung
2026-07-05 6:07 ` [PATCH v3 8/9] config: k1: enable ENV support for eMMC Eric Chung
2026-07-05 6:08 ` [PATCH v3 9/9] spacemit: k1: load product name from environment variable Eric Chung
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=52987597-bb11-4193-a28e-223eeab093eb@altera.com \
--to=tanmay.kathpalia@altera.com \
--cc=angelo@kernel-space.org \
--cc=anshuld@ti.com \
--cc=balsundar.ponnusamy@altera.com \
--cc=bastien.curutchet@bootlin.com \
--cc=bhimeswararao.matsa@gmail.com \
--cc=c.stoidner@phytec.de \
--cc=daniel@thingy.jp \
--cc=eric.chung@riscstar.com \
--cc=guodong.xu@riscstar.com \
--cc=han.xu@nxp.com \
--cc=jbx6244@gmail.com \
--cc=jh80.chung@samsung.com \
--cc=kauschluss@disroot.org \
--cc=leo.liang@sifive.com \
--cc=peng.fan@nxp.com \
--cc=pericycle.cc@gmail.com \
--cc=raymond.mao@riscstar.com \
--cc=rick@andestech.com \
--cc=semen.protsenko@linaro.org \
--cc=tim609@andestech.com \
--cc=trini@konsulko.com \
--cc=u-boot-spacemit@groups.io \
--cc=u-boot@lists.denx.de \
--cc=yanir.levin@tandemg.com \
--cc=ycliang@andestech.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