From patchwork Thu Dec 7 22:48:20 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Antonio Argenziano X-Patchwork-Id: 10101221 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 254F860325 for ; Thu, 7 Dec 2017 22:48:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 16F1328884 for ; Thu, 7 Dec 2017 22:48:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0BAC62888E; Thu, 7 Dec 2017 22:48:46 +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 7F1B428884 for ; Thu, 7 Dec 2017 22:48:45 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 1745A6E87C; Thu, 7 Dec 2017 22:48:45 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) by gabe.freedesktop.org (Postfix) with ESMTPS id BFED96E87C for ; Thu, 7 Dec 2017 22:48:43 +0000 (UTC) Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga104.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 07 Dec 2017 14:48:43 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.45,374,1508828400"; d="scan'208";a="182315479" Received: from relo-linux-2.fm.intel.com ([10.1.27.122]) by orsmga005.jf.intel.com with ESMTP; 07 Dec 2017 14:48:43 -0800 From: Antonio Argenziano To: intel-gfx@lists.freedesktop.org Date: Thu, 7 Dec 2017 14:48:20 -0800 Message-Id: <20171207224823.30052-2-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 2/5] igt_hang_ctx: Wrap hang_ctx parameters into struct 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 Cleanup the interface to create a hang on a context by folding its parameters into a struct. Cc: Chris Wilson Signed-off-by: Antonio Argenziano --- lib/igt_dummyload.c | 25 ++++++++++++------------- lib/igt_gt.c | 41 +++++++++++++++++++---------------------- lib/igt_gt.h | 14 +++++++++----- tests/drv_hangman.c | 5 ++++- tests/gem_reset_stats.c | 7 +++++-- tests/gem_softpin.c | 2 +- 6 files changed, 50 insertions(+), 44 deletions(-) diff --git a/lib/igt_dummyload.c b/lib/igt_dummyload.c index 37ae5a03..fee311f7 100644 --- a/lib/igt_dummyload.c +++ b/lib/igt_dummyload.c @@ -70,8 +70,7 @@ fill_reloc(struct drm_i915_gem_relocation_entry *reloc, } static void emit_recursive_batch(igt_spin_t *spin, - int fd, uint32_t ctx, unsigned engine, - uint32_t dep) + int fd, igt_spin_opt_t opts) { #define SCRATCH 0 #define BATCH 1 @@ -85,13 +84,13 @@ static void emit_recursive_batch(igt_spin_t *spin, int i; nengine = 0; - if (engine == -1) { - for_each_engine(fd, engine) - if (engine) - engines[nengine++] = engine; + if (opts.engine == -1) { + for_each_engine(fd, opts.engine) + if (opts.engine) + engines[nengine++] = opts.engine; } else { - gem_require_ring(fd, engine); - engines[nengine++] = engine; + gem_require_ring(fd, opts.engine); + engines[nengine++] = opts.engine; } igt_require(nengine); @@ -109,11 +108,11 @@ static void emit_recursive_batch(igt_spin_t *spin, I915_GEM_DOMAIN_GTT, I915_GEM_DOMAIN_GTT); execbuf.buffer_count++; - if (dep) { + if (opts.dep) { /* dummy write to dependency */ - obj[SCRATCH].handle = dep; + obj[SCRATCH].handle = opts.dep; fill_reloc(&relocs[obj[BATCH].relocation_count++], - dep, 1020, + opts.dep, 1020, I915_GEM_DOMAIN_RENDER, I915_GEM_DOMAIN_RENDER); execbuf.buffer_count++; @@ -162,7 +161,7 @@ static void emit_recursive_batch(igt_spin_t *spin, obj[BATCH].relocs_ptr = to_user_pointer(relocs); execbuf.buffers_ptr = to_user_pointer(obj + (2 - execbuf.buffer_count)); - execbuf.rsvd1 = ctx; + execbuf.rsvd1 = opts.ctx; for (i = 0; i < nengine; i++) { execbuf.flags &= ~ENGINE_MASK; @@ -179,7 +178,7 @@ __igt_spin_batch_new(int fd, igt_spin_opt_t opts) spin = calloc(1, sizeof(struct igt_spin)); igt_assert(spin); - emit_recursive_batch(spin, fd, opts.ctx, opts.engine, opts.dep); + emit_recursive_batch(spin, fd, opts); igt_assert(gem_bo_busy(fd, spin->handle)); igt_list_add(&spin->link, &spin_list); diff --git a/lib/igt_gt.c b/lib/igt_gt.c index 4a8f541f..86a261cb 100644 --- a/lib/igt_gt.c +++ b/lib/igt_gt.c @@ -250,10 +250,11 @@ static bool has_ctx_exec(int fd, unsigned ring, uint32_t ctx) /** * igt_hang_ring_ctx: * @fd: open i915 drm file descriptor - * @ctx: the contxt specifier - * @ring: execbuf ring flag - * @flags: set of flags to control execution - * @offset: The resultant gtt offset of the exec obj + * @opts: struct wrapping paramters used in this function: + * - ctx: the context specifier + * - ring: execbuf ring flag + * - flags: set of flags to control execution + * - offset: The resultant gtt offset of the exec obj * * This helper function injects a hanging batch associated with @ctx into @ring. * It returns a #igt_hang_t structure which must be passed to @@ -263,11 +264,7 @@ static bool has_ctx_exec(int fd, unsigned ring, uint32_t ctx) * Returns: * Structure with helper internal state for igt_post_hang_ring(). */ -igt_hang_t igt_hang_ctx(int fd, - uint32_t ctx, - int ring, - unsigned flags, - uint64_t *offset) +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; @@ -277,15 +274,15 @@ igt_hang_t igt_hang_ctx(int fd, unsigned ban; unsigned len; - igt_require_hang_ring(fd, ring); + igt_require_hang_ring(fd, opts.ring); /* check if non-default ctx submission is allowed */ - igt_require(ctx == 0 || has_ctx_exec(fd, ring, ctx)); + igt_require(opts.ctx == 0 || has_ctx_exec(fd, opts.ring, opts.ctx)); - param.ctx_id = ctx; + param.ctx_id = opts.ctx; param.size = 0; - if ((flags & HANG_ALLOW_CAPTURE) == 0) { + if ((opts.flags & HANG_ALLOW_CAPTURE) == 0) { param.param = I915_CONTEXT_PARAM_NO_ERROR_CAPTURE; param.value = 1; /* Older kernels may not have NO_ERROR_CAPTURE, in which case @@ -295,10 +292,10 @@ igt_hang_t igt_hang_ctx(int fd, __gem_context_set_param(fd, ¶m); } - ban = context_get_ban(fd, ctx); + ban = context_get_ban(fd, opts.ctx); - if ((flags & HANG_ALLOW_BAN) == 0) - context_set_ban(fd, ctx, 0); + if ((opts.flags & HANG_ALLOW_BAN) == 0) + context_set_ban(fd, opts.ctx, 0); memset(&reloc, 0, sizeof(reloc)); memset(&exec, 0, sizeof(exec)); @@ -324,14 +321,14 @@ igt_hang_t igt_hang_ctx(int fd, execbuf.buffers_ptr = to_user_pointer(&exec); execbuf.buffer_count = 1; - execbuf.flags = ring; - i915_execbuffer2_set_context_id(execbuf, ctx); + execbuf.flags = opts.ring; + i915_execbuffer2_set_context_id(execbuf, opts.ctx); gem_execbuf(fd, &execbuf); - if (offset) - *offset = exec.offset; + if (opts.offset) + *opts.offset = exec.offset; - return (igt_hang_t){ exec.handle, ctx, ban, flags }; + return (igt_hang_t){ exec.handle, opts.ctx, ban, opts.flags }; } /** @@ -348,7 +345,7 @@ igt_hang_t igt_hang_ctx(int fd, */ igt_hang_t igt_hang_ring(int fd, int ring) { - return igt_hang_ctx(fd, 0, ring, 0, NULL); + return igt_hang_ctx(fd, (igt_hang_opt_t){.ring = ring}); } /** diff --git a/lib/igt_gt.h b/lib/igt_gt.h index 48ed48af..55de04d5 100644 --- a/lib/igt_gt.h +++ b/lib/igt_gt.h @@ -36,16 +36,20 @@ typedef struct igt_hang { unsigned flags; } igt_hang_t; +typedef struct igt_hang_opt { + uint32_t ctx; + int ring; + unsigned flags; + uint64_t *offset; +} igt_hang_opt_t; + igt_hang_t igt_allow_hang(int fd, unsigned ctx, unsigned flags); void igt_disallow_hang(int fd, igt_hang_t arg); #define HANG_POISON 0xc5c5c5c5 -igt_hang_t igt_hang_ctx(int fd, - uint32_t ctx, - int ring, - unsigned flags, - uint64_t *offset); +igt_hang_t igt_hang_ctx(int fd, igt_hang_opt_t opts); + #define HANG_ALLOW_BAN 1 #define HANG_ALLOW_CAPTURE 2 diff --git a/tests/drv_hangman.c b/tests/drv_hangman.c index 40c82257..4cd2420a 100644 --- a/tests/drv_hangman.c +++ b/tests/drv_hangman.c @@ -187,7 +187,10 @@ static void test_error_state_capture(unsigned ring_id, clear_error_state(); - hang = igt_hang_ctx(device, 0, ring_id, HANG_ALLOW_CAPTURE, &offset); + hang = igt_hang_ctx(device, (igt_hang_opt_t){ + .ring = ring_id, + .flags = HANG_ALLOW_CAPTURE, + .offset = &offset}); batch = gem_mmap__cpu(device, hang.handle, 0, 4096, PROT_READ); gem_set_domain(device, hang.handle, I915_GEM_DOMAIN_CPU, 0); igt_post_hang_ring(device, hang); diff --git a/tests/gem_reset_stats.c b/tests/gem_reset_stats.c index edc40767..83e79626 100644 --- a/tests/gem_reset_stats.c +++ b/tests/gem_reset_stats.c @@ -161,7 +161,10 @@ static void inject_hang(int fd, uint32_t ctx, clock_gettime(CLOCK_MONOTONIC, &ts_injected); - hang = igt_hang_ctx(fd, ctx, e->exec_id | e->flags, flags & BAN, NULL); + hang = igt_hang_ctx(fd, (igt_hang_opt_t){ + .ctx = ctx, + .ring = e->exec_id | e->flags, + .flags = flags & BAN}); if ((flags & ASYNC) == 0) igt_post_hang_ring(fd, hang); } @@ -543,7 +546,7 @@ static void test_close_pending_fork(const struct intel_execution_engine *e, assert_reset_status(fd, fd, 0, RS_NO_ERROR); - hang = igt_hang_ctx(fd, 0, e->exec_id | e->flags, 0, NULL); + hang = igt_hang_ctx(fd, (igt_hang_opt_t){.ring = e->exec_id | e->flags}); sleep(1); /* Avoid helpers as we need to kill the child diff --git a/tests/gem_softpin.c b/tests/gem_softpin.c index 99388599..f03f2c6f 100644 --- a/tests/gem_softpin.c +++ b/tests/gem_softpin.c @@ -359,7 +359,7 @@ static void test_evict_hang(int fd) execbuf.buffers_ptr = to_user_pointer(&object); execbuf.buffer_count = 1; - hang = igt_hang_ctx(fd, 0, 0, 0, (uint64_t *)&expected); + hang = igt_hang_ctx(fd, (igt_hang_opt_t){.offset = (uint64_t *)&expected}); object.offset = expected; object.flags = EXEC_OBJECT_PINNED;