Devicetree
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Kamal Dasu" <kamal.dasu@broadcom.com>
Cc: devicetree@vger.kernel.org, conor+dt@kernel.org, robh@kernel.org
Subject: Re: [PATCH v8 3/3] mmc: core: Honor keep-power-in-suspend and reset-card-at-resume for (e)MMC
Date: Fri, 07 Aug 2026 20:13:05 +0000	[thread overview]
Message-ID: <20260807201306.584FA1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260807200121.2590202-4-kamal.dasu@broadcom.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] The shutdown/undervoltage fallback path in _mmc_suspend attempts to reselect a firmware-clobbered card without resetting the host controller, guaranteeing a selection failure that silently skips the required power-off.
--

--- Patch [3]: [PATCH v8 3/3] mmc: core: Honor keep-power-in-suspend and reset-card-at-resume for (e)MMC ---
commit 035aca0a123c885d88b4aa6c2a934f57e12bf03c
Author: Kamal Dasu <kamal.dasu@broadcom.com>

mmc: core: Honor keep-power-in-suspend and reset-card-at-resume for (e)MMC

This commit adds support for keep-power-in-suspend and reset-card-at-resume
for (e)MMC devices. It keeps the card powered during suspend so firmware can
access it, and resets the card when the kernel resumes. It also adjusts
_mmc_suspend() to handle shutdown and undervoltage cases when the card is
already in the keep-power suspended state.

Link: https://lore.kernel.org/r/20260413180551.3683969-1-florian.fainelli@broadcom.com/

> diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c
> index 05444ecf3909f..a081907bbcf53 100644
> --- a/drivers/mmc/core/mmc.c
> +++ b/drivers/mmc/core/mmc.c

[ ... ]

> @@ -2144,8 +2144,28 @@ static int _mmc_suspend(struct mmc_host *host, enum mmc_poweroff_type pm_type)
>  
>  	mmc_claim_host(host);
>  
> -	if (mmc_card_suspended(host->card))
> -		goto out;
> +	if (mmc_card_suspended(host->card)) {
> +		/*
> +		 * Nothing to do for a redundant suspend call. Otherwise, the
> +		 * card can only still be marked suspended here because the
> +		 * keep-power fast path below left it powered and merely
> +		 * deselected -- reselect it and continue into the normal
> +		 * power-off sequence below, since shutdown, unbind and
> +		 * undervoltage need mmc_power_off() regardless of how the
> +		 * card got here.
> +		 */
> +		if (pm_type == MMC_POWEROFF_SUSPEND ||
> +		    !(host->pm_flags & MMC_PM_KEEP_POWER))
> +			goto out;
> +
> +		if (!mmc_host_is_spi(host)) {
> +			err = mmc_select_card(host->card);
> +			if (err)
> +				goto out;

[Severity: High]
Since the firmware might have modified the card state during suspend
(which is why reset-card-at-resume is used), will mmc_select_card() fail
here if we haven't reset the host and re-initialized the card first?

If mmc_select_card() fails (e.g. CMD7 timeout), taking the goto out
path will completely skip the mmc_power_off() sequence. Does this leave
the card powered on during shutdown or undervoltage, defeating the
purpose of this fallback path?

> +		}
> +		mmc_card_clr_suspended(host->card);
> +		host->pm_flags &= ~MMC_PM_KEEP_POWER;
> +	}
>  
>  	/*
>  	 * For the undervoltage case, we care more about device integrity.
> @@ -2157,6 +2177,33 @@ static int _mmc_suspend(struct mmc_host *host, enum mmc_poweroff_type pm_type)
>  			goto out;

[Severity: High]
Just below this hunk in _mmc_suspend(), the cache is flushed:

	if (pm_type != MMC_POWEROFF_UNDERVOLTAGE) {
		err = _mmc_flush_cache(host);
		if (err)
			goto out;
	}

Even if mmc_select_card() were to succeed or its error were ignored,
would _mmc_flush_cache() also fail due to the clobbered card state and
abort the power-off sequence?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260807200121.2590202-1-kamal.dasu@broadcom.com?part=3

      reply	other threads:[~2026-08-07 20:13 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-07 20:01 [PATCH v8 0/3] mmc: core: Keep the card powered across suspend when firmware needs it live Kamal Dasu
2026-08-07 20:01 ` [PATCH v8 1/3] dt-bindings: mmc: Extend keep-power-in-suspend beyond SDIO Kamal Dasu
2026-08-07 20:01 ` [PATCH v8 2/3] dt-bindings: mmc: Add reset-card-at-resume property Kamal Dasu
2026-08-07 20:01 ` [PATCH v8 3/3] mmc: core: Honor keep-power-in-suspend and reset-card-at-resume for (e)MMC Kamal Dasu
2026-08-07 20:13   ` sashiko-bot [this message]

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=20260807201306.584FA1F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=kamal.dasu@broadcom.com \
    --cc=robh@kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /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