From patchwork Thu Feb 25 15:19:34 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniele Ceraolo Spurio X-Patchwork-Id: 8424581 Return-Path: X-Original-To: patchwork-intel-gfx@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 18C819F52D for ; Thu, 25 Feb 2016 15:20:15 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 49F822035E for ; Thu, 25 Feb 2016 15:20:14 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 91AFF2035B for ; Thu, 25 Feb 2016 15:20:11 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 25BEF6E8D3; Thu, 25 Feb 2016 15:20:11 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by gabe.freedesktop.org (Postfix) with ESMTP id 7AFBD6E8D3 for ; Thu, 25 Feb 2016 15:20:10 +0000 (UTC) Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga102.jf.intel.com with ESMTP; 25 Feb 2016 07:20:00 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.22,498,1449561600"; d="scan'208";a="911149202" Received: from dceraolo-linux2.isw.intel.com ([10.102.226.73]) by fmsmga001.fm.intel.com with ESMTP; 25 Feb 2016 07:19:58 -0800 From: daniele.ceraolospurio@intel.com To: intel-gfx@lists.freedesktop.org Date: Thu, 25 Feb 2016 15:19:34 +0000 Message-Id: <1456413574-31876-1-git-send-email-daniele.ceraolospurio@intel.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1456396331-27262-1-git-send-email-daniele.ceraolospurio@intel.com> References: <1456396331-27262-1-git-send-email-daniele.ceraolospurio@intel.com> Subject: [Intel-gfx] [PATCH i-g-t v3] tests/drv_hangman: test for acthd increasing through invalid VM space 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-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Daniele Ceraolo Spurio The hangcheck logic will not flag an hang if acthd keeps increasing. However, if a malformed batch jumps to an invalid offset in the ppgtt it can potentially continue executing through the whole address space without triggering the hangcheck mechanism. This patch adds a test to simulate the issue. I've kept the test running for more than 10 minutes before killing it on a BDW and no hang occurred. I've sampled i915_hangcheck_info a few times during the run and got the following: Hangcheck active, fires in 468ms render ring: seqno = fffff55e [current fffff55e] ACTHD = 0x47df685ecc [current 0x4926b81d90] max ACTHD = 0x47df685ecc score = 0 action = 2 instdone read = 0xffd7ffff 0xffffffff 0xffffffff 0xffffffff instdone accu = 0x00000000 0x00000000 0x00000000 0x00000000 Hangcheck active, fires in 424ms render ring: seqno = fffff55e [current fffff55e] ACTHD = 0x6c953d3a34 [current 0x6de5e76fa4] max ACTHD = 0x6c953d3a34 score = 0 action = 2 instdone read = 0xffd7ffff 0xffffffff 0xffffffff 0xffffffff instdone accu = 0x00000000 0x00000000 0x00000000 0x00000000 Hangcheck active, fires in 1692ms render ring: seqno = fffff55e [current fffff55e] ACTHD = 0x1f49b0366dc [current 0x1f4dcbd88ec] max ACTHD = 0x1f49b0366dc score = 0 action = 2 instdone read = 0xffd7ffff 0xffffffff 0xffffffff 0xffffffff instdone accu = 0x00000000 0x00000000 0x00000000 0x00000000 v2: use the new gem_wait() function (Chris) v3: switch to unterminated batch and rename test, remove redundant check, update test requirements (Chris), update top comment Cc: Mika Kuoppala Cc: Arun Siluvery Cc: Chris Wilson Signed-off-by: Daniele Ceraolo Spurio --- tests/drv_hangman.c | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/tests/drv_hangman.c b/tests/drv_hangman.c index 8a465cf..2360f26 100644 --- a/tests/drv_hangman.c +++ b/tests/drv_hangman.c @@ -288,6 +288,42 @@ static void test_error_state_capture(unsigned ring_id, check_error_state(gen, cmd_parser, ring_name, offset); } +/* This test covers the case where we end up in an uninitialised area of the + * ppgtt and keep executing through it. This is particularly relevant if 48b + * ppgtt is enabled because the ppgtt is massively bigger compared to the 32b + * case and it takes a lot more time to wrap, so the acthd can potentially keep + * increasing for a long time + */ +#define NSEC_PER_SEC 1000000000L +static void hangcheck_unterminated(void) +{ + int fd; + /* timeout needs to be greater than ~5*hangcheck */ + int64_t timeout_ns = 100 * NSEC_PER_SEC; /* 100 seconds */ + struct drm_i915_gem_execbuffer2 execbuf; + struct drm_i915_gem_exec_object2 gem_exec; + uint32_t handle; + + fd = drm_open_driver(DRIVER_INTEL); + igt_require(gem_uses_full_ppgtt(fd)); + igt_require_hang_ring(fd, 0); + + handle = gem_create(fd, 4096); + + memset(&gem_exec, 0, sizeof(gem_exec)); + gem_exec.handle = handle; + + memset(&execbuf, 0, sizeof(execbuf)); + execbuf.buffers_ptr = (uintptr_t)&gem_exec; + execbuf.buffer_count = 1; + execbuf.batch_len = 8; + + gem_execbuf(fd, &execbuf); + igt_assert_eq(gem_wait(fd, handle, &timeout_ns), 0); + + close(fd); +} + igt_main { const struct intel_execution_engine *e; @@ -314,4 +350,7 @@ igt_main test_error_state_capture(e->exec_id | e->flags, e->full_name); } + + igt_subtest("hangcheck-unterminated") + hangcheck_unterminated(); }