[igt-dev] [PATCH i-g-t v6 3/4] tests/psr: Test the switching between all PSR version from debugfs
José Roberto de Souza
jose.souza at intel.com
Fri Feb 8 00:53:04 UTC 2019
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 at linux.intel.com>
Cc: Dhinakaran Pandiyan <dhinakaran.pandiyan at intel.com>
Signed-off-by: José Roberto de Souza <jose.souza at 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 b5847bfd..defef63b 100644
--- a/lib/igt_psr.c
+++ b/lib/igt_psr.c
@@ -207,3 +207,31 @@ bool psr2_wait_su(int debugfs_fd, uint16_t *num_su_blocks)
{
return igt_wait(psr2_read_last_num_su_blocks_val(debugfs_fd, num_su_blocks), 40, 1);
}
+
+/**
+ * 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 49599cf8..2e92265d 100644
--- a/lib/igt_psr.h
+++ b/lib/igt_psr.h
@@ -41,5 +41,6 @@ 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 psr2_wait_su(int debugfs_fd, uint16_t *num_su_blocks);
+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
More information about the igt-dev
mailing list