* Subject: [PATCH] APM: fix deadlock in APM_IOC_SUSPEND ioctl
@ 2012-04-01 10:19 NeilBrown
2012-04-03 1:44 ` Jiri Kosina
0 siblings, 1 reply; 2+ messages in thread
From: NeilBrown @ 2012-04-01 10:19 UTC (permalink / raw)
To: Jiri Kosina; +Cc: lkml
[-- Attachment #1: Type: text/plain, Size: 1113 bytes --]
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>
diff --git a/drivers/char/apm-emulation.c b/drivers/char/apm-emulation.c
index f4837a8..6005c5c 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)
* anything critical, chill a bit on each iteration.
*/
while (wait_event_freezable(apm_suspend_waitqueue,
- as->suspend_state == SUSPEND_DONE))
+ as->suspend_state != SUSPEND_ACKED))
msleep(10);
break;
case SUSPEND_ACKTO:
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 828 bytes --]
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: Subject: [PATCH] APM: fix deadlock in APM_IOC_SUSPEND ioctl
2012-04-01 10:19 Subject: [PATCH] APM: fix deadlock in APM_IOC_SUSPEND ioctl NeilBrown
@ 2012-04-03 1:44 ` Jiri Kosina
0 siblings, 0 replies; 2+ messages in thread
From: Jiri Kosina @ 2012-04-03 1:44 UTC (permalink / raw)
To: NeilBrown; +Cc: lkml
On Sun, 1 Apr 2012, NeilBrown wrote:
>
>
> 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>
>
> diff --git a/drivers/char/apm-emulation.c b/drivers/char/apm-emulation.c
> index f4837a8..6005c5c 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)
> * anything critical, chill a bit on each iteration.
> */
> while (wait_event_freezable(apm_suspend_waitqueue,
> - as->suspend_state == SUSPEND_DONE))
> + as->suspend_state != SUSPEND_ACKED))
> msleep(10);
> break;
> case SUSPEND_ACKTO:
Good catch Neil! I have missed this race when we were moving away from
freezer_*_count() to wait_event_freezable() here.
Applied, thanks.
--
Jiri Kosina
SUSE Labs
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2012-04-03 1:44 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-04-01 10:19 Subject: [PATCH] APM: fix deadlock in APM_IOC_SUSPEND ioctl NeilBrown
2012-04-03 1:44 ` Jiri Kosina
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.