From patchwork Wed Dec 6 23:03:44 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Antonio Argenziano X-Patchwork-Id: 10097375 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 7D40C60329 for ; Wed, 6 Dec 2017 23:03:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6F9D429E90 for ; Wed, 6 Dec 2017 23:03:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 649AC29E92; Wed, 6 Dec 2017 23:03:59 +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 1198929E90 for ; Wed, 6 Dec 2017 23:03:59 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 424796E736; Wed, 6 Dec 2017 23:03:58 +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 15C8689FDB for ; Wed, 6 Dec 2017 23:03:57 +0000 (UTC) Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 06 Dec 2017 15:03:57 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.45,369,1508828400"; d="scan'208";a="10217829" Received: from relo-linux-2.fm.intel.com ([10.1.27.122]) by orsmga003.jf.intel.com with ESMTP; 06 Dec 2017 15:03:56 -0800 From: Antonio Argenziano To: intel-gfx@lists.freedesktop.org Date: Wed, 6 Dec 2017 15:03:44 -0800 Message-Id: <20171206230346.30767-3-antonio.argenziano@intel.com> X-Mailer: git-send-email 2.14.2 In-Reply-To: <20171206230346.30767-1-antonio.argenziano@intel.com> References: <20171206230346.30767-1-antonio.argenziano@intel.com> Subject: [Intel-gfx] [RFC i-g-t 3/5] lib/igt_hang_ctx: Use dummyload batch to hang ctx. 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 To hang a context we were effectively reimplementing a spinning batch and never stopping it. This patch reuses the recursive batch from igt_dummyload to hang a context. Cc: Chris Wilson Signed-off-by: Antonio Argenziano --- lib/igt_dummyload.c | 4 +++- lib/igt_dummyload.h | 2 ++ lib/igt_gt.c | 38 ++++---------------------------------- lib/igt_gt.h | 1 + 4 files changed, 10 insertions(+), 35 deletions(-) diff --git a/lib/igt_dummyload.c b/lib/igt_dummyload.c index fee311f7..0bb02e5b 100644 --- a/lib/igt_dummyload.c +++ b/lib/igt_dummyload.c @@ -69,7 +69,7 @@ fill_reloc(struct drm_i915_gem_relocation_entry *reloc, reloc->write_domain = write_domains; } -static void emit_recursive_batch(igt_spin_t *spin, +void emit_recursive_batch(igt_spin_t *spin, int fd, igt_spin_opt_t opts) { #define SCRATCH 0 @@ -168,6 +168,8 @@ static void emit_recursive_batch(igt_spin_t *spin, execbuf.flags = engines[i]; gem_execbuf(fd, &execbuf); } + + spin->spinning_offset = obj->offset; } igt_spin_t * diff --git a/lib/igt_dummyload.h b/lib/igt_dummyload.h index 76ccd37a..2f3f2ebf 100644 --- a/lib/igt_dummyload.h +++ b/lib/igt_dummyload.h @@ -35,6 +35,7 @@ typedef struct igt_spin { timer_t timer; struct igt_list link; uint32_t *batch; + uint64_t spinning_offset; } igt_spin_t; typedef struct igt_spin_opt { @@ -43,6 +44,7 @@ typedef struct igt_spin_opt { uint32_t dep; } igt_spin_opt_t; +void emit_recursive_batch(igt_spin_t *spin, int fd, igt_spin_opt_t opts); igt_spin_t *__igt_spin_batch_new(int fd, igt_spin_opt_t opts); igt_spin_t *igt_spin_batch_new(int fd, igt_spin_opt_t opts); void igt_spin_batch_set_timeout(igt_spin_t *spin, int64_t ns); diff --git a/lib/igt_gt.c b/lib/igt_gt.c index c9a2b508..9ec3b0f6 100644 --- a/lib/igt_gt.c +++ b/lib/igt_gt.c @@ -266,13 +266,9 @@ static bool has_ctx_exec(int fd, unsigned ring, uint32_t ctx) */ igt_hang_t igt_hang_ctx(int fd, igt_hang_opt_t opts) { - 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]; unsigned ban; - unsigned len; + igt_spin_t spin; igt_require_hang_ring(fd, opts.ring); @@ -297,38 +293,12 @@ igt_hang_t igt_hang_ctx(int fd, igt_hang_opt_t opts) if ((opts.flags & HANG_ALLOW_BAN) == 0) context_set_ban(fd, opts.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 = 2; - if (intel_gen(intel_get_drm_devid(fd)) >= 8) - len++; - b[0] = MI_BATCH_BUFFER_START | (len - 2); - b[len] = MI_BATCH_BUFFER_END; - b[len+1] = 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 = opts.ring; - i915_execbuffer2_set_context_id(execbuf, opts.ctx); - gem_execbuf(fd, &execbuf); + emit_recursive_batch(&spin, fd, (igt_spin_opt_t){opts.ctx, opts.ring, 0}); if (opts.offset) - *opts.offset = exec.offset; + *opts.offset = spin.spinning_offset; - return (igt_hang_t){ exec.handle, opts.ctx, ban, opts.flags }; + return (igt_hang_t){ spin.handle, opts.ctx, ban, opts.flags }; } /** diff --git a/lib/igt_gt.h b/lib/igt_gt.h index 55de04d5..3f3e2d96 100644 --- a/lib/igt_gt.h +++ b/lib/igt_gt.h @@ -26,6 +26,7 @@ #include "igt_debugfs.h" #include "igt_core.h" +#include "igt_dummyload.h" void igt_require_hang_ring(int fd, int ring);