From patchwork Thu Dec 7 22:48:21 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Antonio Argenziano X-Patchwork-Id: 10101231 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 789E46056F for ; Thu, 7 Dec 2017 22:58:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6AC2128897 for ; Thu, 7 Dec 2017 22:58:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5F33C2889B; Thu, 7 Dec 2017 22:58:22 +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 0794828898 for ; Thu, 7 Dec 2017 22:58:22 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 22B046E885; Thu, 7 Dec 2017 22:58:21 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by gabe.freedesktop.org (Postfix) with ESMTPS id 137FF6E87F for ; Thu, 7 Dec 2017 22:58:20 +0000 (UTC) Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 07 Dec 2017 14:48:51 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.45,374,1508828400"; d="scan'208";a="182315491" Received: from relo-linux-2.fm.intel.com ([10.1.27.122]) by orsmga005.jf.intel.com with ESMTP; 07 Dec 2017 14:48:50 -0800 From: Antonio Argenziano To: intel-gfx@lists.freedesktop.org Date: Thu, 7 Dec 2017 14:48:21 -0800 Message-Id: <20171207224823.30052-3-antonio.argenziano@intel.com> X-Mailer: git-send-email 2.14.2 In-Reply-To: <20171207224823.30052-1-antonio.argenziano@intel.com> References: <20171207224823.30052-1-antonio.argenziano@intel.com> Subject: [Intel-gfx] [PATCH i-g-t 3/5] lib/igt_hang_ctx: Use recursive 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 | 40 ++++++---------------------------------- lib/igt_gt.h | 1 + 4 files changed, 12 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 86a261cb..a9a69ccd 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,14 @@ 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){ + .ctx = opts.ctx, + .engine = opts.ring}); 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);