[PATCH v5 1/6] drm/xe: add xe_device_wa infrastructure
Lucas De Marchi
lucas.demarchi at intel.com
Thu Jul 3 20:01:00 UTC 2025
On Wed, Jul 02, 2025 at 05:23:03PM -0500, Lucas De Marchi wrote:
>On Wed, Jul 02, 2025 at 03:09:19PM -0700, Matt Atwood wrote:
>>On Wed, Jul 02, 2025 at 04:57:34PM -0500, Lucas De Marchi wrote:
>>>On Wed, Jul 02, 2025 at 12:30:31PM -0700, Matt Atwood wrote:
>>>> There are some workarounds that must be applied before gt init,
>>>> wa_150154044425 for example. Instead of sprinkling them conditionally
>>>> throughout the driver as we did for i915 generate an oob.rules file
>>>> reusing the RTP infrastructure to make these easier to track.
>>>>
>>>> v2: rename xe_soc_wa to xe_device_wa
>>>> v5: derive prefix from argument rather then hard coding the values.
>>>>
>>>> Signed-off-by: Matt Atwood <matthew.s.atwood at intel.com>
>>>> ---
>>>> drivers/gpu/drm/xe/Makefile | 11 ++++++-
>>>> drivers/gpu/drm/xe/xe_device_wa_oob.rules | 0
>>>> drivers/gpu/drm/xe/xe_gen_wa_oob.c | 38 ++++++++++++++++++-----
>>>> 3 files changed, 41 insertions(+), 8 deletions(-)
>>>> create mode 100644 drivers/gpu/drm/xe/xe_device_wa_oob.rules
>>>>
>>>> diff --git a/drivers/gpu/drm/xe/Makefile b/drivers/gpu/drm/xe/Makefile
>>>> index 1d97e5b63f4e..48d4aa9d4ecc 100644
>>>> --- a/drivers/gpu/drm/xe/Makefile
>>>> +++ b/drivers/gpu/drm/xe/Makefile
>>>> @@ -21,6 +21,15 @@ $(obj)/generated/%_wa_oob.c $(obj)/generated/%_wa_oob.h: $(obj)/xe_gen_wa_oob \
>>>> $(src)/xe_wa_oob.rules
>>>> $(call cmd,wa_oob)
>>>>
>>>> +generated_device_oob := $(obj)/generated/xe_device_wa_oob.c $(obj)/generated/xe_device_wa_oob.h
>>>> +quiet_cmd_device_wa_oob = GEN $(notdir $(generated_device_oob))
>>>> + cmd_device_wa_oob = mkdir -p $(@D); $^ $(generated_device_oob)
>>>> +$(obj)/generated/%_device_wa_oob.c $(obj)/generated/%_device_wa_oob.h: $(obj)/xe_gen_wa_oob \
>>>> + $(src)/xe_device_wa_oob.rules
>>>> + $(call cmd,device_wa_oob)
>>>> +
>>>> +
>>>> +
>>>
>>>drop these several newlines.
>>Ack
>>>
>>>> # Please keep these build lists sorted!
>>>>
>>>> # core driver code
>>>> @@ -340,4 +349,4 @@ $(obj)/%.hdrtest: $(src)/%.h FORCE
>>>> $(call if_changed_dep,hdrtest)
>>>>
>>>> uses_generated_oob := $(addprefix $(obj)/, $(xe-y))
>>>> -$(uses_generated_oob): $(obj)/generated/xe_wa_oob.h
>>>> +$(uses_generated_oob): $(obj)/generated/xe_wa_oob.h $(obj)/generated/xe_device_wa_oob.h
>>>> diff --git a/drivers/gpu/drm/xe/xe_device_wa_oob.rules b/drivers/gpu/drm/xe/xe_device_wa_oob.rules
>>>> new file mode 100644
>>>> index 000000000000..e69de29bb2d1
>>>> diff --git a/drivers/gpu/drm/xe/xe_gen_wa_oob.c b/drivers/gpu/drm/xe/xe_gen_wa_oob.c
>>>> index ed9183599e31..341840926f60 100644
>>>> --- a/drivers/gpu/drm/xe/xe_gen_wa_oob.c
>>>> +++ b/drivers/gpu/drm/xe/xe_gen_wa_oob.c
>>>
>>>All the changes in this files should be a prep commit: they can be done
>>>regardless of having device_wa_oob
>>So split out the make file change in addition? or move the makefile
>>changes to the following commit?
>
>the change in the Makefile is only for adding the device_wa, so should
>be in the second commit.
>
>>>did you find any issue with strlcpy? I think it's available on all
>>>toolchains, but maybe we need the workaround by including tools/include/linux/string.h
>>>I tried the diff above locally and it worked for me though.
>>strlcpy isnt currently supported in the distribution recommended for
>
>did you check tools/include/linux/string.h I mentioned? How does perf
>use it since forever and it moved to a common location in 2015? yes, it
>may be that we will need to link string.o to get the weak symbol it
>defines.
so... to answer it myself: it's easy to link tools/lib/string.o for things in tools/.
Not as easy for hostprogs that are needed to generate kernel source.
To keep it simple and not need strlcpy(), let's just do this then:
diff --git a/drivers/gpu/drm/xe/xe_gen_wa_oob.c b/drivers/gpu/drm/xe/xe_gen_wa_oob.c
index 341840926f602..6581cb0f0e590 100644
--- a/drivers/gpu/drm/xe/xe_gen_wa_oob.c
+++ b/drivers/gpu/drm/xe/xe_gen_wa_oob.c
@@ -125,9 +125,16 @@ static int parse(FILE *input, FILE *csource, FILE *cheader, char *prefix)
static int fn_to_prefix(const char *fn, char *prefix, size_t size)
{
- if (!strncpy(prefix, fn, size - 1))
+ size_t len;
+
+ fn = basename(fn);
+ len = strlen(fn);
+
+ if (len > size - 1)
return -ENAMETOOLONG;
+ memcpy(prefix, fn, len + 1);
+
for (char *p = prefix; *p; p++) {
switch (*p) {
case '.':
@@ -168,7 +175,7 @@ int main(int argc, const char *argv[])
return 1;
}
- if (fn_to_prefix(basename(args[ARGS_CHEADER].fn), prefix, sizeof(prefix)) < 0)
+ if (fn_to_prefix(args[ARGS_CHEADER].fn, prefix, sizeof(prefix)) < 0)
return 1;
for (int i = 0; i < _ARGS_COUNT; i++) {
It fixes the bugs, doesn't depend on strlcpy() and doesn't use the
horrible strncpy().
Lucas De Marchi
More information about the Intel-xe
mailing list