From owner-freebsd-bugs@FreeBSD.ORG Fri Sep 14 12:20:03 2007 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id AC7AE16A41A for ; Fri, 14 Sep 2007 12:20:03 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id 7FE9813C4CA for ; Fri, 14 Sep 2007 12:20:03 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.14.1/8.14.1) with ESMTP id l8ECK3BT081702 for ; Fri, 14 Sep 2007 12:20:03 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.1/8.14.1/Submit) id l8ECK3VD081701; Fri, 14 Sep 2007 12:20:03 GMT (envelope-from gnats) Resent-Date: Fri, 14 Sep 2007 12:20:03 GMT Resent-Message-Id: <200709141220.l8ECK3VD081701@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Marko Zec Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id C596A16A417 for ; Fri, 14 Sep 2007 12:18:26 +0000 (UTC) (envelope-from nobody@FreeBSD.org) Received: from www.freebsd.org (www.freebsd.org [IPv6:2001:4f8:fff6::21]) by mx1.freebsd.org (Postfix) with ESMTP id C72D813C45D for ; Fri, 14 Sep 2007 12:18:26 +0000 (UTC) (envelope-from nobody@FreeBSD.org) Received: from www.freebsd.org (localhost [127.0.0.1]) by www.freebsd.org (8.14.1/8.14.1) with ESMTP id l8ECIPd1070188 for ; Fri, 14 Sep 2007 12:18:25 GMT (envelope-from nobody@www.freebsd.org) Received: (from nobody@localhost) by www.freebsd.org (8.14.1/8.14.1/Submit) id l8ECIP2h070187; Fri, 14 Sep 2007 12:18:25 GMT (envelope-from nobody) Message-Id: <200709141218.l8ECIP2h070187@www.freebsd.org> Date: Fri, 14 Sep 2007 12:18:25 GMT From: Marko Zec To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-3.1 Cc: Subject: kern/116347: APM does not suspend USB devices X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 Sep 2007 12:20:03 -0000 >Number: 116347 >Category: kern >Synopsis: APM does not suspend USB devices >Confidential: no >Severity: non-critical >Priority: medium >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Fri Sep 14 12:20:03 GMT 2007 >Closed-Date: >Last-Modified: >Originator: Marko Zec >Release: 7.0-CURRENT >Organization: U. of Zagreb >Environment: FreeBSD tpx32.icir.org 7.0-CURRENT FreeBSD 7.0-CURRENT #6: Fri Sep 14 09:32:49 CEST 2007 marko@tpx32.icir.org:/u/marko/p4/vimage/src/sys/i386/compile/TPX32V i386 >Description: Any USB device attached to a machine running APM instead of ACPI won't survive a suspend/resume cycle. >How-To-Repeat: Boot with ACPI disabled / APM enabled, plug in a USB device, suspend, resume, done. >Fix: See the patch attached. Patch attached with submission follows: --- ../head/src/sys/i386/bios/apm.c 2007-08-31 03:47:17.000000000 +0200 +++ src/sys/i386/bios/apm.c 2007-09-14 10:20:46.000000000 +0200 @@ -485,7 +485,13 @@ apm_do_suspend(void) apm_op_inprog = 0; sc->suspends = sc->suspend_countdown = 0; + /* + * Be sure to hold Giant across DEVICE_SUSPEND/RESUME since + * non-MPSAFE drivers need this. + */ + mtx_lock(&Giant); error = DEVICE_SUSPEND(root_bus); + mtx_unlock(&Giant); if (error) return; @@ -496,7 +502,9 @@ apm_do_suspend(void) } else { /* Failure, 'resume' the system again */ apm_execute_hook(hook[APM_HOOK_RESUME]); + mtx_lock(&Giant); DEVICE_RESUME(root_bus); + mtx_unlock(&Giant); } return; } @@ -602,7 +610,9 @@ apm_resume(void) sc->suspending = 0; apm_execute_hook(hook[APM_HOOK_RESUME]); + mtx_lock(&Giant); DEVICE_RESUME(root_bus); + mtx_unlock(&Giant); return; } >Release-Note: >Audit-Trail: >Unformatted: