Re: [PATCH] mmc: add option to skip eMMC deinit on OS handoff
"Kathpalia, Tanmay" <[email protected]>
| Newsgroups | gmane.comp.boot-loaders.u-boot.general,gmane.comp.boot-loaders.u-boot |
|---|---|
| Message-ID | <[email protected]> |
Hi Minwoo,
On 21-08-2026 14:42, 박민우 (MW Park) wrote:
> When U-Boot hands off to the OS, mmc_deinit() renegotiates the bus
> down out of HS200/HS400 by issuing CMD6 switches and retuning, then
With HS200/HS400 stripped, the path issues CMD6 to switch to HS
timing and then reselects a slower mode(which doesn't require
tuning). Please drop "retuning" (same in the Kconfig help).
> changes the clock. For eMMC this is unnecessary: the OS issues CMD0
> (card reset), which returns the device to backward-compatible mode,
CMD0 returns the protocol state machine to Idle. It is not a
hardware card reset (that is RST_n or a power cycle). Might be
worth wording it that way.
> and renegotiates from scratch regardless of the mode U-Boot left the
> device in.
Please refer to fceea9926804 ("mmc: Downgrade SD/MMC from
UHS/HS200/HS400 modes before boot") for the original motivation.
>
> Add a Kconfig option, MMC_SKIP_DEINIT, to skip this downgrade for
> eMMC devices. SD cards are always deinitialized: a UHS card switched
> to 1.8V signaling cannot be reset by CMD0 and needs a power cycle,
> which not every board can perform.
CMD0 does reset a card that is at 1.8V - it returns to Idle and keeps
working with SDR12 timing. A power cycle is only needed to go
back to 3.3V signaling.
CMD6 (SWITCH_FUNC - Check) can tell you whether the card is
already at 1.8V. So the OS can decide how to re-init the card rather
than assuming a power cycle is required.
I would suggest rewording this paragraph. Keeping SD always-deinit
is perfectly fine, just not for this reason.
>
> This removes unnecessary CMD6 switches, retuning and clock changes
> from the OS-handoff path, which matters on fast-boot / automotive
> platforms.
>
> Signed-off-by: Minwoo Park<[email protected]>
> ---
> drivers/mmc/Kconfig | 23 +++++++++++++++++++++++
> drivers/mmc/mmc.c | 3 +++
> 2 files changed, 26 insertions(+)
>
>
> base-commit: ece349ade2973e220f524ce59e59711cc919263f
> --
> 2.25.1
> This email and any attachments to it may be confidential and are intended solely for the use of the individual to whom it is addressed. Any views or opinions expressed are solely those of the author and do not necessarily represent those of Telechips Inc. If you are not the intended recipient of this email, you must neither take any action based upon its contents nor copy or show it to anyone. Please notify the sender immediately by email if you have received this email by mistake and delete this email from your system. Please consider the environment before printing this email.
>
> diff --git a/drivers/mmc/Kconfig b/drivers/mmc/Kconfig
> index 6c513328de2..8b516bf359f 100644
> --- a/drivers/mmc/Kconfig
> +++ b/drivers/mmc/Kconfig
> @@ -226,6 +226,29 @@ config SPL_MMC_HS200_SUPPORT
> The HS200 mode is support by some eMMC. The bus frequency is up to
> 200MHz. This mode requires tuning the IO.
>
> +config MMC_SKIP_DEINIT
The name MMC_SKIP_DEINIT is broader than the code, which only
skips for eMMC. Would MMC_SKIP_EMMC_DEINIT be a better fit?
Your call.
> + bool "Skip eMMC deinit on OS handoff"
> + depends on MMC_HS200_SUPPORT || MMC_HS400_SUPPORT
Is there a reason MMC_HS400_ES_SUPPORT is left out here? If
there's no reason against it, I'd suggest to add it.
While reviewing this I also noticed the outer guard at the top
of mmc_deinit() has the same gap. I'll send a follow-up patch for that.
> + help
> + When U-Boot hands off to the OS, the MMC subsystem normally
> + renegotiates the bus down out of HS200/HS400 by issuing CMD6
> + switches and retuning, then changes the clock. For eMMC this is
> + unnecessary: the OS issues CMD0 (card reset), which returns the
> + device to backward-compatible mode, and renegotiates from scratch
> + regardless of the mode U-Boot left the device in.
> +
> + Enabling this option skips the deinit for eMMC devices only. SD
> + cards are always deinitialized: a UHS card switched to 1.8V
> + signaling cannot be reset by CMD0 and needs a power cycle, which
> + not every board can perform.
> +
> + This removes unnecessary CMD6 switches, retuning and clock
> + changes from the OS-handoff path, which matters on fast-boot /
> + automotive platforms.
Same as above.
> +
> + If unsure, say N. If your eMMC device or controller cannot be
> + re-initialised by the OS out of HS200/HS400, say N.
"If unsure, say N" is fine. The current wording is a bit vague.
Can you rephrase it to something like say Y: only if the OS can
HW-reset the eMMC (RST_n) or power-cycle.
> +
> config MMC_VERBOSE
> bool "Output more information about the MMC"
> default y
> diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c
> index 2e565560656..121739a0a33 100644
> --- a/drivers/mmc/mmc.c
> +++ b/drivers/mmc/mmc.c
> @@ -3184,6 +3184,9 @@ int mmc_deinit(struct mmc *mmc)
>
> return sd_select_mode_and_width(mmc, caps_filtered);
> } else {
> + if (CONFIG_IS_ENABLED(MMC_SKIP_DEINIT))
> + return 0;
> +
> caps_filtered = mmc->card_caps &
> ~(MMC_CAP(MMC_HS_200) | MMC_CAP(MMC_HS_400) | MMC_CAP(MMC_HS_400_ES));
>