[PATCH i-g-t v4 3/5] lib/igt_sysfs: Update new debug mask requested by user
Pranay Samala
pranay.samala at intel.com
Wed Jun 4 05:30:44 UTC 2025
These below changes will update the required debug mask passed by the
user as per the requirement. Before setting the debug mask, it stores
the original mask which will be used to restore the debug mask post
test.
To handle nested updated, update flag is being used. Using this flag the
original debug mask will be read only once to ensure while restoring it,
it should be the original value and not the previous value.
v3:
- Refactored for readability and address logical comment.
Fixes: 56b91193b825 ("lib/igt_sysfs: Implement dynamic adjustment of debug log level")
Signed-off-by: Pranay Samala <pranay.samala at intel.com>
---
lib/igt_sysfs.c | 23 +++++++++++++++--------
1 file changed, 15 insertions(+), 8 deletions(-)
diff --git a/lib/igt_sysfs.c b/lib/igt_sysfs.c
index ceb776b8d..427aed4de 100644
--- a/lib/igt_sysfs.c
+++ b/lib/igt_sysfs.c
@@ -500,12 +500,14 @@ static void igt_drm_debug_mask_reset_exit_handler(int sig)
/**
* igt_drm_debug_mask_update:
- * @debug_mask: new debug mask to set
+ * @mask_to_set: new debug mask to set
*
* This modifies the current drm debug mask to the new value.
*/
-void igt_drm_debug_mask_update(unsigned int new_mask)
+void igt_drm_debug_mask_update(unsigned int mask_to_set)
{
+ unsigned int new_debug_mask;
+ static bool debug_mask_read_once = true;
char buf[20];
int dir;
@@ -513,14 +515,19 @@ void igt_drm_debug_mask_update(unsigned int new_mask)
if (dir < 0)
return;
- saved_drm_debug_mask = igt_drm_debug_mask_get(dir);
- if (saved_drm_debug_mask < 0) {
- close(dir);
- return;
+ /* The below flag is used to read the original debug mask only once */
+ if (debug_mask_read_once) {
+ debug_mask_read_once = false;
+ saved_drm_debug_mask = igt_drm_debug_mask_get(dir);
+ if (saved_drm_debug_mask < 0) {
+ close(dir);
+ return;
+ }
}
- igt_debug("Setting DRM debug mask to %d\n", new_mask);
- snprintf(buf, sizeof(buf), "%d", new_mask);
+ new_debug_mask = mask_to_set;
+ igt_debug("Setting DRM debug mask to %d\n", new_debug_mask);
+ snprintf(buf, sizeof(buf), "%d", new_debug_mask);
igt_assert(igt_sysfs_set(dir, "debug", buf));
close(dir);
--
2.34.1
More information about the igt-dev
mailing list