From patchwork Wed Feb 1 18:12:30 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Foss X-Patchwork-Id: 9550501 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 D195B60415 for ; Wed, 1 Feb 2017 18:12:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C248128425 for ; Wed, 1 Feb 2017 18:12:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B72C528467; Wed, 1 Feb 2017 18:12:56 +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 2574228425 for ; Wed, 1 Feb 2017 18:12:56 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 40ACE6E8A5; Wed, 1 Feb 2017 18:12:53 +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 DEB1F6E8A7 for ; Wed, 1 Feb 2017 18:12:51 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: robertfoss) with ESMTPSA id CCCED26A194 From: Robert Foss To: intel-gfx@lists.freedesktop.org, Gustavo Padovan , Brian Starkey , Daniel Vetter , Tomeu Vizoso Date: Wed, 1 Feb 2017 13:12:30 -0500 Message-Id: <20170201181233.12723-8-robert.foss@collabora.com> X-Mailer: git-send-email 2.11.0.453.g787f75f05 In-Reply-To: <20170201181233.12723-1-robert.foss@collabora.com> References: <20170201181233.12723-1-robert.foss@collabora.com> Cc: Gustavo Padovan Subject: [Intel-gfx] [PATCH i-g-t v5 07/10] tests/kms_atomic: stress possible fence settings 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 Reviewed-by: Brian Starkey --- tests/kms_atomic.c | 187 ++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 177 insertions(+), 10 deletions(-) diff --git a/tests/kms_atomic.c b/tests/kms_atomic.c index 8df51ccd..e794a62b 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; + int32_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); @@ -433,6 +441,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, + (uint64_t) 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); } @@ -1061,6 +1073,37 @@ static void plane_invalid_params(struct kms_atomic_crtc_state *crtc, drmModeAtomicFree(req); } +static void plane_invalid_params_fence(struct kms_atomic_crtc_state *crtc, + struct kms_atomic_plane_state *plane_old, + struct kms_atomic_connector_state *conn) +{ + struct kms_atomic_plane_state plane = *plane_old; + drmModeAtomicReq *req = drmModeAtomicAlloc(); + int timeline, fence_fd; + + igt_require_sw_sync(); + + /* 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_timeline_create_fence(timeline, 1); + plane.fence_fd = fence_fd; + plane.crtc_id = ~0U; + plane_commit_atomic_err(&plane, plane_old, req, + ATOMIC_RELAX_NONE, EINVAL); + + plane.fence_fd = -1; + close(fence_fd); + close(timeline); + + drmModeAtomicFree(req); +} + static void crtc_invalid_params(struct kms_atomic_crtc_state *crtc_old, struct kms_atomic_plane_state *plane, struct kms_atomic_connector_state *conn) @@ -1072,30 +1115,32 @@ static void crtc_invalid_params(struct kms_atomic_crtc_state *crtc_old, /* 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); + /* successful TEST_ONLY with fences set */ crtc.mode.id = crtc_old->mode.id; - crtc_commit_atomic(&crtc, plane, req, ATOMIC_RELAX_NONE, 0); + crtc_commit_atomic(&crtc, plane, req, ATOMIC_RELAX_NONE, + DRM_MODE_ATOMIC_TEST_ONLY); /* Create a blob which is the wrong size to be a valid mode. */ do_or_die(drmModeCreatePropertyBlob(crtc.state->desc->fd, 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); @@ -1103,15 +1148,108 @@ 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); + /* Restore the CRTC and check the state matches the old. */ crtc_commit_atomic(crtc_old, plane, req, ATOMIC_RELAX_NONE, 0); drmModeAtomicFree(req); } +static void crtc_invalid_params_fence(struct kms_atomic_crtc_state *crtc_old, + struct kms_atomic_plane_state *plane, + struct kms_atomic_connector_state *conn) +{ + struct kms_atomic_crtc_state crtc = *crtc_old; + drmModeAtomicReq *req = drmModeAtomicAlloc(); + int timeline, fence_fd, *out_fence; + + igt_require_sw_sync(); + + /* invalid out_fence_ptr */ + crtc.mode.id = crtc_old->mode.id; + crtc.out_fence_ptr = (int32_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 = (int32_t *) 0x8; + crtc_commit_atomic_err(&crtc, plane, crtc_old, plane, req, 0, + ATOMIC_RELAX_NONE, EFAULT); + crtc.out_fence_ptr = (int32_t *) 0; + + /* valid in fence but not allowed prop on crtc */ + timeline = sw_sync_timeline_create(); + fence_fd = sw_sync_timeline_create_fence(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 = (int32_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 = (int32_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 = (int32_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 = (int32_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 = (int32_t *) 0; + crtc_commit_atomic(&crtc, plane, req, ATOMIC_RELAX_NONE, 0); + + /* out fence ptr but not page flip event */ + crtc.out_fence_ptr = (int32_t *) out_fence; + crtc_commit_atomic(crtc_old, plane, req, ATOMIC_RELAX_NONE, 0); + + close(*out_fence); + free(out_fence); + drmModeAtomicFree(req); +} + /* Abuse the atomic ioctl directly in order to test various invalid conditions, * which the libdrm wrapper won't allow us to create. */ static void atomic_invalid_params(struct kms_atomic_crtc_state *crtc, @@ -1315,6 +1453,20 @@ igt_main atomic_state_free(scratch); } + igt_subtest("plane_invalid_params_fence") { + struct kms_atomic_state *scratch = atomic_state_dup(current); + struct kms_atomic_crtc_state *crtc = find_crtc(scratch, true); + struct kms_atomic_plane_state *plane = + find_plane(current, PLANE_TYPE_PRIMARY, crtc); + struct kms_atomic_connector_state *conn = + find_connector(scratch, crtc); + + igt_require(crtc); + igt_require(plane); + plane_invalid_params_fence(crtc, plane, conn); + atomic_state_free(scratch); + } + igt_subtest("crtc_invalid_params") { struct kms_atomic_state *scratch = atomic_state_dup(current); struct kms_atomic_crtc_state *crtc = find_crtc(scratch, true); @@ -1330,6 +1482,21 @@ igt_main atomic_state_free(scratch); } + igt_subtest("crtc_invalid_params_fence") { + struct kms_atomic_state *scratch = atomic_state_dup(current); + struct kms_atomic_crtc_state *crtc = find_crtc(scratch, true); + struct kms_atomic_plane_state *plane = + find_plane(scratch, NUM_PLANE_TYPE_PROPS, crtc); + struct kms_atomic_connector_state *conn = + find_connector(scratch, crtc); + + igt_require(crtc); + igt_require(plane); + igt_require(conn); + crtc_invalid_params_fence(crtc, plane, conn); + atomic_state_free(scratch); + } + igt_subtest("atomic_invalid_params") { struct kms_atomic_state *scratch = atomic_state_dup(current); struct kms_atomic_crtc_state *crtc = find_crtc(scratch, true);