From patchwork Fri Feb 3 22:45:30 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniele Ceraolo Spurio X-Patchwork-Id: 9555263 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 94DC3602B7 for ; Fri, 3 Feb 2017 22:45:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 784F326B39 for ; Fri, 3 Feb 2017 22:45:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6D28228135; Fri, 3 Feb 2017 22:45:50 +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 13C3326B39 for ; Fri, 3 Feb 2017 22:45:50 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 7439B6EBEF; Fri, 3 Feb 2017 22:45:49 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by gabe.freedesktop.org (Postfix) with ESMTPS id 653B36EBEF for ; Fri, 3 Feb 2017 22:45:48 +0000 (UTC) Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga104.fm.intel.com with ESMTP; 03 Feb 2017 14:45:47 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos; i="5.33,330,1477983600"; d="scan'208"; a="1102805549" Received: from relo-linux-1.fm.intel.com ([10.1.27.60]) by fmsmga001.fm.intel.com with ESMTP; 03 Feb 2017 14:45:47 -0800 From: Daniele Ceraolo Spurio To: intel-gfx@lists.freedesktop.org Date: Fri, 3 Feb 2017 14:45:30 -0800 Message-Id: <1486161930-11764-2-git-send-email-daniele.ceraolospurio@intel.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1486161930-11764-1-git-send-email-daniele.ceraolospurio@intel.com> References: <1486161930-11764-1-git-send-email-daniele.ceraolospurio@intel.com> Subject: [Intel-gfx] [PATCH i-g-t] tests/gem_exec_params: add test for exec_fence params 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 Added a subtest for invalid FENCE_IN usage, updated invalid-flag subtest and made the rsvd2 test skip when exec fences are available. Signed-off-by: Daniele Ceraolo Spurio --- lib/ioctl_wrappers.c | 29 +++++++++++++++++++++++++++++ lib/ioctl_wrappers.h | 1 + tests/gem_exec_fence.c | 14 -------------- tests/gem_exec_params.c | 24 +++++++++++++++++++++--- 4 files changed, 51 insertions(+), 17 deletions(-) diff --git a/lib/ioctl_wrappers.c b/lib/ioctl_wrappers.c index ccc5ccf..cd0c24b 100644 --- a/lib/ioctl_wrappers.c +++ b/lib/ioctl_wrappers.c @@ -1433,6 +1433,35 @@ bool gem_has_softpin(int fd) return has_softpin; } +#define LOCAL_PARAM_HAS_EXEC_FENCE 44 +/** + * gem_has_exec_fence: + * @fd: open i915 drm file descriptor + * + * Feature test macro to query whether in/out fence support in execbuffer is + * available. + * + * Returns: Whether fence support is available + */ +bool gem_has_exec_fence(int fd) +{ + static int has_exec_fence = -1; + + if (has_exec_fence < 0) { + struct drm_i915_getparam gp; + + memset(&gp, 0, sizeof(gp)); + gp.param = LOCAL_PARAM_HAS_EXEC_FENCE; + gp.value = &has_exec_fence; + + has_exec_fence = 0; + ioctl(fd, DRM_IOCTL_I915_GETPARAM, &gp, sizeof(gp)); + errno = 0; + } + + return has_exec_fence; +} + /** * gem_require_caching: * @fd: open i915 drm file descriptor diff --git a/lib/ioctl_wrappers.h b/lib/ioctl_wrappers.h index 5f3bbd1..64628df 100644 --- a/lib/ioctl_wrappers.h +++ b/lib/ioctl_wrappers.h @@ -164,6 +164,7 @@ uint64_t gem_aperture_size(int fd); uint64_t gem_global_aperture_size(int fd); uint64_t gem_mappable_aperture_size(void); bool gem_has_softpin(int fd); +bool gem_has_exec_fence(int fd); /* check functions which auto-skip tests by calling igt_skip() */ void gem_require_caching(int fd); diff --git a/tests/gem_exec_fence.c b/tests/gem_exec_fence.c index 3df436a..ddc5e7f 100644 --- a/tests/gem_exec_fence.c +++ b/tests/gem_exec_fence.c @@ -309,20 +309,6 @@ static void test_fence_flip(int i915) igt_skip_on_f(1, "no fence-in for atomic flips\n"); } -static bool gem_has_exec_fence(int fd) -{ - struct drm_i915_getparam gp; - int val = -1; - - memset(&gp, 0, sizeof(gp)); - gp.param = LOCAL_PARAM_HAS_EXEC_FENCE; - gp.value = &val; - - ioctl(fd, DRM_IOCTL_I915_GETPARAM, &gp); - - return val > 0; -} - igt_main { const struct intel_execution_engine *e; diff --git a/tests/gem_exec_params.c b/tests/gem_exec_params.c index f9a2054..68cdef6 100644 --- a/tests/gem_exec_params.c +++ b/tests/gem_exec_params.c @@ -45,6 +45,8 @@ #define LOCAL_I915_EXEC_BSD_RING1 (1<<13) #define LOCAL_I915_EXEC_BSD_RING2 (2<<13) #define LOCAL_I915_EXEC_RESOURCE_STREAMER (1<<15) +#define LOCAL_I915_EXEC_FENCE_IN (1 << 16) +#define LOCAL_I915_EXEC_FENCE_OUT (1 << 17) static bool has_ring(int fd, unsigned ring_exec_flags) { @@ -239,13 +241,15 @@ igt_main &execbuf) == 0); } - /* HANDLE_LUT and NO_RELOC are already exercised by gem_exec_lut_handle */ + /* HANDLE_LUT and NO_RELOC are already exercised by gem_exec_lut_handle, + * EXEC_FENCE_IN and EXEC_FENCE_OUT correct usage is tested by + * gem_exec_fence, invalid usage of EXEC_FENCE_IN is tested below. */ igt_subtest("invalid-flag") { /* NOTE: This test intentionally exercise the next available * flag. Don't "fix" this testcase without adding the required * tests for the new flag first. */ - execbuf.flags = I915_EXEC_RENDER | (LOCAL_I915_EXEC_RESOURCE_STREAMER << 1); + execbuf.flags = I915_EXEC_RENDER | (LOCAL_I915_EXEC_FENCE_OUT << 1); RUN_FAIL(EINVAL); } @@ -283,6 +287,21 @@ igt_main RUN_FAIL(EINVAL); } + igt_subtest("invalid-fence-in") { + igt_require(gem_has_exec_fence(fd)); + execbuf.flags = LOCAL_I915_EXEC_FENCE_IN; + execbuf.rsvd2 = -1; + RUN_FAIL(EINVAL); + } + + igt_subtest("rsvd2-dirt") { + igt_require(!gem_has_exec_fence(fd)); + execbuf.flags = 0; + execbuf.rsvd2 = 1; + RUN_FAIL(EINVAL); + execbuf.rsvd2 = 0; + } + #define DIRT(name) \ igt_subtest(#name "-dirt") { \ execbuf.flags = 0; \ @@ -291,7 +310,6 @@ igt_main execbuf.name = 0; \ } - DIRT(rsvd2); DIRT(cliprects_ptr); DIRT(DR1); DIRT(DR4);