From patchwork Mon Aug 7 12:36:35 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Wilson X-Patchwork-Id: 9885283 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 02F19603B4 for ; Mon, 7 Aug 2017 12:36:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E6511285DA for ; Mon, 7 Aug 2017 12:36:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D85CE2867B; Mon, 7 Aug 2017 12:36: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 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 399DD285DA for ; Mon, 7 Aug 2017 12:36:56 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id EC79A6E507; Mon, 7 Aug 2017 12:36:54 +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 1FBDD6E507 for ; Mon, 7 Aug 2017 12:36:52 +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 8147963-1500050 for multiple; Mon, 07 Aug 2017 13:36:36 +0100 Received: by haswell.alporthouse.com (sSMTP sendmail emulation); Mon, 07 Aug 2017 13:36:37 +0100 From: Chris Wilson To: intel-gfx@lists.freedesktop.org Date: Mon, 7 Aug 2017 13:36:35 +0100 Message-Id: <20170807123636.24907-1-chris@chris-wilson.co.uk> X-Mailer: git-send-email 2.13.3 X-Originating-IP: 78.156.65.138 X-Country: code=GB country="United Kingdom" ip=78.156.65.138 Cc: daniel.vetter@ffwll.ch Subject: [Intel-gfx] [PATCH igt 1/2] igt/gem_exec_capture: Wait for batch to execute before triggering reset 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 Signed-off-by: Chris Wilson --- tests/gem_exec_capture.c | 65 ++++++++++++++++++++++++++++++++++++------------ 1 file changed, 49 insertions(+), 16 deletions(-) diff --git a/tests/gem_exec_capture.c b/tests/gem_exec_capture.c index f8f43d29..a73ece5d 100644 --- a/tests/gem_exec_capture.c +++ b/tests/gem_exec_capture.c @@ -64,9 +64,9 @@ static void capture(int fd, int dir, unsigned ring) #define CAPTURE 1 #define NOCAPTURE 2 #define BATCH 3 - struct drm_i915_gem_relocation_entry reloc; + struct drm_i915_gem_relocation_entry reloc[2]; struct drm_i915_gem_execbuffer2 execbuf; - uint32_t *batch; + uint32_t *batch, *seqno; int i; memset(obj, 0, sizeof(obj)); @@ -76,25 +76,50 @@ static void capture(int fd, int dir, unsigned ring) obj[NOCAPTURE].handle = gem_create(fd, 4096); obj[BATCH].handle = gem_create(fd, 4096); - obj[BATCH].relocs_ptr = (uintptr_t)&reloc; - obj[BATCH].relocation_count = 1; - - memset(&reloc, 0, sizeof(reloc)); - reloc.target_handle = obj[BATCH].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; + obj[BATCH].relocs_ptr = (uintptr_t)reloc; + obj[BATCH].relocation_count = ARRAY_SIZE(reloc); + + memset(reloc, 0, sizeof(reloc)); + reloc[0].target_handle = obj[BATCH].handle; /* recurse */ + reloc[0].presumed_offset = 0; + reloc[0].offset = 5*sizeof(uint32_t); + reloc[0].delta = 0; + reloc[0].read_domains = I915_GEM_DOMAIN_COMMAND; + reloc[0].write_domain = 0; + + reloc[1].target_handle = obj[SCRATCH].handle; /* breadcrumb */ + reloc[1].presumed_offset = 0; + reloc[1].offset = sizeof(uint32_t); + reloc[1].delta = 0; + reloc[1].read_domains = I915_GEM_DOMAIN_RENDER; + reloc[1].write_domain = I915_GEM_DOMAIN_RENDER; + + seqno = gem_mmap__wc(fd, obj[SCRATCH].handle, 0, 4096, PROT_READ); + gem_set_domain(fd, obj[SCRATCH].handle, + I915_GEM_DOMAIN_GTT, I915_GEM_DOMAIN_GTT); batch = gem_mmap__cpu(fd, obj[BATCH].handle, 0, 4096, PROT_WRITE); gem_set_domain(fd, obj[BATCH].handle, I915_GEM_DOMAIN_CPU, I915_GEM_DOMAIN_CPU); i = 0; - batch[i++] = 0xdeadbeef; /* crashme */ - batch[i++] = -1; - batch[i] = MI_BATCH_BUFFER_START; /* not crashed? try again! */ + batch[i] = MI_STORE_DWORD_IMM | (gen < 6 ? 1 << 22 : 0); + if (gen >= 8) { + batch[++i] = 0; + batch[++i] = 0; + } else if (gen >= 4) { + batch[++i] = 0; + batch[++i] = 0; + reloc[1].offset += sizeof(uint32_t); + } else { + batch[i]--; + batch[++i] = 0; + } + batch[++i] = 0xc0ffee; + if (gen < 3) + batch[++i] = MI_NOOP; + + batch[++i] = MI_BATCH_BUFFER_START; /* not crashed? try again! */ if (gen >= 8) { batch[i] |= 1 << 8 | 1; batch[++i] = 0; @@ -107,7 +132,7 @@ static void capture(int fd, int dir, unsigned ring) batch[++i] = 0; if (gen < 4) { batch[i] |= 1; - reloc.delta = 1; + reloc[0].delta = 1; } } munmap(batch, 4096); @@ -118,10 +143,17 @@ static void capture(int fd, int dir, unsigned ring) execbuf.flags = ring; gem_execbuf(fd, &execbuf); + /* Wait for the request to start */ + while (*(volatile uint32_t *)seqno != 0xc0ffee) + igt_assert(gem_bo_busy(fd, obj[SCRATCH].handle)); + munmap(seqno, 4096); + /* Check that only the buffer we marked is reported in the error */ igt_force_gpu_reset(fd); check_error_state(dir, &obj[CAPTURE]); + gem_sync(fd, obj[BATCH].handle); + gem_close(fd, obj[BATCH].handle); gem_close(fd, obj[NOCAPTURE].handle); gem_close(fd, obj[CAPTURE].handle); @@ -167,6 +199,7 @@ igt_main igt_subtest_f("capture-%s", e->name) { gem_require_ring(fd, e->exec_id | e->flags); + igt_require(gem_can_store_dword(fd, e->exec_id | e->flags)); capture(fd, dir, e->exec_id | e->flags); } }