From patchwork Wed Jun 8 13:07:18 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mika Kuoppala X-Patchwork-Id: 9164577 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 BC21160572 for ; Wed, 8 Jun 2016 13:11:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id ADC6426B4A for ; Wed, 8 Jun 2016 13:11:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A270F2823D; Wed, 8 Jun 2016 13:11:36 +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]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3E6D926B4A for ; Wed, 8 Jun 2016 13:11:36 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 6F5CA6E9ED; Wed, 8 Jun 2016 13:11:35 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by gabe.freedesktop.org (Postfix) with ESMTP id 915ED6E9ED for ; Wed, 8 Jun 2016 13:11:33 +0000 (UTC) Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga102.fm.intel.com with ESMTP; 08 Jun 2016 06:10:28 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.26,439,1459839600"; d="scan'208";a="118262815" Received: from gaia.fi.intel.com (HELO gaia) ([10.237.72.84]) by fmsmga004.fm.intel.com with ESMTP; 08 Jun 2016 06:10:28 -0700 Received: by gaia (Postfix, from userid 1000) id 7E1C0404F6; Wed, 8 Jun 2016 16:07:22 +0300 (EEST) From: Mika Kuoppala To: intel-gfx@lists.freedesktop.org Date: Wed, 8 Jun 2016 16:07:18 +0300 Message-Id: <1465391238-32737-2-git-send-email-mika.kuoppala@intel.com> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1465391238-32737-1-git-send-email-mika.kuoppala@intel.com> References: <1465391238-32737-1-git-send-email-mika.kuoppala@intel.com> Subject: [Intel-gfx] [PATCH 2/2] igt/gem_reset_stats: Add time constraints on hang detection 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 Make sure that injected hang is detected below time threshold. This ensures that we fail if hang was of no-progress type instead of a stuck engine. Cc: Chris Wilson Signed-off-by: Mika Kuoppala --- tests/gem_reset_stats.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/tests/gem_reset_stats.c b/tests/gem_reset_stats.c index 27bc6c9cfb59..74c102d3fd7d 100644 --- a/tests/gem_reset_stats.c +++ b/tests/gem_reset_stats.c @@ -148,6 +148,23 @@ static int gem_reset_status(int fd, int ctx_id) return RS_NO_ERROR; } +static struct timespec ts_injected; + +static double elapsed(const struct timespec *start, const struct timespec *end) +{ + return ((end->tv_sec - start->tv_sec) + + (end->tv_nsec - start->tv_nsec)*1e-9); +} + +static double elapsed_from_hang_injection(void) +{ + struct timespec now; + + clock_gettime(CLOCK_MONOTONIC, &now); + + return elapsed(&ts_injected, &now); +} + #define BAN HANG_ALLOW_BAN #define ASYNC 2 static void inject_hang(int fd, uint32_t ctx, @@ -156,6 +173,8 @@ static void inject_hang(int fd, uint32_t ctx, { igt_hang_ring_t hang; + clock_gettime(CLOCK_MONOTONIC, &ts_injected); + hang = igt_hang_ctx(fd, ctx, e->exec_id | e->flags, flags & BAN, NULL); if ((flags & ASYNC) == 0) igt_post_hang_ring(fd, hang); @@ -238,6 +257,8 @@ static void test_rs(const struct intel_execution_engine *e, assert_reset_status(i, fd[i], 0, RS_BATCH_PENDING); } + igt_assert(elapsed_from_hang_injection() < 31.0); + for (i = 0; i < num_fds; i++) close(fd[i]); } @@ -290,6 +311,8 @@ static void test_rs_ctx(const struct intel_execution_engine *e, } sync_gpu(); + igt_assert(elapsed_from_hang_injection() < 31.0); + for (i = 0; i < num_fds; i++) assert_reset_status(i, fd[i], 0, RS_NO_ERROR);