*/
void update_pm_runtime_accounting(struct device *dev)
{
- u64 now = ktime_get_mono_fast_ns();
- u64 last = dev->power.accounting_timestamp;
- u64 delta;
+ u64 now, last, delta;
+ if (dev->power.disable_depth > 0)
+ return;
+
+ last = dev->power.accounting_timestamp;
+
+ now = ktime_get_mono_fast_ns();
dev->power.accounting_timestamp = now;
/*
delta = now - last;
- if (dev->power.disable_depth > 0)
- return;
-
if (dev->power.runtime_status == RPM_SUSPENDED)
dev->power.suspended_time += delta;
else
pm_runtime_put_noidle(dev);
}
+ /* Update time accounting before disabling PM-runtime. */
+ update_pm_runtime_accounting(dev);
+
if (!dev->power.disable_depth++)
__pm_runtime_barrier(dev);
dev->power.request_pending = false;
dev->power.request = RPM_REQ_NONE;
dev->power.deferred_resume = false;
- dev->power.accounting_timestamp = 0;
INIT_WORK(&dev->power.work, pm_runtime_work);
dev->power.timer_expires = 0;