From patchwork Thu Jan 29 13:32:51 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mika Kuoppala X-Patchwork-Id: 5742301 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 481A89F399 for ; Thu, 29 Jan 2015 13:32:59 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 66D0D2022D for ; Thu, 29 Jan 2015 13:32:58 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 7AFEF201DD for ; Thu, 29 Jan 2015 13:32:57 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 7600C72094; Thu, 29 Jan 2015 05:32:56 -0800 (PST) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by gabe.freedesktop.org (Postfix) with ESMTP id 6A7B672094 for ; Thu, 29 Jan 2015 05:32:55 -0800 (PST) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga101.jf.intel.com with ESMTP; 29 Jan 2015 05:32:53 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.09,486,1418112000"; d="scan'208";a="669694318" Received: from rosetta.fi.intel.com (HELO rosetta) ([10.237.72.102]) by fmsmga002.fm.intel.com with ESMTP; 29 Jan 2015 05:32:52 -0800 Received: by rosetta (Postfix, from userid 1000) id 1E1B180054; Thu, 29 Jan 2015 15:32:54 +0200 (EET) From: Mika Kuoppala To: intel-gfx@lists.freedesktop.org Date: Thu, 29 Jan 2015 15:32:51 +0200 Message-Id: <1422538371-20043-2-git-send-email-mika.kuoppala@intel.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1422538371-20043-1-git-send-email-mika.kuoppala@intel.com> References: <1422538371-20043-1-git-send-email-mika.kuoppala@intel.com> Subject: [Intel-gfx] [PATCH 2/2] tests/gem_reset_stats: add tests for ban period ioctl 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=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, T_RP_MATCHES_RCVD, 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 Test parameter set/get for ban periods. Test actual impact on banning. Signed-off-by: Mika Kuoppala --- tests/gem_reset_stats.c | 101 +++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 100 insertions(+), 1 deletion(-) diff --git a/tests/gem_reset_stats.c b/tests/gem_reset_stats.c index 646d6da..7b04fb7 100644 --- a/tests/gem_reset_stats.c +++ b/tests/gem_reset_stats.c @@ -52,6 +52,8 @@ #define RS_BATCH_PENDING (1 << 1) #define RS_UNKNOWN (1 << 2) +IGT_TEST_DESCRIPTION("Checks for RESET_STATS_IOCTL, context banning and reset recovery"); + static uint32_t devid; static bool hw_contexts; @@ -1047,6 +1049,98 @@ static void defer_hangcheck(int ring_num) close(fd); } +static bool was_banned_in_period(int fd, int ctx, int seconds) +{ + int h1,h2,h3,h4; + bool banned; + + h1 = inject_hang_no_ban_error(fd, ctx); + igt_assert(h1 >= 0); + + sleep(seconds); + + h2 = exec_valid(fd, ctx); + igt_assert(h2 >= 0); + + h3 = inject_hang_no_ban_error(fd, ctx); + igt_assert(h3 >= 0); + + gem_sync(fd, h3); + + h4 = exec_valid(fd, ctx); + banned = (h4 == -EIO); + + gem_close(fd, h1); + gem_close(fd, h2); + gem_close(fd, h3); + if (h4 >= 0) + gem_close(fd, h4); + + return banned; +} + +static int get_ban_period(int fd, uint32_t ctx) +{ + struct local_i915_gem_context_param p; + + p.param = LOCAL_CONTEXT_PARAM_BAN_PERIOD; + p.size = rand(); + p.context = ctx; + p.value = ((uint64_t)rand() << 32) | rand(); + + igt_assert(gem_context_get_param(fd, &p) == 0); + + return p.value; +} + +static void set_ban_period(int fd, uint32_t ctx, int period) +{ + struct local_i915_gem_context_param p; + + p.param = LOCAL_CONTEXT_PARAM_BAN_PERIOD; + p.size = 0; + p.context = ctx; + p.value = period; + igt_assert(gem_context_set_param(fd, &p) == 0); +} + +static void test_ban_period(bool new_ctx) +{ + int fd, period; + uint32_t ctx; + + fd = drm_open_any(); + + igt_require(gem_context_has_param(fd, LOCAL_CONTEXT_PARAM_BAN_PERIOD)); + + if (new_ctx) + ctx = context_create(fd); + else + ctx = 0; + + period = get_ban_period(fd, ctx); + igt_assert(period > 2); + + period += 2; + + set_ban_period(fd, ctx, period); + + igt_assert(was_banned_in_period(fd, ctx, period + 2) == false); + + set_ban_period(fd, ctx, 0); + + igt_assert(was_banned_in_period(fd, ctx, 0) == false); + + /* We just hanged, wait for a while */ + sleep(period + 2); + + set_ban_period(fd, ctx, period); + + igt_assert(was_banned_in_period(fd, ctx, period / 4) == true); + + close(fd); +} + static bool gem_has_hw_contexts(int fd) { struct local_drm_i915_gem_context_create create; @@ -1111,7 +1205,7 @@ static void check_gpu_ok(void) #define RING_HAS_CONTEXTS (current_ring->contexts(current_ring)) #define RUN_TEST(...) do { check_gpu_ok(); __VA_ARGS__; check_gpu_ok(); } while (0) -#define RUN_CTX_TEST(...) do { igt_skip_on(RING_HAS_CONTEXTS == false); RUN_TEST(__VA_ARGS__); } while (0) +#define RUN_CTX_TEST(...) do { igt_require(RING_HAS_CONTEXTS); RUN_TEST(__VA_ARGS__); } while (0) igt_main { @@ -1191,5 +1285,10 @@ igt_main igt_subtest_f("defer-hangcheck-%s", name) RUN_TEST(defer_hangcheck(i)); + igt_subtest_f("ban-period-%s", name) + RUN_TEST(test_ban_period(false)); + + igt_subtest_f("ban-period-ctx-%s", name) + RUN_CTX_TEST(test_ban_period(true)); } }