aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/pm.h
diff options
context:
space:
mode:
authorRafael J. Wysocki <rjw@sisk.pl>2010-01-23 16:23:32 -0500
committerRafael J. Wysocki <rjw@sisk.pl>2010-02-26 14:39:09 -0500
commit5af84b82701a96be4b033aaa51d86c72e2ded061 (patch)
treeac5751c7d2e9c17bf41dabdbeba964a05f09af18 /include/linux/pm.h
parent8cc6b39ff36b4bbce2d7471da088df122b0e9033 (diff)
PM: Asynchronous suspend and resume of devices
Theoretically, the total time of system sleep transitions (suspend to RAM, hibernation) can be reduced by running suspend and resume callbacks of device drivers in parallel with each other. However, there are dependencies between devices such that we're not allowed to suspend the parent of a device before suspending the device itself. Analogously, we're not allowed to resume a device before resuming its parent. The most straightforward way to take these dependencies into accout is to start the async threads used for suspending and resuming devices at the core level, so that async_schedule() is called for each suspend and resume callback supposed to be executed asynchronously. For this purpose, introduce a new device flag, power.async_suspend, used to mark the devices whose suspend and resume callbacks are to be executed asynchronously (ie. in parallel with the main suspend/resume thread and possibly in parallel with each other) and helper function device_enable_async_suspend() allowing one to set power.async_suspend for given device (power.async_suspend is unset by default for all devices). For each device with the power.async_suspend flag set the PM core will use async_schedule() to execute its suspend and resume callbacks. The async threads started for different devices as a result of calling async_schedule() are synchronized with each other and with the main suspend/resume thread with the help of completions, in the following way: (1) There is a completion, power.completion, for each device object. (2) Each device's completion is reset before calling async_schedule() for the device or, in the case of devices with the power.async_suspend flags unset, before executing the device's suspend and resume callbacks. (3) During suspend, right before running the bus type, device type and device class suspend callbacks for the device, the PM core waits for the completions of all the device's children to be completed. (4) During resume, right before running the bus type, device type and device class resume callbacks for the device, the PM core waits for the completion of the device's parent to be completed. (5) The PM core completes power.completion for each device right after the bus type, device type and device class suspend (or resume) callbacks executed for the device have returned. Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
Diffstat (limited to 'include/linux/pm.h')
-rw-r--r--include/linux/pm.h3
1 files changed, 3 insertions, 0 deletions
diff --git a/include/linux/pm.h b/include/linux/pm.h
index 25b1eca8049d..9c16cd20fc96 100644
--- a/include/linux/pm.h
+++ b/include/linux/pm.h
@@ -26,6 +26,7 @@
26#include <linux/spinlock.h> 26#include <linux/spinlock.h>
27#include <linux/wait.h> 27#include <linux/wait.h>
28#include <linux/timer.h> 28#include <linux/timer.h>
29#include <linux/completion.h>
29 30
30/* 31/*
31 * Callbacks for platform drivers to implement. 32 * Callbacks for platform drivers to implement.
@@ -412,9 +413,11 @@ struct dev_pm_info {
412 pm_message_t power_state; 413 pm_message_t power_state;
413 unsigned int can_wakeup:1; 414 unsigned int can_wakeup:1;
414 unsigned int should_wakeup:1; 415 unsigned int should_wakeup:1;
416 unsigned async_suspend:1;
415 enum dpm_state status; /* Owned by the PM core */ 417 enum dpm_state status; /* Owned by the PM core */
416#ifdef CONFIG_PM_SLEEP 418#ifdef CONFIG_PM_SLEEP
417 struct list_head entry; 419 struct list_head entry;
420 struct completion completion;
418#endif 421#endif
419#ifdef CONFIG_PM_RUNTIME 422#ifdef CONFIG_PM_RUNTIME
420 struct timer_list suspend_timer; 423 struct timer_list suspend_timer;