linux-pm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/1] kernel/power/autosleep.c: check for pm_suspend() return before queueing suspend again
@ 2015-06-29 12:34 Nitish Ambastha
  2015-06-29  9:21 ` Pavel Machek
  2015-06-29 18:54 ` [PATCHv2 " Nitish Ambastha
  0 siblings, 2 replies; 14+ messages in thread
From: Nitish Ambastha @ 2015-06-29 12:34 UTC (permalink / raw)
  To: rjw, pavel, len.brown, linux-pm, linux-kernel
  Cc: cpgs, nitish.a, nits.ambastha

Prevent tight loop for suspend-resume when some
devices failed to suspend
If some devices failed to suspend, we monitor this
error in try_to_suspend(). pm_suspend() is already
an 'int' returning function, how about checking return
from pm_suspend() before queueing suspend again?

For devices which do not register for pending events,
this will prevent tight loop for suspend-resume in
suspend abort scenarios due to device suspend failures

Signed-off-by: Nitish Ambastha <nitish.a@samsung.com>
---
 kernel/power/autosleep.c |   13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/kernel/power/autosleep.c b/kernel/power/autosleep.c
index 9012ecf..3923148 100644
--- a/kernel/power/autosleep.c
+++ b/kernel/power/autosleep.c
@@ -26,6 +26,7 @@ static struct wakeup_source *autosleep_ws;
 static void try_to_suspend(struct work_struct *work)
 {
 	unsigned int initial_count, final_count;
+	int error = 0;
 
 	if (!pm_get_wakeup_count(&initial_count, true))
 		goto out;
@@ -45,10 +46,20 @@ static void try_to_suspend(struct work_struct *work)
 	if (autosleep_state >= PM_SUSPEND_MAX)
 		hibernate();
 	else
-		pm_suspend(autosleep_state);
+		error = pm_suspend(autosleep_state);
 
 	mutex_unlock(&autosleep_lock);
 
+	if (error) {
+		/*
+		 * If some devices failed to suspend, its better to wait
+		 * to prevent system from trying to suspend in tight loop
+		 */
+		pr_info("PM: suspend returned (%d)\n", error);
+		schedule_timeout_uninterruptible(HZ / 2);
+		goto out;
+	}
+
 	if (!pm_get_wakeup_count(&final_count, false))
 		goto out;
 
-- 
1.7.9.5


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

end of thread, other threads:[~2015-07-22 20:11 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-06-29 12:34 [PATCH 1/1] kernel/power/autosleep.c: check for pm_suspend() return before queueing suspend again Nitish Ambastha
2015-06-29  9:21 ` Pavel Machek
2015-06-29 18:54 ` [PATCHv2 " Nitish Ambastha
2015-06-29 19:56   ` Rafael J. Wysocki
2015-06-29 20:07     ` Rafael J. Wysocki
2015-06-30 19:22       ` Nitish Ambastha
2015-06-30 20:01         ` Rafael J. Wysocki
2015-07-04 18:06           ` Nitish Ambastha
2015-07-13 20:08   ` [PATCHv3 " Nitish Ambastha
2015-07-13 20:24     ` Nitish Ambastha
2015-07-13 23:43     ` Rafael J. Wysocki
2015-07-14  4:04       ` Nitish Ambastha
2015-07-15 22:29         ` Rafael J. Wysocki
2015-07-22 20:11           ` Nitish Ambastha

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