From patchwork Fri Feb 28 23:47:24 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rodrigo Vivi X-Patchwork-Id: 3745421 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.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 8844E9F35F for ; Fri, 28 Feb 2014 23:47:42 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id AE12D202AE for ; Fri, 28 Feb 2014 23:47:41 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id BDA5A202A7 for ; Fri, 28 Feb 2014 23:47:40 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 72095FBDFA; Fri, 28 Feb 2014 15:47:39 -0800 (PST) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-yh0-f45.google.com (mail-yh0-f45.google.com [209.85.213.45]) by gabe.freedesktop.org (Postfix) with ESMTP id 06869FBDF7 for ; Fri, 28 Feb 2014 15:47:32 -0800 (PST) Received: by mail-yh0-f45.google.com with SMTP id i57so1527463yha.4 for ; Fri, 28 Feb 2014 15:47:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=1aEuyoJgsdjdSLGWY5UEUC0P0BlSN0IpRck1aoRpVL8=; b=Ivz+9dzkB9QnpKP+W5wccl+wiRQBX35M+tCuASlKeG+0EmpegXlXa01ydIiOxMt/qj jJpidLCEJGiZi4NfAy4ChokyHH5pPxe6VPJSZFZsebQ4j2U6FQL4BS51jfKA0jS0eubE UVf9p7F2mi9xe3UmsRTI5zTcIcchP1njDlGHn16yGWfwOaDx0/bvXqhzrmZSu8H2y0e8 Tgzxa7zYpIaLjjLECk5u7zMwoGCTpEU4xFQsWaJa87OTo0tInd4v5blXMPxPH9NsEpcb e7+EOb6i4GFZ4L19B3tfxRUH2xS9zt5BUWzt+0J3fn2Ok2ff3/Ak0lCiqZDBQsP2UI7e 12qQ== X-Received: by 10.236.44.34 with SMTP id m22mr6455672yhb.9.1393631252685; Fri, 28 Feb 2014 15:47:32 -0800 (PST) Received: from localhost.localdomain ([189.67.129.152]) by mx.google.com with ESMTPSA id g26sm10781172yhk.3.2014.02.28.15.47.30 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 28 Feb 2014 15:47:32 -0800 (PST) From: Rodrigo Vivi To: intel-gfx@lists.freedesktop.org Date: Fri, 28 Feb 2014 20:47:24 -0300 Message-Id: <1393631244-4718-2-git-send-email-rodrigo.vivi@gmail.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1393631244-4718-1-git-send-email-rodrigo.vivi@gmail.com> References: <1393631244-4718-1-git-send-email-rodrigo.vivi@gmail.com> Subject: [Intel-gfx] [PATCH 2/2] test/pm_psr: Add Baytrail simple pm_psr test. 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.1 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, T_DKIM_INVALID, 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 Different from core PSR implementation (i.e. Haswell and Broadwell) Baytrail PSR can be enabled even when source is ok because it provides way to inactivate PSR whenever any screen updated is done. Baytrail also doesn't provide any kind of Performance Counters. Signed-off-by: Rodrigo Vivi --- tests/pm_psr.c | 114 ++++++++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 97 insertions(+), 17 deletions(-) diff --git a/tests/pm_psr.c b/tests/pm_psr.c index def8e12..d75ef9e 100644 --- a/tests/pm_psr.c +++ b/tests/pm_psr.c @@ -30,21 +30,23 @@ #include #include #include "drmtest.h" +#include "igt_debugfs.h" -#define SLEEP_DURATION 5000 // in milliseconds +typedef struct { + int drm_fd; + igt_debugfs_t debugfs; + int devid; +} data_t; -static int get_perf(const char *path) +static int get_perf(data_t *data) { int ret, perf; bool sink, source, enabled; FILE *file; char str[4]; - file = fopen(path, "r"); - if (file == NULL) { - fprintf(stderr, "Couldn't open %s (%d)\n", path, errno); - abort(); - } + file = igt_debugfs_fopen(&data->debugfs, "i915_edp_psr_status", "r"); + igt_require(file); ret = fscanf(file, "Sink_Support: %s\n", str); if (ret == 0) @@ -78,23 +80,101 @@ static int get_perf(const char *path) return perf; } -igt_simple_main +static bool psr_supported(data_t *data) { - int ret, perf1, perf2; - int device = drm_get_card(); - char *path; + int ret; + FILE *file; + char str[4]; + bool sink, source; - igt_skip_on_simulation(); + file = igt_debugfs_fopen(&data->debugfs, "i915_edp_psr_status", "r"); + igt_require(file); + + ret = fscanf(file, "Sink_Support: %s\n", str); + if (ret == 0) + igt_skip("i915_edp_psr_status format not supported by this test case\n"); + sink = strcmp(str, "yes") == 0; + + ret = fscanf(file, "Source_OK: %s\n", str); + igt_assert(ret != 0); + source = strcmp(str, "yes") == 0; + + fclose(file); + return sink && source; +} + +static bool psr_enabled(data_t *data) +{ + int ret; + FILE *file; + char str[4]; + + file = igt_debugfs_fopen(&data->debugfs, "i915_edp_psr_status", "r"); + igt_require(file); + + ret = fscanf(file, "Sink_Support: %s\n", str); + igt_assert(ret != 0); + + ret = fscanf(file, "Source_OK: %s\n", str); + igt_assert(ret != 0); + + ret = fscanf(file, "Enabled: %s\n", str); + igt_assert(ret != 0); + + fclose(file); + return strcmp(str, "yes") == 0; +} + +static bool wait_psr_entry(data_t *data, int timeout) +{ + while (timeout--) { + if (psr_enabled(data)) + return true; + sleep(1); + } + return false; +} + +/* Baytrail doesn't provide a performance counter for PSR */ +/* PSR on Baytrail can be disabled/inactive even when source is ok. */ +static void vlv_test(data_t *data) +{ + if (!psr_supported(data)) + igt_skip("This platform or current configuration don't support PSR.\n"); - ret = asprintf(&path, "/sys/kernel/debug/dri/%d/i915_edp_psr_status", device); - igt_assert(ret != -1); + if (!wait_psr_entry(data, 10)) { + fprintf(stderr, " Unable to enter PSR state.\n It can either be disabled by kernel parameter or it simply failed.\n Make sure there is no screen update happening on eDP, not even a small blinking cursor.\n"); + igt_fail(1); + } +} - perf1 = get_perf(path); - sleep(SLEEP_DURATION / 1000); - perf2 = get_perf(path); +/* Haswell and Broadwell */ +static void core_test(data_t *data) +{ + int perf1, perf2; + + perf1 = get_perf(data); + sleep (5); + perf2 = get_perf(data); if (perf1 == perf2) { fprintf(stderr, "Unable to enter PSR state again\n"); igt_fail(1); } } + +igt_simple_main +{ + data_t data = {}; + + igt_skip_on_simulation(); + + data.drm_fd = drm_open_any(); + data.devid = intel_get_drm_devid(data.drm_fd); + igt_debugfs_init(&data.debugfs); + + if (IS_HASWELL(data.devid) || IS_BROADWELL(data.devid)) + core_test(&data); + else if (IS_VALLEYVIEW(data.devid)) + vlv_test(&data); +}