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

Govindapillai, Vinod vinod.govindapillai at intel.com
Fri May 30 10:00:54 UTC 2025


On Fri, 2025-05-30 at 13:28 +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)
> v3: Updated return type discription and debugfs_fd failure check. (Kamil)
>     Return 0 or 1 instead of true or false. (Kamil)
> v4: Add check for xe device before execution. (Vinod)
> 
> Signed-off-by: Mohammed Thasleem <mohammed.thasleem at intel.com>
> Reviewed-by: Kamil Konieczny <kamil.konieczny at linux.intel.com>
> ---
>  lib/igt_debugfs.c | 39 +++++++++++++++++++++++++++++++++++++++
>  lib/igt_debugfs.h |  1 +
>  2 files changed, 40 insertions(+)
> 

Reviewed-by: Vinod Govindapillai <vinod.govindapillai at intel.com>


> diff --git a/lib/igt_debugfs.c b/lib/igt_debugfs.c
> index 8ac215a76..5444c6f5f 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,41 @@ 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
> + *
> + * Returns:	0 if no WA, 1 if WA present, -1 on error
> + */
> +int igt_has_intel_wa(int drm_fd, const char *check_wa)
> +{
> +	int debugfs_fd;
> +	unsigned int xe;
> +	char name[PATH_MAX];
> +	char *debugfs_dump, *has_wa;
> +
> +	if (!is_xe_device(drm_fd))
> +		return 0;
> +
> +	debugfs_fd = igt_debugfs_dir(drm_fd);
> +	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) {
> +			has_wa = strstr(debugfs_dump, check_wa);
> +			free(debugfs_dump);
> +			if (has_wa)
> +				return 1;
> +		}
> +	}
> +
> +	return 0;
> +}
> 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:



More information about the igt-dev mailing list