On Tue, 19 May 2020 at 13:33, Yoshihiro Shimoda <yoshihiro.shimoda.uh@xxxxxxxxxxx> wrote: > > The commit 432356793415 ("mmc: core: Enable power_off_notify for > eMMC shutdown sequence") enabled the power off notification > even if MMC_CAP2_POWEROFF_NOTIFY (MMC_CAP2_FULL_PWR_CYCLE now) is > not set. However, the mmc core lacks to issue the power off > notificaiton when Suspend-to-{RAM,Disk} happens on the system. This isn't an entirely correct description, I think. If the host supports MMC_CAP2_FULL_PWR_CYCLE (both vmmc and vqmmc can be powered on/off), we use power-off-notification during system suspend, in case the eMMC card also supports it. Otherwise we send the sleep command. This behaviour was decided on purpose and it's mainly because without MMC_CAP2_FULL_PWR_CYCLE, we assume that vqmmc remains always-on. In this case, it simply seemed better to use the sleep command, rather than the power-off-notification, as we aren't really going to do a full power off anyway. Kind regards Uffe > > So, add Suspend-to-RAM support at first because this is easy to > check by using pm_suspend_target_state condition on _mmc_suspend(). > > Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@xxxxxxxxxxx> > --- > drivers/mmc/core/mmc.c | 9 ++++++++- > 1 file changed, 8 insertions(+), 1 deletion(-) > > diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c > index 4203303..4a23f83 100644 > --- a/drivers/mmc/core/mmc.c > +++ b/drivers/mmc/core/mmc.c > @@ -11,6 +11,7 @@ > #include <linux/of.h> > #include <linux/slab.h> > #include <linux/stat.h> > +#include <linux/suspend.h> > #include <linux/pm_runtime.h> > > #include <linux/mmc/host.h> > @@ -2027,6 +2028,12 @@ static int _mmc_suspend(struct mmc_host *host, bool is_suspend) > int err = 0; > unsigned int notify_type = is_suspend ? EXT_CSD_POWER_OFF_SHORT : > EXT_CSD_POWER_OFF_LONG; > + bool s2ram = false; > + > +#ifdef CONFIG_PM_SLEEP > + if (pm_suspend_target_state == PM_SUSPEND_MEM) > + s2ram = true; > +#endif > > mmc_claim_host(host); > > @@ -2038,7 +2045,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) || !is_suspend || s2ram)) > err = mmc_poweroff_notify(host->card, notify_type); > else if (mmc_can_sleep(host->card)) > err = mmc_sleep(host); > -- > 2.7.4 >