From patchwork Wed Dec 6 23:03:43 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Antonio Argenziano X-Patchwork-Id: 10097373 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 478CE60329 for ; Wed, 6 Dec 2017 23:03:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 39BFF29E90 for ; Wed, 6 Dec 2017 23:03:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2E5A129E92; Wed, 6 Dec 2017 23:03:58 +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 A3EAA29E90 for ; Wed, 6 Dec 2017 23:03:57 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 100BC89FD3; Wed, 6 Dec 2017 23:03:57 +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 4ACA489FD3 for ; Wed, 6 Dec 2017 23:03:55 +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:55 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.45,369,1508828400"; d="scan'208";a="10217820" Received: from relo-linux-2.fm.intel.com ([10.1.27.122]) by orsmga003.jf.intel.com with ESMTP; 06 Dec 2017 15:03:54 -0800 From: Antonio Argenziano To: intel-gfx@lists.freedesktop.org Date: Wed, 6 Dec 2017 15:03:43 -0800 Message-Id: <20171206230346.30767-2-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 2/5] igt_hang_ctx: Wrap 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 This patch wraps the parameters for the function used to hang a context (igt_hang_ctx) into a struct to cleanup the interface and make it easier to add more parameters. 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 | 2 +- tests/gem_reset_stats.c | 4 ++-- tests/gem_softpin.c | 2 +- 6 files changed, 44 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..c9a2b508 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){0, ring, 0, NULL}); } /** 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..75fb2364 100644 --- a/tests/drv_hangman.c +++ b/tests/drv_hangman.c @@ -187,7 +187,7 @@ 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){0, ring_id, HANG_ALLOW_CAPTURE, &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..19174307 100644 --- a/tests/gem_reset_stats.c +++ b/tests/gem_reset_stats.c @@ -161,7 +161,7 @@ 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, e->exec_id | e->flags, flags & BAN, NULL}); if ((flags & ASYNC) == 0) igt_post_hang_ring(fd, hang); } @@ -543,7 +543,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){0, e->exec_id | e->flags, 0, NULL}); 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..9256138a 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){0, 0, 0, (uint64_t *)&expected}); object.offset = expected; object.flags = EXEC_OBJECT_PINNED;