Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 312723
b: refs/heads/master
c: 4b7760b
h: refs/heads/master
i:
  312721: 2ca76f3
  312719: 645d8f2
v: v3
  • Loading branch information
Sameer Nanda authored and Rafael J. Wysocki committed Jul 1, 2012
1 parent 42cbd14 commit 821cec9
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 3 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 443772d408a25af62498793f6f805ce3c559309a
refs/heads/master: 4b7760ba0dd3319f66886ab2335a0fbecdbc808a
13 changes: 13 additions & 0 deletions trunk/Documentation/ABI/testing/sysfs-power
Original file line number Diff line number Diff line change
Expand Up @@ -231,3 +231,16 @@ Description:
Reads from this file return a string consisting of the names of
wakeup sources created with the help of /sys/power/wake_lock
that are inactive at the moment, separated with spaces.

What: /sys/power/pm_print_times
Date: May 2012
Contact: Sameer Nanda <snanda@chromium.org>
Description:
The /sys/power/pm_print_times file allows user space to
control whether the time taken by devices to suspend and
resume is printed. These prints are useful for hunting down
devices that take too long to suspend or resume.

Writing a "1" enables this printing while writing a "0"
disables it. The default value is "0". Reading from this file
will display the current value.
4 changes: 2 additions & 2 deletions trunk/drivers/base/power/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ static ktime_t initcall_debug_start(struct device *dev)
{
ktime_t calltime = ktime_set(0, 0);

if (initcall_debug) {
if (pm_print_times) {
pr_info("calling %s+ @ %i, parent: %s\n",
dev_name(dev), task_pid_nr(current),
dev->parent ? dev_name(dev->parent) : "none");
Expand All @@ -181,7 +181,7 @@ static void initcall_debug_report(struct device *dev, ktime_t calltime,
{
ktime_t delta, rettime;

if (initcall_debug) {
if (pm_print_times) {
rettime = ktime_get();
delta = ktime_sub(rettime, calltime);
pr_info("call %s+ returned %d after %Ld usecs\n", dev_name(dev),
Expand Down
11 changes: 11 additions & 0 deletions trunk/drivers/base/power/power.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,3 +85,14 @@ static inline int pm_qos_sysfs_add(struct device *dev) { return 0; }
static inline void pm_qos_sysfs_remove(struct device *dev) {}

#endif

#ifdef CONFIG_PM_DEBUG

extern int pm_print_times_enabled;
#define pm_print_times (initcall_debug || pm_print_times_enabled)

#else /* CONFIG_PM_DEBUG */

#define pm_print_times initcall_debug

#endif /* CONFIG_PM_DEBUG */
33 changes: 33 additions & 0 deletions trunk/kernel/power/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,38 @@ static ssize_t pm_test_store(struct kobject *kobj, struct kobj_attribute *attr,
}

power_attr(pm_test);

/*
* pm_print_times: print time taken by devices to suspend and resume.
*
* show() returns whether printing of suspend and resume times is enabled.
* store() accepts 0 or 1. 0 disables printing and 1 enables it.
*/
int pm_print_times_enabled;

static ssize_t pm_print_times_show(struct kobject *kobj,
struct kobj_attribute *attr, char *buf)
{
return sprintf(buf, "%d\n", pm_print_times_enabled);
}

static ssize_t pm_print_times_store(struct kobject *kobj,
struct kobj_attribute *attr,
const char *buf, size_t n)
{
unsigned long val;

if (kstrtoul(buf, 10, &val))
return -EINVAL;

if (val > 1)
return -EINVAL;

pm_print_times_enabled = val;
return n;
}

power_attr(pm_print_times);
#endif /* CONFIG_PM_DEBUG */

#ifdef CONFIG_DEBUG_FS
Expand Down Expand Up @@ -530,6 +562,7 @@ static struct attribute * g[] = {
#endif
#ifdef CONFIG_PM_DEBUG
&pm_test_attr.attr,
&pm_print_times_attr.attr,
#endif
#endif
NULL,
Expand Down

0 comments on commit 821cec9

Please sign in to comment.