[Intel-gfx] [PATCH 3/8] drm/i915/selftests: Flush the submission for lrc_isolation

Ramalingam C ramalingam.c at intel.com
Wed Mar 9 05:17:03 UTC 2022


From: Chris Wilson <chris at chris-wilson.co.uk>

The lrc_isolation test uses two contexts in order to read from one
context while poisoning from a second. The test verifies that the
writes of the second context do not leak into the first context. This is
done by first recording the register state from context A, forcing a
preemption to context B, and only then switching back to context A to
re-read the register state to see if anything changed. The sequence is
important (and internally controlled by semaphores), but it does require
that context A is submitted *before* context B, as context B has higher
priority to force the preemption.

Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
Signed-off-by: Ramalingam C <ramalingam.c at intel.com>
---
 drivers/gpu/drm/i915/gt/selftest_lrc.c | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/i915/gt/selftest_lrc.c b/drivers/gpu/drm/i915/gt/selftest_lrc.c
index 998e561694be..b064e824053f 100644
--- a/drivers/gpu/drm/i915/gt/selftest_lrc.c
+++ b/drivers/gpu/drm/i915/gt/selftest_lrc.c
@@ -1416,8 +1416,10 @@ __lrc_isolation(struct intel_engine_cs *engine, u32 poison, bool relative)
 	}
 
 	if (i915_request_wait(rq, 0, HZ / 2) < 0) {
+		pr_err("%s(%s): wait for reference results timed out\n",
+		       __func__, engine->name);
 		i915_request_put(rq);
-		err = -ETIME;
+		err = -EIO;
 		goto err_ref1;
 	}
 	i915_request_put(rq);
@@ -1440,6 +1442,17 @@ __lrc_isolation(struct intel_engine_cs *engine, u32 poison, bool relative)
 		goto err_result1;
 	}
 
+	/* Wait until we record the register state before allowing preemption */
+	if (wait_for_submit(engine, rq, HZ / 5)) {
+		pr_err("%s(%s): wait for submission timed out\n",
+		       __func__, engine->name);
+		i915_request_put(rq);
+		err = -EIO;
+		goto err_result1;
+	}
+	while (READ_ONCE(*sema.va) && !signal_pending(current))
+		usleep_range(100, 500);
+
 	err = poison_registers(B, engine, poison, relative, &sema);
 	if (err) {
 		WRITE_ONCE(*sema.va, -1);
@@ -1448,6 +1461,8 @@ __lrc_isolation(struct intel_engine_cs *engine, u32 poison, bool relative)
 	}
 
 	if (i915_request_wait(rq, 0, HZ / 2) < 0) {
+		pr_err("%s(%s): wait for results timed out\n",
+		       __func__, engine->name);
 		i915_request_put(rq);
 		err = -ETIME;
 		goto err_result1;
-- 
2.20.1



More information about the Intel-gfx mailing list