[Intel-gfx] [PATCH] drm/i915/selftests: Check timeout before flush and cond checks

Chris Wilson chris at chris-wilson.co.uk
Thu Mar 26 16:41:02 UTC 2020


Allow a bit of leniency for the CPU scheduler to be distracted while we
flush the tasklet and so ensure that we always check the status of the
request once more before timing out.

Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
---
 drivers/gpu/drm/i915/gt/selftest_lrc.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/i915/gt/selftest_lrc.c b/drivers/gpu/drm/i915/gt/selftest_lrc.c
index 6f06ba750a0a..b8c8355b1095 100644
--- a/drivers/gpu/drm/i915/gt/selftest_lrc.c
+++ b/drivers/gpu/drm/i915/gt/selftest_lrc.c
@@ -74,20 +74,19 @@ static int wait_for_submit(struct intel_engine_cs *engine,
 {
 	timeout += jiffies;
 	do {
-		cond_resched();
-		intel_engine_flush_submission(engine);
+		bool done = time_after(jiffies, timeout);
 
-		if (READ_ONCE(engine->execlists.pending[0]))
-			continue;
+		intel_engine_flush_submission(engine);
 
 		if (i915_request_is_active(rq))
 			return 0;
 
 		if (i915_request_started(rq)) /* that was quick! */
 			return 0;
-	} while (time_before(jiffies, timeout));
 
-	return -ETIME;
+		if (done)
+			return -ETIME;
+	} while (1);
 }
 
 static int wait_for_reset(struct intel_engine_cs *engine,
-- 
2.20.1



More information about the Intel-gfx mailing list