Igt-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Gustavo Sousa <gustavo.sousa@intel.com>
To: Shekhar Chauhan <shekhar.chauhan@intel.com>,
	<igt-dev@lists.freedesktop.org>
Cc: <shekhar.chauhan@intel.com>, <ashutosh.dixit@intel.com>
Subject: Re: [PATCH v4 1/2] lib/intel_wa: Add workaround check for a wa within debugfs file
Date: Tue, 5 May 2026 10:34:28 -0300	[thread overview]
Message-ID: <87wlxix9nf.fsf@intel.com> (raw)
In-Reply-To: <20260505054741.486361-2-shekhar.chauhan@intel.com>

Shekhar Chauhan <shekhar.chauhan@intel.com> writes:

> Add a check to see if a workaround exists in the debugfs file.

The commit subject and body are a bit vague and doesn't quite reflect
the purpose of this change.  The subject should try to summarize what is
being done; the most important thing in the body is the "why", although
some details of what is being done doesn't hurt as well.

I would go with something like this:

  lib/intel_wa: Also check for device workarounds

  Currently igt_has_intel_wa() only checks for GT workarounds, but in an
  upcoming change we will also need to check for device workarounds.  As
  such, update igt_has_intel_wa() to also check for device workarounds.

  While at it, make sure that we do not duplicate the logic for reading
  from the debugfs file by extracting it into a separate function called
  debugfs_file_has_wa().


I think there is room for improvement on how those functions are
implemented: the use of strstr() is not very robust, since it can return
partial matches; and this function is currently xe-specific (i.e. can't
be used for i915), so we need some assert to make sure that it is being
called only for xe.  However, those are unrelated to this patch and
could be fixed as a follow-up change.

So, with the commit subject and message fixed as suggested above,

Reviewed-by: Gustavo Sousa <gustavo.sousa@intel.com>

--
Gustavo Sousa
  
>
> Signed-off-by: Shekhar Chauhan <shekhar.chauhan@intel.com>
> ---
>  lib/intel_wa.c | 40 ++++++++++++++++++++++++++--------------
>  1 file changed, 26 insertions(+), 14 deletions(-)
>
> diff --git a/lib/intel_wa.c b/lib/intel_wa.c
> index 685df106f..727dd6c98 100644
> --- a/lib/intel_wa.c
> +++ b/lib/intel_wa.c
> @@ -12,6 +12,27 @@
>  #include "intel_wa.h"
>  #include "xe/xe_query.h"
>  
> +static int debugfs_file_has_wa(int drm_fd, int debugfs_fd,
> +			       const char *debugfs_name, const char *wa)
> +{
> +	char *debugfs_dump;
> +
> +	if (!igt_debugfs_exists(drm_fd, debugfs_name, O_RDONLY))
> +		return -1;
> +
> +	debugfs_dump = igt_sysfs_get(debugfs_fd, debugfs_name);
> +	if (debugfs_dump) {
> +		char *has_wa = strstr(debugfs_dump, wa);
> +
> +		free(debugfs_dump);
> +
> +		if (has_wa)
> +			return 1;
> +	}
> +
> +	return 0;
> +}
> +
>  /**
>   * igt_has_intel_wa:
>   * @drm_fd:	A drm file descriptor
> @@ -25,7 +46,6 @@ int igt_has_intel_wa(int drm_fd, const char *check_wa)
>  	int debugfs_fd;
>  	unsigned int xe;
>  	char name[256];
> -	char *debugfs_dump, *has_wa;
>  
>  	debugfs_fd = igt_debugfs_dir(drm_fd);
>  	if (debugfs_fd == -1)
> @@ -33,22 +53,14 @@ int igt_has_intel_wa(int drm_fd, const char *check_wa)
>  
>  	xe_for_each_gt(drm_fd, xe) {
>  		sprintf(name, "gt%d/workarounds", xe);
> -		if (!igt_debugfs_exists(drm_fd, name, O_RDONLY)) {
> -			ret = -1;
> +		ret = debugfs_file_has_wa(drm_fd, debugfs_fd, name, check_wa);
> +		if (ret)
>  			break;
> -		}
> -
> -		debugfs_dump = igt_sysfs_get(debugfs_fd, name);
> -		if (debugfs_dump) {
> -			has_wa = strstr(debugfs_dump, check_wa);
> -			free(debugfs_dump);
> -			if (has_wa) {
> -				ret = 1;
> -				break;
> -			}
> -		}
>  	}
>  
> +	if (!ret)
> +		ret = debugfs_file_has_wa(drm_fd, debugfs_fd, "workarounds", check_wa);
> +
>  	close(debugfs_fd);
>  	return ret;
>  }
> -- 
> 2.53.0

  reply	other threads:[~2026-05-05 13:34 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-05  5:47 [PATCH v4 0/2] Wa_14026633728 Shekhar Chauhan
2026-05-05  5:47 ` [PATCH v4 1/2] lib/intel_wa: Add workaround check for a wa within debugfs file Shekhar Chauhan
2026-05-05 13:34   ` Gustavo Sousa [this message]
2026-05-05 14:26     ` Jani Nikula
2026-05-05 14:50       ` Gustavo Sousa
2026-05-05 14:53         ` Jani Nikula
2026-05-05  5:47 ` [PATCH v4 2/2] tests/intel/xe_oa: Wa_14026633728 Shekhar Chauhan
2026-05-05 16:42   ` Dixit, Ashutosh
2026-05-05  6:59 ` ✓ i915.CI.BAT: success for Wa_14026633728 Patchwork
2026-05-05  7:25 ` ✓ Xe.CI.BAT: " Patchwork
2026-05-05 11:50 ` ✓ i915.CI.Full: " Patchwork
2026-05-05 14:43 ` ✗ Xe.CI.FULL: failure " 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=87wlxix9nf.fsf@intel.com \
    --to=gustavo.sousa@intel.com \
    --cc=ashutosh.dixit@intel.com \
    --cc=igt-dev@lists.freedesktop.org \
    --cc=shekhar.chauhan@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