[PATCH] pmu
Tvrtko Ursulin
tvrtko.ursulin at linux.intel.com
Thu Apr 22 09:38:37 UTC 2021
From: Tvrtko Ursulin <tvrtko.ursulin at intel.com>
Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin at intel.com>
---
drivers/gpu/drm/i915/i915_pmu.c | 19 ++++++++++---------
1 file changed, 10 insertions(+), 9 deletions(-)
diff --git a/drivers/gpu/drm/i915/i915_pmu.c b/drivers/gpu/drm/i915/i915_pmu.c
index a75cd1db320b..059f2cdc149e 100644
--- a/drivers/gpu/drm/i915/i915_pmu.c
+++ b/drivers/gpu/drm/i915/i915_pmu.c
@@ -230,10 +230,11 @@ static void __i915_pmu_maybe_start_timer(struct i915_pmu *pmu)
{
if (!pmu->timer_enabled && pmu_needs_timer(pmu, true)) {
pmu->timer_enabled = true;
- pmu->timer_last = ktime_get();
- hrtimer_start_range_ns(&pmu->timer,
- ns_to_ktime(PERIOD), 0,
- HRTIMER_MODE_REL_PINNED);
+ if (!hrtimer_active(&pmu->timer)) {
+ pmu->timer_last = pmu->timer.base->get_time();
+ hrtimer_start(&pmu->timer, ns_to_ktime(PERIOD),
+ HRTIMER_MODE_REL_PINNED);
+ }
}
}
@@ -421,13 +422,15 @@ static enum hrtimer_restart i915_sample(struct hrtimer *hrtimer)
struct i915_pmu *pmu = &i915->pmu;
struct intel_gt *gt = &i915->gt;
unsigned int period_ns;
- ktime_t now;
+ ktime_t now, last;
if (!READ_ONCE(pmu->timer_enabled))
return HRTIMER_NORESTART;
- now = ktime_get();
- period_ns = ktime_to_ns(ktime_sub(now, pmu->timer_last));
+ now = hrtimer->base->get_time();
+ last = pmu->timer_last;
+ period_ns = ktime_to_ns(ktime_sub(now, last));
+ hrtimer_forward(hrtimer, last, ns_to_ktime(PERIOD));
pmu->timer_last = now;
/*
@@ -439,8 +442,6 @@ static enum hrtimer_restart i915_sample(struct hrtimer *hrtimer)
engines_sample(gt, period_ns);
frequency_sample(gt, period_ns);
- hrtimer_forward(hrtimer, now, ns_to_ktime(PERIOD));
-
return HRTIMER_RESTART;
}
--
2.27.0
More information about the Intel-gfx-trybot
mailing list