diff mbox series

[i-g-t] kms_busy: Use igt_waitchildren_timeout()

Message ID 20190330235448.5606-1-chris@chris-wilson.co.uk (mailing list archive)
State New, archived
Headers show
Series [i-g-t] kms_busy: Use igt_waitchildren_timeout() | expand

Commit Message

Chris Wilson March 30, 2019, 11:54 p.m. UTC
Replace the convoluted raising of SIGALRM from the child with an
interruptible sleep in the parent with the equivalent and far more
natural igt_waitchildren_timeout().

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=103182
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
---
 tests/kms_busy.c | 31 +++++--------------------------
 1 file changed, 5 insertions(+), 26 deletions(-)

Comments

Daniel Vetter April 1, 2019, 7:32 a.m. UTC | #1
On Sat, Mar 30, 2019 at 11:54:48PM +0000, Chris Wilson wrote:
> Replace the convoluted raising of SIGALRM from the child with an
> interruptible sleep in the parent with the equivalent and far more
> natural igt_waitchildren_timeout().
> 
> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=103182
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>

I guess v2 missing here somewhere? Either way nice cleanup!

Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>

> ---
>  tests/kms_busy.c | 31 +++++--------------------------
>  1 file changed, 5 insertions(+), 26 deletions(-)
> 
> diff --git a/tests/kms_busy.c b/tests/kms_busy.c
> index ed3caae4c..321db8207 100644
> --- a/tests/kms_busy.c
> +++ b/tests/kms_busy.c
> @@ -29,9 +29,6 @@
>  
>  IGT_TEST_DESCRIPTION("Basic check of KMS ABI with busy framebuffers.");
>  
> -#define FRAME_TIME 16 /* milleseconds */
> -#define TIMEOUT (6*16)
> -
>  static igt_output_t *
>  set_fb_on_crtc(igt_display_t *dpy, int pipe, struct igt_fb *fb)
>  {
> @@ -70,17 +67,13 @@ static void do_cleanup_display(igt_display_t *dpy)
>  	igt_display_commit2(dpy, dpy->is_atomic ? COMMIT_ATOMIC : COMMIT_LEGACY);
>  }
>  
> -static void sighandler(int sig)
> -{
> -}
> -
>  static void flip_to_fb(igt_display_t *dpy, int pipe,
>  		       igt_output_t *output,
>  		       struct igt_fb *fb, unsigned ring,
>  		       const char *name, bool modeset)
>  {
>  	struct pollfd pfd = { .fd = dpy->drm_fd, .events = POLLIN };
> -	struct timespec tv = { 1, 0 };
> +	const int timeout = modeset ? 8500 : 100;
>  	struct drm_event_vblank ev;
>  
>  	igt_spin_t *t = igt_spin_batch_new(dpy->drm_fd,
> @@ -114,24 +107,14 @@ static void flip_to_fb(igt_display_t *dpy, int pipe,
>  						  DRM_MODE_ATOMIC_ALLOW_MODESET, NULL);
>  		}
>  
> -		kill(getppid(), SIGALRM);
> -		igt_assert(gem_bo_busy(dpy->drm_fd, fb->gem_handle));
> -		igt_assert_f(poll(&pfd, 1, modeset ? 8500 : TIMEOUT) == 0,
> +		igt_assert_f(poll(&pfd, 1, timeout) == 0,
>  			     "flip completed whilst %s was busy [%d]\n",
>  			     name, gem_bo_busy(dpy->drm_fd, fb->gem_handle));
> +		igt_assert(gem_bo_busy(dpy->drm_fd, fb->gem_handle));
>  	}
>  
> -	igt_assert_f(nanosleep(&tv, NULL) == -1,
> -		     "flip to %s blocked waiting for busy fb", name);
> -
> -	igt_waitchildren();
> -
> -	if (!modeset) {
> -		tv.tv_sec = 0;
> -		tv.tv_nsec = (2 * TIMEOUT) * 1000000ULL;
> -		nanosleep(&tv, NULL);
> -	}
> -
> +	igt_waitchildren_timeout(5 * timeout,
> +				 "flip blocked waiting for busy bo\n");
>  	igt_spin_batch_end(t);
>  
>  	igt_assert(read(dpy->drm_fd, &ev, sizeof(ev)) == sizeof(ev));
> @@ -160,8 +143,6 @@ static void test_flip(igt_display_t *dpy, unsigned ring, int pipe, bool modeset)
>  	if (modeset)
>  		igt_require(dpy->is_atomic);
>  
> -	signal(SIGALRM, sighandler);
> -
>  	output = set_fb_on_crtc(dpy, pipe, &fb[0]);
>  	igt_display_commit2(dpy, COMMIT_LEGACY);
>  
> @@ -194,8 +175,6 @@ static void test_flip(igt_display_t *dpy, unsigned ring, int pipe, bool modeset)
>  	do_cleanup_display(dpy);
>  	igt_remove_fb(dpy->drm_fd, &fb[1]);
>  	igt_remove_fb(dpy->drm_fd, &fb[0]);
> -
> -	signal(SIGALRM, SIG_DFL);
>  }
>  
>  static void test_atomic_commit_hang(igt_display_t *dpy, igt_plane_t *primary,
> -- 
> 2.20.1
> 
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Chris Wilson April 1, 2019, 7:39 a.m. UTC | #2
Quoting Daniel Vetter (2019-04-01 08:32:27)
> On Sat, Mar 30, 2019 at 11:54:48PM +0000, Chris Wilson wrote:
> > Replace the convoluted raising of SIGALRM from the child with an
> > interruptible sleep in the parent with the equivalent and far more
> > natural igt_waitchildren_timeout().
> > 
> > Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=103182
> > Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> 
> I guess v2 missing here somewhere? Either way nice cleanup!

gcc pointed out the dead code that I could remove.
-Chris
diff mbox series

Patch

diff --git a/tests/kms_busy.c b/tests/kms_busy.c
index ed3caae4c..321db8207 100644
--- a/tests/kms_busy.c
+++ b/tests/kms_busy.c
@@ -29,9 +29,6 @@ 
 
 IGT_TEST_DESCRIPTION("Basic check of KMS ABI with busy framebuffers.");
 
-#define FRAME_TIME 16 /* milleseconds */
-#define TIMEOUT (6*16)
-
 static igt_output_t *
 set_fb_on_crtc(igt_display_t *dpy, int pipe, struct igt_fb *fb)
 {
@@ -70,17 +67,13 @@  static void do_cleanup_display(igt_display_t *dpy)
 	igt_display_commit2(dpy, dpy->is_atomic ? COMMIT_ATOMIC : COMMIT_LEGACY);
 }
 
-static void sighandler(int sig)
-{
-}
-
 static void flip_to_fb(igt_display_t *dpy, int pipe,
 		       igt_output_t *output,
 		       struct igt_fb *fb, unsigned ring,
 		       const char *name, bool modeset)
 {
 	struct pollfd pfd = { .fd = dpy->drm_fd, .events = POLLIN };
-	struct timespec tv = { 1, 0 };
+	const int timeout = modeset ? 8500 : 100;
 	struct drm_event_vblank ev;
 
 	igt_spin_t *t = igt_spin_batch_new(dpy->drm_fd,
@@ -114,24 +107,14 @@  static void flip_to_fb(igt_display_t *dpy, int pipe,
 						  DRM_MODE_ATOMIC_ALLOW_MODESET, NULL);
 		}
 
-		kill(getppid(), SIGALRM);
-		igt_assert(gem_bo_busy(dpy->drm_fd, fb->gem_handle));
-		igt_assert_f(poll(&pfd, 1, modeset ? 8500 : TIMEOUT) == 0,
+		igt_assert_f(poll(&pfd, 1, timeout) == 0,
 			     "flip completed whilst %s was busy [%d]\n",
 			     name, gem_bo_busy(dpy->drm_fd, fb->gem_handle));
+		igt_assert(gem_bo_busy(dpy->drm_fd, fb->gem_handle));
 	}
 
-	igt_assert_f(nanosleep(&tv, NULL) == -1,
-		     "flip to %s blocked waiting for busy fb", name);
-
-	igt_waitchildren();
-
-	if (!modeset) {
-		tv.tv_sec = 0;
-		tv.tv_nsec = (2 * TIMEOUT) * 1000000ULL;
-		nanosleep(&tv, NULL);
-	}
-
+	igt_waitchildren_timeout(5 * timeout,
+				 "flip blocked waiting for busy bo\n");
 	igt_spin_batch_end(t);
 
 	igt_assert(read(dpy->drm_fd, &ev, sizeof(ev)) == sizeof(ev));
@@ -160,8 +143,6 @@  static void test_flip(igt_display_t *dpy, unsigned ring, int pipe, bool modeset)
 	if (modeset)
 		igt_require(dpy->is_atomic);
 
-	signal(SIGALRM, sighandler);
-
 	output = set_fb_on_crtc(dpy, pipe, &fb[0]);
 	igt_display_commit2(dpy, COMMIT_LEGACY);
 
@@ -194,8 +175,6 @@  static void test_flip(igt_display_t *dpy, unsigned ring, int pipe, bool modeset)
 	do_cleanup_display(dpy);
 	igt_remove_fb(dpy->drm_fd, &fb[1]);
 	igt_remove_fb(dpy->drm_fd, &fb[0]);
-
-	signal(SIGALRM, SIG_DFL);
 }
 
 static void test_atomic_commit_hang(igt_display_t *dpy, igt_plane_t *primary,