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 mode supports High Speed
SDR. Drop incompatible HS200/HS400/UHS/DDR caps early so timing
selection falls through to mmc_select_hs() correctly.
Signed-off-by: Luke Wang <ziniu.wang_1@nxp.com>
---
drivers/mmc/host/sdhci.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
index b1a3cd574c84..3e163f14a640 100644
--- a/drivers/mmc/host/sdhci.c
+++ b/drivers/mmc/host/sdhci.c
@@ -4539,8 +4539,14 @@ int sdhci_setup_host(struct sdhci_host *host)
* their platform code before calling sdhci_add_host(), and we
* won't assume 8-bit width for hosts without that CAP.
*/
- if (!(host->quirks & SDHCI_QUIRK_FORCE_1_BIT_DATA))
+ if (host->quirks & SDHCI_QUIRK_FORCE_1_BIT_DATA) {
+ host->caps1 &= ~(SDHCI_SUPPORT_SDR104 | SDHCI_SUPPORT_SDR50 |
+ SDHCI_SUPPORT_DDR50 | SDHCI_SUPPORT_HS400);
+ mmc->caps2 &= ~(MMC_CAP2_HS200 | MMC_CAP2_HS400 | MMC_CAP2_HS400_ES);
+ mmc->caps &= ~(MMC_CAP_DDR | MMC_CAP_UHS);
+ } else {
mmc->caps |= MMC_CAP_4_BIT_DATA;
+ }
if (host->quirks2 & SDHCI_QUIRK2_HOST_NO_CMD23)
mmc->caps &= ~MMC_CAP_CMD23;
--
2.34.1
On 03/03/2026 12:50, ziniu.wang_1@nxp.com wrote:
> 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 mode supports High Speed
> SDR. Drop incompatible HS200/HS400/UHS/DDR caps early so timing
> selection falls through to mmc_select_hs() correctly.
>
Fixes: f2119df6b7646 ("mmc: sd: add support for signal voltage switch procedure")
> Signed-off-by: Luke Wang <ziniu.wang_1@nxp.com>
> ---
> drivers/mmc/host/sdhci.c | 8 +++++++-
> 1 file changed, 7 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
> index b1a3cd574c84..3e163f14a640 100644
> --- a/drivers/mmc/host/sdhci.c
> +++ b/drivers/mmc/host/sdhci.c
> @@ -4539,8 +4539,14 @@ int sdhci_setup_host(struct sdhci_host *host)
> * their platform code before calling sdhci_add_host(), and we
> * won't assume 8-bit width for hosts without that CAP.
> */
> - if (!(host->quirks & SDHCI_QUIRK_FORCE_1_BIT_DATA))
> + if (host->quirks & SDHCI_QUIRK_FORCE_1_BIT_DATA) {
> + host->caps1 &= ~(SDHCI_SUPPORT_SDR104 | SDHCI_SUPPORT_SDR50 |
> + SDHCI_SUPPORT_DDR50 | SDHCI_SUPPORT_HS400);
SDHCI_SUPPORT_HS400 is non-standard. Hence the check for
SDHCI_QUIRK2_CAPS_BIT63_FOR_HS400 is needed:
host->caps1 &= ~(SDHCI_SUPPORT_SDR104 | SDHCI_SUPPORT_SDR50 | SDHCI_SUPPORT_DDR50);
if (host->quirks2 & SDHCI_QUIRK2_CAPS_BIT63_FOR_HS400)
host->caps1 &= ~SDHCI_SUPPORT_HS400;
> + mmc->caps2 &= ~(MMC_CAP2_HS200 | MMC_CAP2_HS400 | MMC_CAP2_HS400_ES);
> + mmc->caps &= ~(MMC_CAP_DDR | MMC_CAP_UHS);
> + } else {
> mmc->caps |= MMC_CAP_4_BIT_DATA;
> + }
>
> if (host->quirks2 & SDHCI_QUIRK2_HOST_NO_CMD23)
> mmc->caps &= ~MMC_CAP_CMD23;
From: Frank Li (AI-BOT) <frank.li@nxp.com>
Subject: Re: [PATCH v2 1/4] mmc: sdhci: fix timing selection for 1-bit bus width
> - if (!(host->quirks & SDHCI_QUIRK_FORCE_1_BIT_DATA))
> + if (host->quirks & SDHCI_QUIRK_FORCE_1_BIT_DATA) {
> + host->caps1 &= ~(SDHCI_SUPPORT_SDR104 | SDHCI_SUPPORT_SDR50 |
> + SDHCI_SUPPORT_DDR50 | SDHCI_SUPPORT_HS400);
> + mmc->caps2 &= ~(MMC_CAP2_HS200 | MMC_CAP2_HS400 | MMC_CAP2_HS400_ES);
> + mmc->caps &= ~(MMC_CAP_DDR | MMC_CAP_UHS);
> + } else {
> mmc->caps |= MMC_CAP_4_BIT_DATA;
> + }
The logic inversion here is correct and the fix addresses the root cause
per JEDEC spec. However, consider whether clearing MMC_CAP_UHS is
necessary—UHS modes require 4-bit width anyway, so this may be redundant
with the SDR104/SDR50/DDR50 clears. If intentional for belt-and-suspenders
safety, add a brief comment explaining why.
Also verify that mmc pointer is always valid at this point in
sdhci_setup_host(). If there's any path where mmc could be NULL, the
new code will crash.
AI bot review and may be useless.
© 2016 - 2026 Red Hat, Inc.