From patchwork Thu Oct 12 22:27:32 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: 10003029 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 67BF76028A for ; Thu, 12 Oct 2017 22:27:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5A2CB28F05 for ; Thu, 12 Oct 2017 22:27:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4F4E428F08; Thu, 12 Oct 2017 22:27:57 +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 0BD0E28F05 for ; Thu, 12 Oct 2017 22:27:57 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id E626A6E9A4; Thu, 12 Oct 2017 22:27:54 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by gabe.freedesktop.org (Postfix) with ESMTPS id 046226E99D for ; Thu, 12 Oct 2017 22:27:48 +0000 (UTC) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga105.fm.intel.com with ESMTP; 12 Oct 2017 15:27:48 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos; i="5.43,368,1503385200"; d="scan'208"; a="1230197866" Received: from relo-linux-1.fm.intel.com ([10.1.27.112]) by fmsmga002.fm.intel.com with ESMTP; 12 Oct 2017 15:27:48 -0700 From: Daniele Ceraolo Spurio To: intel-gfx@lists.freedesktop.org Date: Thu, 12 Oct 2017 15:27:32 -0700 Message-Id: <1507847254-3289-7-git-send-email-daniele.ceraolospurio@intel.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1507847254-3289-1-git-send-email-daniele.ceraolospurio@intel.com> References: <1507847254-3289-1-git-send-email-daniele.ceraolospurio@intel.com> Subject: [Intel-gfx] [PATCH i-g-t 6/8] tests/gem_wait: use igt_cork 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 With igt_cork added as common utility we can use it instead of the local copy Signed-off-by: Daniele Ceraolo Spurio Cc: Chris Wilson --- tests/gem_wait.c | 52 ++++++++-------------------------------------------- 1 file changed, 8 insertions(+), 44 deletions(-) diff --git a/tests/gem_wait.c b/tests/gem_wait.c index cf8c815..5fba233 100644 --- a/tests/gem_wait.c +++ b/tests/gem_wait.c @@ -69,51 +69,14 @@ static void invalid_buf(int fd) #define AWAIT 4 #define WRITE 8 -struct cork { - int device; - uint32_t handle; - uint32_t fence; -}; - -static struct cork plug(int fd, unsigned flags) -{ - struct cork c; - struct vgem_bo bo; - int dmabuf; - - if ((flags & (WRITE | AWAIT)) == 0) - return (struct cork){0}; - - c.device = drm_open_driver(DRIVER_VGEM); - - bo.width = bo.height = 1; - bo.bpp = 4; - vgem_create(c.device, &bo); - c.fence = vgem_fence_attach(c.device, &bo, VGEM_FENCE_WRITE); - - dmabuf = prime_handle_to_fd(c.device, bo.handle); - c.handle = prime_fd_to_handle(fd, dmabuf); - close(dmabuf); - - return c; -} - -static void unplug(struct cork *c) -{ - if (!c->device) - return; - - vgem_fence_signal(c->device, c->fence); - close(c->device); -} - static void basic(int fd, unsigned engine, unsigned flags) { - struct cork cork = plug(fd, flags); - igt_spin_t *spin = igt_spin_batch_new(fd, 0, engine, cork.handle); + igt_cork_t *cork = flags & (WRITE | AWAIT) ? igt_cork_new(fd) : NULL; + igt_spin_t *spin = igt_spin_batch_new(fd, 0, engine, + cork ? cork->handle : 0); struct drm_i915_gem_wait wait = { - flags & WRITE ? cork.handle : spin->handle - }; + flags & WRITE ? cork->handle : spin->handle + }; igt_assert_eq(__gem_wait(fd, &wait), -ETIME); @@ -127,7 +90,7 @@ static void basic(int fd, unsigned engine, unsigned flags) timeout = 1; } - unplug(&cork); + igt_cork_signal(cork); igt_assert_eq(__gem_wait(fd, &wait), -ETIME); while (__gem_wait(fd, &wait) == -ETIME) @@ -137,7 +100,7 @@ static void basic(int fd, unsigned engine, unsigned flags) igt_assert_eq(__gem_wait(fd, &wait), -ETIME); igt_assert_eq_s64(wait.timeout_ns, 0); - unplug(&cork); + igt_cork_signal(cork); wait.timeout_ns = 0; igt_assert_eq(__gem_wait(fd, &wait), -ETIME); @@ -157,6 +120,7 @@ static void basic(int fd, unsigned engine, unsigned flags) igt_assert(wait.timeout_ns == 0); } + igt_cork_free(fd, cork); igt_spin_batch_free(fd, spin); }