Date: Tue, 22 Sep 2015 15:13:39 -0400 From: Jung-uk Kim <jkim@FreeBSD.org> To: Colin Percival <cperciva@freebsd.org>, Anthony Jenkins <Scoobi_doo@yahoo.com>, "freebsd-acpi@freebsd.org" <freebsd-acpi@freebsd.org> Subject: Re: disabling sleep when shutting down Message-ID: <5601A863.5070406@FreeBSD.org> In-Reply-To: <55FE5D54.1030806@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>
next in thread | previous in thread | raw e-mail | index | archive | help
This is a multi-part message in MIME format. --------------000903080601040909000901 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256 > On 09/20/2015 03:16, Colin Percival wrote: >> On 09/18/15 11:29, Anthony Jenkins wrote: >>> Is it possible for /etc/rc.shutdown to complete, but shutdown >>> not occur? If so, there should be a mechanism to restore the >>> ability to suspend. Other than that, I like it. >> >> Hmm... well, rc.shutdown runs before the system drops into >> single-user mode. Which makes me think that maybe we should be >> making the kernel call from inside init instead of from >> rc.shutdown. > > 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). Jung-uk Kim -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQEcBAEBCAAGBQJWAag9AAoJEHyflib82/FGkmQH/2LM7+pCPkvCq4ljV3UMlLbc YhvVZYr2k/j6CwjknMC0e4trF9Owgwxstnt+T8HDiGuIO553zUFPDTfgKTredv2x UHn48KgyBupnmanT1rBmQs9zg1+yVsmUGl4YgNHTaSjDz6qEB9+Jc+OTMssqBYcP 3DujmU2HWD3XDm9M5hCxyAuzh6anolb/Ev2FePezz81D7atJJoc+yF34tm3Y/Fjh KSybphHzib78qzLsXhz3Tf1LKbdZVBHFobkCTOUovB9bM5YPCT7/8HXSa/TBbvEV 1HLnj9GJX1x5WZIu4ACcsUkmJ2YT/JIwTUcZemw0BvG0usSkZL/G1fdybfgctxk= =qmkC -----END PGP SIGNATURE----- --------------000903080601040909000901 Content-Type: text/x-patch; name="init.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="init.diff" Index: sbin/init/init.c =================================================================== --- sbin/init/init.c (revision 288123) +++ sbin/init/init.c (working copy) @@ -1487,7 +1487,18 @@ static state_func_t death(void) { session_t *sp; +#if defined(__amd64__) || defined(__i386__) + size_t len; + int block, blocked; + /* Temporarily block any suspend requests. */ + len = sizeof(blocked); + block = 1; + if (sysctlbyname("debug.acpi.sleep_blocked", &blocked, &len, + &block, sizeof(block)) == -1) + blocked = 0; +#endif + /* * Also revoke the TTY here. Because runshutdown() may reopen * the TTY whose getty we're killing here, there is no guarantee @@ -1503,6 +1514,13 @@ death(void) /* Try to run the rc.shutdown script within a period of time */ runshutdown(); +#if defined(__amd64__) || defined(__i386__) + /* Unblock suspend requests. */ + if (!blocked) + sysctlbyname("debug.acpi.sleep_blocked", NULL, NULL, + &blocked, sizeof(blocked)); +#endif + return (state_func_t) death_single; } Index: sys/dev/acpica/acpi.c =================================================================== --- sys/dev/acpica/acpi.c (revision 288123) +++ sys/dev/acpica/acpi.c (working copy) @@ -292,6 +292,11 @@ static int acpi_susp_bounce; SYSCTL_INT(_debug_acpi, OID_AUTO, suspend_bounce, CTLFLAG_RW, &acpi_susp_bounce, 0, "Don't actually suspend, just test devices."); +/* Block suspend requests. */ +static int acpi_sleep_blocked; +SYSCTL_INT(_debug_acpi, OID_AUTO, sleep_blocked, CTLFLAG_RW, + &acpi_sleep_blocked, 0, "Ignore any sleep requests."); + /* * ACPI can only be loaded as a module by the loader; activating it after * system bootstrap time is not useful, and can be fatal to the system. @@ -2574,10 +2579,12 @@ 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/shutdown/suspend request is already in progress + * or suspend is explicitly disabled, just return. + */ + if (rebooting || sc->acpi_next_sstate != 0 || acpi_sleep_blocked) return (0); - } /* Wait until sleep is enabled. */ while (sc->acpi_sleep_disabled) { --------------000903080601040909000901--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?5601A863.5070406>