lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID:
 <PH7PR16MB6196C3AC7A7B7CA99A70E7DDE5A02@PH7PR16MB6196.namprd16.prod.outlook.com>
Date: Fri, 28 Mar 2025 13:55:51 +0000
From: Avri Altman <Avri.Altman@...disk.com>
To: Ulf Hansson <ulf.hansson@...aro.org>, "linux-mmc@...r.kernel.org"
	<linux-mmc@...r.kernel.org>
CC: Adrian Hunter <adrian.hunter@...el.com>, Wolfram Sang
	<wsa+renesas@...g-engineering.com>, Yoshihiro Shimoda
	<yoshihiro.shimoda.uh@...esas.com>, "linux-renesas-soc@...r.kernel.org"
	<linux-renesas-soc@...r.kernel.org>, "linux-kernel@...r.kernel.org"
	<linux-kernel@...r.kernel.org>
Subject: RE: [PATCH 2/5] mmc: core: Further avoid re-storing power to the eMMC
 before a shutdown

> To manage a graceful power-off of the eMMC card during platform shutdown,
> the preferred option is to use the poweroff-notification command.
> 
> Due to an earlier suspend request the eMMC may already have been properly
> powered-off, hence we are sometimes leaving the eMMC in its current state.
> However, in one case when the host has
> MMC_CAP2_FULL_PWR_CYCLE_IN_SUSPEND
> set we may unnecessarily restore the power to the eMMC, let's avoid this.
> 
> Signed-off-by: Ulf Hansson <ulf.hansson@...aro.org>
> ---
>  drivers/mmc/core/mmc.c | 17 ++++++++++++++---
>  1 file changed, 14 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c index
> 3424bc9e20c5..400dd0449fec 100644
> --- a/drivers/mmc/core/mmc.c
> +++ b/drivers/mmc/core/mmc.c
> @@ -2014,6 +2014,18 @@ static bool mmc_can_poweroff_notify(const
> struct mmc_card *card)
>  		(card->ext_csd.power_off_notification ==
> EXT_CSD_POWER_ON);  }
> 
> +static bool mmc_may_poweroff_notify(const struct mmc_host *host,
> +				    bool is_suspend)
> +{
> +	if (host->caps2 & MMC_CAP2_FULL_PWR_CYCLE)
> +		return true;
> +
> +	if (host->caps2 & MMC_CAP2_FULL_PWR_CYCLE_IN_SUSPEND &&
> is_suspend)
> +		return true;
> +
> +	return !is_suspend;
> +}
> +
>  static int mmc_poweroff_notify(struct mmc_card *card, unsigned int
> notify_type)  {
>  	unsigned int timeout = card->ext_csd.generic_cmd6_time; @@ -
> 2124,8 +2136,7 @@ static int _mmc_suspend(struct mmc_host *host, bool
> is_suspend)
>  		goto out;
> 
>  	if (mmc_can_poweroff_notify(host->card) &&
> -	    ((host->caps2 & MMC_CAP2_FULL_PWR_CYCLE) || !is_suspend ||
> -	     (host->caps2 & MMC_CAP2_FULL_PWR_CYCLE_IN_SUSPEND)))
> +	    mmc_may_poweroff_notify(host, is_suspend))
>  		err = mmc_poweroff_notify(host->card, notify_type);
>  	else if (mmc_can_sleep(host->card))
>  		err = mmc_sleep(host);
> @@ -2191,7 +2202,7 @@ static int mmc_shutdown(struct mmc_host *host)
>  	 * before we can shutdown it properly.
>  	 */
>  	if (mmc_can_poweroff_notify(host->card) &&
> -		!(host->caps2 & MMC_CAP2_FULL_PWR_CYCLE))
> +	    !mmc_may_poweroff_notify(host, true))
I guess this deserve some extra documentation because:
If MMC_CAP2_FULL_PWR_CYCLE is not set but MMC_CAP2_FULL_PWR_CYCLE_IN_SUSPEND is set,
!mmc_may_poweroff_notify(host, true) will evaluate to false while !(host->caps2 & MMC_CAP2_FULL_PWR_CYCLE) will evaluate to true.

Thanks,
Avri

>  		err = _mmc_resume(host);
> 
>  	if (!err)
> --
> 2.43.0
> 


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ