PM-runtime: Replace jiffies-based accounting with ktime-based accounting
Replace jiffies-based accounting for runtime_active_time and runtime_suspended_time with ktime-based accounting. This makes the runtime debug counters inline with genpd and other PM subsytems which use ktime-based accounting. Timekeeping is initialized before driver_init(). It's only at that time that PM-runtime can be enabled. Signed-off-by: Thara Gopinath <thara.gopinath@linaro.org> [switch from ktime to raw nsec] Signed-off-by: Vincent Guittot <vincent.guittot@linaro.org> Reviewed-by: Ulf Hansson <ulf.hansson@linaro.org> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
This commit is contained in:
parent
58456488e0
commit
a08c2a5a31
@ -66,8 +66,8 @@ static int rpm_suspend(struct device *dev, int rpmflags);
|
|||||||
*/
|
*/
|
||||||
void update_pm_runtime_accounting(struct device *dev)
|
void update_pm_runtime_accounting(struct device *dev)
|
||||||
{
|
{
|
||||||
unsigned long now = jiffies;
|
u64 now = ktime_to_ns(ktime_get());
|
||||||
unsigned long delta;
|
u64 delta;
|
||||||
|
|
||||||
delta = now - dev->power.accounting_timestamp;
|
delta = now - dev->power.accounting_timestamp;
|
||||||
|
|
||||||
@ -77,9 +77,9 @@ void update_pm_runtime_accounting(struct device *dev)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
if (dev->power.runtime_status == RPM_SUSPENDED)
|
if (dev->power.runtime_status == RPM_SUSPENDED)
|
||||||
dev->power.suspended_jiffies += delta;
|
dev->power.suspended_time += delta;
|
||||||
else
|
else
|
||||||
dev->power.active_jiffies += delta;
|
dev->power.active_time += delta;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void __update_runtime_status(struct device *dev, enum rpm_status status)
|
static void __update_runtime_status(struct device *dev, enum rpm_status status)
|
||||||
@ -90,16 +90,17 @@ static void __update_runtime_status(struct device *dev, enum rpm_status status)
|
|||||||
|
|
||||||
u64 pm_runtime_suspended_time(struct device *dev)
|
u64 pm_runtime_suspended_time(struct device *dev)
|
||||||
{
|
{
|
||||||
unsigned long flags, time;
|
u64 time;
|
||||||
|
unsigned long flags;
|
||||||
|
|
||||||
spin_lock_irqsave(&dev->power.lock, flags);
|
spin_lock_irqsave(&dev->power.lock, flags);
|
||||||
|
|
||||||
update_pm_runtime_accounting(dev);
|
update_pm_runtime_accounting(dev);
|
||||||
time = dev->power.suspended_jiffies;
|
time = dev->power.suspended_time;
|
||||||
|
|
||||||
spin_unlock_irqrestore(&dev->power.lock, flags);
|
spin_unlock_irqrestore(&dev->power.lock, flags);
|
||||||
|
|
||||||
return jiffies_to_nsecs(time);
|
return time;
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL_GPL(pm_runtime_suspended_time);
|
EXPORT_SYMBOL_GPL(pm_runtime_suspended_time);
|
||||||
|
|
||||||
@ -1314,7 +1315,7 @@ void pm_runtime_enable(struct device *dev)
|
|||||||
|
|
||||||
/* About to enable runtime pm, set accounting_timestamp to now */
|
/* About to enable runtime pm, set accounting_timestamp to now */
|
||||||
if (!dev->power.disable_depth)
|
if (!dev->power.disable_depth)
|
||||||
dev->power.accounting_timestamp = jiffies;
|
dev->power.accounting_timestamp = ktime_to_ns(ktime_get());
|
||||||
} else {
|
} else {
|
||||||
dev_warn(dev, "Unbalanced %s!\n", __func__);
|
dev_warn(dev, "Unbalanced %s!\n", __func__);
|
||||||
}
|
}
|
||||||
|
@ -125,9 +125,12 @@ static ssize_t runtime_active_time_show(struct device *dev,
|
|||||||
struct device_attribute *attr, char *buf)
|
struct device_attribute *attr, char *buf)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
|
u64 tmp;
|
||||||
spin_lock_irq(&dev->power.lock);
|
spin_lock_irq(&dev->power.lock);
|
||||||
update_pm_runtime_accounting(dev);
|
update_pm_runtime_accounting(dev);
|
||||||
ret = sprintf(buf, "%i\n", jiffies_to_msecs(dev->power.active_jiffies));
|
tmp = dev->power.active_time;
|
||||||
|
do_div(tmp, NSEC_PER_MSEC);
|
||||||
|
ret = sprintf(buf, "%llu\n", tmp);
|
||||||
spin_unlock_irq(&dev->power.lock);
|
spin_unlock_irq(&dev->power.lock);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -138,10 +141,12 @@ static ssize_t runtime_suspended_time_show(struct device *dev,
|
|||||||
struct device_attribute *attr, char *buf)
|
struct device_attribute *attr, char *buf)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
|
u64 tmp;
|
||||||
spin_lock_irq(&dev->power.lock);
|
spin_lock_irq(&dev->power.lock);
|
||||||
update_pm_runtime_accounting(dev);
|
update_pm_runtime_accounting(dev);
|
||||||
ret = sprintf(buf, "%i\n",
|
tmp = dev->power.suspended_time;
|
||||||
jiffies_to_msecs(dev->power.suspended_jiffies));
|
do_div(tmp, NSEC_PER_MSEC);
|
||||||
|
ret = sprintf(buf, "%llu\n", tmp);
|
||||||
spin_unlock_irq(&dev->power.lock);
|
spin_unlock_irq(&dev->power.lock);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -633,9 +633,9 @@ struct dev_pm_info {
|
|||||||
int runtime_error;
|
int runtime_error;
|
||||||
int autosuspend_delay;
|
int autosuspend_delay;
|
||||||
u64 last_busy;
|
u64 last_busy;
|
||||||
unsigned long active_jiffies;
|
u64 active_time;
|
||||||
unsigned long suspended_jiffies;
|
u64 suspended_time;
|
||||||
unsigned long accounting_timestamp;
|
u64 accounting_timestamp;
|
||||||
#endif
|
#endif
|
||||||
struct pm_subsys_data *subsys_data; /* Owned by the subsystem. */
|
struct pm_subsys_data *subsys_data; /* Owned by the subsystem. */
|
||||||
void (*set_latency_tolerance)(struct device *, s32);
|
void (*set_latency_tolerance)(struct device *, s32);
|
||||||
|
Loading…
Reference in New Issue
Block a user