From: Pranay Samala <pranay.samala@intel.com>
To: igt-dev@lists.freedesktop.org
Cc: karthik.b.s@intel.com, kunal1.joshi@intel.com,
sameer.lattannavar@intel.com, pranay.samala@intel.com
Subject: [PATCH i-g-t v3 3/5] lib/igt_sysfs: Update new debug mask requested by user
Date: Tue, 1 Apr 2025 14:50:13 +0530 [thread overview]
Message-ID: <20250401092015.818465-4-pranay.samala@intel.com> (raw)
In-Reply-To: <20250401092015.818465-1-pranay.samala@intel.com>
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.
Fixes: 56b91193b825 ("lib/igt_sysfs: Implement dynamic adjustment of debug log level")
Signed-off-by: Pranay Samala <pranay.samala@intel.com>
---
lib/igt_sysfs.c | 25 +++++++++++++++++--------
1 file changed, 17 insertions(+), 8 deletions(-)
diff --git a/lib/igt_sysfs.c b/lib/igt_sysfs.c
index e6058a1dd..0df2ab9fc 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_level: new debug mask to set
+ * @mast_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_log_level)
+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,20 @@ void igt_drm_debug_mask_update(unsigned int new_log_level)
if (dir < 0)
return;
- original_debug_mask = igt_drm_debug_mask_get(dir);
- if (original_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;
+ original_debug_mask = igt_drm_debug_mask_get(dir);
+ if (original_debug_mask < 0) {
+ close(dir);
+ return;
+ }
}
- igt_debug("Setting DRM debug mask to %d\n", new_log_level);
- snprintf(buf, sizeof(buf), "%d", new_log_level);
+ 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);
@@ -530,6 +538,7 @@ void igt_drm_debug_mask_update(unsigned int new_log_level)
* if we call this api multiple times
*/
igt_install_exit_handler(igt_drm_debug_level_reset_exit_handler);
+
}
/**
--
2.34.1
next prev parent reply other threads:[~2025-04-01 9:20 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-01 9:20 [PATCH i-g-t v3 0/5] Refactor DRM Debug Severity Handling for Pranay Samala
2025-04-01 9:20 ` [PATCH i-g-t v3 1/5] lib/igt_sysfs: Usage of Original debug mask to read/reset Pranay Samala
2025-04-23 11:49 ` [i-g-t,v3,1/5] " Joshi, Kunal1
2025-04-01 9:20 ` [PATCH i-g-t v3 2/5] lib/igt_sysfs: Rename debug level APIs/variables to debug mask Pranay Samala
2025-04-23 11:56 ` [i-g-t,v3,2/5] " Joshi, Kunal1
2025-04-01 9:20 ` Pranay Samala [this message]
2025-04-01 9:20 ` [PATCH i-g-t v3 4/5] tests/kms: Add parse_bitmask support for user Pranay Samala
2025-04-03 15:18 ` Jani Nikula
2025-04-23 12:23 ` [i-g-t,v3,4/5] " Joshi, Kunal1
2025-04-01 9:20 ` [PATCH i-g-t v3 5/5] lib/igt_sysfs: Move igt_exit_handler into test Pranay Samala
2025-04-01 10:04 ` [PATCH i-g-t v3 0/5] Refactor DRM Debug Severity Handling for Samala, Pranay
2025-04-01 12:24 ` ✗ i915.CI.BAT: failure for " Patchwork
2025-04-01 12:30 ` ✓ Xe.CI.BAT: success " Patchwork
2025-04-01 14:39 ` ✗ Xe.CI.Full: failure " Patchwork
2025-04-06 22:24 ` Patchwork
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250401092015.818465-4-pranay.samala@intel.com \
--to=pranay.samala@intel.com \
--cc=igt-dev@lists.freedesktop.org \
--cc=karthik.b.s@intel.com \
--cc=kunal1.joshi@intel.com \
--cc=sameer.lattannavar@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox