From: NeilBrown <neilb@suse.de>
To: Jiri Kosina <jkosina@suse.cz>
Cc: lkml <linux-kernel@vger.kernel.org>
Subject: Subject: [PATCH] APM: fix deadlock in APM_IOC_SUSPEND ioctl
Date: Sun, 1 Apr 2012 20:19:30 +1000 [thread overview]
Message-ID: <20120401201930.01202cd2@notabene.brown> (raw)
[-- 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 --]
next reply other threads:[~2012-04-01 10:19 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-04-01 10:19 NeilBrown [this message]
2012-04-03 1:44 ` Subject: [PATCH] APM: fix deadlock in APM_IOC_SUSPEND ioctl Jiri Kosina
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20120401201930.01202cd2@notabene.brown \
--to=neilb@suse.de \
--cc=jkosina@suse.cz \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.