Commit 875ab0b7 authored by Rafael J. Wysocki's avatar Rafael J. Wysocki

PM: Make the initcall_debug style timing for suspend/resume complete

Commit f2511774
(PM: Add initcall_debug style timing for suspend/resume) introduced
basic timing instrumentation, needed for a scritps/bootgraph.pl
equivalent or humans, but it missed the fact that bus types and
device classes which haven't been switched to using struct dev_pm_ops
objects yet need special handling.  As a result, the suspend/resume
timing information is only available for devices whose bus types or
device classes use struct dev_pm_ops objects, so the majority of
devices is not covered.

Fix this by adding basic suspend/resume timing instrumentation for
devices whose bus types and device classes still don't use struct
dev_pm_ops objects for power management.  To reduce code duplication
move the timing code to helper functions.
Signed-off-by: default avatarRafael J. Wysocki <rjw@sisk.pl>
parent b8a7f3cd
...@@ -161,6 +161,32 @@ void device_pm_move_last(struct device *dev) ...@@ -161,6 +161,32 @@ void device_pm_move_last(struct device *dev)
list_move_tail(&dev->power.entry, &dpm_list); list_move_tail(&dev->power.entry, &dpm_list);
} }
static ktime_t initcall_debug_start(struct device *dev)
{
ktime_t calltime = ktime_set(0, 0);
if (initcall_debug) {
pr_info("calling %s+ @ %i\n",
dev_name(dev), task_pid_nr(current));
calltime = ktime_get();
}
return calltime;
}
static void initcall_debug_report(struct device *dev, ktime_t calltime,
int error)
{
ktime_t delta, rettime;
if (initcall_debug) {
rettime = ktime_get();
delta = ktime_sub(rettime, calltime);
pr_info("call %s+ returned %d after %Ld usecs\n", dev_name(dev),
error, (unsigned long long)ktime_to_ns(delta) >> 10);
}
}
/** /**
* pm_op - Execute the PM operation appropriate for given PM event. * pm_op - Execute the PM operation appropriate for given PM event.
* @dev: Device to handle. * @dev: Device to handle.
...@@ -172,13 +198,9 @@ static int pm_op(struct device *dev, ...@@ -172,13 +198,9 @@ static int pm_op(struct device *dev,
pm_message_t state) pm_message_t state)
{ {
int error = 0; int error = 0;
ktime_t calltime, delta, rettime; ktime_t calltime;
if (initcall_debug) { calltime = initcall_debug_start(dev);
pr_info("calling %s+ @ %i\n",
dev_name(dev), task_pid_nr(current));
calltime = ktime_get();
}
switch (state.event) { switch (state.event) {
#ifdef CONFIG_SUSPEND #ifdef CONFIG_SUSPEND
...@@ -227,12 +249,7 @@ static int pm_op(struct device *dev, ...@@ -227,12 +249,7 @@ static int pm_op(struct device *dev,
error = -EINVAL; error = -EINVAL;
} }
if (initcall_debug) { initcall_debug_report(dev, calltime, error);
rettime = ktime_get();
delta = ktime_sub(rettime, calltime);
pr_info("call %s+ returned %d after %Ld usecs\n", dev_name(dev),
error, (unsigned long long)ktime_to_ns(delta) >> 10);
}
return error; return error;
} }
...@@ -309,8 +326,9 @@ static int pm_noirq_op(struct device *dev, ...@@ -309,8 +326,9 @@ static int pm_noirq_op(struct device *dev,
if (initcall_debug) { if (initcall_debug) {
rettime = ktime_get(); rettime = ktime_get();
delta = ktime_sub(rettime, calltime); delta = ktime_sub(rettime, calltime);
printk("initcall %s_i+ returned %d after %Ld usecs\n", dev_name(dev), printk("initcall %s_i+ returned %d after %Ld usecs\n",
error, (unsigned long long)ktime_to_ns(delta) >> 10); dev_name(dev), error,
(unsigned long long)ktime_to_ns(delta) >> 10);
} }
return error; return error;
...@@ -407,6 +425,26 @@ void dpm_resume_noirq(pm_message_t state) ...@@ -407,6 +425,26 @@ void dpm_resume_noirq(pm_message_t state)
} }
EXPORT_SYMBOL_GPL(dpm_resume_noirq); EXPORT_SYMBOL_GPL(dpm_resume_noirq);
/**
* legacy_resume - Execute a legacy (bus or class) resume callback for device.
* dev: Device to resume.
* cb: Resume callback to execute.
*/
static int legacy_resume(struct device *dev, int (*cb)(struct device *dev))
{
int error;
ktime_t calltime;
calltime = initcall_debug_start(dev);
error = cb(dev);
suspend_report_result(cb, error);
initcall_debug_report(dev, calltime, error);
return error;
}
/** /**
* device_resume - Execute "resume" callbacks for given device. * device_resume - Execute "resume" callbacks for given device.
* @dev: Device to handle. * @dev: Device to handle.
...@@ -427,7 +465,7 @@ static int device_resume(struct device *dev, pm_message_t state) ...@@ -427,7 +465,7 @@ static int device_resume(struct device *dev, pm_message_t state)
error = pm_op(dev, dev->bus->pm, state); error = pm_op(dev, dev->bus->pm, state);
} else if (dev->bus->resume) { } else if (dev->bus->resume) {
pm_dev_dbg(dev, state, "legacy "); pm_dev_dbg(dev, state, "legacy ");
error = dev->bus->resume(dev); error = legacy_resume(dev, dev->bus->resume);
} }
if (error) if (error)
goto End; goto End;
...@@ -448,7 +486,7 @@ static int device_resume(struct device *dev, pm_message_t state) ...@@ -448,7 +486,7 @@ static int device_resume(struct device *dev, pm_message_t state)
error = pm_op(dev, dev->class->pm, state); error = pm_op(dev, dev->class->pm, state);
} else if (dev->class->resume) { } else if (dev->class->resume) {
pm_dev_dbg(dev, state, "legacy class "); pm_dev_dbg(dev, state, "legacy class ");
error = dev->class->resume(dev); error = legacy_resume(dev, dev->class->resume);
} }
} }
End: End:
...@@ -647,6 +685,27 @@ int dpm_suspend_noirq(pm_message_t state) ...@@ -647,6 +685,27 @@ int dpm_suspend_noirq(pm_message_t state)
} }
EXPORT_SYMBOL_GPL(dpm_suspend_noirq); EXPORT_SYMBOL_GPL(dpm_suspend_noirq);
/**
* legacy_suspend - Execute a legacy (bus or class) suspend callback for device.
* dev: Device to suspend.
* cb: Suspend callback to execute.
*/
static int legacy_suspend(struct device *dev, pm_message_t state,
int (*cb)(struct device *dev, pm_message_t state))
{
int error;
ktime_t calltime;
calltime = initcall_debug_start(dev);
error = cb(dev, state);
suspend_report_result(cb, error);
initcall_debug_report(dev, calltime, error);
return error;
}
/** /**
* device_suspend - Execute "suspend" callbacks for given device. * device_suspend - Execute "suspend" callbacks for given device.
* @dev: Device to handle. * @dev: Device to handle.
...@@ -664,8 +723,7 @@ static int device_suspend(struct device *dev, pm_message_t state) ...@@ -664,8 +723,7 @@ static int device_suspend(struct device *dev, pm_message_t state)
error = pm_op(dev, dev->class->pm, state); error = pm_op(dev, dev->class->pm, state);
} else if (dev->class->suspend) { } else if (dev->class->suspend) {
pm_dev_dbg(dev, state, "legacy class "); pm_dev_dbg(dev, state, "legacy class ");
error = dev->class->suspend(dev, state); error = legacy_suspend(dev, state, dev->class->suspend);
suspend_report_result(dev->class->suspend, error);
} }
if (error) if (error)
goto End; goto End;
...@@ -686,8 +744,7 @@ static int device_suspend(struct device *dev, pm_message_t state) ...@@ -686,8 +744,7 @@ static int device_suspend(struct device *dev, pm_message_t state)
error = pm_op(dev, dev->bus->pm, state); error = pm_op(dev, dev->bus->pm, state);
} else if (dev->bus->suspend) { } else if (dev->bus->suspend) {
pm_dev_dbg(dev, state, "legacy "); pm_dev_dbg(dev, state, "legacy ");
error = dev->bus->suspend(dev, state); error = legacy_suspend(dev, state, dev->bus->suspend);
suspend_report_result(dev->bus->suspend, error);
} }
} }
End: End:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment