summaryrefslogtreecommitdiffstats
path: root/sys
diff options
context:
space:
mode:
authorcperciva <cperciva@FreeBSD.org>2015-10-01 10:52:26 +0000
committercperciva <cperciva@FreeBSD.org>2015-10-01 10:52:26 +0000
commit8e136c4370617d6cb5580f3c9e51ae1c58f7edbe (patch)
tree7989543c22e5c121e120ae359b7126a9764569f1 /sys
parent10e70b971f2cc53a76bf17bffc580cab730750ed (diff)
downloadFreeBSD-src-8e136c4370617d6cb5580f3c9e51ae1c58f7edbe.zip
FreeBSD-src-8e136c4370617d6cb5580f3c9e51ae1c58f7edbe.tar.gz
Disable suspend when we're shutting down. This solves the "tell FreeBSD
to shut down; close laptop lid" scenario which otherwise tended to end with a laptop overheating or the battery dying. The implementation uses a new sysctl, kern.suspend_blocked; init(8) sets this while rc.suspend runs, and the ACPI sleep code ignores requests while the sysctl is set. Discussed on: freebsd-acpi (35 emails) MFC after: 1 week
Diffstat (limited to 'sys')
-rw-r--r--sys/dev/acpica/acpi.c7
-rw-r--r--sys/kern/kern_shutdown.c4
-rw-r--r--sys/sys/systm.h1
3 files changed, 10 insertions, 2 deletions
diff --git a/sys/dev/acpica/acpi.c b/sys/dev/acpica/acpi.c
index 92f1292..0593235 100644
--- a/sys/dev/acpica/acpi.c
+++ b/sys/dev/acpica/acpi.c
@@ -2574,8 +2574,11 @@ acpi_ReqSleepState(struct acpi_softc *sc, int state)
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 blocked due to an upcoming shutdown, just return.
+ */
+ if (rebooting || sc->acpi_next_sstate != 0 || suspend_blocked) {
return (0);
}
diff --git a/sys/kern/kern_shutdown.c b/sys/kern/kern_shutdown.c
index 29ea693..87e7d63 100644
--- a/sys/kern/kern_shutdown.c
+++ b/sys/kern/kern_shutdown.c
@@ -137,6 +137,10 @@ static int show_busybufs = 1;
SYSCTL_INT(_kern_shutdown, OID_AUTO, show_busybufs, CTLFLAG_RW,
&show_busybufs, 0, "");
+int suspend_blocked = 0;
+SYSCTL_INT(_kern, OID_AUTO, suspend_blocked, CTLFLAG_RW,
+ &suspend_blocked, 0, "Block suspend due to a pending shutdown");
+
/*
* Variable panicstr contains argument to first call to panic; used as flag
* to indicate that the kernel has already called panic.
diff --git a/sys/sys/systm.h b/sys/sys/systm.h
index 592112a..6c68802 100644
--- a/sys/sys/systm.h
+++ b/sys/sys/systm.h
@@ -46,6 +46,7 @@
#include <sys/stdint.h> /* for people using printf mainly */
extern int cold; /* nonzero if we are doing a cold boot */
+extern int suspend_blocked; /* block suspend due to pending shutdown */
extern int rebooting; /* kern_reboot() has been called. */
extern const char *panicstr; /* panic message */
extern char version[]; /* system version */
OpenPOWER on IntegriCloud