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>
This commit is contained in:
Rafael J. Wysocki 2012-06-21 00:19:33 +02:00
parent 4b7760ba0d
commit b2df1d4f8b
5 changed files with 54 additions and 47 deletions

View File

@ -166,7 +166,7 @@ static ktime_t initcall_debug_start(struct device *dev)
{ {
ktime_t calltime = ktime_set(0, 0); ktime_t calltime = ktime_set(0, 0);
if (pm_print_times) { if (pm_print_times_enabled) {
pr_info("calling %s+ @ %i, parent: %s\n", pr_info("calling %s+ @ %i, parent: %s\n",
dev_name(dev), task_pid_nr(current), dev_name(dev), task_pid_nr(current),
dev->parent ? dev_name(dev->parent) : "none"); dev->parent ? dev_name(dev->parent) : "none");
@ -181,7 +181,7 @@ static void initcall_debug_report(struct device *dev, ktime_t calltime,
{ {
ktime_t delta, rettime; ktime_t delta, rettime;
if (pm_print_times) { if (pm_print_times_enabled) {
rettime = ktime_get(); rettime = ktime_get();
delta = ktime_sub(rettime, calltime); delta = ktime_sub(rettime, calltime);
pr_info("call %s+ returned %d after %Ld usecs\n", dev_name(dev), pr_info("call %s+ returned %d after %Ld usecs\n", dev_name(dev),

View File

@ -85,14 +85,3 @@ static inline int pm_qos_sysfs_add(struct device *dev) { return 0; }
static inline void pm_qos_sysfs_remove(struct device *dev) {} static inline void pm_qos_sysfs_remove(struct device *dev) {}
#endif #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 */

View File

@ -408,6 +408,12 @@ static inline void unlock_system_sleep(void) {}
#endif /* !CONFIG_PM_SLEEP */ #endif /* !CONFIG_PM_SLEEP */
#ifdef CONFIG_PM_SLEEP_DEBUG
extern bool pm_print_times_enabled;
#else
#define pm_print_times_enabled (false)
#endif
#ifdef CONFIG_PM_AUTOSLEEP #ifdef CONFIG_PM_AUTOSLEEP
/* kernel/power/autosleep.c */ /* kernel/power/autosleep.c */

View File

@ -175,7 +175,7 @@ config PM_TEST_SUSPEND
You probably want to have your system's RTC driver statically You probably want to have your system's RTC driver statically
linked, ensuring that it's available when this test runs. linked, ensuring that it's available when this test runs.
config CAN_PM_TRACE config PM_SLEEP_DEBUG
def_bool y def_bool y
depends on PM_DEBUG && PM_SLEEP depends on PM_DEBUG && PM_SLEEP
@ -196,7 +196,7 @@ config PM_TRACE
config PM_TRACE_RTC config PM_TRACE_RTC
bool "Suspend/resume event tracing" bool "Suspend/resume event tracing"
depends on CAN_PM_TRACE depends on PM_SLEEP_DEBUG
depends on X86 depends on X86
select PM_TRACE select PM_TRACE
---help--- ---help---

View File

@ -132,38 +132,6 @@ static ssize_t pm_test_store(struct kobject *kobj, struct kobj_attribute *attr,
} }
power_attr(pm_test); 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 */ #endif /* CONFIG_PM_DEBUG */
#ifdef CONFIG_DEBUG_FS #ifdef CONFIG_DEBUG_FS
@ -267,6 +235,47 @@ late_initcall(pm_debugfs_init);
#endif /* CONFIG_PM_SLEEP */ #endif /* CONFIG_PM_SLEEP */
#ifdef CONFIG_PM_SLEEP_DEBUG
/*
* 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.
*/
bool 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);
static inline void pm_print_times_init(void)
{
pm_print_times_enabled = !!initcall_debug;
}
#else /* !CONFIG_PP_SLEEP_DEBUG */
static inline void pm_print_times_init(void) {}
#endif /* CONFIG_PM_SLEEP_DEBUG */
struct kobject *power_kobj; struct kobject *power_kobj;
/** /**
@ -562,6 +571,8 @@ static struct attribute * g[] = {
#endif #endif
#ifdef CONFIG_PM_DEBUG #ifdef CONFIG_PM_DEBUG
&pm_test_attr.attr, &pm_test_attr.attr,
#endif
#ifdef CONFIG_PM_SLEEP_DEBUG
&pm_print_times_attr.attr, &pm_print_times_attr.attr,
#endif #endif
#endif #endif
@ -599,6 +610,7 @@ static int __init pm_init(void)
error = sysfs_create_group(power_kobj, &attr_group); error = sysfs_create_group(power_kobj, &attr_group);
if (error) if (error)
return error; return error;
pm_print_times_init();
return pm_autosleep_init(); return pm_autosleep_init();
} }