Commit b2df1d4f8b95d9d1e3f064cef02fc5c5116b05cf
1 parent
4b7760ba0d
Exists in
smarc-l5.0.0_1.0.0-ga
and in
5 other branches
PM / Sleep: Separate printing suspend times from initcall_debug
Change the behavior of the newly introduced /sys/power/pm_print_times attribute so that its initial value depends on initcall_debug, but setting it to 0 will cause device suspend/resume times not to be printed, even if initcall_debug has been set. This way, the people who use initcall_debug for reasons other than PM debugging will be able to switch the suspend/resume times printing off, if need be. Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl> Reviewed-by: Srivatsa S. Bhat <srivatsa.bhat@linux.vnet.ibm.com> Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Showing 5 changed files with 54 additions and 47 deletions Side-by-side Diff
drivers/base/power/main.c
... | ... | @@ -166,7 +166,7 @@ |
166 | 166 | { |
167 | 167 | ktime_t calltime = ktime_set(0, 0); |
168 | 168 | |
169 | - if (pm_print_times) { | |
169 | + if (pm_print_times_enabled) { | |
170 | 170 | pr_info("calling %s+ @ %i, parent: %s\n", |
171 | 171 | dev_name(dev), task_pid_nr(current), |
172 | 172 | dev->parent ? dev_name(dev->parent) : "none"); |
... | ... | @@ -181,7 +181,7 @@ |
181 | 181 | { |
182 | 182 | ktime_t delta, rettime; |
183 | 183 | |
184 | - if (pm_print_times) { | |
184 | + if (pm_print_times_enabled) { | |
185 | 185 | rettime = ktime_get(); |
186 | 186 | delta = ktime_sub(rettime, calltime); |
187 | 187 | pr_info("call %s+ returned %d after %Ld usecs\n", dev_name(dev), |
drivers/base/power/power.h
... | ... | @@ -85,15 +85,4 @@ |
85 | 85 | static inline void pm_qos_sysfs_remove(struct device *dev) {} |
86 | 86 | |
87 | 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 */ |
include/linux/suspend.h
... | ... | @@ -408,6 +408,12 @@ |
408 | 408 | |
409 | 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 | 417 | #ifdef CONFIG_PM_AUTOSLEEP |
412 | 418 | |
413 | 419 | /* kernel/power/autosleep.c */ |
kernel/power/Kconfig
... | ... | @@ -175,7 +175,7 @@ |
175 | 175 | You probably want to have your system's RTC driver statically |
176 | 176 | linked, ensuring that it's available when this test runs. |
177 | 177 | |
178 | -config CAN_PM_TRACE | |
178 | +config PM_SLEEP_DEBUG | |
179 | 179 | def_bool y |
180 | 180 | depends on PM_DEBUG && PM_SLEEP |
181 | 181 | |
... | ... | @@ -196,7 +196,7 @@ |
196 | 196 | |
197 | 197 | config PM_TRACE_RTC |
198 | 198 | bool "Suspend/resume event tracing" |
199 | - depends on CAN_PM_TRACE | |
199 | + depends on PM_SLEEP_DEBUG | |
200 | 200 | depends on X86 |
201 | 201 | select PM_TRACE |
202 | 202 | ---help--- |
kernel/power/main.c
... | ... | @@ -132,38 +132,6 @@ |
132 | 132 | } |
133 | 133 | |
134 | 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 | 135 | #endif /* CONFIG_PM_DEBUG */ |
168 | 136 | |
169 | 137 | #ifdef CONFIG_DEBUG_FS |
... | ... | @@ -267,6 +235,47 @@ |
267 | 235 | |
268 | 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 | 279 | struct kobject *power_kobj; |
271 | 280 | |
272 | 281 | /** |
... | ... | @@ -562,6 +571,8 @@ |
562 | 571 | #endif |
563 | 572 | #ifdef CONFIG_PM_DEBUG |
564 | 573 | &pm_test_attr.attr, |
574 | +#endif | |
575 | +#ifdef CONFIG_PM_SLEEP_DEBUG | |
565 | 576 | &pm_print_times_attr.attr, |
566 | 577 | #endif |
567 | 578 | #endif |
... | ... | @@ -599,6 +610,7 @@ |
599 | 610 | error = sysfs_create_group(power_kobj, &attr_group); |
600 | 611 | if (error) |
601 | 612 | return error; |
613 | + pm_print_times_init(); | |
602 | 614 | return pm_autosleep_init(); |
603 | 615 | } |
604 | 616 |