diff options
-rw-r--r-- | Documentation/ABI/testing/sysfs-power | 13 | ||||
-rw-r--r-- | drivers/base/power/main.c | 4 | ||||
-rw-r--r-- | drivers/base/power/power.h | 11 | ||||
-rw-r--r-- | kernel/power/main.c | 33 |
4 files changed, 59 insertions, 2 deletions
diff --git a/Documentation/ABI/testing/sysfs-power b/Documentation/ABI/testing/sysfs-power index 31725ffeeb3a..217772615d02 100644 --- a/Documentation/ABI/testing/sysfs-power +++ b/Documentation/ABI/testing/sysfs-power | |||
@@ -231,3 +231,16 @@ Description: | |||
231 | Reads from this file return a string consisting of the names of | 231 | Reads from this file return a string consisting of the names of |
232 | wakeup sources created with the help of /sys/power/wake_lock | 232 | wakeup sources created with the help of /sys/power/wake_lock |
233 | that are inactive at the moment, separated with spaces. | 233 | that are inactive at the moment, separated with spaces. |
234 | |||
235 | What: /sys/power/pm_print_times | ||
236 | Date: May 2012 | ||
237 | Contact: Sameer Nanda <snanda@chromium.org> | ||
238 | Description: | ||
239 | The /sys/power/pm_print_times file allows user space to | ||
240 | control whether the time taken by devices to suspend and | ||
241 | resume is printed. These prints are useful for hunting down | ||
242 | devices that take too long to suspend or resume. | ||
243 | |||
244 | Writing a "1" enables this printing while writing a "0" | ||
245 | disables it. The default value is "0". Reading from this file | ||
246 | will display the current value. | ||
diff --git a/drivers/base/power/main.c b/drivers/base/power/main.c index 9cb845e49334..6e4db96958d1 100644 --- a/drivers/base/power/main.c +++ b/drivers/base/power/main.c | |||
@@ -166,7 +166,7 @@ static ktime_t initcall_debug_start(struct device *dev) | |||
166 | { | 166 | { |
167 | ktime_t calltime = ktime_set(0, 0); | 167 | ktime_t calltime = ktime_set(0, 0); |
168 | 168 | ||
169 | if (initcall_debug) { | 169 | if (pm_print_times) { |
170 | pr_info("calling %s+ @ %i, parent: %s\n", | 170 | pr_info("calling %s+ @ %i, parent: %s\n", |
171 | dev_name(dev), task_pid_nr(current), | 171 | dev_name(dev), task_pid_nr(current), |
172 | dev->parent ? dev_name(dev->parent) : "none"); | 172 | dev->parent ? dev_name(dev->parent) : "none"); |
@@ -181,7 +181,7 @@ static void initcall_debug_report(struct device *dev, ktime_t calltime, | |||
181 | { | 181 | { |
182 | ktime_t delta, rettime; | 182 | ktime_t delta, rettime; |
183 | 183 | ||
184 | if (initcall_debug) { | 184 | if (pm_print_times) { |
185 | rettime = ktime_get(); | 185 | rettime = ktime_get(); |
186 | delta = ktime_sub(rettime, calltime); | 186 | delta = ktime_sub(rettime, calltime); |
187 | pr_info("call %s+ returned %d after %Ld usecs\n", dev_name(dev), | 187 | pr_info("call %s+ returned %d after %Ld usecs\n", dev_name(dev), |
diff --git a/drivers/base/power/power.h b/drivers/base/power/power.h index eeb4bff9505c..12c77b7ff8e8 100644 --- a/drivers/base/power/power.h +++ b/drivers/base/power/power.h | |||
@@ -85,3 +85,14 @@ static inline int pm_qos_sysfs_add(struct device *dev) { return 0; } | |||
85 | static inline void pm_qos_sysfs_remove(struct device *dev) {} | 85 | static inline void pm_qos_sysfs_remove(struct device *dev) {} |
86 | 86 | ||
87 | #endif | 87 | #endif |
88 | |||
89 | #ifdef CONFIG_PM_DEBUG | ||
90 | |||
91 | extern int pm_print_times_enabled; | ||
92 | #define pm_print_times (initcall_debug || pm_print_times_enabled) | ||
93 | |||
94 | #else /* CONFIG_PM_DEBUG */ | ||
95 | |||
96 | #define pm_print_times initcall_debug | ||
97 | |||
98 | #endif /* CONFIG_PM_DEBUG */ | ||
diff --git a/kernel/power/main.c b/kernel/power/main.c index 428f8a034e96..7beb3fb3670b 100644 --- a/kernel/power/main.c +++ b/kernel/power/main.c | |||
@@ -132,6 +132,38 @@ static ssize_t pm_test_store(struct kobject *kobj, struct kobj_attribute *attr, | |||
132 | } | 132 | } |
133 | 133 | ||
134 | power_attr(pm_test); | 134 | power_attr(pm_test); |
135 | |||
136 | /* | ||
137 | * pm_print_times: print time taken by devices to suspend and resume. | ||
138 | * | ||
139 | * show() returns whether printing of suspend and resume times is enabled. | ||
140 | * store() accepts 0 or 1. 0 disables printing and 1 enables it. | ||
141 | */ | ||
142 | int pm_print_times_enabled; | ||
143 | |||
144 | static ssize_t pm_print_times_show(struct kobject *kobj, | ||
145 | struct kobj_attribute *attr, char *buf) | ||
146 | { | ||
147 | return sprintf(buf, "%d\n", pm_print_times_enabled); | ||
148 | } | ||
149 | |||
150 | static ssize_t pm_print_times_store(struct kobject *kobj, | ||
151 | struct kobj_attribute *attr, | ||
152 | const char *buf, size_t n) | ||
153 | { | ||
154 | unsigned long val; | ||
155 | |||
156 | if (kstrtoul(buf, 10, &val)) | ||
157 | return -EINVAL; | ||
158 | |||
159 | if (val > 1) | ||
160 | return -EINVAL; | ||
161 | |||
162 | pm_print_times_enabled = val; | ||
163 | return n; | ||
164 | } | ||
165 | |||
166 | power_attr(pm_print_times); | ||
135 | #endif /* CONFIG_PM_DEBUG */ | 167 | #endif /* CONFIG_PM_DEBUG */ |
136 | 168 | ||
137 | #ifdef CONFIG_DEBUG_FS | 169 | #ifdef CONFIG_DEBUG_FS |
@@ -530,6 +562,7 @@ static struct attribute * g[] = { | |||
530 | #endif | 562 | #endif |
531 | #ifdef CONFIG_PM_DEBUG | 563 | #ifdef CONFIG_PM_DEBUG |
532 | &pm_test_attr.attr, | 564 | &pm_test_attr.attr, |
565 | &pm_print_times_attr.attr, | ||
533 | #endif | 566 | #endif |
534 | #endif | 567 | #endif |
535 | NULL, | 568 | NULL, |