[PATCH i-g-t v2 5/6] lib/igt_psr: Do not clear/touch psr_debug disable bits
Jouni Högander
jouni.hogander at intel.com
Fri Jun 7 05:26:33 UTC 2024
Current implementation is assuming psr_debug is 0. Currently we are
using disable bits of psr debugfs interface to prevent using unstable
features.
Stop writing bit we don't want to write and restore original value.
Signed-off-by: Jouni Högander <jouni.hogander at intel.com>
---
lib/igt_psr.c | 28 ++++++++++++++++++++++++----
1 file changed, 24 insertions(+), 4 deletions(-)
diff --git a/lib/igt_psr.c b/lib/igt_psr.c
index 012521fc5..3d58ea7c1 100644
--- a/lib/igt_psr.c
+++ b/lib/igt_psr.c
@@ -119,6 +119,17 @@ static ssize_t psr_write(int debugfs_fd, const char *buf, igt_output_t *output)
strlen(buf));
}
+static ssize_t psr_read(int debugfs_fd, char *buf, size_t len, igt_output_t *output)
+{
+ /*
+ * FIXME: Currently we don't have separate psr_debug file for each output.
+ * so, we are using i915_edp_psr_debug file for all outputs.
+ * Later we need to add support for separate psr_debug file for each output.
+ */
+ return igt_sysfs_read(debugfs_fd, "i915_edp_psr_debug", buf,
+ len);
+}
+
static int has_psr_debugfs(int debugfs_fd, igt_output_t *output)
{
int ret;
@@ -154,15 +165,19 @@ static bool psr_modparam_set(int device, int val)
}
static int psr_restore_debugfs_fd = -1;
+static int psr_restore_value;
static void restore_psr_debugfs(int sig)
{
- psr_write(psr_restore_debugfs_fd, "0", NULL);
+ char debug_str[8];
+
+ sprintf(debug_str, "0x%x", psr_restore_value);
+ psr_write(psr_restore_debugfs_fd, debug_str, NULL);
}
static bool psr_set(int device, int debugfs_fd, int mode, igt_output_t *output)
{
- int ret;
+ int ret, restore_value;
ret = has_psr_debugfs(debugfs_fd, output);
if (ret == -ENODEV) {
@@ -179,8 +194,14 @@ static bool psr_set(int device, int debugfs_fd, int mode, igt_output_t *output)
*/
ret = psr_modparam_set(device, mode >= PSR_MODE_1);
} else {
+ char debug_str[8];
int debug_val = mode <= PSR_MODE_2_SEL_FETCH ? 0x40 : 0;
+ ret = psr_read(debugfs_fd, debug_str, sizeof(debug_str), output);
+ restore_value = debug_val = (int)atoi(debug_str);
+ debug_val &= ~0xf;
+ debug_val |= mode <= PSR_MODE_2_SEL_FETCH ? 0x40 : 0;
+
switch (mode) {
case PSR_MODE_1:
case PR_MODE:
@@ -200,8 +221,6 @@ static bool psr_set(int device, int debugfs_fd, int mode, igt_output_t *output)
/* old debugfs interface doesn't recognize Panel Replay disable bit */
do {
- char debug_str[8];
-
sprintf(debug_str, "0x%x", debug_val);
ret = psr_write(debugfs_fd, debug_str, output);
if (!(debug_val & 0x40))
@@ -215,6 +234,7 @@ static bool psr_set(int device, int debugfs_fd, int mode, igt_output_t *output)
/* Restore original value on exit */
if (psr_restore_debugfs_fd == -1) {
psr_restore_debugfs_fd = dup(debugfs_fd);
+ psr_restore_value = restore_value;
igt_assert(psr_restore_debugfs_fd >= 0);
igt_install_exit_handler(restore_psr_debugfs);
}
--
2.34.1
More information about the Intel-gfx-trybot
mailing list