summaryrefslogtreecommitdiffstats
path: root/etc
diff options
context:
space:
mode:
authornjl <njl@FreeBSD.org>2007-06-21 22:50:37 +0000
committernjl <njl@FreeBSD.org>2007-06-21 22:50:37 +0000
commit79d6390885127f514c12c1f7aeb8e0272fa73621 (patch)
tree6d3282ab53bb6c9d24fd93319d317dd8d32ef41e /etc
parent4db323384d511bec08394e226ffbc340bcadbbf0 (diff)
downloadFreeBSD-src-79d6390885127f514c12c1f7aeb8e0272fa73621.zip
FreeBSD-src-79d6390885127f514c12c1f7aeb8e0272fa73621.tar.gz
Update the suspend/resume user API while maintaining backwards compat.
Improvements: * /etc/rc.suspend,rc.resume are always run, no matter the source of the suspend request (user or kernel, apm or acpi) * suspend now requires positive user acknowledgement. If a user program wants to cancel the suspend, they can. If one of the user programs hangs or doesn't respond within 10 seconds, the system suspends anyway. * /dev/apm is clonable, allowing multiple listeners for suspend events. In the future, xorg-server can use this to be informed about suspend even if there are other listeners (i.e. apmd). Changes: * Two new ACPI ioctls: REQSLPSTATE and ACKSLPSTATE. Request begins the process of suspending by notifying all listeners. acpi is monitored by devd(8) and /dev/apm listener(s) are also counted. Users register their approval or disapproval via Ack. If anyone disapproves, suspend is vetoed. * Old user programs or kernel modules that used SETSLPSTATE continue to work. A message is printed once that this interface is deprecated. * acpiconf gains the -k flag to ack the suspend request. This flag is undocumented on purpose since it's only used by /etc/rc.suspend. It is not intended to be a permanent change and will be removed once a better power API is implemented. * S5 (power off) is no longer supported via acpiconf -s 5 or apm -z/-Z. This restores previous behavior of halt/shutdown -p being the interface. * Miscellaneous improvements to error reporting Approved by: re
Diffstat (limited to 'etc')
-rw-r--r--etc/devd.conf14
-rwxr-xr-xetc/rc.resume12
-rwxr-xr-xetc/rc.suspend15
3 files changed, 32 insertions, 9 deletions
diff --git a/etc/devd.conf b/etc/devd.conf
index 59ac15f..94fbb79 100644
--- a/etc/devd.conf
+++ b/etc/devd.conf
@@ -239,6 +239,19 @@ notify 10 {
action "logger -p kern.warn 'ZFS: checksum mismatch, zpool=$pool path=$vdev_path offset=$zio_offset size=$zio_size'";
};
+# User requested suspend, so perform preparation steps and then execute
+# the actual suspend process.
+notify 10 {
+ match "system" "ACPI";
+ match "subsystem" "Suspend";
+ action "/etc/rc.suspend acpi $notify";
+};
+notify 10 {
+ match "system" "ACPI";
+ match "subsystem" "Resume";
+ action "/etc/rc.resume acpi $notify";
+};
+
/* EXAMPLES TO END OF FILE
# The following might be an example of something that a vendor might
@@ -277,6 +290,7 @@ detach 10 {
# Button: Button pressed (0 for power, 1 for sleep)
# CMBAT: ACPI battery events
# Lid: Lid state (0 is closed, 1 is open)
+# Suspend, Resume: Suspend and resume notification
# Thermal: ACPI thermal zone events
#
# This example calls a script when the AC state changes, passing the
diff --git a/etc/rc.resume b/etc/rc.resume
index 4e133e0..54f49c5 100755
--- a/etc/rc.resume
+++ b/etc/rc.resume
@@ -30,7 +30,7 @@
# sample run command file for APM Resume Event
if [ $# -ne 2 ]; then
- echo "Usage: $0 [apm|acpi] [standby,suspend|1-5]"
+ echo "Usage: $0 [apm|acpi] [standby,suspend|1-4]"
exit 1
fi
@@ -48,9 +48,13 @@ fi
# pccardq | awk -F '~' '$5 == "inactive" \
# { printf("pccardc power %d 1", $1); }' | sh
-# UHCI has trouble resuming so we just load/unload it. You
-# should add any other kernel modules you want reloaded here.
-# kldload usb
+# If a device driver has problems resuming, try unloading it before
+# suspend and reloading it on resume. Example:
+# kldunload usb
+
+# wpa_supplicant(8) doesn't seem to reassociate during resume. Uncomment
+# the following to signal it to reassociate.
+# /usr/sbin/wpa_cli reassociate
logger -t $subsystem resumed at `date +'%Y%m%d %H:%M:%S'`
sync && sync && sync
diff --git a/etc/rc.suspend b/etc/rc.suspend
index 26fe198..4028b32 100755
--- a/etc/rc.suspend
+++ b/etc/rc.suspend
@@ -30,7 +30,7 @@
# sample run command file for APM Suspend Event
if [ $# -ne 2 ]; then
- echo "Usage: $0 [apm|acpi] [standby,suspend|1-5]"
+ echo "Usage: $0 [apm|acpi] [standby,suspend|1-4]"
exit 1
fi
@@ -48,15 +48,20 @@ echo $$ 2> /dev/null > /var/run/rc.suspend.pid
# pccardq | awk -F '~' '$5 == "filled" && $4 ~ /sio/ \
# { printf("pccardc power %d 0", $1); }' | sh
-# UHCI has trouble resuming so we just load/unload it. You
-# should add any other kernel modules you want unloaded here.
+# If a device driver has problems suspending, try unloading it before
+# suspend and reloading it on resume. Example:
# kldunload usb
logger -t $subsystem suspend at `date +'%Y%m%d %H:%M:%S'`
sync && sync && sync
-[ $subsystem = "apm" ] && sleep 3
+sleep 3
rm -f /var/run/rc.suspend.pid
-[ $subsystem = "apm" ] && zzz
+if [ $subsystem = "apm" ]; then
+ /usr/sbin/zzz
+else
+ # Notify the kernel to continue the suspend process
+ /usr/sbin/acpiconf -k 0
+fi
exit 0
OpenPOWER on IntegriCloud