<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none;"><!-- P {margin-top:0;margin-bottom:0;} --></style>
</head>
<body dir="ltr">
<div id="divtagdefaultwrapper" dir="ltr" style="font-size:12pt; color:rgb(0,0,0); font-family:Calibri,Helvetica,sans-serif,EmojiFont,"Apple Color Emoji","Segoe UI Emoji",NotoColorEmoji,"Segoe UI Symbol","Android Emoji",EmojiSymbols">
<p></p>
<div>> Wait for the GPU to wake up from the semaphore before measuring the</div>
<div>>time, so that we coordinate the sampling on both the CPU and GPU for</div>
<div>> more accurate comparisons.</div>
<div>> </div>
<div>>Reported-by: Bruce Chang <yu.bruce.chang@intel.com></div>
<div>> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk></div>
<div>> Cc: CQ Tang <cq.tang@intel.com></div>
<div>> ---</div>
<div>> drivers/gpu/drm/i915/gt/selftest_engine_pm.c | 4 +++-</div>
<div>> 1 file changed, 3 insertions(+), 1 deletion(-)</div>
<div>> </div>
<div>> diff --git a/drivers/gpu/drm/i915/gt/selftest_engine_pm.c b/drivers/gpu/drm/i915/gt/selftest_engine_pm.c</div>
<div>>index 3ce8cb3329f3..007a7c790778 100644</div>
<div>> --- a/drivers/gpu/drm/i915/gt/selftest_engine_pm.c</div>
<div>> +++ b/drivers/gpu/drm/i915/gt/selftest_engine_pm.c</div>
<div>> @@ -111,8 +111,10 @@ static int __measure_timestamps(struct intel_context *ce,</div>
<div>> </div>
<div>> /* Run the request for a 100us, sampling timestamps before/after */</div>
<div>> preempt_disable();</div>
<div>> - *dt = local_clock();</div>
<div>> write_semaphore(&sema[2], 0);</div>
<div>> + while (READ_ONCE(sema[1]) == 0) /* wait for the gpu to catch up */</div>
<div>> + cpu_relax();</div>
<div>> + *dt = local_clock();</div>
<div>> udelay(100);</div>
<div>> *dt = local_clock() - *dt;</div>
<div>> write_semaphore(&sema[2], 1);</div>
<div>> -- </div>
<div>>2.20.1</div>
<div>> </div>
<div><br>
</div>
<div>This trick should work!</div>
<div>Thanks!</div>
<div><br>
</div>
<div>Reviewed-by: <span style="color: rgb(33, 33, 33); font-family: wf_segoe-ui_normal, "Segoe UI", "Segoe WP", Tahoma, Arial, sans-serif, serif, EmojiFont; font-size: 13.3333px;">Bruce Chang <yu.bruce.chang@intel.com></span> </div>
<div><br>
</div>
<p></p>
</div>
</body>
</html>