power: fix lcd resume taking long time with an ongoing file copy
author黄涛 <huangtao@rock-chips.com>
Wed, 28 Dec 2011 06:43:33 +0000 (14:43 +0800)
committer黄涛 <huangtao@rock-chips.com>
Wed, 28 Dec 2011 06:46:00 +0000 (14:46 +0800)
commitc6e6466d054f5a03c0a1cbcf7911dde06a549324
treee5fc4d63a7192503710ef43713c3966680fe38b3
parentd55726c18b5c4ddcc477d9aba2a748286ce42c8c
power: fix lcd resume taking long time with an ongoing file copy

port from msm:
This fixes the issue where LCD takes a long time to come back up
since the execution of backlight on and late_resume works by the
suspend worker thread is delayed due to one (or more) of the
sys_sync calls in early_suspend and suspend paths taking a long
time (sometimes 15sec or more) for the below reported scenario(s):

Scenario 1 (copy with usb connected):
1. plug usb
2. adb shell
3. busybox cp /sdcard/file1 /sdcard/file2 (copy >= 100MB file1
   in sdcard/emmc to file2 in sdcard/emmc)
4. press end key to suspend
5. press end key again and it takes a long time for LCD to come
   back up

Scenario 2 (background copy):
1. plug usb
2. adb shell
3. busybox cp /sdcard/file1 /sdcard/file2 & (copy >= 100MB file1
   in sdcard/emmc to file2 in sdcard/emmc)
4. disconnect usb
5. press end key to suspend
6. press end key again and it takes a long time for LCD to come
   back up

A more common form of Scenario 2 is for the user to just use the
copy function on the UI to copy large file(s).

We address this by moving sys_sync calls to a separate workqueue
and having a timeout polling based mechanism to bail out of suspend
in case of user invoking a wakeup event (like end key press) while
we are waiting for the sys_sync completion at the synchronization
point in suspend worker thread context.
kernel/power/Kconfig
kernel/power/earlysuspend.c
kernel/power/power.h
kernel/power/process.c
kernel/power/suspend.c
kernel/power/wakelock.c