diff options
author | Zhang Jiejing <jiejing.zhang@freescale.com> | 2010-11-22 17:14:32 +0800 |
---|---|---|
committer | Zhang Jiejing <jiejing.zhang@freescale.com> | 2010-11-24 10:22:29 +0800 |
commit | 70df9e557c59c346f257a9b21418abf20045a571 (patch) | |
tree | f005aa5752041a8389f08c21ba71f4eb81f6e8a4 /drivers | |
parent | 838705ba857ca22c7c512331b6431651ed5a303d (diff) |
ENGR00133978 PM: add time sensitive debug function to suspend & resume
There was some driver is slow on suspend/resume,
but some embeded system like eReader,Cellphone
are time sensitive,this commit will report the slow
driver on suspend/resume, the default value is 500us(0.5ms)
Also, the threshold can be change by modify
'/sys/power/device_suspend_time_threshold' to change the threshold,
it is in microsecond.
The output is like:
PM: device platform:soc-audio.2 suspend too slow, takes 606.696 msecs
PM: device platform:mxc_sdc_fb.1 suspend too slow, takes 7.708 msecs
Signed-off-by: Zhang Jiejing <jiejing.zhang@freescale.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/base/power/main.c | 39 | ||||
-rw-r--r-- | drivers/base/power/power.h | 4 |
2 files changed, 42 insertions, 1 deletions
diff --git a/drivers/base/power/main.c b/drivers/base/power/main.c index 941fcb87e52a..286fc77a5d81 100644 --- a/drivers/base/power/main.c +++ b/drivers/base/power/main.c @@ -190,6 +190,39 @@ static void initcall_debug_report(struct device *dev, ktime_t calltime, error, (unsigned long long)ktime_to_ns(delta) >> 10); } } +#ifdef CONFIG_SUSPEND_DEVICE_TIME_DEBUG +static void suspend_time_debug_start(ktime_t *start) +{ + *start = ktime_get(); +} + +static void suspend_time_debug_report(const char *name, struct device *dev, + ktime_t starttime) +{ + ktime_t rettime; + s64 usecs64; + int usecs; + + if (!dev->driver) + return; + + rettime = ktime_get(); + usecs64 = ktime_to_us(ktime_sub(rettime, starttime)); + usecs = usecs64; + if (usecs == 0) + usecs = 1; + + if (device_suspend_time_threshold + && usecs > device_suspend_time_threshold) + pr_info("PM: device %s:%s %s too slow, it takes \t %ld.%03ld msecs\n", + dev->bus->name, dev_name(dev), name, + usecs / USEC_PER_MSEC, usecs % USEC_PER_MSEC); +} +#else +static void suspend_time_debug_start(ktime_t *start) {} +static void suspend_time_debug_report(const char *name, struct device *dev, + ktime_t starttime) {} +#endif /* CONFIG_SUSPEND_DEVICE_TIME_DEBUG */ /** * dpm_wait - Wait for a PM operation to complete. @@ -227,7 +260,7 @@ static int pm_op(struct device *dev, pm_message_t state) { int error = 0; - ktime_t calltime; + ktime_t calltime, starttime; calltime = initcall_debug_start(dev); @@ -235,13 +268,17 @@ static int pm_op(struct device *dev, #ifdef CONFIG_SUSPEND case PM_EVENT_SUSPEND: if (ops->suspend) { + suspend_time_debug_start(&starttime); error = ops->suspend(dev); + suspend_time_debug_report("suspend", dev, starttime); suspend_report_result(ops->suspend, error); } break; case PM_EVENT_RESUME: if (ops->resume) { + suspend_time_debug_start(&starttime); error = ops->resume(dev); + suspend_time_debug_report("resume", dev, starttime); suspend_report_result(ops->resume, error); } break; diff --git a/drivers/base/power/power.h b/drivers/base/power/power.h index c0bd03c83b9c..354a220a4070 100644 --- a/drivers/base/power/power.h +++ b/drivers/base/power/power.h @@ -10,6 +10,10 @@ static inline void pm_runtime_remove(struct device *dev) {} #endif /* !CONFIG_PM_RUNTIME */ +#ifdef CONFIG_SUSPEND_DEVICE_TIME_DEBUG +extern int device_suspend_time_threshold; +#endif + #ifdef CONFIG_PM_SLEEP /* kernel/power/main.c */ |