[igt-dev] [PATCH i-g-t] lib/igt_psr: Changed psr_set logic to account for older kernels

Casey Bowman casey.g.bowman at intel.com
Wed Oct 17 21:26:58 UTC 2018


Only EINVAL was being used to account for older kernels,
but on legacy kernels that don't use i915_edp_psr_debug,
the ENOENT error will be thrown. This changes the logic
to set PSR via the module parameter if a problem occurs
when attempting to set PSR via the debugfs_fd.

Signed-off-by: Casey Bowman <casey.g.bowman at intel.com>
---
 lib/igt_psr.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/lib/igt_psr.c b/lib/igt_psr.c
index 0ddfb64f..6904393c 100644
--- a/lib/igt_psr.c
+++ b/lib/igt_psr.c
@@ -61,6 +61,8 @@ static int has_psr_debugfs(int debugfs_fd)
 	 * Check if new PSR debugfs api is usable by writing an invalid value.
 	 * Legacy mode will return OK here, debugfs api will return -EINVAL.
 	 * -ENODEV is returned when PSR is unavailable.
+	 * -ENOENT is returned when PSR debugfs api doesn't exist (i.e. using
+	 * an older kernel).
 	 */
 	ret = psr_write(debugfs_fd, "0xf");
 	if (ret == -EINVAL)
@@ -103,11 +105,11 @@ static bool psr_set(int debugfs_fd, bool enable)
 		return false;
 	}
 
-	if (ret == -EINVAL) {
-		ret = psr_modparam_set(enable);
-	} else {
+	if (ret == 0) {
 		ret = psr_write(debugfs_fd, enable ? "0x3" : "0x1");
 		igt_assert(ret > 0);
+	} else {
+		ret = psr_modparam_set(enable);
 	}
 
 	/* Restore original value on exit */
-- 
2.19.0



More information about the igt-dev mailing list