From patchwork Wed May 22 15:57:35 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Wilson X-Patchwork-Id: 10956243 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 35DB11390 for ; Wed, 22 May 2019 15:58:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2828C205F6 for ; Wed, 22 May 2019 15:58:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1D2482896F; Wed, 22 May 2019 15:58:14 +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=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, 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 ABFF0205F6 for ; Wed, 22 May 2019 15:58:13 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 14DA889911; Wed, 22 May 2019 15:58:13 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from fireflyinternet.com (mail.fireflyinternet.com [109.228.58.192]) by gabe.freedesktop.org (Postfix) with ESMTPS id 3ABE789911 for ; Wed, 22 May 2019 15:58:04 +0000 (UTC) X-Default-Received-SPF: pass (skip=forwardok (res=PASS)) x-ip-name=78.156.65.138; Received: from haswell.alporthouse.com (unverified [78.156.65.138]) by fireflyinternet.com (Firefly Internet (M1)) with ESMTP id 16643347-1500050 for multiple; Wed, 22 May 2019 16:57:36 +0100 From: Chris Wilson To: intel-gfx@lists.freedesktop.org Date: Wed, 22 May 2019 16:57:35 +0100 Message-Id: <20190522155735.15597-1-chris@chris-wilson.co.uk> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH i-g-t] i915/gem_exec_fence: Replace open-coded recursive batch with igt_spin_t X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Matthew Auld Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Virus-Scanned: ClamAV using ClamSMTP The only detail of note here was that we were creating a fence from the recursive batch, now supported by igt_spin_t (thanks Tvrtko). Signed-off-by: Chris Wilson Cc: Tvrtko Ursulin Cc: Matthew Auld Reviewed-by: Matthew Auld --- tests/i915/gem_exec_fence.c | 74 ++++++------------------------------- 1 file changed, 12 insertions(+), 62 deletions(-) diff --git a/tests/i915/gem_exec_fence.c b/tests/i915/gem_exec_fence.c index 8120f8b56..45017105c 100644 --- a/tests/i915/gem_exec_fence.c +++ b/tests/i915/gem_exec_fence.c @@ -317,68 +317,22 @@ static void test_fence_busy_all(int fd, unsigned flags) static void test_fence_await(int fd, unsigned ring, unsigned flags) { - const int gen = intel_gen(intel_get_drm_devid(fd)); - struct drm_i915_gem_exec_object2 obj; - struct drm_i915_gem_relocation_entry reloc; - struct drm_i915_gem_execbuffer2 execbuf; uint32_t scratch = gem_create(fd, 4096); - uint32_t *batch, *out; + igt_spin_t *spin; unsigned engine; - int fence, i; + uint32_t *out; + int i; igt_require(gem_can_store_dword(fd, 0)); - memset(&execbuf, 0, sizeof(execbuf)); - execbuf.buffers_ptr = to_user_pointer(&obj); - execbuf.buffer_count = 1; - execbuf.flags = ring | LOCAL_EXEC_FENCE_OUT; - - memset(&obj, 0, sizeof(obj)); - obj.handle = gem_create(fd, 4096); - - obj.relocs_ptr = to_user_pointer(&reloc); - obj.relocation_count = 1; - memset(&reloc, 0, sizeof(reloc)); - out = gem_mmap__wc(fd, scratch, 0, 4096, PROT_WRITE); - gem_set_domain(fd, obj.handle, - I915_GEM_DOMAIN_GTT, I915_GEM_DOMAIN_GTT); - - batch = gem_mmap__wc(fd, obj.handle, 0, 4096, PROT_WRITE); - gem_set_domain(fd, obj.handle, + gem_set_domain(fd, scratch, I915_GEM_DOMAIN_GTT, I915_GEM_DOMAIN_GTT); - reloc.target_handle = obj.handle; /* recurse */ - reloc.presumed_offset = 0; - reloc.offset = sizeof(uint32_t); - reloc.delta = 0; - reloc.read_domains = I915_GEM_DOMAIN_COMMAND; - reloc.write_domain = 0; - - i = 0; - batch[i] = MI_BATCH_BUFFER_START; - if (gen >= 8) { - batch[i] |= 1 << 8 | 1; - batch[++i] = 0; - batch[++i] = 0; - } else if (gen >= 6) { - batch[i] |= 1 << 8; - batch[++i] = 0; - } else { - batch[i] |= 2 << 6; - batch[++i] = 0; - if (gen < 4) { - batch[i] |= 1; - reloc.delta = 1; - } - } - i++; - - execbuf.rsvd2 = -1; - gem_execbuf_wr(fd, &execbuf); - gem_close(fd, obj.handle); - fence = execbuf.rsvd2 >> 32; - igt_assert(fence != -1); + spin = igt_spin_new(fd, + .engine = ring, + .flags = IGT_SPIN_FENCE_OUT); + igt_assert(spin->out_fence != -1); i = 0; for_each_physical_engine(fd, engine) { @@ -386,15 +340,14 @@ static void test_fence_await(int fd, unsigned ring, unsigned flags) continue; if (flags & NONBLOCK) { - store(fd, engine, fence, scratch, i); + store(fd, engine, spin->out_fence, scratch, i); } else { igt_fork(child, 1) - store(fd, engine, fence, scratch, i); + store(fd, engine, spin->out_fence, scratch, i); } i++; } - close(fence); sleep(1); @@ -402,11 +355,8 @@ static void test_fence_await(int fd, unsigned ring, unsigned flags) for (int n = 0; n < i; n++) igt_assert_eq_u32(out[n], 0); - if ((flags & HANG) == 0) { - *batch = MI_BATCH_BUFFER_END; - __sync_synchronize(); - } - munmap(batch, 4096); + if ((flags & HANG) == 0) + igt_spin_end(spin); igt_waitchildren();