diff options
author | Rafael J. Wysocki <rjw@sisk.pl> | 2012-04-29 16:53:22 -0400 |
---|---|---|
committer | Rafael J. Wysocki <rjw@sisk.pl> | 2012-05-01 15:25:38 -0400 |
commit | 7483b4a4d9abf9dcf1ffe6e805ead2847ec3264e (patch) | |
tree | d03af746dc3be6480580ec569e0c2d708031f0bd /include/linux/suspend.h | |
parent | 6791e36c4a40e8930e08669e60077eea6770c429 (diff) |
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>
Diffstat (limited to 'include/linux/suspend.h')
-rw-r--r-- | include/linux/suspend.h | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/include/linux/suspend.h b/include/linux/suspend.h index ac1c114c499..76b7ec7d3a8 100644 --- a/include/linux/suspend.h +++ b/include/linux/suspend.h | |||
@@ -356,7 +356,7 @@ extern int unregister_pm_notifier(struct notifier_block *nb); | |||
356 | extern bool events_check_enabled; | 356 | extern bool events_check_enabled; |
357 | 357 | ||
358 | extern bool pm_wakeup_pending(void); | 358 | extern bool pm_wakeup_pending(void); |
359 | extern bool pm_get_wakeup_count(unsigned int *count); | 359 | extern bool pm_get_wakeup_count(unsigned int *count, bool block); |
360 | extern bool pm_save_wakeup_count(unsigned int count); | 360 | extern bool pm_save_wakeup_count(unsigned int count); |
361 | 361 | ||
362 | static inline void lock_system_sleep(void) | 362 | static inline void lock_system_sleep(void) |
@@ -407,6 +407,17 @@ static inline void unlock_system_sleep(void) {} | |||
407 | 407 | ||
408 | #endif /* !CONFIG_PM_SLEEP */ | 408 | #endif /* !CONFIG_PM_SLEEP */ |
409 | 409 | ||
410 | #ifdef CONFIG_PM_AUTOSLEEP | ||
411 | |||
412 | /* kernel/power/autosleep.c */ | ||
413 | void queue_up_suspend_work(void); | ||
414 | |||
415 | #else /* !CONFIG_PM_AUTOSLEEP */ | ||
416 | |||
417 | static inline void queue_up_suspend_work(void) {} | ||
418 | |||
419 | #endif /* !CONFIG_PM_AUTOSLEEP */ | ||
420 | |||
410 | #ifdef CONFIG_ARCH_SAVE_PAGE_KEYS | 421 | #ifdef CONFIG_ARCH_SAVE_PAGE_KEYS |
411 | /* | 422 | /* |
412 | * The ARCH_SAVE_PAGE_KEYS functions can be used by an architecture | 423 | * The ARCH_SAVE_PAGE_KEYS functions can be used by an architecture |