[PATCH i-g-t v2 10/12] tests/kms_atomic_transition: add out_fences tests

Robert Foss
2016-12-14T09:05:20Z

From: Gustavo Padovan <gustavo.padovan@collabora.co.uk>

Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
Signed-off-by: Robert Foss <robert.foss@collabora.com>
---
lib/igt_kms.c | 22 ++++++++++++++++++++++
tests/kms_atomic_transition.c | 32 ++++++++++++++++++++++++++++++--
2 files changed, 52 insertions(+), 2 deletions(-)

diff --git a/lib/igt_kms.c b/lib/igt_kms.c
index fe1b356d..eb59ab36 100644
--- a/lib/igt_kms.c
+++ b/lib/igt_kms.c
@@ -49,6 +49,7 @@
#include "intel_chipset.h"
#include "igt_debugfs.h"
#include "igt_sysfs.h"
+#include "sw_sync.h"

/**
* SECTION:igt_kms
@@ -2184,6 +2185,27 @@ static int igt_atomic_commit(igt_display_t *display, uint32_t flags, void *user_
}

ret = drmModeAtomicCommit(display->drm_fd, req, flags, user_data);
+ if (!ret) {
+ int64_t *fence_ptr;
+
+ for_each_pipe(display, pipe) {
+ igt_pipe_t *pipe_obj = &display->pipes[pipe];
+
+ fence_ptr = pipe_obj->out_fence_ptr;
+ if (!fence_ptr)
+ continue;
+
+ if (flags & DRM_MODE_ATOMIC_TEST_ONLY) {
+ igt_assert(*fence_ptr == -1);
+ } else {
+ igt_assert(*fence_ptr >= 0);
+ ret = sw_sync_wait(*fence_ptr, 1000);
+ igt_assert(ret == 0);
+ close(*fence_ptr);
+ }
+ }
+ }
+
drmModeAtomicFree(req);
return ret;

diff --git a/tests/kms_atomic_transition.c b/tests/kms_atomic_transition.c
index b7d99975..08f9499f 100644
--- a/tests/kms_atomic_transition.c
+++ b/tests/kms_atomic_transition.c
@@ -132,6 +132,7 @@ run_transition_test(igt_display_t *display, enum pipe pipe, igt_output_t *output
struct plane_parms parms[IGT_MAX_PLANES];
bool skip_test = false;
unsigned flags = DRM_MODE_PAGE_FLIP_EVENT;
+ int out_fence, ret;

if (nonblocking)
flags |= DRM_MODE_ATOMIC_NONBLOCK;
@@ -198,9 +199,11 @@ run_transition_test(igt_display_t *display, enum pipe pipe, igt_output_t *output
* planes to fix this
*/
while (1) {
- int ret;
-
wm_setup_plane(display, pipe, iter_max - 1, parms);
+
+ if (fencing)
+ igt_pipe_set_out_fence_ptr(&display->pipes[pipe],
+ (int64_t *) &out_fence);
ret = igt_display_try_commit_atomic(display, DRM_MODE_ATOMIC_TEST_ONLY | DRM_MODE_ATOMIC_ALLOW_MODESET, NULL);

if (ret != -EINVAL || n_planes < 3)
@@ -231,6 +234,9 @@ run_transition_test(igt_display_t *display, enum pipe pipe, igt_output_t *output

wm_setup_plane(display, pipe, i, parms);

+ if (fencing)
+ igt_pipe_set_out_fence_ptr(&display->pipes[pipe], &out_fence);
+
igt_display_commit_atomic(display, flags, (void *)(unsigned long)i);
drmHandleEvent(display->drm_fd, &drm_events);

@@ -239,6 +245,10 @@ run_transition_test(igt_display_t *display, enum pipe pipe, igt_output_t *output

wm_setup_plane(display, pipe, 0, parms);

+ if (fencing)
+ igt_pipe_set_out_fence_ptr(&display->pipes[pipe],
+ (int64_t *) &out_fence);
+
igt_display_commit_atomic(display, flags, (void *)0UL);

drmHandleEvent(display->drm_fd, &drm_events);
@@ -252,6 +262,9 @@ run_transition_test(igt_display_t *display, enum pipe pipe, igt_output_t *output
if (type == TRANSITION_MODESET)
igt_output_override_mode(output, &override_mode);

+ if (fencing)
+ igt_pipe_set_out_fence_ptr(&display->pipes[pipe], &out_fence);
+
igt_display_commit_atomic(display, flags, (void *)(unsigned long)j);
drmHandleEvent(display->drm_fd, &drm_events);

@@ -259,6 +272,9 @@ run_transition_test(igt_display_t *display, enum pipe pipe, igt_output_t *output
if (type == TRANSITION_MODESET)
igt_output_override_mode(output, NULL);

+ if (fencing)
+ igt_pipe_set_out_fence_ptr(&display->pipes[pipe], &out_fence);
+
igt_display_commit_atomic(display, flags, (void *)(unsigned long)i);
drmHandleEvent(display->drm_fd, &drm_events);
}
@@ -588,14 +604,26 @@ igt_main
for_each_pipe_with_valid_output(&display, pipe, output)
run_transition_test(&display, pipe, output, TRANSITION_PLANES, false, false);

+ igt_subtest("plane-all-transition-fencing")
+ for_each_pipe_with_valid_output(&display, pipe, output)
+ run_transition_test(&display, pipe, output, TRANSITION_PLANES, false, true);
+
igt_subtest("plane-all-transition-nonblocking")
for_each_pipe_with_valid_output(&display, pipe, output)
run_transition_test(&display, pipe, output, TRANSITION_PLANES, true, false);

+ igt_subtest("plane-all-transition-nonblocking-fencing")
+ for_each_pipe_with_valid_output(&display, pipe, output)
+ run_transition_test(&display, pipe, output, TRANSITION_PLANES, true, true);
+
igt_subtest("plane-all-modeset-transition")
for_each_pipe_with_valid_output(&display, pipe, output)
run_transition_test(&display, pipe, output, TRANSITION_MODESET, false, false);

+ igt_subtest("plane-all-modeset-transition-fencing")
+ for_each_pipe_with_valid_output(&display, pipe, output)
+ run_transition_test(&display, pipe, output, TRANSITION_MODESET, false, true);
+
igt_subtest("plane-toggle-modeset-transition")
for_each_pipe_with_valid_output(&display, pipe, output)
run_transition_test(&display, pipe, output, TRANSITION_MODESET_DISABLE, false, false);