Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1465030 > unrolled thread
| Started by | Sudeep Holla <sudeep.holla@arm.com> |
|---|---|
| First post | 2016-08-18 11:20 +0200 |
| Last post | 2016-08-24 07:20 +0200 |
| Articles | 7 — 4 participants |
Back to article view | Back to linux.kernel
[PATCH] PM / sleep: enable suspend-to-idle even without registered suspend_ops Sudeep Holla <sudeep.holla@arm.com> - 2016-08-18 11:20 +0200
Re: [PATCH] PM / sleep: enable suspend-to-idle even without registered suspend_ops "Rafael J. Wysocki" <rjw@rjwysocki.net> - 2016-08-18 13:10 +0200
Re: [PATCH] PM / sleep: enable suspend-to-idle even without registered suspend_ops Sudeep Holla <sudeep.holla@arm.com> - 2016-08-18 15:20 +0200
[PATCH v2] PM / sleep: enable suspend-to-idle even without registered suspend_ops Sudeep Holla <sudeep.holla@arm.com> - 2016-08-18 19:30 +0200
Re: [PATCH v2] PM / sleep: enable suspend-to-idle even without registered suspend_ops "Rafael J. Wysocki" <rafael@kernel.org> - 2016-08-19 04:20 +0200
[PATCH v3] PM / sleep: enable suspend-to-idle even without registered suspend_ops Sudeep Holla <sudeep.holla@arm.com> - 2016-08-19 15:50 +0200
Re: [PATCH v3] PM / sleep: enable suspend-to-idle even without registered suspend_ops Andy Gross <andy.gross@linaro.org> - 2016-08-24 07:20 +0200
| From | Sudeep Holla <sudeep.holla@arm.com> |
|---|---|
| Date | 2016-08-18 11:20 +0200 |
| Subject | [PATCH] PM / sleep: enable suspend-to-idle even without registered suspend_ops |
| Message-ID | <s7rEt-6bL-1@gated-at.bofh.it> |
Suspend-to-idle (aka the "freeze" sleep state) is a system sleep state
in which all of the processors enter deepest possible idle state and
wait for interrupts right after suspending all the devices.
There is no hard requirement for a platform to support and register
platform specific suspend_ops to enter suspend-to-idle/freeze state.
Only deeper system sleep states like PM_SUSPEND_STANDBY and
PM_SUSPEND_MEM rely on such low level support/implementation.
suspend-to-idle can be entered as along as all the devices can be
suspended. This patch enables the support for suspend-to-idle even on
systems that don't have any low level support for deeper system sleep
states and/or don't register any platform specific suspend_ops.
Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>
Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
---
kernel/power/main.c | 5 +++++
kernel/power/suspend.c | 8 +++++---
2 files changed, 10 insertions(+), 3 deletions(-)
Hi Rafael,
I am not sure if you like this approach. I found this to be the simplest
but I may have missed to consider all possible corner cases especially
for x86 and other platforms. I don't see any such issues/cases with ARM
systems.
Regards,
Sudeep
diff --git a/kernel/power/main.c b/kernel/power/main.c
index 5ea50b1b7595..0f0fd9184f39 100644
--- a/kernel/power/main.c
+++ b/kernel/power/main.c
@@ -651,6 +651,11 @@ static int __init pm_init(void)
if (error)
return error;
pm_print_times_init();
+ /*
+ * freeze state should be supported even without any suspend_ops,
+ * calling suspend_set_ops without any ops will setup freeze state
+ */
+ suspend_set_ops(NULL);
return pm_autosleep_init();
}
diff --git a/kernel/power/suspend.c b/kernel/power/suspend.c
index 0acab9d7f96f..37d64f811ecd 100644
--- a/kernel/power/suspend.c
+++ b/kernel/power/suspend.c
@@ -138,7 +138,9 @@ void suspend_set_ops(const struct platform_suspend_ops *ops)
lock_system_sleep();
- suspend_ops = ops;
+ WARN_ONCE(ops && suspend_ops, "overriding suspend_ops");
+ if (ops)
+ suspend_ops = ops;
for (i = PM_SUSPEND_MEM; i >= PM_SUSPEND_STANDBY; i--)
if (valid_state(i)) {
pm_states[i] = pm_labels[j++];
@@ -211,7 +213,7 @@ static int platform_suspend_begin(suspend_state_t state)
{
if (state == PM_SUSPEND_FREEZE && freeze_ops && freeze_ops->begin)
return freeze_ops->begin();
- else if (suspend_ops->begin)
+ else if (suspend_ops && suspend_ops->begin)
return suspend_ops->begin(state);
else
return 0;
@@ -221,7 +223,7 @@ static void platform_resume_end(suspend_state_t state)
{
if (state == PM_SUSPEND_FREEZE && freeze_ops && freeze_ops->end)
freeze_ops->end();
- else if (suspend_ops->end)
+ else if (suspend_ops && suspend_ops->end)
suspend_ops->end();
}
--
2.7.4
[toc] | [next] | [standalone]
| From | "Rafael J. Wysocki" <rjw@rjwysocki.net> |
|---|---|
| Date | 2016-08-18 13:10 +0200 |
| Message-ID | <s7tmW-7oo-23@gated-at.bofh.it> |
| In reply to | #1465030 |
On Thursday, August 18, 2016 10:19:24 AM Sudeep Holla wrote:
> Suspend-to-idle (aka the "freeze" sleep state) is a system sleep state
> in which all of the processors enter deepest possible idle state and
> wait for interrupts right after suspending all the devices.
>
> There is no hard requirement for a platform to support and register
> platform specific suspend_ops to enter suspend-to-idle/freeze state.
> Only deeper system sleep states like PM_SUSPEND_STANDBY and
> PM_SUSPEND_MEM rely on such low level support/implementation.
>
> suspend-to-idle can be entered as along as all the devices can be
> suspended. This patch enables the support for suspend-to-idle even on
> systems that don't have any low level support for deeper system sleep
> states and/or don't register any platform specific suspend_ops.
>
> Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>
> Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
> ---
> kernel/power/main.c | 5 +++++
> kernel/power/suspend.c | 8 +++++---
> 2 files changed, 10 insertions(+), 3 deletions(-)
>
> Hi Rafael,
>
> I am not sure if you like this approach. I found this to be the simplest
> but I may have missed to consider all possible corner cases especially
> for x86 and other platforms. I don't see any such issues/cases with ARM
> systems.
>
> diff --git a/kernel/power/main.c b/kernel/power/main.c
> index 5ea50b1b7595..0f0fd9184f39 100644
> --- a/kernel/power/main.c
> +++ b/kernel/power/main.c
> @@ -651,6 +651,11 @@ static int __init pm_init(void)
> if (error)
> return error;
> pm_print_times_init();
> + /*
> + * freeze state should be supported even without any suspend_ops,
> + * calling suspend_set_ops without any ops will setup freeze state
> + */
> + suspend_set_ops(NULL);
Well, this is a core initcall, so suspend_set_ops() invocations from platforms
really should happen after that, so something like this should be sufficient here:
pm_state[PM_SUSPEND_FREEZE] = pm_labels[relative_states ? PM_SUSPEND_MEM : PM_SUSPEND_FREEZE];
if I'm not mistaken.
> return pm_autosleep_init();
> }
> diff --git a/kernel/power/suspend.c b/kernel/power/suspend.c
> index 0acab9d7f96f..37d64f811ecd 100644
> --- a/kernel/power/suspend.c
> +++ b/kernel/power/suspend.c
> @@ -138,7 +138,9 @@ void suspend_set_ops(const struct platform_suspend_ops *ops)
>
> lock_system_sleep();
>
> - suspend_ops = ops;
> + WARN_ONCE(ops && suspend_ops, "overriding suspend_ops");
> + if (ops)
> + suspend_ops = ops;
And this should not be necessary then.
> for (i = PM_SUSPEND_MEM; i >= PM_SUSPEND_STANDBY; i--)
> if (valid_state(i)) {
> pm_states[i] = pm_labels[j++];
> @@ -211,7 +213,7 @@ static int platform_suspend_begin(suspend_state_t state)
> {
> if (state == PM_SUSPEND_FREEZE && freeze_ops && freeze_ops->begin)
> return freeze_ops->begin();
> - else if (suspend_ops->begin)
> + else if (suspend_ops && suspend_ops->begin)
> return suspend_ops->begin(state);
> else
> return 0;
> @@ -221,7 +223,7 @@ static void platform_resume_end(suspend_state_t state)
> {
> if (state == PM_SUSPEND_FREEZE && freeze_ops && freeze_ops->end)
> freeze_ops->end();
> - else if (suspend_ops->end)
> + else if (suspend_ops && suspend_ops->end)
> suspend_ops->end();
> }
And this is still needed, of course.
Thanks,
Rafael
[toc] | [prev] | [next] | [standalone]
| From | Sudeep Holla <sudeep.holla@arm.com> |
|---|---|
| Date | 2016-08-18 15:20 +0200 |
| Subject | Re: [PATCH] PM / sleep: enable suspend-to-idle even without registered suspend_ops |
| Message-ID | <s7voL-ho-63@gated-at.bofh.it> |
| In reply to | #1465166 |
On 18/08/16 12:06, Rafael J. Wysocki wrote: > On Thursday, August 18, 2016 10:19:24 AM Sudeep Holla wrote: >> Suspend-to-idle (aka the "freeze" sleep state) is a system sleep state >> in which all of the processors enter deepest possible idle state and >> wait for interrupts right after suspending all the devices. >> >> There is no hard requirement for a platform to support and register >> platform specific suspend_ops to enter suspend-to-idle/freeze state. >> Only deeper system sleep states like PM_SUSPEND_STANDBY and >> PM_SUSPEND_MEM rely on such low level support/implementation. >> >> suspend-to-idle can be entered as along as all the devices can be >> suspended. This patch enables the support for suspend-to-idle even on >> systems that don't have any low level support for deeper system sleep >> states and/or don't register any platform specific suspend_ops. >> >> Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net> >> Signed-off-by: Sudeep Holla <sudeep.holla@arm.com> >> --- >> kernel/power/main.c | 5 +++++ >> kernel/power/suspend.c | 8 +++++--- >> 2 files changed, 10 insertions(+), 3 deletions(-) >> >> Hi Rafael, >> >> I am not sure if you like this approach. I found this to be the simplest >> but I may have missed to consider all possible corner cases especially >> for x86 and other platforms. I don't see any such issues/cases with ARM >> systems. >> >> diff --git a/kernel/power/main.c b/kernel/power/main.c >> index 5ea50b1b7595..0f0fd9184f39 100644 >> --- a/kernel/power/main.c >> +++ b/kernel/power/main.c >> @@ -651,6 +651,11 @@ static int __init pm_init(void) >> if (error) >> return error; >> pm_print_times_init(); >> + /* >> + * freeze state should be supported even without any suspend_ops, >> + * calling suspend_set_ops without any ops will setup freeze state >> + */ >> + suspend_set_ops(NULL); > > Well, this is a core initcall, so suspend_set_ops() invocations from platforms > really should happen after that, so something like this should be sufficient here: > > pm_state[PM_SUSPEND_FREEZE] = pm_labels[relative_states ? PM_SUSPEND_MEM : PM_SUSPEND_FREEZE]; > > if I'm not mistaken. > But won't this show up as "standby" state in /sys/power/state ? Or did you mean: pm_state[PM_SUSPEND_FREEZE] = pm_labels[relative_states ? 0 : 2]; which will be "mem" or "freeze" based on relative_states. In-fact, I did exactly this when I first hacked. Since it exposed incorrectly to sysfs and I was not sure of these relative_states and it's usage, I preferred re-using suspend_set_ops for this. IIUC showing freeze state as "mem" in sysfs is fine as that's the deepest possible state when relative_states=1. But showing it as freeze as "standby" in sysfs when relative_states=0 looked wrong to me though it works as freeze state. As a side-note with psci, it get called quite early before core_initcall. But that can be fixed if needed and is different issue. -- Regards, Sudeep
[toc] | [prev] | [next] | [standalone]
| From | Sudeep Holla <sudeep.holla@arm.com> |
|---|---|
| Date | 2016-08-18 19:30 +0200 |
| Subject | [PATCH v2] PM / sleep: enable suspend-to-idle even without registered suspend_ops |
| Message-ID | <s7ziF-2HZ-3@gated-at.bofh.it> |
| In reply to | #1465030 |
Suspend-to-idle (aka the "freeze" sleep state) is a system sleep state
in which all of the processors enter deepest possible idle state and
wait for interrupts right after suspending all the devices.
There is no hard requirement for a platform to support and register
platform specific suspend_ops to enter suspend-to-idle/freeze state.
Only deeper system sleep states like PM_SUSPEND_STANDBY and
PM_SUSPEND_MEM rely on such low level support/implementation.
Suspend-to-idle can be entered as along as all the devices can be
suspended. This patch enables the support for suspend-to-idle even on
systems that don't have any low level support for deeper system sleep
states and/or don't register any platform specific suspend_ops.
Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>
Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
---
include/linux/suspend.h | 2 ++
kernel/power/main.c | 1 +
kernel/power/suspend.c | 14 +++++++++++---
3 files changed, 14 insertions(+), 3 deletions(-)
v1->v2:
- Introduced pm_freeze_init instead of (mis/re)using suspend_set_ops
to setup freeze state in absense of registered platform suspend_ops
diff --git a/include/linux/suspend.h b/include/linux/suspend.h
index 7693e39b14fe..0528ee32be7c 100644
--- a/include/linux/suspend.h
+++ b/include/linux/suspend.h
@@ -245,6 +245,7 @@ static inline bool idle_should_freeze(void)
return unlikely(suspend_freeze_state == FREEZE_STATE_ENTER);
}
+extern void __init pm_freeze_init(void);
extern void freeze_set_ops(const struct platform_freeze_ops *ops);
extern void freeze_wake(void);
@@ -279,6 +280,7 @@ static inline bool pm_resume_via_firmware(void) { return false; }
static inline void suspend_set_ops(const struct platform_suspend_ops *ops) {}
static inline int pm_suspend(suspend_state_t state) { return -ENOSYS; }
static inline bool idle_should_freeze(void) { return false; }
+static inline void __init pm_freeze_init(void) {}
static inline void freeze_set_ops(const struct platform_freeze_ops *ops) {}
static inline void freeze_wake(void) {}
#endif /* !CONFIG_SUSPEND */
diff --git a/kernel/power/main.c b/kernel/power/main.c
index 5ea50b1b7595..f27c2f2d0f22 100644
--- a/kernel/power/main.c
+++ b/kernel/power/main.c
@@ -651,6 +651,7 @@ static int __init pm_init(void)
if (error)
return error;
pm_print_times_init();
+ pm_freeze_init();
return pm_autosleep_init();
}
diff --git a/kernel/power/suspend.c b/kernel/power/suspend.c
index 0acab9d7f96f..1c962a366678 100644
--- a/kernel/power/suspend.c
+++ b/kernel/power/suspend.c
@@ -118,10 +118,18 @@ static bool valid_state(suspend_state_t state)
*/
static bool relative_states;
+void __init pm_freeze_init(void)
+{
+ /*
+ * freeze state should be supported even without any suspend_ops,
+ * initialize pm_states accordingly here
+ */
+ pm_states[PM_SUSPEND_FREEZE] = pm_labels[relative_states ? 0 : 2];
+}
+
static int __init sleep_states_setup(char *str)
{
relative_states = !strncmp(str, "1", 1);
- pm_states[PM_SUSPEND_FREEZE] = pm_labels[relative_states ? 0 : 2];
return 1;
}
@@ -211,7 +219,7 @@ static int platform_suspend_begin(suspend_state_t state)
{
if (state == PM_SUSPEND_FREEZE && freeze_ops && freeze_ops->begin)
return freeze_ops->begin();
- else if (suspend_ops->begin)
+ else if (suspend_ops && suspend_ops->begin)
return suspend_ops->begin(state);
else
return 0;
@@ -221,7 +229,7 @@ static void platform_resume_end(suspend_state_t state)
{
if (state == PM_SUSPEND_FREEZE && freeze_ops && freeze_ops->end)
freeze_ops->end();
- else if (suspend_ops->end)
+ else if (suspend_ops && suspend_ops->end)
suspend_ops->end();
}
--
2.7.4
[toc] | [prev] | [next] | [standalone]
| From | "Rafael J. Wysocki" <rafael@kernel.org> |
|---|---|
| Date | 2016-08-19 04:20 +0200 |
| Subject | Re: [PATCH v2] PM / sleep: enable suspend-to-idle even without registered suspend_ops |
| Message-ID | <s7Hzz-817-9@gated-at.bofh.it> |
| In reply to | #1465653 |
On Thu, Aug 18, 2016 at 6:42 PM, Sudeep Holla <sudeep.holla@arm.com> wrote:
> Suspend-to-idle (aka the "freeze" sleep state) is a system sleep state
> in which all of the processors enter deepest possible idle state and
> wait for interrupts right after suspending all the devices.
>
> There is no hard requirement for a platform to support and register
> platform specific suspend_ops to enter suspend-to-idle/freeze state.
> Only deeper system sleep states like PM_SUSPEND_STANDBY and
> PM_SUSPEND_MEM rely on such low level support/implementation.
>
> Suspend-to-idle can be entered as along as all the devices can be
> suspended. This patch enables the support for suspend-to-idle even on
> systems that don't have any low level support for deeper system sleep
> states and/or don't register any platform specific suspend_ops.
>
> Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>
> Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
> ---
> include/linux/suspend.h | 2 ++
> kernel/power/main.c | 1 +
> kernel/power/suspend.c | 14 +++++++++++---
> 3 files changed, 14 insertions(+), 3 deletions(-)
>
> v1->v2:
> - Introduced pm_freeze_init instead of (mis/re)using suspend_set_ops
> to setup freeze state in absense of registered platform suspend_ops
>
> diff --git a/include/linux/suspend.h b/include/linux/suspend.h
> index 7693e39b14fe..0528ee32be7c 100644
> --- a/include/linux/suspend.h
> +++ b/include/linux/suspend.h
> @@ -245,6 +245,7 @@ static inline bool idle_should_freeze(void)
> return unlikely(suspend_freeze_state == FREEZE_STATE_ENTER);
> }
>
> +extern void __init pm_freeze_init(void);
> extern void freeze_set_ops(const struct platform_freeze_ops *ops);
> extern void freeze_wake(void);
>
> @@ -279,6 +280,7 @@ static inline bool pm_resume_via_firmware(void) { return false; }
> static inline void suspend_set_ops(const struct platform_suspend_ops *ops) {}
> static inline int pm_suspend(suspend_state_t state) { return -ENOSYS; }
> static inline bool idle_should_freeze(void) { return false; }
> +static inline void __init pm_freeze_init(void) {}
Why don't you call it pm_states_init()?
> static inline void freeze_set_ops(const struct platform_freeze_ops *ops) {}
> static inline void freeze_wake(void) {}
> #endif /* !CONFIG_SUSPEND */
> diff --git a/kernel/power/main.c b/kernel/power/main.c
> index 5ea50b1b7595..f27c2f2d0f22 100644
> --- a/kernel/power/main.c
> +++ b/kernel/power/main.c
> @@ -651,6 +651,7 @@ static int __init pm_init(void)
> if (error)
> return error;
> pm_print_times_init();
> + pm_freeze_init();
And please move this up (before the registration of power_kobj).
> return pm_autosleep_init();
> }
>
> diff --git a/kernel/power/suspend.c b/kernel/power/suspend.c
> index 0acab9d7f96f..1c962a366678 100644
> --- a/kernel/power/suspend.c
> +++ b/kernel/power/suspend.c
> @@ -118,10 +118,18 @@ static bool valid_state(suspend_state_t state)
> */
> static bool relative_states;
>
> +void __init pm_freeze_init(void)
> +{
> + /*
> + * freeze state should be supported even without any suspend_ops,
> + * initialize pm_states accordingly here
> + */
> + pm_states[PM_SUSPEND_FREEZE] = pm_labels[relative_states ? 0 : 2];
> +}
> +
> static int __init sleep_states_setup(char *str)
> {
> relative_states = !strncmp(str, "1", 1);
> - pm_states[PM_SUSPEND_FREEZE] = pm_labels[relative_states ? 0 : 2];
> return 1;
> }
>
> @@ -211,7 +219,7 @@ static int platform_suspend_begin(suspend_state_t state)
> {
> if (state == PM_SUSPEND_FREEZE && freeze_ops && freeze_ops->begin)
> return freeze_ops->begin();
> - else if (suspend_ops->begin)
> + else if (suspend_ops && suspend_ops->begin)
> return suspend_ops->begin(state);
> else
> return 0;
> @@ -221,7 +229,7 @@ static void platform_resume_end(suspend_state_t state)
> {
> if (state == PM_SUSPEND_FREEZE && freeze_ops && freeze_ops->end)
> freeze_ops->end();
> - else if (suspend_ops->end)
> + else if (suspend_ops && suspend_ops->end)
> suspend_ops->end();
> }
>
> --
Thanks,
Rafael
[toc] | [prev] | [next] | [standalone]
| From | Sudeep Holla <sudeep.holla@arm.com> |
|---|---|
| Date | 2016-08-19 15:50 +0200 |
| Subject | [PATCH v3] PM / sleep: enable suspend-to-idle even without registered suspend_ops |
| Message-ID | <s7Slj-6gW-11@gated-at.bofh.it> |
| In reply to | #1465653 |
Suspend-to-idle (aka the "freeze" sleep state) is a system sleep state
in which all of the processors enter deepest possible idle state and
wait for interrupts right after suspending all the devices.
There is no hard requirement for a platform to support and register
platform specific suspend_ops to enter suspend-to-idle/freeze state.
Only deeper system sleep states like PM_SUSPEND_STANDBY and
PM_SUSPEND_MEM rely on such low level support/implementation.
suspend-to-idle can be entered as along as all the devices can be
suspended. This patch enables the support for suspend-to-idle even on
systems that don't have any low level support for deeper system sleep
states and/or don't register any platform specific suspend_ops.
Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>
Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
---
include/linux/suspend.h | 2 ++
kernel/power/main.c | 1 +
kernel/power/suspend.c | 14 +++++++++++---
3 files changed, 14 insertions(+), 3 deletions(-)
v2->v3:
- Renamed pm_freeze_init to pm_states_init
- Moved pm_states_init earlier in pm_init
v1->v2:
- Introduced pm_freeze_init instead of (mis/re)using suspend_set_ops
to setup freeze state in absense of registered platform suspend_ops
diff --git a/include/linux/suspend.h b/include/linux/suspend.h
index 7693e39b14fe..d9718378a8be 100644
--- a/include/linux/suspend.h
+++ b/include/linux/suspend.h
@@ -245,6 +245,7 @@ static inline bool idle_should_freeze(void)
return unlikely(suspend_freeze_state == FREEZE_STATE_ENTER);
}
+extern void __init pm_states_init(void);
extern void freeze_set_ops(const struct platform_freeze_ops *ops);
extern void freeze_wake(void);
@@ -279,6 +280,7 @@ static inline bool pm_resume_via_firmware(void) { return false; }
static inline void suspend_set_ops(const struct platform_suspend_ops *ops) {}
static inline int pm_suspend(suspend_state_t state) { return -ENOSYS; }
static inline bool idle_should_freeze(void) { return false; }
+static inline void __init pm_states_init(void) {}
static inline void freeze_set_ops(const struct platform_freeze_ops *ops) {}
static inline void freeze_wake(void) {}
#endif /* !CONFIG_SUSPEND */
diff --git a/kernel/power/main.c b/kernel/power/main.c
index 5ea50b1b7595..281a697fd458 100644
--- a/kernel/power/main.c
+++ b/kernel/power/main.c
@@ -644,6 +644,7 @@ static int __init pm_init(void)
return error;
hibernate_image_size_init();
hibernate_reserved_size_init();
+ pm_states_init();
power_kobj = kobject_create_and_add("power", NULL);
if (!power_kobj)
return -ENOMEM;
diff --git a/kernel/power/suspend.c b/kernel/power/suspend.c
index 0acab9d7f96f..1e7f5da648d9 100644
--- a/kernel/power/suspend.c
+++ b/kernel/power/suspend.c
@@ -118,10 +118,18 @@ static bool valid_state(suspend_state_t state)
*/
static bool relative_states;
+void __init pm_states_init(void)
+{
+ /*
+ * freeze state should be supported even without any suspend_ops,
+ * initialize pm_states accordingly here
+ */
+ pm_states[PM_SUSPEND_FREEZE] = pm_labels[relative_states ? 0 : 2];
+}
+
static int __init sleep_states_setup(char *str)
{
relative_states = !strncmp(str, "1", 1);
- pm_states[PM_SUSPEND_FREEZE] = pm_labels[relative_states ? 0 : 2];
return 1;
}
@@ -211,7 +219,7 @@ static int platform_suspend_begin(suspend_state_t state)
{
if (state == PM_SUSPEND_FREEZE && freeze_ops && freeze_ops->begin)
return freeze_ops->begin();
- else if (suspend_ops->begin)
+ else if (suspend_ops && suspend_ops->begin)
return suspend_ops->begin(state);
else
return 0;
@@ -221,7 +229,7 @@ static void platform_resume_end(suspend_state_t state)
{
if (state == PM_SUSPEND_FREEZE && freeze_ops && freeze_ops->end)
freeze_ops->end();
- else if (suspend_ops->end)
+ else if (suspend_ops && suspend_ops->end)
suspend_ops->end();
}
-
2.7.4
[toc] | [prev] | [next] | [standalone]
| From | Andy Gross <andy.gross@linaro.org> |
|---|---|
| Date | 2016-08-24 07:20 +0200 |
| Subject | Re: [PATCH v3] PM / sleep: enable suspend-to-idle even without registered suspend_ops |
| Message-ID | <s9yLw-68S-15@gated-at.bofh.it> |
| In reply to | #1466433 |
On 19 August 2016 at 08:41, Sudeep Holla <sudeep.holla@arm.com> wrote: > Suspend-to-idle (aka the "freeze" sleep state) is a system sleep state > in which all of the processors enter deepest possible idle state and > wait for interrupts right after suspending all the devices. > > There is no hard requirement for a platform to support and register > platform specific suspend_ops to enter suspend-to-idle/freeze state. > Only deeper system sleep states like PM_SUSPEND_STANDBY and > PM_SUSPEND_MEM rely on such low level support/implementation. > > suspend-to-idle can be entered as along as all the devices can be > suspended. This patch enables the support for suspend-to-idle even on > systems that don't have any low level support for deeper system sleep > states and/or don't register any platform specific suspend_ops. > > Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net> > Signed-off-by: Sudeep Holla <sudeep.holla@arm.com> I tested this patch on the Qualcomm 410c platform. It worked like a charm. Thanks for working on this! Tested-by: Andy Gross <andy.gross@linaro.org>
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web