PM: Dump suspend thread stack on dpm suspend timeout
authorBenoit Goby <benoit@android.com>
Fri, 21 Jan 2011 23:53:44 +0000 (15:53 -0800)
committer黄涛 <huangtao@rock-chips.com>
Tue, 25 Jan 2011 12:05:36 +0000 (20:05 +0800)
When a driver takes more than 3 seconds to suspend, dump the suspend
thread stack since BUG() might only dump the idle thread stack.

Change-Id: If854db355fdcf3b773ea20b1b5e031def6d4b114
Signed-off-by: Benoit Goby <benoit@android.com>
drivers/base/power/main.c

index 55b9e6bd4f1b8f84ed45219455b7eeeeb05bcca8..0855a10337ee00f6b8d2c526d82d3c8695c7380a 100644 (file)
@@ -46,6 +46,10 @@ static DEFINE_MUTEX(dpm_list_mtx);
 
 static void dpm_drv_timeout(unsigned long data);
 static DEFINE_TIMER(dpm_drv_wd, dpm_drv_timeout, 0, 0);
+static struct {
+       struct device *dev;
+       struct task_struct *tsk;
+} dpm_drv_wd_data;
 
 /*
  * Set once the preparation of devices for a PM transition has started, reset
@@ -446,10 +450,15 @@ static int device_resume(struct device *dev, pm_message_t state)
  */
 static void dpm_drv_timeout(unsigned long data)
 {
-       struct device *dev = (struct device *) data;
+       struct device *dev = dpm_drv_wd_data.dev;
+       struct task_struct *tsk = dpm_drv_wd_data.tsk;
 
        printk(KERN_EMERG "**** DPM device timeout: %s (%s)\n", dev_name(dev),
               (dev->driver ? dev->driver->name : "no driver"));
+
+       printk(KERN_EMERG "dpm suspend stack:\n");
+       show_stack(tsk, NULL);
+
        BUG();
 }
 
@@ -460,7 +469,9 @@ static void dpm_drv_timeout(unsigned long data)
  */
 static void dpm_drv_wdset(struct device *dev)
 {
-       dpm_drv_wd.data = (unsigned long) 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));
 }