linux-renesas-soc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3 0/2] treewide: fix _mmc_suspend() on PSCI
@ 2020-06-22  2:24 Yoshihiro Shimoda
  2020-06-22  2:24 ` [PATCH v3 1/2] firmware: psci: call pm_set_suspend_via_firmware() Yoshihiro Shimoda
  2020-06-22  2:24 ` [PATCH v3 2/2] mmc: core: Call mmc_poweroff_nofity() if pm_suspend_via_firmware() Yoshihiro Shimoda
  0 siblings, 2 replies; 12+ messages in thread
From: Yoshihiro Shimoda @ 2020-06-22  2:24 UTC (permalink / raw)
  To: mark.rutland, lorenzo.pieralisi, ulf.hansson
  Cc: linux-mmc, linux-arm-kernel, linux-renesas-soc, Yoshihiro Shimoda

We can detect whether the system is going to suspend by using
pm_suspend_via_firmware() API. So, this patch series update
both PSCI and MMC driver for my environment (r8a77951-salvator-xs).

We can apply each patch to each subsystem without any dependency.

Changes from v2:
 - Fix typo of function name in patch2.
 - Remove RFC.
 https://patchwork.kernel.org/project/linux-renesas-soc/list/?series=305523

Changes from v1:
 - Use pm_suspend_via_firmware() API instead of pm_suspend_target_state.
 - Modify the psci driver to call pm_set_suspend_via_firmware.
 https://patchwork.kernel.org/patch/11557505/


Yoshihiro Shimoda (2):
  firmware: psci: call pm_set_suspend_via_firmware()
  mmc: core: Call mmc_poweroff_nofity() if pm_suspend_via_firmware()

 drivers/firmware/psci/psci.c | 8 ++++++++
 drivers/mmc/core/mmc.c       | 4 +++-
 2 files changed, 11 insertions(+), 1 deletion(-)

-- 
2.7.4


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH v3 1/2] firmware: psci: call pm_set_suspend_via_firmware()
  2020-06-22  2:24 [PATCH v3 0/2] treewide: fix _mmc_suspend() on PSCI Yoshihiro Shimoda
@ 2020-06-22  2:24 ` Yoshihiro Shimoda
  2020-08-05  8:08   ` Geert Uytterhoeven
  2020-06-22  2:24 ` [PATCH v3 2/2] mmc: core: Call mmc_poweroff_nofity() if pm_suspend_via_firmware() Yoshihiro Shimoda
  1 sibling, 1 reply; 12+ messages in thread
From: Yoshihiro Shimoda @ 2020-06-22  2:24 UTC (permalink / raw)
  To: mark.rutland, lorenzo.pieralisi, ulf.hansson
  Cc: linux-mmc, linux-arm-kernel, linux-renesas-soc, Yoshihiro Shimoda

Call pm_set_suspend_via_firmware() in .begin() of psci_suspend_ops
to use pm_suspend_via_firmware() on PSCI environment.

Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
---
 drivers/firmware/psci/psci.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/drivers/firmware/psci/psci.c b/drivers/firmware/psci/psci.c
index 92013ec..1c22b01 100644
--- a/drivers/firmware/psci/psci.c
+++ b/drivers/firmware/psci/psci.c
@@ -309,6 +309,13 @@ static int psci_system_suspend(unsigned long unused)
 			      __pa_symbol(cpu_resume), 0, 0);
 }
 
+static int psci_system_suspend_begin(suspend_state_t state)
+{
+	pm_set_suspend_via_firmware();
+
+	return 0;
+}
+
 static int psci_system_suspend_enter(suspend_state_t state)
 {
 	return cpu_suspend(0, psci_system_suspend);
@@ -316,6 +323,7 @@ static int psci_system_suspend_enter(suspend_state_t state)
 
 static const struct platform_suspend_ops psci_suspend_ops = {
 	.valid          = suspend_valid_only_mem,
+	.begin          = psci_system_suspend_begin,
 	.enter          = psci_system_suspend_enter,
 };
 
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH v3 2/2] mmc: core: Call mmc_poweroff_nofity() if pm_suspend_via_firmware()
  2020-06-22  2:24 [PATCH v3 0/2] treewide: fix _mmc_suspend() on PSCI Yoshihiro Shimoda
  2020-06-22  2:24 ` [PATCH v3 1/2] firmware: psci: call pm_set_suspend_via_firmware() Yoshihiro Shimoda
@ 2020-06-22  2:24 ` Yoshihiro Shimoda
  2020-06-24 10:05   ` Ulf Hansson
  1 sibling, 1 reply; 12+ messages in thread
From: Yoshihiro Shimoda @ 2020-06-22  2:24 UTC (permalink / raw)
  To: mark.rutland, lorenzo.pieralisi, ulf.hansson
  Cc: linux-mmc, linux-arm-kernel, linux-renesas-soc, Yoshihiro Shimoda

If pm_suspend_via_firmware() returns true, the system will be able
to cut both vcc and vccq in the suspend. So, call
mmc_poweroff_nofity() if pm_suspend_via_firmware() returns true.

Note that we should not update the MMC_CAP2_FULL_PWR_CYCLE caps
because the mmc_select_voltage() checks the caps when attaches
a mmc/sd.

Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
---
 drivers/mmc/core/mmc.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c
index 4203303..81941fd 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>
@@ -2038,7 +2039,8 @@ 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 ||
+	     pm_suspend_via_firmware()))
 		err = mmc_poweroff_notify(host->card, notify_type);
 	else if (mmc_can_sleep(host->card))
 		err = mmc_sleep(host);
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* Re: [PATCH v3 2/2] mmc: core: Call mmc_poweroff_nofity() if pm_suspend_via_firmware()
  2020-06-22  2:24 ` [PATCH v3 2/2] mmc: core: Call mmc_poweroff_nofity() if pm_suspend_via_firmware() Yoshihiro Shimoda
@ 2020-06-24 10:05   ` Ulf Hansson
  2020-06-24 11:13     ` Geert Uytterhoeven
  0 siblings, 1 reply; 12+ messages in thread
From: Ulf Hansson @ 2020-06-24 10:05 UTC (permalink / raw)
  To: Yoshihiro Shimoda
  Cc: Mark Rutland, Lorenzo Pieralisi, linux-mmc, Linux ARM, Linux-Renesas

On Mon, 22 Jun 2020 at 04:25, Yoshihiro Shimoda
<yoshihiro.shimoda.uh@renesas.com> wrote:
>
> If pm_suspend_via_firmware() returns true, the system will be able
> to cut both vcc and vccq in the suspend. So, call
> mmc_poweroff_nofity() if pm_suspend_via_firmware() returns true.
>
> Note that we should not update the MMC_CAP2_FULL_PWR_CYCLE caps
> because the mmc_select_voltage() checks the caps when attaches
> a mmc/sd.
>
> Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
> ---
>  drivers/mmc/core/mmc.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c
> index 4203303..81941fd 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>
> @@ -2038,7 +2039,8 @@ 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 ||
> +            pm_suspend_via_firmware()))

Sorry, but this doesn't work.

Even if PSCI is a generic FW interface, it doesn't mean that all PSCI
implementations will cut the vcc and vccq for the MMC card at system
suspend.

Instead, you need to decide this based on some specific DT property.
Perhaps in conjunction with using pm_suspend_via_firmware().

>                 err = mmc_poweroff_notify(host->card, notify_type);
>         else if (mmc_can_sleep(host->card))
>                 err = mmc_sleep(host);
> --
> 2.7.4
>

Kind regards
Uffe

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v3 2/2] mmc: core: Call mmc_poweroff_nofity() if pm_suspend_via_firmware()
  2020-06-24 10:05   ` Ulf Hansson
@ 2020-06-24 11:13     ` Geert Uytterhoeven
  2020-06-25  6:31       ` Yoshihiro Shimoda
  0 siblings, 1 reply; 12+ messages in thread
From: Geert Uytterhoeven @ 2020-06-24 11:13 UTC (permalink / raw)
  To: Ulf Hansson
  Cc: Yoshihiro Shimoda, Mark Rutland, Linux-Renesas,
	Lorenzo Pieralisi, linux-mmc, Linux ARM

Hi Ulf,

On Wed, Jun 24, 2020 at 12:06 PM Ulf Hansson <ulf.hansson@linaro.org> wrote:
> On Mon, 22 Jun 2020 at 04:25, Yoshihiro Shimoda
> <yoshihiro.shimoda.uh@renesas.com> wrote:
> > If pm_suspend_via_firmware() returns true, the system will be able
> > to cut both vcc and vccq in the suspend. So, call
> > mmc_poweroff_nofity() if pm_suspend_via_firmware() returns true.
> >
> > Note that we should not update the MMC_CAP2_FULL_PWR_CYCLE caps
> > because the mmc_select_voltage() checks the caps when attaches
> > a mmc/sd.

> > --- a/drivers/mmc/core/mmc.c
> > +++ b/drivers/mmc/core/mmc.c
> > @@ -2038,7 +2039,8 @@ 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 ||
> > +            pm_suspend_via_firmware()))
>
> Sorry, but this doesn't work.
>
> Even if PSCI is a generic FW interface, it doesn't mean that all PSCI
> implementations will cut the vcc and vccq for the MMC card at system
> suspend.

Indeed, there's nothing guaranteed here.  Nor documented how it should
behave.  Basically the firmware is free to power off the SoC. Or not do that.
"If firmware is involved, all odds are off".

> Instead, you need to decide this based on some specific DT property.
> Perhaps in conjunction with using pm_suspend_via_firmware().

Last time I was involved in a discussion about this, the PSCI people
didn't want to add any properties describing particular PSCI behavior...
"If firmware is involved, all odds are off".

So the only safe thing to do is to expect the worst, and prepare for it...

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

^ permalink raw reply	[flat|nested] 12+ messages in thread

* RE: [PATCH v3 2/2] mmc: core: Call mmc_poweroff_nofity() if pm_suspend_via_firmware()
  2020-06-24 11:13     ` Geert Uytterhoeven
@ 2020-06-25  6:31       ` Yoshihiro Shimoda
  2020-06-25  9:26         ` Geert Uytterhoeven
  0 siblings, 1 reply; 12+ messages in thread
From: Yoshihiro Shimoda @ 2020-06-25  6:31 UTC (permalink / raw)
  To: Geert Uytterhoeven, Ulf Hansson
  Cc: Mark Rutland, Linux-Renesas, Lorenzo Pieralisi, linux-mmc, Linux ARM

Hi Ulf, Geert,

> From: Geert Uytterhoeven, Sent: Wednesday, June 24, 2020 8:13 PM
> 
> Hi Ulf,
> 
> On Wed, Jun 24, 2020 at 12:06 PM Ulf Hansson <ulf.hansson@linaro.org> wrote:
> > On Mon, 22 Jun 2020 at 04:25, Yoshihiro Shimoda
> > <yoshihiro.shimoda.uh@renesas.com> wrote:
> > > If pm_suspend_via_firmware() returns true, the system will be able
> > > to cut both vcc and vccq in the suspend. So, call
> > > mmc_poweroff_nofity() if pm_suspend_via_firmware() returns true.
> > >
> > > Note that we should not update the MMC_CAP2_FULL_PWR_CYCLE caps
> > > because the mmc_select_voltage() checks the caps when attaches
> > > a mmc/sd.
> 
> > > --- a/drivers/mmc/core/mmc.c
> > > +++ b/drivers/mmc/core/mmc.c
> > > @@ -2038,7 +2039,8 @@ 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 ||
> > > +            pm_suspend_via_firmware()))
> >
> > Sorry, but this doesn't work.
> >
> > Even if PSCI is a generic FW interface, it doesn't mean that all PSCI
> > implementations will cut the vcc and vccq for the MMC card at system
> > suspend.
> 
> Indeed, there's nothing guaranteed here.  Nor documented how it should
> behave.  Basically the firmware is free to power off the SoC. Or not do that.
> "If firmware is involved, all odds are off".

I thought we could be guaranteed. But, I understood we could not be guaranteed...

> > Instead, you need to decide this based on some specific DT property.
> > Perhaps in conjunction with using pm_suspend_via_firmware().
> 
> Last time I was involved in a discussion about this, the PSCI people
> didn't want to add any properties describing particular PSCI behavior...
> "If firmware is involved, all odds are off".
> 
> So the only safe thing to do is to expect the worst, and prepare for it...

A headache point is an eMMC device consumes much power if that the system
doesn't cut the vcc and vccq and doesn’t enter the sleep mode.
In other words, in power consumption point of view, this patch will
cause a regression in such a case...

By the way, about adding specific DT property, the regulator can have
regulator-off-in-suspend property in regulator-state-mem subnode.
For now, we doesn't seem to get the property from a regulator consumer though.
So, I'll try to add an API of regulator for it.

Best regards,
Yoshihiro Shimoda

> Gr{oetje,eeting}s,
> 
>                         Geert
> 
> --
> Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
> 
> In personal conversations with technical people, I call myself a hacker. But
> when I'm talking to journalists I just say "programmer" or something like that.
>                                 -- Linus Torvalds

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v3 2/2] mmc: core: Call mmc_poweroff_nofity() if pm_suspend_via_firmware()
  2020-06-25  6:31       ` Yoshihiro Shimoda
@ 2020-06-25  9:26         ` Geert Uytterhoeven
  2020-06-26 11:03           ` Ulf Hansson
  0 siblings, 1 reply; 12+ messages in thread
From: Geert Uytterhoeven @ 2020-06-25  9:26 UTC (permalink / raw)
  To: Yoshihiro Shimoda
  Cc: Ulf Hansson, Mark Rutland, Linux-Renesas, Lorenzo Pieralisi,
	linux-mmc, Linux ARM, Mark Brown

Hi Shimoda-san,

CC broonie

On Thu, Jun 25, 2020 at 8:31 AM Yoshihiro Shimoda
<yoshihiro.shimoda.uh@renesas.com> wrote:
> > From: Geert Uytterhoeven, Sent: Wednesday, June 24, 2020 8:13 PM
> > On Wed, Jun 24, 2020 at 12:06 PM Ulf Hansson <ulf.hansson@linaro.org> wrote:
> > > On Mon, 22 Jun 2020 at 04:25, Yoshihiro Shimoda
> > > <yoshihiro.shimoda.uh@renesas.com> wrote:
> > > > If pm_suspend_via_firmware() returns true, the system will be able
> > > > to cut both vcc and vccq in the suspend. So, call
> > > > mmc_poweroff_nofity() if pm_suspend_via_firmware() returns true.
> > > >
> > > > Note that we should not update the MMC_CAP2_FULL_PWR_CYCLE caps
> > > > because the mmc_select_voltage() checks the caps when attaches
> > > > a mmc/sd.
> >
> > > > --- a/drivers/mmc/core/mmc.c
> > > > +++ b/drivers/mmc/core/mmc.c
> > > > @@ -2038,7 +2039,8 @@ 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 ||
> > > > +            pm_suspend_via_firmware()))
> > >
> > > Sorry, but this doesn't work.
> > >
> > > Even if PSCI is a generic FW interface, it doesn't mean that all PSCI
> > > implementations will cut the vcc and vccq for the MMC card at system
> > > suspend.
> >
> > Indeed, there's nothing guaranteed here.  Nor documented how it should
> > behave.  Basically the firmware is free to power off the SoC. Or not do that.
> > "If firmware is involved, all odds are off".
>
> I thought we could be guaranteed. But, I understood we could not be guaranteed...
>
> > > Instead, you need to decide this based on some specific DT property.
> > > Perhaps in conjunction with using pm_suspend_via_firmware().
> >
> > Last time I was involved in a discussion about this, the PSCI people
> > didn't want to add any properties describing particular PSCI behavior...
> > "If firmware is involved, all odds are off".
> >
> > So the only safe thing to do is to expect the worst, and prepare for it...
>
> A headache point is an eMMC device consumes much power if that the system
> doesn't cut the vcc and vccq and doesn’t enter the sleep mode.
> In other words, in power consumption point of view, this patch will
> cause a regression in such a case...

Indeed.

> By the way, about adding specific DT property, the regulator can have
> regulator-off-in-suspend property in regulator-state-mem subnode.
> For now, we doesn't seem to get the property from a regulator consumer though.
> So, I'll try to add an API of regulator for it.

Oh right, the eMMC is described in DT as being connected to two
regulators.
Note that the semantics of regulator-off-in-suspend are that the
regulator should be disabled (by the regulator core) during suspend, not
that the regulator is disabled during suspend by a third party.
No idea if that will work with a fixed-regulator without GPIO control,
but of course you can try.

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v3 2/2] mmc: core: Call mmc_poweroff_nofity() if pm_suspend_via_firmware()
  2020-06-25  9:26         ` Geert Uytterhoeven
@ 2020-06-26 11:03           ` Ulf Hansson
  2020-07-02 12:37             ` Yoshihiro Shimoda
  0 siblings, 1 reply; 12+ messages in thread
From: Ulf Hansson @ 2020-06-26 11:03 UTC (permalink / raw)
  To: Geert Uytterhoeven, Yoshihiro Shimoda, Rob Herring
  Cc: Mark Rutland, Linux-Renesas, Lorenzo Pieralisi, linux-mmc,
	Linux ARM, Mark Brown

+ Rob

On Thu, 25 Jun 2020 at 11:26, Geert Uytterhoeven <geert@linux-m68k.org> wrote:
>
> Hi Shimoda-san,
>
> CC broonie
>
> On Thu, Jun 25, 2020 at 8:31 AM Yoshihiro Shimoda
> <yoshihiro.shimoda.uh@renesas.com> wrote:
> > > From: Geert Uytterhoeven, Sent: Wednesday, June 24, 2020 8:13 PM
> > > On Wed, Jun 24, 2020 at 12:06 PM Ulf Hansson <ulf.hansson@linaro.org> wrote:
> > > > On Mon, 22 Jun 2020 at 04:25, Yoshihiro Shimoda
> > > > <yoshihiro.shimoda.uh@renesas.com> wrote:
> > > > > If pm_suspend_via_firmware() returns true, the system will be able
> > > > > to cut both vcc and vccq in the suspend. So, call
> > > > > mmc_poweroff_nofity() if pm_suspend_via_firmware() returns true.
> > > > >
> > > > > Note that we should not update the MMC_CAP2_FULL_PWR_CYCLE caps
> > > > > because the mmc_select_voltage() checks the caps when attaches
> > > > > a mmc/sd.
> > >
> > > > > --- a/drivers/mmc/core/mmc.c
> > > > > +++ b/drivers/mmc/core/mmc.c
> > > > > @@ -2038,7 +2039,8 @@ 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 ||
> > > > > +            pm_suspend_via_firmware()))
> > > >
> > > > Sorry, but this doesn't work.
> > > >
> > > > Even if PSCI is a generic FW interface, it doesn't mean that all PSCI
> > > > implementations will cut the vcc and vccq for the MMC card at system
> > > > suspend.
> > >
> > > Indeed, there's nothing guaranteed here.  Nor documented how it should
> > > behave.  Basically the firmware is free to power off the SoC. Or not do that.
> > > "If firmware is involved, all odds are off".
> >
> > I thought we could be guaranteed. But, I understood we could not be guaranteed...
> >
> > > > Instead, you need to decide this based on some specific DT property.
> > > > Perhaps in conjunction with using pm_suspend_via_firmware().
> > >
> > > Last time I was involved in a discussion about this, the PSCI people
> > > didn't want to add any properties describing particular PSCI behavior...
> > > "If firmware is involved, all odds are off".
> > >
> > > So the only safe thing to do is to expect the worst, and prepare for it...
> >
> > A headache point is an eMMC device consumes much power if that the system
> > doesn't cut the vcc and vccq and doesn’t enter the sleep mode.
> > In other words, in power consumption point of view, this patch will
> > cause a regression in such a case...
>
> Indeed.
>
> > By the way, about adding specific DT property, the regulator can have
> > regulator-off-in-suspend property in regulator-state-mem subnode.
> > For now, we doesn't seem to get the property from a regulator consumer though.
> > So, I'll try to add an API of regulator for it.
>
> Oh right, the eMMC is described in DT as being connected to two
> regulators.
> Note that the semantics of regulator-off-in-suspend are that the
> regulator should be disabled (by the regulator core) during suspend, not
> that the regulator is disabled during suspend by a third party.
> No idea if that will work with a fixed-regulator without GPIO control,
> but of course you can try.

For mmc we already have a DT property, "full-pwr-cycle". Which tells
whether the host is able to completely power-cycle the card (some
host's manage power internally).

However, maybe the proper thing here would be to add a property of
regulator instead. If that doesn't make sense, I am also open to add a
new MMC property, "full-pwr-cycle-in-suspend".

Kind regards
Uffe

^ permalink raw reply	[flat|nested] 12+ messages in thread

* RE: [PATCH v3 2/2] mmc: core: Call mmc_poweroff_nofity() if pm_suspend_via_firmware()
  2020-06-26 11:03           ` Ulf Hansson
@ 2020-07-02 12:37             ` Yoshihiro Shimoda
  2020-07-06 13:10               ` Ulf Hansson
  0 siblings, 1 reply; 12+ messages in thread
From: Yoshihiro Shimoda @ 2020-07-02 12:37 UTC (permalink / raw)
  To: Ulf Hansson
  Cc: Mark Rutland, Linux-Renesas, Lorenzo Pieralisi, linux-mmc,
	Linux ARM, Mark Brown, Geert Uytterhoeven, Rob Herring

Hi Ulf,

> From: Ulf Hansson, Sent: Friday, June 26, 2020 8:03 PM
> 
> + Rob
> 
> On Thu, 25 Jun 2020 at 11:26, Geert Uytterhoeven <geert@linux-m68k.org> wrote:
> >
> > Hi Shimoda-san,
> >
> > CC broonie
> >
> > On Thu, Jun 25, 2020 at 8:31 AM Yoshihiro Shimoda
> > <yoshihiro.shimoda.uh@renesas.com> wrote:
> > > > From: Geert Uytterhoeven, Sent: Wednesday, June 24, 2020 8:13 PM
> > > > On Wed, Jun 24, 2020 at 12:06 PM Ulf Hansson <ulf.hansson@linaro.org> wrote:
> > > > > On Mon, 22 Jun 2020 at 04:25, Yoshihiro Shimoda
> > > > > <yoshihiro.shimoda.uh@renesas.com> wrote:
> > > > > > If pm_suspend_via_firmware() returns true, the system will be able
> > > > > > to cut both vcc and vccq in the suspend. So, call
> > > > > > mmc_poweroff_nofity() if pm_suspend_via_firmware() returns true.
> > > > > >
> > > > > > Note that we should not update the MMC_CAP2_FULL_PWR_CYCLE caps
> > > > > > because the mmc_select_voltage() checks the caps when attaches
> > > > > > a mmc/sd.
> > > >
> > > > > > --- a/drivers/mmc/core/mmc.c
> > > > > > +++ b/drivers/mmc/core/mmc.c
> > > > > > @@ -2038,7 +2039,8 @@ 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 ||
> > > > > > +            pm_suspend_via_firmware()))
> > > > >
> > > > > Sorry, but this doesn't work.
> > > > >
> > > > > Even if PSCI is a generic FW interface, it doesn't mean that all PSCI
> > > > > implementations will cut the vcc and vccq for the MMC card at system
> > > > > suspend.
> > > >
> > > > Indeed, there's nothing guaranteed here.  Nor documented how it should
> > > > behave.  Basically the firmware is free to power off the SoC. Or not do that.
> > > > "If firmware is involved, all odds are off".
> > >
> > > I thought we could be guaranteed. But, I understood we could not be guaranteed...
> > >
> > > > > Instead, you need to decide this based on some specific DT property.
> > > > > Perhaps in conjunction with using pm_suspend_via_firmware().
> > > >
> > > > Last time I was involved in a discussion about this, the PSCI people
> > > > didn't want to add any properties describing particular PSCI behavior...
> > > > "If firmware is involved, all odds are off".
> > > >
> > > > So the only safe thing to do is to expect the worst, and prepare for it...
> > >
> > > A headache point is an eMMC device consumes much power if that the system
> > > doesn't cut the vcc and vccq and doesn’t enter the sleep mode.
> > > In other words, in power consumption point of view, this patch will
> > > cause a regression in such a case...
> >
> > Indeed.
> >
> > > By the way, about adding specific DT property, the regulator can have
> > > regulator-off-in-suspend property in regulator-state-mem subnode.
> > > For now, we doesn't seem to get the property from a regulator consumer though.
> > > So, I'll try to add an API of regulator for it.
> >
> > Oh right, the eMMC is described in DT as being connected to two
> > regulators.
> > Note that the semantics of regulator-off-in-suspend are that the
> > regulator should be disabled (by the regulator core) during suspend, not
> > that the regulator is disabled during suspend by a third party.
> > No idea if that will work with a fixed-regulator without GPIO control,
> > but of course you can try.

As other email thread of this trial as v4, I could not get approval [1].

[1]
https://lore.kernel.org/linux-renesas-soc/CAMuHMdX93Q9WhKLqv_wNPzArbc68NcbVN8jJ9MDKxAcicpBQ5Q@mail.gmail.com/T/#m70883cc5de4fa7fca50118dad743c836d5e3b451

> For mmc we already have a DT property, "full-pwr-cycle". Which tells
> whether the host is able to completely power-cycle the card (some
> host's manage power internally).
> 
> However, maybe the proper thing here would be to add a property of
> regulator instead.

My v4 patch was using a regulator property. But since I could not get
approval, we could not use this way, I think.

> If that doesn't make sense, I am also open to add a
> new MMC property, "full-pwr-cycle-in-suspend".

I thought this way was better. However, I'm wondering if adding such a new MMC
property to issue Power Off Notification in mmc_suspend() is really better
than the current implementation. This is because we don't have any completely
solutions now:
 - Depend on board configuration (The board doesn't have "full-pwr-cycle").
 - Depend on firmware on board [2]. So, even if adding a new MMC property,
   it cannot sync the firmware condition. In fact, this is possible to
   cause regression in power consumption point of view [3].
 - My environment (PSCI which is one of firmware) doesn't support
   any ability to sync between the firmware and OS for now [4].

But, what do you think?

[2]
https://lore.kernel.org/linux-renesas-soc/1592792699-24638-1-git-send-email-yoshihiro.shimoda.uh@renesas.com/T/#mde38d5866b7f3edc9a2ed105ac06b4fda4c3e99e

[3]
https://lore.kernel.org/linux-renesas-soc/1592792699-24638-1-git-send-email-yoshihiro.shimoda.uh@renesas.com/T/#mf8e7abdf135586ba0b70a1c235410a6f94c6007d

[4]
https://lore.kernel.org/linux-renesas-soc/CAMuHMdX93Q9WhKLqv_wNPzArbc68NcbVN8jJ9MDKxAcicpBQ5Q@mail.gmail.com/T/#m442a2ce972cfdb3ff33637c120c8d096e4d07af8

Best regards,
Yoshihiro Shimoda

> Kind regards
> Uffe

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v3 2/2] mmc: core: Call mmc_poweroff_nofity() if pm_suspend_via_firmware()
  2020-07-02 12:37             ` Yoshihiro Shimoda
@ 2020-07-06 13:10               ` Ulf Hansson
  2020-07-07  1:26                 ` Yoshihiro Shimoda
  0 siblings, 1 reply; 12+ messages in thread
From: Ulf Hansson @ 2020-07-06 13:10 UTC (permalink / raw)
  To: Yoshihiro Shimoda
  Cc: Mark Rutland, Linux-Renesas, Lorenzo Pieralisi, linux-mmc,
	Linux ARM, Mark Brown, Geert Uytterhoeven, Rob Herring

On Thu, 2 Jul 2020 at 14:37, Yoshihiro Shimoda
<yoshihiro.shimoda.uh@renesas.com> wrote:
>
> Hi Ulf,
>
> > From: Ulf Hansson, Sent: Friday, June 26, 2020 8:03 PM
> >
> > + Rob
> >
> > On Thu, 25 Jun 2020 at 11:26, Geert Uytterhoeven <geert@linux-m68k.org> wrote:
> > >
> > > Hi Shimoda-san,
> > >
> > > CC broonie
> > >
> > > On Thu, Jun 25, 2020 at 8:31 AM Yoshihiro Shimoda
> > > <yoshihiro.shimoda.uh@renesas.com> wrote:
> > > > > From: Geert Uytterhoeven, Sent: Wednesday, June 24, 2020 8:13 PM
> > > > > On Wed, Jun 24, 2020 at 12:06 PM Ulf Hansson <ulf.hansson@linaro.org> wrote:
> > > > > > On Mon, 22 Jun 2020 at 04:25, Yoshihiro Shimoda
> > > > > > <yoshihiro.shimoda.uh@renesas.com> wrote:
> > > > > > > If pm_suspend_via_firmware() returns true, the system will be able
> > > > > > > to cut both vcc and vccq in the suspend. So, call
> > > > > > > mmc_poweroff_nofity() if pm_suspend_via_firmware() returns true.
> > > > > > >
> > > > > > > Note that we should not update the MMC_CAP2_FULL_PWR_CYCLE caps
> > > > > > > because the mmc_select_voltage() checks the caps when attaches
> > > > > > > a mmc/sd.
> > > > >
> > > > > > > --- a/drivers/mmc/core/mmc.c
> > > > > > > +++ b/drivers/mmc/core/mmc.c
> > > > > > > @@ -2038,7 +2039,8 @@ 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 ||
> > > > > > > +            pm_suspend_via_firmware()))
> > > > > >
> > > > > > Sorry, but this doesn't work.
> > > > > >
> > > > > > Even if PSCI is a generic FW interface, it doesn't mean that all PSCI
> > > > > > implementations will cut the vcc and vccq for the MMC card at system
> > > > > > suspend.
> > > > >
> > > > > Indeed, there's nothing guaranteed here.  Nor documented how it should
> > > > > behave.  Basically the firmware is free to power off the SoC. Or not do that.
> > > > > "If firmware is involved, all odds are off".
> > > >
> > > > I thought we could be guaranteed. But, I understood we could not be guaranteed...
> > > >
> > > > > > Instead, you need to decide this based on some specific DT property.
> > > > > > Perhaps in conjunction with using pm_suspend_via_firmware().
> > > > >
> > > > > Last time I was involved in a discussion about this, the PSCI people
> > > > > didn't want to add any properties describing particular PSCI behavior...
> > > > > "If firmware is involved, all odds are off".
> > > > >
> > > > > So the only safe thing to do is to expect the worst, and prepare for it...
> > > >
> > > > A headache point is an eMMC device consumes much power if that the system
> > > > doesn't cut the vcc and vccq and doesn’t enter the sleep mode.
> > > > In other words, in power consumption point of view, this patch will
> > > > cause a regression in such a case...
> > >
> > > Indeed.
> > >
> > > > By the way, about adding specific DT property, the regulator can have
> > > > regulator-off-in-suspend property in regulator-state-mem subnode.
> > > > For now, we doesn't seem to get the property from a regulator consumer though.
> > > > So, I'll try to add an API of regulator for it.
> > >
> > > Oh right, the eMMC is described in DT as being connected to two
> > > regulators.
> > > Note that the semantics of regulator-off-in-suspend are that the
> > > regulator should be disabled (by the regulator core) during suspend, not
> > > that the regulator is disabled during suspend by a third party.
> > > No idea if that will work with a fixed-regulator without GPIO control,
> > > but of course you can try.
>
> As other email thread of this trial as v4, I could not get approval [1].
>
> [1]
> https://lore.kernel.org/linux-renesas-soc/CAMuHMdX93Q9WhKLqv_wNPzArbc68NcbVN8jJ9MDKxAcicpBQ5Q@mail.gmail.com/T/#m70883cc5de4fa7fca50118dad743c836d5e3b451
>
> > For mmc we already have a DT property, "full-pwr-cycle". Which tells
> > whether the host is able to completely power-cycle the card (some
> > host's manage power internally).
> >
> > However, maybe the proper thing here would be to add a property of
> > regulator instead.
>
> My v4 patch was using a regulator property. But since I could not get
> approval, we could not use this way, I think.
>
> > If that doesn't make sense, I am also open to add a
> > new MMC property, "full-pwr-cycle-in-suspend".
>
> I thought this way was better. However, I'm wondering if adding such a new MMC
> property to issue Power Off Notification in mmc_suspend() is really better
> than the current implementation. This is because we don't have any completely
> solutions now:
>  - Depend on board configuration (The board doesn't have "full-pwr-cycle").
>  - Depend on firmware on board [2]. So, even if adding a new MMC property,
>    it cannot sync the firmware condition. In fact, this is possible to
>    cause regression in power consumption point of view [3].

This is a generic problem with FWs.

I guess one could try to update the DTB using DT overlays, in case
some FW version changes.

>  - My environment (PSCI which is one of firmware) doesn't support
>    any ability to sync between the firmware and OS for now [4].

Yes, I see.

It seems like Geert has tried different approaches to convince PSCI
folkz, to find a solution for this, but it seems like none have make
it yet.

>
> But, what do you think?

From the mmc DT property point of view, I am fine adding a
"full-pwr-cycle-in-suspend" - and then also update the mmc core's
behavior to use the eMMC power-off-notify command at system suspend.

However, I don't have a strong opinion, as the current solution with
the eMMC sleep command also seems to work.

My main concern with the current approach though, is not about wasting
energy, but rather that we are not doing a graceful shutdown of the
eMMC device. Instead we just cut VCCQ while the eMMC is "sleeping",
which in worst case could lead to internal data corruptions, but also
increased re-initialization time at system suspend.

>
> [2]
> https://lore.kernel.org/linux-renesas-soc/1592792699-24638-1-git-send-email-yoshihiro.shimoda.uh@renesas.com/T/#mde38d5866b7f3edc9a2ed105ac06b4fda4c3e99e
>
> [3]
> https://lore.kernel.org/linux-renesas-soc/1592792699-24638-1-git-send-email-yoshihiro.shimoda.uh@renesas.com/T/#mf8e7abdf135586ba0b70a1c235410a6f94c6007d
>
> [4]
> https://lore.kernel.org/linux-renesas-soc/CAMuHMdX93Q9WhKLqv_wNPzArbc68NcbVN8jJ9MDKxAcicpBQ5Q@mail.gmail.com/T/#m442a2ce972cfdb3ff33637c120c8d096e4d07af8
>

Kind regards
Uffe

^ permalink raw reply	[flat|nested] 12+ messages in thread

* RE: [PATCH v3 2/2] mmc: core: Call mmc_poweroff_nofity() if pm_suspend_via_firmware()
  2020-07-06 13:10               ` Ulf Hansson
@ 2020-07-07  1:26                 ` Yoshihiro Shimoda
  0 siblings, 0 replies; 12+ messages in thread
From: Yoshihiro Shimoda @ 2020-07-07  1:26 UTC (permalink / raw)
  To: Ulf Hansson
  Cc: Mark Rutland, Linux-Renesas, Lorenzo Pieralisi, linux-mmc,
	Linux ARM, Mark Brown, Geert Uytterhoeven, Rob Herring

Hi Ulf,

> From: Ulf Hansson, Sent: Monday, July 6, 2020 10:11 PM
> 
> On Thu, 2 Jul 2020 at 14:37, Yoshihiro Shimoda
> <yoshihiro.shimoda.uh@renesas.com> wrote:
> >
> > Hi Ulf,
> >
> > > From: Ulf Hansson, Sent: Friday, June 26, 2020 8:03 PM
> > >
> > > + Rob
> > >
> > > On Thu, 25 Jun 2020 at 11:26, Geert Uytterhoeven <geert@linux-m68k.org> wrote:
> > > >
> > > > Hi Shimoda-san,
> > > >
> > > > CC broonie
> > > >
> > > > On Thu, Jun 25, 2020 at 8:31 AM Yoshihiro Shimoda
> > > > <yoshihiro.shimoda.uh@renesas.com> wrote:
> > > > > > From: Geert Uytterhoeven, Sent: Wednesday, June 24, 2020 8:13 PM
> > > > > > On Wed, Jun 24, 2020 at 12:06 PM Ulf Hansson <ulf.hansson@linaro.org> wrote:
> > > > > > > On Mon, 22 Jun 2020 at 04:25, Yoshihiro Shimoda
> > > > > > > <yoshihiro.shimoda.uh@renesas.com> wrote:
> > > > > > > > If pm_suspend_via_firmware() returns true, the system will be able
> > > > > > > > to cut both vcc and vccq in the suspend. So, call
> > > > > > > > mmc_poweroff_nofity() if pm_suspend_via_firmware() returns true.
> > > > > > > >
> > > > > > > > Note that we should not update the MMC_CAP2_FULL_PWR_CYCLE caps
> > > > > > > > because the mmc_select_voltage() checks the caps when attaches
> > > > > > > > a mmc/sd.
> > > > > >
> > > > > > > > --- a/drivers/mmc/core/mmc.c
> > > > > > > > +++ b/drivers/mmc/core/mmc.c
> > > > > > > > @@ -2038,7 +2039,8 @@ 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 ||
> > > > > > > > +            pm_suspend_via_firmware()))
> > > > > > >
> > > > > > > Sorry, but this doesn't work.
> > > > > > >
> > > > > > > Even if PSCI is a generic FW interface, it doesn't mean that all PSCI
> > > > > > > implementations will cut the vcc and vccq for the MMC card at system
> > > > > > > suspend.
> > > > > >
> > > > > > Indeed, there's nothing guaranteed here.  Nor documented how it should
> > > > > > behave.  Basically the firmware is free to power off the SoC. Or not do that.
> > > > > > "If firmware is involved, all odds are off".
> > > > >
> > > > > I thought we could be guaranteed. But, I understood we could not be guaranteed...
> > > > >
> > > > > > > Instead, you need to decide this based on some specific DT property.
> > > > > > > Perhaps in conjunction with using pm_suspend_via_firmware().
> > > > > >
> > > > > > Last time I was involved in a discussion about this, the PSCI people
> > > > > > didn't want to add any properties describing particular PSCI behavior...
> > > > > > "If firmware is involved, all odds are off".
> > > > > >
> > > > > > So the only safe thing to do is to expect the worst, and prepare for it...
> > > > >
> > > > > A headache point is an eMMC device consumes much power if that the system
> > > > > doesn't cut the vcc and vccq and doesn’t enter the sleep mode.
> > > > > In other words, in power consumption point of view, this patch will
> > > > > cause a regression in such a case...
> > > >
> > > > Indeed.
> > > >
> > > > > By the way, about adding specific DT property, the regulator can have
> > > > > regulator-off-in-suspend property in regulator-state-mem subnode.
> > > > > For now, we doesn't seem to get the property from a regulator consumer though.
> > > > > So, I'll try to add an API of regulator for it.
> > > >
> > > > Oh right, the eMMC is described in DT as being connected to two
> > > > regulators.
> > > > Note that the semantics of regulator-off-in-suspend are that the
> > > > regulator should be disabled (by the regulator core) during suspend, not
> > > > that the regulator is disabled during suspend by a third party.
> > > > No idea if that will work with a fixed-regulator without GPIO control,
> > > > but of course you can try.
> >
> > As other email thread of this trial as v4, I could not get approval [1].
> >
> > [1]
> >
> https://lore.kernel.org/linux-renesas-soc/CAMuHMdX93Q9WhKLqv_wNPzArbc68NcbVN8jJ9MDKxAcicpBQ5Q@mail.gmail.com/T/#m708
> 83cc5de4fa7fca50118dad743c836d5e3b451
> >
> > > For mmc we already have a DT property, "full-pwr-cycle". Which tells
> > > whether the host is able to completely power-cycle the card (some
> > > host's manage power internally).
> > >
> > > However, maybe the proper thing here would be to add a property of
> > > regulator instead.
> >
> > My v4 patch was using a regulator property. But since I could not get
> > approval, we could not use this way, I think.
> >
> > > If that doesn't make sense, I am also open to add a
> > > new MMC property, "full-pwr-cycle-in-suspend".
> >
> > I thought this way was better. However, I'm wondering if adding such a new MMC
> > property to issue Power Off Notification in mmc_suspend() is really better
> > than the current implementation. This is because we don't have any completely
> > solutions now:
> >  - Depend on board configuration (The board doesn't have "full-pwr-cycle").
> >  - Depend on firmware on board [2]. So, even if adding a new MMC property,
> >    it cannot sync the firmware condition. In fact, this is possible to
> >    cause regression in power consumption point of view [3].
> 
> This is a generic problem with FWs.
> 
> I guess one could try to update the DTB using DT overlays, in case
> some FW version changes.

It's interesting.

> >  - My environment (PSCI which is one of firmware) doesn't support
> >    any ability to sync between the firmware and OS for now [4].
> 
> Yes, I see.
> 
> It seems like Geert has tried different approaches to convince PSCI
> folkz, to find a solution for this, but it seems like none have make
> it yet.
> 
> >
> > But, what do you think?
> 
> From the mmc DT property point of view, I am fine adding a
> "full-pwr-cycle-in-suspend" - and then also update the mmc core's
> behavior to use the eMMC power-off-notify command at system suspend.
> 
> However, I don't have a strong opinion, as the current solution with
> the eMMC sleep command also seems to work.
> 
> My main concern with the current approach though, is not about wasting
> energy, but rather that we are not doing a graceful shutdown of the
> eMMC device. Instead we just cut VCCQ while the eMMC is "sleeping",
> which in worst case could lead to internal data corruptions, but also
> increased re-initialization time at system suspend.

Thank you very much for your comments! I understood your main concern.
So, I'm thinking adding a new MMC property "full-pwr-cycle-in-suspend"
is useful now. After that, user could choose a graceful shutdown instead
of "sleeping" to avoid internal data corruptions in worst case at system
suspend. I'll submit such a patch.

Best regards,
Yoshihiro Shimoda

> >
> > [2]
> >
> https://lore.kernel.org/linux-renesas-soc/1592792699-24638-1-git-send-email-yoshihiro.shimoda.uh@renesas.com/T/#mde3
> 8d5866b7f3edc9a2ed105ac06b4fda4c3e99e
> >
> > [3]
> >
> https://lore.kernel.org/linux-renesas-soc/1592792699-24638-1-git-send-email-yoshihiro.shimoda.uh@renesas.com/T/#mf8e
> 7abdf135586ba0b70a1c235410a6f94c6007d
> >
> > [4]
> >
> https://lore.kernel.org/linux-renesas-soc/CAMuHMdX93Q9WhKLqv_wNPzArbc68NcbVN8jJ9MDKxAcicpBQ5Q@mail.gmail.com/T/#m442
> a2ce972cfdb3ff33637c120c8d096e4d07af8
> >
> 
> Kind regards
> Uffe

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v3 1/2] firmware: psci: call pm_set_suspend_via_firmware()
  2020-06-22  2:24 ` [PATCH v3 1/2] firmware: psci: call pm_set_suspend_via_firmware() Yoshihiro Shimoda
@ 2020-08-05  8:08   ` Geert Uytterhoeven
  0 siblings, 0 replies; 12+ messages in thread
From: Geert Uytterhoeven @ 2020-08-05  8:08 UTC (permalink / raw)
  To: Yoshihiro Shimoda
  Cc: Mark Rutland, Lorenzo Pieralisi, Ulf Hansson, Linux MMC List,
	Linux ARM, Linux-Renesas, Linux PM list

Hi Shimoda-san,

CC linux-pm

On Mon, Jun 22, 2020 at 4:25 AM Yoshihiro Shimoda
<yoshihiro.shimoda.uh@renesas.com> wrote:
> Call pm_set_suspend_via_firmware() in .begin() of psci_suspend_ops
> to use pm_suspend_via_firmware() on PSCI environment.
>
> Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>

Thanks for your patch!

While [PATCH v3 2/2] has been rejected, and a different solution (DT
property "full-pwr-cycle-in-suspend") was accepted, I think this patch
has merits on its own: it makes sure pm_suspend_global_flags contains
the correct state not only for systems using ACPI, but also for PSCI.

> --- a/drivers/firmware/psci/psci.c
> +++ b/drivers/firmware/psci/psci.c
> @@ -309,6 +309,13 @@ static int psci_system_suspend(unsigned long unused)
>                               __pa_symbol(cpu_resume), 0, 0);
>  }
>
> +static int psci_system_suspend_begin(suspend_state_t state)
> +{
> +       pm_set_suspend_via_firmware();
> +
> +       return 0;
> +}
> +
>  static int psci_system_suspend_enter(suspend_state_t state)
>  {

Shouldn't you add a call to pm_set_resume_via_firmware() here?

>         return cpu_suspend(0, psci_system_suspend);
> @@ -316,6 +323,7 @@ static int psci_system_suspend_enter(suspend_state_t state)
>
>  static const struct platform_suspend_ops psci_suspend_ops = {
>         .valid          = suspend_valid_only_mem,
> +       .begin          = psci_system_suspend_begin,
>         .enter          = psci_system_suspend_enter,
>  };

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2020-08-05  8:08 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-22  2:24 [PATCH v3 0/2] treewide: fix _mmc_suspend() on PSCI Yoshihiro Shimoda
2020-06-22  2:24 ` [PATCH v3 1/2] firmware: psci: call pm_set_suspend_via_firmware() Yoshihiro Shimoda
2020-08-05  8:08   ` Geert Uytterhoeven
2020-06-22  2:24 ` [PATCH v3 2/2] mmc: core: Call mmc_poweroff_nofity() if pm_suspend_via_firmware() Yoshihiro Shimoda
2020-06-24 10:05   ` Ulf Hansson
2020-06-24 11:13     ` Geert Uytterhoeven
2020-06-25  6:31       ` Yoshihiro Shimoda
2020-06-25  9:26         ` Geert Uytterhoeven
2020-06-26 11:03           ` Ulf Hansson
2020-07-02 12:37             ` Yoshihiro Shimoda
2020-07-06 13:10               ` Ulf Hansson
2020-07-07  1:26                 ` Yoshihiro Shimoda

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).