[PATCH i-g-t v4 1/5] lib/igt_sysfs: Usage of Original debug mask to read/reset

Samala, Pranay pranay.samala at intel.com
Wed Jul 2 03:06:41 UTC 2025


Hi Ramanaidu,

> -----Original Message-----
> From: igt-dev <igt-dev-bounces at lists.freedesktop.org> On Behalf Of Naladala,
> Ramanaidu
> Sent: Wednesday, July 2, 2025 1:50 AM
> To: igt-dev at lists.freedesktop.org
> Subject: Re: [PATCH i-g-t v4 1/5] lib/igt_sysfs: Usage of Original debug mask to
> read/reset
> 
> Hi Pranay,
> 
> On 6/4/2025 11:00 AM, Pranay Samala wrote:
> > Original debug mask holds the mask before the test and will be used to
> > reset the debug mask post test.
> >
> > v3:
> > - Refactored for readability and address logical comment.
> >
> > v4:
> > - Improve variable name for debug mask saving (Kunal)
> >
> > 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 | 16 ++++++++--------
> >   1 file changed, 8 insertions(+), 8 deletions(-)
> >
> > diff --git a/lib/igt_sysfs.c b/lib/igt_sysfs.c index
> > 2ba96ca7f..b7ca1f2b6 100644
> > --- a/lib/igt_sysfs.c
> > +++ b/lib/igt_sysfs.c
> > @@ -443,7 +443,7 @@ int igt_sysfs_drm_module_params_open(void)
> >   	return open(path, O_RDONLY);
> >   }
> >
> > -static int log_level = -1;
> > +static int saved_drm_debug_mask = -1;
> >
> >   /**
> >    * igt_drm_debug_level_get:
> > @@ -458,8 +458,8 @@ int igt_drm_debug_level_get(int dir)
> >   {
> >   	char buf[20];
> >
> > -	if (log_level >= 0)
> > -		return log_level;
> > +	if (saved_drm_debug_mask >= 0)
> > +		return saved_drm_debug_mask;
> return previously saved variable is not correct.  Instead always returns the current
> debug level value from the file.
This saved_drm_debug_mask variable is used to store only the original debug mask to 
ensure that in case of recursive debug mask updates, at the end of the test this original 
variable will be stored and not the previous one.
It saves the current debug mask only at the 1st instance.

And apart from this nowhere I am using current drm_debug_mask. I am passing
The required debug mask from the test itself when it's in under CI execution.
> >
> >   	if (igt_sysfs_read(dir, "debug", buf, sizeof(buf) - 1) < 0)
> >   		return -1;
> > @@ -479,15 +479,15 @@ void igt_drm_debug_level_reset(void)
> Imho, The function name should use the word restore instead of reset, as it more
> accurately reflects the intended behavior.
> >   	char buf[20];
> >   	int dir;
> >
> > -	if (log_level < 0)
> > +	if (saved_drm_debug_mask < 0)
> >   		return;
> >
> >   	dir = igt_sysfs_drm_module_params_open();
> >   	if (dir < 0)
> >   		return;
> >
> > -	igt_debug("Resetting DRM debug level to %d\n", log_level);
> same here.
> > -	snprintf(buf, sizeof(buf), "%d", log_level);
> > +	igt_debug("Resetting DRM debug level to %d\n",
> > +saved_drm_debug_mask);
> same here.
> > +	snprintf(buf, sizeof(buf), "%d", saved_drm_debug_mask);
> >   	igt_assert(igt_sysfs_set(dir, "debug", buf));
> >
> >   	close(dir);
> > @@ -513,8 +513,8 @@ void igt_drm_debug_level_update(unsigned int
> new_log_level)
> >   	if (dir < 0)
> >   		return;
> >
> > -	log_level = igt_drm_debug_level_get(dir);
> > -	if (log_level < 0) {
> > +	saved_drm_debug_mask = igt_drm_debug_level_get(dir);
> > +	if (saved_drm_debug_mask < 0) {
> >   		close(dir);
> >   		return;
> >   	}
> Thanks & Regards,
> Ramanaidu N.


More information about the igt-dev mailing list