From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Rafael J. Wysocki" Subject: [PATCH 2/2] Freezer: Fix APM emulation breakage Date: Wed, 21 Nov 2007 23:26:33 +0100 Message-ID: <200711212326.34531.rjw@sisk.pl> References: <200711212322.02340.rjw@sisk.pl> Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-2" Content-Transfer-Encoding: quoted-printable Return-path: In-Reply-To: <200711212322.02340.rjw@sisk.pl> Content-Disposition: inline List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linux-pm-bounces@lists.linux-foundation.org Errors-To: linux-pm-bounces@lists.linux-foundation.org To: Len Brown Cc: Nigel Cunningham , pm list List-Id: linux-pm@vger.kernel.org From: Rafael J. Wysocki The APM emulation is currently broken as a result of commit 831441862956fffa17b9801db37e6ea1650b0f69 "Freezer: make kernel threads nonfreezable by default" that removed the PF_NOFREEZE annotations from apm_ioctl() without adding the appropriate freezer hooks. =A0Fix it and remove the unnecessary varia= ble flags from apm_ioctl(). Special thanks to Franck Bui-Huu for pointing out= the problem. Signed-off-by: Rafael J. Wysocki Cc: Pavel Machek Cc: Franck Bui-Huu Cc: Nigel Cunningham --- drivers/char/apm-emulation.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) Index: linux-2.6/drivers/char/apm-emulation.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- linux-2.6.orig/drivers/char/apm-emulation.c +++ linux-2.6/drivers/char/apm-emulation.c @@ -295,7 +295,6 @@ static int apm_ioctl(struct inode * inode, struct file *filp, u_int cmd, u_long arg= ) { struct apm_user *as =3D filp->private_data; - unsigned long flags; int err =3D -EINVAL; =20 if (!as->suser || !as->writer) @@ -331,10 +330,16 @@ apm_ioctl(struct inode * inode, struct f * Wait for the suspend/resume to complete. If there * are pending acknowledges, we wait here for them. */ - flags =3D current->flags; + freezer_do_not_count(); =20 wait_event(apm_suspend_waitqueue, as->suspend_state =3D=3D SUSPEND_DONE); + + /* + * Since we are waiting until the suspend is done, the + * try_to_freeze() in freezer_count() will not trigger + */ + freezer_count(); } else { as->suspend_state =3D SUSPEND_WAIT; mutex_unlock(&state_lock); @@ -362,14 +367,10 @@ apm_ioctl(struct inode * inode, struct f * Wait for the suspend/resume to complete. If there * are pending acknowledges, we wait here for them. */ - flags =3D current->flags; - - wait_event_interruptible(apm_suspend_waitqueue, + wait_event_freezable(apm_suspend_waitqueue, as->suspend_state =3D=3D SUSPEND_DONE); } =20 - current->flags =3D flags; - mutex_lock(&state_lock); err =3D as->suspend_result; as->suspend_state =3D SUSPEND_NONE;