Message ID | 1545315385-14384-2-git-send-email-vincent.guittot@linaro.org (mailing list archive) |
---|---|
State | Superseded, archived |
Headers | show |
Series | Move pm_runtime accounted time to raw nsec | expand |
On Thu, 20 Dec 2018 at 15:16, Vincent Guittot <vincent.guittot@linaro.org> wrote: > > 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. > > Signed-off-by: Vincent Guittot <vincent.guittot@linaro.org> Reviewed-by: Ulf Hansson <ulf.hansson@linaro.org> Kind regards Uffe > --- > drivers/base/power/runtime.c | 16 ++++++++++++++++ > include/linux/pm_runtime.h | 2 ++ > 2 files changed, 18 insertions(+) > > diff --git a/drivers/base/power/runtime.c b/drivers/base/power/runtime.c > index beb85c3..e695544 100644 > --- a/drivers/base/power/runtime.c > +++ b/drivers/base/power/runtime.c > @@ -86,6 +86,22 @@ 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. > diff --git a/include/linux/pm_runtime.h b/include/linux/pm_runtime.h > index f0fc470..d479707 100644 > --- a/include/linux/pm_runtime.h > +++ b/include/linux/pm_runtime.h > @@ -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; } > -- > 2.7.4 >
diff --git a/drivers/base/power/runtime.c b/drivers/base/power/runtime.c index beb85c3..e695544 100644 --- a/drivers/base/power/runtime.c +++ b/drivers/base/power/runtime.c @@ -86,6 +86,22 @@ 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. diff --git a/include/linux/pm_runtime.h b/include/linux/pm_runtime.h index f0fc470..d479707 100644 --- a/include/linux/pm_runtime.h +++ b/include/linux/pm_runtime.h @@ -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; }
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. Signed-off-by: Vincent Guittot <vincent.guittot@linaro.org> --- drivers/base/power/runtime.c | 16 ++++++++++++++++ include/linux/pm_runtime.h | 2 ++ 2 files changed, 18 insertions(+)