From patchwork Tue Jul 11 22:48:32 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: jim.bride@linux.intel.com X-Patchwork-Id: 9835613 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 BBAF8602BD for ; Tue, 11 Jul 2017 22:51:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A14B028512 for ; Tue, 11 Jul 2017 22:51:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 95C51285C3; Tue, 11 Jul 2017 22:51:12 +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]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 2B368285CB for ; Tue, 11 Jul 2017 22:51:12 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 900F56E322; Tue, 11 Jul 2017 22:51:08 +0000 (UTC) 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 ESMTPS id DF1D16E320 for ; Tue, 11 Jul 2017 22:51:07 +0000 (UTC) Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 11 Jul 2017 15:51:07 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.40,347,1496127600"; d="scan'208";a="123996633" Received: from shiv.jf.intel.com ([10.54.75.141]) by orsmga005.jf.intel.com with ESMTP; 11 Jul 2017 15:51:06 -0700 From: Jim Bride To: intel-gfx@lists.freedesktop.org Date: Tue, 11 Jul 2017 15:48:32 -0700 Message-Id: <1499813316-15038-8-git-send-email-jim.bride@linux.intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1499813316-15038-1-git-send-email-jim.bride@linux.intel.com> References: <1499813316-15038-1-git-send-email-jim.bride@linux.intel.com> Subject: [Intel-gfx] [PATCH IGT 07/11] lib: Add igt_psr_await_status() and modify tests to use it. 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 Signed-off-by: Jim Bride --- lib/igt_psr.c | 12 ++++++++++++ lib/igt_psr.h | 1 + tests/kms_fbcon_fbt.c | 28 ++++++++++++---------------- tests/kms_frontbuffer_tracking.c | 17 +++++------------ tests/kms_psr_sink_crc.c | 16 ++-------------- 5 files changed, 32 insertions(+), 42 deletions(-) diff --git a/lib/igt_psr.c b/lib/igt_psr.c index d849961..d27c32a 100644 --- a/lib/igt_psr.c +++ b/lib/igt_psr.c @@ -102,3 +102,15 @@ bool igt_psr_active(int fd) actret ? "true" : "false"); return hwactret && actret; } + +/** + * igt_psr_await_status: + * @active: A boolean that causes the function to wait for PSR to activate + * if set to true, or to wait for PSR to deactivate if false. + * + * Returns true if the requested condition is met. + */ +bool igt_psr_await_status(int fd, bool active) +{ + return igt_wait(igt_psr_active(fd) == active, 5000, 1); +} diff --git a/lib/igt_psr.h b/lib/igt_psr.h index b678329..3c355e0 100644 --- a/lib/igt_psr.h +++ b/lib/igt_psr.h @@ -31,5 +31,6 @@ bool igt_psr_source_support(int fd); bool igt_psr_sink_support(int fd); bool igt_psr_possible(int fd); bool igt_psr_active(int fd); +bool igt_psr_await_status(int fd, bool active); #endif /* IGT_PSR_H */ diff --git a/tests/kms_fbcon_fbt.c b/tests/kms_fbcon_fbt.c index 41ab36d..cba632e 100644 --- a/tests/kms_fbcon_fbt.c +++ b/tests/kms_fbcon_fbt.c @@ -103,8 +103,9 @@ static bool fbc_is_enabled(int fd) return strstr(buf, "FBC enabled\n"); } -static bool fbc_wait_until_enabled(int fd) +static bool fbc_await_status(int fd, bool enabled) { + igt_assert(enabled); return igt_wait(fbc_is_enabled(fd), 5000, 1); } @@ -157,29 +158,24 @@ static bool connector_can_psr(drmModeConnectorPtr connector) return (connector->connector_type == DRM_MODE_CONNECTOR_eDP); } -static bool psr_is_enabled(int fd) +static bool psr_await_status(int fd, bool enabled) { - return igt_psr_active(fd); -} - -static bool psr_wait_until_enabled(int fd) -{ - return igt_wait(psr_is_enabled(fd), 5000, 1); + return igt_psr_await_status(fd, enabled); } struct feature { bool (*supported_on_chipset)(int fd); - bool (*wait_until_enabled)(int fd); + bool (*await_status)(int fd, bool enabled); bool (*connector_possible_fn)(drmModeConnectorPtr connector); const char *param_name; } fbc = { .supported_on_chipset = fbc_supported_on_chipset, - .wait_until_enabled = fbc_wait_until_enabled, + .await_status = fbc_await_status, .connector_possible_fn = connector_can_fbc, .param_name = "enable_fbc", }, psr = { .supported_on_chipset = psr_supported_on_chipset, - .wait_until_enabled = psr_wait_until_enabled, + .await_status = psr_await_status, .connector_possible_fn = connector_can_psr, .param_name = "enable_psr", }; @@ -204,17 +200,17 @@ static void subtest(struct feature *feature, bool suspend) kmstest_unset_all_crtcs(drm.fd, drm.res); wait_user("Modes unset."); - igt_assert(!feature->wait_until_enabled(drm.fd)); + igt_assert(feature->await_status(drm.fd, false)); set_mode_for_one_screen(&drm, &fb, feature->connector_possible_fn); wait_user("Screen set."); - igt_assert(feature->wait_until_enabled(drm.fd)); + igt_assert(feature->await_status(drm.fd, true)); if (suspend) { igt_system_suspend_autoresume(SUSPEND_STATE_MEM, SUSPEND_TEST_NONE); sleep(5); - igt_assert(feature->wait_until_enabled(drm.fd)); + igt_assert(feature->await_status(drm.fd, true)); } igt_remove_fb(drm.fd, &fb); @@ -224,13 +220,13 @@ static void subtest(struct feature *feature, bool suspend) sleep(3); wait_user("Back to fbcon."); - igt_assert(!feature->wait_until_enabled(drm.fd)); + igt_assert(feature->await_status(drm.fd, false)); if (suspend) { igt_system_suspend_autoresume(SUSPEND_STATE_MEM, SUSPEND_TEST_NONE); sleep(5); - igt_assert(!feature->wait_until_enabled(drm.fd)); + igt_assert(feature->await_status(drm.fd, false)); } } diff --git a/tests/kms_frontbuffer_tracking.c b/tests/kms_frontbuffer_tracking.c index b202297..4d20899 100644 --- a/tests/kms_frontbuffer_tracking.c +++ b/tests/kms_frontbuffer_tracking.c @@ -798,11 +798,6 @@ static void fbc_print_status(void) igt_info("FBC status:\n%s\n", buf); } -static bool psr_is_enabled(void) -{ - return igt_psr_active(drm.fd); -} - static void psr_print_status(void) { char buf[256]; @@ -916,11 +911,6 @@ static bool fbc_wait_until_enabled(void) return igt_wait(fbc_is_enabled(), 2000, 1); } -static bool psr_wait_until_enabled(void) -{ - return igt_wait(psr_is_enabled(), 5000, 1); -} - #define fbc_enable() igt_set_module_param_int("enable_fbc", 1) #define fbc_disable() igt_set_module_param_int("enable_fbc", 0) #define psr_enable() igt_psr_enable() @@ -1704,12 +1694,15 @@ static int adjust_assertion_flags(const struct test_mode *t, int flags) } \ \ if (flags_ & ASSERT_PSR_ENABLED) { \ - if (!psr_wait_until_enabled()) { \ + if (!igt_psr_await_status(drm.fd, true)) { \ psr_print_status(); \ igt_assert_f(false, "PSR disabled\n"); \ } \ } else if (flags_ & ASSERT_PSR_DISABLED) { \ - igt_assert(!psr_wait_until_enabled()); \ + if (!igt_psr_await_status(drm.fd, false)) { \ + psr_print_status(); \ + igt_assert_f(false, "PSR enabled\n"); \ + } \ } \ } while (0) diff --git a/tests/kms_psr_sink_crc.c b/tests/kms_psr_sink_crc.c index 0c27fc7..c9f7993 100644 --- a/tests/kms_psr_sink_crc.c +++ b/tests/kms_psr_sink_crc.c @@ -198,22 +198,10 @@ static bool psr_possible(data_t *data) igt_psr_possible(data->drm_fd); } -static bool psr_active(data_t *data) -{ - - return running_with_psr_disabled || - igt_psr_active(data->drm_fd); -} - static bool wait_psr_entry(data_t *data) { - int timeout = 5; - while (timeout--) { - if (psr_active(data)) - return true; - sleep(1); - } - return false; + return running_with_psr_disabled || + igt_psr_await_status(data->drm_fd, true); } static void get_sink_crc(data_t *data, char *crc) {