From patchwork Fri Jul 29 09:34:36 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Antoine X-Patchwork-Id: 9252403 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 AD88F601C0 for ; Fri, 29 Jul 2016 09:34:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9E9972094D for ; Fri, 29 Jul 2016 09:34:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9376C27F9E; Fri, 29 Jul 2016 09:34:56 +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 18FCA2094D for ; Fri, 29 Jul 2016 09:34:56 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 44CC66E967; Fri, 29 Jul 2016 09:34:49 +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 552346E969 for ; Fri, 29 Jul 2016 09:34:45 +0000 (UTC) Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga102.jf.intel.com with ESMTP; 29 Jul 2016 02:34:45 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.28,438,1464678000"; d="scan'208";a="741417709" Received: from peterant-linux2.isw.intel.com ([10.102.226.41]) by FMSMGA003.fm.intel.com with ESMTP; 29 Jul 2016 02:34:44 -0700 From: Peter Antoine To: intel-gfx@lists.freedesktop.org Date: Fri, 29 Jul 2016 10:34:36 +0100 Message-Id: <1469784876-33201-5-git-send-email-peter.antoine@intel.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1469784876-33201-1-git-send-email-peter.antoine@intel.com> References: <1469784876-33201-1-git-send-email-peter.antoine@intel.com> Subject: [Intel-gfx] [I-G-T 3/3] igt/gem_mocs_settings: Reduce the amount of cascading failures 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 If one of the previous tests fails then the following tests fail. This patch means that the following tests do not fail when the previous test fails (for some cases). Signed-off-by: Peter Antoine --- lib/igt_aux.c | 67 +++++++++++++++++++++++++++++++++++++++++++++++ lib/igt_aux.h | 2 ++ tests/gem_mocs_settings.c | 56 +++++++++++++++++++++------------------ 3 files changed, 99 insertions(+), 26 deletions(-) diff --git a/lib/igt_aux.c b/lib/igt_aux.c index 1cb9398..cc3ce26 100644 --- a/lib/igt_aux.c +++ b/lib/igt_aux.c @@ -629,6 +629,41 @@ void igt_cleanup_aperture_trashers(void) #define SQUELCH ">/dev/null 2>&1" /** + * igt_system_suspend_autoresume_no_assert: + * + * Execute a system suspend-to-mem cycle and automatically wake up again using + * the firmware's resume timer. + * + * This is very handy for implementing any kind of suspend/resume test. + * + * This version does not cause an "exception" as the test will need to tidy-up + * to allow for subsequent tests to run. + */ +bool igt_system_suspend_autoresume_no_assert(void) +{ + /* FIXME: Simulation doesn't like suspend/resume, and not even a lighter + * approach using /sys/power/pm_test to just test our driver's callbacks + * seems to fare better. We need to investigate what's going on. */ + if (igt_run_in_simulation()) { + igt_debug("autoresume cannot be used in simulation\n"); + return false; + + } else if (system("rtcwake -n -s 15 -m mem" SQUELCH) != 0) { + igt_debug("rtcwake -n -s 15 -m mem is not supported\n"); + return false; + + } else if (system("rtcwake -s 15 -m mem") != 0) { + igt_debug( + "This failure means that something is wrong with the " + "rtcwake tool or how your distro is set up. This is not " + "a i915.ko or i-g-t bug.\n"); + return false; + } + + return true; +} + +/** * igt_system_suspend_autoresume: * * Execute a system suspend-to-mem cycle and automatically wake up again using @@ -653,6 +688,38 @@ void igt_system_suspend_autoresume(void) } /** + * igt_system_hibernate_autoresume_no_assert: + * + * Execute a system suspend-to-disk cycle and automatically wake up again using + * the firmware's resume timer. + * + * This is very handy for implementing any kind of hibernate/resume test. + * + * This version does not cause an "exception" as the test will need to tidy-up + * to allow for subsequent tests to run. + */ +bool igt_system_hibernate_autoresume_no_assert(void) +{ + if (igt_run_in_simulation()) { + igt_debug("autoresume cannot be used in simulation\n"); + return false; + + } else if (system("rtcwake -n -s 30 -m disk" SQUELCH) != 0) { + igt_debug("rtcwake -n -s 30 -m disk is not supported\n"); + return false; + + } else if (system("rtcwake -s 30 -m disk") != 0) { + igt_debug( + "This failure means that something is wrong with the " + "rtcwake tool or how your distro is set up. This is not " + "a i915.ko or i-g-t bug.\n"); + return false; + } + + return true; +} + +/** * igt_system_hibernate_autoresume: * * Execute a system suspend-to-disk cycle and automatically wake up again using diff --git a/lib/igt_aux.h b/lib/igt_aux.h index be0d2d6..483c444 100644 --- a/lib/igt_aux.h +++ b/lib/igt_aux.h @@ -103,7 +103,9 @@ void igt_cleanup_aperture_trashers(void); /* suspend/hibernate and auto-resume system */ void igt_system_suspend_autoresume(void); +bool igt_system_suspend_autoresume_no_assert(void); void igt_system_hibernate_autoresume(void); +bool igt_system_hibernate_autoresume_no_assert(void); /* dropping priviledges */ void igt_drop_root(void); diff --git a/tests/gem_mocs_settings.c b/tests/gem_mocs_settings.c index 66d02d9..1da7473 100644 --- a/tests/gem_mocs_settings.c +++ b/tests/gem_mocs_settings.c @@ -373,6 +373,27 @@ static void test_mocs_values(int fd) } } +static void action_test(int fd, unsigned int mode) +{ + switch (mode) { + case RESET: + igt_force_gpu_reset(); + break; + case SUSPEND: + if (!igt_system_suspend_autoresume_no_assert()) { + close(fd); + igt_fail(1); + } + break; + case HIBERNATE: + if (!igt_system_hibernate_autoresume_no_assert()) { + close(fd); + igt_fail(1); + } + break; + } +} + static void default_context_tests(unsigned mode) { int fd = drm_open_driver_master(DRIVER_INTEL); @@ -380,12 +401,7 @@ static void default_context_tests(unsigned mode) igt_debug("Testing Non/Default Context Engines\n"); test_mocs_values(fd); - switch (mode) { - case NONE: break; - case RESET: igt_force_gpu_reset(); break; - case SUSPEND: igt_system_suspend_autoresume(); break; - case HIBERNATE: igt_system_hibernate_autoresume(); break; - } + action_test(fd, mode); test_mocs_values(fd); close(fd); @@ -419,12 +435,7 @@ static void default_dirty_tests(unsigned mode) engine); } - switch (mode) { - case NONE: break; - case RESET: igt_force_gpu_reset(); break; - case SUSPEND: igt_system_suspend_autoresume(); break; - case HIBERNATE: igt_system_hibernate_autoresume(); break; - } + action_test(fd, mode); close(fd); @@ -442,12 +453,7 @@ static void context_save_restore_test(unsigned mode) check_control_registers(fd, I915_EXEC_RENDER, ctx_id, false); check_l3cc_registers(fd, I915_EXEC_RENDER, ctx_id, false); - switch (mode) { - case NONE: break; - case RESET: igt_force_gpu_reset(); break; - case SUSPEND: igt_system_suspend_autoresume(); break; - case HIBERNATE: igt_system_hibernate_autoresume(); break; - } + action_test(fd, mode); check_control_registers(fd, I915_EXEC_RENDER, ctx_id, false); check_l3cc_registers(fd, I915_EXEC_RENDER, ctx_id, false); @@ -485,12 +491,7 @@ static void context_dirty_test(unsigned mode) check_control_registers(fd, I915_EXEC_RENDER, ctx_id, true); check_l3cc_registers(fd, I915_EXEC_RENDER, ctx_id, true); - switch (mode) { - case NONE: break; - case RESET: igt_force_gpu_reset(); break; - case SUSPEND: igt_system_suspend_autoresume(); break; - case HIBERNATE: igt_system_hibernate_autoresume(); break; - } + action_test(fd, mode); check_control_registers(fd, I915_EXEC_RENDER, ctx_id, true); check_l3cc_registers(fd, I915_EXEC_RENDER, ctx_id, true); @@ -562,8 +563,11 @@ static void context_rc6_test(void) check_l3cc_registers(fd, I915_EXEC_RENDER, ctx_id, false); res_ms = read_rc6_residency(); - sleep(3); - igt_assert_neq(res_ms, read_rc6_residency()); + sleep(6); + if (res_ms == read_rc6_residency()) { + close(fd); + igt_assert_neq(res_ms, read_rc6_residency()); + } check_control_registers(fd, I915_EXEC_RENDER, ctx_id, false); check_l3cc_registers(fd, I915_EXEC_RENDER, ctx_id, false);