LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH] PM / sleep: Do not assume that "mem" is always present
@ 2021-09-15  2:23 Florian Fainelli
  2021-09-15 12:05 ` Rafael J. Wysocki
  0 siblings, 1 reply; 3+ messages in thread
From: Florian Fainelli @ 2021-09-15  2:23 UTC (permalink / raw)
  To: linux-kernel
  Cc: geert+renesas, Florian Fainelli, Rafael J. Wysocki, Len Brown,
	Pavel Machek, open list:SUSPEND TO RAM

An implementation of suspend_ops is allowed to reject the PM_SUSPEND_MEM
suspend type from its ->valid() callback, we should not assume that it
is always present as this is not a correct reflection of what a firmware
interface may support.

Fixes: 406e79385f32 ("PM / sleep: System sleep state selection interface rework")
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
---
 kernel/power/suspend.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/kernel/power/suspend.c b/kernel/power/suspend.c
index eb75f394a059..02e306ad8db8 100644
--- a/kernel/power/suspend.c
+++ b/kernel/power/suspend.c
@@ -171,8 +171,7 @@ static bool valid_state(suspend_state_t state)
 
 void __init pm_states_init(void)
 {
-	/* "mem" and "freeze" are always present in /sys/power/state. */
-	pm_states[PM_SUSPEND_MEM] = pm_labels[PM_SUSPEND_MEM];
+	/* "freeze" is always present in /sys/power/state. */
 	pm_states[PM_SUSPEND_TO_IDLE] = pm_labels[PM_SUSPEND_TO_IDLE];
 	/*
 	 * Suspend-to-idle should be supported even without any suspend_ops,
@@ -214,6 +213,7 @@ void suspend_set_ops(const struct platform_suspend_ops *ops)
 	}
 	if (valid_state(PM_SUSPEND_MEM)) {
 		mem_sleep_states[PM_SUSPEND_MEM] = mem_sleep_labels[PM_SUSPEND_MEM];
+		pm_states[PM_SUSPEND_MEM] = pm_labels[PM_SUSPEND_MEM];
 		if (mem_sleep_default >= PM_SUSPEND_MEM)
 			mem_sleep_current = PM_SUSPEND_MEM;
 	}
-- 
2.25.1


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

* Re: [PATCH] PM / sleep: Do not assume that "mem" is always present
  2021-09-15  2:23 [PATCH] PM / sleep: Do not assume that "mem" is always present Florian Fainelli
@ 2021-09-15 12:05 ` Rafael J. Wysocki
  2021-10-20 13:54   ` Rafael J. Wysocki
  0 siblings, 1 reply; 3+ messages in thread
From: Rafael J. Wysocki @ 2021-09-15 12:05 UTC (permalink / raw)
  To: Florian Fainelli
  Cc: Linux Kernel Mailing List, Geert Uytterhoeven, Rafael J. Wysocki,
	Len Brown, Pavel Machek, open list:SUSPEND TO RAM

On Wed, Sep 15, 2021 at 4:23 AM Florian Fainelli <f.fainelli@gmail.com> wrote:
>
> An implementation of suspend_ops is allowed to reject the PM_SUSPEND_MEM
> suspend type from its ->valid() callback, we should not assume that it
> is always present as this is not a correct reflection of what a firmware
> interface may support.
>
> Fixes: 406e79385f32 ("PM / sleep: System sleep state selection interface rework")
> Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
> ---
>  kernel/power/suspend.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/kernel/power/suspend.c b/kernel/power/suspend.c
> index eb75f394a059..02e306ad8db8 100644
> --- a/kernel/power/suspend.c
> +++ b/kernel/power/suspend.c
> @@ -171,8 +171,7 @@ static bool valid_state(suspend_state_t state)
>
>  void __init pm_states_init(void)
>  {
> -       /* "mem" and "freeze" are always present in /sys/power/state. */
> -       pm_states[PM_SUSPEND_MEM] = pm_labels[PM_SUSPEND_MEM];
> +       /* "freeze" is always present in /sys/power/state. */
>         pm_states[PM_SUSPEND_TO_IDLE] = pm_labels[PM_SUSPEND_TO_IDLE];
>         /*
>          * Suspend-to-idle should be supported even without any suspend_ops,
> @@ -214,6 +213,7 @@ void suspend_set_ops(const struct platform_suspend_ops *ops)
>         }
>         if (valid_state(PM_SUSPEND_MEM)) {
>                 mem_sleep_states[PM_SUSPEND_MEM] = mem_sleep_labels[PM_SUSPEND_MEM];
> +               pm_states[PM_SUSPEND_MEM] = pm_labels[PM_SUSPEND_MEM];
>                 if (mem_sleep_default >= PM_SUSPEND_MEM)
>                         mem_sleep_current = PM_SUSPEND_MEM;
>         }
> --

Applied as 5.16 material, thanks!

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

* Re: [PATCH] PM / sleep: Do not assume that "mem" is always present
  2021-09-15 12:05 ` Rafael J. Wysocki
@ 2021-10-20 13:54   ` Rafael J. Wysocki
  0 siblings, 0 replies; 3+ messages in thread
From: Rafael J. Wysocki @ 2021-10-20 13:54 UTC (permalink / raw)
  To: Florian Fainelli
  Cc: Linux Kernel Mailing List, Geert Uytterhoeven, Rafael J. Wysocki,
	Len Brown, Pavel Machek, open list:SUSPEND TO RAM

On Wed, Sep 15, 2021 at 2:05 PM Rafael J. Wysocki <rafael@kernel.org> wrote:
>
> On Wed, Sep 15, 2021 at 4:23 AM Florian Fainelli <f.fainelli@gmail.com> wrote:
> >
> > An implementation of suspend_ops is allowed to reject the PM_SUSPEND_MEM
> > suspend type from its ->valid() callback, we should not assume that it
> > is always present as this is not a correct reflection of what a firmware
> > interface may support.
> >
> > Fixes: 406e79385f32 ("PM / sleep: System sleep state selection interface rework")
> > Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
> > ---
> >  kernel/power/suspend.c | 4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/kernel/power/suspend.c b/kernel/power/suspend.c
> > index eb75f394a059..02e306ad8db8 100644
> > --- a/kernel/power/suspend.c
> > +++ b/kernel/power/suspend.c
> > @@ -171,8 +171,7 @@ static bool valid_state(suspend_state_t state)
> >
> >  void __init pm_states_init(void)
> >  {
> > -       /* "mem" and "freeze" are always present in /sys/power/state. */
> > -       pm_states[PM_SUSPEND_MEM] = pm_labels[PM_SUSPEND_MEM];
> > +       /* "freeze" is always present in /sys/power/state. */
> >         pm_states[PM_SUSPEND_TO_IDLE] = pm_labels[PM_SUSPEND_TO_IDLE];
> >         /*
> >          * Suspend-to-idle should be supported even without any suspend_ops,
> > @@ -214,6 +213,7 @@ void suspend_set_ops(const struct platform_suspend_ops *ops)
> >         }
> >         if (valid_state(PM_SUSPEND_MEM)) {
> >                 mem_sleep_states[PM_SUSPEND_MEM] = mem_sleep_labels[PM_SUSPEND_MEM];
> > +               pm_states[PM_SUSPEND_MEM] = pm_labels[PM_SUSPEND_MEM];
> >                 if (mem_sleep_default >= PM_SUSPEND_MEM)
> >                         mem_sleep_current = PM_SUSPEND_MEM;
> >         }
> > --
>
> Applied as 5.16 material, thanks!

And reverted as per
https://lore.kernel.org/linux-pm/d36f79b4-472c-4852-7370-a011f9f556ce@intel.com/

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

end of thread, other threads:[~2021-10-20 13:54 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-15  2:23 [PATCH] PM / sleep: Do not assume that "mem" is always present Florian Fainelli
2021-09-15 12:05 ` Rafael J. Wysocki
2021-10-20 13:54   ` Rafael J. Wysocki

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).