Blob Blame History Raw
From 402fd7daaf424eda08bc5dba95c27342e014a4f0 Mon Sep 17 00:00:00 2001
From: Chris Wilson <chris@chris-wilson.co.uk>
Date: Fri, 14 Feb 2020 12:06:59 +0000
Subject: drm/i915/selftests: Check for the error interrupt before we wait!
Git-commit: fcf7df7aae24facdedf42d76842e97ecc2f5d5bb
Patch-mainline: v5.7-rc1
References: jsc#SLE-12680, jsc#SLE-12880, jsc#SLE-12882, jsc#SLE-12883, jsc#SLE-13496, jsc#SLE-15322

Sometimes the error interrupt can fire even before we have seen the
request go active -- in which case, we end up waiting until the timeout
as the request is already completed. Double check for this case!

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: Matthew Auld <matthew.auld@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200214120659.3888735-1-chris@chris-wilson.co.uk
Signed-off-by: Patrik Jakobsson <pjakobsson@suse.de>
---
 drivers/gpu/drm/i915/gt/selftest_lrc.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/gpu/drm/i915/gt/selftest_lrc.c b/drivers/gpu/drm/i915/gt/selftest_lrc.c
index 3a74a54739a8..64761e619876 100644
--- a/drivers/gpu/drm/i915/gt/selftest_lrc.c
+++ b/drivers/gpu/drm/i915/gt/selftest_lrc.c
@@ -76,11 +76,15 @@ static int wait_for_submit(struct intel_engine_cs *engine,
 	do {
 		cond_resched();
 		intel_engine_flush_submission(engine);
+
 		if (i915_request_is_active(rq) &&
 		    !READ_ONCE(engine->execlists.pending[0])) {
 			tasklet_unlock_wait(&engine->execlists.tasklet);
 			return 0;
 		}
+
+		if (i915_request_completed(rq)) /* that was quick! */
+			return 0;
 	} while (time_before(jiffies, timeout));
 
 	return -ETIME;
-- 
2.28.0