[PATCH v2 1/2] lib/igt_debugfs: Add specific checks for WA in GTs

Kamil Konieczny kamil.konieczny at linux.intel.com
Mon May 19 18:18:30 UTC 2025


Hi Mohammed,
On 2025-05-19 at 18:01:34 +0530, Mohammed Thasleem wrote:
> This function check the given workaround on available GTs
> 
> v2: Add discription for return. (Kamil)
>     Rename function to igt_has_intel_wa. (Kamil)
>     Move lib changes to lib/igt_debugfs. (Kamil)
>     Dump the whole wa sysfs file and then search for the wa. (Vinod)
>     Use return true/false directly instead assigning value. (Vinod)
> 
> Signed-off-by: Mohammed Thasleem <mohammed.thasleem at intel.com>
> ---
>  lib/igt_debugfs.c | 31 +++++++++++++++++++++++++++++++
>  lib/igt_debugfs.h |  1 +
>  2 files changed, 32 insertions(+)
> 
> diff --git a/lib/igt_debugfs.c b/lib/igt_debugfs.c
> index 8ac215a76..ec3e33854 100644
> --- a/lib/igt_debugfs.c
> +++ b/lib/igt_debugfs.c
> @@ -44,6 +44,7 @@
>  #include "igt_kms.h"
>  #include "igt_debugfs.h"
>  #include "igt_sysfs.h"
> +#include "xe/xe_query.h"
>  
>  /**
>   * SECTION:igt_debugfs
> @@ -770,3 +771,33 @@ void __igt_debugfs_dump(int device, const char *filename, int level)
>  	igt_log(IGT_LOG_DOMAIN, level, "%s:\n%s\n", filename, contents);
>  	free(contents);
>  }
> +
> +/**
> + * igt_has_intel_wa:
> + * @drm_fd:	A drm file descriptor
> + * @check_wa:	Workaround to be checked

Add one line here before 'Returns:', so
 *
 * Returns: 0 if no WA, 1 if WA present, -1 on error
 */

> + * @return:	It will return true if WA found otherwise false
> + */
> +int igt_has_intel_wa(int drm_fd, const char *check_wa)
> +{
> +	char name[PATH_MAX];
> +	char *debugfs_dump;
> +	unsigned int xe, debugfs_fd;
> +
> +	debugfs_fd = igt_debugfs_dir(drm_fd);

Check for error here:
	if (debugfs_fd == -1)
		return -1;

> +
> +	xe_for_each_gt(drm_fd, xe) {
> +		sprintf(name, "gt%d/workarounds", xe);
> +		if (!igt_debugfs_exists(drm_fd, name, O_RDONLY))
> +			return -1;
> +
> +		debugfs_dump = igt_sysfs_get(debugfs_fd, name);
> +
> +		if (debugfs_dump != NULL) {
> +			if (strstr(debugfs_dump, check_wa))

Free debugfs_dump before return or remember strstr result, eg.

has_wa = strstr(debugfs_dump, check_wa);
free(debugfs_dump);
...rest of actions...

> +				return true;

Should be:
				return 1;

> +		}
> +	}
> +

Should be:
	return 0;

> +	return false;

Regards,
Kamil

> +}
> diff --git a/lib/igt_debugfs.h b/lib/igt_debugfs.h
> index f4044d545..6d4c09d2f 100644
> --- a/lib/igt_debugfs.h
> +++ b/lib/igt_debugfs.h
> @@ -49,6 +49,7 @@ bool igt_debugfs_search(int fd, const char *filename, const char *substring);
>  int igt_debugfs_gt_dir(int device, unsigned int gt);
>  int igt_debugfs_gt_open(int device, unsigned int gt, const char *filename,
>  			int mode);
> +int igt_has_intel_wa(int drm_fd, const char *check_wa);
>  
>  /**
>   * igt_debugfs_read:
> -- 
> 2.34.1
> 


More information about the igt-dev mailing list