From patchwork Fri Dec 30 12:00:38 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mika Kahola X-Patchwork-Id: 9492063 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id CEC8660417 for ; Fri, 30 Dec 2016 12:05:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BD3811FF29 for ; Fri, 30 Dec 2016 12:05:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B184E22638; Fri, 30 Dec 2016 12:05:27 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 00B971FF29 for ; Fri, 30 Dec 2016 12:05:25 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id D33C86E256; Fri, 30 Dec 2016 12:05:23 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by gabe.freedesktop.org (Postfix) with ESMTPS id AAF506E252 for ; Fri, 30 Dec 2016 12:04:21 +0000 (UTC) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga101.fm.intel.com with ESMTP; 30 Dec 2016 04:04:21 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.33,432,1477983600"; d="scan'208";a="24384611" Received: from sorvi.fi.intel.com ([10.237.72.109]) by orsmga002.jf.intel.com with ESMTP; 30 Dec 2016 04:04:20 -0800 From: Mika Kahola To: intel-gfx@lists.freedesktop.org Date: Fri, 30 Dec 2016 14:00:38 +0200 Message-Id: <1483099241-15898-3-git-send-email-mika.kahola@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1483099241-15898-1-git-send-email-mika.kahola@intel.com> References: <1483099241-15898-1-git-send-email-mika.kahola@intel.com> Subject: [Intel-gfx] [PATCH i-g-t 2/5] tests/kms_atomic_transition: Add TEST_ONLY flag X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Virus-Scanned: ClamAV using ClamSMTP Add TEST_ONLY flag to test atomic transition display commits without actual real-life commit. Signed-off-by: Mika Kahola --- 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 {