Add TEST_ONLY flag to test atomic transition display commits without actual real-life commit. Signed-off-by: Mika Kahola <mika.kahola@xxxxxxxxx> --- tests/kms_atomic_transition.c | 227 ++++++++++++++++++++++++++++-------------- 1 file changed, 152 insertions(+), 75 deletions(-) diff --git a/tests/kms_atomic_transition.c b/tests/kms_atomic_transition.c index 851ffc9..2505210 100644 --- a/tests/kms_atomic_transition.c +++ b/tests/kms_atomic_transition.c @@ -68,7 +68,7 @@ wm_setup_plane(igt_display_t *display, enum pipe pipe, } } -static bool skip_on_unsupported_nonblocking_modeset(igt_display_t *display) +static bool skip_on_unsupported_nonblocking_modeset(igt_display_t *display, bool test_only) { enum pipe pipe; int ret; @@ -81,12 +81,14 @@ static bool skip_on_unsupported_nonblocking_modeset(igt_display_t *display) */ igt_display_commit_atomic(display, DRM_MODE_ATOMIC_TEST_ONLY | DRM_MODE_ATOMIC_ALLOW_MODESET, NULL); - ret = igt_display_try_commit_atomic(display, DRM_MODE_ATOMIC_ALLOW_MODESET | DRM_MODE_ATOMIC_NONBLOCK, NULL); + if (!test_only) { + ret = igt_display_try_commit_atomic(display, DRM_MODE_ATOMIC_ALLOW_MODESET | DRM_MODE_ATOMIC_NONBLOCK, NULL); - if (ret == -EINVAL) - return true; + if (ret == -EINVAL) + return true; - igt_assert_eq(ret, 0); + igt_assert_eq(ret, 0); + } /* Force the next state to update all crtc's, to synchronize with the nonblocking modeset. */ for_each_pipe(display, pipe) @@ -267,7 +269,7 @@ retry: */ static void run_transition_test(igt_display_t *display, enum pipe pipe, igt_output_t *output, - enum transition_type type, bool nonblocking) + enum transition_type type, bool nonblocking, bool test_only) { struct igt_fb fb, argb_fb, sprite_fb; drmModeModeInfo *mode, override_mode; @@ -276,6 +278,10 @@ 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 ret; + + if (test_only) + flags = DRM_MODE_ATOMIC_ALLOW_MODESET | DRM_MODE_ATOMIC_TEST_ONLY; if (nonblocking) flags |= DRM_MODE_ATOMIC_NONBLOCK; @@ -295,18 +301,26 @@ run_transition_test(igt_display_t *display, enum pipe pipe, igt_output_t *output wm_setup_plane(display, pipe, 0, NULL); if (flags & DRM_MODE_ATOMIC_ALLOW_MODESET) { - skip_test = nonblocking && skip_on_unsupported_nonblocking_modeset(display); + skip_test = nonblocking && skip_on_unsupported_nonblocking_modeset(display, test_only); if (skip_test) goto cleanup; igt_output_set_pipe(output, PIPE_NONE); - igt_display_commit2(display, COMMIT_ATOMIC); + if (test_only) { + ret = igt_display_try_commit_atomic(display, flags, NULL); + igt_assert_eq(ret, 0); + } else + igt_display_commit2(display, COMMIT_ATOMIC); igt_output_set_pipe(output, pipe); } - igt_display_commit2(display, COMMIT_ATOMIC); + if (test_only) { + ret = igt_display_try_commit_atomic(display, flags, NULL); + igt_assert_eq(ret, 0); + } else + igt_display_commit2(display, COMMIT_ATOMIC); setup_parms(display, pipe, mode, &argb_fb, &sprite_fb, parms); @@ -315,17 +329,22 @@ run_transition_test(igt_display_t *display, enum pipe pipe, igt_output_t *output wm_setup_plane(display, pipe, i, parms); - igt_display_commit_atomic(display, flags, (void *)(unsigned long)i); - drmHandleEvent(display->drm_fd, &drm_events); + ret = igt_display_try_commit_atomic(display, flags, (void *)(unsigned long)i); + igt_assert_eq(ret, 0); + + if (!test_only) + drmHandleEvent(display->drm_fd, &drm_events); if (type == TRANSITION_MODESET_DISABLE) { igt_output_set_pipe(output, PIPE_NONE); wm_setup_plane(display, pipe, 0, parms); - igt_display_commit_atomic(display, flags, (void *)0UL); + ret = igt_display_try_commit_atomic(display, flags, (void *)0UL); + igt_assert_eq(ret, 0); - drmHandleEvent(display->drm_fd, &drm_events); + if (!test_only) + drmHandleEvent(display->drm_fd, &drm_events); } else { uint32_t j; @@ -336,15 +355,21 @@ 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); - igt_display_commit_atomic(display, flags, (void *)(unsigned long)j); - drmHandleEvent(display->drm_fd, &drm_events); + ret = igt_display_try_commit_atomic(display, flags, (void *)(unsigned long)j); + igt_assert_eq(ret, 0); + + if (!test_only) + drmHandleEvent(display->drm_fd, &drm_events); wm_setup_plane(display, pipe, i, parms); if (type == TRANSITION_MODESET) igt_output_override_mode(output, NULL); - igt_display_commit_atomic(display, flags, (void *)(unsigned long)i); - drmHandleEvent(display->drm_fd, &drm_events); + ret = igt_display_try_commit_atomic(display, flags, (void *)(unsigned long)i); + igt_assert_eq(ret, 0); + + if (!test_only) + drmHandleEvent(display->drm_fd, &drm_events); } } } @@ -355,7 +380,8 @@ cleanup: for_each_plane_on_pipe(display, pipe, plane) igt_plane_set_fb(plane, NULL); - igt_display_commit2(display, COMMIT_ATOMIC); + if (!test_only) + igt_display_commit2(display, COMMIT_ATOMIC); igt_remove_fb(display->drm_fd, &fb); igt_remove_fb(display->drm_fd, &argb_fb); @@ -364,51 +390,60 @@ cleanup: igt_skip("Atomic nonblocking modesets are not supported.\n"); } -static void commit_display(igt_display_t *display, unsigned event_mask, bool nonblocking) +static void commit_display(igt_display_t *display, unsigned int event_mask, + bool nonblocking, bool test_only) { unsigned flags; int num_events = hweight32(event_mask); ssize_t ret; - flags = DRM_MODE_ATOMIC_ALLOW_MODESET | DRM_MODE_PAGE_FLIP_EVENT; + if (test_only) + flags = DRM_MODE_ATOMIC_TEST_ONLY | DRM_MODE_ATOMIC_ALLOW_MODESET; + else + flags = DRM_MODE_ATOMIC_ALLOW_MODESET | DRM_MODE_PAGE_FLIP_EVENT; + if (nonblocking) flags |= DRM_MODE_ATOMIC_NONBLOCK; - igt_display_commit_atomic(display, flags, NULL); + ret = igt_display_try_commit_atomic(display, flags, NULL); - igt_debug("Event mask: %x, waiting for %i events\n", event_mask, num_events); + igt_assert_eq(ret, 0); - igt_set_timeout(30, "Waiting for events timed out\n"); + if (!test_only) { + igt_debug("Event mask: %x, waiting for %i events\n", event_mask, num_events); - while (num_events) { - char buf[32]; - struct drm_event *e = (void *)buf; - struct drm_event_vblank *vblank = (void *)buf; - uint32_t crtc_id, pipe = I915_MAX_PIPES; + igt_set_timeout(30, "Waiting for events timed out\n"); - ret = read(display->drm_fd, buf, sizeof(buf)); - if (ret < 0 && (errno == EINTR || errno == EAGAIN)) - continue; + while (num_events) { + char buf[32]; + struct drm_event *e = (void *)buf; + struct drm_event_vblank *vblank = (void *)buf; + uint32_t crtc_id, pipe = I915_MAX_PIPES; - igt_assert(ret >= 0); - igt_assert_eq(e->type, DRM_EVENT_FLIP_COMPLETE); + ret = read(display->drm_fd, buf, sizeof(buf)); + if (ret < 0 && (errno == EINTR || errno == EAGAIN)) + continue; - crtc_id = vblank->reserved; - if (crtc_id) { - for_each_pipe(display, pipe) - if (display->pipes[pipe].crtc_id == crtc_id) - break; + igt_assert(ret >= 0); + igt_assert_eq(e->type, DRM_EVENT_FLIP_COMPLETE); - igt_assert_lt(pipe, display->n_pipes); + crtc_id = vblank->reserved; + if (crtc_id) { + for_each_pipe(display, pipe) + if (display->pipes[pipe].crtc_id == crtc_id) + break; - igt_debug("Retrieved vblank seq: %u on %u/%u\n", vblank->sequence, vblank->reserved, pipe); - } else - igt_debug("Retrieved vblank seq: %u on unk/unk\n", vblank->sequence); + igt_assert_lt(pipe, display->n_pipes); - num_events--; - } + igt_debug("Retrieved vblank seq: %u on %u/%u\n", vblank->sequence, vblank->reserved, pipe); + } else + igt_debug("Retrieved vblank seq: %u on unk/unk\n", vblank->sequence); - igt_reset_timeout(); + num_events--; + } + + igt_reset_timeout(); + } } static unsigned set_combinations(igt_display_t *display, unsigned mask, struct igt_fb *fb) @@ -481,7 +516,8 @@ static void collect_crcs_mask(igt_pipe_crc_t **pipe_crcs, unsigned mask, igt_crc } } -static void run_modeset_tests(igt_display_t *display, int howmany, bool nonblocking) +static void run_modeset_tests(igt_display_t *display, int howmany, + bool nonblocking, bool test_only) { struct igt_fb fbs[2]; int i, j; @@ -490,6 +526,7 @@ static void run_modeset_tests(igt_display_t *display, int howmany, bool nonblock igt_output_t *output; unsigned width = 0, height = 0; bool skip_test = false; + int ret; for_each_connected_output(display, output) { drmModeModeInfo *mode = igt_output_get_mode(output); @@ -501,7 +538,7 @@ static void run_modeset_tests(igt_display_t *display, int howmany, bool nonblock } igt_create_pattern_fb(display->drm_fd, width, height, - DRM_FORMAT_XRGB8888, 0, &fbs[0]); + DRM_FORMAT_XRGB8888, 0, &fbs[0]); igt_create_color_pattern_fb(display->drm_fd, width, height, DRM_FORMAT_XRGB8888, 0, .5, .5, .5, &fbs[1]); @@ -533,10 +570,15 @@ static void run_modeset_tests(igt_display_t *display, int howmany, bool nonblock * When i915 supports nonblocking modeset, this if branch can be removed. * It's only purpose is to ensure nonblocking modeset works. */ - if (nonblocking && (skip_test = skip_on_unsupported_nonblocking_modeset(display))) + if (nonblocking && (skip_test = skip_on_unsupported_nonblocking_modeset(display, test_only))) goto cleanup; - igt_display_commit2(display, COMMIT_ATOMIC); + if (test_only) + ret = igt_display_try_commit2(display, DRM_MODE_ATOMIC_TEST_ONLY | COMMIT_ATOMIC); + else + ret = igt_display_try_commit2(display, COMMIT_ATOMIC); + + igt_assert_eq(ret, 0); for (i = 0; i < iter_max; i++) { igt_crc_t crcs[5][I915_MAX_PIPES]; @@ -549,9 +591,10 @@ static void run_modeset_tests(igt_display_t *display, int howmany, bool nonblock if (!event_mask && i) continue; - commit_display(display, event_mask, nonblocking); + commit_display(display, event_mask, nonblocking, test_only); - collect_crcs_mask(pipe_crcs, i, crcs[0]); + if (!test_only) + collect_crcs_mask(pipe_crcs, i, crcs[0]); for (j = iter_max - 1; j > i + 1; j--) { if (hweight32(j) > howmany) @@ -564,43 +607,54 @@ static void run_modeset_tests(igt_display_t *display, int howmany, bool nonblock if (!event_mask) continue; - commit_display(display, event_mask, nonblocking); + commit_display(display, event_mask, nonblocking, test_only); - collect_crcs_mask(pipe_crcs, j, crcs[1]); + if (!test_only) + collect_crcs_mask(pipe_crcs, j, crcs[1]); refresh_primaries(display); - commit_display(display, j, nonblocking); - collect_crcs_mask(pipe_crcs, j, crcs[2]); + commit_display(display, j, nonblocking, test_only); + + if (!test_only) + collect_crcs_mask(pipe_crcs, j, crcs[2]); event_mask = set_combinations(display, i, &fbs[0]); if (!event_mask) continue; - commit_display(display, event_mask, nonblocking); - collect_crcs_mask(pipe_crcs, i, crcs[3]); + commit_display(display, event_mask, nonblocking, test_only); + + if (!test_only) + collect_crcs_mask(pipe_crcs, i, crcs[3]); refresh_primaries(display); - commit_display(display, i, nonblocking); - collect_crcs_mask(pipe_crcs, i, crcs[4]); + commit_display(display, i, nonblocking, test_only); + + if (!test_only) + collect_crcs_mask(pipe_crcs, i, crcs[4]); if (!is_i915_device(display->drm_fd)) continue; - for (int k = 0; k < I915_MAX_PIPES; k++) { - if (i & (1 << k)) { - igt_assert_crc_equal(&crcs[0][k], &crcs[3][k]); - igt_assert_crc_equal(&crcs[0][k], &crcs[4][k]); - } + if (!test_only) { + for (int k = 0; k < I915_MAX_PIPES; k++) { + if (i & (1 << k)) { + igt_assert_crc_equal(&crcs[0][k], &crcs[3][k]); + igt_assert_crc_equal(&crcs[0][k], &crcs[4][k]); + } - if (j & (1 << k)) - igt_assert_crc_equal(&crcs[1][k], &crcs[2][k]); + if (j & (1 << k)) + igt_assert_crc_equal(&crcs[1][k], &crcs[2][k]); + } } } } cleanup: set_combinations(display, 0, NULL); - igt_display_commit2(display, COMMIT_ATOMIC); + + if (!test_only) + igt_display_commit2(display, COMMIT_ATOMIC); if (is_i915_device(display->drm_fd)) for_each_pipe(display, i) @@ -614,7 +668,8 @@ cleanup: } -static void run_modeset_transition(igt_display_t *display, int requested_outputs, bool nonblocking) +static void run_modeset_transition(igt_display_t *display, int requested_outputs, + bool nonblocking, bool test_only) { igt_output_t *outputs[I915_MAX_PIPES] = {}; int num_outputs = 0; @@ -642,7 +697,7 @@ static void run_modeset_transition(igt_display_t *display, int requested_outputs "Should have at least %i outputs, found %i\n", requested_outputs, num_outputs); - run_modeset_tests(display, requested_outputs, nonblocking); + run_modeset_tests(display, requested_outputs, nonblocking, test_only); } igt_main @@ -673,26 +728,48 @@ igt_main igt_subtest("plane-all-transition") for_each_pipe_with_valid_output(&display, pipe, output) - run_transition_test(&display, pipe, output, TRANSITION_PLANES, false); + run_transition_test(&display, pipe, output, TRANSITION_PLANES, false, false); + + igt_subtest("plane-all-transition-test-only") + 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); + run_transition_test(&display, pipe, output, TRANSITION_PLANES, true, false); + + igt_subtest("plane-all-transition-nonblocking-test-only") + 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); + run_transition_test(&display, pipe, output, TRANSITION_MODESET, false, false); + + igt_subtest("plane-all-modeset-transition-test-only") + 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); + run_transition_test(&display, pipe, output, TRANSITION_MODESET_DISABLE, false, false); + + igt_subtest("plane-toggle-modeset-transition-test-only") + for_each_pipe_with_valid_output(&display, pipe, output) + run_transition_test(&display, pipe, output, TRANSITION_MODESET_DISABLE, false, true); for (i = 1; i <= I915_MAX_PIPES; i++) { igt_subtest_f("%ix-modeset-transitions", i) - run_modeset_transition(&display, i, false); + run_modeset_transition(&display, i, false, false); + + igt_subtest_f("%ix-modeset-transitions-test-only", i) + run_modeset_transition(&display, i, false, true); igt_subtest_f("%ix-modeset-transitions-nonblocking", i) - run_modeset_transition(&display, i, true); + run_modeset_transition(&display, i, true, false); + + igt_subtest_f("%ix-modeset-transitions-nonblocking-test-only", i) + run_modeset_transition(&display, i, true, true); } igt_fixture { -- 2.7.4 _______________________________________________ Intel-gfx mailing list Intel-gfx@xxxxxxxxxxxxxxxxxxxxx https://lists.freedesktop.org/mailman/listinfo/intel-gfx