[Intel-gfx] [PATCH i-g-t] kms_busy: Replace fiddling with hangcheck modparam with explicit fence

Chris Wilson chris at chris-wilson.co.uk
Sat Jul 27 18:02:47 UTC 2019


Use an explicit fence to circumvent the [i915] GPU hang detection rather
than tweak the i915 specific modparam (and remove the assertion that
such a param exists). Note, that with a bit more work, the fence could
be used be directly rather than via dirtying the fb with a dummyload.

Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
---
 lib/igt_dummyload.c |  5 +++++
 lib/igt_dummyload.h | 10 ++++++----
 tests/kms_busy.c    | 26 ++++++++++----------------
 3 files changed, 21 insertions(+), 20 deletions(-)

diff --git a/lib/igt_dummyload.c b/lib/igt_dummyload.c
index 0e06276af..65b5cc927 100644
--- a/lib/igt_dummyload.c
+++ b/lib/igt_dummyload.c
@@ -236,6 +236,11 @@ emit_recursive_batch(igt_spin_t *spin,
 	if (opts->flags & IGT_SPIN_FENCE_OUT)
 		execbuf->flags |= I915_EXEC_FENCE_OUT;
 
+	if (opts->flags & IGT_SPIN_FENCE_IN) {
+		execbuf->flags |= I915_EXEC_FENCE_IN;
+		execbuf->rsvd2 = opts->fence;
+	}
+
 	for (i = 0; i < nengine; i++) {
 		execbuf->flags &= ~ENGINE_MASK;
 		execbuf->flags |= flags[i];
diff --git a/lib/igt_dummyload.h b/lib/igt_dummyload.h
index bb25751ad..66837057d 100644
--- a/lib/igt_dummyload.h
+++ b/lib/igt_dummyload.h
@@ -54,12 +54,14 @@ struct igt_spin_factory {
 	uint32_t dependency;
 	unsigned int engine;
 	unsigned int flags;
+	int fence;
 };
 
-#define IGT_SPIN_FENCE_OUT     (1 << 0)
-#define IGT_SPIN_POLL_RUN      (1 << 1)
-#define IGT_SPIN_FAST          (1 << 2)
-#define IGT_SPIN_NO_PREEMPTION (1 << 3)
+#define IGT_SPIN_FENCE_IN      (1 << 0)
+#define IGT_SPIN_FENCE_OUT     (1 << 1)
+#define IGT_SPIN_POLL_RUN      (1 << 2)
+#define IGT_SPIN_FAST          (1 << 3)
+#define IGT_SPIN_NO_PREEMPTION (1 << 4)
 
 igt_spin_t *
 __igt_spin_factory(int fd, const struct igt_spin_factory *opts);
diff --git a/tests/kms_busy.c b/tests/kms_busy.c
index 66f26cd08..baf45f30f 100644
--- a/tests/kms_busy.c
+++ b/tests/kms_busy.c
@@ -75,22 +75,16 @@ static void flip_to_fb(igt_display_t *dpy, int pipe,
 	struct pollfd pfd = { .fd = dpy->drm_fd, .events = POLLIN };
 	const int timeout = modeset ? 8500 : 100;
 	struct drm_event_vblank ev;
+	IGT_CORK_FENCE(cork);
+	igt_spin_t *t;
+	int fence;
 
-	igt_spin_t *t = igt_spin_new(dpy->drm_fd,
-				     .engine = ring,
-				     .dependency = fb->gem_handle);
-
-	if (modeset) {
-		/*
-		 * We want to check that a modeset actually waits for the
-		 * spin batch to complete, but we keep a bigger timeout for
-		 * disable than required for flipping.
-		 *
-		 * As a result, the GPU reset code may kick in, which we neuter
-		 * here to be sure there's no premature completion.
-		 */
-		igt_set_module_param_int("enable_hangcheck", 0);
-	}
+	fence = igt_cork_plug(&cork, dpy->drm_fd);
+	t = igt_spin_new(dpy->drm_fd,
+			 .engine = ring,
+			 .fence = fence,
+			 .dependency = fb->gem_handle,
+			 .flags = IGT_SPIN_FENCE_IN | IGT_SPIN_NO_PREEMPTION);
 
 	igt_fork(child, 1) {
 		igt_assert(gem_bo_busy(dpy->drm_fd, fb->gem_handle));
@@ -116,13 +110,13 @@ static void flip_to_fb(igt_display_t *dpy, int pipe,
 	igt_waitchildren_timeout(5 * timeout,
 				 "flip blocked waiting for busy bo\n");
 	igt_spin_end(t);
+	close(fence);
 
 	igt_assert(read(dpy->drm_fd, &ev, sizeof(ev)) == sizeof(ev));
 	igt_assert(poll(&pfd, 1, 0) == 0);
 
 	if (modeset) {
 		gem_quiescent_gpu(dpy->drm_fd);
-		igt_set_module_param_int("enable_hangcheck", 1);
 
 		/* Clear old mode blob. */
 		igt_pipe_refresh(dpy, pipe, true);
-- 
2.22.0



More information about the Intel-gfx mailing list