aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char/apm-emulation.c
diff options
context:
space:
mode:
authorNeilBrown <neilb@suse.de>2012-04-01 06:19:30 -0400
committerJiri Kosina <jkosina@suse.cz>2012-04-02 21:42:36 -0400
commitf283d22713b0bdc147097c92c9b45855339cf1c8 (patch)
treefee788fb13479ebe013eae8c9a4b621d6ccd3057 /drivers/char/apm-emulation.c
parentb4a133da2eaccb844a7beaef16ffd9c76a0d21d3 (diff)
APM: fix deadlock in APM_IOC_SUSPEND ioctl
I found the Xorg server on my ARM device stuck in the 'msleep()' loop in apm_ioctl. I suspect it had attempted suspend immediately after resuming and lost a race. During that msleep(10);, a new suspend cycle must have started and changed ->suspend_state to SUSPEND_PENDING, so it was never seen to be SUSPEND_DONE and the loop could never exited. It would have moved on to SUSPEND_ACKTO but never been able to reach SUSPEND_DONE. So change the loop to only run while SUSPEND_ACKED rather than until SUSPEND_DONE. This is much safer. Signed-off-by: NeilBrown <neilb@suse.de> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Diffstat (limited to 'drivers/char/apm-emulation.c')
-rw-r--r--drivers/char/apm-emulation.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/char/apm-emulation.c b/drivers/char/apm-emulation.c
index f4837a893dfa..6005c5c03f2a 100644
--- a/drivers/char/apm-emulation.c
+++ b/drivers/char/apm-emulation.c
@@ -302,7 +302,7 @@ apm_ioctl(struct file *filp, u_int cmd, u_long arg)
302 * anything critical, chill a bit on each iteration. 302 * anything critical, chill a bit on each iteration.
303 */ 303 */
304 while (wait_event_freezable(apm_suspend_waitqueue, 304 while (wait_event_freezable(apm_suspend_waitqueue,
305 as->suspend_state == SUSPEND_DONE)) 305 as->suspend_state != SUSPEND_ACKED))
306 msleep(10); 306 msleep(10);
307 break; 307 break;
308 case SUSPEND_ACKTO: 308 case SUSPEND_ACKTO: