[PATCH i-g-t v3 5/5] lib/igt_sysfs: Move igt_exit_handler into test

Pranay Samala pranay.samala at intel.com
Tue Apr 1 09:20:15 UTC 2025


In case of nested updated the exit handler will be called multiple
times. Hence calling it before the updates rather than calling after
update.

Fixes: 56b91193b825 ("lib/igt_sysfs: Implement dynamic adjustment of debug log level")
Fixes: a2ab0ec12ef4 ("tests/kms_atomic_transition: Reducing debug loglevel dynamically")
Fixes: 4baeb7397d71 ("tests/intel/kms_dp_linktrain_fallback: Reduce debug loglevel dynamically")
Fixes: 7a8a3744466f ("tests/kms_cursor_legacy: Reduce debug loglevel dynamically")
Signed-off-by: Pranay Samala <pranay.samala at intel.com>
---
 lib/igt_sysfs.c                         | 9 +--------
 lib/igt_sysfs.h                         | 1 +
 tests/intel/kms_dp_linktrain_fallback.c | 1 +
 tests/kms_atomic_transition.c           | 1 +
 tests/kms_cursor_legacy.c               | 1 +
 5 files changed, 5 insertions(+), 8 deletions(-)

diff --git a/lib/igt_sysfs.c b/lib/igt_sysfs.c
index 0df2ab9fc..735b8c29f 100644
--- a/lib/igt_sysfs.c
+++ b/lib/igt_sysfs.c
@@ -493,7 +493,7 @@ void igt_drm_debug_mask_reset(void)
 	close(dir);
 }
 
-static void igt_drm_debug_mask_reset_exit_handler(int sig)
+void igt_drm_debug_mask_reset_exit_handler(int sig)
 {
 	igt_drm_debug_mask_reset();
 }
@@ -532,13 +532,6 @@ void igt_drm_debug_mask_update(unsigned int mask_to_set)
 	igt_assert(igt_sysfs_set(dir, "debug", buf));
 
 	close(dir);
-
-	/*
-	 * TODO: Check whether multiple exit handlers will get installed,
-	 * if we call this api multiple times
-	 */
-	igt_install_exit_handler(igt_drm_debug_level_reset_exit_handler);
-
 }
 
 /**
diff --git a/lib/igt_sysfs.h b/lib/igt_sysfs.h
index 2f4d25bf6..c351e3069 100644
--- a/lib/igt_sysfs.h
+++ b/lib/igt_sysfs.h
@@ -143,6 +143,7 @@ void igt_sysfs_set_boolean(int dir, const char *attr, bool value);
 void bind_fbcon(bool enable);
 void fbcon_blink_enable(bool enable);
 
+void igt_drm_debug_mask_reset_exit_handler(int sig);
 void igt_drm_debug_mask_update(unsigned int new_log_level);
 void igt_drm_debug_mask_reset(void);
 int igt_drm_debug_mask_get(int dir);
diff --git a/tests/intel/kms_dp_linktrain_fallback.c b/tests/intel/kms_dp_linktrain_fallback.c
index a6f7b586f..a093f651a 100644
--- a/tests/intel/kms_dp_linktrain_fallback.c
+++ b/tests/intel/kms_dp_linktrain_fallback.c
@@ -643,6 +643,7 @@ igt_main_args("", long_opts, help_str, opt_handler, NULL)
 		for_each_pipe(&data.display, data.pipe)
 			data.n_pipes++;
 
+		igt_install_exit_handler(igt_drm_debug_mask_reset_exit_handler);
 		if (parse_bitmask)
 			igt_drm_debug_mask_update(parse_bitmask);
 		else
diff --git a/tests/kms_atomic_transition.c b/tests/kms_atomic_transition.c
index a92edc2b1..7403e829e 100644
--- a/tests/kms_atomic_transition.c
+++ b/tests/kms_atomic_transition.c
@@ -1194,6 +1194,7 @@ igt_main_args("", long_opts, help_str, opt_handler, &data)
 		for_each_connected_output(&data.display, output)
 			count++;
 
+		igt_install_exit_handler(igt_drm_debug_mask_reset_exit_handler);
 		if (parse_bitmask)
 			igt_drm_debug_mask_update(parse_bitmask);
 		else
diff --git a/tests/kms_cursor_legacy.c b/tests/kms_cursor_legacy.c
index 09d511935..2985e4852 100644
--- a/tests/kms_cursor_legacy.c
+++ b/tests/kms_cursor_legacy.c
@@ -1872,6 +1872,7 @@ igt_main_args("", long_opts, help_str, opt_handler, NULL)
 		 */
 		intel_psr2_restore = i915_psr2_sel_fetch_to_psr1(display.drm_fd, NULL);
 
+		igt_install_exit_handler(igt_drm_debug_mask_reset_exit_handler);
 		if (parse_bitmask)
 			igt_drm_debug_mask_update(parse_bitmask);
 		else
-- 
2.34.1



More information about the igt-dev mailing list