Re: [PATCH v12 3/6] mmc: core: Add option to keep an eMMC powered on at system suspend
From: Kamal Dasu
Date: Thu Nov 12 2026 - 14:08:58 EST
On Wed, Nov 11, 2026 at 2:44 PM Kamal Dasu <kamal.dasu@xxxxxxxxxxxx> wrote:
>
> From: Ulf Hansson <ulf.hansson@xxxxxxxxxxxxxxxx>
>
> The DT property keep-power-in-suspend, allows us to specify whether the
> platform is capable of keeping the power to the card during system suspend.
> Up until now, this has been restricted to be used for SDIO cards only, but
> let's add the initial support to allow this for eMMC too.
>
> Signed-off-by: Ulf Hansson <ulf.hansson@xxxxxxxxxxxxxxxx>
> Reviewed-by: Shawn Lin <shawn.lin@xxxxxxxxxxxxxx>
> Signed-off-by: Kamal Dasu <kamal.dasu@xxxxxxxxxxxx>
> ---
> drivers/mmc/core/mmc.c | 24 +++++++++++++++++++++++-
> 1 file changed, 23 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c
> index a02b04938e1a..c936272bcd81 100644
> --- a/drivers/mmc/core/mmc.c
> +++ b/drivers/mmc/core/mmc.c
> @@ -38,6 +38,7 @@ enum mmc_poweroff_type {
> MMC_POWEROFF_SHUTDOWN,
> MMC_POWEROFF_UNDERVOLTAGE,
> MMC_POWEROFF_UNBIND,
> + MMC_NO_POWEROFF_SUSPEND,
> };
>
> static const unsigned int tran_exp[] = {
> @@ -2157,6 +2158,15 @@ static int _mmc_suspend(struct mmc_host *host, enum mmc_poweroff_type pm_type)
> goto out;
> }
>
> + if (pm_type == MMC_NO_POWEROFF_SUSPEND) {
> + if (host->retune_period) {
> + mmc_retune_timer_stop(host);
> + mmc_retune_needed(host);
> + }
> + mmc_card_set_suspended(host->card);
> + goto out;
> + }
> +
> if (mmc_card_can_poweroff_notify(host->card) &&
> mmc_host_can_poweroff_notify(host, pm_type))
> err = mmc_poweroff_notify(host->card, notify_type);
> @@ -2193,9 +2203,15 @@ static void mmc_remove(struct mmc_host *host)
> */
> static int mmc_suspend(struct mmc_host *host)
> {
> + enum mmc_poweroff_type pm_type = MMC_POWEROFF_SUSPEND;
> int err;
>
> - err = _mmc_suspend(host, MMC_POWEROFF_SUSPEND);
> + if (mmc_card_keep_power(host)) {
> + pm_runtime_resume(&host->card->dev);
> + pm_type = MMC_NO_POWEROFF_SUSPEND;
> + }
> +
> + err = _mmc_suspend(host, pm_type);
> if (!err) {
> pm_runtime_disable(&host->card->dev);
> pm_runtime_set_suspended(&host->card->dev);
> @@ -2260,7 +2276,13 @@ static int mmc_shutdown(struct mmc_host *host)
> */
> static int mmc_resume(struct mmc_host *host)
> {
> + if (mmc_card_keep_power(host)) {
> + pm_runtime_set_active(&host->card->dev);
> + mmc_card_clr_suspended(host->card);
> + }
> +
> pm_runtime_enable(&host->card->dev);
> + host->pm_flags &= ~MMC_PM_KEEP_POWER;
> return 0;
> }
>
Hi Ulf,
Sashiko reviewed this patch and sent the result to me and the DT list
only: https://sashiko.dev/#/patchset/20261111194426.1652644-1-kamal.dasu@xxxxxxxxxxxx?part=3
It points out that with MMC_NO_POWEROFF_SUSPEND, CQE can stay on across
suspend if _mmc_flush_cache() sends no command (e.g. cache disabled),
since the flush is then the only thing that would call ->cqe_off(). It
looks valid to me from reading the code.
This patch is unchanged since v10 and Sashiko had no findings on it for
v11.
Would you like a guard in that branch, e.g.
"if (host->cqe_on) host->cqe_ops->cqe_off(host);"? I can fold it into
the next version v13 if so.
Regards
Kamal
Attachment:
smime.p7s
Description: S/MIME Cryptographic Signature