summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenoit Goby <benoit@android.com>2011-12-02 14:04:46 +0800
committerAndy Green <andy.green@linaro.org>2011-12-02 14:04:46 +0800
commit3adc0e2b1bd3eeda1a7d98464745581a258f9eca (patch)
treebe22611ab29f2f4d3510193a01c9a497e187fce5
parentade914067518ad7b5760415a8bd28618367352f7 (diff)
PM: Change dpm watchdog to support async suspend
Exclude from the watchdog the time spent waiting for children that are resumed asynchronously and time every devices, whether or not they resumed synchronously. Change-Id: I84209dfd5df72842e045096c906fd61e20e6d183 Signed-off-by: Benoit Goby <benoit@android.com>
-rw-r--r--drivers/base/power/main.c47
1 files changed, 19 insertions, 28 deletions
diff --git a/drivers/base/power/main.c b/drivers/base/power/main.c
index 4e365ce9ed0..193e9bcbe70 100644
--- a/drivers/base/power/main.c
+++ b/drivers/base/power/main.c
@@ -53,11 +53,10 @@ static DEFINE_MUTEX(dpm_list_mtx);
static pm_message_t pm_transition;
static void dpm_drv_timeout(unsigned long data);
-static DEFINE_TIMER(dpm_drv_wd, dpm_drv_timeout, 0, 0);
-static struct {
+struct dpm_drv_wd_data {
struct device *dev;
struct task_struct *tsk;
-} dpm_drv_wd_data;
+};
static int async_error;
@@ -619,8 +618,9 @@ static bool is_async(struct device *dev)
*/
static void dpm_drv_timeout(unsigned long data)
{
- struct device *dev = dpm_drv_wd_data.dev;
- struct task_struct *tsk = dpm_drv_wd_data.tsk;
+ struct dpm_drv_wd_data *wd_data = (void *)data;
+ struct device *dev = wd_data->dev;
+ struct task_struct *tsk = wd_data->tsk;
printk(KERN_EMERG "**** DPM device timeout: %s (%s)\n", dev_name(dev),
(dev->driver ? dev->driver->name : "no driver"));
@@ -632,29 +632,6 @@ static void dpm_drv_timeout(unsigned long data)
}
/**
- * dpm_drv_wdset - Sets up driver suspend/resume watchdog timer.
- * @dev: struct device which we're guarding.
- *
- */
-static void dpm_drv_wdset(struct device *dev)
-{
- dpm_drv_wd_data.dev = dev;
- dpm_drv_wd_data.tsk = get_current();
- dpm_drv_wd.data = (unsigned long) &dpm_drv_wd_data;
- mod_timer(&dpm_drv_wd, jiffies + (HZ * 3));
-}
-
-/**
- * dpm_drv_wdclr - clears driver suspend/resume watchdog timer.
- * @dev: struct device which we're no longer guarding.
- *
- */
-static void dpm_drv_wdclr(struct device *dev)
-{
- del_timer_sync(&dpm_drv_wd);
-}
-
-/**
* dpm_resume - Execute "resume" callbacks for non-sysdev devices.
* @state: PM transition of the system being carried out.
*
@@ -919,6 +896,8 @@ static int legacy_suspend(struct device *dev, pm_message_t state,
static int __device_suspend(struct device *dev, pm_message_t state, bool async)
{
int error = 0;
+ struct timer_list timer;
+ struct dpm_drv_wd_data data;
dpm_wait_for_children(dev, async);
@@ -935,6 +914,14 @@ static int __device_suspend(struct device *dev, pm_message_t state, bool async)
return 0;
}
+ data.dev = dev;
+ data.tsk = get_current();
+ init_timer_on_stack(&timer);
+ timer.expires = jiffies + HZ * 3;
+ timer.function = dpm_drv_timeout;
+ timer.data = (unsigned long)&data;
+ add_timer(&timer);
+
device_lock(dev);
if (dev->pm_domain) {
@@ -980,6 +967,10 @@ static int __device_suspend(struct device *dev, pm_message_t state, bool async)
}
device_unlock(dev);
+
+ del_timer_sync(&timer);
+ destroy_timer_on_stack(&timer);
+
complete_all(&dev->power.completion);
if (error) {