public inbox for igt-dev@lists.freedesktop.org
 help / color / mirror / Atom feed
From: "José Roberto de Souza" <jose.souza@intel.com>
To: igt-dev@lists.freedesktop.org
Cc: Dhinakaran Pandiyan <dhinakaran.pandiyan@intel.com>
Subject: [igt-dev] [PATCH i-g-t] tests/psr: Test the switching between all PSR version from debugfs
Date: Thu, 31 Jan 2019 18:01:18 -0800	[thread overview]
Message-ID: <20190201020118.24817-1-jose.souza@intel.com> (raw)

A bug was found in the code that handles the switching of PSR modes
from debugfs, the fix was sent to kernel but lets add this test to
avoid future regrestions.

Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Cc: Dhinakaran Pandiyan <dhinakaran.pandiyan@intel.com>
Signed-off-by: José Roberto de Souza <jose.souza@intel.com>
---
 lib/igt_psr.c   | 28 +++++++++++++++++++++++++
 lib/igt_psr.h   |  1 +
 tests/kms_psr.c | 55 +++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 84 insertions(+)

diff --git a/lib/igt_psr.c b/lib/igt_psr.c
index d726fad5..0393639f 100644
--- a/lib/igt_psr.c
+++ b/lib/igt_psr.c
@@ -178,3 +178,31 @@ bool psr_sink_support(int debugfs_fd, enum psr_mode mode)
 		 */
 		return strstr(buf, "Sink support: yes [0x03]");
 }
+
+/**
+ * Returns true if PSR is enabled(don't mean active) and set mode parameter
+ * with the PSR version that is enabled if not NULL.
+ */
+bool psr_enabled(int debugfs_fd, enum psr_mode *mode)
+{
+	char buf[PSR_STATUS_MAX_LEN];
+	int ret;
+
+	ret = igt_debugfs_simple_read(debugfs_fd, "i915_edp_psr_status", buf,
+				      sizeof(buf));
+	if (ret < 1)
+		return false;
+
+	if (strstr(buf, "PSR mode: disabled"))
+		return false;
+
+	if (!mode)
+		return true;
+
+	if (strstr(buf, "PSR2 enabled"))
+		*mode = PSR_MODE_2;
+	else
+		*mode = PSR_MODE_1;
+
+	return true;
+}
diff --git a/lib/igt_psr.h b/lib/igt_psr.h
index 7e7017bf..8e88b065 100644
--- a/lib/igt_psr.h
+++ b/lib/igt_psr.h
@@ -40,5 +40,6 @@ bool psr_wait_update(int debugfs_fd, enum psr_mode mode);
 bool psr_enable(int debugfs_fd, enum psr_mode);
 bool psr_disable(int debugfs_fd);
 bool psr_sink_support(int debugfs_fd, enum psr_mode);
+bool psr_enabled(int debugfs_fd, enum psr_mode *mode);
 
 #endif
diff --git a/tests/kms_psr.c b/tests/kms_psr.c
index 3e16a6bf..c7ecb1c1 100644
--- a/tests/kms_psr.c
+++ b/tests/kms_psr.c
@@ -454,6 +454,61 @@ int main(int argc, char *argv[])
 		display_init(&data);
 	}
 
+	igt_subtest_f("debugfs") {
+		enum psr_mode mode;
+
+		igt_require(!data.with_psr_disabled);
+
+		data.test_plane_id = DRM_PLANE_TYPE_PRIMARY;
+		setup_test_plane(&data, data.test_plane_id);
+
+		/*
+		 * Testing all combinations:
+		 * disabled -> PSR1
+		 * disabled -> PSR2
+		 *
+		 * PSR1 -> disabled
+		 * PSR1 -> PSR2
+		 *
+		 * PSR2 -> disabled
+		 * PSR2 -> PSR1
+		 *
+		 * Not testing the default value in debugfs because the result
+		 * of the default value will vary between kernel versions,
+		 * gen version and enable_psr kernel parameter.
+		 */
+		psr_disable(data.debugfs_fd);
+		igt_assert(!psr_enabled(data.debugfs_fd, NULL));
+
+		psr_enable(data.debugfs_fd, PSR_MODE_1);
+		igt_assert(psr_enabled(data.debugfs_fd, &mode));
+		igt_assert(mode == PSR_MODE_1);
+
+		psr_disable(data.debugfs_fd);
+		igt_assert(!psr_enabled(data.debugfs_fd, NULL));
+
+		if (data.supports_psr2) {
+			psr_enable(data.debugfs_fd, PSR_MODE_2);
+			igt_assert(psr_enabled(data.debugfs_fd, &mode));
+			igt_assert(mode == PSR_MODE_2);
+
+			psr_disable(data.debugfs_fd);
+			igt_assert(!psr_enabled(data.debugfs_fd, NULL));
+
+			psr_enable(data.debugfs_fd, PSR_MODE_2);
+			igt_assert(psr_enabled(data.debugfs_fd, &mode));
+			igt_assert(mode == PSR_MODE_2);
+
+			psr_enable(data.debugfs_fd, PSR_MODE_1);
+			igt_assert(psr_enabled(data.debugfs_fd, &mode));
+			igt_assert(mode == PSR_MODE_1);
+
+			psr_enable(data.debugfs_fd, PSR_MODE_2);
+			igt_assert(psr_enabled(data.debugfs_fd, &mode));
+			igt_assert(mode == PSR_MODE_2);
+		}
+	}
+
 	for (data.op_psr_mode = PSR_MODE_1; data.op_psr_mode <= PSR_MODE_2;
 	     data.op_psr_mode++) {
 
-- 
2.20.1

_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

             reply	other threads:[~2019-02-01  2:01 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-01  2:01 José Roberto de Souza [this message]
2019-02-01  3:01 ` [igt-dev] ✓ Fi.CI.BAT: success for tests/psr: Test the switching between all PSR version from debugfs Patchwork
2019-02-01  6:30 ` [igt-dev] ✓ Fi.CI.IGT: " Patchwork

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190201020118.24817-1-jose.souza@intel.com \
    --to=jose.souza@intel.com \
    --cc=dhinakaran.pandiyan@intel.com \
    --cc=igt-dev@lists.freedesktop.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox