From patchwork Fri Jan 10 15:24:16 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mika Kuoppala X-Patchwork-Id: 3466971 Return-Path: X-Original-To: patchwork-intel-gfx@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 5F66EC02DC for ; Fri, 10 Jan 2014 15:24:35 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 2E67E20121 for ; Fri, 10 Jan 2014 15:24:34 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 03845200EC for ; Fri, 10 Jan 2014 15:24:33 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 23A8A10645F; Fri, 10 Jan 2014 07:24:32 -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 A461310645F for ; Fri, 10 Jan 2014 07:24:30 -0800 (PST) Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga101.jf.intel.com with ESMTP; 10 Jan 2014 07:24:20 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.95,638,1384329600"; d="scan'208";a="456734830" Received: from rosetta.fi.intel.com (HELO rosetta) ([10.237.72.60]) by fmsmga001.fm.intel.com with ESMTP; 10 Jan 2014 07:24:18 -0800 Received: by rosetta (Postfix, from userid 1000) id 233F881E14; Fri, 10 Jan 2014 17:24:18 +0200 (EET) From: Mika Kuoppala To: intel-gfx@lists.freedesktop.org Date: Fri, 10 Jan 2014 17:24:16 +0200 Message-Id: <1389367457-13513-1-git-send-email-mika.kuoppala@intel.com> X-Mailer: git-send-email 1.7.9.5 Subject: [Intel-gfx] [PATCH 1/2] tests/gem_reset_stats: split ctx tests X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: intel-gfx-bounces@lists.freedesktop.org Errors-To: intel-gfx-bounces@lists.freedesktop.org X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, 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 Split context related tests from non-context ones and cleanup the naming. Signed-off-by: Mika Kuoppala --- tests/gem_reset_stats.c | 138 ++++++++++++++++++++++++++++++++++++----------- 1 file changed, 108 insertions(+), 30 deletions(-) diff --git a/tests/gem_reset_stats.c b/tests/gem_reset_stats.c index 0515605..bed4a0c 100644 --- a/tests/gem_reset_stats.c +++ b/tests/gem_reset_stats.c @@ -462,6 +462,94 @@ static void test_rs_ctx(int num_fds, int num_ctx, int hang_index, static void test_ban(void) { int h1,h2,h3,h4,h5,h6,h7; + int fd_bad, fd_good; + int retry = 10; + int active_count = 0, pending_count = 0; + struct local_drm_i915_reset_stats rs_bad, rs_good; + + fd_bad = drm_open_any(); + igt_assert(fd_bad >= 0); + + fd_good = drm_open_any(); + igt_assert(fd_good >= 0); + + assert_reset_status(fd_bad, 0, RS_NO_ERROR); + assert_reset_status(fd_good, 0, RS_NO_ERROR); + + h1 = exec_valid(fd_bad, 0); + igt_assert(h1 >= 0); + h5 = exec_valid(fd_good, 0); + igt_assert(h5 >= 0); + + assert_reset_status(fd_bad, 0, RS_NO_ERROR); + assert_reset_status(fd_good, 0, RS_NO_ERROR); + + h2 = inject_hang(fd_bad, 0); + igt_assert(h2 >= 0); + active_count++; + /* Second hang will be pending for this */ + pending_count++; + + h6 = exec_valid(fd_good, 0); + h7 = exec_valid(fd_good, 0); + + while (retry--) { + h3 = inject_hang(fd_bad, 0); + igt_assert(h3 >= 0); + gem_sync(fd_bad, h3); + active_count++; + /* This second hand will count as pending */ + assert_reset_status(fd_bad, 0, RS_BATCH_ACTIVE); + + h4 = exec_valid(fd_bad, 0); + if (h4 == -EIO) { + gem_close(fd_bad, h3); + break; + } + + /* Should not happen often but sometimes hang is declared too slow + * due to our way of faking hang using loop */ + + igt_assert(h4 >= 0); + gem_close(fd_bad, h3); + gem_close(fd_bad, h4); + + printf("retrying for ban (%d)\n", retry); + } + + igt_assert(h4 == -EIO); + assert_reset_status(fd_bad, 0, RS_BATCH_ACTIVE); + + gem_sync(fd_good, h7); + assert_reset_status(fd_good, 0, RS_BATCH_PENDING); + + igt_assert(gem_reset_stats(fd_good, 0, &rs_good) == 0); + igt_assert(gem_reset_stats(fd_bad, 0, &rs_bad) == 0); + + igt_assert(rs_bad.batch_active == active_count); + igt_assert(rs_bad.batch_pending == pending_count); + igt_assert(rs_good.batch_active == 0); + igt_assert(rs_good.batch_pending == 2); + + gem_close(fd_bad, h1); + gem_close(fd_bad, h2); + gem_close(fd_good, h6); + gem_close(fd_good, h7); + + h1 = exec_valid(fd_good, 0); + igt_assert(h1 >= 0); + gem_close(fd_good, h1); + + close(fd_bad); + close(fd_good); + + igt_assert(gem_reset_status(fd_bad, 0) < 0); + igt_assert(gem_reset_status(fd_good, 0) < 0); +} + +static void test_ban_ctx(void) +{ + int h1,h2,h3,h4,h5,h6,h7; int ctx_good, ctx_bad; int fd; int retry = 10; @@ -554,7 +642,7 @@ static void test_ban(void) close(fd); } -static void test_nonrelated_hang(void) +static void test_unrelated_ctx(void) { int h1,h2; int fd1,fd2; @@ -603,7 +691,7 @@ static int get_reset_count(int fd, int ctx) return rs.reset_count; } -static void test_double_destroy_pending(void) +static void test_close_pending_ctx(void) { int fd, h; uint32_t ctx; @@ -766,7 +854,7 @@ static void drop_root(void) igt_assert(getuid() == 2); } -static void __test_count(const bool create_ctx) +static void test_reset_count(const bool create_ctx) { int fd, h, ctx; long c1, c2; @@ -813,22 +901,6 @@ static void __test_count(const bool create_ctx) close(fd); } -static void test_count(void) -{ - return __test_count(false); -} - -static void test_count_context(void) -{ - return __test_count(true); -} - -static void test_global_reset_count(void) -{ - test_count(); - test_count_context(); -} - static int _test_params(int fd, int ctx, uint32_t flags, uint32_t pad) { struct local_drm_i915_reset_stats rs; @@ -934,32 +1006,38 @@ igt_main close(fd); } - igt_subtest("basic-reset-status") + igt_subtest("params") + test_params(); + + igt_subtest("reset-stats") test_rs(4, 1, 0); - igt_subtest("context-reset-status") + igt_subtest("reset-stats-ctx") test_rs_ctx(4, 4, 1, 2); igt_subtest("ban") test_ban(); - igt_subtest("ctx-unrelated") - test_nonrelated_hang(); + igt_subtest("ban-ctx") + test_ban_ctx(); + + igt_subtest("unrelated-ctx") + test_unrelated_ctx(); - igt_subtest("global-count") - test_global_reset_count(); + igt_subtest("reset-count") + test_reset_count(false); - igt_subtest("double-destroy-pending") - test_double_destroy_pending(); + igt_subtest("reset-count-ctx") + test_reset_count(true); igt_subtest("close-pending") test_close_pending(); + igt_subtest("close-pending-ctx") + test_close_pending_ctx(); + igt_subtest("close-pending-fork") { test_close_pending_fork(true); test_close_pending_fork(false); } - - igt_subtest("params") - test_params(); }