-----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-----
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) {
_______________________________________________
freebsd-acpi@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-acpi
To unsubscribe, send any mail to "freebsd-acpi-unsubscr...@freebsd.org"

Reply via email to