From patchwork Wed Dec 14 09:05:08 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Foss X-Patchwork-Id: 9473863 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 08E8260823 for ; Wed, 14 Dec 2016 09:05:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id ED1F22866F for ; Wed, 14 Dec 2016 09:05:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E1B2C286F9; Wed, 14 Dec 2016 09:05:30 +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, UNPARSEABLE_RELAY 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 88DAE2866F for ; Wed, 14 Dec 2016 09:05:30 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 1F3BB6E75A; Wed, 14 Dec 2016 09:05:28 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from bhuna.collabora.co.uk (bhuna.collabora.co.uk [46.235.227.227]) by gabe.freedesktop.org (Postfix) with ESMTPS id A68AB6E75A for ; Wed, 14 Dec 2016 09:05:21 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: robertfoss) with ESMTPSA id 0BADD266F6F From: Robert Foss To: intel-gfx@lists.freedesktop.org, Gustavo Padovan , Brian Starkey , Daniel Vetter , Tomeu Vizoso Date: Wed, 14 Dec 2016 04:05:08 -0500 Message-Id: <20161214090509.15716-12-robert.foss@collabora.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20161214090509.15716-1-robert.foss@collabora.com> References: <20161214090509.15716-1-robert.foss@collabora.com> Cc: Gustavo Padovan Subject: [Intel-gfx] [PATCH i-g-t v2 11/12] tests/kms_atomic_transition: add in_fences tests 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 From: Gustavo Padovan Signed-off-by: Gustavo Padovan Signed-off-by: Robert Foss --- tests/kms_atomic_transition.c | 95 ++++++++++++++++++++++++++++++++++++++----- 1 file changed, 85 insertions(+), 10 deletions(-) diff --git a/tests/kms_atomic_transition.c b/tests/kms_atomic_transition.c index 08f9499f..c2ec89d7 100644 --- a/tests/kms_atomic_transition.c +++ b/tests/kms_atomic_transition.c @@ -23,7 +23,9 @@ #include "igt.h" #include "drmtest.h" +#include "sw_sync.h" #include +#include #include #include #include @@ -111,6 +113,81 @@ enum transition_type { TRANSITION_MODESET_DISABLE, }; +int timeline[IGT_MAX_PLANES]; +pthread_t thread[IGT_MAX_PLANES]; +int seqno[IGT_MAX_PLANES]; + +static void prepare_fencing(igt_display_t *display, enum pipe pipe) +{ + igt_plane_t *plane; + + igt_require_sw_sync(); + + for_each_plane_on_pipe(display, pipe, plane) + timeline[plane->index] = sw_sync_timeline_create(); +} + +static void unprepare_fencing(igt_display_t *display, enum pipe pipe) +{ + igt_plane_t *plane; + + for_each_plane_on_pipe(display, pipe, plane) + close(timeline[plane->index]); +} + +static void *fence_inc_thread(void *arg) +{ + int t = *((int *) arg); + + pthread_detach(pthread_self()); + + usleep(5000); + sw_sync_timeline_inc(t, 1); + return NULL; +} + +static void configure_fencing(igt_display_t *display, enum pipe pipe) +{ + igt_plane_t *plane; + int i, fd, ret; + + for_each_plane_on_pipe(display, pipe, plane) { + + if (!plane->fb) + continue; + + i = plane->index; + + seqno[i]++; + fd = sw_sync_fence_create(timeline[i], seqno[i]); + igt_plane_set_fence_fd(plane, fd); + ret = pthread_create(&thread[i], NULL, fence_inc_thread, &timeline[i]); + igt_assert_eq(ret, 0); + } +} + +static void clear_fencing(igt_display_t *display, enum pipe pipe) +{ + igt_plane_t *plane; + + for_each_plane_on_pipe(display, pipe, plane) + igt_plane_set_fence_fd(plane, -1); +} + +static void atomic_commit(igt_display_t *display, enum pipe pipe, unsigned int flags, void *data, bool fencing, int *out_fence) +{ + if (fencing) { + configure_fencing(display, pipe); + igt_pipe_set_out_fence_ptr(&display->pipes[pipe], + (int64_t *) out_fence); + } + + igt_display_commit_atomic(display, flags, data); + + if (fencing) + clear_fencing(display, pipe); +} + /* * 1. Set primary plane to a known fb. * 2. Make sure getcrtc returns the correct fb id. @@ -134,6 +211,9 @@ run_transition_test(igt_display_t *display, enum pipe pipe, igt_output_t *output unsigned flags = DRM_MODE_PAGE_FLIP_EVENT; int out_fence, ret; + if (fencing) + prepare_fencing(display, pipe); + if (nonblocking) flags |= DRM_MODE_ATOMIC_NONBLOCK; @@ -234,10 +314,8 @@ 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); + atomic_commit(display, pipe, flags, (void *)(unsigned long)i, fencing, &out_fence); - igt_display_commit_atomic(display, flags, (void *)(unsigned long)i); drmHandleEvent(display->drm_fd, &drm_events); if (type == TRANSITION_MODESET_DISABLE) { @@ -262,19 +340,14 @@ 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); + atomic_commit(display, pipe, flags, (void *)(unsigned long)i, fencing, &out_fence); drmHandleEvent(display->drm_fd, &drm_events); wm_setup_plane(display, pipe, i, parms); if (type == TRANSITION_MODESET) igt_output_override_mode(output, NULL); - if (fencing) - igt_pipe_set_out_fence_ptr(&display->pipes[pipe], &out_fence); - + atomic_commit(display, pipe, flags, (void *)(unsigned long)i, fencing, &out_fence); igt_display_commit_atomic(display, flags, (void *)(unsigned long)i); drmHandleEvent(display->drm_fd, &drm_events); } @@ -282,6 +355,8 @@ run_transition_test(igt_display_t *display, enum pipe pipe, igt_output_t *output } cleanup: + unprepare_fencing(display, pipe); + igt_output_set_pipe(output, PIPE_NONE); for_each_plane_on_pipe(display, pipe, plane)