From patchwork Thu May 25 07:40:54 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lukasz Fiedorowicz X-Patchwork-Id: 9747911 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 0805660246 for ; Thu, 25 May 2017 07:41:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EAD3227852 for ; Thu, 25 May 2017 07:41:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DF9B727CF9; Thu, 25 May 2017 07:41:19 +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 4568627852 for ; Thu, 25 May 2017 07:41:19 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 850EA6E8CD; Thu, 25 May 2017 07:41:17 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by gabe.freedesktop.org (Postfix) with ESMTPS id 499AC6E8CD for ; Thu, 25 May 2017 07:41:16 +0000 (UTC) Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 25 May 2017 00:41:15 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.38,390,1491289200"; d="scan'208";a="266188205" Received: from lfiedoro-desk1.igk.intel.com ([172.28.171.155]) by fmsmga004.fm.intel.com with ESMTP; 25 May 2017 00:41:14 -0700 From: Lukasz Fiedorowicz To: intel-gfx@lists.freedesktop.org Date: Thu, 25 May 2017 09:40:54 +0200 Message-Id: <20170525074054.21203-1-lukasz.fiedorowicz@intel.com> X-Mailer: git-send-email 2.9.4 Subject: [Intel-gfx] [PATCH i-g-t] lib: Moving gem_execbuf_wr to ioctl_wrappers 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 gem_execbuf_wr was duplicated in multiple places. Moving everything to lib/ Signed-off-by: Lukasz Fiedorowicz Reviewed-by: Tvrtko Ursulin --- benchmarks/gem_busy.c | 16 ---------------- benchmarks/gem_latency.c | 16 ---------------- benchmarks/gem_wsim.c | 16 ---------------- lib/ioctl_wrappers.c | 33 +++++++++++++++++++++++++++++++++ lib/ioctl_wrappers.h | 2 ++ tests/gem_exec_fence.c | 16 ---------------- tests/gem_exec_nop.c | 16 ---------------- 7 files changed, 35 insertions(+), 80 deletions(-) diff --git a/benchmarks/gem_busy.c b/benchmarks/gem_busy.c index bda3e13..c1cee6c 100644 --- a/benchmarks/gem_busy.c +++ b/benchmarks/gem_busy.c @@ -45,8 +45,6 @@ #include "intel_chipset.h" #include "igt_stats.h" -#define LOCAL_IOCTL_I915_GEM_EXECBUFFER2_WR DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_GEM_EXECBUFFER2, struct drm_i915_gem_execbuffer2) - #define LOCAL_I915_EXEC_NO_RELOC (1<<11) #define LOCAL_I915_EXEC_HANDLE_LUT (1<<12) @@ -73,20 +71,6 @@ static bool gem_busy(int fd, uint32_t handle) return busy.busy != 0; } -static int __gem_execbuf_wr(int fd, struct drm_i915_gem_execbuffer2 *execbuf) -{ - int err = 0; - if (igt_ioctl(fd, LOCAL_IOCTL_I915_GEM_EXECBUFFER2_WR, execbuf)) - err = -errno; - errno = 0; - return err; -} - -static void gem_execbuf_wr(int fd, struct drm_i915_gem_execbuffer2 *execbuf) -{ - igt_assert_eq(__gem_execbuf_wr(fd, execbuf), 0); -} - static bool gem_wait__busy(int fd, uint32_t handle) { struct drm_i915_gem_wait wait; diff --git a/benchmarks/gem_latency.c b/benchmarks/gem_latency.c index 7975ade..6cb16ba 100644 --- a/benchmarks/gem_latency.c +++ b/benchmarks/gem_latency.c @@ -45,8 +45,6 @@ #include #include "drm.h" -#define LOCAL_IOCTL_I915_GEM_EXECBUFFER2_WR DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_GEM_EXECBUFFER2, struct drm_i915_gem_execbuffer2) - #define LOCAL_I915_EXEC_FENCE_IN (1<<16) #define LOCAL_I915_EXEC_FENCE_OUT (1<<17) @@ -103,20 +101,6 @@ inline static uint32_t read_timestamp(void) } #endif -static int __gem_execbuf_wr(int _fd, struct drm_i915_gem_execbuffer2 *execbuf) -{ - int err = 0; - if (igt_ioctl(_fd, LOCAL_IOCTL_I915_GEM_EXECBUFFER2_WR, execbuf)) - err = -errno; - errno = 0; - return err; -} - -static void gem_execbuf_wr(int _fd, struct drm_i915_gem_execbuffer2 *execbuf) -{ - igt_assert_eq(__gem_execbuf_wr(_fd, execbuf), 0); -} - struct consumer { pthread_t thread; diff --git a/benchmarks/gem_wsim.c b/benchmarks/gem_wsim.c index b366a5d..485de15 100644 --- a/benchmarks/gem_wsim.c +++ b/benchmarks/gem_wsim.c @@ -1481,22 +1481,6 @@ static void init_status_page(struct workload *wrk, unsigned int flags) } } -#define LOCAL_IOCTL_I915_GEM_EXECBUFFER2_WR DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_GEM_EXECBUFFER2, struct drm_i915_gem_execbuffer2) - -static int __gem_execbuf_wr(int gemfd, struct drm_i915_gem_execbuffer2 *execbuf) -{ - int err = 0; - if (igt_ioctl(gemfd, LOCAL_IOCTL_I915_GEM_EXECBUFFER2_WR, execbuf)) - err = -errno; - errno = 0; - return err; -} - -static void gem_execbuf_wr(int gemfd, struct drm_i915_gem_execbuffer2 *execbuf) -{ - igt_assert_eq(__gem_execbuf_wr(gemfd, execbuf), 0); -} - static void do_eb(struct workload *wrk, struct w_step *w, enum intel_engine_id engine, unsigned int flags) diff --git a/lib/ioctl_wrappers.c b/lib/ioctl_wrappers.c index 48bdcc5..0816a7b 100644 --- a/lib/ioctl_wrappers.c +++ b/lib/ioctl_wrappers.c @@ -624,6 +624,39 @@ void gem_execbuf(int fd, struct drm_i915_gem_execbuffer2 *execbuf) igt_assert_eq(__gem_execbuf(fd, execbuf), 0); } +#define LOCAL_IOCTL_I915_GEM_EXECBUFFER2_WR \ + DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_GEM_EXECBUFFER2, struct drm_i915_gem_execbuffer2) + +/** + * __gem_execbuf_wr: + * @fd: open i915 drm file descriptor + * @execbuf: execbuffer data structure + * + * This wraps the EXECBUFFER2_WR ioctl, which submits a batchbuffer for the gpu to + * run. This is allowed to fail, with -errno returned. + */ +int __gem_execbuf_wr(int fd, struct drm_i915_gem_execbuffer2 *execbuf) +{ + int err = 0; + if (igt_ioctl(fd, LOCAL_IOCTL_I915_GEM_EXECBUFFER2_WR, execbuf)) + err = -errno; + errno = 0; + return err; +} + +/** + * gem_execbuf_wr: + * @fd: open i915 drm file descriptor + * @execbuf: execbuffer data structure + * + * This wraps the EXECBUFFER2_WR ioctl, which submits a batchbuffer for the gpu to + * run. + */ +void gem_execbuf_wr(int fd, struct drm_i915_gem_execbuffer2 *execbuf) +{ + igt_assert_eq(__gem_execbuf_wr(fd, execbuf), 0); +} + /** * __gem_mmap__gtt: * @fd: open i915 drm file descriptor diff --git a/lib/ioctl_wrappers.h b/lib/ioctl_wrappers.h index d6d8bad..e1279d9 100644 --- a/lib/ioctl_wrappers.h +++ b/lib/ioctl_wrappers.h @@ -74,6 +74,8 @@ uint32_t __gem_create_stolen(int fd, uint64_t size); uint32_t gem_create_stolen(int fd, uint64_t size); uint32_t __gem_create(int fd, int size); uint32_t gem_create(int fd, uint64_t size); +void gem_execbuf_wr(int fd, struct drm_i915_gem_execbuffer2 *execbuf); +int __gem_execbuf_wr(int fd, struct drm_i915_gem_execbuffer2 *execbuf); void gem_execbuf(int fd, struct drm_i915_gem_execbuffer2 *execbuf); int __gem_execbuf(int fd, struct drm_i915_gem_execbuffer2 *execbuf); diff --git a/tests/gem_exec_fence.c b/tests/gem_exec_fence.c index 05e55f0..82b0c89 100644 --- a/tests/gem_exec_fence.c +++ b/tests/gem_exec_fence.c @@ -31,10 +31,8 @@ IGT_TEST_DESCRIPTION("Check that execbuf waits for explicit fences"); -#define LOCAL_PARAM_HAS_EXEC_FENCE 44 #define LOCAL_EXEC_FENCE_IN (1 << 16) #define LOCAL_EXEC_FENCE_OUT (1 << 17) -#define LOCAL_IOCTL_I915_GEM_EXECBUFFER2_WR DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_GEM_EXECBUFFER2, struct drm_i915_gem_execbuffer2) #ifndef SYNC_IOC_MERGE struct sync_merge_data { @@ -101,20 +99,6 @@ static void store(int fd, unsigned ring, int fence, uint32_t target, unsigned of gem_close(fd, obj[BATCH].handle); } -static int __gem_execbuf_wr(int fd, struct drm_i915_gem_execbuffer2 *execbuf) -{ - int err = 0; - if (igt_ioctl(fd, LOCAL_IOCTL_I915_GEM_EXECBUFFER2_WR, execbuf)) - err = -errno; - errno = 0; - return err; -} - -static void gem_execbuf_wr(int fd, struct drm_i915_gem_execbuffer2 *execbuf) -{ - igt_assert_eq(__gem_execbuf_wr(fd, execbuf), 0); -} - static bool fence_busy(int fence) { return poll(&(struct pollfd){fence, POLLIN}, 1, 0) == 0; diff --git a/tests/gem_exec_nop.c b/tests/gem_exec_nop.c index 440e357..45ab47d 100644 --- a/tests/gem_exec_nop.c +++ b/tests/gem_exec_nop.c @@ -489,22 +489,6 @@ static void sequential(int fd, uint32_t handle, unsigned flags, int timeout) } #define LOCAL_EXEC_FENCE_OUT (1 << 17) -#define LOCAL_IOCTL_I915_GEM_EXECBUFFER2_WR DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_GEM_EXECBUFFER2, struct drm_i915_gem_execbuffer2) - -static int __gem_execbuf_wr(int fd, struct drm_i915_gem_execbuffer2 *execbuf) -{ - int err = 0; - if (igt_ioctl(fd, LOCAL_IOCTL_I915_GEM_EXECBUFFER2_WR, execbuf)) - err = -errno; - errno = 0; - return err; -} - -static void gem_execbuf_wr(int fd, struct drm_i915_gem_execbuffer2 *execbuf) -{ - igt_assert_eq(__gem_execbuf_wr(fd, execbuf), 0); -} - static bool fence_enable_signaling(int fence) { return poll(&(struct pollfd){fence, POLLIN}, 1, 0) == 0;