summaryrefslogtreecommitdiffstats
path: root/drivers/base/power
diff options
context:
space:
mode:
authorVincent Guittot <vincent.guittot@linaro.org>2019-01-23 08:50:13 +0100
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2019-01-31 10:44:44 +0100
commit58456488e0e3793f2f95a3d2e2a78b6eba0ad0aa (patch)
tree177a0ec4de71845192fdbe59aabe2442b673d0db /drivers/base/power
parent40619f7dd3ef05ae7861bc60d401585d316e1374 (diff)
downloadblackbird-op-linux-58456488e0e3793f2f95a3d2e2a78b6eba0ad0aa.tar.gz
blackbird-op-linux-58456488e0e3793f2f95a3d2e2a78b6eba0ad0aa.zip
PM-runtime: update accounting_timestamp on enable
Initializing accounting_timestamp to something different from 0 during pm_runtime_init() doesn't make sense and puts an artificial ordering constraint between timekeeping_init() and pm_runtime_init(). PM-runtime should start time accounting only when it is enabled and discard the period when disabled. Set accounting_timestamp to now when enabling PM-runtime. Suggested-by: "Rafael J. Wysocki" <rjw@rjwysocki.net> Signed-off-by: Vincent Guittot <vincent.guittot@linaro.org> Reviewed-by: Ulf Hansson <ulf.hansson@linaro.org> [ rjw: Subject & changelog ] Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Diffstat (limited to 'drivers/base/power')
-rw-r--r--drivers/base/power/runtime.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/drivers/base/power/runtime.c b/drivers/base/power/runtime.c
index a453090c9449..f23b7ecfce3b 100644
--- a/drivers/base/power/runtime.c
+++ b/drivers/base/power/runtime.c
@@ -1309,10 +1309,15 @@ void pm_runtime_enable(struct device *dev)
spin_lock_irqsave(&dev->power.lock, flags);
- if (dev->power.disable_depth > 0)
+ if (dev->power.disable_depth > 0) {
dev->power.disable_depth--;
- else
+
+ /* About to enable runtime pm, set accounting_timestamp to now */
+ if (!dev->power.disable_depth)
+ dev->power.accounting_timestamp = jiffies;
+ } else {
dev_warn(dev, "Unbalanced %s!\n", __func__);
+ }
WARN(!dev->power.disable_depth &&
dev->power.runtime_status == RPM_SUSPENDED &&
@@ -1509,7 +1514,7 @@ 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 = jiffies;
+ dev->power.accounting_timestamp = 0;
INIT_WORK(&dev->power.work, pm_runtime_work);
dev->power.timer_expires = 0;
OpenPOWER on IntegriCloud