Re: [PATCH] mmc: core: Don't program invalid host driver type for fixed eMMC type
From: Ulf Hansson
Date: Tue Sep 29 2026 - 09:08:29 EST
+ Adrian
On Sat, Sep 26, 2026 at 2:29 PM Ian Ray <ian.ray@xxxxxxxxxxxxxxxx> wrote:
>
> The host controller driver type value used by the MMC core [1] _mostly_
> overlaps with the eMMC device I/O driver strength value [2] as shown in
> the table below; however, there is _no_ host mapping for eMMC value 4.
I think the mapping exists only because that is what the SD spec
provided when this was introduced.
We can certainly add something that corresponds to value 4 from the
eMMC spec as well, to make this complete.
>
> host value/type | eMMC value | nominal impedance | strength
> ------------------+------------+-------------------+---------
> 0 / Type B | 0 | 50 Ohm | x1
> 1 / Type A | 1 | 33 Ohm | x1.5
> 2 / Type C | 2 | 66 Ohm | x0.75
> 3 / Type D | 3 | 100 Ohm | x0.5
> (none) | 4 | 40 Ohm | x1.2
>
> [1] MMC_SET_DRIVER_TYPE_* in include/linux/mmc/host.h
>
> [2] 'fixed-emmc-driver-type', see JESD84-B51 Table 206 and
>
>
> Since commit 5a52c5701a67 ("mmc: core: Fix host controller programming
> for fixed driver type"), the selected eMMC driver strength is passed
> directly to mmc_set_driver_type(). For a fixed eMMC driver type of 4
> this reaches sdhci_set_ios(), which only knows types 0..3 and therefore
> complains on every ios update:
>
> mmc2: invalid driver type, default to driver type B
Perhaps the print above from sdhci_set_ios() is simply a bit
misleading. For example, it looks like arasan_select_phy_clock()
actually uses the value in ios.drv_type as is.
To me, it looks like the problem is that mmc_select_drive_strength()
doesn't really do its job correctly, as it should help us to figure
out what is supported by the card *and* by the host, so we can request
a proper driver type when calling the ->set_ios() callback.
>
> The mmc card itself is still programmed correctly (the HS_TIMING driver
> strength field is set from card->drive_strength independently), so this
> is a spurious, repeated warning for a valid, documented configuration.
>
> Change to only program the host when the eMMC driver type value maps to
> a valid host driver type.
>
> Tested on i.MX8MP (usdhc3, eMMC in HS400) with
> `fixed-emmc-driver-type = <4>`: the warning is no longer logged and the
> HS_TIMING register contains 0x43 as expected.
>
> Fixes: 5a52c5701a67 ("mmc: core: Fix host controller programming for fixed driver type")
> Cc: stable@xxxxxxxxxxxxxxx
> Signed-off-by: Ian Ray <ian.ray@xxxxxxxxxxxxxxxx>
I have looped in Adrian, to get his opinion on this.
Kind regards
Uffe
> ---
> drivers/mmc/core/mmc.c | 8 +++++---
> 1 file changed, 5 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c
> index 05444ecf3909..ff5d4b805998 100644
> --- a/drivers/mmc/core/mmc.c
> +++ b/drivers/mmc/core/mmc.c
> @@ -1371,9 +1371,11 @@ static void mmc_select_driver_type(struct mmc_card *card)
>
> card->drive_strength = drive_strength;
>
> - if (fixed_drv_type >= 0 && drive_strength)
> - mmc_set_driver_type(card->host, drive_strength);
> - else if (drv_type)
> + if (fixed_drv_type >= 0 && drive_strength) {
> + /* eMMC driver types >= 4 have no host controller equivalent. */
> + if (drive_strength <= MMC_SET_DRIVER_TYPE_D)
> + mmc_set_driver_type(card->host, drive_strength);
> + } else if (drv_type)
> mmc_set_driver_type(card->host, drv_type);
> }
>
> --
> 2.49.0
>