From patchwork Fri Mar 28 16:38:50 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mika Kuoppala X-Patchwork-Id: 3904931 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 4F035BF540 for ; Fri, 28 Mar 2014 16:39:23 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 7BF3520304 for ; Fri, 28 Mar 2014 16:39:22 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 93018202A7 for ; Fri, 28 Mar 2014 16:39:21 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 1E9726ED48; Fri, 28 Mar 2014 09:39:21 -0700 (PDT) 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 99EB36ED48 for ; Fri, 28 Mar 2014 09:39:20 -0700 (PDT) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga101.jf.intel.com with ESMTP; 28 Mar 2014 09:38:59 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.97,751,1389772800"; d="scan'208";a="509772038" Received: from rosetta.fi.intel.com (HELO rosetta) ([10.237.72.72]) by orsmga002.jf.intel.com with ESMTP; 28 Mar 2014 09:38:53 -0700 Received: by rosetta (Postfix, from userid 1000) id 952C581668; Fri, 28 Mar 2014 18:38:52 +0200 (EET) From: Mika Kuoppala To: intel-gfx@lists.freedesktop.org Date: Fri, 28 Mar 2014 18:38:50 +0200 Message-Id: <1396024730-9514-4-git-send-email-mika.kuoppala@intel.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1396024730-9514-1-git-send-email-mika.kuoppala@intel.com> References: <1396024730-9514-1-git-send-email-mika.kuoppala@intel.com> Subject: [Intel-gfx] [PATCH 4/4] tests/gem_reset_stats: check gpu state before each subtest X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.15 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.6 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 Some tests, namely the close pending variety, tries to carefully drop all handles to gpu when hang is intruduced, to expose bugs in reset handling without any clients. Add guards after and before tests to really know if the gpu is still alive as the particular test might report success and then gpu dies few seconds after. Signed-off-by: Mika Kuoppala --- tests/gem_reset_stats.c | 66 ++++++++++++++++++++++++++++++++--------------- 1 file changed, 45 insertions(+), 21 deletions(-) diff --git a/tests/gem_reset_stats.c b/tests/gem_reset_stats.c index 9581703..f402d97 100644 --- a/tests/gem_reset_stats.c +++ b/tests/gem_reset_stats.c @@ -1057,16 +1057,41 @@ static bool gem_has_reset_stats(int fd) return false; } -#define RING_HAS_CONTEXTS (current_ring->contexts(current_ring)) -#define RUN_CTX_TEST(...) do { igt_skip_on(RING_HAS_CONTEXTS == false); __VA_ARGS__; } while (0) +static void check_gpu_ok(void) +{ + int retry_count = 30; + enum stop_ring_flags flags; + int fd; + + igt_debug("checking gpu state\n"); + + while (retry_count--) { + flags = igt_get_stop_rings(); + if (flags == 0) + break; + + igt_debug("waiting previous hang to clear\n"); + sleep(1); + } + + igt_assert(flags == 0); + + fd = drm_open_any(); + gem_quiescent_gpu(fd); + close(fd); +} -static int fd; +#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) igt_main { igt_skip_on_simulation(); igt_fixture { + int fd; + bool has_reset_stats; fd = drm_open_any(); devid = intel_get_drm_devid(fd); @@ -1074,6 +1099,8 @@ igt_main hw_contexts = gem_has_hw_contexts(fd); has_reset_stats = gem_has_reset_stats(fd); + close(fd); + igt_require_f(has_reset_stats, "No reset stats ioctl support. Too old kernel?\n"); } @@ -1087,8 +1114,11 @@ igt_main current_ring = &rings[i]; name = current_ring->name; - igt_fixture + igt_fixture { + int fd = drm_open_any(); gem_require_ring(fd, current_ring->exec); + close(fd); + } igt_fixture igt_require_f(intel_gen(devid) >= 4, @@ -1098,19 +1128,19 @@ igt_main RUN_CTX_TEST(test_params_ctx()); igt_subtest_f("reset-stats-%s", name) - test_rs(4, 1, 0); + RUN_TEST(test_rs(4, 1, 0)); igt_subtest_f("reset-stats-ctx-%s", name) RUN_CTX_TEST(test_rs_ctx(4, 4, 1, 2)); igt_subtest_f("ban-%s", name) - test_ban(); + RUN_TEST(test_ban()); igt_subtest_f("ban-ctx-%s", name) RUN_CTX_TEST(test_ban_ctx()); igt_subtest_f("reset-count-%s", name) - test_reset_count(false); + RUN_TEST(test_reset_count(false)); igt_subtest_f("reset-count-ctx-%s", name) RUN_CTX_TEST(test_reset_count(true)); @@ -1118,22 +1148,16 @@ igt_main igt_subtest_f("unrelated-ctx-%s", name) RUN_CTX_TEST(test_unrelated_ctx()); - igt_subtest_f("close-pending-%s", name) { - test_close_pending(); - gem_quiescent_gpu(fd); - } + igt_subtest_f("close-pending-%s", name) + RUN_TEST(test_close_pending()); - igt_subtest_f("close-pending-ctx-%s", name) { + igt_subtest_f("close-pending-ctx-%s", name) RUN_CTX_TEST(test_close_pending_ctx()); - gem_quiescent_gpu(fd); - } - igt_subtest_f("close-pending-fork-%s", name) { - test_close_pending_fork(true); - test_close_pending_fork(false); - } - } + igt_subtest_f("close-pending-fork-%s", name) + RUN_TEST(test_close_pending_fork(false)); - igt_fixture - close(fd); + igt_subtest_f("close-pending-fork-reverse-%s", name) + RUN_TEST(test_close_pending_fork(true)); + } }