From owner-freebsd-acpi@freebsd.org Wed Sep 23 17:17:02 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 5FD07A07CCE for ; Wed, 23 Sep 2015 17:17:02 +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 4E9971DB1; Wed, 23 Sep 2015 17:17:02 +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 DB2143AF1; Wed, 23 Sep 2015 17:17:01 +0000 (UTC) (envelope-from jkim@FreeBSD.org) Subject: Re: disabling sleep when shutting down To: Colin Percival , Anthony Jenkins , "freebsd-acpi@freebsd.org" References: <55FA3848.7090802@freebsd.org> <55FB233D.2080000@FreeBSD.org> <55FB48E3.20401@freebsd.org> <55FC4F13.3090603@FreeBSD.org> <55FC57F9.3050702@yahoo.com> <55FE5D54.1030806@freebsd.org> <5601A863.5070406@FreeBSD.org> <560262BF.7090107@freebsd.org> From: Jung-uk Kim X-Enigmail-Draft-Status: N1110 Message-ID: <5602DE8D.3020102@FreeBSD.org> Date: Wed, 23 Sep 2015 13:17:01 -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: <560262BF.7090107@freebsd.org> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 8bit 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: Wed, 23 Sep 2015 17:17:02 -0000 -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256 On 09/23/2015 04:28, Colin Percival wrote: > On 09/22/15 12:13, Jung-uk Kim wrote: >>> I didn't want to pollute init with arch-dependent hacks. >>> Anyway, the attached patch should do what you want (not >>> tested). >> >> Or a simpler hack with sysctl(3) instead of ioctl(2). > > Right, this is more like what I was thinking. (I can write patches > myself btw -- I was asking for help with figuring out the right > solution, not with the coding itself!) I don't doubt that. In fact, I wanted to save some electrons because you can read/write patches and "the code speaks for itself". :-) > A couple things I'm not sure about though: >> + /* Temporarily block any suspend requests. */ + len = >> sizeof(blocked); + block = 1; + if >> (sysctlbyname("debug.acpi.sleep_blocked", &blocked, &len, + >> &block, sizeof(block)) == -1) + blocked = 0; > > Wouldn't it make sense to wrap this in "if (Reboot)"? That way it > would block suspend for poweroff / halt / reboot, but not for > dropping to single-user mode. I think dropping to single user should be protected, too. Jung-uk Kim >> +#if defined(__amd64__) || defined(__i386__) + /* Unblock suspend >> requests. */ + if (!blocked) + >> sysctlbyname("debug.acpi.sleep_blocked", NULL, NULL, + >> &blocked, sizeof(blocked)); +#endif + > > And if we restrict the blocking to only happen if (Reboot), is > there any point unblocking suspend when we're about to call > reboot(2)? -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQEcBAEBCAAGBQJWAt6IAAoJEHyflib82/FGoT4H/3eoM/O/Zj80VqT1qBmYiSoa VFJM/RQ3c0Nvu+a+D0GHoD4G98QFclmqmeQiaSBl6LchgqTPllN3o5l8WTKVisM7 12iFzx5WrfVpdoB8u6l2wMp9YcIvsqPwEAbz+nvaZOHZWpSgjxcjImCoI1nKhHpz SPF2jkjdTwvPvpDHgfT1GALfDXFPtFGyDZeEin5ntkTm9mJOyxd0v3Jj4iFSRzgc D1KsTRfIjsygiNHnTvTfuKSOspU4yhlWr+NS3b3hnXpPgOmBhdS8UYjOjVCt03eE SRfZ9FPqMI8rX8l8AXchxKHpRSkngqGTpUpMdNooqqyNfqGoHwvqQ2nI4NStHsc= =wzTq -----END PGP SIGNATURE-----