[igt-dev] [PATCH i-g-t] prime_vgem: Replace nanosleep with igt_waitchildren_timeout

Chris Wilson chris at chris-wilson.co.uk
Mon Apr 1 07:58:40 UTC 2019


We want to use a child in order to detect an uninterruptable sleep (a
potential bug we might hit), but we can use igt_waitchildren_timeout()
to replace our risky self-signaling + nanosleep.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=103182
Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
---
 tests/prime_vgem.c | 20 +++++++-------------
 1 file changed, 7 insertions(+), 13 deletions(-)

diff --git a/tests/prime_vgem.c b/tests/prime_vgem.c
index 60bb951c8..fe28322a6 100644
--- a/tests/prime_vgem.c
+++ b/tests/prime_vgem.c
@@ -697,29 +697,24 @@ static void flip_to_vgem(int i915, int vgem,
 			 unsigned hang,
 			 const char *name)
 {
-	const struct timespec tv = { 1, 0 };
 	struct pollfd pfd = { i915, POLLIN };
 	struct drm_event_vblank vbl;
 	uint32_t fence;
 
 	fence = vgem_fence_attach(vgem, bo, VGEM_FENCE_WRITE | hang);
 
-	igt_fork(child, 1) {
+	igt_fork(child, 1) { /* Use a child in case we block uninterruptibly */
+		/* Check we don't block nor flip before the fence is ready */
 		do_or_die(drmModePageFlip(i915, crtc_id, fb_id,
 					  DRM_MODE_PAGE_FLIP_EVENT, &fb_id));
-		kill(getppid(), SIGHUP);
-
-		/* Check we don't flip before the fence is ready */
-		for (int n = 0; n < 5; n++) {
+		for (int n = 0; n < 5; n++) { /* 5 frames should be <100ms */
 			igt_assert_f(poll(&pfd, 1, 0) == 0,
 				     "flip to %s completed whilst busy\n",
-				      name);
+				     name);
 			get_vblank(i915, 0, DRM_VBLANK_NEXTONMISS);
 		}
 	}
-
-	igt_assert_f(nanosleep(&tv, NULL) == -1,
-		     "flip to busy %s blocked\n", name);
+	igt_waitchildren_timeout(2, "flip blocked by waiting for busy vgem fence");
 
 	/* And then the flip is completed as soon as it is ready */
 	if (!hang) {
@@ -734,12 +729,11 @@ static void flip_to_vgem(int i915, int vgem,
 		get_vblank(i915, 0, DRM_VBLANK_NEXTONMISS);
 		igt_assert_eq(poll(&pfd, 1, 0), 1);
 	}
+
 	/* Even if hung, the flip must complete *eventually* */
-	igt_set_timeout(20, "Ignored hang"); /* XXX lower fail threshold? */
+	igt_set_timeout(20, "flip blocked by hanging vgem fence"); /* XXX lower fail threshold? */
 	igt_assert_eq(read(i915, &vbl, sizeof(vbl)), sizeof(vbl));
 	igt_reset_timeout();
-
-	igt_waitchildren();
 }
 
 static void test_flip(int i915, int vgem, unsigned hang)
-- 
2.20.1



More information about the igt-dev mailing list