From patchwork Thu Nov 14 19:15:46 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Wilson X-Patchwork-Id: 11244343 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9A1536C1 for ; Thu, 14 Nov 2019 19:16:14 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 81AE520718 for ; Thu, 14 Nov 2019 19:16:14 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 81AE520718 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=chris-wilson.co.uk Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=intel-gfx-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 11C1F6E07F; Thu, 14 Nov 2019 19:16:13 +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 CC9B46E07F; Thu, 14 Nov 2019 19:16:11 +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 19205176-1500050 for multiple; Thu, 14 Nov 2019 19:15:47 +0000 From: Chris Wilson To: intel-gfx@lists.freedesktop.org Date: Thu, 14 Nov 2019 19:15:46 +0000 Message-Id: <20191114191546.149722-1-chris@chris-wilson.co.uk> X-Mailer: git-send-email 2.24.0 MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH i-g-t] i915/gem_exec_balancer: Throw a few hangs into the virtual pipelines 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 Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" Although a virtual engine itself has no hang detection; that is on the underlying physical engines, it does provide a unique means for clients to try and break the system. Try and break it before they do. Signed-off-by: Chris Wilson Cc: Tvrtko Ursulin Reviewed-by: Tvrtko Ursulin --- tests/i915/gem_exec_balancer.c | 105 +++++++++++++++++++++++++++++++++ 1 file changed, 105 insertions(+) diff --git a/tests/i915/gem_exec_balancer.c b/tests/i915/gem_exec_balancer.c index 70c4529b4..86028cfdd 100644 --- a/tests/i915/gem_exec_balancer.c +++ b/tests/i915/gem_exec_balancer.c @@ -24,6 +24,7 @@ #include #include "igt.h" +#include "igt_gt.h" #include "igt_perf.h" #include "i915/gem_ring.h" #include "sw_sync.h" @@ -1314,6 +1315,102 @@ static void semaphore(int i915) gem_quiescent_gpu(i915); } +static void set_unbannable(int i915, uint32_t ctx) +{ + struct drm_i915_gem_context_param p = { + .ctx_id = ctx, + .param = I915_CONTEXT_PARAM_BANNABLE, + }; + + igt_assert_eq(__gem_context_set_param(i915, &p), 0); +} + +static void hangme(int i915) +{ + struct drm_i915_gem_exec_object2 batch = { + .handle = batch_create(i915), + }; + + /* + * Fill the available engines with hanging virtual engines and verify + * that execution continues onto the second batch. + */ + + for (int class = 1; class < 32; class++) { + struct i915_engine_class_instance *ci; + struct client { + igt_spin_t *spin[2]; + } *client; + unsigned int count; + uint32_t bg; + + ci = list_engines(i915, 1u << class, &count); + if (!ci) + continue; + + if (count < 2) { + free(ci); + continue; + } + + client = malloc(sizeof(*client) * count); + igt_assert(client); + + for (int i = 0; i < count; i++) { + uint32_t ctx = gem_context_create(i915); + struct client *c = &client[i]; + unsigned int flags; + + set_unbannable(i915, ctx); + set_load_balancer(i915, ctx, ci, count, NULL); + + flags = IGT_SPIN_FENCE_OUT | IGT_SPIN_NO_PREEMPTION; + for (int j = 0; j < ARRAY_SIZE(c->spin); j++) { + c->spin[j] = igt_spin_new(i915, ctx, + .flags = flags); + flags = IGT_SPIN_FENCE_OUT; + } + + gem_context_destroy(i915, ctx); + } + + /* Apply some background context to speed up hang detection */ + bg = gem_context_create(i915); + set_engines(i915, bg, ci, count); + for (int i = 0; i < count; i++) { + struct drm_i915_gem_execbuffer2 execbuf = { + .buffers_ptr = to_user_pointer(&batch), + .buffer_count = 1, + .flags = i, + .rsvd1 = bg, + }; + gem_execbuf(i915, &execbuf); + } + gem_context_destroy(i915, bg); + + for (int i = 0; i < count; i++) { + struct client *c = &client[i]; + + igt_debug("Waiting for client[%d].spin[%d]\n", i, 0); + gem_sync(i915, c->spin[0]->handle); + igt_assert_eq(sync_fence_status(c->spin[0]->out_fence), + -EIO); + + igt_debug("Waiting for client[%d].spin[%d]\n", i, 1); + gem_sync(i915, c->spin[1]->handle); + igt_assert_eq(sync_fence_status(c->spin[1]->out_fence), + -EIO); + + igt_spin_free(i915, c->spin[0]); + igt_spin_free(i915, c->spin[1]); + } + free(client); + } + + gem_close(i915, batch.handle); + gem_quiescent_gpu(i915); +} + static void smoketest(int i915, int timeout) { struct drm_i915_gem_exec_object2 batch[2] = { @@ -1486,4 +1583,12 @@ igt_main igt_fixture { igt_stop_hang_detector(); } + + igt_subtest("hang") { + igt_hang_t hang = igt_allow_hang(i915, 0, 0); + + hangme(i915); + + igt_disallow_hang(i915, hang); + } }