diff options
-rw-r--r-- | drivers/base/power/main.c | 4 | ||||
-rw-r--r-- | drivers/base/power/power.h | 11 | ||||
-rw-r--r-- | include/linux/suspend.h | 6 | ||||
-rw-r--r-- | kernel/power/Kconfig | 4 | ||||
-rw-r--r-- | kernel/power/main.c | 76 |
5 files changed, 54 insertions, 47 deletions
diff --git a/drivers/base/power/main.c b/drivers/base/power/main.c index 6e4db96958d1..df5f41d2ec95 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 (pm_print_times) { | 169 | if (pm_print_times_enabled) { |
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 (pm_print_times) { | 184 | if (pm_print_times_enabled) { |
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 12c77b7ff8e8..eeb4bff9505c 100644 --- a/drivers/base/power/power.h +++ b/drivers/base/power/power.h | |||
@@ -85,14 +85,3 @@ 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/include/linux/suspend.h b/include/linux/suspend.h index cd83059fb592..0c808d7fa579 100644 --- a/include/linux/suspend.h +++ b/include/linux/suspend.h | |||
@@ -408,6 +408,12 @@ static inline void unlock_system_sleep(void) {} | |||
408 | 408 | ||
409 | #endif /* !CONFIG_PM_SLEEP */ | 409 | #endif /* !CONFIG_PM_SLEEP */ |
410 | 410 | ||
411 | #ifdef CONFIG_PM_SLEEP_DEBUG | ||
412 | extern bool pm_print_times_enabled; | ||
413 | #else | ||
414 | #define pm_print_times_enabled (false) | ||
415 | #endif | ||
416 | |||
411 | #ifdef CONFIG_PM_AUTOSLEEP | 417 | #ifdef CONFIG_PM_AUTOSLEEP |
412 | 418 | ||
413 | /* kernel/power/autosleep.c */ | 419 | /* kernel/power/autosleep.c */ |
diff --git a/kernel/power/Kconfig b/kernel/power/Kconfig index 8f9b4eb974e0..a70518c9d82f 100644 --- a/kernel/power/Kconfig +++ b/kernel/power/Kconfig | |||
@@ -175,7 +175,7 @@ config PM_TEST_SUSPEND | |||
175 | You probably want to have your system's RTC driver statically | 175 | You probably want to have your system's RTC driver statically |
176 | linked, ensuring that it's available when this test runs. | 176 | linked, ensuring that it's available when this test runs. |
177 | 177 | ||
178 | config CAN_PM_TRACE | 178 | config PM_SLEEP_DEBUG |
179 | def_bool y | 179 | def_bool y |
180 | depends on PM_DEBUG && PM_SLEEP | 180 | depends on PM_DEBUG && PM_SLEEP |
181 | 181 | ||
@@ -196,7 +196,7 @@ config PM_TRACE | |||
196 | 196 | ||
197 | config PM_TRACE_RTC | 197 | config PM_TRACE_RTC |
198 | bool "Suspend/resume event tracing" | 198 | bool "Suspend/resume event tracing" |
199 | depends on CAN_PM_TRACE | 199 | depends on PM_SLEEP_DEBUG |
200 | depends on X86 | 200 | depends on X86 |
201 | select PM_TRACE | 201 | select PM_TRACE |
202 | ---help--- | 202 | ---help--- |
diff --git a/kernel/power/main.c b/kernel/power/main.c index 7beb3fb3670b..f458238109cc 100644 --- a/kernel/power/main.c +++ b/kernel/power/main.c | |||
@@ -132,38 +132,6 @@ 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); | ||
167 | #endif /* CONFIG_PM_DEBUG */ | 135 | #endif /* CONFIG_PM_DEBUG */ |
168 | 136 | ||
169 | #ifdef CONFIG_DEBUG_FS | 137 | #ifdef CONFIG_DEBUG_FS |
@@ -267,6 +235,47 @@ late_initcall(pm_debugfs_init); | |||
267 | 235 | ||
268 | #endif /* CONFIG_PM_SLEEP */ | 236 | #endif /* CONFIG_PM_SLEEP */ |
269 | 237 | ||
238 | #ifdef CONFIG_PM_SLEEP_DEBUG | ||
239 | /* | ||
240 | * pm_print_times: print time taken by devices to suspend and resume. | ||
241 | * | ||
242 | * show() returns whether printing of suspend and resume times is enabled. | ||
243 | * store() accepts 0 or 1. 0 disables printing and 1 enables it. | ||
244 | */ | ||
245 | bool pm_print_times_enabled; | ||
246 | |||
247 | static ssize_t pm_print_times_show(struct kobject *kobj, | ||
248 | struct kobj_attribute *attr, char *buf) | ||
249 | { | ||
250 | return sprintf(buf, "%d\n", pm_print_times_enabled); | ||
251 | } | ||
252 | |||
253 | static ssize_t pm_print_times_store(struct kobject *kobj, | ||
254 | struct kobj_attribute *attr, | ||
255 | const char *buf, size_t n) | ||
256 | { | ||
257 | unsigned long val; | ||
258 | |||
259 | if (kstrtoul(buf, 10, &val)) | ||
260 | return -EINVAL; | ||
261 | |||
262 | if (val > 1) | ||
263 | return -EINVAL; | ||
264 | |||
265 | pm_print_times_enabled = !!val; | ||
266 | return n; | ||
267 | } | ||
268 | |||
269 | power_attr(pm_print_times); | ||
270 | |||
271 | static inline void pm_print_times_init(void) | ||
272 | { | ||
273 | pm_print_times_enabled = !!initcall_debug; | ||
274 | } | ||
275 | #else /* !CONFIG_PP_SLEEP_DEBUG */ | ||
276 | static inline void pm_print_times_init(void) {} | ||
277 | #endif /* CONFIG_PM_SLEEP_DEBUG */ | ||
278 | |||
270 | struct kobject *power_kobj; | 279 | struct kobject *power_kobj; |
271 | 280 | ||
272 | /** | 281 | /** |
@@ -562,6 +571,8 @@ static struct attribute * g[] = { | |||
562 | #endif | 571 | #endif |
563 | #ifdef CONFIG_PM_DEBUG | 572 | #ifdef CONFIG_PM_DEBUG |
564 | &pm_test_attr.attr, | 573 | &pm_test_attr.attr, |
574 | #endif | ||
575 | #ifdef CONFIG_PM_SLEEP_DEBUG | ||
565 | &pm_print_times_attr.attr, | 576 | &pm_print_times_attr.attr, |
566 | #endif | 577 | #endif |
567 | #endif | 578 | #endif |
@@ -599,6 +610,7 @@ static int __init pm_init(void) | |||
599 | error = sysfs_create_group(power_kobj, &attr_group); | 610 | error = sysfs_create_group(power_kobj, &attr_group); |
600 | if (error) | 611 | if (error) |
601 | return error; | 612 | return error; |
613 | pm_print_times_init(); | ||
602 | return pm_autosleep_init(); | 614 | return pm_autosleep_init(); |
603 | } | 615 | } |
604 | 616 | ||