summaryrefslogtreecommitdiff
path: root/drivers/gpu/drm/i915/gt/selftest_engine_pm.c
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2020-06-17 14:09:16 +0100
committerChris Wilson <chris@chris-wilson.co.uk>2020-06-18 09:26:54 +0100
commit810b7ee3008ab2ac94791f75857815484c2f9cce (patch)
tree85ff11b677567a5670ccd63e5ba00a1d22994c81 /drivers/gpu/drm/i915/gt/selftest_engine_pm.c
parent1b90e4a43b7444fc4159c6dd338a44e8808e8718 (diff)
drm/i915/gt: Always report the sample time for busy-stats
Return the monotonic timestamp (ktime_get()) at the time of sampling the busy-time. This is used in preference to taking ktime_get() separately before or after the read seqlock as there can be some large variance in reported timestamps. For selftests trying to ascertain that we are reporting accurate to within a few microseconds, even a small delay leads to the test failing. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com> Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com> Link: https://patchwork.freedesktop.org/patch/msgid/20200617130916.15261-2-chris@chris-wilson.co.uk
Diffstat (limited to 'drivers/gpu/drm/i915/gt/selftest_engine_pm.c')
-rw-r--r--drivers/gpu/drm/i915/gt/selftest_engine_pm.c18
1 files changed, 8 insertions, 10 deletions
diff --git a/drivers/gpu/drm/i915/gt/selftest_engine_pm.c b/drivers/gpu/drm/i915/gt/selftest_engine_pm.c
index dd54dcb5cca2..b08fc5390e8a 100644
--- a/drivers/gpu/drm/i915/gt/selftest_engine_pm.c
+++ b/drivers/gpu/drm/i915/gt/selftest_engine_pm.c
@@ -29,8 +29,8 @@ static int live_engine_busy_stats(void *arg)
GEM_BUG_ON(intel_gt_pm_is_awake(gt));
for_each_engine(engine, gt, id) {
struct i915_request *rq;
- ktime_t de;
- u64 dt;
+ ktime_t de, dt;
+ ktime_t t[2];
if (!intel_engine_supports_stats(engine))
continue;
@@ -47,12 +47,11 @@ static int live_engine_busy_stats(void *arg)
ENGINE_TRACE(engine, "measuring idle time\n");
preempt_disable();
- dt = ktime_to_ns(ktime_get());
- de = intel_engine_get_busy_time(engine);
+ de = intel_engine_get_busy_time(engine, &t[0]);
udelay(100);
- de = ktime_sub(intel_engine_get_busy_time(engine), de);
- dt = ktime_to_ns(ktime_get()) - dt;
+ de = ktime_sub(intel_engine_get_busy_time(engine, &t[1]), de);
preempt_enable();
+ dt = ktime_sub(t[1], t[0]);
if (de < 0 || de > 10) {
pr_err("%s: reported %lldns [%d%%] busyness while sleeping [for %lldns]\n",
engine->name,
@@ -80,12 +79,11 @@ static int live_engine_busy_stats(void *arg)
ENGINE_TRACE(engine, "measuring busy time\n");
preempt_disable();
- dt = ktime_to_ns(ktime_get());
- de = intel_engine_get_busy_time(engine);
+ de = intel_engine_get_busy_time(engine, &t[0]);
udelay(100);
- de = ktime_sub(intel_engine_get_busy_time(engine), de);
- dt = ktime_to_ns(ktime_get()) - dt;
+ de = ktime_sub(intel_engine_get_busy_time(engine, &t[1]), de);
preempt_enable();
+ dt = ktime_sub(t[1], t[0]);
if (100 * de < 95 * dt || 95 * de > 100 * dt) {
pr_err("%s: reported %lldns [%d%%] busyness while spinning [for %lldns]\n",
engine->name,