Skip to content

Commit

Permalink
PM-runtime: add tracepoints for usage_count changes
Browse files Browse the repository at this point in the history
Add tracepoints to remaining places where device's power.usage_count
is changed.

This helps debugging where and why autosuspend is prevented.

Signed-off-by: Michał Mirosław <[email protected]>
Signed-off-by: Rafael J. Wysocki <[email protected]>
  • Loading branch information
osctobe authored and rafaeljw committed Jan 13, 2020
1 parent b3a987b commit d229290
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
13 changes: 11 additions & 2 deletions drivers/base/power/runtime.c
Original file line number Diff line number Diff line change
Expand Up @@ -1006,8 +1006,10 @@ int __pm_runtime_idle(struct device *dev, int rpmflags)
int retval;

if (rpmflags & RPM_GET_PUT) {
if (!atomic_dec_and_test(&dev->power.usage_count))
if (!atomic_dec_and_test(&dev->power.usage_count)) {
trace_rpm_usage_rcuidle(dev, rpmflags);
return 0;
}
}

might_sleep_if(!(rpmflags & RPM_ASYNC) && !dev->power.irq_safe);
Expand Down Expand Up @@ -1038,8 +1040,10 @@ int __pm_runtime_suspend(struct device *dev, int rpmflags)
int retval;

if (rpmflags & RPM_GET_PUT) {
if (!atomic_dec_and_test(&dev->power.usage_count))
if (!atomic_dec_and_test(&dev->power.usage_count)) {
trace_rpm_usage_rcuidle(dev, rpmflags);
return 0;
}
}

might_sleep_if(!(rpmflags & RPM_ASYNC) && !dev->power.irq_safe);
Expand Down Expand Up @@ -1101,6 +1105,7 @@ int pm_runtime_get_if_in_use(struct device *dev)
retval = dev->power.disable_depth > 0 ? -EINVAL :
dev->power.runtime_status == RPM_ACTIVE
&& atomic_inc_not_zero(&dev->power.usage_count);
trace_rpm_usage_rcuidle(dev, 0);
spin_unlock_irqrestore(&dev->power.lock, flags);
return retval;
}
Expand Down Expand Up @@ -1434,6 +1439,8 @@ void pm_runtime_allow(struct device *dev)
dev->power.runtime_auto = true;
if (atomic_dec_and_test(&dev->power.usage_count))
rpm_idle(dev, RPM_AUTO | RPM_ASYNC);
else
trace_rpm_usage_rcuidle(dev, RPM_AUTO | RPM_ASYNC);

out:
spin_unlock_irq(&dev->power.lock);
Expand Down Expand Up @@ -1501,6 +1508,8 @@ static void update_autosuspend(struct device *dev, int old_delay, int old_use)
if (!old_use || old_delay >= 0) {
atomic_inc(&dev->power.usage_count);
rpm_resume(dev, 0);
} else {
trace_rpm_usage_rcuidle(dev, 0);
}
}

Expand Down
6 changes: 6 additions & 0 deletions include/trace/events/rpm.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,12 @@ DEFINE_EVENT(rpm_internal, rpm_idle,

TP_ARGS(dev, flags)
);
DEFINE_EVENT(rpm_internal, rpm_usage,

TP_PROTO(struct device *dev, int flags),

TP_ARGS(dev, flags)
);

TRACE_EVENT(rpm_return_int,
TP_PROTO(struct device *dev, unsigned long ip, int ret),
Expand Down

0 comments on commit d229290

Please sign in to comment.