PM / Sleep: Implement opportunistic sleep, v2
authorRafael J. Wysocki <rjw@sisk.pl>
Sun, 29 Apr 2012 20:53:22 +0000 (22:53 +0200)
committerVarun Wadekar <vwadekar@nvidia.com>
Mon, 23 Jul 2012 08:37:51 +0000 (13:37 +0530)
commitc968c1d9df7e9d16aafa57607ddabe2b92e17933
treea5f6fa69d49d651478d7d7e45a235ca50e866338
parent88c76bf78fe8e5bedc035e3ff88b63d5b5883193
PM / Sleep: Implement opportunistic sleep, v2

Introduce a mechanism by which the kernel can trigger global
transitions to a sleep state chosen by user space if there are no
active wakeup sources.

It consists of a new sysfs attribute, /sys/power/autosleep, that
can be written one of the strings returned by reads from
/sys/power/state, an ordered workqueue and a work item carrying out
the "suspend" operations.  If a string representing the system's
sleep state is written to /sys/power/autosleep, the work item
triggering transitions to that state is queued up and it requeues
itself after every execution until user space writes "off" to
/sys/power/autosleep.

That work item enables the detection of wakeup events using the
functions already defined in drivers/base/power/wakeup.c (with one
small modification) and calls either pm_suspend(), or hibernate() to
put the system into a sleep state.  If a wakeup event is reported
while the transition is in progress, it will abort the transition and
the "system suspend" work item will be queued up again.

Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Reviewed-by: NeilBrown <neilb@suse.de>
Documentation/ABI/testing/sysfs-power
drivers/base/power/wakeup.c
include/linux/suspend.h
kernel/power/Kconfig
kernel/power/Makefile
kernel/power/autosleep.c [new file with mode: 0644]
kernel/power/main.c
kernel/power/power.h