Skip to content

Commit 985458d

Browse files
ickledanvet
authored andcommitted
drm/i915/selftest: Synchronise with the GPU timestamp
Wait for the GPU to wake up from the semaphore before measuring the time, so that we coordinate the sampling on both the CPU and GPU for more accurate comparisons. v2: Switch to local_irq_disable() as once suggested by Mika. Reported-by: Bruce Chang <[email protected]> Signed-off-by: Chris Wilson <[email protected]> Cc: CQ Tang <[email protected]> Reviewed-by: Bruce Chang <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected] Signed-off-by: Daniel Vetter <[email protected]>
1 parent dc43040 commit 985458d

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

drivers/gpu/drm/i915/gt/selftest_engine_pm.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,13 +110,15 @@ static int __measure_timestamps(struct intel_context *ce,
110110
cpu_relax();
111111

112112
/* Run the request for a 100us, sampling timestamps before/after */
113-
preempt_disable();
114-
*dt = local_clock();
113+
local_irq_disable();
115114
write_semaphore(&sema[2], 0);
115+
while (READ_ONCE(sema[1]) == 0) /* wait for the gpu to catch up */
116+
cpu_relax();
117+
*dt = local_clock();
116118
udelay(100);
117119
*dt = local_clock() - *dt;
118120
write_semaphore(&sema[2], 1);
119-
preempt_enable();
121+
local_irq_enable();
120122

121123
if (i915_request_wait(rq, 0, HZ / 2) < 0) {
122124
i915_request_put(rq);

0 commit comments

Comments
 (0)