From aea8045d06f0711cdbacf19517bf01e5c6d9acf9 Mon Sep 17 00:00:00 2001 From: Srinivasarao P Date: Thu, 30 Jan 2014 15:31:59 +0530 Subject: [PATCH] power: don't wait for timeout if sys_sync completes early In some cases the suspend thread is waiting for timer to expire even if the sync workqueue is empty. So the suspend is taking extra time. To avoid this waiting, sending the completion event from last sync item in workqueue. CRs-Fixed: 583016 Change-Id: Ia3219e90762ec7f6ad3e7096126832acfd03ed69 Signed-off-by: Srinivasarao P --- kernel/power/wakelock.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/kernel/power/wakelock.c b/kernel/power/wakelock.c index 2583856fab3..0db39b85129 100644 --- a/kernel/power/wakelock.c +++ b/kernel/power/wakelock.c @@ -265,6 +265,9 @@ long has_wake_lock(int type) return ret; } +static bool is_suspend_sys_sync_waiting; +static void suspend_sys_sync_handler(unsigned long); +static DEFINE_TIMER(suspend_sys_sync_timer, suspend_sys_sync_handler, 0, 0); static void suspend_sys_sync(struct work_struct *work) { if (debug_mask & DEBUG_SUSPEND) @@ -277,6 +280,10 @@ static void suspend_sys_sync(struct work_struct *work) spin_lock(&suspend_sys_sync_lock); suspend_sys_sync_count--; + if (is_suspend_sys_sync_waiting && (suspend_sys_sync_count == 0)) { + complete(&suspend_sys_sync_comp); + del_timer(&suspend_sys_sync_timer); + } spin_unlock(&suspend_sys_sync_lock); } static DECLARE_WORK(suspend_sys_sync_work, suspend_sys_sync); @@ -293,8 +300,6 @@ void suspend_sys_sync_queue(void) } static bool suspend_sys_sync_abort; -static void suspend_sys_sync_handler(unsigned long); -static DEFINE_TIMER(suspend_sys_sync_timer, suspend_sys_sync_handler, 0, 0); /* value should be less then half of input event wake lock timeout value * which is currently set to 5*HZ (see drivers/input/evdev.c) */ @@ -319,7 +324,9 @@ int suspend_sys_sync_wait(void) if (suspend_sys_sync_count != 0) { mod_timer(&suspend_sys_sync_timer, jiffies + SUSPEND_SYS_SYNC_TIMEOUT); + is_suspend_sys_sync_waiting = true; wait_for_completion(&suspend_sys_sync_comp); + is_suspend_sys_sync_waiting = false; } if (suspend_sys_sync_abort) { pr_info("suspend aborted....while waiting for sys_sync\n");