From patchwork Fri Jul 13 08:14:53 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Wilson X-Patchwork-Id: 10522767 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 148C46028E for ; Fri, 13 Jul 2018 08:15:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0564828607 for ; Fri, 13 Jul 2018 08:15:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EBC1B29A92; Fri, 13 Jul 2018 08:15:06 +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 7A4E028607 for ; Fri, 13 Jul 2018 08:15:06 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 95BEC6F1A1; Fri, 13 Jul 2018 08:15:05 +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 D2D956F19E; Fri, 13 Jul 2018 08:15:03 +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 12339630-1500050 for multiple; Fri, 13 Jul 2018 09:14:46 +0100 From: Chris Wilson To: intel-gfx@lists.freedesktop.org Date: Fri, 13 Jul 2018 09:14:53 +0100 Message-Id: <20180713081453.30596-1-chris@chris-wilson.co.uk> X-Mailer: git-send-email 2.18.0 Subject: [Intel-gfx] [PATCH i-g-t] lib/hang_ctx: Make use of dummyload library to create recursive batch 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: igt-dev@lists.freedesktop.org MIME-Version: 1.0 Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Virus-Scanned: ClamAV using ClamSMTP From: Antonio Argenziano An hanging batch is nothing more than a spinning batch that never gets stopped, so re-use the routines implemented in dummyload.c. v2: - Let caller decide spin loop size - Now builds with meson. v3: - Only use loose loops for hangs (Chris) v4: - No requires Signed-off-by: Antonio Argenziano Cc: Chris Wilson Reviewed-by: Chris Wilson --- lib/igt_gt.c | 57 ++++++++-------------------------------------------- 1 file changed, 8 insertions(+), 49 deletions(-) diff --git a/lib/igt_gt.c b/lib/igt_gt.c index 89b318ae6..e2701fb21 100644 --- a/lib/igt_gt.c +++ b/lib/igt_gt.c @@ -40,6 +40,7 @@ #include "ioctl_wrappers.h" #include "intel_reg.h" #include "intel_chipset.h" +#include "igt_dummyload.h" /** * SECTION:igt_gt @@ -271,14 +272,9 @@ igt_hang_t igt_hang_ctx(int fd, unsigned flags, uint64_t *offset) { - struct drm_i915_gem_relocation_entry reloc; - struct drm_i915_gem_execbuffer2 execbuf; - struct drm_i915_gem_exec_object2 exec; struct drm_i915_gem_context_param param; - uint32_t b[16]; + igt_spin_t *spin; unsigned ban; - unsigned len; - int gen; igt_require_hang_ring(fd, ring); @@ -302,52 +298,15 @@ igt_hang_t igt_hang_ctx(int fd, if ((flags & HANG_ALLOW_BAN) == 0) context_set_ban(fd, ctx, 0); - memset(&reloc, 0, sizeof(reloc)); - memset(&exec, 0, sizeof(exec)); - memset(&execbuf, 0, sizeof(execbuf)); - - exec.handle = gem_create(fd, 4096); - exec.relocation_count = 1; - exec.relocs_ptr = to_user_pointer(&reloc); - - memset(b, 0xc5, sizeof(b)); - - len = 0; - gen = intel_gen(intel_get_drm_devid(fd)); - if (gen >= 8) { - b[len++] = MI_BATCH_BUFFER_START | 1 << 8 | 1; - b[len++] = 0; - b[len++] = 0; - } else if (gen >= 6) { - b[len++] = MI_BATCH_BUFFER_START | 1 << 8; - b[len++] = 0; - } else { - b[len++] = MI_BATCH_BUFFER_START | 2 << 6; - b[len] = 0; - if (gen < 4) { - b[len] |= 1; - reloc.delta = 1; - } - len++; - } - b[len++] = MI_BATCH_BUFFER_END; - b[len] = MI_NOOP; - gem_write(fd, exec.handle, 0, b, sizeof(b)); - - reloc.offset = sizeof(uint32_t); - reloc.target_handle = exec.handle; - reloc.read_domains = I915_GEM_DOMAIN_COMMAND; - - execbuf.buffers_ptr = to_user_pointer(&exec); - execbuf.buffer_count = 1; - execbuf.flags = ring; - i915_execbuffer2_set_context_id(execbuf, ctx); - gem_execbuf(fd, &execbuf); + spin = __igt_spin_batch_new(fd, + .ctx = ctx, + .engine = ring, + .flags = IGT_SPIN_NO_PREEMPTION); if (offset) - *offset = exec.offset; + *offset = spin->obj[1].offset; - return (igt_hang_t){ exec.handle, ctx, ban, flags }; + return (igt_hang_t){ spin->handle, ctx, ban, flags }; } /**