From patchwork Thu Dec 7 09:49:35 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maarten Lankhorst X-Patchwork-Id: 10097941 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 539AC602BF for ; Thu, 7 Dec 2017 09:49:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 441EF28D42 for ; Thu, 7 Dec 2017 09:49:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 38CFB293E1; Thu, 7 Dec 2017 09:49:42 +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 BE49B28D42 for ; Thu, 7 Dec 2017 09:49:41 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 082806E7A7; Thu, 7 Dec 2017 09:49:41 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mblankhorst.nl (mblankhorst.nl [IPv6:2a02:2308::216:3eff:fe92:dfa3]) by gabe.freedesktop.org (Postfix) with ESMTPS id 376BA6E7A7 for ; Thu, 7 Dec 2017 09:49:39 +0000 (UTC) From: Maarten Lankhorst To: intel-gfx@lists.freedesktop.org Date: Thu, 7 Dec 2017 10:49:35 +0100 Message-Id: <20171207094935.21445-1-maarten.lankhorst@linux.intel.com> X-Mailer: git-send-email 2.15.1 Subject: [Intel-gfx] [PATCH i-g-t for CI] tests/kms_vblank: Add test to ensure DRM_CAP_CRTC_IN_VBLANK_EVENT works correctly 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 This was implemented correctly only on the atomic ioctl before, but it should really be working on all 3 ioctl's involved, so ensure we always set crtc_id correctly with a testcase. The following events are tested: - Pageflip with event. - Atomic commit with event. - wait_vblank ioctl with event. Signed-off-by: Maarten Lankhorst Reviewed-by: Daniel Vetter --- tests/kms_vblank.c | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 56 insertions(+), 4 deletions(-) diff --git a/tests/kms_vblank.c b/tests/kms_vblank.c index b7d570cc96fd..97ccacc4aab9 100644 --- a/tests/kms_vblank.c +++ b/tests/kms_vblank.c @@ -120,7 +120,6 @@ static void run_test(data_t *data, int fd, void (*testfunc)(data_t *, int, int)) igt_display_t *display = &data->display; igt_output_t *output; enum pipe p; - unsigned int valid_tests = 0; for_each_pipe_with_valid_output(display, p, output) { data->pipe = p; @@ -161,11 +160,60 @@ static void run_test(data_t *data, int fd, void (*testfunc)(data_t *, int, int)) /* cleanup what prepare_crtc() has done */ cleanup_crtc(data, fd, output); - valid_tests++; } +} + +static void crtc_id_subtest(data_t *data, int fd) +{ + igt_display_t *display = &data->display; + igt_output_t *output; + enum pipe p; + + for_each_pipe_with_valid_output(display, p, output) { + struct drm_event_vblank buf; + const uint32_t pipe_id_flag = kmstest_get_vbl_flag(p); + unsigned crtc_id, expected_crtc_id; + uint64_t val; + union drm_wait_vblank vbl; + + crtc_id = display->pipes[p].crtc_id; + if (drmGetCap(display->drm_fd, DRM_CAP_CRTC_IN_VBLANK_EVENT, &val) == 0) + expected_crtc_id = crtc_id; + else + expected_crtc_id = 0; + + data->pipe = p; + prepare_crtc(data, fd, output); + + memset(&vbl, 0, sizeof(vbl)); + vbl.request.type = DRM_VBLANK_RELATIVE | DRM_VBLANK_EVENT; + vbl.request.type |= pipe_id_flag; + vbl.request.sequence = 1; + igt_assert_eq(wait_vblank(fd, &vbl), 0); + + igt_assert_eq(read(fd, &buf, sizeof(buf)), sizeof(buf)); + igt_assert_eq(buf.crtc_id, expected_crtc_id); + + do_or_die(drmModePageFlip(fd, crtc_id, + data->primary_fb.fb_id, + DRM_MODE_PAGE_FLIP_EVENT, NULL)); + + igt_assert_eq(read(fd, &buf, sizeof(buf)), sizeof(buf)); + igt_assert_eq(buf.crtc_id, expected_crtc_id); + + if (display->is_atomic) { + igt_plane_t *primary = igt_output_get_plane(output, 0); + + igt_plane_set_fb(primary, &data->primary_fb); + igt_display_commit_atomic(display, DRM_MODE_PAGE_FLIP_EVENT, NULL); - igt_require_f(valid_tests, - "no valid crtc/connector combinations found\n"); + igt_assert_eq(read(fd, &buf, sizeof(buf)), sizeof(buf)); + igt_assert_eq(buf.crtc_id, expected_crtc_id); + } + + cleanup_crtc(data, fd, output); + return; + } } static void accuracy(data_t *data, int fd, int nchildren) @@ -298,8 +346,12 @@ igt_main fd = drm_open_driver(DRIVER_ANY); kmstest_set_vt_graphics_mode(); igt_display_init(&data.display, fd); + igt_display_require_output(&data.display); } + igt_subtest("crtc-id") + crtc_id_subtest(&data, fd); + for (f = funcs; f->name; f++) { for (m = modes; m->name; m++) { if (m->flags & ~f->valid)