From owner-freebsd-acpi@freebsd.org Thu Sep 17 20:31:58 2015 Return-Path: Delivered-To: freebsd-acpi@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 9440A9CEC82 for ; Thu, 17 Sep 2015 20:31:58 +0000 (UTC) (envelope-from jkim@FreeBSD.org) Received: from mx2.freebsd.org (mx2.freebsd.org [8.8.178.116]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mx2.freebsd.org", Issuer "Gandi Standard SSL CA 2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 834901FF9; Thu, 17 Sep 2015 20:31:58 +0000 (UTC) (envelope-from jkim@FreeBSD.org) Received: from hammer.pct.niksun.com (freefall.freebsd.org [IPv6:2001:1900:2254:206c::16:87]) by mx2.freebsd.org (Postfix) with ESMTP id 2A89517BF; Thu, 17 Sep 2015 20:31:58 +0000 (UTC) (envelope-from jkim@FreeBSD.org) Subject: Re: disabling sleep when shutting down To: Colin Percival , "freebsd-acpi@freebsd.org" References: <55FA3848.7090802@freebsd.org> From: Jung-uk Kim Message-ID: <55FB233D.2080000@FreeBSD.org> Date: Thu, 17 Sep 2015 16:31:57 -0400 User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <55FA3848.7090802@freebsd.org> Content-Type: multipart/mixed; boundary="------------040101010504090901040306" X-BeenThere: freebsd-acpi@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: ACPI and power management development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 17 Sep 2015 20:31:58 -0000 This is a multi-part message in MIME format. --------------040101010504090901040306 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256 On 09/16/2015 23:49, Colin Percival wrote: > Hi ACPI people, > > I ran into an interesting glitch recently: I told my laptop to shut > down, then closed the lid... and it promptly went into S3. When I > opened the lid a couple days later, it resumed... and then finished > the shutdown which it had started 2 days earlier. Meanwhile with > two days of sitting in S3 instead of S5, the battery had almost > completely drained. > > The obvious answer here is to disable Suspend if we're in the > shutdown path. My first thought was to make rc.suspend slightly > smarter, but that isn't good enough since there's a 10 second > timeout after which the suspend will happen even if rc.suspend > doesn't send the expected acknowledgment. So I think we need to > get the kernel ACPI bits to disable Suspend. > > It looks to me like adding a sysctl to dev/acpica/acpi.c and > checking it in acpi_ReqSleepState would work; then we just need a > line in /etc/rc.shutdown to set the sysctl. But ACPI code scares > me, so I figured I should check with you guys first... am I missing > anything? Please try the attached patch. Jung-uk Kim -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQEcBAEBCAAGBQJV+yM4AAoJEHyflib82/FGxSUH/3Aw2bk+fDxyLIZHxidyxDRo jbNwkm8CIPGOOshQy8R/nMULPnCoVkLAuXA9O7rNK4G+PB96FoHHUEp/UoDnZfDF exINmGs6DM0scx2ioVtXM50+lC1SzMfFtb5VaS5t7lAyLwYFtE2bQaUWINethUW7 WpsJ5eyyyoMwTTnRxIQcaYC9I+8oqjC4W6KOO1VeTxaj8kvnacYtCxoXbEU7NHHX 9IprjpopHz9tNlTWuh+gX2SsgaRD7PhWSAekNcN1okYa6Jj1QGAiBIsNvc0GLmUZ hYv4GIPjxG1ZwYfu9HDCXp8Yiz3i44GIpC6EKuO2y0WO36DTM4vUYKK0OFjNdbw= =PVmk -----END PGP SIGNATURE----- --------------040101010504090901040306 Content-Type: text/x-patch; name="acpi.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="acpi.diff" Index: sys/dev/acpica/acpi.c =================================================================== --- sys/dev/acpica/acpi.c (revision 287922) +++ sys/dev/acpica/acpi.c (working copy) @@ -2574,10 +2574,9 @@ acpi_ReqSleepState(struct acpi_softc *sc, int stat if (!acpi_sleep_states[state]) return (EOPNOTSUPP); - /* If a suspend request is already in progress, just return. */ - if (sc->acpi_next_sstate != 0) { + /* If a reboot or suspend request is already in progress, just return. */ + if (rebooting || sc->acpi_next_sstate != 0) return (0); - } /* Wait until sleep is enabled. */ while (sc->acpi_sleep_disabled) { --------------040101010504090901040306--