From patchwork Tue Oct 22 15:58:58 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Wilson X-Patchwork-Id: 11204775 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 B9D31913 for ; Tue, 22 Oct 2019 15:59:51 +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 A26F6214B2 for ; Tue, 22 Oct 2019 15:59:51 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A26F6214B2 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 5912C6E879; Tue, 22 Oct 2019 15:59:50 +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 BFA496E86B for ; Tue, 22 Oct 2019 15:59:35 +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 18927715-1500050 for multiple; Tue, 22 Oct 2019 16:59:18 +0100 From: Chris Wilson To: intel-gfx@lists.freedesktop.org Date: Tue, 22 Oct 2019 16:58:58 +0100 Message-Id: <20191022155907.32203-1-chris@chris-wilson.co.uk> X-Mailer: git-send-email 2.24.0.rc0 MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH i-g-t 01/10] i915: Exercise hostile context execution 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: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" Verify that contexts are automatically shotdown on close if hangchecking is disabled. Basic environmental robustness test stolen from gem_ctx_persistence. Signed-off-by: Chris Wilson Cc: Jon Bloomfield Cc: Tvrtko Ursulin --- tests/i915/gem_ctx_exec.c | 41 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/tests/i915/gem_ctx_exec.c b/tests/i915/gem_ctx_exec.c index 614a9f401..92e899869 100644 --- a/tests/i915/gem_ctx_exec.c +++ b/tests/i915/gem_ctx_exec.c @@ -40,6 +40,8 @@ #include +#include "igt_dummyload.h" +#include "igt_sysfs.h" IGT_TEST_DESCRIPTION("Test context batch buffer execution."); @@ -196,6 +198,42 @@ static void norecovery(int i915) igt_disallow_hang(i915, hang); } +static bool __enable_hangcheck(int dir, bool state) +{ + return igt_sysfs_set(dir, "enable_hangcheck", state ? "1" : "0"); +} + +static void nohangcheck_hostile(int i915) +{ + int64_t timeout = NSEC_PER_SEC / 2; + igt_spin_t *spin; + uint32_t ctx; + int dir; + + /* + * Even if the user disables hangcheck during their context, + * we forcibly terminate that context. + */ + + dir = igt_sysfs_open_parameters(i915); + igt_require(dir != -1); + + ctx = gem_context_create(i915); + + igt_require(__enable_hangcheck(dir, false)); + + spin = igt_spin_new(i915, ctx, .flags = IGT_SPIN_NO_PREEMPTION); + gem_context_destroy(i915, ctx); + + igt_assert_eq(gem_wait(i915, spin->handle, &timeout), 0); + + igt_require(__enable_hangcheck(dir, true)); + + igt_spin_free(i915, spin); + gem_quiescent_gpu(i915); + close(dir); +} + igt_main { const uint32_t batch[2] = { 0, MI_BATCH_BUFFER_END }; @@ -239,6 +277,9 @@ igt_main igt_subtest("basic-norecovery") norecovery(fd); + igt_subtest("basic-nohangcheck") + nohangcheck_hostile(fd); + igt_subtest("reset-pin-leak") { int i;