From: Shawn Lin <shawn.lin@rock-chips.com>
To: ziniu.wang_1@nxp.com
Cc: shawn.lin@rock-chips.com, Frank.Li@nxp.com,
s.hauer@pengutronix.de, kernel@pengutronix.de,
festevam@gmail.com, imx@lists.linux.dev,
linux-mmc@vger.kernel.org, s32@nxp.com,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, haibo.chen@nxp.com,
ulf.hansson@linaro.org, adrian.hunter@intel.com
Subject: Re: [PATCH 1/4] mmc: core: fix timing selection for 1-bit bus width
Date: Mon, 2 Mar 2026 16:54:27 +0800 [thread overview]
Message-ID: <2135cbdd-9329-1097-dd38-bb12aa1a7ff6@rock-chips.com> (raw)
In-Reply-To: <20260302080057.974102-2-ziniu.wang_1@nxp.com>
Hi Luke
在 2026/03/02 星期一 16:00, ziniu.wang_1@nxp.com 写道:
> From: Luke Wang <ziniu.wang_1@nxp.com>
>
> When 1-bit bus width is used with HS200/HS400 capabilities set,
> mmc_select_hs200() returns 0 without actually switching. This
> causes mmc_select_timing() to skip mmc_select_hs(), leaving eMMC
> in legacy mode (26MHz) instead of High Speed SDR (52MHz).
>
> Per JEDEC eMMC spec section 5.3.2, 1-bit width supports High Speed
> SDR. Drop incompatible HS200/HS400/UHS/DDR caps early so timing
> selection falls through to mmc_select_hs() correctly.
>
I've tested this patch, and it works as intended.
Unrelated to your specific change, however, I'm not convinced that
mmc_validate_host_caps() is doing what its name suggests, at least not
comprehensively. For example, the SD card path handles 1-bit bus with
UHS support correctly, thanks to the mmc_host_uhs() check inside the
SD/SDIO code. This makes the validation logic feel scattered across
different layers IMO. It would be even better if you could consolidate
all these checks in one place maybe, but anyway
Tested-by: Shawn Lin <shawn.lin@rock-chips.com>
> Signed-off-by: Luke Wang <ziniu.wang_1@nxp.com>
> ---
> drivers/mmc/core/host.c | 19 ++++++++++++++-----
> 1 file changed, 14 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/mmc/core/host.c b/drivers/mmc/core/host.c
> index 88c95dbfd9cf..18b9c3174e1f 100644
> --- a/drivers/mmc/core/host.c
> +++ b/drivers/mmc/core/host.c
> @@ -617,17 +617,26 @@ EXPORT_SYMBOL(devm_mmc_alloc_host);
> static int mmc_validate_host_caps(struct mmc_host *host)
> {
> struct device *dev = host->parent;
> - u32 caps = host->caps, caps2 = host->caps2;
>
> - if (caps & MMC_CAP_SDIO_IRQ && !host->ops->enable_sdio_irq) {
> + if (host->caps & MMC_CAP_SDIO_IRQ && !host->ops->enable_sdio_irq) {
> dev_warn(dev, "missing ->enable_sdio_irq() ops\n");
> return -EINVAL;
> }
>
> - if (caps2 & (MMC_CAP2_HS400_ES | MMC_CAP2_HS400) &&
> - !(caps & MMC_CAP_8_BIT_DATA) && !(caps2 & MMC_CAP2_NO_MMC)) {
> + /* UHS/DDR/HS200/HS400 modes require at least 4-bit bus */
> + if (!(host->caps & (MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA)) &&
> + ((host->caps & (MMC_CAP_UHS | MMC_CAP_DDR)) ||
> + (host->caps2 & (MMC_CAP2_HS200 | MMC_CAP2_HS400_ES | MMC_CAP2_HS400)))) {
> + dev_warn(dev, "drop UHS/DDR/HS200/HS400 support since 1-bit bus only\n");
> + host->caps &= ~(MMC_CAP_UHS | MMC_CAP_DDR);
> + host->caps2 &= ~(MMC_CAP2_HS200 | MMC_CAP2_HS400_ES | MMC_CAP2_HS400);
> + }
> +
> + if (host->caps2 & (MMC_CAP2_HS400_ES | MMC_CAP2_HS400) &&
> + !(host->caps & MMC_CAP_8_BIT_DATA) &&
> + !(host->caps2 & MMC_CAP2_NO_MMC)) {
> dev_warn(dev, "drop HS400 support since no 8-bit bus\n");
> - host->caps2 = caps2 & ~MMC_CAP2_HS400_ES & ~MMC_CAP2_HS400;
> + host->caps2 &= ~(MMC_CAP2_HS400_ES | MMC_CAP2_HS400);
> }
>
> return 0;
>
next prev parent reply other threads:[~2026-03-02 8:59 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-02 8:00 [PATCH 0/4] mmc: sdhci-esdhc-imx: add 1-bit bus width support ziniu.wang_1
2026-03-02 8:00 ` [PATCH 1/4] mmc: core: fix timing selection for 1-bit bus width ziniu.wang_1
2026-03-02 8:54 ` Shawn Lin [this message]
2026-03-02 8:00 ` [PATCH 2/4] mmc: sdhci-esdhc-imx: add 1-bit bus width support ziniu.wang_1
2026-03-02 8:00 ` [PATCH 3/4] mmc: sdhci-esdhc-imx: remove duplicate HS400 bus width validation ziniu.wang_1
2026-03-02 8:00 ` [PATCH 4/4] mmc: sdhci-pltfm: remove duplicate DTS property parsing ziniu.wang_1
2026-03-02 13:44 ` [PATCH 0/4] mmc: sdhci-esdhc-imx: add 1-bit bus width support Adrian Hunter
2026-03-03 3:39 ` [EXT] " Luke Wang
2026-03-03 9:29 ` Adrian Hunter
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=2135cbdd-9329-1097-dd38-bb12aa1a7ff6@rock-chips.com \
--to=shawn.lin@rock-chips.com \
--cc=Frank.Li@nxp.com \
--cc=adrian.hunter@intel.com \
--cc=festevam@gmail.com \
--cc=haibo.chen@nxp.com \
--cc=imx@lists.linux.dev \
--cc=kernel@pengutronix.de \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mmc@vger.kernel.org \
--cc=s.hauer@pengutronix.de \
--cc=s32@nxp.com \
--cc=ulf.hansson@linaro.org \
--cc=ziniu.wang_1@nxp.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