From patchwork Mon Nov 14 09:59:22 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gustavo Padovan X-Patchwork-Id: 9426983 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 39A3860471 for ; Mon, 14 Nov 2016 10:01:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2C3B3286D4 for ; Mon, 14 Nov 2016 10:01:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1F892286FE; Mon, 14 Nov 2016 10:01:01 +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=unavailable 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 A0BED286D4 for ; Mon, 14 Nov 2016 10:01:00 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 9FE056E3CE; Mon, 14 Nov 2016 10:00:09 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pg0-f68.google.com (mail-pg0-f68.google.com [74.125.83.68]) by gabe.freedesktop.org (Postfix) with ESMTPS id 2908B6E3B3; Mon, 14 Nov 2016 09:59:58 +0000 (UTC) Received: by mail-pg0-f68.google.com with SMTP id p66so8627519pga.2; Mon, 14 Nov 2016 01:59:58 -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=0rRqR/mZ1RPm3jJgXuDqCYCKxRjh/PROuCuDzCy2mKA=; b=D5Xzu3UwpOfjHRquhgQFu2TRiytgi/o8UPH/zlCD2jUoCtBk3KqkQDiAzPUXW3gJ62 /P/fiyjVgjDssBVqr9RRZjw9HmVfu8YE1PFSzoaLl+YJzF7CzYXs5dfNgyAiUbWlq8V2 UM1nyCc5sd3+AJcL/AC4/HCZh5RWtdoTB8XrPOwo0Z+L44Zkws04BsWNcbdWgqQkpYD+ 2+gN9jlmwSEWVb8eaUzcm/TQ8f2LN+vB4bGDxoNqjx9criiEEE+z+c6tjPkTvdxXWuTH mPqNwhJG1QY60Qbs/bveEnCP/eIFN6+YOtALOh+QFOc3viou4X7LhZI5UM+Rfdo3PcKd 2juA== X-Gm-Message-State: ABUngvdXJu7LzCwg+XfdoQ01v6jIZUYeNuDDi0e1Li4qa5a98i23S9mTgAOH8Z/6gIHynQ== X-Received: by 10.98.100.66 with SMTP id y63mr34793303pfb.49.1479117597414; Mon, 14 Nov 2016 01:59:57 -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.01.59.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 14 Nov 2016 01:59:57 -0800 (PST) From: Gustavo Padovan To: intel-gfx@lists.freedesktop.org Subject: [PATCH 08/12] tests/kms_atomic: stress possible fence settings Date: Mon, 14 Nov 2016 18:59:22 +0900 Message-Id: <1479117566-17709-11-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 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Gustavo Padovan Signed-off-by: Gustavo Padovan --- tests/kms_atomic.c | 124 +++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 115 insertions(+), 9 deletions(-) diff --git a/tests/kms_atomic.c b/tests/kms_atomic.c index 8b648eb..58fc0dd 100644 --- a/tests/kms_atomic.c +++ b/tests/kms_atomic.c @@ -44,6 +44,7 @@ #include "drmtest.h" #include "igt.h" #include "igt_aux.h" +#include "sw_sync.h" #ifndef DRM_CLIENT_CAP_ATOMIC #define DRM_CLIENT_CAP_ATOMIC 3 @@ -126,6 +127,7 @@ struct kms_atomic_plane_state { uint32_t fb_id; /* 0 to disable */ uint32_t src_x, src_y, src_w, src_h; /* 16.16 fixed-point */ uint32_t crtc_x, crtc_y, crtc_w, crtc_h; /* normal integers */ + int32_t fence_fd; }; struct kms_atomic_crtc_state { @@ -133,6 +135,7 @@ struct kms_atomic_crtc_state { uint32_t obj; int idx; bool active; + uint64_t out_fence_ptr; struct kms_atomic_blob mode; }; @@ -190,11 +193,13 @@ static uint32_t blob_duplicate(int fd, uint32_t id_orig) crtc_populate_req(crtc, req); \ plane_populate_req(plane, req); \ do_atomic_commit((crtc)->state->desc->fd, req, flags); \ - crtc_check_current_state(crtc, plane, relax); \ - plane_check_current_state(plane, relax); \ + if (!(flags & DRM_MODE_ATOMIC_TEST_ONLY)) { \ + crtc_check_current_state(crtc, plane, relax); \ + plane_check_current_state(plane, relax); \ + } \ } -#define crtc_commit_atomic_err(crtc, plane, crtc_old, plane_old, req, relax, e) { \ +#define crtc_commit_atomic_err(crtc, plane, crtc_old, plane_old, req, flags, relax, e) { \ drmModeAtomicSetCursor(req, 0); \ crtc_populate_req(crtc, req); \ plane_populate_req(plane, req); \ @@ -299,6 +304,9 @@ find_connector(struct kms_atomic_state *state, static void plane_populate_req(struct kms_atomic_plane_state *plane, drmModeAtomicReq *req) { + if (plane->fence_fd) + plane_set_prop(req, plane, IGT_PLANE_IN_FENCE_FD, plane->fence_fd); + plane_set_prop(req, plane, IGT_PLANE_CRTC_ID, plane->crtc_id); plane_set_prop(req, plane, IGT_PLANE_FB_ID, plane->fb_id); plane_set_prop(req, plane, IGT_PLANE_SRC_X, plane->src_x); @@ -424,6 +432,10 @@ find_plane(struct kms_atomic_state *state, enum plane_type type, static void crtc_populate_req(struct kms_atomic_crtc_state *crtc, drmModeAtomicReq *req) { + if (crtc->out_fence_ptr) + crtc_set_prop(req, crtc, IGT_CRTC_OUT_FENCE_PTR, + crtc->out_fence_ptr); + crtc_set_prop(req, crtc, IGT_CRTC_MODE_ID, crtc->mode.id); crtc_set_prop(req, crtc, IGT_CRTC_ACTIVE, crtc->active); } @@ -986,6 +998,7 @@ static void plane_invalid_params(struct kms_atomic_crtc_state *crtc, uint32_t format = plane_get_igt_format(&plane); drmModeAtomicReq *req = drmModeAtomicAlloc(); struct igt_fb fb; + int timeline, fence_fd; /* Pass a series of invalid object IDs for the FB ID. */ plane.fb_id = plane.obj; @@ -1024,6 +1037,23 @@ static void plane_invalid_params(struct kms_atomic_crtc_state *crtc, plane_commit_atomic_err(&plane, plane_old, req, ATOMIC_RELAX_NONE, EINVAL); + /* invalid fence fd */ + plane.fence_fd = plane.state->desc->fd; + plane.crtc_id = plane_old->crtc_id; + plane_commit_atomic_err(&plane, plane_old, req, + ATOMIC_RELAX_NONE, EINVAL); + + /* Valid fence_fd but invalid CRTC */ + timeline = sw_sync_timeline_create(); + fence_fd = sw_sync_fence_create(timeline, 1); + plane.fence_fd = fence_fd; + plane.crtc_id = ~0U; + plane_commit_atomic_err(&plane, plane_old, req, + ATOMIC_RELAX_NONE, EINVAL); + close(fence_fd); + close(timeline); + + plane.fence_fd = -1; plane.crtc_id = plane_old->crtc_id; plane_commit_atomic(&plane, req, ATOMIC_RELAX_NONE); @@ -1058,27 +1088,98 @@ static void crtc_invalid_params(struct kms_atomic_crtc_state *crtc_old, { struct kms_atomic_crtc_state crtc = *crtc_old; drmModeAtomicReq *req = drmModeAtomicAlloc(); + int timeline, fence_fd, *out_fence; igt_assert(req); /* Pass a series of invalid object IDs for the mode ID. */ crtc.mode.id = plane->obj; - crtc_commit_atomic_err(&crtc, plane, crtc_old, plane, req, + crtc_commit_atomic_err(&crtc, plane, crtc_old, plane, req, 0, ATOMIC_RELAX_NONE, EINVAL); crtc.mode.id = crtc.obj; - crtc_commit_atomic_err(&crtc, plane, crtc_old, plane, req, + crtc_commit_atomic_err(&crtc, plane, crtc_old, plane, req, 0, ATOMIC_RELAX_NONE, EINVAL); crtc.mode.id = conn->obj; - crtc_commit_atomic_err(&crtc, plane, crtc_old, plane, req, + crtc_commit_atomic_err(&crtc, plane, crtc_old, plane, req, 0, ATOMIC_RELAX_NONE, EINVAL); crtc.mode.id = plane->fb_id; - crtc_commit_atomic_err(&crtc, plane, crtc_old, plane, req, + crtc_commit_atomic_err(&crtc, plane, crtc_old, plane, req, 0, ATOMIC_RELAX_NONE, EINVAL); + /* invalid out_fence_ptr */ + crtc.mode.id = crtc_old->mode.id; + crtc.out_fence_ptr = (uint64_t) crtc_invalid_params; + crtc_commit_atomic_err(&crtc, plane, crtc_old, plane, req, 0, + ATOMIC_RELAX_NONE, EFAULT); + + /* invalid out_fence_ptr */ + crtc.mode.id = crtc_old->mode.id; + crtc.out_fence_ptr = (uint64_t) 0x8; + crtc_commit_atomic_err(&crtc, plane, crtc_old, plane, req, 0, + ATOMIC_RELAX_NONE, EFAULT); + crtc.out_fence_ptr = (uint64_t) 0; + + /* valid in fence but not allowed prop on crtc */ + timeline = sw_sync_timeline_create(); + fence_fd = sw_sync_fence_create(timeline, 1); + plane->fence_fd = fence_fd; + crtc.active = false; + crtc_commit_atomic_err(&crtc, plane, crtc_old, plane, req, 0, + ATOMIC_RELAX_NONE, EINVAL); + + out_fence = malloc(sizeof(uint64_t)); + igt_assert(out_fence); + + + /* valid out fence ptr and flip event but not allowed prop on crtc */ + crtc.out_fence_ptr = (uint64_t) out_fence; + crtc_commit_atomic_err(&crtc, plane, crtc_old, plane, req, 0, + ATOMIC_RELAX_NONE, EINVAL); + + /* valid out fence ptr and flip event but not allowed prop on crtc */ + crtc_commit_atomic_err(&crtc, plane, crtc_old, plane, req, + DRM_MODE_PAGE_FLIP_EVENT, + ATOMIC_RELAX_NONE, EINVAL); + + /* valid page flip event but not allowed prop on crtc */ + crtc.out_fence_ptr = (uint64_t) 0; + crtc_commit_atomic_err(&crtc, plane, crtc_old, plane, req, + DRM_MODE_PAGE_FLIP_EVENT, + ATOMIC_RELAX_NONE, EINVAL); + crtc.active = true; + + /* valid out fence ptr and flip event but invalid prop on crtc */ + crtc.out_fence_ptr = (uint64_t) out_fence; + crtc.mode.id = plane->fb_id; + crtc_commit_atomic_err(&crtc, plane, crtc_old, plane, req, 0, + ATOMIC_RELAX_NONE, EINVAL); + + /* valid out fence ptr and flip event but invalid prop on crtc */ + crtc_commit_atomic_err(&crtc, plane, crtc_old, plane, req, + DRM_MODE_PAGE_FLIP_EVENT, + ATOMIC_RELAX_NONE, EINVAL); + + /* valid page flip event but invalid prop on crtc */ + crtc.out_fence_ptr = (uint64_t) 0; + crtc_commit_atomic_err(&crtc, plane, crtc_old, plane, req, + DRM_MODE_PAGE_FLIP_EVENT, + ATOMIC_RELAX_NONE, EINVAL); + + /* successful TEST_ONLY with fences set */ + plane->fence_fd = fence_fd; crtc.mode.id = crtc_old->mode.id; + crtc_commit_atomic(&crtc, plane, req, ATOMIC_RELAX_NONE, + DRM_MODE_ATOMIC_TEST_ONLY); + igt_assert(*out_fence == -1); + close(fence_fd); + close(timeline); + + /* reset fences */ + plane->fence_fd = -1; + crtc.out_fence_ptr = (uint64_t) 0; crtc_commit_atomic(&crtc, plane, req, ATOMIC_RELAX_NONE, 0); /* Create a blob which is the wrong size to be a valid mode. */ @@ -1086,7 +1187,7 @@ static void crtc_invalid_params(struct kms_atomic_crtc_state *crtc_old, crtc.mode.data, sizeof(struct drm_mode_modeinfo) - 1, &crtc.mode.id)); - crtc_commit_atomic_err(&crtc, plane, crtc_old, plane, req, + crtc_commit_atomic_err(&crtc, plane, crtc_old, plane, req, 0, ATOMIC_RELAX_NONE, EINVAL); @@ -1094,12 +1195,17 @@ static void crtc_invalid_params(struct kms_atomic_crtc_state *crtc_old, crtc.mode.data, sizeof(struct drm_mode_modeinfo) + 1, &crtc.mode.id)); - crtc_commit_atomic_err(&crtc, plane, crtc_old, plane, req, + crtc_commit_atomic_err(&crtc, plane, crtc_old, plane, req, 0, ATOMIC_RELAX_NONE, EINVAL); + /* out fence ptr but not page flip event */ + crtc.out_fence_ptr = (uint64_t) out_fence; + crtc_commit_atomic(crtc_old, plane, req, ATOMIC_RELAX_NONE, 0); + /* Restore the CRTC and check the state matches the old. */ crtc_commit_atomic(crtc_old, plane, req, ATOMIC_RELAX_NONE, 0); + free(out_fence); drmModeAtomicFree(req); }