mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-08-21 16:29:59 +00:00
PM-runtime: update time accounting only when enabled
Update the accounting_timestamp field only when PM runtime is enabled and don't forget to account the last state before disabling it. Suggested-by: Ulf Hansson <ulf.hansson@linaro.org> Signed-off-by: Vincent Guittot <vincent.guittot@linaro.org> Reviewed-by: Ulf Hansson <ulf.hansson@linaro.org> [ rjw: Minor cleanups ] Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
This commit is contained in:
parent
c155f6499f
commit
fed7e88c07
1 changed files with 10 additions and 7 deletions
|
@ -66,10 +66,14 @@ static int rpm_suspend(struct device *dev, int rpmflags);
|
|||
*/
|
||||
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;
|
||||
|
||||
/*
|
||||
|
@ -82,9 +86,6 @@ void update_pm_runtime_accounting(struct device *dev)
|
|||
|
||||
delta = now - last;
|
||||
|
||||
if (dev->power.disable_depth > 0)
|
||||
return;
|
||||
|
||||
if (dev->power.runtime_status == RPM_SUSPENDED)
|
||||
dev->power.suspended_time += delta;
|
||||
else
|
||||
|
@ -1298,6 +1299,9 @@ void __pm_runtime_disable(struct device *dev, bool check_resume)
|
|||
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);
|
||||
|
||||
|
@ -1521,7 +1525,6 @@ void pm_runtime_init(struct device *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;
|
||||
|
|
Loading…
Reference in a new issue