Skip to contentSkip to conversation

drm/xe: Create and use XE_DEVICE_WA infrastructure

PATCH Superseded Matt Atwood 3 participants 13 messages Jun 25, 2025

Subsystems (2)

v2 of 6 Superseded Latest is v6 →

lore
Share & tools
lore
#0 lore raw

v2 cover drm/xe: Create and use XE_DEVICE_WA infrastructure

There currently is not a way to apply and track workarounds that are needed ahead of GT init. This series adds a bit field to the xe_device structure similar to those in the GT structures to apply and track workarounds applied at runtime (oobs).

Device workarounds in this new infrastructure are tracked in the existing sysfs entries in gtX/workarounds.

Currently 15015404425 is the only workaround like this, so move it to using this new infrastructure.

PTL A0 is impacted by 15015404425, but only applies to Compute Die A0 stepping. The reality of modern platforms is that we're a Multi Chip Package with logic spread acress multiple dies. This information not being readily available during PCI probe without a read makes this more complicated.

Apply 15015404425 to PTL unconditionally during PCI probe (and GT init). After GT init use the Media GT stepping to determine if we can disable this workaround.

v2: Change naming from SoC to device, address styling issues, update commit messages
v3: rebase

Matt Atwood (5):
drm/xe: add xe_device_wa infrastructure
drm/xe: Add infrastructure for Device OOB workarounds drm/xe: Move Wa_15015404425 to use the new EX_DEVICE_WA macro drm/xe: extend Wa_15015404425 to apply to PTL drm/xe: disable wa_15015404425 for PTL B0

 drivers/gpu/drm/xe/Makefile               | 11 +++++-
 drivers/gpu/drm/xe/xe_device_types.h      |  9 +++++
 drivers/gpu/drm/xe/xe_device_wa_oob.rules |  2 +
 drivers/gpu/drm/xe/xe_gen_wa_oob.c        | 27 +++++++++----
 drivers/gpu/drm/xe/xe_mmio.c              | 10 ++---
 drivers/gpu/drm/xe/xe_pci.c               | 11 ++++++
 drivers/gpu/drm/xe/xe_rtp.c               |  5 +++
 drivers/gpu/drm/xe/xe_rtp.h               |  3 +-
 drivers/gpu/drm/xe/xe_rtp_types.h         |  2 +
 drivers/gpu/drm/xe/xe_wa.c                | 46 +++++++++++++++++++++++
 drivers/gpu/drm/xe/xe_wa.h                | 18 +++++++--
 drivers/gpu/drm/xe/xe_wa_oob.rules        |  1 +
 12 files changed, 127 insertions(+), 18 deletions(-)
 create mode 100644 drivers/gpu/drm/xe/xe_device_wa_oob.rules
Signature · 1 line
2.49.0
#1 lore raw

PATCH v3 1/5 drm/xe: add xe_device_wa infrastructure

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

---
 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        | 27 ++++++++++++++++-------
 3 files changed, 29 insertions(+), 9 deletions(-)
 create mode 100644 drivers/gpu/drm/xe/xe_device_wa_oob.rules
drivers/gpu/drm/xe/Makefile +10 -1
index eee6bac01a00..64498ce2a839 100644
@@ -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)
+
+
+
 # Please keep these build lists sorted!
 
 # core driver code
@@ -339,4 +348,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
drivers/gpu/drm/xe/xe_device_wa_oob.rules new file +0 -0
new file mode 100644
index 000000000000..e69de29bb2d1
drivers/gpu/drm/xe/xe_gen_wa_oob.c +19 -8
index ed9183599e31..d8bb26317f28 100644
@@ -18,8 +18,8 @@
 	" *\n" \
 	" * This file was generated from rules: %s\n" \
 	" */\n" \
-	"#ifndef _GENERATED_XE_WA_OOB_\n" \
-	"#define _GENERATED_XE_WA_OOB_\n" \
+	"#ifndef _GENERATED_%s_\n" \
+	"#define _GENERATED_%s_\n" \
 	"\n" \
 	"enum {\n"
 
@@ -52,7 +52,7 @@ static char *strip(char *line, size_t linelen)
 }
 
 #define MAX_LINE_LEN 4096
-static int parse(FILE *input, FILE *csource, FILE *cheader)
+static int parse(FILE *input, FILE *csource, FILE *cheader, bool device)
 {
 	char line[MAX_LINE_LEN + 1];
 	char *name, *prev_name = NULL, *rules;
@@ -96,7 +96,10 @@ static int parse(FILE *input, FILE *csource, FILE *cheader)
 		}
 
 		if (name) {
-			fprintf(cheader, "\tXE_WA_OOB_%s = %u,\n", name, idx);
+			if (device == false)
+				fprintf(cheader, "\tXE_WA_OOB_%s = %u,\n", name, idx);
+			else
+				fprintf(cheader, "\tXE_DEVICE_WA_OOB_%s = %u,\n", name, idx);
 
 			/* Close previous entry before starting a new one */
 			if (idx)
@@ -117,8 +120,10 @@ static int parse(FILE *input, FILE *csource, FILE *cheader)
 	/* Close last entry */
 	if (idx)
 		fprintf(csource, ") },\n");
-
-	fprintf(cheader, "\t_XE_WA_OOB_COUNT = %u\n", idx);
+	if (device == false)
+		fprintf(cheader, "\t_XE_WA_OOB_COUNT = %u\n", idx);
+	else
+		fprintf(cheader, "\t_XE_DEVICE_WA_OOB_COUNT = %u\n", idx);
 
 	return 0;
 }
@@ -157,9 +162,15 @@ int main(int argc, const char *argv[])
 		}
 	}
 
-	fprintf(args[ARGS_CHEADER].f, HEADER, args[ARGS_INPUT].fn);
+	char *device = strstr(args[ARGS_CHEADER].fn, "device_");
+	if (device == NULL)
+		fprintf(args[ARGS_CHEADER].f, HEADER, args[ARGS_INPUT].fn, "XE_WA_OOB", "XE_WA_OOB");
+	else
+		fprintf(args[ARGS_CHEADER].f, HEADER, args[ARGS_INPUT].fn, "XE_DEVICE_WA_OOB", "XE_DEVICE_WA_OOB");
+
+	bool prefix = device != NULL ? true : false;
 	ret = parse(args[ARGS_INPUT].f, args[ARGS_CSOURCE].f,
-		    args[ARGS_CHEADER].f);
+		    args[ARGS_CHEADER].f, prefix);
 	if (!ret)
 		fprintf(args[ARGS_CHEADER].f, FOOTER);
 
Signature · 1 line
2.49.0
#2 lore raw

PATCH v3 2/5 drm/xe: Add infrastructure for Device OOB workarounds

In reply to Matt Atwood

Some workarounds need to be able to be applied ahead of any GT initialization for example 15015404425. This patch creates XE_DEVICE_WA macro, in the same vein as XE_WA. This macro can be used ahead of GT initialization, and can be tracked in sysfs. This should alleviate some of the complexities that exist in i915.

v2: name change SoC to Device, address style issues

---
 drivers/gpu/drm/xe/xe_device_types.h |  9 ++++++
 drivers/gpu/drm/xe/xe_pci.c          |  4 +++
 drivers/gpu/drm/xe/xe_rtp.c          |  5 +++
 drivers/gpu/drm/xe/xe_rtp.h          |  3 +-
 drivers/gpu/drm/xe/xe_rtp_types.h    |  2 ++
 drivers/gpu/drm/xe/xe_wa.c           | 46 ++++++++++++++++++++++++++++
 drivers/gpu/drm/xe/xe_wa.h           | 18 +++++++++--
 7 files changed, 83 insertions(+), 4 deletions(-)
drivers/gpu/drm/xe/xe_device_types.h +9 -0
index 6aca4b1a2824..62f09d2923c3 100644
@@ -360,6 +360,15 @@ struct xe_device {
 		u8 skip_pcode:1;
 	} info;
 
+	/** @xe_active.oob: bitmap with active OOB workarounds */
+	unsigned long *oob;
+	/**
+	 *  @xe_active.oob_initialized: mark oob as initialized to help
+	 *  detecting misuse of XE_SOC_WA() - it can only be called on
+	 *  initialization after SOC OOB WAs have been processed
+	 */
+	bool oob_initialized;
+
 	/** @survivability: survivability information for device */
 	struct xe_survivability survivability;
 
drivers/gpu/drm/xe/xe_pci.c +4 -0
index 824461c31288..a9f708608f3e 100644
@@ -32,6 +32,7 @@
 #include "xe_step.h"
 #include "xe_survivability_mode.h"
 #include "xe_tile.h"
+#include "xe_wa.h"
 
 enum toggle_d3cold {
 	D3COLD_DISABLE,
@@ -832,6 +833,9 @@ static int xe_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 	if (err)
 		return err;
 
+	xe_device_wa_init(xe);
+	xe_device_wa_process_oob(xe);
+
 	err = xe_device_probe_early(xe);
 	/*
 	 * In Boot Survivability mode, no drm card is exposed and driver
drivers/gpu/drm/xe/xe_rtp.c +5 -0
index 29e694bb1219..2a0b0a1a8969 100644
@@ -196,6 +196,11 @@ static void rtp_get_context(struct xe_rtp_process_ctx *ctx,
 		*gt = (*hwe)->gt;
 		*xe = gt_to_xe(*gt);
 		break;
+	case XE_RTP_PROCESS_TYPE_DEVICE:
+		*hwe = NULL;
+		*gt = NULL;
+		*xe = ctx->xe;
+		break;
 	}
 }
 
drivers/gpu/drm/xe/xe_rtp.h +2 -1
index 4fe736a11c42..ac260feaabef 100644
@@ -422,7 +422,8 @@ struct xe_reg_sr;
 
 #define XE_RTP_PROCESS_CTX_INITIALIZER(arg__) _Generic((arg__),							\
 	struct xe_hw_engine * :	(struct xe_rtp_process_ctx){ { (void *)(arg__) }, XE_RTP_PROCESS_TYPE_ENGINE },	\
-	struct xe_gt * :	(struct xe_rtp_process_ctx){ { (void *)(arg__) }, XE_RTP_PROCESS_TYPE_GT })
+	struct xe_gt * :	(struct xe_rtp_process_ctx){ { (void *)(arg__) }, XE_RTP_PROCESS_TYPE_GT },	\
+	struct xe_device * :	(struct xe_rtp_process_ctx){ { (void *)(arg__) }, XE_RTP_PROCESS_TYPE_DEVICE })
 
 void xe_rtp_process_ctx_enable_active_tracking(struct xe_rtp_process_ctx *ctx,
 					       unsigned long *active_entries,
drivers/gpu/drm/xe/xe_rtp_types.h +2 -0
index 1b76b947c706..123579ebf2cf 100644
@@ -112,12 +112,14 @@ struct xe_rtp_entry {
 enum xe_rtp_process_type {
 	XE_RTP_PROCESS_TYPE_GT,
 	XE_RTP_PROCESS_TYPE_ENGINE,
+	XE_RTP_PROCESS_TYPE_DEVICE,
 };
 
 struct xe_rtp_process_ctx {
 	union {
 		struct xe_gt *gt;
 		struct xe_hw_engine *hwe;
+		struct xe_device *xe;
 	};
 	enum xe_rtp_process_type type;
 	unsigned long *active_entries;
drivers/gpu/drm/xe/xe_wa.c +46 -0

70 lines not on this page · raw message

drivers/gpu/drm/xe/xe_wa.h +15 -3
index 52337405b5bc..09d065e0abb5 100644
@@ -14,7 +14,9 @@ struct xe_hw_engine;
 struct xe_tile;
 
 int xe_wa_init(struct xe_gt *gt);
+int xe_device_wa_init(struct xe_device *xe);
 void xe_wa_process_oob(struct xe_gt *gt);
+void xe_device_wa_process_oob(struct xe_device *xe);
 void xe_wa_process_gt(struct xe_gt *gt);
 void xe_wa_process_engine(struct xe_hw_engine *hwe);
 void xe_wa_process_lrc(struct xe_hw_engine *hwe);
@@ -22,14 +24,24 @@ void xe_wa_apply_tile_workarounds(struct xe_tile *tile);
 void xe_wa_dump(struct xe_gt *gt, struct drm_printer *p);
 
 /**
- * XE_WA - Out-of-band workarounds, that don't fit the lifecycle any
- *         other more specific type
+ * XE_WA - Out-of-band GT workarounds, that don't fit the lifecycle any
+ *         other more specific type,
  * @gt__: gt instance
- * @id__: XE_OOB_<id__>, as generated by build system in generated/xe_wa_oob.h
+ * @id__: XE_WA_OOB_<id__>, as generated by build system in generated/xe_wa_oob.h
  */
 #define XE_WA(gt__, id__) ({						\
 	xe_gt_assert(gt__, (gt__)->wa_active.oob_initialized);		\
 	test_bit(XE_WA_OOB_ ## id__, (gt__)->wa_active.oob);		\
 })
 
+/**
+ * XE_DEVICE_WA - Out-of-band Device workarounds, that don't fit the lifecycle any
+ *         other more specific type
+ * @xe__: xe_device
+ * @id__: XE_SOC_WA_OOB_<id__>, as generated by build system in generated/xe_wa_oob.h
+ */
+#define XE_DEVICE_WA(xe__, id__) ({					\
+	xe_assert(xe__, (xe__)->oob_initialized);			\
+	test_bit(XE_DEVICE_WA_OOB_ ## id__, (xe__)->oob);			\
+})
 #endif
Signature · 1 line
2.49.0
#3 lore raw

Re: [PATCH v3 2/5] drm/xe: Add infrastructure for Device OOB workarounds

Quoted 5 lines · Matt Atwood

Some workarounds need to be able to be applied ahead of any GT initialization for example 15015404425. This patch creates XE_DEVICE_WA macro, in the same vein as XE_WA. This macro can be used ahead of GT initialization, and can be tracked in sysfs. This should alleviate some of the complexities that exist in i915.

I'd be inclined to break this into two patches:

* A patch to RTP that adds devices as a new type of RTP context. This should also add WARN_ON guards for all of the existing RTP rules that require a gt (similar to those that exist for engines).

* A patch that adds the the the tracking information to xe_device and calls the init/process functions at the appropriate place.

Quoted 20 lines

v2: name change SoC to Device, address style issues

---
 drivers/gpu/drm/xe/xe_device_types.h |  9 ++++++
 drivers/gpu/drm/xe/xe_pci.c          |  4 +++
 drivers/gpu/drm/xe/xe_rtp.c          |  5 +++
 drivers/gpu/drm/xe/xe_rtp.h          |  3 +-
 drivers/gpu/drm/xe/xe_rtp_types.h    |  2 ++
 drivers/gpu/drm/xe/xe_wa.c           | 46 ++++++++++++++++++++++++++++
 drivers/gpu/drm/xe/xe_wa.h           | 18 +++++++++--
 7 files changed, 83 insertions(+), 4 deletions(-)
drivers/gpu/drm/xe/xe_device_types.h +0 -0
index 6aca4b1a2824..62f09d2923c3 100644
@@ -360,6 +360,15 @@ struct xe_device {
 		u8 skip_pcode:1;

drivers/gpu/drm/xe/xe_device_types.h struct xe_device { · line 370

Quoted 10 lines
drivers/gpu/drm/xe/xe_device_types.h +8 -0
 	} info;
 
+	/** @xe_active.oob: bitmap with active OOB workarounds */
+	unsigned long *oob;
+	/**
+	 *  @xe_active.oob_initialized: mark oob as initialized to help
+	 *  detecting misuse of XE_SOC_WA() - it can only be called on
+	 *  initialization after SOC OOB WAs have been processed
+	 */
+	bool oob_initialized;

Did you mean to wrap these in a sub-struct? Because right now the kerneldocs don't match the actual placement. Also the "SOC" stuff is outdated.

Quoted 102 lines
drivers/gpu/drm/xe/xe_device_types.h +1 -0
+
 	/** @survivability: survivability information for device */
 	struct xe_survivability survivability;
 
drivers/gpu/drm/xe/xe_pci.c +4 -0
index 824461c31288..a9f708608f3e 100644
@@ -32,6 +32,7 @@
 #include "xe_step.h"
 #include "xe_survivability_mode.h"
 #include "xe_tile.h"
+#include "xe_wa.h"
 
 enum toggle_d3cold {
 	D3COLD_DISABLE,
@@ -832,6 +833,9 @@ static int xe_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 	if (err)
 		return err;
 
+	xe_device_wa_init(xe);
+	xe_device_wa_process_oob(xe);
+
 	err = xe_device_probe_early(xe);
 	/*
 	 * In Boot Survivability mode, no drm card is exposed and driver
drivers/gpu/drm/xe/xe_rtp.c +5 -0
index 29e694bb1219..2a0b0a1a8969 100644
@@ -196,6 +196,11 @@ static void rtp_get_context(struct xe_rtp_process_ctx *ctx,
 		*gt = (*hwe)->gt;
 		*xe = gt_to_xe(*gt);
 		break;
+	case XE_RTP_PROCESS_TYPE_DEVICE:
+		*hwe = NULL;
+		*gt = NULL;
+		*xe = ctx->xe;
+		break;
 	}
 }
 
drivers/gpu/drm/xe/xe_rtp.h +2 -1
index 4fe736a11c42..ac260feaabef 100644
@@ -422,7 +422,8 @@ struct xe_reg_sr;
 
 #define XE_RTP_PROCESS_CTX_INITIALIZER(arg__) _Generic((arg__),							\
 	struct xe_hw_engine * :	(struct xe_rtp_process_ctx){ { (void *)(arg__) }, XE_RTP_PROCESS_TYPE_ENGINE },	\
-	struct xe_gt * :	(struct xe_rtp_process_ctx){ { (void *)(arg__) }, XE_RTP_PROCESS_TYPE_GT })
+	struct xe_gt * :	(struct xe_rtp_process_ctx){ { (void *)(arg__) }, XE_RTP_PROCESS_TYPE_GT },	\
+	struct xe_device * :	(struct xe_rtp_process_ctx){ { (void *)(arg__) }, XE_RTP_PROCESS_TYPE_DEVICE })
 
 void xe_rtp_process_ctx_enable_active_tracking(struct xe_rtp_process_ctx *ctx,
 					       unsigned long *active_entries,
drivers/gpu/drm/xe/xe_rtp_types.h +2 -0
index 1b76b947c706..123579ebf2cf 100644
@@ -112,12 +112,14 @@ struct xe_rtp_entry {
 enum xe_rtp_process_type {
 	XE_RTP_PROCESS_TYPE_GT,
 	XE_RTP_PROCESS_TYPE_ENGINE,
+	XE_RTP_PROCESS_TYPE_DEVICE,
 };
 
 struct xe_rtp_process_ctx {
 	union {
 		struct xe_gt *gt;
 		struct xe_hw_engine *hwe;
+		struct xe_device *xe;
 	};
 	enum xe_rtp_process_type type;
 	unsigned long *active_entries;
drivers/gpu/drm/xe/xe_wa.c +8 -0
index f51218a7a580..2cb2fab20070 100644
@@ -11,6 +11,7 @@
 #include <linux/fault-inject.h>
 
 #include <generated/xe_wa_oob.h>
+#include <generated/xe_device_wa_oob.h>
 
 #include "regs/xe_engine_regs.h"
 #include "regs/xe_gt_regs.h"
@@ -876,6 +877,13 @@ static __maybe_unused const struct xe_rtp_entry oob_was[] = {
 
 static_assert(ARRAY_SIZE(oob_was) - 1 == _XE_WA_OOB_COUNT);
 
+static __maybe_unused const struct xe_rtp_entry device_oob_was[] = {
+#include <generated/xe_device_wa_oob.c>
+	{}
+};
+
+static_assert(ARRAY_SIZE(device_oob_was) - 1 == _XE_DEVICE_WA_OOB_COUNT);
+
 __diag_pop();
 
 /**

drivers/gpu/drm/xe/xe_wa.c void xe_wa_process_oob(struct xe_gt *gt) · line 906

Quoted 4 lines
drivers/gpu/drm/xe/xe_wa.c +1 -0
@@ -895,6 +903,39 @@ void xe_wa_process_oob(struct xe_gt *gt)
 	xe_rtp_process(&ctx, oob_was);
 }
 
+int xe_device_wa_init(struct xe_device *xe)

We've been trying to be better about naming functions from xe_foo.c as xe_foo_*(). So these new functions might be better with names like xe_wa_device_init() and xe_wa_process_device_oob() and such.

At some point we should also probably go back and rename the existing GT functions to include 'gt' in their names at the corresponding places.

Quoted 36 lines
drivers/gpu/drm/xe/xe_wa.c +32 -0
+{
+	unsigned long *p;
+
+	p = drmm_kzalloc(&xe->drm,
+			 sizeof(xe->oob) * BITS_TO_LONGS(ARRAY_SIZE(device_oob_was)),
+			 GFP_KERNEL);
+
+	if (!p)
+		return -ENOMEM;
+
+	xe->oob = p;
+
+	return 0;
+}
+
+/**
+ * xe_device_wa_process_oob - process OOB workaround table
+ * @xe: xe device instance process workarounds for
+ *
+ * Process OOB workaround table for this platform, marking in @xe the
+ * workarounds that are active.
+ */
+void xe_device_wa_process_oob(struct xe_device *xe)
+{
+	struct xe_rtp_process_ctx ctx = XE_RTP_PROCESS_CTX_INITIALIZER(xe);
+
+	xe_rtp_process_ctx_enable_active_tracking(&ctx, xe->oob, ARRAY_SIZE(device_oob_was));
+
+	xe->oob_initialized = true;
+	xe_rtp_process(&ctx, device_oob_was);
+}
+
 /**
  * xe_wa_process_gt - process GT workaround table
  * @gt: GT instance to process workarounds for

drivers/gpu/drm/xe/xe_wa.c void xe_wa_dump(struct xe_gt *gt, struct drm_printer *p) · line 1048

Quoted 8 lines
drivers/gpu/drm/xe/xe_wa.c +5 -0
@@ -1000,6 +1041,11 @@ void xe_wa_dump(struct xe_gt *gt, struct drm_printer *p)
 	for_each_set_bit(idx, gt->wa_active.oob, ARRAY_SIZE(oob_was))
 		if (oob_was[idx].name)
 			drm_printf_indent(p, 1, "%s\n", oob_was[idx].name);
+
+	drm_printf(p, "\nDevice OOB Workarounds\n");
+	for_each_set_bit(idx, gt_to_xe(gt)->oob, ARRAY_SIZE(device_oob_was))
+		if (device_oob_was[idx].name)
+			drm_printf_indent(p, 1, "%s\n", device_oob_was[idx].name);

This function generates the contents of a per-GT debugfs node. We don't want to stick device workarounds at the bottom of a per-GT entry; we should probably have a different debugfs entry outside the GT hierarchy to report these. That would also ensure that we can track device workarounds on platforms with no GTs and no GT debugfs (that's not something that exists today, but there's been a lot of interest in letting igpu's run in a "not GT" mode for debug purposes, so we'll probably have it eventually).

Quoted 29 lines
drivers/gpu/drm/xe/xe_wa.c +0 -0
 }
 
 /*
drivers/gpu/drm/xe/xe_wa.h +5 -3
index 52337405b5bc..09d065e0abb5 100644
@@ -14,7 +14,9 @@ struct xe_hw_engine;
 struct xe_tile;
 
 int xe_wa_init(struct xe_gt *gt);
+int xe_device_wa_init(struct xe_device *xe);
 void xe_wa_process_oob(struct xe_gt *gt);
+void xe_device_wa_process_oob(struct xe_device *xe);
 void xe_wa_process_gt(struct xe_gt *gt);
 void xe_wa_process_engine(struct xe_hw_engine *hwe);
 void xe_wa_process_lrc(struct xe_hw_engine *hwe);
@@ -22,14 +24,24 @@ void xe_wa_apply_tile_workarounds(struct xe_tile *tile);
 void xe_wa_dump(struct xe_gt *gt, struct drm_printer *p);
 
 /**
- * XE_WA - Out-of-band workarounds, that don't fit the lifecycle any
- *         other more specific type
+ * XE_WA - Out-of-band GT workarounds, that don't fit the lifecycle any
+ *         other more specific type,
  * @gt__: gt instance
- * @id__: XE_OOB_<id__>, as generated by build system in generated/xe_wa_oob.h
+ * @id__: XE_WA_OOB_<id__>, as generated by build system in generated/xe_wa_oob.h
  */

drivers/gpu/drm/xe/xe_wa.h void xe_wa_apply_tile_workarounds(struct xe_tile *tile); · line 41

Quoted 10 lines
drivers/gpu/drm/xe/xe_wa.h +5 -0
 #define XE_WA(gt__, id__) ({						\
 	xe_gt_assert(gt__, (gt__)->wa_active.oob_initialized);		\
 	test_bit(XE_WA_OOB_ ## id__, (gt__)->wa_active.oob);		\
 })
 
+/**
+ * XE_DEVICE_WA - Out-of-band Device workarounds, that don't fit the lifecycle any
+ *         other more specific type
+ * @xe__: xe_device
+ * @id__: XE_SOC_WA_OOB_<id__>, as generated by build system in generated/xe_wa_oob.h

The "SOC" here is outdated. Also the wrong header is referenced.

drivers/gpu/drm/xe/xe_wa.h void xe_wa_apply_tile_workarounds(struct xe_tile *tile); · line 47

Quoted 6 lines
drivers/gpu/drm/xe/xe_wa.h +5 -0
+ */
+#define XE_DEVICE_WA(xe__, id__) ({					\
+	xe_assert(xe__, (xe__)->oob_initialized);			\
+	test_bit(XE_DEVICE_WA_OOB_ ## id__, (xe__)->oob);			\
+})
 #endif

This is probably fine short-term, but I think eventually we should just have a single XE_WA() call that _Generic()'s on its parameter to do the lookup in the proper place (gt or device). If we don't want to _Generic it for some reason, then the existing macro should probably get renamed to XE_GT_WA() to clarify its purpose.

Matt

Quoted 3 lines
Signature · 1 line
2.49.0
Signature · 4 lines
Matt Roper
Graphics Software Engineer
Linux GPU Platform Enablement
Intel Corporation
#4 lore raw

Re: [PATCH v3 2/5] drm/xe: Add infrastructure for Device OOB workarounds

Quoted 162 lines · Matt Roper
Quoted 5 lines · Matt Atwood

Some workarounds need to be able to be applied ahead of any GT initialization for example 15015404425. This patch creates XE_DEVICE_WA macro, in the same vein as XE_WA. This macro can be used ahead of GT initialization, and can be tracked in sysfs. This should alleviate some of the complexities that exist in i915.

I'd be inclined to break this into two patches:

* A patch to RTP that adds devices as a new type of RTP context. This should also add WARN_ON guards for all of the existing RTP rules that require a gt (similar to those that exist for engines).

* A patch that adds the the the tracking information to xe_device and calls the init/process functions at the appropriate place.

Quoted 20 lines

v2: name change SoC to Device, address style issues

---
 drivers/gpu/drm/xe/xe_device_types.h |  9 ++++++
 drivers/gpu/drm/xe/xe_pci.c          |  4 +++
 drivers/gpu/drm/xe/xe_rtp.c          |  5 +++
 drivers/gpu/drm/xe/xe_rtp.h          |  3 +-
 drivers/gpu/drm/xe/xe_rtp_types.h    |  2 ++
 drivers/gpu/drm/xe/xe_wa.c           | 46 ++++++++++++++++++++++++++++
 drivers/gpu/drm/xe/xe_wa.h           | 18 +++++++++--
 7 files changed, 83 insertions(+), 4 deletions(-)
drivers/gpu/drm/xe/xe_device_types.h +0 -0
index 6aca4b1a2824..62f09d2923c3 100644
@@ -360,6 +360,15 @@ struct xe_device {
 		u8 skip_pcode:1;

drivers/gpu/drm/xe/xe_device_types.h struct xe_device { · line 370

Quoted 10 lines
drivers/gpu/drm/xe/xe_device_types.h +8 -0
 	} info;
 
+	/** @xe_active.oob: bitmap with active OOB workarounds */
+	unsigned long *oob;
+	/**
+	 *  @xe_active.oob_initialized: mark oob as initialized to help
+	 *  detecting misuse of XE_SOC_WA() - it can only be called on
+	 *  initialization after SOC OOB WAs have been processed
+	 */
+	bool oob_initialized;

Did you mean to wrap these in a sub-struct? Because right now the kerneldocs don't match the actual placement. Also the "SOC" stuff is outdated.

Quoted 102 lines
drivers/gpu/drm/xe/xe_device_types.h +1 -0
+
 	/** @survivability: survivability information for device */
 	struct xe_survivability survivability;
 
drivers/gpu/drm/xe/xe_pci.c +4 -0
index 824461c31288..a9f708608f3e 100644
@@ -32,6 +32,7 @@
 #include "xe_step.h"
 #include "xe_survivability_mode.h"
 #include "xe_tile.h"
+#include "xe_wa.h"
 
 enum toggle_d3cold {
 	D3COLD_DISABLE,
@@ -832,6 +833,9 @@ static int xe_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 	if (err)
 		return err;
 
+	xe_device_wa_init(xe);
+	xe_device_wa_process_oob(xe);
+
 	err = xe_device_probe_early(xe);
 	/*
 	 * In Boot Survivability mode, no drm card is exposed and driver
drivers/gpu/drm/xe/xe_rtp.c +5 -0
index 29e694bb1219..2a0b0a1a8969 100644
@@ -196,6 +196,11 @@ static void rtp_get_context(struct xe_rtp_process_ctx *ctx,
 		*gt = (*hwe)->gt;
 		*xe = gt_to_xe(*gt);
 		break;
+	case XE_RTP_PROCESS_TYPE_DEVICE:
+		*hwe = NULL;
+		*gt = NULL;
+		*xe = ctx->xe;
+		break;
 	}
 }
 
drivers/gpu/drm/xe/xe_rtp.h +2 -1
index 4fe736a11c42..ac260feaabef 100644
@@ -422,7 +422,8 @@ struct xe_reg_sr;
 
 #define XE_RTP_PROCESS_CTX_INITIALIZER(arg__) _Generic((arg__),							\
 	struct xe_hw_engine * :	(struct xe_rtp_process_ctx){ { (void *)(arg__) }, XE_RTP_PROCESS_TYPE_ENGINE },	\
-	struct xe_gt * :	(struct xe_rtp_process_ctx){ { (void *)(arg__) }, XE_RTP_PROCESS_TYPE_GT })
+	struct xe_gt * :	(struct xe_rtp_process_ctx){ { (void *)(arg__) }, XE_RTP_PROCESS_TYPE_GT },	\
+	struct xe_device * :	(struct xe_rtp_process_ctx){ { (void *)(arg__) }, XE_RTP_PROCESS_TYPE_DEVICE })
 
 void xe_rtp_process_ctx_enable_active_tracking(struct xe_rtp_process_ctx *ctx,
 					       unsigned long *active_entries,
drivers/gpu/drm/xe/xe_rtp_types.h +2 -0
index 1b76b947c706..123579ebf2cf 100644
@@ -112,12 +112,14 @@ struct xe_rtp_entry {
 enum xe_rtp_process_type {
 	XE_RTP_PROCESS_TYPE_GT,
 	XE_RTP_PROCESS_TYPE_ENGINE,
+	XE_RTP_PROCESS_TYPE_DEVICE,
 };
 
 struct xe_rtp_process_ctx {
 	union {
 		struct xe_gt *gt;
 		struct xe_hw_engine *hwe;
+		struct xe_device *xe;
 	};
 	enum xe_rtp_process_type type;
 	unsigned long *active_entries;
drivers/gpu/drm/xe/xe_wa.c +8 -0
index f51218a7a580..2cb2fab20070 100644
@@ -11,6 +11,7 @@
 #include <linux/fault-inject.h>
 
 #include <generated/xe_wa_oob.h>
+#include <generated/xe_device_wa_oob.h>
 
 #include "regs/xe_engine_regs.h"
 #include "regs/xe_gt_regs.h"
@@ -876,6 +877,13 @@ static __maybe_unused const struct xe_rtp_entry oob_was[] = {
 
 static_assert(ARRAY_SIZE(oob_was) - 1 == _XE_WA_OOB_COUNT);
 
+static __maybe_unused const struct xe_rtp_entry device_oob_was[] = {
+#include <generated/xe_device_wa_oob.c>
+	{}
+};
+
+static_assert(ARRAY_SIZE(device_oob_was) - 1 == _XE_DEVICE_WA_OOB_COUNT);
+
 __diag_pop();
 
 /**

drivers/gpu/drm/xe/xe_wa.c void xe_wa_process_oob(struct xe_gt *gt) · line 906

Quoted 4 lines
drivers/gpu/drm/xe/xe_wa.c +1 -0
@@ -895,6 +903,39 @@ void xe_wa_process_oob(struct xe_gt *gt)
 	xe_rtp_process(&ctx, oob_was);
 }
 
+int xe_device_wa_init(struct xe_device *xe)

We've been trying to be better about naming functions from xe_foo.c as xe_foo_*(). So these new functions might be better with names like xe_wa_device_init() and xe_wa_process_device_oob() and such.

Quoted 8 lines

At some point we should also probably go back and rename the existing GT functions to include 'gt' in their names at the corresponding places.

drivers/gpu/drm/xe/xe_wa.c void xe_wa_process_oob(struct xe_gt *gt) · line 911

Quoted 5 lines
drivers/gpu/drm/xe/xe_wa.c +5 -0
+{
+	unsigned long *p;
+
+	p = drmm_kzalloc(&xe->drm,
+			 sizeof(xe->oob) * BITS_TO_LONGS(ARRAY_SIZE(device_oob_was)),

Overlooked this before...this winds up working because the size of a pointer (xe->oob) is the same as the size of an unsigned long. But logically we want to know the allocation size of each long in the array here, so passing either *p or *xe->oob would be better (preferably *p since that matches the coding pattern used pretty much everywhere in the kernel).

Matt

Quoted 117 lines
Quoted 31 lines
drivers/gpu/drm/xe/xe_wa.c +27 -0
+			 GFP_KERNEL);
+
+	if (!p)
+		return -ENOMEM;
+
+	xe->oob = p;
+
+	return 0;
+}
+
+/**
+ * xe_device_wa_process_oob - process OOB workaround table
+ * @xe: xe device instance process workarounds for
+ *
+ * Process OOB workaround table for this platform, marking in @xe the
+ * workarounds that are active.
+ */
+void xe_device_wa_process_oob(struct xe_device *xe)
+{
+	struct xe_rtp_process_ctx ctx = XE_RTP_PROCESS_CTX_INITIALIZER(xe);
+
+	xe_rtp_process_ctx_enable_active_tracking(&ctx, xe->oob, ARRAY_SIZE(device_oob_was));
+
+	xe->oob_initialized = true;
+	xe_rtp_process(&ctx, device_oob_was);
+}
+
 /**
  * xe_wa_process_gt - process GT workaround table
  * @gt: GT instance to process workarounds for

drivers/gpu/drm/xe/xe_wa.c void xe_wa_dump(struct xe_gt *gt, struct drm_printer *p) · line 1048

Quoted 8 lines
drivers/gpu/drm/xe/xe_wa.c +5 -0
@@ -1000,6 +1041,11 @@ void xe_wa_dump(struct xe_gt *gt, struct drm_printer *p)
 	for_each_set_bit(idx, gt->wa_active.oob, ARRAY_SIZE(oob_was))
 		if (oob_was[idx].name)
 			drm_printf_indent(p, 1, "%s\n", oob_was[idx].name);
+
+	drm_printf(p, "\nDevice OOB Workarounds\n");
+	for_each_set_bit(idx, gt_to_xe(gt)->oob, ARRAY_SIZE(device_oob_was))
+		if (device_oob_was[idx].name)
+			drm_printf_indent(p, 1, "%s\n", device_oob_was[idx].name);

This function generates the contents of a per-GT debugfs node. We don't want to stick device workarounds at the bottom of a per-GT entry; we should probably have a different debugfs entry outside the GT hierarchy to report these. That would also ensure that we can track device workarounds on platforms with no GTs and no GT debugfs (that's not something that exists today, but there's been a lot of interest in letting igpu's run in a "not GT" mode for debug purposes, so we'll probably have it eventually).

Quoted 29 lines
drivers/gpu/drm/xe/xe_wa.c +0 -0
 }
 
 /*
drivers/gpu/drm/xe/xe_wa.h +5 -3
index 52337405b5bc..09d065e0abb5 100644
@@ -14,7 +14,9 @@ struct xe_hw_engine;
 struct xe_tile;
 
 int xe_wa_init(struct xe_gt *gt);
+int xe_device_wa_init(struct xe_device *xe);
 void xe_wa_process_oob(struct xe_gt *gt);
+void xe_device_wa_process_oob(struct xe_device *xe);
 void xe_wa_process_gt(struct xe_gt *gt);
 void xe_wa_process_engine(struct xe_hw_engine *hwe);
 void xe_wa_process_lrc(struct xe_hw_engine *hwe);
@@ -22,14 +24,24 @@ void xe_wa_apply_tile_workarounds(struct xe_tile *tile);
 void xe_wa_dump(struct xe_gt *gt, struct drm_printer *p);
 
 /**
- * XE_WA - Out-of-band workarounds, that don't fit the lifecycle any
- *         other more specific type
+ * XE_WA - Out-of-band GT workarounds, that don't fit the lifecycle any
+ *         other more specific type,
  * @gt__: gt instance
- * @id__: XE_OOB_<id__>, as generated by build system in generated/xe_wa_oob.h
+ * @id__: XE_WA_OOB_<id__>, as generated by build system in generated/xe_wa_oob.h
  */

drivers/gpu/drm/xe/xe_wa.h void xe_wa_apply_tile_workarounds(struct xe_tile *tile); · line 41

Quoted 10 lines
drivers/gpu/drm/xe/xe_wa.h +5 -0
 #define XE_WA(gt__, id__) ({						\
 	xe_gt_assert(gt__, (gt__)->wa_active.oob_initialized);		\
 	test_bit(XE_WA_OOB_ ## id__, (gt__)->wa_active.oob);		\
 })
 
+/**
+ * XE_DEVICE_WA - Out-of-band Device workarounds, that don't fit the lifecycle any
+ *         other more specific type
+ * @xe__: xe_device
+ * @id__: XE_SOC_WA_OOB_<id__>, as generated by build system in generated/xe_wa_oob.h

The "SOC" here is outdated. Also the wrong header is referenced.

drivers/gpu/drm/xe/xe_wa.h void xe_wa_apply_tile_workarounds(struct xe_tile *tile); · line 47

Quoted 6 lines
drivers/gpu/drm/xe/xe_wa.h +5 -0
+ */
+#define XE_DEVICE_WA(xe__, id__) ({					\
+	xe_assert(xe__, (xe__)->oob_initialized);			\
+	test_bit(XE_DEVICE_WA_OOB_ ## id__, (xe__)->oob);			\
+})
 #endif

This is probably fine short-term, but I think eventually we should just have a single XE_WA() call that _Generic()'s on its parameter to do the lookup in the proper place (gt or device). If we don't want to _Generic it for some reason, then the existing macro should probably get renamed to XE_GT_WA() to clarify its purpose.

Matt

Quoted 3 lines
Signature · 1 line
2.49.0
Signature · 4 lines
Matt Roper
Graphics Software Engineer
Linux GPU Platform Enablement
Intel Corporation
Signature · 4 lines
Matt Roper
Graphics Software Engineer
Linux GPU Platform Enablement
Intel Corporation
#5 lore raw

PATCH v3 3/5 drm/xe: Move Wa_15015404425 to use the new EX_DEVICE_WA macro

In reply to Matt Atwood

Move Wa_15015404425 to use the new implemented OOB macro XE_DEVICE_WA()

v2: rename from SoC to Device

---
 drivers/gpu/drm/xe/xe_device_wa_oob.rules |  1 +
 drivers/gpu/drm/xe/xe_mmio.c              | 10 +++++-----
 2 files changed, 6 insertions(+), 5 deletions(-)
drivers/gpu/drm/xe/xe_device_wa_oob.rules +1 -0
index e69de29bb2d1..b7d12ea4d65c 100644
@@ -0,0 +1 @@
+15015404425     PLATFORM(LUNARLAKE)
drivers/gpu/drm/xe/xe_mmio.c +5 -5
index 7357458bc0d2..4990b3a47afd 100644
@@ -22,6 +22,9 @@
 #include "xe_macros.h"
 #include "xe_sriov.h"
 #include "xe_trace.h"
+#include "xe_wa.h"
+
+#include "generated/xe_soc_wa_oob.h"
 
 static void tiles_fini(void *arg)
 {
@@ -163,9 +166,6 @@ static void mmio_flush_pending_writes(struct xe_mmio *mmio)
 #define DUMMY_REG_OFFSET	0x130030
 	int i;
 
-	if (mmio->tile->xe->info.platform != XE_LUNARLAKE)
-		return;
-
 	/* 4 dummy writes */
 	for (i = 0; i < 4; i++)
 		writel(0, mmio->regs + DUMMY_REG_OFFSET);
@@ -176,8 +176,8 @@ u8 xe_mmio_read8(struct xe_mmio *mmio, struct xe_reg reg)
 	u32 addr = xe_mmio_adjusted_addr(mmio, reg.addr);
 	u8 val;
 
-	/* Wa_15015404425 */
-	mmio_flush_pending_writes(mmio);
+	if (XE_DEVICE_WA(mmio->tile->xe, 15015404425))
+		mmio_flush_pending_writes(mmio);
 
 	val = readb(mmio->regs + addr);
 	trace_xe_reg_rw(mmio, false, addr, val, sizeof(val));
Signature · 1 line
2.49.0
#6 lore raw

Re: [PATCH v3 3/5] drm/xe: Move Wa_15015404425 to use the new EX_DEVICE_WA macro

Quoted 21 lines · Matt Atwood

Move Wa_15015404425 to use the new implemented OOB macro XE_DEVICE_WA()

v2: rename from SoC to Device

---
 drivers/gpu/drm/xe/xe_device_wa_oob.rules |  1 +
 drivers/gpu/drm/xe/xe_mmio.c              | 10 +++++-----
 2 files changed, 6 insertions(+), 5 deletions(-)
drivers/gpu/drm/xe/xe_device_wa_oob.rules +1 -0
index e69de29bb2d1..b7d12ea4d65c 100644
@@ -0,0 +1 @@
+15015404425     PLATFORM(LUNARLAKE)
drivers/gpu/drm/xe/xe_mmio.c +0 -0
index 7357458bc0d2..4990b3a47afd 100644

drivers/gpu/drm/xe/xe_mmio.c line 27

Quoted 6 lines
drivers/gpu/drm/xe/xe_mmio.c +3 -0
@@ -22,6 +22,9 @@
 #include "xe_macros.h"
 #include "xe_sriov.h"
 #include "xe_trace.h"
+#include "xe_wa.h"
+
+#include "generated/xe_soc_wa_oob.h"

Isn't this the wrong header name?

Quoted 14 lines
drivers/gpu/drm/xe/xe_mmio.c +0 -3
 static void tiles_fini(void *arg)
 {
@@ -163,9 +166,6 @@ static void mmio_flush_pending_writes(struct xe_mmio *mmio)
 #define DUMMY_REG_OFFSET	0x130030
 	int i;
 
-	if (mmio->tile->xe->info.platform != XE_LUNARLAKE)
-		return;
-
 	/* 4 dummy writes */
 	for (i = 0; i < 4; i++)
 		writel(0, mmio->regs + DUMMY_REG_OFFSET);

drivers/gpu/drm/xe/xe_mmio.c u8 xe_mmio_read8(struct xe_mmio *mmio, struct xe_reg reg) · line 180

Quoted 7 lines
drivers/gpu/drm/xe/xe_mmio.c +2 -2
@@ -176,8 +176,8 @@ u8 xe_mmio_read8(struct xe_mmio *mmio, struct xe_reg reg)
 	u32 addr = xe_mmio_adjusted_addr(mmio, reg.addr);
 	u8 val;
 
-	/* Wa_15015404425 */
-	mmio_flush_pending_writes(mmio);
+	if (XE_DEVICE_WA(mmio->tile->xe, 15015404425))
+		mmio_flush_pending_writes(mmio);

Moving the check out of the function to the callsite seems fine to me, but we need to do it at all the callsites, not just read8.

Also, you have a typo in the patch subject line (s/EX/XE/).

Matt

Quoted 6 lines
drivers/gpu/drm/xe/xe_mmio.c +0 -0
 	val = readb(mmio->regs + addr);
 	trace_xe_reg_rw(mmio, false, addr, val, sizeof(val));
Signature · 1 line
2.49.0
Signature · 4 lines
Matt Roper
Graphics Software Engineer
Linux GPU Platform Enablement
Intel Corporation
#7 lore raw

Re: [PATCH v3 3/5] drm/xe: Move Wa_15015404425 to use the new EX_DEVICE_WA macro

Quoted 22 lines · Matt Roper
Quoted 21 lines · Matt Atwood

Move Wa_15015404425 to use the new implemented OOB macro XE_DEVICE_WA()

v2: rename from SoC to Device

---
 drivers/gpu/drm/xe/xe_device_wa_oob.rules |  1 +
 drivers/gpu/drm/xe/xe_mmio.c              | 10 +++++-----
 2 files changed, 6 insertions(+), 5 deletions(-)
drivers/gpu/drm/xe/xe_device_wa_oob.rules +1 -0
index e69de29bb2d1..b7d12ea4d65c 100644
@@ -0,0 +1 @@
+15015404425     PLATFORM(LUNARLAKE)
drivers/gpu/drm/xe/xe_mmio.c +0 -0
index 7357458bc0d2..4990b3a47afd 100644
@@ -22,6 +22,9 @@
Quoted 8 lines

drivers/gpu/drm/xe/xe_mmio.c line 27

Quoted 6 lines
drivers/gpu/drm/xe/xe_mmio.c +3 -0
 #include "xe_macros.h"
 #include "xe_sriov.h"
 #include "xe_trace.h"
+#include "xe_wa.h"
+
+#include "generated/xe_soc_wa_oob.h"

Isn't this the wrong header name?

Yes

Quoted 43 lines
Quoted 15 lines
drivers/gpu/drm/xe/xe_mmio.c +0 -3
 static void tiles_fini(void *arg)
 {
@@ -163,9 +166,6 @@ static void mmio_flush_pending_writes(struct xe_mmio *mmio)
 #define DUMMY_REG_OFFSET	0x130030
 	int i;
 
-	if (mmio->tile->xe->info.platform != XE_LUNARLAKE)
-		return;
-
 	/* 4 dummy writes */
 	for (i = 0; i < 4; i++)
 		writel(0, mmio->regs + DUMMY_REG_OFFSET);

drivers/gpu/drm/xe/xe_mmio.c u8 xe_mmio_read8(struct xe_mmio *mmio, struct xe_reg reg) · line 180

Quoted 7 lines
drivers/gpu/drm/xe/xe_mmio.c +2 -2
@@ -176,8 +176,8 @@ u8 xe_mmio_read8(struct xe_mmio *mmio, struct xe_reg reg)
 	u32 addr = xe_mmio_adjusted_addr(mmio, reg.addr);
 	u8 val;
 
-	/* Wa_15015404425 */
-	mmio_flush_pending_writes(mmio);
+	if (XE_DEVICE_WA(mmio->tile->xe, 15015404425))
+		mmio_flush_pending_writes(mmio);

Moving the check out of the function to the callsite seems fine to me, but we need to do it at all the callsites, not just read8.

Also, you have a typo in the patch subject line (s/EX/XE/).

Matt

Quoted 6 lines
drivers/gpu/drm/xe/xe_mmio.c +0 -0
 	val = readb(mmio->regs + addr);
 	trace_xe_reg_rw(mmio, false, addr, val, sizeof(val));
Signature · 1 line
2.49.0
Signature · 4 lines
Matt Roper
Graphics Software Engineer
Linux GPU Platform Enablement
Intel Corporation
#8 lore raw

PATCH v3 4/5 drm/xe: extend Wa_15015404425 to apply to PTL

In reply to Matt Atwood

Wa_15015404425 needs to be applied to PTL A0 to B0, a subsequent patch will address the complexity required to do this. For now apply to PTL as a whole.

---
 drivers/gpu/drm/xe/xe_device_wa_oob.rules | 1 +
 1 file changed, 1 insertion(+)
drivers/gpu/drm/xe/xe_device_wa_oob.rules +1 -0
index b7d12ea4d65c..3a0c4ccc4224 100644
@@ -1 +1,2 @@
 15015404425     PLATFORM(LUNARLAKE)
+		PLATFORM(PANTHERLAKE)
Signature · 1 line
2.49.0
#9 lore raw

PATCH v3 5/5 drm/xe: disable wa_15015404425 for PTL B0

In reply to Matt Atwood

This workaround only applies to PTL Compute Die A0. The reality of modern platforms is we're Multi Chip Packages with logic spread across multiple dies. Because this information is not available during PCI probe it becomes a bit more complicated.

This workaround needs to be applied on PTL until we prove that we are not Compute Die A0 stepping without reading any MMIOs. So use the new XE_DEVICE_WA infrastructure to apply early, until we can determine our stepping.

There are at least two ways to determine Compute Die stepping. This patch uses the Media GT stepping to map to Compute Die stepping, in this case Compute and Media dies step synchronously.

Since we're using the Media GT information to determine Compute Die stepping, use the XE_WA and the oob infrastructure to come back and toggle the workaround off when we know its safe, and after GT init.

v2: rename SoC to device, avoid null pointer dereference, update commit message.
v3: rebase

---
 drivers/gpu/drm/xe/xe_pci.c        | 7 +++++++
 drivers/gpu/drm/xe/xe_wa_oob.rules | 2 ++
 2 files changed, 9 insertions(+)
drivers/gpu/drm/xe/xe_pci.c +7 -0
index a9f708608f3e..a294a1b26d8f 100644
@@ -34,6 +34,9 @@
 #include "xe_tile.h"
 #include "xe_wa.h"
 
+#include "generated/xe_wa_oob.h"
+#include "generated/xe_device_wa_oob.h"
+
 enum toggle_d3cold {
 	D3COLD_DISABLE,
 	D3COLD_ENABLE,
@@ -896,6 +899,10 @@ static int xe_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 	drm_dbg(&xe->drm, "d3cold: capable=%s\n",
 		str_yes_no(xe->d3cold.capable));
 
+	if (xe->tiles->media_gt != NULL &&
+	    XE_WA(xe->tiles->media_gt, 15015404425_disable))
+		xe->oob[XE_DEVICE_WA_OOB_15015404425] = 0;
+
 	return 0;
 
 err_driver_cleanup:
drivers/gpu/drm/xe/xe_wa_oob.rules +2 -0
index 96cc33da0fb5..255e67113406 100644
@@ -70,3 +70,5 @@ no_media_l3	MEDIA_VERSION(3000)
 # SoC workaround - currently applies to all platforms with the following
 # primary GT GMDID
 14022085890	GRAPHICS_VERSION(2001)
+
+15015404425_disable	PLATFORM(PANTHERLAKE), MEDIA_STEP(B0, FOREVER)
Signature · 1 line
2.49.0
#10 lore raw

Re: [PATCH v3 5/5] drm/xe: disable wa_15015404425 for PTL B0

Quoted 1 line · Matt Atwood

This workaround only applies to PTL Compute Die A0. The reality of

Nitpick: it would be better to just say "A-step" rather than A0 since that's what we're implementing. The workaround is documented as no longer being necessary from B0 onward, so "A-step" also covers any A1, A2, etc. steppings (which may or may not exist) and matches how the code is written.

Quoted 8 lines

modern platforms is we're Multi Chip Packages with logic spread across multiple dies. Because this information is not available during PCI probe it becomes a bit more complicated.

This workaround needs to be applied on PTL until we prove that we are not Compute Die A0 stepping without reading any MMIOs. So use the new XE_DEVICE_WA infrastructure to apply early, until we can determine our stepping.

It looks like you copied a lot of the text I wrote on an earlier review, which was just meant for general discussion, not a long-term record of the change. To be more clear to people reading the commit message and trying to understand this down the road, it might be better to elaborate a bit. Maybe something along the lines of:

Wa_15015404425 only needs to be applied on PTL platforms with an A-step compute die. There's no direct way to map the PCI revid into a compute die stepping, so the suggested way to figure this out is by inspecting the media IP's stepping since on PTL the media IP resides on the compute die. For PTL, the compute die has an A stepping if and only if the media IP is also A-step (this relationship isn't something guaranteed to always be true, but it works out this way on PTL).

Unfortunately there's a bit of a chicken-and-egg problem here; Wa_15015404425 requires that all register reads be preceded by four dummy MMIO writes (including during early driver init and even pre-OS firmware), but the driver needs to perform some MMIO reads (including the GMD_ID register that holds the media IP version) before we can determine the media stepping. To handle this safely, we need to just assume Wa_15015404425 always applies on PTL during the early parts of device probe, and then go back later and deactivate the workaround if we determine that we're running on a later stepping that doesn't require the workaround.

So we implement the overall solution as two workarounds in the driver:

* 15015404425 - a device OOB workaround that's always active on PTL
* 15015404425_disable - a GT OOB workaround that applies to PTL platforms with a B0 or later media stepping

The former workaround guards the extra dummy MMIO writes we do when reading registers, and the latter workaround guards logic that disables the former once we have the necessary information later in the probe process.

Quoted 34 lines

There are at least two ways to determine Compute Die stepping. This patch uses the Media GT stepping to map to Compute Die stepping, in this case Compute and Media dies step synchronously.

Since we're using the Media GT information to determine Compute Die stepping, use the XE_WA and the oob infrastructure to come back and toggle the workaround off when we know its safe, and after GT init.

v2: rename SoC to device, avoid null pointer dereference, update commit message.
v3: rebase

---
 drivers/gpu/drm/xe/xe_pci.c        | 7 +++++++
 drivers/gpu/drm/xe/xe_wa_oob.rules | 2 ++
 2 files changed, 9 insertions(+)
drivers/gpu/drm/xe/xe_pci.c +3 -0
index a9f708608f3e..a294a1b26d8f 100644
@@ -34,6 +34,9 @@
 #include "xe_tile.h"
 #include "xe_wa.h"
 
+#include "generated/xe_wa_oob.h"
+#include "generated/xe_device_wa_oob.h"
+
 enum toggle_d3cold {
 	D3COLD_DISABLE,
 	D3COLD_ENABLE,

drivers/gpu/drm/xe/xe_pci.c static int xe_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) · line 904

Quoted 6 lines
drivers/gpu/drm/xe/xe_pci.c +3 -0
@@ -896,6 +899,10 @@ static int xe_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 	drm_dbg(&xe->drm, "d3cold: capable=%s\n",
 		str_yes_no(xe->d3cold.capable));
 
+	if (xe->tiles->media_gt != NULL &&
+	    XE_WA(xe->tiles->media_gt, 15015404425_disable))
+		xe->oob[XE_DEVICE_WA_OOB_15015404425] = 0;

xe->oob is a bitmask; you're clobbering a whole word here which isn't what you want to do (and will probably go way past the end of the bitmask as well). We really shouldn't be mucking with the internals of the bitmask here anyway; we should have a documented interface from xe_rtp that allows a workaround to be disabled, and then use that here.

Also note that the condition here can also be simplified slightly if you use the suggestion below.

Quoted 9 lines
drivers/gpu/drm/xe/xe_pci.c +1 -0
+
 	return 0;
 
 err_driver_cleanup:
drivers/gpu/drm/xe/xe_wa_oob.rules +0 -0
index 96cc33da0fb5..255e67113406 100644

drivers/gpu/drm/xe/xe_wa_oob.rules no_media_l3 MEDIA_VERSION(3000) · line 74

Quoted 5 lines
drivers/gpu/drm/xe/xe_wa_oob.rules +2 -0
@@ -70,3 +70,5 @@ no_media_l3	MEDIA_VERSION(3000)
 # SoC workaround - currently applies to all platforms with the following
 # primary GT GMDID
 14022085890	GRAPHICS_VERSION(2001)
+
+15015404425_disable	PLATFORM(PANTHERLAKE), MEDIA_STEP(B0, FOREVER)

If you use MEDIA_VERSION_ANY_GT() here, then you could make this one a device workaround as well (since it wouldn't need any specific GT structures to lookup the media version, as long as we're past the point where the driver looked those up). It would also have the advantage of keeping both 15015404425 and 15015404425_disable together in the rules file. Note that if you do this, you'll need to adjust the suggested commit message text I wrote above accordingly.

Matt

Quoted 3 lines
Signature · 1 line
2.49.0
Signature · 4 lines
Matt Roper
Graphics Software Engineer
Linux GPU Platform Enablement
Intel Corporation
#11 lore raw

✗ CI.checkpatch: warning for drm/xe: Create and use XE_DEVICE_WA infrastructure (rev2)

In reply to Matt Atwood
== Series Details ==

== Series Details ==

Series: drm/xe: Create and use XE_DEVICE_WA infrastructure (rev2)
URL : https://patchwork.freedesktop.org/series/150777/
State : warning

== Summary ==

+ KERNEL=/kernel
+ git clone https://gitlab.freedesktop.org/drm/maintainer-tools mt Cloning into 'mt'...
warning: redirecting to https://gitlab.freedesktop.org/drm/maintainer-tools.git/
+ git -C mt rev-list -n1 origin/master f8ff75ae1d2127635239b134695774ed4045d05b
+ cd /kernel
+ git config --global --add safe.directory /kernel
+ git log -n1
commit 8745f5a69fcda58c554f9f0e5e5bdc29cc3cb12a

Author: Matt Atwood <[email protected]>
Date:   Wed Jun 25 12:33:40 2025 -0700

drm/xe: disable wa_15015404425 for PTL B0

This workaround only applies to PTL Compute Die A0. The reality of modern platforms is we're Multi Chip Packages with logic spread across multiple dies. Because this information is not available during PCI probe it becomes a bit more complicated.

This workaround needs to be applied on PTL until we prove that we are not Compute Die A0 stepping without reading any MMIOs. So use the new XE_DEVICE_WA infrastructure to apply early, until we can determine our stepping.

There are at least two ways to determine Compute Die stepping. This patch uses the Media GT stepping to map to Compute Die stepping, in this case Compute and Media dies step synchronously.

Since we're using the Media GT information to determine Compute Die stepping, use the XE_WA and the oob infrastructure to come back and toggle the workaround off when we know its safe, and after GT init.

v2: rename SoC to device, avoid null pointer dereference, update commit message.
v3: rebase

+ /mt/dim checkpatch 74f3ed8bab4e5ef51f1c266e8c7ffd1f2a052a73 drm-intel 22a4dc42eab7 drm/xe: add xe_device_wa infrastructure
-:42: WARNING:FILE_PATH_CHANGES: added, moved or deleted file(s), does MAINTAINERS need updating? #42:
new file mode 100644

-:73: CHECK:BOOL_COMPARISON: Using comparison to false is error prone #73: FILE: drivers/gpu/drm/xe/xe_gen_wa_oob.c:99:
+ if (device == false)

-:86: CHECK:BOOL_COMPARISON: Using comparison to false is error prone #86: FILE: drivers/gpu/drm/xe/xe_gen_wa_oob.c:123:
+ if (device == false)

-:99: WARNING:LINE_SPACING: Missing a blank line after declarations #99: FILE: drivers/gpu/drm/xe/xe_gen_wa_oob.c:166:
+ char *device = strstr(args[ARGS_CHEADER].fn, "device_");
+ if (device == NULL)

-:99: CHECK:COMPARISON_TO_NULL: Comparison to NULL could be written "!device" #99: FILE: drivers/gpu/drm/xe/xe_gen_wa_oob.c:166:
+ if (device == NULL)

-:104: CHECK:COMPARISON_TO_NULL: Comparison to NULL could be written "device" #104: FILE: drivers/gpu/drm/xe/xe_gen_wa_oob.c:171:
+ bool prefix = device != NULL ? true : false;

total: 0 errors, 2 warnings, 4 checks, 78 lines checked 347eaf10ed50 drm/xe: Add infrastructure for Device OOB workarounds -:83: WARNING:LONG_LINE: line length of 113 exceeds 100 columns #83: FILE: drivers/gpu/drm/xe/xe_rtp.h:425:
+ struct xe_gt * : (struct xe_rtp_process_ctx){ { (void *)(arg__) }, XE_RTP_PROCESS_TYPE_GT }, \

-:84: WARNING:LONG_LINE: line length of 111 exceeds 100 columns #84: FILE: drivers/gpu/drm/xe/xe_rtp.h:426:
+ struct xe_device * : (struct xe_rtp_process_ctx){ { (void *)(arg__) }, XE_RTP_PROCESS_TYPE_DEVICE })

-:222: CHECK:MACRO_ARG_REUSE: Macro argument reuse 'xe__' - possible side-effects? #222: FILE: drivers/gpu/drm/xe/xe_wa.h:43:
+#define XE_DEVICE_WA(xe__, id__) ({ \
+ xe_assert(xe__, (xe__)->oob_initialized); \
+ test_bit(XE_DEVICE_WA_OOB_ ## id__, (xe__)->oob); \
+})

total: 0 errors, 2 warnings, 1 checks, 171 lines checked
4fba0ac8b6b7 drm/xe: Move Wa_15015404425 to use the new EX_DEVICE_WA macro 88f6fc810099 drm/xe: extend Wa_15015404425 to apply to PTL
8745f5a69fcd drm/xe: disable wa_15015404425 for PTL B0
-:48: CHECK:COMPARISON_TO_NULL: Comparison to NULL could be written "xe->tiles->media_gt" #48: FILE: drivers/gpu/drm/xe/xe_pci.c:902:
+ if (xe->tiles->media_gt != NULL &&

total: 0 errors, 0 warnings, 1 checks, 24 lines checked

#12 lore raw

✗ CI.KUnit: failure for drm/xe: Create and use XE_DEVICE_WA infrastructure (rev2)

In reply to Matt Atwood
== Series Details ==

== Series Details ==

Series: drm/xe: Create and use XE_DEVICE_WA infrastructure (rev2)
URL : https://patchwork.freedesktop.org/series/150777/
State : failure

== Summary ==

+ trap cleanup EXIT
+ /kernel/tools/testing/kunit/kunit.py run --kunitconfig /kernel/drivers/gpu/drm/xe/.kunitconfig ERROR:root:../drivers/gpu/drm/xe/xe_mmio.c:27:10: fatal error: generated/xe_soc_wa_oob.h: No such file or directory 27 | #include "generated/xe_soc_wa_oob.h"

      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~

compilation terminated.
make[7]: *** [../scripts/Makefile.build:287: drivers/gpu/drm/xe/xe_mmio.o] Error 1 make[7]: *** Waiting for unfinished jobs....
make[6]: *** [../scripts/Makefile.build:554: drivers/gpu/drm/xe] Error 2 make[5]: *** [../scripts/Makefile.build:554: drivers/gpu/drm] Error 2 make[4]: *** [../scripts/Makefile.build:554: drivers/gpu] Error 2 make[3]: *** [../scripts/Makefile.build:554: drivers] Error 2 make[2]: *** [/kernel/Makefile:2003: .] Error 2
make[1]: *** [/kernel/Makefile:248: __sub-make] Error 2
make: *** [Makefile:248: __sub-make] Error 2

[19:39:02] Configuring KUnit Kernel ...
Generating .config ...
Populating config with:

$ make ARCH=um O=.kunit olddefconfig
[19:39:06] Building KUnit Kernel ...
Populating config with:
$ make ARCH=um O=.kunit olddefconfig
Building with:
$ make all compile_commands.json scripts_gdb ARCH=um O=.kunit --jobs=48
+ cleanup
++ stat -c %u:%g /kernel
+ chown -R 1003:1003 /kernel