From patchwork Mon Nov 14 09:59:25 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gustavo Padovan X-Patchwork-Id: 9426975 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 0852760471 for ; Mon, 14 Nov 2016 10:00:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F1CA6286FE for ; Mon, 14 Nov 2016 10:00:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E6886286D4; Mon, 14 Nov 2016 10:00:45 +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=-3.7 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RCVD_IN_SORBS_SPAM 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 90BCE286D4 for ; Mon, 14 Nov 2016 10:00:45 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 052956E3C8; Mon, 14 Nov 2016 10:00:09 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-pf0-f196.google.com (mail-pf0-f196.google.com [209.85.192.196]) by gabe.freedesktop.org (Postfix) with ESMTPS id 295DC6E3C5; Mon, 14 Nov 2016 10:00:07 +0000 (UTC) Received: by mail-pf0-f196.google.com with SMTP id c4so3385637pfb.3; Mon, 14 Nov 2016 02:00:07 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=b+Sg0xAq/3CSQC80Mwj+VsaSYQd4UGvLIZjkywsUr38=; b=VBvkOVQGVxKizFuBBAb17JRFumzOQRm2Q07b4VeLWjuQND53fH+sepc7amuhZ47ZiM 8TyM/G7tovm5WPaGPZIb6VGzG3Igv3OLjUp9dEd5SCh8YHcEQ61p5XsZ6it8coYwvJ5P /6dagfT3kvf1AtfzfRcJUmIv+CWcNbMuUrw9Xa3U/U7W7pLvrPjNZoTz/33dNbayxupi 74iKovHRxk0M1oZUd4INCOpFGminRDoeEUl7dUbXOw45N0aY+aRpyLtGz/efnZDY+BfS ozV4GAJBWh/yUQOhXWWtXoJrDKLKEJpxSukc/jZwLTVx6xOQy1b9qs/j/iH6/WPGqQOV hy2w== X-Gm-Message-State: ABUngveKwwEiGZrPNRsQKVfsDke3Pi1qQobw12CGdkBaFqpjvgmWuiXOruGcYc+1L3gy/Q== X-Received: by 10.99.174.4 with SMTP id q4mr4112256pgf.178.1479117606608; Mon, 14 Nov 2016 02:00:06 -0800 (PST) Received: from jade.nodan1.kt.home.ne.jp (202-72-64-164.koalanet.ne.jp. [202.72.64.164]) by smtp.gmail.com with ESMTPSA id p125sm14320235pfg.33.2016.11.14.02.00.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 14 Nov 2016 02:00:06 -0800 (PST) From: Gustavo Padovan To: intel-gfx@lists.freedesktop.org Date: Mon, 14 Nov 2016 18:59:25 +0900 Message-Id: <1479117566-17709-14-git-send-email-gustavo@padovan.org> X-Mailer: git-send-email 2.5.5 In-Reply-To: <1479117566-17709-1-git-send-email-gustavo@padovan.org> References: <1479117566-17709-1-git-send-email-gustavo@padovan.org> Cc: Gustavo Padovan , dri-devel@lists.freedesktop.org Subject: [Intel-gfx] [PATCH 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 --- tests/kms_atomic_transition.c | 92 ++++++++++++++++++++++++++++++++++++++----- 1 file changed, 82 insertions(+), 10 deletions(-) diff --git a/tests/kms_atomic_transition.c b/tests/kms_atomic_transition.c index 507f526..54fc9da 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,78 @@ 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; + + 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], 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 +208,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; @@ -233,10 +310,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) { @@ -260,19 +335,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); } @@ -280,6 +350,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)