* Re: [PATCH] PM / suspend: Catch wake-up requests in suspend_again
[not found] <CACB9iXzNUA5+kLkDC=_w2PLB9TkLSXwxsesbL5pJbOrkYYYwLA@mail.gmail.com>
@ 2014-09-30 20:38 ` Pavel Machek
0 siblings, 0 replies; 2+ messages in thread
From: Pavel Machek @ 2014-09-30 20:38 UTC (permalink / raw)
To: Joseph Swantek; +Cc: rjw, len.brown, linux-pm, linux-kernel
On Fri 2014-09-26 17:44:24, Joseph Swantek wrote:
> It is possible during the processing of suspend_again() that a
> wake-up request (i.e. pm_stay_awake()) be made by a driver in response
> to an outside event (i.e. hw interrupt, etc.). Currently, when
> suspend_again() requests to re-enter suspend, suspend_enter() runs
> to re-enter suspend. The pm_wakeup_pending() function is called to check
> for any wake-up requests. However, this function is essentially disabled
> because the events_check_enabled flag is set to false by the previous
> run through suspend_enter(). This causes any wake-up request made
> during the processing of suspend_again() to be delayed until the next
> time the kernel resumes sometime in the future.
>
> To resolve this issue, if suspend_again() votes to re-enter
> suspend_enter() the count of wake-up requests is re-evaluated
> and the events_check_enabled flag set correctly based on the
> presence of wake-up requests that occurred during suspend_again().
>
> @@ -188,8 +188,25 @@ static void platform_suspend_recover(suspend_state_t
> state)
>
> static bool platform_suspend_again(suspend_state_t state)
> {
> - return state != PM_SUSPEND_FREEZE && suspend_ops->suspend_again ?
> + int count;
> + bool suspend = state != PM_SUSPEND_FREEZE &&
> + suspend_ops->suspend_again ?
> suspend_ops->suspend_again() : false;
> +
> + if (suspend) {
> + /*
> + * pm_get_wakeup_count() gets an updated count of wakeup events
> + * that have occured and will return false (i.e. abort suspend)
> + * if a wakeup event has been started during suspend_again() and
> + * is still active. pm_save_wakeup_count() stores the count
> + * and enables pm_wakeup_pending() to properly analyze wakeup
> + * events before entering suspend in suspend_enter().
> + */
> + suspend = pm_get_wakeup_count(&count, false) &&
> + pm_save_wakeup_count(count);
> + }
> +
> + return suspend;
> }
That seems rather whitespace damaged.
--
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
^ permalink raw reply [flat|nested] 2+ messages in thread
* [PATCH] PM / suspend: Catch wake-up requests in suspend_again
@ 2014-09-30 22:20 Joe Swantek
0 siblings, 0 replies; 2+ messages in thread
From: Joe Swantek @ 2014-09-30 22:20 UTC (permalink / raw)
To: rjw; +Cc: pavel, len.brown, linux-pm, linux-kernel, Joe Swantek
It is possible during the processing of suspend_again() that a
wake-up request (i.e. pm_stay_awake()) be made by a driver in response
to an outside event (i.e. hw interrupt, etc.). Currently, when
suspend_again() requests to re-enter suspend, suspend_enter() runs
to re-enter suspend. The pm_wakeup_pending() function is called to check
for any wake-up requests. However, this function is essentially disabled
because the events_check_enabled flag is set to false by the previous
run through suspend_enter(). This causes any wake-up request made
during the processing of suspend_again() to be delayed until the next
time the kernel resumes sometime in the future.
To resolve this issue, if suspend_again() votes to re-enter
suspend_enter() the count of wake-up requests is re-evaluated
and the events_check_enabled flag set correctly based on the
presence of wake-up requests that occurred during suspend_again().
Signed-off-by: Joe Swantek <jswantek@motorola.com>
---
kernel/power/suspend.c | 19 ++++++++++++++++++-
1 file changed, 18 insertions(+), 1 deletion(-)
diff --git a/kernel/power/suspend.c b/kernel/power/suspend.c
index 18c6219..f619492 100644
--- a/kernel/power/suspend.c
+++ b/kernel/power/suspend.c
@@ -188,8 +188,25 @@ static void platform_suspend_recover(suspend_state_t state)
static bool platform_suspend_again(suspend_state_t state)
{
- return state != PM_SUSPEND_FREEZE && suspend_ops->suspend_again ?
+ int count;
+ bool suspend = state != PM_SUSPEND_FREEZE &&
+ suspend_ops->suspend_again ?
suspend_ops->suspend_again() : false;
+
+ if (suspend) {
+ /*
+ * pm_get_wakeup_count() gets an updated count of wakeup events
+ * that have occured and will return false (i.e. abort suspend)
+ * if a wakeup event has been started during suspend_again() and
+ * is still active. pm_save_wakeup_count() stores the count
+ * and enables pm_wakeup_pending() to properly analyze wakeup
+ * events before entering suspend in suspend_enter().
+ */
+ suspend = pm_get_wakeup_count(&count, false) &&
+ pm_save_wakeup_count(count);
+ }
+
+ return suspend;
}
static int suspend_test(int level)
--
1.9.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2014-09-30 22:36 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <CACB9iXzNUA5+kLkDC=_w2PLB9TkLSXwxsesbL5pJbOrkYYYwLA@mail.gmail.com>
2014-09-30 20:38 ` [PATCH] PM / suspend: Catch wake-up requests in suspend_again Pavel Machek
2014-09-30 22:20 Joe Swantek
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).