All of lore.kernel.org
 help / color / mirror / Atom feed
From: Gustavo Sousa <gustavo.sousa@intel.com>
To: Matt Roper <matthew.d.roper@intel.com>
Cc: <igt-dev@lists.freedesktop.org>
Subject: Re: [PATCH i-g-t 02/10] lib/xe: Use stricter line-equality check when checking for workarounds
Date: Tue, 18 Aug 2026 15:40:44 -0300	[thread overview]
Message-ID: <87ik57b7bn.fsf@intel.com> (raw)
In-Reply-To: <20260729212333.GB7790@mdroper-desk1.amr.corp.intel.com>

Matt Roper <matthew.d.roper@intel.com> writes:

> On Tue, Jul 21, 2026 at 03:59:55PM -0300, Gustavo Sousa wrote:
>> Currently debugfs_file_has_wa() uses strstr() to check if a workaround
>> name is present in the debugfs dump.  Using strstr() would match the
>> workaround name anywhere in the dump buffer and with that we risk
>> producing unexpected results if the checked workaround name happens to
>> be a substring of another workaround present in the dump.
>> 
>> Fix that by making sure we match the workaround name with the full
>> line from the dump.
>
> There are other parts of IGT that use regular expressions from either
> POSIX (regcomp / regexec) or Glib (g_regex_new / g_regex_match).  Would
> it be possible to use one of those here instead of opencoding a match
> function?

Yeah.  That could make this function more readable and easier to extend.
I'll take a look at those options.

--
Gustavo Sousa

>
>
> Matt
>
>> 
>> Signed-off-by: Gustavo Sousa <gustavo.sousa@intel.com>
>> ---
>>  lib/xe/xe_wa.c | 39 ++++++++++++++++++++++++++++++++++++++-
>>  1 file changed, 38 insertions(+), 1 deletion(-)
>> 
>> diff --git a/lib/xe/xe_wa.c b/lib/xe/xe_wa.c
>> index ff5daf529831..d44431e7e61f 100644
>> --- a/lib/xe/xe_wa.c
>> +++ b/lib/xe/xe_wa.c
>> @@ -13,6 +13,43 @@
>>  #include "xe/xe_wa.h"
>>  #include "xe/xe_query.h"
>>  
>> +static bool debugfs_dump_has_wa(char *dump, const char *wa)
>> +{
>> +	char *a = dump;
>> +
>> +	while (*a) {
>> +		const char *b = wa;
>> +
>> +		/*
>> +		 * Each workaround name is indented by one tab
>> +		 * character; unindented lines are used as "section
>> +		 * names" identifying the type of workarounds that
>> +		 * follow (e.g. "GT Workarounds", "Engine Workarounds"
>> +		 * etc).
>> +		 */
>> +		if (*a++ != '\t')
>> +			goto next_line;
>> +
>> +		while (*a == *b && !(*a == '\0' || *a == '\n' || *b == '\0')) {
>> +			a++;
>> +			b++;
>> +		}
>> +
>> +		if ((*a == '\0' || *a == '\n') && *b == '\0')
>> +			return true;
>> +
>> +	next_line:
>> +		/* No match for this line, advance to the next one. */
>> +		while (*a != '\n' && *a != '\0')
>> +			a++;
>> +
>> +		if (*a == '\n')
>> +			a++;
>> +	}
>> +
>> +	return false;
>> +}
>> +
>>  static int debugfs_file_has_wa(int drm_fd, int debugfs_fd,
>>  			       const char *debugfs_name, const char *wa)
>>  {
>> @@ -23,7 +60,7 @@ static int debugfs_file_has_wa(int drm_fd, int debugfs_fd,
>>  
>>  	debugfs_dump = igt_sysfs_get(debugfs_fd, debugfs_name);
>>  	if (debugfs_dump) {
>> -		char *has_wa = strstr(debugfs_dump, wa);
>> +		bool has_wa = debugfs_dump_has_wa(debugfs_dump, wa);
>>  
>>  		free(debugfs_dump);
>>  
>> 
>> -- 
>> 2.55.0
>> 
>
> -- 
> Matt Roper
> Graphics Software Engineer
> Linux GPU Platform Enablement
> Intel Corporation

  reply	other threads:[~2026-08-18 18:41 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-21 18:59 [PATCH i-g-t 00/10] Implement Wa_14026539277 Gustavo Sousa
2026-07-21 18:59 ` [PATCH i-g-t 01/10] lib/xe: Move lib/intel_wa to lib/xe/xe_wa Gustavo Sousa
2026-07-29 21:04   ` Matt Roper
2026-07-29 21:09     ` Gustavo Sousa
2026-07-21 18:59 ` [PATCH i-g-t 02/10] lib/xe: Use stricter line-equality check when checking for workarounds Gustavo Sousa
2026-07-29 21:23   ` Matt Roper
2026-08-18 18:40     ` Gustavo Sousa [this message]
2026-07-21 18:59 ` [PATCH i-g-t 03/10] lib/xe: Gather workarounds debugfs dumps Gustavo Sousa
2026-07-29 21:39   ` Matt Roper
2026-07-21 18:59 ` [PATCH i-g-t 04/10] lib/xe: Cache workaround information in xe_device Gustavo Sousa
2026-07-29 21:58   ` Matt Roper
2026-08-18 18:02     ` Gustavo Sousa
2026-07-21 18:59 ` [PATCH i-g-t 05/10] lib/xe: Return boolean from xe_wa() Gustavo Sousa
2026-07-29 22:14   ` Matt Roper
2026-08-18 18:08     ` Gustavo Sousa
2026-07-21 18:59 ` [PATCH i-g-t 06/10] tests/intel/xe_pat: Adapt pat_entry_is_wb() to Xe3p Gustavo Sousa
2026-07-29 22:16   ` Matt Roper
2026-07-21 19:00 ` [PATCH i-g-t 07/10] lib/xe: Add xe_wa_from_cache() Gustavo Sousa
2026-07-29 22:20   ` Matt Roper
2026-07-21 19:00 ` [PATCH i-g-t 08/10] lib/intel_pat: Encapsulate management of xe_device's pat_cache Gustavo Sousa
2026-07-29 22:35   ` Matt Roper
2026-08-18 18:25     ` Gustavo Sousa
2026-07-21 19:00 ` [PATCH i-g-t 09/10] lib/intel_pat: Pass xe_device to xe_get_pat_config() Gustavo Sousa
2026-07-29 22:38   ` Matt Roper
2026-07-21 19:00 ` [PATCH i-g-t 10/10] intel: Implement Wa_14026539277 Gustavo Sousa
2026-07-21 23:18 ` ✓ Xe.CI.BAT: success for " Patchwork
2026-07-21 23:56 ` ✓ i915.CI.BAT: " Patchwork
2026-07-22 14:09 ` ✓ Xe.CI.FULL: " Patchwork
2026-07-22 22:52 ` ✗ i915.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=87ik57b7bn.fsf@intel.com \
    --to=gustavo.sousa@intel.com \
    --cc=igt-dev@lists.freedesktop.org \
    --cc=matthew.d.roper@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.