PM-runtime: Add new interface to get accounted time
authorVincent Guittot <vincent.guittot@linaro.org>
Fri, 21 Dec 2018 10:33:54 +0000 (11:33 +0100)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Tue, 15 Jan 2019 21:47:24 +0000 (22:47 +0100)
Some drivers (like i915/drm) needs to get the accounted suspended time.
pm_runtime_suspended_time() will return the suspended accounted time
in ns unit.

Reviewed-by: Ulf Hansson <ulf.hansson@linaro.org>
Signed-off-by: Vincent Guittot <vincent.guittot@linaro.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
drivers/base/power/runtime.c
include/linux/pm_runtime.h

index 457be03b744d276c9279b2a41686afdc49a05e20..a453090c9449bb281a800a35720febd89edc6c3e 100644 (file)
@@ -88,6 +88,21 @@ static void __update_runtime_status(struct device *dev, enum rpm_status status)
        dev->power.runtime_status = status;
 }
 
+u64 pm_runtime_suspended_time(struct device *dev)
+{
+       unsigned long flags, time;
+
+       spin_lock_irqsave(&dev->power.lock, flags);
+
+       update_pm_runtime_accounting(dev);
+       time = dev->power.suspended_jiffies;
+
+       spin_unlock_irqrestore(&dev->power.lock, flags);
+
+       return jiffies_to_nsecs(time);
+}
+EXPORT_SYMBOL_GPL(pm_runtime_suspended_time);
+
 /**
  * pm_runtime_deactivate_timer - Deactivate given device's suspend timer.
  * @dev: Device to handle.
index 54af4eef169f3e6b8e775a2352a83f99cfa36b37..a370006921c0b2a9d29b6ff14f8431d1d84a3ab7 100644 (file)
@@ -113,6 +113,8 @@ static inline bool pm_runtime_is_irq_safe(struct device *dev)
        return dev->power.irq_safe;
 }
 
+extern u64 pm_runtime_suspended_time(struct device *dev);
+
 #else /* !CONFIG_PM */
 
 static inline bool queue_pm_work(struct work_struct *work) { return false; }