All of lore.kernel.org
 help / color / mirror / Atom feed
* [Intel-xe] [PATCH v4 00/21] Dump + OOB workarounds
@ 2023-05-25 21:33 Lucas De Marchi
  2023-05-25 21:33 ` [Intel-xe] [PATCH v4 01/21] drm/xe: Fix Wa_22011802037 annotation Lucas De Marchi
                   ` (22 more replies)
  0 siblings, 23 replies; 44+ messages in thread
From: Lucas De Marchi @ 2023-05-25 21:33 UTC (permalink / raw)
  To: intel-xe; +Cc: Lucas De Marchi, Matt Roper

May the fourth be with the workarounds.
Fourth version of the OOB workarounds.

Previous version can be seen here:
https://lore.kernel.org/intel-xe/20230516221950.3512818-1-lucas.demarchi@intel.com/

Changes in v4:

  - All workarounds are now tracked per gt instead of per device. This
    helps supporting new platforms with different types of GTs

  - Split the last commit to be per (group of) workaround. Original
    intention was to just port the workarounds over to the new infra
    using the same conditions as was originally in the code. As
    demonstrated by v3 and the commits here, the conditions currently
    there can't be trusted much.

  - Add commit to fix build with M=drivers/gpu/drm/xe/ since it has a
    side-effect of not including the $(obj) in the include search path.

  - Properly convert Wa_14014475959 using IP versions. This is currently
    working for DG2, but I couldn't really test on MTL. We may want to
    postpone the last 2 commits to when xe is properly loading in MTL.

Using a DG2 platform for test:
	XE_DG2 G12 56b2:0001 dgfx:1 gfx:Xe_HPG (12.55) media:Xe_HPM (12.55) ...
	Stepping = (G:A1, M:A1, D:C0, B:**)

Output:
	# cat gt0/workarounds
	GT Workarounds
		14014830051
		14015795083
		18018781329
		1509235366
		14010648519

	Engine Workarounds
		14010826681, 1606700617, 22010271021, 18019627453
		22013037850
		22014226127
		18017747507
		14015227452
		16015675438
		16011620976, 22015475538
		1509727124
		22012856258
		22010960976, 14013347512
		1608949956, 14010198302

	LRC Workarounds
		16013271637
		14014947963
		18018764978
		15010599737
		18019271663

	OOB Workarounds
		14014475959
		22011391025
		14012197797
		16015675438
		18020744125

Eventually we may want to add a node in debugfs to consolidate the WAs
for all GTs, but that is not currently needed.

Lucas De Marchi (21):
  drm/xe: Fix Wa_22011802037 annotation
  drm/xe/rtp: Split rtp process initialization
  drm/xe/rtp: Replace XE_WARN_ON
  drm/xe/rtp: Add "_sr" to entry/function names
  drm/xe/rtp: Allow to track active workarounds
  drm/xe/wa: Track gt/engine/lrc active workarounds
  drm/xe/debugfs: Dump active workarounds
  drm/xe/rtp: Rename STEP to GRAPHICS_STEP
  drm/xe/rtp: Add check for media stepping
  drm/xe/rtp: Add support for entries with no action
  drm/xe: Include build directory
  drm/xe: Add support for OOB workarounds
  drm/xe/guc: Port Wa_22012773006 to xe_wa
  drm/xe/guc: Port Wa_16011759253 to xe_wa
  drm/xe/guc: Port Wa_14012197797/Wa_22011391025 to xe_wa
  drm/xe/guc: Port Wa_16011777198 to xe_wa
  drm/xe/guc: Port Wa_22012727170/Wa_22012727685 to xe_wa
  drm/xe/guc: Port Wa_16015675438/Wa_18020744125 to xe_wa
  drm/xe/guc: Port Wa_1509372804 to xe_wa
  drm/xe/rtp: Also check gt type
  drm/xe/guc: Port Wa_14014475959 to xe_wa and fix it

 drivers/gpu/drm/xe/Makefile            |  16 +-
 drivers/gpu/drm/xe/tests/xe_rtp_test.c |  23 +--
 drivers/gpu/drm/xe/xe_gen_wa_oob.c     | 164 ++++++++++++++++++++
 drivers/gpu/drm/xe/xe_gt.c             |   6 +
 drivers/gpu/drm/xe/xe_gt_debugfs.c     |  12 ++
 drivers/gpu/drm/xe/xe_gt_types.h       |  12 ++
 drivers/gpu/drm/xe/xe_guc.c            |  49 ++----
 drivers/gpu/drm/xe/xe_hw_engine.c      |  10 +-
 drivers/gpu/drm/xe/xe_reg_whitelist.c  |   6 +-
 drivers/gpu/drm/xe/xe_rtp.c            | 207 ++++++++++++++++++++-----
 drivers/gpu/drm/xe/xe_rtp.h            |  63 ++++++--
 drivers/gpu/drm/xe/xe_rtp_types.h      |  29 +++-
 drivers/gpu/drm/xe/xe_tuning.c         |  12 +-
 drivers/gpu/drm/xe/xe_wa.c             | 172 +++++++++++++++-----
 drivers/gpu/drm/xe/xe_wa.h             |  12 ++
 drivers/gpu/drm/xe/xe_wa_oob.rules     |  16 ++
 16 files changed, 662 insertions(+), 147 deletions(-)
 create mode 100644 drivers/gpu/drm/xe/xe_gen_wa_oob.c
 create mode 100644 drivers/gpu/drm/xe/xe_wa_oob.rules

-- 
2.40.1


^ permalink raw reply	[flat|nested] 44+ messages in thread

* [Intel-xe] [PATCH v4 01/21] drm/xe: Fix Wa_22011802037 annotation
  2023-05-25 21:33 [Intel-xe] [PATCH v4 00/21] Dump + OOB workarounds Lucas De Marchi
@ 2023-05-25 21:33 ` Lucas De Marchi
  2023-05-25 21:33 ` [Intel-xe] [PATCH v4 02/21] drm/xe/rtp: Split rtp process initialization Lucas De Marchi
                   ` (21 subsequent siblings)
  22 siblings, 0 replies; 44+ messages in thread
From: Lucas De Marchi @ 2023-05-25 21:33 UTC (permalink / raw)
  To: intel-xe; +Cc: Lucas De Marchi, Matt Roper

It was missing one digit, so not showing up as a proper WA number. Add
the missing number and annotate it with a FIXME as there are more to be
implemented to consider this WA done: ensure CS is stop before doing a
reset, wait for pending.

Also, this WA applies to platforms up to graphics version 1270 (with the
exception of MTL A*, that are not supported in xe). Fix platform check.

Link: https://gitlab.freedesktop.org/drm/xe/kernel/-/issues/284
Reviewed-by: Matt Roper <matthew.d.roper@intel.com>
Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
---
 drivers/gpu/drm/xe/xe_guc.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/xe/xe_guc.c b/drivers/gpu/drm/xe/xe_guc.c
index 71f18b32d09b..a8e249205bff 100644
--- a/drivers/gpu/drm/xe/xe_guc.c
+++ b/drivers/gpu/drm/xe/xe_guc.c
@@ -160,9 +160,11 @@ static u32 guc_ctl_wa_flags(struct xe_guc *guc)
 		flags |= GUC_WA_DUAL_QUEUE;
 
 	/*
-	 * Wa_2201180203
+	 * Wa_22011802037: FIXME - there's more to be done than simply setting
+	 * this flag: make sure each CS is stopped when preparing for GT reset
+	 * and wait for pending MI_FW.
 	 */
-	if (GRAPHICS_VER(xe) <= 12)
+	if (GRAPHICS_VERx100(xe) < 1270)
 		flags |= GUC_WA_PRE_PARSER;
 
 	/* Wa_16011777198 */
-- 
2.40.1


^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [Intel-xe] [PATCH v4 02/21] drm/xe/rtp: Split rtp process initialization
  2023-05-25 21:33 [Intel-xe] [PATCH v4 00/21] Dump + OOB workarounds Lucas De Marchi
  2023-05-25 21:33 ` [Intel-xe] [PATCH v4 01/21] drm/xe: Fix Wa_22011802037 annotation Lucas De Marchi
@ 2023-05-25 21:33 ` Lucas De Marchi
  2023-05-25 21:33 ` [Intel-xe] [PATCH v4 03/21] drm/xe/rtp: Replace XE_WARN_ON Lucas De Marchi
                   ` (20 subsequent siblings)
  22 siblings, 0 replies; 44+ messages in thread
From: Lucas De Marchi @ 2023-05-25 21:33 UTC (permalink / raw)
  To: intel-xe; +Cc: Lucas De Marchi, Matt Roper

The selection between hwe and gt is exposed to the outside of rtp, by
the xe_rtp_process() function. However it doesn't make seense from the
caller point of view to pass a hwe and a gt as argument since the gt
should always be the one containing the hwe.

This clarifies the interface by separating the context creation into an
initializer. The initializer then passes the correct value and there
should never be a case with hwe and gt set: when hwe is passed, the gt
is the one containing it. Internally the functions continue receiving
the argument separately.

v2: Leave the device-only context to a separate patch if they are indeed
    needed later

Reviewed-by: Matt Roper <matthew.d.roper@intel.com>
Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
---
 drivers/gpu/drm/xe/tests/xe_rtp_test.c |  3 +-
 drivers/gpu/drm/xe/xe_hw_engine.c      |  8 ++--
 drivers/gpu/drm/xe/xe_reg_whitelist.c  |  4 +-
 drivers/gpu/drm/xe/xe_rtp.c            | 63 +++++++++++++++++++-------
 drivers/gpu/drm/xe/xe_rtp.h            |  9 +++-
 drivers/gpu/drm/xe/xe_rtp_types.h      | 13 ++++++
 drivers/gpu/drm/xe/xe_tuning.c         |  8 +++-
 drivers/gpu/drm/xe/xe_wa.c             | 12 +++--
 8 files changed, 91 insertions(+), 29 deletions(-)

diff --git a/drivers/gpu/drm/xe/tests/xe_rtp_test.c b/drivers/gpu/drm/xe/tests/xe_rtp_test.c
index 4b2aac5ccf28..f96ef1987719 100644
--- a/drivers/gpu/drm/xe/tests/xe_rtp_test.c
+++ b/drivers/gpu/drm/xe/tests/xe_rtp_test.c
@@ -238,10 +238,11 @@ static void xe_rtp_process_tests(struct kunit *test)
 	struct xe_device *xe = test->priv;
 	struct xe_reg_sr *reg_sr = &xe->gt[0].reg_sr;
 	const struct xe_reg_sr_entry *sre, *sr_entry = NULL;
+	struct xe_rtp_process_ctx ctx = XE_RTP_PROCESS_CTX_INITIALIZER(&xe->gt[0]);
 	unsigned long idx, count = 0;
 
 	xe_reg_sr_init(reg_sr, "xe_rtp_tests", xe);
-	xe_rtp_process(param->entries, reg_sr, &xe->gt[0], NULL);
+	xe_rtp_process(&ctx, param->entries, reg_sr);
 
 	xa_for_each(&reg_sr->xa, idx, sre) {
 		if (idx == param->expected_reg.addr)
diff --git a/drivers/gpu/drm/xe/xe_hw_engine.c b/drivers/gpu/drm/xe/xe_hw_engine.c
index 71ac4defb947..25b96f40d5a7 100644
--- a/drivers/gpu/drm/xe/xe_hw_engine.c
+++ b/drivers/gpu/drm/xe/xe_hw_engine.c
@@ -281,6 +281,7 @@ xe_hw_engine_setup_default_lrc_state(struct xe_hw_engine *hwe)
 	const u8 mocs_read_idx = gt->mocs.uc_index;
 	u32 blit_cctl_val = REG_FIELD_PREP(BLIT_CCTL_DST_MOCS_MASK, mocs_write_idx) |
 			    REG_FIELD_PREP(BLIT_CCTL_SRC_MOCS_MASK, mocs_read_idx);
+	struct xe_rtp_process_ctx ctx = XE_RTP_PROCESS_CTX_INITIALIZER(hwe);
 	const struct xe_rtp_entry lrc_was[] = {
 		/*
 		 * Some blitter commands do not have a field for MOCS, those
@@ -299,7 +300,7 @@ xe_hw_engine_setup_default_lrc_state(struct xe_hw_engine *hwe)
 		{}
 	};
 
-	xe_rtp_process(lrc_was, &hwe->reg_lrc, gt, hwe);
+	xe_rtp_process(&ctx, lrc_was, &hwe->reg_lrc);
 }
 
 static void
@@ -311,7 +312,8 @@ hw_engine_setup_default_state(struct xe_hw_engine *hwe)
 	const u8 mocs_read_idx = gt->mocs.uc_index;
 	u32 ring_cmd_cctl_val = REG_FIELD_PREP(CMD_CCTL_WRITE_OVERRIDE_MASK, mocs_write_idx) |
 			        REG_FIELD_PREP(CMD_CCTL_READ_OVERRIDE_MASK, mocs_read_idx);
-	const struct xe_rtp_entry engine_was[] = {
+	struct xe_rtp_process_ctx ctx = XE_RTP_PROCESS_CTX_INITIALIZER(hwe);
+	const struct xe_rtp_entry engine_entries[] = {
 		/*
 		 * RING_CMD_CCTL specifies the default MOCS entry that will be
 		 * used by the command streamer when executing commands that
@@ -332,7 +334,7 @@ hw_engine_setup_default_state(struct xe_hw_engine *hwe)
 		{}
 	};
 
-	xe_rtp_process(engine_was, &hwe->reg_sr, gt, hwe);
+	xe_rtp_process(&ctx, engine_entries, &hwe->reg_sr);
 }
 
 static void hw_engine_init_early(struct xe_gt *gt, struct xe_hw_engine *hwe,
diff --git a/drivers/gpu/drm/xe/xe_reg_whitelist.c b/drivers/gpu/drm/xe/xe_reg_whitelist.c
index 7a2bb60ebd85..98f678d74445 100644
--- a/drivers/gpu/drm/xe/xe_reg_whitelist.c
+++ b/drivers/gpu/drm/xe/xe_reg_whitelist.c
@@ -63,7 +63,9 @@ static const struct xe_rtp_entry register_whitelist[] = {
  */
 void xe_reg_whitelist_process_engine(struct xe_hw_engine *hwe)
 {
-	xe_rtp_process(register_whitelist, &hwe->reg_whitelist, hwe->gt, hwe);
+	struct xe_rtp_process_ctx ctx = XE_RTP_PROCESS_CTX_INITIALIZER(hwe);
+
+	xe_rtp_process(&ctx, register_whitelist, &hwe->reg_whitelist);
 }
 
 /**
diff --git a/drivers/gpu/drm/xe/xe_rtp.c b/drivers/gpu/drm/xe/xe_rtp.c
index 0c6a23e14a71..5be25fe0e8e4 100644
--- a/drivers/gpu/drm/xe/xe_rtp.c
+++ b/drivers/gpu/drm/xe/xe_rtp.c
@@ -23,11 +23,11 @@
  * the values to the registers that have matching rules.
  */
 
-static bool rule_matches(struct xe_gt *gt,
+static bool rule_matches(const struct xe_device *xe,
+			 struct xe_gt *gt,
 			 struct xe_hw_engine *hwe,
 			 const struct xe_rtp_entry *entry)
 {
-	const struct xe_device *xe = gt_to_xe(gt);
 	const struct xe_rtp_rule *r;
 	unsigned int i;
 	bool match;
@@ -62,22 +62,27 @@ static bool rule_matches(struct xe_gt *gt,
 			match = xe->info.step.graphics >= r->step_start &&
 				xe->info.step.graphics < r->step_end;
 			break;
+		case XE_RTP_MATCH_INTEGRATED:
+			match = !xe->info.is_dgfx;
+			break;
+		case XE_RTP_MATCH_DISCRETE:
+			match = xe->info.is_dgfx;
+			break;
 		case XE_RTP_MATCH_ENGINE_CLASS:
+			if (drm_WARN_ON(&xe->drm, !hwe))
+				return false;
+
 			match = hwe->class == r->engine_class;
 			break;
 		case XE_RTP_MATCH_NOT_ENGINE_CLASS:
+			if (drm_WARN_ON(&xe->drm, !hwe))
+				return false;
+
 			match = hwe->class != r->engine_class;
 			break;
 		case XE_RTP_MATCH_FUNC:
 			match = r->match_func(gt, hwe);
 			break;
-		case XE_RTP_MATCH_INTEGRATED:
-			match = !xe->info.is_dgfx;
-			break;
-		case XE_RTP_MATCH_DISCRETE:
-			match = xe->info.is_dgfx;
-			break;
-
 		default:
 			XE_WARN_ON(r->match_type);
 		}
@@ -105,14 +110,15 @@ static void rtp_add_sr_entry(const struct xe_rtp_action *action,
 	xe_reg_sr_add(sr, &sr_entry);
 }
 
-static void rtp_process_one(const struct xe_rtp_entry *entry, struct xe_gt *gt,
+static void rtp_process_one(const struct xe_rtp_entry *entry,
+			    struct xe_device *xe, struct xe_gt *gt,
 			    struct xe_hw_engine *hwe, struct xe_reg_sr *sr)
 {
 	const struct xe_rtp_action *action;
 	u32 mmio_base;
 	unsigned int i;
 
-	if (!rule_matches(gt, hwe, entry))
+	if (!rule_matches(xe, gt, hwe, entry))
 		return;
 
 	for (action = &entry->actions[0]; i < entry->n_actions; action++, i++) {
@@ -126,23 +132,46 @@ static void rtp_process_one(const struct xe_rtp_entry *entry, struct xe_gt *gt,
 	}
 }
 
+static void rtp_get_context(struct xe_rtp_process_ctx *ctx,
+			    struct xe_hw_engine **hwe,
+			    struct xe_gt **gt,
+			    struct xe_device **xe)
+{
+	switch (ctx->type) {
+	case XE_RTP_PROCESS_TYPE_GT:
+		*hwe = NULL;
+		*gt = ctx->gt;
+		*xe = gt_to_xe(*gt);
+		break;
+	case XE_RTP_PROCESS_TYPE_ENGINE:
+		*hwe = ctx->hwe;
+		*gt = (*hwe)->gt;
+		*xe = gt_to_xe(*gt);
+		break;
+	};
+}
+
 /**
  * xe_rtp_process - Process all rtp @entries, adding the matching ones to @sr
+ * @ctx: The context for processing the table, with one of device, gt or hwe
  * @entries: Table with RTP definitions
  * @sr: Where to add an entry to with the values for matching. This can be
  *      viewed as the "coalesced view" of multiple the tables. The bits for each
  *      register set are expected not to collide with previously added entries
- * @gt: The GT to be used for matching rules
- * @hwe: Engine instance to use for matching rules and as mmio base
  *
  * Walk the table pointed by @entries (with an empty sentinel) and add all
  * entries with matching rules to @sr. If @hwe is not NULL, its mmio_base is
  * used to calculate the right register offset
  */
-void xe_rtp_process(const struct xe_rtp_entry *entries, struct xe_reg_sr *sr,
-		    struct xe_gt *gt, struct xe_hw_engine *hwe)
+void xe_rtp_process(struct xe_rtp_process_ctx *ctx,
+		    const struct xe_rtp_entry *entries, struct xe_reg_sr *sr)
 {
 	const struct xe_rtp_entry *entry;
+	struct xe_hw_engine *hwe = NULL;
+	struct xe_gt *gt = NULL;
+	struct xe_device *xe = NULL;
+
+	rtp_get_context(ctx, &hwe, &gt, &xe);
 
 	for (entry = entries; entry && entry->name; entry++) {
 		if (entry->flags & XE_RTP_ENTRY_FLAG_FOREACH_ENGINE) {
@@ -150,9 +179,9 @@ void xe_rtp_process(const struct xe_rtp_entry *entries, struct xe_reg_sr *sr,
 			enum xe_hw_engine_id id;
 
 			for_each_hw_engine(each_hwe, gt, id)
-				rtp_process_one(entry, gt, each_hwe, sr);
+				rtp_process_one(entry, xe, gt, each_hwe, sr);
 		} else {
-			rtp_process_one(entry, gt, hwe, sr);
+			rtp_process_one(entry, xe, gt, hwe, sr);
 		}
 	}
 }
diff --git a/drivers/gpu/drm/xe/xe_rtp.h b/drivers/gpu/drm/xe/xe_rtp.h
index 8a89ad45589a..c4b718b9632e 100644
--- a/drivers/gpu/drm/xe/xe_rtp.h
+++ b/drivers/gpu/drm/xe/xe_rtp.h
@@ -355,8 +355,13 @@ struct xe_reg_sr;
 		XE_RTP_PASTE_FOREACH(ACTION_, COMMA, (__VA_ARGS__))	\
 	}
 
-void xe_rtp_process(const struct xe_rtp_entry *entries, struct xe_reg_sr *sr,
-		    struct xe_gt *gt, struct xe_hw_engine *hwe);
+#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 })
+
+void xe_rtp_process(struct xe_rtp_process_ctx *ctx,
+		    const struct xe_rtp_entry *entries,
+		    struct xe_reg_sr *sr);
 
 /* Match functions to be used with XE_RTP_MATCH_FUNC */
 
diff --git a/drivers/gpu/drm/xe/xe_rtp_types.h b/drivers/gpu/drm/xe/xe_rtp_types.h
index 12df8a9e9c45..5afacbd9083d 100644
--- a/drivers/gpu/drm/xe/xe_rtp_types.h
+++ b/drivers/gpu/drm/xe/xe_rtp_types.h
@@ -95,4 +95,17 @@ struct xe_rtp_entry {
 	u8 flags;
 };
 
+enum xe_rtp_process_type {
+	XE_RTP_PROCESS_TYPE_GT,
+	XE_RTP_PROCESS_TYPE_ENGINE,
+};
+
+struct xe_rtp_process_ctx {
+	union {
+		struct xe_gt *gt;
+		struct xe_hw_engine *hwe;
+	};
+	enum xe_rtp_process_type type;
+};
+
 #endif
diff --git a/drivers/gpu/drm/xe/xe_tuning.c b/drivers/gpu/drm/xe/xe_tuning.c
index 5fc6a408429b..c2810ede3a65 100644
--- a/drivers/gpu/drm/xe/xe_tuning.c
+++ b/drivers/gpu/drm/xe/xe_tuning.c
@@ -59,7 +59,9 @@ static const struct xe_rtp_entry lrc_tunings[] = {
 
 void xe_tuning_process_gt(struct xe_gt *gt)
 {
-	xe_rtp_process(gt_tunings, &gt->reg_sr, gt, NULL);
+	struct xe_rtp_process_ctx ctx = XE_RTP_PROCESS_CTX_INITIALIZER(gt);
+
+	xe_rtp_process(&ctx, gt_tunings, &gt->reg_sr);
 }
 EXPORT_SYMBOL_IF_KUNIT(xe_tuning_process_gt);
 
@@ -73,5 +75,7 @@ EXPORT_SYMBOL_IF_KUNIT(xe_tuning_process_gt);
  */
 void xe_tuning_process_lrc(struct xe_hw_engine *hwe)
 {
-	xe_rtp_process(lrc_tunings, &hwe->reg_lrc, hwe->gt, hwe);
+	struct xe_rtp_process_ctx ctx = XE_RTP_PROCESS_CTX_INITIALIZER(hwe);
+
+	xe_rtp_process(&ctx, lrc_tunings, &hwe->reg_lrc);
 }
diff --git a/drivers/gpu/drm/xe/xe_wa.c b/drivers/gpu/drm/xe/xe_wa.c
index b0bb2f4438f4..4b236b6f4c8e 100644
--- a/drivers/gpu/drm/xe/xe_wa.c
+++ b/drivers/gpu/drm/xe/xe_wa.c
@@ -579,7 +579,9 @@ __diag_pop();
  */
 void xe_wa_process_gt(struct xe_gt *gt)
 {
-	xe_rtp_process(gt_was, &gt->reg_sr, gt, NULL);
+	struct xe_rtp_process_ctx ctx = XE_RTP_PROCESS_CTX_INITIALIZER(gt);
+
+	xe_rtp_process(&ctx, gt_was, &gt->reg_sr);
 }
 EXPORT_SYMBOL_IF_KUNIT(xe_wa_process_gt);
 
@@ -593,7 +595,9 @@ EXPORT_SYMBOL_IF_KUNIT(xe_wa_process_gt);
  */
 void xe_wa_process_engine(struct xe_hw_engine *hwe)
 {
-	xe_rtp_process(engine_was, &hwe->reg_sr, hwe->gt, hwe);
+	struct xe_rtp_process_ctx ctx = XE_RTP_PROCESS_CTX_INITIALIZER(hwe);
+
+	xe_rtp_process(&ctx, engine_was, &hwe->reg_sr);
 }
 
 /**
@@ -606,5 +610,7 @@ void xe_wa_process_engine(struct xe_hw_engine *hwe)
  */
 void xe_wa_process_lrc(struct xe_hw_engine *hwe)
 {
-	xe_rtp_process(lrc_was, &hwe->reg_lrc, hwe->gt, hwe);
+	struct xe_rtp_process_ctx ctx = XE_RTP_PROCESS_CTX_INITIALIZER(hwe);
+
+	xe_rtp_process(&ctx, lrc_was, &hwe->reg_lrc);
 }
-- 
2.40.1


^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [Intel-xe] [PATCH v4 03/21] drm/xe/rtp: Replace XE_WARN_ON
  2023-05-25 21:33 [Intel-xe] [PATCH v4 00/21] Dump + OOB workarounds Lucas De Marchi
  2023-05-25 21:33 ` [Intel-xe] [PATCH v4 01/21] drm/xe: Fix Wa_22011802037 annotation Lucas De Marchi
  2023-05-25 21:33 ` [Intel-xe] [PATCH v4 02/21] drm/xe/rtp: Split rtp process initialization Lucas De Marchi
@ 2023-05-25 21:33 ` Lucas De Marchi
  2023-05-25 22:18   ` Matt Roper
  2023-05-25 21:33 ` [Intel-xe] [PATCH v4 04/21] drm/xe/rtp: Add "_sr" to entry/function names Lucas De Marchi
                   ` (19 subsequent siblings)
  22 siblings, 1 reply; 44+ messages in thread
From: Lucas De Marchi @ 2023-05-25 21:33 UTC (permalink / raw)
  To: intel-xe; +Cc: Lucas De Marchi, Matt Roper

Now that rule_matches() always has an xe pointer, replace the XE_WARN_ON
with the more appropriate drm_warn().

Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
---
 drivers/gpu/drm/xe/xe_rtp.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/xe/xe_rtp.c b/drivers/gpu/drm/xe/xe_rtp.c
index 5be25fe0e8e4..5dcdfe45f0cb 100644
--- a/drivers/gpu/drm/xe/xe_rtp.c
+++ b/drivers/gpu/drm/xe/xe_rtp.c
@@ -84,7 +84,9 @@ static bool rule_matches(const struct xe_device *xe,
 			match = r->match_func(gt, hwe);
 			break;
 		default:
-			XE_WARN_ON(r->match_type);
+			drm_warn(&xe->drm, "Invalid RTP match %u\n",
+				 r->match_type);
+			match = false;
 		}
 
 		if (!match)
-- 
2.40.1


^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [Intel-xe] [PATCH v4 04/21] drm/xe/rtp: Add "_sr" to entry/function names
  2023-05-25 21:33 [Intel-xe] [PATCH v4 00/21] Dump + OOB workarounds Lucas De Marchi
                   ` (2 preceding siblings ...)
  2023-05-25 21:33 ` [Intel-xe] [PATCH v4 03/21] drm/xe/rtp: Replace XE_WARN_ON Lucas De Marchi
@ 2023-05-25 21:33 ` Lucas De Marchi
  2023-05-25 21:33 ` [Intel-xe] [PATCH v4 05/21] drm/xe/rtp: Allow to track active workarounds Lucas De Marchi
                   ` (18 subsequent siblings)
  22 siblings, 0 replies; 44+ messages in thread
From: Lucas De Marchi @ 2023-05-25 21:33 UTC (permalink / raw)
  To: intel-xe; +Cc: Lucas De Marchi, Matt Roper

The xe_rtp_process() function and xe_rtp_entry depend on the
save-restore struct. In future it will be desired to process rtp rules,
regardless of adding them to a save-restore. Rename the struct and
function so the intent is clear and the name is freed for future uses.

Reviewed-by: Matt Roper <matthew.d.roper@intel.com>
Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
---
 drivers/gpu/drm/xe/tests/xe_rtp_test.c | 22 +++++++++++-----------
 drivers/gpu/drm/xe/xe_hw_engine.c      |  8 ++++----
 drivers/gpu/drm/xe/xe_reg_whitelist.c  |  4 ++--
 drivers/gpu/drm/xe/xe_rtp.c            | 26 ++++++++++++++------------
 drivers/gpu/drm/xe/xe_rtp.h            | 20 ++++++++++----------
 drivers/gpu/drm/xe/xe_rtp_types.h      |  4 ++--
 drivers/gpu/drm/xe/xe_tuning.c         |  8 ++++----
 drivers/gpu/drm/xe/xe_wa.c             | 12 ++++++------
 8 files changed, 53 insertions(+), 51 deletions(-)

diff --git a/drivers/gpu/drm/xe/tests/xe_rtp_test.c b/drivers/gpu/drm/xe/tests/xe_rtp_test.c
index f96ef1987719..ab6f7a47db50 100644
--- a/drivers/gpu/drm/xe/tests/xe_rtp_test.c
+++ b/drivers/gpu/drm/xe/tests/xe_rtp_test.c
@@ -36,7 +36,7 @@ struct rtp_test_case {
 	u32 expected_clr_bits;
 	unsigned long expected_count;
 	unsigned int expected_sr_errors;
-	const struct xe_rtp_entry *entries;
+	const struct xe_rtp_entry_sr *entries;
 };
 
 static bool match_yes(const struct xe_gt *gt, const struct xe_hw_engine *hwe)
@@ -57,7 +57,7 @@ static const struct rtp_test_case cases[] = {
 		.expected_clr_bits = REG_BIT(0) | REG_BIT(1),
 		.expected_count = 1,
 		/* Different bits on the same register: create a single entry */
-		.entries = (const struct xe_rtp_entry[]) {
+		.entries = (const struct xe_rtp_entry_sr[]) {
 			{ XE_RTP_NAME("basic-1"),
 			  XE_RTP_RULES(FUNC(match_yes)),
 			  XE_RTP_ACTIONS(SET(REGULAR_REG1, REG_BIT(0)))
@@ -76,7 +76,7 @@ static const struct rtp_test_case cases[] = {
 		.expected_clr_bits = REG_BIT(0),
 		.expected_count = 1,
 		/* Don't coalesce second entry since rules don't match */
-		.entries = (const struct xe_rtp_entry[]) {
+		.entries = (const struct xe_rtp_entry_sr[]) {
 			{ XE_RTP_NAME("basic-1"),
 			  XE_RTP_RULES(FUNC(match_yes)),
 			  XE_RTP_ACTIONS(SET(REGULAR_REG1, REG_BIT(0)))
@@ -95,7 +95,7 @@ static const struct rtp_test_case cases[] = {
 		.expected_clr_bits = REG_BIT(0),
 		.expected_count = 1,
 		/* Don't coalesce second entry due to one of the rules */
-		.entries = (const struct xe_rtp_entry[]) {
+		.entries = (const struct xe_rtp_entry_sr[]) {
 			{ XE_RTP_NAME("basic-1"),
 			  XE_RTP_RULES(FUNC(match_yes)),
 			  XE_RTP_ACTIONS(SET(REGULAR_REG1, REG_BIT(0)))
@@ -114,7 +114,7 @@ static const struct rtp_test_case cases[] = {
 		.expected_clr_bits = REG_BIT(0),
 		.expected_count = 2,
 		/* Same bits on different registers are not coalesced */
-		.entries = (const struct xe_rtp_entry[]) {
+		.entries = (const struct xe_rtp_entry_sr[]) {
 			{ XE_RTP_NAME("basic-1"),
 			  XE_RTP_RULES(FUNC(match_yes)),
 			  XE_RTP_ACTIONS(SET(REGULAR_REG1, REG_BIT(0)))
@@ -133,7 +133,7 @@ static const struct rtp_test_case cases[] = {
 		.expected_clr_bits = REG_BIT(1) | REG_BIT(0),
 		.expected_count = 1,
 		/* Check clr vs set actions on different bits */
-		.entries = (const struct xe_rtp_entry[]) {
+		.entries = (const struct xe_rtp_entry_sr[]) {
 			{ XE_RTP_NAME("basic-1"),
 			  XE_RTP_RULES(FUNC(match_yes)),
 			  XE_RTP_ACTIONS(SET(REGULAR_REG1, REG_BIT(0)))
@@ -154,7 +154,7 @@ static const struct rtp_test_case cases[] = {
 		.expected_clr_bits = TEMP_MASK,
 		.expected_count = 1,
 		/* Check FIELD_SET works */
-		.entries = (const struct xe_rtp_entry[]) {
+		.entries = (const struct xe_rtp_entry_sr[]) {
 			{ XE_RTP_NAME("basic-1"),
 			  XE_RTP_RULES(FUNC(match_yes)),
 			  XE_RTP_ACTIONS(FIELD_SET(REGULAR_REG1,
@@ -172,7 +172,7 @@ static const struct rtp_test_case cases[] = {
 		.expected_clr_bits = REG_BIT(0),
 		.expected_count = 1,
 		.expected_sr_errors = 1,
-		.entries = (const struct xe_rtp_entry[]) {
+		.entries = (const struct xe_rtp_entry_sr[]) {
 			{ XE_RTP_NAME("basic-1"),
 			  XE_RTP_RULES(FUNC(match_yes)),
 			  XE_RTP_ACTIONS(SET(REGULAR_REG1, REG_BIT(0)))
@@ -192,7 +192,7 @@ static const struct rtp_test_case cases[] = {
 		.expected_clr_bits = REG_BIT(0),
 		.expected_count = 1,
 		.expected_sr_errors = 1,
-		.entries = (const struct xe_rtp_entry[]) {
+		.entries = (const struct xe_rtp_entry_sr[]) {
 			{ XE_RTP_NAME("basic-1"),
 			  XE_RTP_RULES(FUNC(match_yes)),
 			  XE_RTP_ACTIONS(SET(REGULAR_REG1, REG_BIT(0)))
@@ -212,7 +212,7 @@ static const struct rtp_test_case cases[] = {
 		.expected_clr_bits = REG_BIT(0),
 		.expected_count = 1,
 		.expected_sr_errors = 2,
-		.entries = (const struct xe_rtp_entry[]) {
+		.entries = (const struct xe_rtp_entry_sr[]) {
 			{ XE_RTP_NAME("basic-1"),
 			  XE_RTP_RULES(FUNC(match_yes)),
 			  XE_RTP_ACTIONS(SET(REGULAR_REG1, REG_BIT(0)))
@@ -242,7 +242,7 @@ static void xe_rtp_process_tests(struct kunit *test)
 	unsigned long idx, count = 0;
 
 	xe_reg_sr_init(reg_sr, "xe_rtp_tests", xe);
-	xe_rtp_process(&ctx, param->entries, reg_sr);
+	xe_rtp_process_to_sr(&ctx, param->entries, reg_sr);
 
 	xa_for_each(&reg_sr->xa, idx, sre) {
 		if (idx == param->expected_reg.addr)
diff --git a/drivers/gpu/drm/xe/xe_hw_engine.c b/drivers/gpu/drm/xe/xe_hw_engine.c
index 25b96f40d5a7..7e4b0b465244 100644
--- a/drivers/gpu/drm/xe/xe_hw_engine.c
+++ b/drivers/gpu/drm/xe/xe_hw_engine.c
@@ -282,7 +282,7 @@ xe_hw_engine_setup_default_lrc_state(struct xe_hw_engine *hwe)
 	u32 blit_cctl_val = REG_FIELD_PREP(BLIT_CCTL_DST_MOCS_MASK, mocs_write_idx) |
 			    REG_FIELD_PREP(BLIT_CCTL_SRC_MOCS_MASK, mocs_read_idx);
 	struct xe_rtp_process_ctx ctx = XE_RTP_PROCESS_CTX_INITIALIZER(hwe);
-	const struct xe_rtp_entry lrc_was[] = {
+	const struct xe_rtp_entry_sr lrc_was[] = {
 		/*
 		 * Some blitter commands do not have a field for MOCS, those
 		 * commands will use MOCS index pointed by BLIT_CCTL.
@@ -300,7 +300,7 @@ xe_hw_engine_setup_default_lrc_state(struct xe_hw_engine *hwe)
 		{}
 	};
 
-	xe_rtp_process(&ctx, lrc_was, &hwe->reg_lrc);
+	xe_rtp_process_to_sr(&ctx, lrc_was, &hwe->reg_lrc);
 }
 
 static void
@@ -313,7 +313,7 @@ hw_engine_setup_default_state(struct xe_hw_engine *hwe)
 	u32 ring_cmd_cctl_val = REG_FIELD_PREP(CMD_CCTL_WRITE_OVERRIDE_MASK, mocs_write_idx) |
 			        REG_FIELD_PREP(CMD_CCTL_READ_OVERRIDE_MASK, mocs_read_idx);
 	struct xe_rtp_process_ctx ctx = XE_RTP_PROCESS_CTX_INITIALIZER(hwe);
-	const struct xe_rtp_entry engine_entries[] = {
+	const struct xe_rtp_entry_sr engine_entries[] = {
 		/*
 		 * RING_CMD_CCTL specifies the default MOCS entry that will be
 		 * used by the command streamer when executing commands that
@@ -334,7 +334,7 @@ hw_engine_setup_default_state(struct xe_hw_engine *hwe)
 		{}
 	};
 
-	xe_rtp_process(&ctx, engine_entries, &hwe->reg_sr);
+	xe_rtp_process_to_sr(&ctx, engine_entries, &hwe->reg_sr);
 }
 
 static void hw_engine_init_early(struct xe_gt *gt, struct xe_hw_engine *hwe,
diff --git a/drivers/gpu/drm/xe/xe_reg_whitelist.c b/drivers/gpu/drm/xe/xe_reg_whitelist.c
index 98f678d74445..70892f134718 100644
--- a/drivers/gpu/drm/xe/xe_reg_whitelist.c
+++ b/drivers/gpu/drm/xe/xe_reg_whitelist.c
@@ -20,7 +20,7 @@ static bool match_not_render(const struct xe_gt *gt,
 	return hwe->class != XE_ENGINE_CLASS_RENDER;
 }
 
-static const struct xe_rtp_entry register_whitelist[] = {
+static const struct xe_rtp_entry_sr register_whitelist[] = {
 	{ XE_RTP_NAME("WaAllowPMDepthAndInvocationCountAccessFromUMD, 1408556865"),
 	  XE_RTP_RULES(GRAPHICS_VERSION_RANGE(1200, 1210), ENGINE_CLASS(RENDER)),
 	  XE_RTP_ACTIONS(WHITELIST(PS_INVOCATION_COUNT,
@@ -65,7 +65,7 @@ void xe_reg_whitelist_process_engine(struct xe_hw_engine *hwe)
 {
 	struct xe_rtp_process_ctx ctx = XE_RTP_PROCESS_CTX_INITIALIZER(hwe);
 
-	xe_rtp_process(&ctx, register_whitelist, &hwe->reg_whitelist);
+	xe_rtp_process_to_sr(&ctx, register_whitelist, &hwe->reg_whitelist);
 }
 
 /**
diff --git a/drivers/gpu/drm/xe/xe_rtp.c b/drivers/gpu/drm/xe/xe_rtp.c
index 5dcdfe45f0cb..0be1f4cfc4d5 100644
--- a/drivers/gpu/drm/xe/xe_rtp.c
+++ b/drivers/gpu/drm/xe/xe_rtp.c
@@ -26,7 +26,7 @@
 static bool rule_matches(const struct xe_device *xe,
 			 struct xe_gt *gt,
 			 struct xe_hw_engine *hwe,
-			 const struct xe_rtp_entry *entry)
+			 const struct xe_rtp_entry_sr *entry)
 {
 	const struct xe_rtp_rule *r;
 	unsigned int i;
@@ -112,9 +112,9 @@ static void rtp_add_sr_entry(const struct xe_rtp_action *action,
 	xe_reg_sr_add(sr, &sr_entry);
 }
 
-static void rtp_process_one(const struct xe_rtp_entry *entry,
-			    struct xe_device *xe, struct xe_gt *gt,
-			    struct xe_hw_engine *hwe, struct xe_reg_sr *sr)
+static void rtp_process_one_sr(const struct xe_rtp_entry_sr *entry,
+			       struct xe_device *xe, struct xe_gt *gt,
+			       struct xe_hw_engine *hwe, struct xe_reg_sr *sr)
 {
 	const struct xe_rtp_action *action;
 	u32 mmio_base;
@@ -154,10 +154,11 @@ static void rtp_get_context(struct xe_rtp_process_ctx *ctx,
 }
 
 /**
- * xe_rtp_process - Process all rtp @entries, adding the matching ones to @sr
+ * xe_rtp_process_to_sr - Process all rtp @entries, adding the matching ones to
+ *                        the save-restore argument.
  * @ctx: The context for processing the table, with one of device, gt or hwe
  * @entries: Table with RTP definitions
- * @sr: Where to add an entry to with the values for matching. This can be
+ * @sr: Save-restore struct where matching rules execute the action. This can be
  *      viewed as the "coalesced view" of multiple the tables. The bits for each
  *      register set are expected not to collide with previously added entries
  *
@@ -165,10 +166,11 @@ static void rtp_get_context(struct xe_rtp_process_ctx *ctx,
  * entries with matching rules to @sr. If @hwe is not NULL, its mmio_base is
  * used to calculate the right register offset
  */
-void xe_rtp_process(struct xe_rtp_process_ctx *ctx,
-		    const struct xe_rtp_entry *entries, struct xe_reg_sr *sr)
+void xe_rtp_process_to_sr(struct xe_rtp_process_ctx *ctx,
+			  const struct xe_rtp_entry_sr *entries,
+			  struct xe_reg_sr *sr)
 {
-	const struct xe_rtp_entry *entry;
+	const struct xe_rtp_entry_sr *entry;
 	struct xe_hw_engine *hwe = NULL;
 	struct xe_gt *gt = NULL;
 	struct xe_device *xe = NULL;
@@ -181,13 +183,13 @@ void xe_rtp_process(struct xe_rtp_process_ctx *ctx,
 			enum xe_hw_engine_id id;
 
 			for_each_hw_engine(each_hwe, gt, id)
-				rtp_process_one(entry, xe, gt, each_hwe, sr);
+				rtp_process_one_sr(entry, xe, gt, each_hwe, sr);
 		} else {
-			rtp_process_one(entry, xe, gt, hwe, sr);
+			rtp_process_one_sr(entry, xe, gt, hwe, sr);
 		}
 	}
 }
-EXPORT_SYMBOL_IF_KUNIT(xe_rtp_process);
+EXPORT_SYMBOL_IF_KUNIT(xe_rtp_process_to_sr);
 
 bool xe_rtp_match_even_instance(const struct xe_gt *gt,
 				const struct xe_hw_engine *hwe)
diff --git a/drivers/gpu/drm/xe/xe_rtp.h b/drivers/gpu/drm/xe/xe_rtp.h
index c4b718b9632e..179b497186d2 100644
--- a/drivers/gpu/drm/xe/xe_rtp.h
+++ b/drivers/gpu/drm/xe/xe_rtp.h
@@ -261,7 +261,7 @@ struct xe_reg_sr;
 #define XE_RTP_NAME(s_)	.name = (s_)
 
 /**
- * XE_RTP_ENTRY_FLAG - Helper to add multiple flags to a struct xe_rtp_entry
+ * XE_RTP_ENTRY_FLAG - Helper to add multiple flags to a struct xe_rtp_entry_sr
  * @...: Entry flags, without the ``XE_RTP_ENTRY_FLAG_`` prefix
  *
  * Helper to automatically add a ``XE_RTP_ENTRY_FLAG_`` prefix to the flags
@@ -269,7 +269,7 @@ struct xe_reg_sr;
  *
  * .. code-block:: c
  *
- *	const struct xe_rtp_entry wa_entries[] = {
+ *	const struct xe_rtp_entry_sr wa_entries[] = {
  *		...
  *		{ XE_RTP_NAME("test-entry"),
  *		  ...
@@ -291,7 +291,7 @@ struct xe_reg_sr;
  *
  * .. code-block:: c
  *
- *	const struct xe_rtp_entry wa_entries[] = {
+ *	const struct xe_rtp_entry_sr wa_entries[] = {
  *		...
  *		{ XE_RTP_NAME("test-entry"),
  *		  ...
@@ -305,7 +305,7 @@ struct xe_reg_sr;
 	.flags = (XE_RTP_PASTE_FOREACH(ACTION_FLAG_, BITWISE_OR, (__VA_ARGS__)))
 
 /**
- * XE_RTP_RULES - Helper to set multiple rules to a struct xe_rtp_entry entry
+ * XE_RTP_RULES - Helper to set multiple rules to a struct xe_rtp_entry_sr entry
  * @...: Rules
  *
  * At least one rule is needed and up to 4 are supported. Multiple rules are
@@ -314,7 +314,7 @@ struct xe_reg_sr;
  *
  * .. code-block:: c
  *
- *	const struct xe_rtp_entry wa_entries[] = {
+ *	const struct xe_rtp_entry_sr wa_entries[] = {
  *		...
  *		{ XE_RTP_NAME("test-entry"),
  *		  XE_RTP_RULES(SUBPLATFORM(DG2, G10), STEP(A0, B0)),
@@ -330,7 +330,7 @@ struct xe_reg_sr;
 	}
 
 /**
- * XE_RTP_ACTIONS - Helper to set multiple actions to a struct xe_rtp_entry
+ * XE_RTP_ACTIONS - Helper to set multiple actions to a struct xe_rtp_entry_sr
  * @...: Actions to be taken
  *
  * At least one rule is needed and up to 4 are supported. Multiple rules are
@@ -339,7 +339,7 @@ struct xe_reg_sr;
  *
  * .. code-block:: c
  *
- *	const struct xe_rtp_entry wa_entries[] = {
+ *	const struct xe_rtp_entry_sr wa_entries[] = {
  *		...
  *		{ XE_RTP_NAME("test-entry"),
  *		  XE_RTP_RULES(...),
@@ -359,9 +359,9 @@ struct xe_reg_sr;
 	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 })
 
-void xe_rtp_process(struct xe_rtp_process_ctx *ctx,
-		    const struct xe_rtp_entry *entries,
-		    struct xe_reg_sr *sr);
+void xe_rtp_process_to_sr(struct xe_rtp_process_ctx *ctx,
+			  const struct xe_rtp_entry_sr *entries,
+			  struct xe_reg_sr *sr);
 
 /* Match functions to be used with XE_RTP_MATCH_FUNC */
 
diff --git a/drivers/gpu/drm/xe/xe_rtp_types.h b/drivers/gpu/drm/xe/xe_rtp_types.h
index 5afacbd9083d..66d1cb0aaa08 100644
--- a/drivers/gpu/drm/xe/xe_rtp_types.h
+++ b/drivers/gpu/drm/xe/xe_rtp_types.h
@@ -84,8 +84,8 @@ struct xe_rtp_rule {
 	};
 };
 
-/** struct xe_rtp_entry - Entry in an rtp table */
-struct xe_rtp_entry {
+/** struct xe_rtp_entry_sr - Entry in an rtp table */
+struct xe_rtp_entry_sr {
 	const char *name;
 	const struct xe_rtp_action *actions;
 	const struct xe_rtp_rule *rules;
diff --git a/drivers/gpu/drm/xe/xe_tuning.c b/drivers/gpu/drm/xe/xe_tuning.c
index c2810ede3a65..412e59de9842 100644
--- a/drivers/gpu/drm/xe/xe_tuning.c
+++ b/drivers/gpu/drm/xe/xe_tuning.c
@@ -15,7 +15,7 @@
 #undef XE_REG_MCR
 #define XE_REG_MCR(...)     XE_REG(__VA_ARGS__, .mcr = 1)
 
-static const struct xe_rtp_entry gt_tunings[] = {
+static const struct xe_rtp_entry_sr gt_tunings[] = {
 	{ XE_RTP_NAME("Tuning: Blend Fill Caching Optimization Disable"),
 	  XE_RTP_RULES(PLATFORM(DG2)),
 	  XE_RTP_ACTIONS(SET(XEHP_L3SCQREG7, BLEND_FILL_CACHING_OPT_DIS))
@@ -27,7 +27,7 @@ static const struct xe_rtp_entry gt_tunings[] = {
 	{}
 };
 
-static const struct xe_rtp_entry lrc_tunings[] = {
+static const struct xe_rtp_entry_sr lrc_tunings[] = {
 	{ XE_RTP_NAME("Tuning: ganged timer, also known as 16011163337"),
 	  XE_RTP_RULES(GRAPHICS_VERSION_RANGE(1200, 1210)),
 	  /* read verification is ignored due to 1608008084. */
@@ -61,7 +61,7 @@ void xe_tuning_process_gt(struct xe_gt *gt)
 {
 	struct xe_rtp_process_ctx ctx = XE_RTP_PROCESS_CTX_INITIALIZER(gt);
 
-	xe_rtp_process(&ctx, gt_tunings, &gt->reg_sr);
+	xe_rtp_process_to_sr(&ctx, gt_tunings, &gt->reg_sr);
 }
 EXPORT_SYMBOL_IF_KUNIT(xe_tuning_process_gt);
 
@@ -77,5 +77,5 @@ void xe_tuning_process_lrc(struct xe_hw_engine *hwe)
 {
 	struct xe_rtp_process_ctx ctx = XE_RTP_PROCESS_CTX_INITIALIZER(hwe);
 
-	xe_rtp_process(&ctx, lrc_tunings, &hwe->reg_lrc);
+	xe_rtp_process_to_sr(&ctx, lrc_tunings, &hwe->reg_lrc);
 }
diff --git a/drivers/gpu/drm/xe/xe_wa.c b/drivers/gpu/drm/xe/xe_wa.c
index 4b236b6f4c8e..557e90d79f0b 100644
--- a/drivers/gpu/drm/xe/xe_wa.c
+++ b/drivers/gpu/drm/xe/xe_wa.c
@@ -93,7 +93,7 @@
 __diag_push();
 __diag_ignore_all("-Woverride-init", "Allow field overrides in table");
 
-static const struct xe_rtp_entry gt_was[] = {
+static const struct xe_rtp_entry_sr gt_was[] = {
 	{ XE_RTP_NAME("14011060649"),
 	  XE_RTP_RULES(MEDIA_VERSION_RANGE(1200, 1255),
 		       ENGINE_CLASS(VIDEO_DECODE),
@@ -235,7 +235,7 @@ static const struct xe_rtp_entry gt_was[] = {
 	{}
 };
 
-static const struct xe_rtp_entry engine_was[] = {
+static const struct xe_rtp_entry_sr engine_was[] = {
 	{ XE_RTP_NAME("22010931296, 18011464164, 14010919138"),
 	  XE_RTP_RULES(GRAPHICS_VERSION(1200), ENGINE_CLASS(RENDER)),
 	  XE_RTP_ACTIONS(SET(FF_THREAD_MODE,
@@ -490,7 +490,7 @@ static const struct xe_rtp_entry engine_was[] = {
 	{}
 };
 
-static const struct xe_rtp_entry lrc_was[] = {
+static const struct xe_rtp_entry_sr lrc_was[] = {
 	{ XE_RTP_NAME("1409342910, 14010698770, 14010443199, 1408979724, 1409178076, 1409207793, 1409217633, 1409252684, 1409347922, 1409142259"),
 	  XE_RTP_RULES(GRAPHICS_VERSION_RANGE(1200, 1210)),
 	  XE_RTP_ACTIONS(SET(COMMON_SLICE_CHICKEN3,
@@ -581,7 +581,7 @@ void xe_wa_process_gt(struct xe_gt *gt)
 {
 	struct xe_rtp_process_ctx ctx = XE_RTP_PROCESS_CTX_INITIALIZER(gt);
 
-	xe_rtp_process(&ctx, gt_was, &gt->reg_sr);
+	xe_rtp_process_to_sr(&ctx, gt_was, &gt->reg_sr);
 }
 EXPORT_SYMBOL_IF_KUNIT(xe_wa_process_gt);
 
@@ -597,7 +597,7 @@ void xe_wa_process_engine(struct xe_hw_engine *hwe)
 {
 	struct xe_rtp_process_ctx ctx = XE_RTP_PROCESS_CTX_INITIALIZER(hwe);
 
-	xe_rtp_process(&ctx, engine_was, &hwe->reg_sr);
+	xe_rtp_process_to_sr(&ctx, engine_was, &hwe->reg_sr);
 }
 
 /**
@@ -612,5 +612,5 @@ void xe_wa_process_lrc(struct xe_hw_engine *hwe)
 {
 	struct xe_rtp_process_ctx ctx = XE_RTP_PROCESS_CTX_INITIALIZER(hwe);
 
-	xe_rtp_process(&ctx, lrc_was, &hwe->reg_lrc);
+	xe_rtp_process_to_sr(&ctx, lrc_was, &hwe->reg_lrc);
 }
-- 
2.40.1


^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [Intel-xe] [PATCH v4 05/21] drm/xe/rtp: Allow to track active workarounds
  2023-05-25 21:33 [Intel-xe] [PATCH v4 00/21] Dump + OOB workarounds Lucas De Marchi
                   ` (3 preceding siblings ...)
  2023-05-25 21:33 ` [Intel-xe] [PATCH v4 04/21] drm/xe/rtp: Add "_sr" to entry/function names Lucas De Marchi
@ 2023-05-25 21:33 ` Lucas De Marchi
  2023-05-25 21:33 ` [Intel-xe] [PATCH v4 06/21] drm/xe/wa: Track gt/engine/lrc " Lucas De Marchi
                   ` (17 subsequent siblings)
  22 siblings, 0 replies; 44+ messages in thread
From: Lucas De Marchi @ 2023-05-25 21:33 UTC (permalink / raw)
  To: intel-xe; +Cc: Lucas De Marchi, Matt Roper

Add the metadata in struct xe_rtp_process_ctx, to be set by
xe_rtp_process_ctx_enable_active_tracking(), so rtp knows how to mark
the active entries while processing the table. This can be used by the
WA infra to record what are the active workarounds.

Reviewed-by: Matt Roper <matthew.d.roper@intel.com>
Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
---
 drivers/gpu/drm/xe/xe_rtp.c       | 48 ++++++++++++++++++++++++++++---
 drivers/gpu/drm/xe/xe_rtp.h       |  4 +++
 drivers/gpu/drm/xe/xe_rtp_types.h |  2 ++
 3 files changed, 50 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/xe/xe_rtp.c b/drivers/gpu/drm/xe/xe_rtp.c
index 0be1f4cfc4d5..29cf92f9b7b3 100644
--- a/drivers/gpu/drm/xe/xe_rtp.c
+++ b/drivers/gpu/drm/xe/xe_rtp.c
@@ -112,7 +112,7 @@ static void rtp_add_sr_entry(const struct xe_rtp_action *action,
 	xe_reg_sr_add(sr, &sr_entry);
 }
 
-static void rtp_process_one_sr(const struct xe_rtp_entry_sr *entry,
+static bool rtp_process_one_sr(const struct xe_rtp_entry_sr *entry,
 			       struct xe_device *xe, struct xe_gt *gt,
 			       struct xe_hw_engine *hwe, struct xe_reg_sr *sr)
 {
@@ -121,7 +121,7 @@ static void rtp_process_one_sr(const struct xe_rtp_entry_sr *entry,
 	unsigned int i;
 
 	if (!rule_matches(xe, gt, hwe, entry))
-		return;
+		return false;
 
 	for (action = &entry->actions[0]; i < entry->n_actions; action++, i++) {
 		if ((entry->flags & XE_RTP_ENTRY_FLAG_FOREACH_ENGINE) ||
@@ -132,6 +132,8 @@ static void rtp_process_one_sr(const struct xe_rtp_entry_sr *entry,
 
 		rtp_add_sr_entry(action, gt, mmio_base, sr);
 	}
+
+	return true;
 }
 
 static void rtp_get_context(struct xe_rtp_process_ctx *ctx,
@@ -153,6 +155,38 @@ static void rtp_get_context(struct xe_rtp_process_ctx *ctx,
 	};
 }
 
+/**
+ * xe_rtp_process_ctx_enable_active_tracking - Enable tracking of active entries
+ *
+ * Set additional metadata to track what entries are considered "active", i.e.
+ * their rules match the condition. Bits are never cleared: entries with
+ * matching rules set the corresponding bit in the bitmap.
+ *
+ * @ctx: The context for processing the table
+ * @active_entries: bitmap to store the active entries
+ * @n_entries: number of entries to be processed
+ */
+void xe_rtp_process_ctx_enable_active_tracking(struct xe_rtp_process_ctx *ctx,
+					       unsigned long *active_entries,
+					       size_t n_entries)
+{
+	ctx->active_entries = active_entries;
+	ctx->n_entries = n_entries;
+}
+
+static void rtp_mark_active(struct xe_device *xe,
+			    struct xe_rtp_process_ctx *ctx,
+			    unsigned int bit)
+{
+	if (!ctx->active_entries)
+		return;
+
+	if (drm_WARN_ON(&xe->drm, bit > ctx->n_entries))
+		return;
+
+	bitmap_set(ctx->active_entries, bit, 1);
+}
+
 /**
  * xe_rtp_process_to_sr - Process all rtp @entries, adding the matching ones to
  *                        the save-restore argument.
@@ -178,15 +212,21 @@ void xe_rtp_process_to_sr(struct xe_rtp_process_ctx *ctx,
 	rtp_get_context(ctx, &hwe, &gt, &xe);
 
 	for (entry = entries; entry && entry->name; entry++) {
+		bool match = false;
+
 		if (entry->flags & XE_RTP_ENTRY_FLAG_FOREACH_ENGINE) {
 			struct xe_hw_engine *each_hwe;
 			enum xe_hw_engine_id id;
 
 			for_each_hw_engine(each_hwe, gt, id)
-				rtp_process_one_sr(entry, xe, gt, each_hwe, sr);
+				match |= rtp_process_one_sr(entry, xe, gt,
+							    each_hwe, sr);
 		} else {
-			rtp_process_one_sr(entry, xe, gt, hwe, sr);
+			match = rtp_process_one_sr(entry, xe, gt, hwe, sr);
 		}
+
+		if (match)
+			rtp_mark_active(xe, ctx, entry - entries);
 	}
 }
 EXPORT_SYMBOL_IF_KUNIT(xe_rtp_process_to_sr);
diff --git a/drivers/gpu/drm/xe/xe_rtp.h b/drivers/gpu/drm/xe/xe_rtp.h
index 179b497186d2..e69f514ee6c4 100644
--- a/drivers/gpu/drm/xe/xe_rtp.h
+++ b/drivers/gpu/drm/xe/xe_rtp.h
@@ -359,6 +359,10 @@ struct xe_reg_sr;
 	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 })
 
+void xe_rtp_process_ctx_enable_active_tracking(struct xe_rtp_process_ctx *ctx,
+					       unsigned long *active_entries,
+					       size_t n_entries);
+
 void xe_rtp_process_to_sr(struct xe_rtp_process_ctx *ctx,
 			  const struct xe_rtp_entry_sr *entries,
 			  struct xe_reg_sr *sr);
diff --git a/drivers/gpu/drm/xe/xe_rtp_types.h b/drivers/gpu/drm/xe/xe_rtp_types.h
index 66d1cb0aaa08..03d97b666c64 100644
--- a/drivers/gpu/drm/xe/xe_rtp_types.h
+++ b/drivers/gpu/drm/xe/xe_rtp_types.h
@@ -106,6 +106,8 @@ struct xe_rtp_process_ctx {
 		struct xe_hw_engine *hwe;
 	};
 	enum xe_rtp_process_type type;
+	unsigned long *active_entries;
+	size_t n_entries;
 };
 
 #endif
-- 
2.40.1


^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [Intel-xe] [PATCH v4 06/21] drm/xe/wa: Track gt/engine/lrc active workarounds
  2023-05-25 21:33 [Intel-xe] [PATCH v4 00/21] Dump + OOB workarounds Lucas De Marchi
                   ` (4 preceding siblings ...)
  2023-05-25 21:33 ` [Intel-xe] [PATCH v4 05/21] drm/xe/rtp: Allow to track active workarounds Lucas De Marchi
@ 2023-05-25 21:33 ` Lucas De Marchi
  2023-05-25 22:28   ` Matt Roper
  2023-05-25 21:33 ` [Intel-xe] [PATCH v4 07/21] drm/xe/debugfs: Dump " Lucas De Marchi
                   ` (16 subsequent siblings)
  22 siblings, 1 reply; 44+ messages in thread
From: Lucas De Marchi @ 2023-05-25 21:33 UTC (permalink / raw)
  To: intel-xe; +Cc: Lucas De Marchi, Matt Roper

Allocate the data to track workarounds on each gt of the device,
and pass that to RTP so the active workarounds are tracked.

Even if the workarounds available until know are mostly device
or platform centric, with the different IP versions for media and
graphics starting with MTL, it's possible that some workarounds
need to be applied only on select GTs. Also, given the workaround
database is per IP block, for tracking purposes there is no need to
differentiate the workarounds per engine class. Hence the bitmask
tro track active workarounds can be tracked per GT.

v2: Move the tracking from per-device to per-GT basis (Matt Roper)

Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
---
 drivers/gpu/drm/xe/xe_gt.c       |  5 +++++
 drivers/gpu/drm/xe/xe_gt_types.h | 10 +++++++++
 drivers/gpu/drm/xe/xe_wa.c       | 37 ++++++++++++++++++++++++++++++++
 drivers/gpu/drm/xe/xe_wa.h       |  1 +
 4 files changed, 53 insertions(+)

diff --git a/drivers/gpu/drm/xe/xe_gt.c b/drivers/gpu/drm/xe/xe_gt.c
index 80d42c7c7cfa..d139554316d4 100644
--- a/drivers/gpu/drm/xe/xe_gt.c
+++ b/drivers/gpu/drm/xe/xe_gt.c
@@ -315,6 +315,11 @@ int xe_gt_init_early(struct xe_gt *gt)
 		return err;
 
 	xe_reg_sr_init(&gt->reg_sr, "GT", gt_to_xe(gt));
+
+	err = xe_wa_init(gt);
+	if (err)
+		return err;
+
 	xe_wa_process_gt(gt);
 	xe_tuning_process_gt(gt);
 
diff --git a/drivers/gpu/drm/xe/xe_gt_types.h b/drivers/gpu/drm/xe/xe_gt_types.h
index 7c47d67aa8be..017ab60f2498 100644
--- a/drivers/gpu/drm/xe/xe_gt_types.h
+++ b/drivers/gpu/drm/xe/xe_gt_types.h
@@ -359,6 +359,16 @@ struct xe_gt {
 	 *    of a steered operation
 	 */
 	spinlock_t mcr_lock;
+
+	/** @wa_active: keep track of active workarounds */
+	struct {
+		/** @gt: bitmap with active GT workarounds */
+		unsigned long *gt;
+		/** @engine: bitmap with active engine workarounds */
+		unsigned long *engine;
+		/** @lrc: bitmap with active LRC workarounds */
+		unsigned long *lrc;
+	} wa_active;
 };
 
 #endif
diff --git a/drivers/gpu/drm/xe/xe_wa.c b/drivers/gpu/drm/xe/xe_wa.c
index 557e90d79f0b..3e2a3f678f36 100644
--- a/drivers/gpu/drm/xe/xe_wa.c
+++ b/drivers/gpu/drm/xe/xe_wa.c
@@ -5,6 +5,7 @@
 
 #include "xe_wa.h"
 
+#include <drm/drm_managed.h>
 #include <kunit/visibility.h>
 #include <linux/compiler_types.h>
 
@@ -581,6 +582,8 @@ void xe_wa_process_gt(struct xe_gt *gt)
 {
 	struct xe_rtp_process_ctx ctx = XE_RTP_PROCESS_CTX_INITIALIZER(gt);
 
+	xe_rtp_process_ctx_enable_active_tracking(&ctx, gt->wa_active.gt,
+						  ARRAY_SIZE(gt_was));
 	xe_rtp_process_to_sr(&ctx, gt_was, &gt->reg_sr);
 }
 EXPORT_SYMBOL_IF_KUNIT(xe_wa_process_gt);
@@ -597,6 +600,8 @@ void xe_wa_process_engine(struct xe_hw_engine *hwe)
 {
 	struct xe_rtp_process_ctx ctx = XE_RTP_PROCESS_CTX_INITIALIZER(hwe);
 
+	xe_rtp_process_ctx_enable_active_tracking(&ctx, hwe->gt->wa_active.engine,
+						  ARRAY_SIZE(engine_was));
 	xe_rtp_process_to_sr(&ctx, engine_was, &hwe->reg_sr);
 }
 
@@ -612,5 +617,37 @@ void xe_wa_process_lrc(struct xe_hw_engine *hwe)
 {
 	struct xe_rtp_process_ctx ctx = XE_RTP_PROCESS_CTX_INITIALIZER(hwe);
 
+	xe_rtp_process_ctx_enable_active_tracking(&ctx, hwe->gt->wa_active.lrc,
+						  ARRAY_SIZE(lrc_was));
 	xe_rtp_process_to_sr(&ctx, lrc_was, &hwe->reg_lrc);
 }
+
+/**
+ * xe_wa_init - initialize xe with workaround bookkeeping
+ * @gt: GT instance to initialize
+ *
+ * Returns 0 for success, negative error code otherwise.
+ */
+int xe_wa_init(struct xe_gt *gt)
+{
+	struct xe_device *xe = gt_to_xe(gt);
+	size_t n_lrc, n_engine, n_gt, total;
+	unsigned long *p;
+
+	n_gt = BITS_TO_LONGS(ARRAY_SIZE(gt_was));
+	n_engine = BITS_TO_LONGS(ARRAY_SIZE(engine_was));
+	n_lrc = BITS_TO_LONGS(ARRAY_SIZE(lrc_was));
+	total = n_gt + n_engine + n_lrc;
+
+	p = drmm_kzalloc(&xe->drm, sizeof(*p) * total, GFP_KERNEL);
+	if (!p)
+		return -ENOMEM;
+
+	gt->wa_active.gt = p;
+	p += n_gt;
+	gt->wa_active.engine = p;
+	p += n_engine;
+	gt->wa_active.lrc = p;
+
+	return 0;
+}
diff --git a/drivers/gpu/drm/xe/xe_wa.h b/drivers/gpu/drm/xe/xe_wa.h
index cd2307d58795..eae05bcecc68 100644
--- a/drivers/gpu/drm/xe/xe_wa.h
+++ b/drivers/gpu/drm/xe/xe_wa.h
@@ -9,6 +9,7 @@
 struct xe_gt;
 struct xe_hw_engine;
 
+int xe_wa_init(struct xe_gt *gt);
 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);
-- 
2.40.1


^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [Intel-xe] [PATCH v4 07/21] drm/xe/debugfs: Dump active workarounds
  2023-05-25 21:33 [Intel-xe] [PATCH v4 00/21] Dump + OOB workarounds Lucas De Marchi
                   ` (5 preceding siblings ...)
  2023-05-25 21:33 ` [Intel-xe] [PATCH v4 06/21] drm/xe/wa: Track gt/engine/lrc " Lucas De Marchi
@ 2023-05-25 21:33 ` Lucas De Marchi
  2023-05-25 22:29   ` Matt Roper
  2023-05-25 21:33 ` [Intel-xe] [PATCH v4 08/21] drm/xe/rtp: Rename STEP to GRAPHICS_STEP Lucas De Marchi
                   ` (15 subsequent siblings)
  22 siblings, 1 reply; 44+ messages in thread
From: Lucas De Marchi @ 2023-05-25 21:33 UTC (permalink / raw)
  To: intel-xe; +Cc: Lucas De Marchi, Matt Roper

Add a "workarounds" node in debugfs that can dump all the active
workarounds using the information recorded by rtp infra when those
workarounds were processed.

v2: move workarounds to be reported per-GT

Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
---
 drivers/gpu/drm/xe/xe_gt_debugfs.c | 12 ++++++++++++
 drivers/gpu/drm/xe/xe_wa.c         | 17 +++++++++++++++++
 drivers/gpu/drm/xe/xe_wa.h         |  2 ++
 3 files changed, 31 insertions(+)

diff --git a/drivers/gpu/drm/xe/xe_gt_debugfs.c b/drivers/gpu/drm/xe/xe_gt_debugfs.c
index 8bf441e850a0..339ecd5fad9b 100644
--- a/drivers/gpu/drm/xe/xe_gt_debugfs.c
+++ b/drivers/gpu/drm/xe/xe_gt_debugfs.c
@@ -19,6 +19,7 @@
 #include "xe_reg_sr.h"
 #include "xe_reg_whitelist.h"
 #include "xe_uc_debugfs.h"
+#include "xe_wa.h"
 
 static struct xe_gt *node_to_gt(struct drm_info_node *node)
 {
@@ -127,6 +128,16 @@ static int register_save_restore(struct seq_file *m, void *data)
 	return 0;
 }
 
+static int workarounds(struct seq_file *m, void *data)
+{
+	struct xe_gt *gt = node_to_gt(m->private);
+	struct drm_printer p = drm_seq_file_printer(m);
+
+	xe_wa_dump(gt, &p);
+
+	return 0;
+}
+
 static const struct drm_info_list debugfs_list[] = {
 	{"hw_engines", hw_engines, 0},
 	{"force_reset", force_reset, 0},
@@ -135,6 +146,7 @@ static const struct drm_info_list debugfs_list[] = {
 	{"steering", steering, 0},
 	{"ggtt", ggtt, 0},
 	{"register-save-restore", register_save_restore, 0},
+	{"workarounds", workarounds, 0},
 };
 
 void xe_gt_debugfs_register(struct xe_gt *gt)
diff --git a/drivers/gpu/drm/xe/xe_wa.c b/drivers/gpu/drm/xe/xe_wa.c
index 3e2a3f678f36..f578544c7646 100644
--- a/drivers/gpu/drm/xe/xe_wa.c
+++ b/drivers/gpu/drm/xe/xe_wa.c
@@ -651,3 +651,20 @@ int xe_wa_init(struct xe_gt *gt)
 
 	return 0;
 }
+
+void xe_wa_dump(struct xe_gt *gt, struct drm_printer *p)
+{
+	size_t idx;
+
+	drm_printf(p, "GT Workarounds\n");
+	for_each_set_bit(idx, gt->wa_active.gt, ARRAY_SIZE(gt_was))
+		drm_printf_indent(p, 1, "%s\n", gt_was[idx].name);
+
+	drm_printf(p, "\nEngine Workarounds\n");
+	for_each_set_bit(idx, gt->wa_active.engine, ARRAY_SIZE(engine_was))
+		drm_printf_indent(p, 1, "%s\n", engine_was[idx].name);
+
+	drm_printf(p, "\nLRC Workarounds\n");
+	for_each_set_bit(idx, gt->wa_active.lrc, ARRAY_SIZE(lrc_was))
+		drm_printf_indent(p, 1, "%s\n", lrc_was[idx].name);
+}
diff --git a/drivers/gpu/drm/xe/xe_wa.h b/drivers/gpu/drm/xe/xe_wa.h
index eae05bcecc68..defefa5d9611 100644
--- a/drivers/gpu/drm/xe/xe_wa.h
+++ b/drivers/gpu/drm/xe/xe_wa.h
@@ -6,6 +6,7 @@
 #ifndef _XE_WA_
 #define _XE_WA_
 
+struct drm_printer;
 struct xe_gt;
 struct xe_hw_engine;
 
@@ -15,5 +16,6 @@ void xe_wa_process_engine(struct xe_hw_engine *hwe);
 void xe_wa_process_lrc(struct xe_hw_engine *hwe);
 
 void xe_reg_whitelist_process_engine(struct xe_hw_engine *hwe);
+void xe_wa_dump(struct xe_gt *gt, struct drm_printer *p);
 
 #endif
-- 
2.40.1


^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [Intel-xe] [PATCH v4 08/21] drm/xe/rtp: Rename STEP to GRAPHICS_STEP
  2023-05-25 21:33 [Intel-xe] [PATCH v4 00/21] Dump + OOB workarounds Lucas De Marchi
                   ` (6 preceding siblings ...)
  2023-05-25 21:33 ` [Intel-xe] [PATCH v4 07/21] drm/xe/debugfs: Dump " Lucas De Marchi
@ 2023-05-25 21:33 ` Lucas De Marchi
  2023-05-25 22:31   ` Matt Roper
  2023-05-25 21:33 ` [Intel-xe] [PATCH v4 09/21] drm/xe/rtp: Add check for media stepping Lucas De Marchi
                   ` (14 subsequent siblings)
  22 siblings, 1 reply; 44+ messages in thread
From: Lucas De Marchi @ 2023-05-25 21:33 UTC (permalink / raw)
  To: intel-xe; +Cc: Lucas De Marchi, Matt Roper

Rename the RTP match in order to prepare the code base to check for the
media version. Up until MTL, the graphics vs media distinction wrt to
stepping was not ver relevant as they were the same GT. However, with
MTL this is no longer true.

Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
---
 drivers/gpu/drm/xe/xe_rtp.c       |  2 +-
 drivers/gpu/drm/xe/xe_rtp.h       | 16 ++++----
 drivers/gpu/drm/xe/xe_rtp_types.h |  2 +-
 drivers/gpu/drm/xe/xe_wa.c        | 64 ++++++++++++++++++-------------
 4 files changed, 47 insertions(+), 37 deletions(-)

diff --git a/drivers/gpu/drm/xe/xe_rtp.c b/drivers/gpu/drm/xe/xe_rtp.c
index 29cf92f9b7b3..2ac7b47942fe 100644
--- a/drivers/gpu/drm/xe/xe_rtp.c
+++ b/drivers/gpu/drm/xe/xe_rtp.c
@@ -57,7 +57,7 @@ static bool rule_matches(const struct xe_device *xe,
 			match = xe->info.media_verx100 >= r->ver_start &&
 				xe->info.media_verx100 <= r->ver_end;
 			break;
-		case XE_RTP_MATCH_STEP:
+		case XE_RTP_MATCH_GRAPHICS_STEP:
 			/* TODO: match media/display */
 			match = xe->info.step.graphics >= r->step_start &&
 				xe->info.step.graphics < r->step_end;
diff --git a/drivers/gpu/drm/xe/xe_rtp.h b/drivers/gpu/drm/xe/xe_rtp.h
index e69f514ee6c4..7ba9d2ecab92 100644
--- a/drivers/gpu/drm/xe/xe_rtp.h
+++ b/drivers/gpu/drm/xe/xe_rtp.h
@@ -35,8 +35,8 @@ struct xe_reg_sr;
 	{ .match_type = XE_RTP_MATCH_SUBPLATFORM,				\
 	  .platform = plat__, .subplatform = sub__ }
 
-#define _XE_RTP_RULE_STEP(start__, end__)					\
-	{ .match_type = XE_RTP_MATCH_STEP,					\
+#define _XE_RTP_RULE_GRAPHICS_STEP(start__, end__)				\
+	{ .match_type = XE_RTP_MATCH_GRAPHICS_STEP,				\
 	  .step_start = start__, .step_end = end__ }
 
 #define _XE_RTP_RULE_ENGINE_CLASS(cls__)					\
@@ -63,17 +63,17 @@ struct xe_reg_sr;
 	_XE_RTP_RULE_SUBPLATFORM(XE_##plat_, XE_SUBPLATFORM_##plat_##_##sub_)
 
 /**
- * XE_RTP_RULE_STEP - Create rule matching platform stepping
+ * XE_RTP_RULE_GRAPHICS_STEP - Create rule matching graphics stepping
  * @start_: First stepping matching the rule
  * @end_: First stepping that does not match the rule
  *
- * Note that the range matching this rule [ @start_, @end_ ), i.e. inclusive on
- * the left, exclusive on the right.
+ * Note that the range matching this rule is [ @start_, @end_ ), i.e. inclusive
+ * on the left, exclusive on the right.
  *
  * Refer to XE_RTP_RULES() for expected usage.
  */
-#define XE_RTP_RULE_STEP(start_, end_)						\
-	_XE_RTP_RULE_STEP(STEP_##start_, STEP_##end_)
+#define XE_RTP_RULE_GRAPHICS_STEP(start_, end_)					\
+	_XE_RTP_RULE_GRAPHICS_STEP(STEP_##start_, STEP_##end_)
 
 /**
  * XE_RTP_RULE_ENGINE_CLASS - Create rule matching an engine class
@@ -317,7 +317,7 @@ struct xe_reg_sr;
  *	const struct xe_rtp_entry_sr wa_entries[] = {
  *		...
  *		{ XE_RTP_NAME("test-entry"),
- *		  XE_RTP_RULES(SUBPLATFORM(DG2, G10), STEP(A0, B0)),
+ *		  XE_RTP_RULES(SUBPLATFORM(DG2, G10), GRAPHICS_STEP(A0, B0)),
  *		  ...
  *		},
  *		...
diff --git a/drivers/gpu/drm/xe/xe_rtp_types.h b/drivers/gpu/drm/xe/xe_rtp_types.h
index 03d97b666c64..52adbf7de752 100644
--- a/drivers/gpu/drm/xe/xe_rtp_types.h
+++ b/drivers/gpu/drm/xe/xe_rtp_types.h
@@ -39,11 +39,11 @@ enum {
 	XE_RTP_MATCH_SUBPLATFORM,
 	XE_RTP_MATCH_GRAPHICS_VERSION,
 	XE_RTP_MATCH_GRAPHICS_VERSION_RANGE,
+	XE_RTP_MATCH_GRAPHICS_STEP,
 	XE_RTP_MATCH_MEDIA_VERSION,
 	XE_RTP_MATCH_MEDIA_VERSION_RANGE,
 	XE_RTP_MATCH_INTEGRATED,
 	XE_RTP_MATCH_DISCRETE,
-	XE_RTP_MATCH_STEP,
 	XE_RTP_MATCH_ENGINE_CLASS,
 	XE_RTP_MATCH_NOT_ENGINE_CLASS,
 	XE_RTP_MATCH_FUNC,
diff --git a/drivers/gpu/drm/xe/xe_wa.c b/drivers/gpu/drm/xe/xe_wa.c
index f578544c7646..b717e0025bd9 100644
--- a/drivers/gpu/drm/xe/xe_wa.c
+++ b/drivers/gpu/drm/xe/xe_wa.c
@@ -122,7 +122,7 @@ static const struct xe_rtp_entry_sr gt_was[] = {
 
 	{ XE_RTP_NAME("16010515920"),
 	  XE_RTP_RULES(SUBPLATFORM(DG2, G10),
-		       STEP(A0, B0),
+		       GRAPHICS_STEP(A0, B0),
 		       ENGINE_CLASS(VIDEO_DECODE)),
 	  XE_RTP_ACTIONS(SET(VDBOX_CGCTL3F18(0), ALNUNIT_CLKGATE_DIS)),
 	  XE_RTP_ENTRY_FLAG(FOREACH_ENGINE),
@@ -136,27 +136,27 @@ static const struct xe_rtp_entry_sr gt_was[] = {
 	  XE_RTP_ACTIONS(SET(SUBSLICE_UNIT_LEVEL_CLKGATE, DSS_ROUTER_CLKGATE_DIS))
 	},
 	{ XE_RTP_NAME("14012362059"),
-	  XE_RTP_RULES(SUBPLATFORM(DG2, G10), STEP(A0, B0)),
+	  XE_RTP_RULES(SUBPLATFORM(DG2, G10), GRAPHICS_STEP(A0, B0)),
 	  XE_RTP_ACTIONS(SET(XEHP_MERT_MOD_CTRL, FORCE_MISS_FTLB))
 	},
 	{ XE_RTP_NAME("14012362059"),
-	  XE_RTP_RULES(SUBPLATFORM(DG2, G11), STEP(A0, B0)),
+	  XE_RTP_RULES(SUBPLATFORM(DG2, G11), GRAPHICS_STEP(A0, B0)),
 	  XE_RTP_ACTIONS(SET(XEHP_MERT_MOD_CTRL, FORCE_MISS_FTLB))
 	},
 	{ XE_RTP_NAME("14010948348"),
-	  XE_RTP_RULES(SUBPLATFORM(DG2, G10), STEP(A0, B0)),
+	  XE_RTP_RULES(SUBPLATFORM(DG2, G10), GRAPHICS_STEP(A0, B0)),
 	  XE_RTP_ACTIONS(SET(UNSLCGCTL9430, MSQDUNIT_CLKGATE_DIS))
 	},
 	{ XE_RTP_NAME("14011037102"),
-	  XE_RTP_RULES(SUBPLATFORM(DG2, G10), STEP(A0, B0)),
+	  XE_RTP_RULES(SUBPLATFORM(DG2, G10), GRAPHICS_STEP(A0, B0)),
 	  XE_RTP_ACTIONS(SET(UNSLCGCTL9444, LTCDD_CLKGATE_DIS))
 	},
 	{ XE_RTP_NAME("14011371254"),
-	  XE_RTP_RULES(SUBPLATFORM(DG2, G10), STEP(A0, B0)),
+	  XE_RTP_RULES(SUBPLATFORM(DG2, G10), GRAPHICS_STEP(A0, B0)),
 	  XE_RTP_ACTIONS(SET(XEHP_SLICE_UNIT_LEVEL_CLKGATE, NODEDSS_CLKGATE_DIS))
 	},
 	{ XE_RTP_NAME("14011431319"),
-	  XE_RTP_RULES(SUBPLATFORM(DG2, G10), STEP(A0, B0)),
+	  XE_RTP_RULES(SUBPLATFORM(DG2, G10), GRAPHICS_STEP(A0, B0)),
 	  XE_RTP_ACTIONS(SET(UNSLCGCTL9440,
 			     GAMTLBOACS_CLKGATE_DIS |
 			     GAMTLBVDBOX7_CLKGATE_DIS | GAMTLBVDBOX6_CLKGATE_DIS |
@@ -176,15 +176,15 @@ static const struct xe_rtp_entry_sr gt_was[] = {
 			     GAMTLBVEBOX1_CLKGATE_DIS | GAMTLBVEBOX0_CLKGATE_DIS))
 	},
 	{ XE_RTP_NAME("14010569222"),
-	  XE_RTP_RULES(SUBPLATFORM(DG2, G10), STEP(A0, B0)),
+	  XE_RTP_RULES(SUBPLATFORM(DG2, G10), GRAPHICS_STEP(A0, B0)),
 	  XE_RTP_ACTIONS(SET(UNSLICE_UNIT_LEVEL_CLKGATE, GAMEDIA_CLKGATE_DIS))
 	},
 	{ XE_RTP_NAME("14011028019"),
-	  XE_RTP_RULES(SUBPLATFORM(DG2, G10), STEP(A0, B0)),
+	  XE_RTP_RULES(SUBPLATFORM(DG2, G10), GRAPHICS_STEP(A0, B0)),
 	  XE_RTP_ACTIONS(SET(SSMCGCTL9530, RTFUNIT_CLKGATE_DIS))
 	},
 	{ XE_RTP_NAME("14010680813"),
-	  XE_RTP_RULES(SUBPLATFORM(DG2, G10), STEP(A0, B0)),
+	  XE_RTP_RULES(SUBPLATFORM(DG2, G10), GRAPHICS_STEP(A0, B0)),
 	  XE_RTP_ACTIONS(SET(XEHP_GAMSTLB_CTRL,
 			     CONTROL_BLOCK_CLKGATE_DIS |
 			     EGRESS_BLOCK_CLKGATE_DIS |
@@ -316,7 +316,7 @@ static const struct xe_rtp_entry_sr engine_was[] = {
 			     POLYGON_TRIFAN_LINELOOP_DISABLE))
 	},
 	{ XE_RTP_NAME("22012826095, 22013059131"),
-	  XE_RTP_RULES(SUBPLATFORM(DG2, G10), STEP(B0, C0),
+	  XE_RTP_RULES(SUBPLATFORM(DG2, G10), GRAPHICS_STEP(B0, C0),
 		       FUNC(xe_rtp_match_first_render_or_compute)),
 	  XE_RTP_ACTIONS(FIELD_SET(LSC_CHICKEN_BIT_0_UDW,
 				   MAXREQS_PER_BANK,
@@ -330,7 +330,7 @@ static const struct xe_rtp_entry_sr engine_was[] = {
 				   REG_FIELD_PREP(MAXREQS_PER_BANK, 2)))
 	},
 	{ XE_RTP_NAME("22013059131"),
-	  XE_RTP_RULES(SUBPLATFORM(DG2, G10), STEP(B0, C0),
+	  XE_RTP_RULES(SUBPLATFORM(DG2, G10), GRAPHICS_STEP(B0, C0),
 		       FUNC(xe_rtp_match_first_render_or_compute)),
 	  XE_RTP_ACTIONS(SET(LSC_CHICKEN_BIT_0, FORCE_1_SUB_MESSAGE_PER_FRAGMENT))
 	},
@@ -368,7 +368,7 @@ static const struct xe_rtp_entry_sr engine_was[] = {
 	  XE_RTP_ACTIONS(SET(LSC_CHICKEN_BIT_0_UDW, DIS_CHAIN_2XSIMD8))
 	},
 	{ XE_RTP_NAME("22012654132"),
-	  XE_RTP_RULES(SUBPLATFORM(DG2, G10), STEP(A0, C0),
+	  XE_RTP_RULES(SUBPLATFORM(DG2, G10), GRAPHICS_STEP(A0, C0),
 		       FUNC(xe_rtp_match_first_render_or_compute)),
 	  XE_RTP_ACTIONS(SET(CACHE_MODE_SS, ENABLE_PREFETCH_INTO_IC,
 			     /*
@@ -396,21 +396,25 @@ static const struct xe_rtp_entry_sr engine_was[] = {
 	  XE_RTP_ACTIONS(SET(ROW_CHICKEN2, DISABLE_READ_SUPPRESSION))
 	},
 	{ XE_RTP_NAME("14013392000"),
-	  XE_RTP_RULES(SUBPLATFORM(DG2, G11), STEP(A0, B0), ENGINE_CLASS(RENDER)),
+	  XE_RTP_RULES(SUBPLATFORM(DG2, G11), GRAPHICS_STEP(A0, B0),
+		       ENGINE_CLASS(RENDER)),
 	  XE_RTP_ACTIONS(SET(ROW_CHICKEN2, ENABLE_LARGE_GRF_MODE))
 	},
 	{ XE_RTP_NAME("14012419201"),
-	  XE_RTP_RULES(SUBPLATFORM(DG2, G10), STEP(A0, B0), ENGINE_CLASS(RENDER)),
+	  XE_RTP_RULES(SUBPLATFORM(DG2, G10), GRAPHICS_STEP(A0, B0),
+		       ENGINE_CLASS(RENDER)),
 	  XE_RTP_ACTIONS(SET(ROW_CHICKEN4,
 			     DISABLE_HDR_PAST_PAYLOAD_HOLD_FIX))
 	},
 	{ XE_RTP_NAME("14012419201"),
-	  XE_RTP_RULES(SUBPLATFORM(DG2, G11), STEP(A0, B0), ENGINE_CLASS(RENDER)),
+	  XE_RTP_RULES(SUBPLATFORM(DG2, G11), GRAPHICS_STEP(A0, B0),
+		       ENGINE_CLASS(RENDER)),
 	  XE_RTP_ACTIONS(SET(ROW_CHICKEN4,
 			     DISABLE_HDR_PAST_PAYLOAD_HOLD_FIX))
 	},
 	{ XE_RTP_NAME("1308578152"),
-	  XE_RTP_RULES(SUBPLATFORM(DG2, G10), STEP(B0, C0), ENGINE_CLASS(RENDER),
+	  XE_RTP_RULES(SUBPLATFORM(DG2, G10), GRAPHICS_STEP(B0, C0),
+		       ENGINE_CLASS(RENDER),
 		       FUNC(xe_rtp_match_first_gslice_fused_off)),
 	  XE_RTP_ACTIONS(CLR(CS_DEBUG_MODE1,
 			     REPLAY_MODE_GRANULARITY))
@@ -426,30 +430,35 @@ static const struct xe_rtp_entry_sr engine_was[] = {
 			     MDQ_ARBITRATION_MODE | UGM_BACKUP_MODE))
 	},
 	{ XE_RTP_NAME("22010430635"),
-	  XE_RTP_RULES(SUBPLATFORM(DG2, G10), STEP(A0, B0), ENGINE_CLASS(RENDER)),
+	  XE_RTP_RULES(SUBPLATFORM(DG2, G10), GRAPHICS_STEP(A0, B0),
+		       ENGINE_CLASS(RENDER)),
 	  XE_RTP_ACTIONS(SET(ROW_CHICKEN4,
 			     DISABLE_GRF_CLEAR))
 	},
 	{ XE_RTP_NAME("14013202645"),
-	  XE_RTP_RULES(SUBPLATFORM(DG2, G10), STEP(B0, C0), ENGINE_CLASS(RENDER)),
+	  XE_RTP_RULES(SUBPLATFORM(DG2, G10), GRAPHICS_STEP(B0, C0),
+		       ENGINE_CLASS(RENDER)),
 	  XE_RTP_ACTIONS(SET(RT_CTRL, DIS_NULL_QUERY))
 	},
 	{ XE_RTP_NAME("14013202645"),
-	  XE_RTP_RULES(SUBPLATFORM(DG2, G11), STEP(A0, B0), ENGINE_CLASS(RENDER)),
+	  XE_RTP_RULES(SUBPLATFORM(DG2, G11), GRAPHICS_STEP(A0, B0),
+		       ENGINE_CLASS(RENDER)),
 	  XE_RTP_ACTIONS(SET(RT_CTRL, DIS_NULL_QUERY))
 	},
 	{ XE_RTP_NAME("22012532006"),
-	  XE_RTP_RULES(SUBPLATFORM(DG2, G10), STEP(A0, C0), ENGINE_CLASS(RENDER)),
+	  XE_RTP_RULES(SUBPLATFORM(DG2, G10), GRAPHICS_STEP(A0, C0),
+		       ENGINE_CLASS(RENDER)),
 	  XE_RTP_ACTIONS(SET(HALF_SLICE_CHICKEN7,
 			     DG2_DISABLE_ROUND_ENABLE_ALLOW_FOR_SSLA))
 	},
 	{ XE_RTP_NAME("22012532006"),
-	  XE_RTP_RULES(SUBPLATFORM(DG2, G11), STEP(A0, B0), ENGINE_CLASS(RENDER)),
+	  XE_RTP_RULES(SUBPLATFORM(DG2, G11), GRAPHICS_STEP(A0, B0),
+		       ENGINE_CLASS(RENDER)),
 	  XE_RTP_ACTIONS(SET(HALF_SLICE_CHICKEN7,
 			     DG2_DISABLE_ROUND_ENABLE_ALLOW_FOR_SSLA))
 	},
 	{ XE_RTP_NAME("22014600077"),
-	  XE_RTP_RULES(SUBPLATFORM(DG2, G11), STEP(B0, FOREVER),
+	  XE_RTP_RULES(SUBPLATFORM(DG2, G11), GRAPHICS_STEP(B0, FOREVER),
 		       ENGINE_CLASS(RENDER)),
 	  XE_RTP_ACTIONS(SET(CACHE_MODE_SS,
 			     ENABLE_EU_COUNT_FOR_TDL_FLUSH,
@@ -485,7 +494,8 @@ static const struct xe_rtp_entry_sr engine_was[] = {
 	  XE_RTP_ACTIONS(SET(FF_SLICE_CS_CHICKEN2, PERF_FIX_BALANCING_CFE_DISABLE))
 	},
 	{ XE_RTP_NAME("14014999345"),
-	  XE_RTP_RULES(PLATFORM(PVC), ENGINE_CLASS(COMPUTE), STEP(B0, C0)),
+	  XE_RTP_RULES(PLATFORM(PVC), ENGINE_CLASS(COMPUTE),
+		       GRAPHICS_STEP(B0, C0)),
 	  XE_RTP_ACTIONS(SET(CACHE_MODE_SS, DISABLE_ECC))
 	},
 	{}
@@ -528,17 +538,17 @@ static const struct xe_rtp_entry_sr lrc_was[] = {
 	/* DG2 */
 
 	{ XE_RTP_NAME("16011186671"),
-	  XE_RTP_RULES(SUBPLATFORM(DG2, G11), STEP(A0, B0)),
+	  XE_RTP_RULES(SUBPLATFORM(DG2, G11), GRAPHICS_STEP(A0, B0)),
 	  XE_RTP_ACTIONS(CLR(VFLSKPD, DIS_MULT_MISS_RD_SQUASH),
 			 SET(VFLSKPD, DIS_OVER_FETCH_CACHE))
 	},
 	{ XE_RTP_NAME("14010469329"),
-	  XE_RTP_RULES(SUBPLATFORM(DG2, G10), STEP(A0, B0)),
+	  XE_RTP_RULES(SUBPLATFORM(DG2, G10), GRAPHICS_STEP(A0, B0)),
 	  XE_RTP_ACTIONS(SET(XEHP_COMMON_SLICE_CHICKEN3,
 			     XEHP_DUAL_SIMD8_SEQ_MERGE_DISABLE))
 	},
 	{ XE_RTP_NAME("14010698770, 22010613112, 22010465075"),
-	  XE_RTP_RULES(SUBPLATFORM(DG2, G10), STEP(A0, B0)),
+	  XE_RTP_RULES(SUBPLATFORM(DG2, G10), GRAPHICS_STEP(A0, B0)),
 	  XE_RTP_ACTIONS(SET(XEHP_COMMON_SLICE_CHICKEN3,
 			     DISABLE_CPS_AWARE_COLOR_PIPE))
 	},
-- 
2.40.1


^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [Intel-xe] [PATCH v4 09/21] drm/xe/rtp: Add check for media stepping
  2023-05-25 21:33 [Intel-xe] [PATCH v4 00/21] Dump + OOB workarounds Lucas De Marchi
                   ` (7 preceding siblings ...)
  2023-05-25 21:33 ` [Intel-xe] [PATCH v4 08/21] drm/xe/rtp: Rename STEP to GRAPHICS_STEP Lucas De Marchi
@ 2023-05-25 21:33 ` Lucas De Marchi
  2023-05-25 22:39   ` Matt Roper
  2023-05-25 21:33 ` [Intel-xe] [PATCH v4 10/21] drm/xe/rtp: Add support for entries with no action Lucas De Marchi
                   ` (13 subsequent siblings)
  22 siblings, 1 reply; 44+ messages in thread
From: Lucas De Marchi @ 2023-05-25 21:33 UTC (permalink / raw)
  To: intel-xe; +Cc: Lucas De Marchi, Matt Roper

Start differentiating the media and graphics stepping as it will be
important for MTL. Note that RTP is still not prepared to handle the
different types of GT, i.e. checking for graphics version/range/stepping
on a media gt or vice versa still matches regardless of the gt being
passed as parameter. Changing it to accommodate MTL is left for a future
patch.

Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
---
 drivers/gpu/drm/xe/xe_rtp.c       | 12 +++++++-----
 drivers/gpu/drm/xe/xe_rtp.h       | 17 +++++++++++++++++
 drivers/gpu/drm/xe/xe_rtp_types.h |  1 +
 3 files changed, 25 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/xe/xe_rtp.c b/drivers/gpu/drm/xe/xe_rtp.c
index 2ac7b47942fe..70769852a93d 100644
--- a/drivers/gpu/drm/xe/xe_rtp.c
+++ b/drivers/gpu/drm/xe/xe_rtp.c
@@ -43,13 +43,16 @@ static bool rule_matches(const struct xe_device *xe,
 				xe->info.subplatform == r->subplatform;
 			break;
 		case XE_RTP_MATCH_GRAPHICS_VERSION:
-			/* TODO: match display */
 			match = xe->info.graphics_verx100 == r->ver_start;
 			break;
 		case XE_RTP_MATCH_GRAPHICS_VERSION_RANGE:
 			match = xe->info.graphics_verx100 >= r->ver_start &&
 				xe->info.graphics_verx100 <= r->ver_end;
 			break;
+		case XE_RTP_MATCH_GRAPHICS_STEP:
+			match = xe->info.step.graphics >= r->step_start &&
+				xe->info.step.graphics < r->step_end;
+			break;
 		case XE_RTP_MATCH_MEDIA_VERSION:
 			match = xe->info.media_verx100 == r->ver_start;
 			break;
@@ -57,10 +60,9 @@ static bool rule_matches(const struct xe_device *xe,
 			match = xe->info.media_verx100 >= r->ver_start &&
 				xe->info.media_verx100 <= r->ver_end;
 			break;
-		case XE_RTP_MATCH_GRAPHICS_STEP:
-			/* TODO: match media/display */
-			match = xe->info.step.graphics >= r->step_start &&
-				xe->info.step.graphics < r->step_end;
+		case XE_RTP_MATCH_MEDIA_STEP:
+			match = xe->info.step.media >= r->step_start &&
+				xe->info.step.media < r->step_end;
 			break;
 		case XE_RTP_MATCH_INTEGRATED:
 			match = !xe->info.is_dgfx;
diff --git a/drivers/gpu/drm/xe/xe_rtp.h b/drivers/gpu/drm/xe/xe_rtp.h
index 7ba9d2ecab92..d55701d2f39b 100644
--- a/drivers/gpu/drm/xe/xe_rtp.h
+++ b/drivers/gpu/drm/xe/xe_rtp.h
@@ -39,6 +39,10 @@ struct xe_reg_sr;
 	{ .match_type = XE_RTP_MATCH_GRAPHICS_STEP,				\
 	  .step_start = start__, .step_end = end__ }
 
+#define _XE_RTP_RULE_MEDIA_STEP(start__, end__)					\
+	{ .match_type = XE_RTP_MATCH_MEDIA_STEP,				\
+	  .step_start = start__, .step_end = end__ }
+
 #define _XE_RTP_RULE_ENGINE_CLASS(cls__)					\
 	{ .match_type = XE_RTP_MATCH_ENGINE_CLASS,				\
 	  .engine_class = (cls__) }
@@ -75,6 +79,19 @@ struct xe_reg_sr;
 #define XE_RTP_RULE_GRAPHICS_STEP(start_, end_)					\
 	_XE_RTP_RULE_GRAPHICS_STEP(STEP_##start_, STEP_##end_)
 
+/**
+ * XE_RTP_RULE_MEDIA_STEP - Create rule matching media stepping
+ * @start_: First stepping matching the rule
+ * @end_: First stepping that does not match the rule
+ *
+ * Note that the range matching this rule is [ @start_, @end_ ), i.e. inclusive
+ * on the left, exclusive on the right.
+ *
+ * Refer to XE_RTP_RULES() for expected usage.
+ */
+#define XE_RTP_RULE_MEDIA_STEP(start_, end_)					\
+	_XE_RTP_RULE_MEDIA_STEP(STEP_##start_, STEP_##end_)
+
 /**
  * XE_RTP_RULE_ENGINE_CLASS - Create rule matching an engine class
  * @cls_: Engine class to match
diff --git a/drivers/gpu/drm/xe/xe_rtp_types.h b/drivers/gpu/drm/xe/xe_rtp_types.h
index 52adbf7de752..af49cbf98407 100644
--- a/drivers/gpu/drm/xe/xe_rtp_types.h
+++ b/drivers/gpu/drm/xe/xe_rtp_types.h
@@ -42,6 +42,7 @@ enum {
 	XE_RTP_MATCH_GRAPHICS_STEP,
 	XE_RTP_MATCH_MEDIA_VERSION,
 	XE_RTP_MATCH_MEDIA_VERSION_RANGE,
+	XE_RTP_MATCH_MEDIA_STEP,
 	XE_RTP_MATCH_INTEGRATED,
 	XE_RTP_MATCH_DISCRETE,
 	XE_RTP_MATCH_ENGINE_CLASS,
-- 
2.40.1


^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [Intel-xe] [PATCH v4 10/21] drm/xe/rtp: Add support for entries with no action
  2023-05-25 21:33 [Intel-xe] [PATCH v4 00/21] Dump + OOB workarounds Lucas De Marchi
                   ` (8 preceding siblings ...)
  2023-05-25 21:33 ` [Intel-xe] [PATCH v4 09/21] drm/xe/rtp: Add check for media stepping Lucas De Marchi
@ 2023-05-25 21:33 ` Lucas De Marchi
  2023-05-25 21:33 ` [Intel-xe] [PATCH v4 11/21] drm/xe: Include build directory Lucas De Marchi
                   ` (12 subsequent siblings)
  22 siblings, 0 replies; 44+ messages in thread
From: Lucas De Marchi @ 2023-05-25 21:33 UTC (permalink / raw)
  To: intel-xe; +Cc: Lucas De Marchi, Matt Roper

Add a separate struct to hold entries in a table that has no action
associated with each of them. The goal is that the caller in future can
set a per-context callback, or just use the active entry marking
feature.

Reviewed-by: Matt Roper <matthew.d.roper@intel.com>
Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
---
 drivers/gpu/drm/xe/xe_rtp.c       | 65 +++++++++++++++++++++++++++----
 drivers/gpu/drm/xe/xe_rtp.h       |  3 ++
 drivers/gpu/drm/xe/xe_rtp_types.h |  7 ++++
 3 files changed, 67 insertions(+), 8 deletions(-)

diff --git a/drivers/gpu/drm/xe/xe_rtp.c b/drivers/gpu/drm/xe/xe_rtp.c
index 70769852a93d..ebcfb04c391a 100644
--- a/drivers/gpu/drm/xe/xe_rtp.c
+++ b/drivers/gpu/drm/xe/xe_rtp.c
@@ -26,14 +26,14 @@
 static bool rule_matches(const struct xe_device *xe,
 			 struct xe_gt *gt,
 			 struct xe_hw_engine *hwe,
-			 const struct xe_rtp_entry_sr *entry)
+			 const struct xe_rtp_rule *rules,
+			 unsigned int n_rules)
 {
 	const struct xe_rtp_rule *r;
 	unsigned int i;
 	bool match;
 
-	for (r = entry->rules, i = 0; i < entry->n_rules;
-	     r = &entry->rules[++i]) {
+	for (r = rules, i = 0; i < n_rules; r = &rules[++i]) {
 		switch (r->match_type) {
 		case XE_RTP_MATCH_PLATFORM:
 			match = xe->info.platform == r->platform;
@@ -122,7 +122,7 @@ static bool rtp_process_one_sr(const struct xe_rtp_entry_sr *entry,
 	u32 mmio_base;
 	unsigned int i;
 
-	if (!rule_matches(xe, gt, hwe, entry))
+	if (!rule_matches(xe, gt, hwe, entry->rules, entry->n_rules))
 		return false;
 
 	for (action = &entry->actions[0]; i < entry->n_actions; action++, i++) {
@@ -178,15 +178,18 @@ void xe_rtp_process_ctx_enable_active_tracking(struct xe_rtp_process_ctx *ctx,
 
 static void rtp_mark_active(struct xe_device *xe,
 			    struct xe_rtp_process_ctx *ctx,
-			    unsigned int bit)
+			    unsigned int first, unsigned int last)
 {
 	if (!ctx->active_entries)
 		return;
 
-	if (drm_WARN_ON(&xe->drm, bit > ctx->n_entries))
+	if (drm_WARN_ON(&xe->drm, last > ctx->n_entries))
 		return;
 
-	bitmap_set(ctx->active_entries, bit, 1);
+	if (first == last)
+		bitmap_set(ctx->active_entries, first, 1);
+	else
+		bitmap_set(ctx->active_entries, first, last - first + 2);
 }
 
 /**
@@ -228,11 +231,57 @@ void xe_rtp_process_to_sr(struct xe_rtp_process_ctx *ctx,
 		}
 
 		if (match)
-			rtp_mark_active(xe, ctx, entry - entries);
+			rtp_mark_active(xe, ctx, entry - entries,
+					entry - entries);
 	}
 }
 EXPORT_SYMBOL_IF_KUNIT(xe_rtp_process_to_sr);
 
+/**
+ * xe_rtp_process - Process all rtp @entries, without running any action
+ * @ctx: The context for processing the table, with one of device, gt or hwe
+ * @entries: Table with RTP definitions
+ *
+ * Walk the table pointed by @entries (with an empty sentinel), executing the
+ * rules. A few differences from xe_rtp_process_to_sr():
+ *
+ * 1. There is no action associated with each entry since this uses
+ *    struct xe_rtp_entry. Its main use is for marking active workarounds via
+ *    xe_rtp_process_ctx_enable_active_tracking().
+ * 2. There is support for OR operations by having entries with no name.
+ */
+void xe_rtp_process(struct xe_rtp_process_ctx *ctx,
+		    const struct xe_rtp_entry *entries)
+{
+	const struct xe_rtp_entry *entry, *first_entry;
+	struct xe_hw_engine *hwe;
+	struct xe_gt *gt;
+	struct xe_device *xe;
+
+	rtp_get_context(ctx, &hwe, &gt, &xe);
+
+	first_entry = entries;
+	if (drm_WARN_ON(&xe->drm, !first_entry->name))
+		return;
+
+	for (entry = entries; entry && entry->rules; entry++) {
+		if (entry->name)
+			first_entry = entry;
+
+		if (!rule_matches(xe, gt, hwe, entry->rules, entry->n_rules))
+			continue;
+
+		/* Fast-forward entry, eliminating the OR'ed entries */
+		for (entry++; entry && entry->rules; entry++)
+			if (entry->name)
+				break;
+		entry--;
+
+		rtp_mark_active(xe, ctx, first_entry - entries,
+				entry - entries);
+	}
+}
+
 bool xe_rtp_match_even_instance(const struct xe_gt *gt,
 				const struct xe_hw_engine *hwe)
 {
diff --git a/drivers/gpu/drm/xe/xe_rtp.h b/drivers/gpu/drm/xe/xe_rtp.h
index d55701d2f39b..8581bd9b1426 100644
--- a/drivers/gpu/drm/xe/xe_rtp.h
+++ b/drivers/gpu/drm/xe/xe_rtp.h
@@ -384,6 +384,9 @@ void xe_rtp_process_to_sr(struct xe_rtp_process_ctx *ctx,
 			  const struct xe_rtp_entry_sr *entries,
 			  struct xe_reg_sr *sr);
 
+void xe_rtp_process(struct xe_rtp_process_ctx *ctx,
+		    const struct xe_rtp_entry *entries);
+
 /* Match functions to be used with XE_RTP_MATCH_FUNC */
 
 /**
diff --git a/drivers/gpu/drm/xe/xe_rtp_types.h b/drivers/gpu/drm/xe/xe_rtp_types.h
index af49cbf98407..d170532a98a5 100644
--- a/drivers/gpu/drm/xe/xe_rtp_types.h
+++ b/drivers/gpu/drm/xe/xe_rtp_types.h
@@ -96,6 +96,13 @@ struct xe_rtp_entry_sr {
 	u8 flags;
 };
 
+/** struct xe_rtp_entry - Entry in an rtp table, with no action associated */
+struct xe_rtp_entry {
+	const char *name;
+	const struct xe_rtp_rule *rules;
+	u8 n_rules;
+};
+
 enum xe_rtp_process_type {
 	XE_RTP_PROCESS_TYPE_GT,
 	XE_RTP_PROCESS_TYPE_ENGINE,
-- 
2.40.1


^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [Intel-xe] [PATCH v4 11/21] drm/xe: Include build directory
  2023-05-25 21:33 [Intel-xe] [PATCH v4 00/21] Dump + OOB workarounds Lucas De Marchi
                   ` (9 preceding siblings ...)
  2023-05-25 21:33 ` [Intel-xe] [PATCH v4 10/21] drm/xe/rtp: Add support for entries with no action Lucas De Marchi
@ 2023-05-25 21:33 ` Lucas De Marchi
  2023-05-25 22:41   ` Matt Roper
  2023-05-25 21:33 ` [Intel-xe] [PATCH v4 12/21] drm/xe: Add support for OOB workarounds Lucas De Marchi
                   ` (11 subsequent siblings)
  22 siblings, 1 reply; 44+ messages in thread
From: Lucas De Marchi @ 2023-05-25 21:33 UTC (permalink / raw)
  To: intel-xe; +Cc: Lucas De Marchi, Matt Roper

When doing out-of-tree builds with O= or KBUILD_OUTPUT=, it's important
to also add the directory where the target is saved. Otherwise any file
generated by the build system may not be available for other targets
depending on it.

The $(obj) is added automatically when building the entire kernel,
but it's not added when M=drivers/gpu/drm/xe is added.

Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
---
 drivers/gpu/drm/xe/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/xe/Makefile b/drivers/gpu/drm/xe/Makefile
index cd1614b68734..e058b1dda6e6 100644
--- a/drivers/gpu/drm/xe/Makefile
+++ b/drivers/gpu/drm/xe/Makefile
@@ -24,7 +24,7 @@ subdir-ccflags-y += $(call cc-disable-warning, initializer-overrides)
 subdir-ccflags-y += $(call cc-disable-warning, frame-address)
 subdir-ccflags-$(CONFIG_DRM_XE_WERROR) += -Werror
 
-subdir-ccflags-y += -I$(srctree)/$(src)
+subdir-ccflags-y += -I$(obj) -I$(srctree)/$(src)
 
 # Please keep these build lists sorted!
 
-- 
2.40.1


^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [Intel-xe] [PATCH v4 12/21] drm/xe: Add support for OOB workarounds
  2023-05-25 21:33 [Intel-xe] [PATCH v4 00/21] Dump + OOB workarounds Lucas De Marchi
                   ` (10 preceding siblings ...)
  2023-05-25 21:33 ` [Intel-xe] [PATCH v4 11/21] drm/xe: Include build directory Lucas De Marchi
@ 2023-05-25 21:33 ` Lucas De Marchi
  2023-05-25 23:13   ` Matt Roper
  2023-05-25 21:33 ` [Intel-xe] [PATCH v4 13/21] drm/xe/guc: Port Wa_22012773006 to xe_wa Lucas De Marchi
                   ` (10 subsequent siblings)
  22 siblings, 1 reply; 44+ messages in thread
From: Lucas De Marchi @ 2023-05-25 21:33 UTC (permalink / raw)
  To: intel-xe; +Cc: Lucas De Marchi, Matt Roper

There are WAs that, due to their nature, cannot be applied from a
central place like xe_wa.c. Those are peppered around the rest of the
code, as needed. Now they have a new name:  "out-of-band workarounds".

These workarounds have their names and rules still grouped in xe_wa.c,
inside the xe_wa_oob array, which is generated at compile time by
xe_wa_oob.rules and the hostprog xe_gen_wa_oob. The code generation
guarantees that the header xe_wa_oob.h contains the IDs for the
workarounds that match the index in the table. This way the runtime
checks that are spread throughout the code are simple tests against the
bitmap saved during initialization.

Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
---
 drivers/gpu/drm/xe/Makefile        |  14 +++
 drivers/gpu/drm/xe/xe_gen_wa_oob.c | 164 +++++++++++++++++++++++++++++
 drivers/gpu/drm/xe/xe_gt.c         |   1 +
 drivers/gpu/drm/xe/xe_gt_types.h   |   2 +
 drivers/gpu/drm/xe/xe_wa.c         |  40 ++++++-
 drivers/gpu/drm/xe/xe_wa.h         |   9 ++
 drivers/gpu/drm/xe/xe_wa_oob.rules |   0
 7 files changed, 226 insertions(+), 4 deletions(-)
 create mode 100644 drivers/gpu/drm/xe/xe_gen_wa_oob.c
 create mode 100644 drivers/gpu/drm/xe/xe_wa_oob.rules

diff --git a/drivers/gpu/drm/xe/Makefile b/drivers/gpu/drm/xe/Makefile
index e058b1dda6e6..738975faaa05 100644
--- a/drivers/gpu/drm/xe/Makefile
+++ b/drivers/gpu/drm/xe/Makefile
@@ -26,6 +26,20 @@ subdir-ccflags-$(CONFIG_DRM_XE_WERROR) += -Werror
 
 subdir-ccflags-y += -I$(obj) -I$(srctree)/$(src)
 
+# generated sources
+hostprogs := xe_gen_wa_oob
+
+XE_WA_OOB := $(obj)/generated/xe_wa_oob.c $(obj)/generated/xe_wa_oob.h
+
+quiet_cmd_wa_oob = GEN     xe_wa_oob.[ch]
+      cmd_wa_oob = $^ $(XE_WA_OOB)
+
+$(XE_WA_OOB) &: $(obj)/xe_gen_wa_oob $(srctree)/$(src)/xe_wa_oob.rules
+	@mkdir -p $(@D)
+	$(call cmd,wa_oob)
+
+%.o:  $(XE_WA_OOB)
+
 # Please keep these build lists sorted!
 
 # core driver code
diff --git a/drivers/gpu/drm/xe/xe_gen_wa_oob.c b/drivers/gpu/drm/xe/xe_gen_wa_oob.c
new file mode 100644
index 000000000000..930cdb7ccf52
--- /dev/null
+++ b/drivers/gpu/drm/xe/xe_gen_wa_oob.c
@@ -0,0 +1,164 @@
+// SPDX-License-Identifier: MIT
+/*
+ * Copyright © 2023 Intel Corporation
+ */
+
+#define _GNU_SOURCE
+#include <ctype.h>
+#include <errno.h>
+#include <stdbool.h>
+#include <stdio.h>
+#include <string.h>
+
+#define HEADER \
+	"// SPDX-License-Identifier: MIT\n" \
+	"\n" \
+	"/*\n" \
+	" * DO NOT MODIFY.\n" \
+	" *\n" \
+	" * This file was generated from rules: %s\n" \
+	" */\n" \
+	"#ifndef _GENERATED_XE_WA_OOB_\n" \
+	"#define _GENERATED_XE_WA_OOB_\n" \
+	"\n" \
+	"enum {\n"
+
+#define FOOTER \
+	"};\n" \
+	"\n" \
+	"#endif\n"
+
+static void print_usage(FILE *f)
+{
+	fprintf(f, "usage: %s <input-rule-file> <generated-c-source-file> <generated-c-header-file>\n",
+		program_invocation_short_name);
+}
+
+static void print_parse_error(const char *err_msg, const char *line,
+			      unsigned int lineno)
+{
+	fprintf(stderr, "ERROR: %s\nERROR: %u: %.60s\n",
+		err_msg, lineno, line);
+}
+
+static char *strip(char *line, size_t linelen)
+{
+	while (isspace(*(line + linelen)))
+		linelen--;
+
+	line[linelen - 1] = '\0';
+
+	return  line + strspn(line, " \f\n\r\t\v");
+}
+
+#define MAX_LINE_LEN 4096
+static int parse(FILE *input, FILE *csource, FILE *cheader)
+{
+	char line[MAX_LINE_LEN + 1];
+	char *name, *prev_name = NULL, *rules;
+	unsigned int lineno = 0, idx = 0;
+
+	while (fgets(line, sizeof(line), input)) {
+		size_t linelen;
+		bool is_continuation;
+
+		if (line[0] == '\0' || line[0] == '#' || line[0] == '\n') {
+			lineno++;
+			continue;
+		}
+
+		linelen = strlen(line);
+		if (linelen == MAX_LINE_LEN) {
+			print_parse_error("line too long", line, lineno);
+			return -EINVAL;
+		}
+
+		is_continuation = isspace(line[0]);
+		name = strip(line, linelen);
+
+		if (!is_continuation) {
+			name = strtok(name, " \t");
+			rules = strtok(NULL, "");
+		} else {
+			if (!prev_name) {
+				print_parse_error("invalid rule continuation",
+						  line, lineno);
+				return -EINVAL;
+			}
+
+			rules = name;
+			name = NULL;
+		}
+
+		if (rules[0] == '\0') {
+			print_parse_error("invalid empty rule\n", line, lineno);
+			return -EINVAL;
+		}
+
+		if (name) {
+			fprintf(cheader, "\tXE_WA_OOB_%s = %u,\n", name, idx);
+			fprintf(csource, "{ XE_RTP_NAME(\"%s\"), XE_RTP_RULES(%s) },\n",
+				name, rules);
+		} else {
+			fprintf(csource, "{ XE_RTP_NAME(NULL), XE_RTP_RULES(%s) },\n",
+				rules);
+		}
+
+		idx++;
+		lineno++;
+		prev_name = name;
+	}
+
+	fprintf(cheader, "\t_XE_WA_OOB_COUNT = %u\n", idx);
+
+	return 0;
+}
+
+int main(int argc, const char *argv[])
+{
+	enum {
+		ARGS_INPUT,
+		ARGS_CSOURCE,
+		ARGS_CHEADER,
+		_ARGS_COUNT
+	};
+	struct {
+		const char *fn;
+		const char *mode;
+		FILE *f;
+	} args[] = {
+		[ARGS_INPUT] = { .fn = argv[1], .mode = "r" },
+		[ARGS_CSOURCE] = { .fn = argv[2], .mode = "w" },
+		[ARGS_CHEADER] = { .fn = argv[3], .mode = "w" },
+	};
+	int ret = 1;
+
+	if (argc < 3) {
+		fprintf(stderr, "ERROR: wrong arguments\n");
+		print_usage(stderr);
+		return 1;
+	}
+
+	for (int i = 0; i < _ARGS_COUNT; i++) {
+		args[i].f = fopen(args[i].fn, args[i].mode);
+		if (!args[i].f) {
+			fprintf(stderr, "ERROR: Can't open %s: %m\n",
+				args[i].fn);
+			goto err;
+		}
+	}
+
+	fprintf(args[ARGS_CHEADER].f, HEADER, args[ARGS_INPUT].fn);
+	ret = parse(args[ARGS_INPUT].f, args[ARGS_CSOURCE].f,
+		    args[ARGS_CHEADER].f);
+	if (!ret)
+		fprintf(args[ARGS_CHEADER].f, FOOTER);
+
+err:
+	for (int i = 0; i < _ARGS_COUNT; i++) {
+		if (args[i].f)
+			fclose(args[i].f);
+	}
+
+	return ret;
+}
diff --git a/drivers/gpu/drm/xe/xe_gt.c b/drivers/gpu/drm/xe/xe_gt.c
index d139554316d4..18eda5b1377f 100644
--- a/drivers/gpu/drm/xe/xe_gt.c
+++ b/drivers/gpu/drm/xe/xe_gt.c
@@ -321,6 +321,7 @@ int xe_gt_init_early(struct xe_gt *gt)
 		return err;
 
 	xe_wa_process_gt(gt);
+	xe_wa_process_oob(gt);
 	xe_tuning_process_gt(gt);
 
 	return 0;
diff --git a/drivers/gpu/drm/xe/xe_gt_types.h b/drivers/gpu/drm/xe/xe_gt_types.h
index 017ab60f2498..b83c834e7ced 100644
--- a/drivers/gpu/drm/xe/xe_gt_types.h
+++ b/drivers/gpu/drm/xe/xe_gt_types.h
@@ -368,6 +368,8 @@ struct xe_gt {
 		unsigned long *engine;
 		/** @lrc: bitmap with active LRC workarounds */
 		unsigned long *lrc;
+		/** @oob: bitmap with active OOB workaroudns */
+		unsigned long *oob;
 	} wa_active;
 };
 
diff --git a/drivers/gpu/drm/xe/xe_wa.c b/drivers/gpu/drm/xe/xe_wa.c
index b717e0025bd9..ded100245479 100644
--- a/drivers/gpu/drm/xe/xe_wa.c
+++ b/drivers/gpu/drm/xe/xe_wa.c
@@ -9,6 +9,7 @@
 #include <kunit/visibility.h>
 #include <linux/compiler_types.h>
 
+#include "generated/xe_wa_oob.h"
 #include "regs/xe_engine_regs.h"
 #include "regs/xe_gt_regs.h"
 #include "regs/xe_regs.h"
@@ -73,8 +74,8 @@
  *      engine registers are restored in a context restore sequence. This is
  *      currently not used in the driver.
  *
- * - Other:  There are WAs that, due to their nature, cannot be applied from a
- *   central place. Those are peppered around the rest of the code, as needed.
+ * - Other/OOB:  There are WAs that, due to their nature, cannot be applied from
+ *   a central place. Those are peppered around the rest of the code, as needed.
  *   Workarounds related to the display IP are the main example.
  *
  * .. [1] Technically, some registers are powercontext saved & restored, so they
@@ -579,8 +580,31 @@ static const struct xe_rtp_entry_sr lrc_was[] = {
 	{}
 };
 
+static __maybe_unused const struct xe_rtp_entry oob_was[] = {
+#include <generated/xe_wa_oob.c>
+	{}
+};
+
+static_assert(ARRAY_SIZE(oob_was) - 1 == _XE_WA_OOB_COUNT);
+
 __diag_pop();
 
+/**
+ * xe_wa_process_oob - process OOB workaround table
+ * @gt: GT instance to process workarounds for
+ *
+ * Process OOB workaround table for this platform, marking in @gt the
+ * workarounds that are active.
+ */
+void xe_wa_process_oob(struct xe_gt *gt)
+{
+	struct xe_rtp_process_ctx ctx = XE_RTP_PROCESS_CTX_INITIALIZER(gt);
+
+	xe_rtp_process_ctx_enable_active_tracking(&ctx, gt->wa_active.oob,
+						  ARRAY_SIZE(oob_was));
+	xe_rtp_process(&ctx, oob_was);
+}
+
 /**
  * xe_wa_process_gt - process GT workaround table
  * @gt: GT instance to process workarounds for
@@ -641,13 +665,14 @@ void xe_wa_process_lrc(struct xe_hw_engine *hwe)
 int xe_wa_init(struct xe_gt *gt)
 {
 	struct xe_device *xe = gt_to_xe(gt);
-	size_t n_lrc, n_engine, n_gt, total;
+	size_t n_oob, n_lrc, n_engine, n_gt, total;
 	unsigned long *p;
 
 	n_gt = BITS_TO_LONGS(ARRAY_SIZE(gt_was));
 	n_engine = BITS_TO_LONGS(ARRAY_SIZE(engine_was));
 	n_lrc = BITS_TO_LONGS(ARRAY_SIZE(lrc_was));
-	total = n_gt + n_engine + n_lrc;
+	n_oob = BITS_TO_LONGS(ARRAY_SIZE(oob_was));
+	total = n_gt + n_engine + n_lrc + n_oob;
 
 	p = drmm_kzalloc(&xe->drm, sizeof(*p) * total, GFP_KERNEL);
 	if (!p)
@@ -658,6 +683,8 @@ int xe_wa_init(struct xe_gt *gt)
 	gt->wa_active.engine = p;
 	p += n_engine;
 	gt->wa_active.lrc = p;
+	p += n_lrc;
+	gt->wa_active.oob = p;
 
 	return 0;
 }
@@ -677,4 +704,9 @@ void xe_wa_dump(struct xe_gt *gt, struct drm_printer *p)
 	drm_printf(p, "\nLRC Workarounds\n");
 	for_each_set_bit(idx, gt->wa_active.lrc, ARRAY_SIZE(lrc_was))
 		drm_printf_indent(p, 1, "%s\n", lrc_was[idx].name);
+
+	drm_printf(p, "\nOOB Workarounds\n");
+	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);
 }
diff --git a/drivers/gpu/drm/xe/xe_wa.h b/drivers/gpu/drm/xe/xe_wa.h
index defefa5d9611..cfe685989524 100644
--- a/drivers/gpu/drm/xe/xe_wa.h
+++ b/drivers/gpu/drm/xe/xe_wa.h
@@ -11,6 +11,7 @@ struct xe_gt;
 struct xe_hw_engine;
 
 int xe_wa_init(struct xe_gt *gt);
+void xe_wa_process_oob(struct xe_gt *gt);
 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);
@@ -18,4 +19,12 @@ void xe_wa_process_lrc(struct xe_hw_engine *hwe);
 void xe_reg_whitelist_process_engine(struct xe_hw_engine *hwe);
 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
+ * @gt__: gt instance
+ * @id__: XE_OOB_<id__>, as generated by build system in generated/xe_wa_oob.h
+ */
+#define XE_WA(gt__, id__) test_bit(XE_WA_OOB_ ## id__, (gt__)->wa_active.oob)
+
 #endif
diff --git a/drivers/gpu/drm/xe/xe_wa_oob.rules b/drivers/gpu/drm/xe/xe_wa_oob.rules
new file mode 100644
index 000000000000..e69de29bb2d1
-- 
2.40.1


^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [Intel-xe] [PATCH v4 13/21] drm/xe/guc: Port Wa_22012773006 to xe_wa
  2023-05-25 21:33 [Intel-xe] [PATCH v4 00/21] Dump + OOB workarounds Lucas De Marchi
                   ` (11 preceding siblings ...)
  2023-05-25 21:33 ` [Intel-xe] [PATCH v4 12/21] drm/xe: Add support for OOB workarounds Lucas De Marchi
@ 2023-05-25 21:33 ` Lucas De Marchi
  2023-05-25 23:14   ` Matt Roper
  2023-05-25 21:34 ` [Intel-xe] [PATCH v4 14/21] drm/xe/guc: Port Wa_16011759253 " Lucas De Marchi
                   ` (9 subsequent siblings)
  22 siblings, 1 reply; 44+ messages in thread
From: Lucas De Marchi @ 2023-05-25 21:33 UTC (permalink / raw)
  To: intel-xe; +Cc: Lucas De Marchi, Matt Roper

Let xe_guc.c start using XE_WA() for workarounds, starting from a simple
one: Wa_22012773006. It's also changed to start with graphics version
12, since that is the first supported by xe.

Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
---
 drivers/gpu/drm/xe/xe_guc.c        | 6 +++---
 drivers/gpu/drm/xe/xe_wa_oob.rules | 1 +
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/xe/xe_guc.c b/drivers/gpu/drm/xe/xe_guc.c
index a8e249205bff..08362db6a886 100644
--- a/drivers/gpu/drm/xe/xe_guc.c
+++ b/drivers/gpu/drm/xe/xe_guc.c
@@ -5,6 +5,7 @@
 
 #include "xe_guc.h"
 
+#include "generated/xe_wa_oob.h"
 #include "regs/xe_gt_regs.h"
 #include "regs/xe_guc_regs.h"
 #include "xe_bo.h"
@@ -20,6 +21,7 @@
 #include "xe_mmio.h"
 #include "xe_platform_types.h"
 #include "xe_uc_fw.h"
+#include "xe_wa.h"
 #include "xe_wopcm.h"
 
 static struct xe_gt *
@@ -134,9 +136,7 @@ static u32 guc_ctl_wa_flags(struct xe_guc *guc)
 	struct xe_gt *gt = guc_to_gt(guc);
 	u32 flags = 0;
 
-	/* Wa_22012773006:gen11,gen12 < XeHP */
-	if (GRAPHICS_VER(xe) >= 11 &&
-	    GRAPHICS_VERx100(xe) < 1250)
+	if (XE_WA(gt, 22012773006))
 		flags |= GUC_WA_POLLCS;
 
 	/* Wa_16011759253 */
diff --git a/drivers/gpu/drm/xe/xe_wa_oob.rules b/drivers/gpu/drm/xe/xe_wa_oob.rules
index e69de29bb2d1..b54f70eeccf4 100644
--- a/drivers/gpu/drm/xe/xe_wa_oob.rules
+++ b/drivers/gpu/drm/xe/xe_wa_oob.rules
@@ -0,0 +1 @@
+22012773006	GRAPHICS_VERSION_RANGE(1200, 1250)
-- 
2.40.1


^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [Intel-xe] [PATCH v4 14/21] drm/xe/guc: Port Wa_16011759253 to xe_wa
  2023-05-25 21:33 [Intel-xe] [PATCH v4 00/21] Dump + OOB workarounds Lucas De Marchi
                   ` (12 preceding siblings ...)
  2023-05-25 21:33 ` [Intel-xe] [PATCH v4 13/21] drm/xe/guc: Port Wa_22012773006 to xe_wa Lucas De Marchi
@ 2023-05-25 21:34 ` Lucas De Marchi
  2023-05-25 23:17   ` Matt Roper
  2023-05-25 21:34 ` [Intel-xe] [PATCH v4 15/21] drm/xe/guc: Port Wa_14012197797/Wa_22011391025 " Lucas De Marchi
                   ` (8 subsequent siblings)
  22 siblings, 1 reply; 44+ messages in thread
From: Lucas De Marchi @ 2023-05-25 21:34 UTC (permalink / raw)
  To: intel-xe; +Cc: Lucas De Marchi, Matt Roper

Port Wa_16011759253 to oob. Wa_22011383443, that has the same action,
doesn't need to be ported as it targets early PVC steppings.

Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
---
 drivers/gpu/drm/xe/xe_guc.c        | 4 +---
 drivers/gpu/drm/xe/xe_wa_oob.rules | 1 +
 2 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/xe/xe_guc.c b/drivers/gpu/drm/xe/xe_guc.c
index 08362db6a886..1b3fbbd74923 100644
--- a/drivers/gpu/drm/xe/xe_guc.c
+++ b/drivers/gpu/drm/xe/xe_guc.c
@@ -139,9 +139,7 @@ static u32 guc_ctl_wa_flags(struct xe_guc *guc)
 	if (XE_WA(gt, 22012773006))
 		flags |= GUC_WA_POLLCS;
 
-	/* Wa_16011759253 */
-	/* Wa_22011383443 */
-	if (IS_SUBPLATFORM_STEP(xe, XE_DG2, XE_SUBPLATFORM_DG2_G10, STEP_A0, STEP_B0))
+	if (XE_WA(gt, 16011759253))
 		flags |= GUC_WA_GAM_CREDITS;
 
 	/* Wa_14014475959 */
diff --git a/drivers/gpu/drm/xe/xe_wa_oob.rules b/drivers/gpu/drm/xe/xe_wa_oob.rules
index b54f70eeccf4..9b29a0dd0934 100644
--- a/drivers/gpu/drm/xe/xe_wa_oob.rules
+++ b/drivers/gpu/drm/xe/xe_wa_oob.rules
@@ -1 +1,2 @@
 22012773006	GRAPHICS_VERSION_RANGE(1200, 1250)
+16011759253	SUBPLATFORM(DG2, G10), GRAPHICS_STEP(A0, B0)
-- 
2.40.1


^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [Intel-xe] [PATCH v4 15/21] drm/xe/guc: Port Wa_14012197797/Wa_22011391025 to xe_wa
  2023-05-25 21:33 [Intel-xe] [PATCH v4 00/21] Dump + OOB workarounds Lucas De Marchi
                   ` (13 preceding siblings ...)
  2023-05-25 21:34 ` [Intel-xe] [PATCH v4 14/21] drm/xe/guc: Port Wa_16011759253 " Lucas De Marchi
@ 2023-05-25 21:34 ` Lucas De Marchi
  2023-05-25 23:18   ` Matt Roper
  2023-05-25 21:34 ` [Intel-xe] [PATCH v4 16/21] drm/xe/guc: Port Wa_16011777198 " Lucas De Marchi
                   ` (7 subsequent siblings)
  22 siblings, 1 reply; 44+ messages in thread
From: Lucas De Marchi @ 2023-05-25 21:34 UTC (permalink / raw)
  To: intel-xe; +Cc: Lucas De Marchi, Matt Roper

Wa_14012197797 and Wa_22011391025 apply to DG2 using the same action.
They apply to slightly different conditions. Add both to the oob rules
so they are both reported as active.

Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
---
 drivers/gpu/drm/xe/xe_guc.c        | 9 +--------
 drivers/gpu/drm/xe/xe_wa_oob.rules | 2 ++
 2 files changed, 3 insertions(+), 8 deletions(-)

diff --git a/drivers/gpu/drm/xe/xe_guc.c b/drivers/gpu/drm/xe/xe_guc.c
index 1b3fbbd74923..54aaf6e6b577 100644
--- a/drivers/gpu/drm/xe/xe_guc.c
+++ b/drivers/gpu/drm/xe/xe_guc.c
@@ -147,14 +147,7 @@ static u32 guc_ctl_wa_flags(struct xe_guc *guc)
 	    xe->info.platform == XE_DG2)
 		flags |= GUC_WA_HOLD_CCS_SWITCHOUT;
 
-	/*
-	 * Wa_14012197797
-	 * Wa_22011391025
-	 *
-	 * The same WA bit is used for both and 22011391025 is applicable to
-	 * all DG2.
-	 */
-	if (xe->info.platform == XE_DG2)
+	if (XE_WA(gt, 22011391025) || XE_WA(gt, 14012197797))
 		flags |= GUC_WA_DUAL_QUEUE;
 
 	/*
diff --git a/drivers/gpu/drm/xe/xe_wa_oob.rules b/drivers/gpu/drm/xe/xe_wa_oob.rules
index 9b29a0dd0934..77ac4a4a3296 100644
--- a/drivers/gpu/drm/xe/xe_wa_oob.rules
+++ b/drivers/gpu/drm/xe/xe_wa_oob.rules
@@ -1,2 +1,4 @@
 22012773006	GRAPHICS_VERSION_RANGE(1200, 1250)
 16011759253	SUBPLATFORM(DG2, G10), GRAPHICS_STEP(A0, B0)
+22011391025	PLATFORM(DG2)
+14012197797	PLATFORM(DG2), GRAPHICS_STEP(A0, B0)
-- 
2.40.1


^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [Intel-xe] [PATCH v4 16/21] drm/xe/guc: Port Wa_16011777198 to xe_wa
  2023-05-25 21:33 [Intel-xe] [PATCH v4 00/21] Dump + OOB workarounds Lucas De Marchi
                   ` (14 preceding siblings ...)
  2023-05-25 21:34 ` [Intel-xe] [PATCH v4 15/21] drm/xe/guc: Port Wa_14012197797/Wa_22011391025 " Lucas De Marchi
@ 2023-05-25 21:34 ` Lucas De Marchi
  2023-05-25 23:19   ` Matt Roper
  2023-05-25 21:34 ` [Intel-xe] [PATCH v4 17/21] drm/xe/guc: Port Wa_22012727170/Wa_22012727685 " Lucas De Marchi
                   ` (6 subsequent siblings)
  22 siblings, 1 reply; 44+ messages in thread
From: Lucas De Marchi @ 2023-05-25 21:34 UTC (permalink / raw)
  To: intel-xe; +Cc: Lucas De Marchi, Matt Roper

Port Wa_16011777198 to xe_wa so it's reported as active.

Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
---
 drivers/gpu/drm/xe/xe_guc.c        | 5 +----
 drivers/gpu/drm/xe/xe_wa_oob.rules | 2 ++
 2 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/xe/xe_guc.c b/drivers/gpu/drm/xe/xe_guc.c
index 54aaf6e6b577..5eccc4b67381 100644
--- a/drivers/gpu/drm/xe/xe_guc.c
+++ b/drivers/gpu/drm/xe/xe_guc.c
@@ -158,10 +158,7 @@ static u32 guc_ctl_wa_flags(struct xe_guc *guc)
 	if (GRAPHICS_VERx100(xe) < 1270)
 		flags |= GUC_WA_PRE_PARSER;
 
-	/* Wa_16011777198 */
-	if (IS_SUBPLATFORM_STEP(xe, XE_DG2, XE_SUBPLATFORM_DG2_G10, STEP_A0, STEP_C0) ||
-	    IS_SUBPLATFORM_STEP(xe, XE_DG2, XE_SUBPLATFORM_DG2_G11, STEP_A0,
-				STEP_B0))
+	if (XE_WA(gt, 16011777198))
 		flags |= GUC_WA_RCS_RESET_BEFORE_RC6;
 
 	/*
diff --git a/drivers/gpu/drm/xe/xe_wa_oob.rules b/drivers/gpu/drm/xe/xe_wa_oob.rules
index 77ac4a4a3296..3d4304b7111e 100644
--- a/drivers/gpu/drm/xe/xe_wa_oob.rules
+++ b/drivers/gpu/drm/xe/xe_wa_oob.rules
@@ -2,3 +2,5 @@
 16011759253	SUBPLATFORM(DG2, G10), GRAPHICS_STEP(A0, B0)
 22011391025	PLATFORM(DG2)
 14012197797	PLATFORM(DG2), GRAPHICS_STEP(A0, B0)
+16011777198	SUBPLATFORM(DG2, G10), GRAPHICS_STEP(A0, C0)
+		SUBPLATFORM(DG2, G11), GRAPHICS_STEP(A0, B0)
-- 
2.40.1


^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [Intel-xe] [PATCH v4 17/21] drm/xe/guc: Port Wa_22012727170/Wa_22012727685 to xe_wa
  2023-05-25 21:33 [Intel-xe] [PATCH v4 00/21] Dump + OOB workarounds Lucas De Marchi
                   ` (15 preceding siblings ...)
  2023-05-25 21:34 ` [Intel-xe] [PATCH v4 16/21] drm/xe/guc: Port Wa_16011777198 " Lucas De Marchi
@ 2023-05-25 21:34 ` Lucas De Marchi
  2023-05-25 23:25   ` Matt Roper
  2023-05-25 21:34 ` [Intel-xe] [PATCH v4 18/21] drm/xe/guc: Port Wa_16015675438/Wa_18020744125 " Lucas De Marchi
                   ` (5 subsequent siblings)
  22 siblings, 1 reply; 44+ messages in thread
From: Lucas De Marchi @ 2023-05-25 21:34 UTC (permalink / raw)
  To: intel-xe; +Cc: Lucas De Marchi, Matt Roper

Wa_22012727170 and Wa_22012727685 apply to DG2 using the same action and
conditions. Add both to the oob rules so they are both reported as
active.

Do not Wa_22012727170 to PVC and MTL since only early A* steppings are
affected.

Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
---
 drivers/gpu/drm/xe/xe_guc.c        | 8 +-------
 drivers/gpu/drm/xe/xe_wa_oob.rules | 4 ++++
 2 files changed, 5 insertions(+), 7 deletions(-)

diff --git a/drivers/gpu/drm/xe/xe_guc.c b/drivers/gpu/drm/xe/xe_guc.c
index 5eccc4b67381..1291f71348db 100644
--- a/drivers/gpu/drm/xe/xe_guc.c
+++ b/drivers/gpu/drm/xe/xe_guc.c
@@ -161,13 +161,7 @@ static u32 guc_ctl_wa_flags(struct xe_guc *guc)
 	if (XE_WA(gt, 16011777198))
 		flags |= GUC_WA_RCS_RESET_BEFORE_RC6;
 
-	/*
-	 * Wa_22012727170
-	 * Wa_22012727685
-	 */
-	if (IS_SUBPLATFORM_STEP(xe, XE_DG2, XE_SUBPLATFORM_DG2_G10, STEP_A0, STEP_C0) ||
-	    IS_SUBPLATFORM_STEP(xe, XE_DG2, XE_SUBPLATFORM_DG2_G11, STEP_A0,
-				STEP_FOREVER))
+	if (XE_WA(gt, 22012727170) || XE_WA(gt, 22012727685))
 		flags |= GUC_WA_CONTEXT_ISOLATION;
 
 	/* Wa_16015675438, Wa_18020744125 */
diff --git a/drivers/gpu/drm/xe/xe_wa_oob.rules b/drivers/gpu/drm/xe/xe_wa_oob.rules
index 3d4304b7111e..fecf9dd431c5 100644
--- a/drivers/gpu/drm/xe/xe_wa_oob.rules
+++ b/drivers/gpu/drm/xe/xe_wa_oob.rules
@@ -4,3 +4,7 @@
 14012197797	PLATFORM(DG2), GRAPHICS_STEP(A0, B0)
 16011777198	SUBPLATFORM(DG2, G10), GRAPHICS_STEP(A0, C0)
 		SUBPLATFORM(DG2, G11), GRAPHICS_STEP(A0, B0)
+22012727170	SUBPLATFORM(DG2, G10), GRAPHICS_STEP(A0, C0)
+		SUBPLATFORM(DG2, G11), GRAPHICS_STEP(A0, FOREVER)
+22012727685	SUBPLATFORM(DG2, G10), GRAPHICS_STEP(A0, C0)
+		SUBPLATFORM(DG2, G11), GRAPHICS_STEP(A0, FOREVER)
-- 
2.40.1


^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [Intel-xe] [PATCH v4 18/21] drm/xe/guc: Port Wa_16015675438/Wa_18020744125 to xe_wa
  2023-05-25 21:33 [Intel-xe] [PATCH v4 00/21] Dump + OOB workarounds Lucas De Marchi
                   ` (16 preceding siblings ...)
  2023-05-25 21:34 ` [Intel-xe] [PATCH v4 17/21] drm/xe/guc: Port Wa_22012727170/Wa_22012727685 " Lucas De Marchi
@ 2023-05-25 21:34 ` Lucas De Marchi
  2023-05-25 23:28   ` Matt Roper
  2023-05-25 21:34 ` [Intel-xe] [PATCH v4 19/21] drm/xe/guc: Port Wa_1509372804 " Lucas De Marchi
                   ` (4 subsequent siblings)
  22 siblings, 1 reply; 44+ messages in thread
From: Lucas De Marchi @ 2023-05-25 21:34 UTC (permalink / raw)
  To: intel-xe; +Cc: Lucas De Marchi, Matt Roper

Wa_16015675438 and Wa_18020744125 apply to DG2 using the same action and
conditions. Add both to the oob rules so they are both reported as
active. Note that previously they were not checking by platform or IP
version, hence making them not future-proof.  Those workarounds should
only be active in PVC and DG2, besides the check for "no render engine".

Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
---
 drivers/gpu/drm/xe/xe_guc.c        | 4 ++--
 drivers/gpu/drm/xe/xe_wa_oob.rules | 3 +++
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/xe/xe_guc.c b/drivers/gpu/drm/xe/xe_guc.c
index 1291f71348db..cc58a2092236 100644
--- a/drivers/gpu/drm/xe/xe_guc.c
+++ b/drivers/gpu/drm/xe/xe_guc.c
@@ -164,8 +164,8 @@ static u32 guc_ctl_wa_flags(struct xe_guc *guc)
 	if (XE_WA(gt, 22012727170) || XE_WA(gt, 22012727685))
 		flags |= GUC_WA_CONTEXT_ISOLATION;
 
-	/* Wa_16015675438, Wa_18020744125 */
-	if (!xe_hw_engine_mask_per_class(gt, XE_ENGINE_CLASS_RENDER))
+	if ((XE_WA(gt, 16015675438) || XE_WA(gt, 18020744125)) &&
+	    !xe_hw_engine_mask_per_class(gt, XE_ENGINE_CLASS_RENDER))
 		flags |= GUC_WA_RCS_REGS_IN_CCS_REGS_LIST;
 
 	/* Wa_1509372804 */
diff --git a/drivers/gpu/drm/xe/xe_wa_oob.rules b/drivers/gpu/drm/xe/xe_wa_oob.rules
index fecf9dd431c5..05c821a50680 100644
--- a/drivers/gpu/drm/xe/xe_wa_oob.rules
+++ b/drivers/gpu/drm/xe/xe_wa_oob.rules
@@ -8,3 +8,6 @@
 		SUBPLATFORM(DG2, G11), GRAPHICS_STEP(A0, FOREVER)
 22012727685	SUBPLATFORM(DG2, G10), GRAPHICS_STEP(A0, C0)
 		SUBPLATFORM(DG2, G11), GRAPHICS_STEP(A0, FOREVER)
+16015675438	PLATFORM(PVC)
+		PLATFORM(DG2)
+18020744125	PLATFORM(PVC)
-- 
2.40.1


^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [Intel-xe] [PATCH v4 19/21] drm/xe/guc: Port Wa_1509372804 to xe_wa
  2023-05-25 21:33 [Intel-xe] [PATCH v4 00/21] Dump + OOB workarounds Lucas De Marchi
                   ` (17 preceding siblings ...)
  2023-05-25 21:34 ` [Intel-xe] [PATCH v4 18/21] drm/xe/guc: Port Wa_16015675438/Wa_18020744125 " Lucas De Marchi
@ 2023-05-25 21:34 ` Lucas De Marchi
  2023-05-25 23:30   ` Matt Roper
  2023-05-25 21:34 ` [Intel-xe] [PATCH v4 20/21] drm/xe/rtp: Also check gt type Lucas De Marchi
                   ` (3 subsequent siblings)
  22 siblings, 1 reply; 44+ messages in thread
From: Lucas De Marchi @ 2023-05-25 21:34 UTC (permalink / raw)
  To: intel-xe; +Cc: Lucas De Marchi, Matt Roper

Port Wa_1509372804 to xe_wa so it's reported as active.

Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
---
 drivers/gpu/drm/xe/xe_guc.c        | 3 +--
 drivers/gpu/drm/xe/xe_wa_oob.rules | 1 +
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/xe/xe_guc.c b/drivers/gpu/drm/xe/xe_guc.c
index cc58a2092236..3ed460d3b6ca 100644
--- a/drivers/gpu/drm/xe/xe_guc.c
+++ b/drivers/gpu/drm/xe/xe_guc.c
@@ -168,8 +168,7 @@ static u32 guc_ctl_wa_flags(struct xe_guc *guc)
 	    !xe_hw_engine_mask_per_class(gt, XE_ENGINE_CLASS_RENDER))
 		flags |= GUC_WA_RCS_REGS_IN_CCS_REGS_LIST;
 
-	/* Wa_1509372804 */
-	if (IS_PLATFORM_STEP(xe, XE_PVC, STEP_B0, STEP_C0))
+	if (XE_WA(gt, 1509372804))
 		flags |= GUC_WA_RENDER_RST_RC6_EXIT;
 
 	return flags;
diff --git a/drivers/gpu/drm/xe/xe_wa_oob.rules b/drivers/gpu/drm/xe/xe_wa_oob.rules
index 05c821a50680..fc9846af460c 100644
--- a/drivers/gpu/drm/xe/xe_wa_oob.rules
+++ b/drivers/gpu/drm/xe/xe_wa_oob.rules
@@ -11,3 +11,4 @@
 16015675438	PLATFORM(PVC)
 		PLATFORM(DG2)
 18020744125	PLATFORM(PVC)
+1509372804	PLATFORM(PVC), GRAPHICS_STEP(B0, C0)
-- 
2.40.1


^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [Intel-xe] [PATCH v4 20/21] drm/xe/rtp: Also check gt type
  2023-05-25 21:33 [Intel-xe] [PATCH v4 00/21] Dump + OOB workarounds Lucas De Marchi
                   ` (18 preceding siblings ...)
  2023-05-25 21:34 ` [Intel-xe] [PATCH v4 19/21] drm/xe/guc: Port Wa_1509372804 " Lucas De Marchi
@ 2023-05-25 21:34 ` Lucas De Marchi
  2023-05-25 23:34   ` Matt Roper
  2023-05-25 21:34 ` [Intel-xe] [PATCH v4 21/21] drm/xe/guc: Port Wa_14014475959 to xe_wa and fix it Lucas De Marchi
                   ` (2 subsequent siblings)
  22 siblings, 1 reply; 44+ messages in thread
From: Lucas De Marchi @ 2023-05-25 21:34 UTC (permalink / raw)
  To: intel-xe; +Cc: Lucas De Marchi, Matt Roper

When running rules on MTL and beyond that have media as a standalone GT,
the rule should only match if the gt passed as parameter match the
version/range/stepping that the rule is checking. This allows
workarounds affecting only the media GT to be applied only on that GT
and vice-versa.

For platforms before MTL, the GT will not be of media type, even if it
includes media engines. Make sure to cover that case by checking if the
platforma has standalone media.

Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
---
 drivers/gpu/drm/xe/xe_rtp.c | 23 +++++++++++++++++------
 1 file changed, 17 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/xe/xe_rtp.c b/drivers/gpu/drm/xe/xe_rtp.c
index ebcfb04c391a..43a86358efb6 100644
--- a/drivers/gpu/drm/xe/xe_rtp.c
+++ b/drivers/gpu/drm/xe/xe_rtp.c
@@ -23,6 +23,11 @@
  * the values to the registers that have matching rules.
  */
 
+static bool has_samedia(const struct xe_device *xe)
+{
+	return xe->info.media_verx100 >= 1300;
+}
+
 static bool rule_matches(const struct xe_device *xe,
 			 struct xe_gt *gt,
 			 struct xe_hw_engine *hwe,
@@ -43,26 +48,32 @@ static bool rule_matches(const struct xe_device *xe,
 				xe->info.subplatform == r->subplatform;
 			break;
 		case XE_RTP_MATCH_GRAPHICS_VERSION:
-			match = xe->info.graphics_verx100 == r->ver_start;
+			match = xe->info.graphics_verx100 == r->ver_start &&
+				(!has_samedia(xe) || !xe_gt_is_media_type(gt));
 			break;
 		case XE_RTP_MATCH_GRAPHICS_VERSION_RANGE:
 			match = xe->info.graphics_verx100 >= r->ver_start &&
-				xe->info.graphics_verx100 <= r->ver_end;
+				xe->info.graphics_verx100 <= r->ver_end &&
+				(!has_samedia(xe) || !xe_gt_is_media_type(gt));
 			break;
 		case XE_RTP_MATCH_GRAPHICS_STEP:
 			match = xe->info.step.graphics >= r->step_start &&
-				xe->info.step.graphics < r->step_end;
+				xe->info.step.graphics < r->step_end &&
+				(!has_samedia(xe) || !xe_gt_is_media_type(gt));
 			break;
 		case XE_RTP_MATCH_MEDIA_VERSION:
-			match = xe->info.media_verx100 == r->ver_start;
+			match = xe->info.media_verx100 == r->ver_start &&
+				(!has_samedia(xe) || xe_gt_is_media_type(gt));
 			break;
 		case XE_RTP_MATCH_MEDIA_VERSION_RANGE:
 			match = xe->info.media_verx100 >= r->ver_start &&
-				xe->info.media_verx100 <= r->ver_end;
+				xe->info.media_verx100 <= r->ver_end &&
+				(!has_samedia(xe) || xe_gt_is_media_type(gt));
 			break;
 		case XE_RTP_MATCH_MEDIA_STEP:
 			match = xe->info.step.media >= r->step_start &&
-				xe->info.step.media < r->step_end;
+				xe->info.step.media < r->step_end &&
+				(!has_samedia(xe) || xe_gt_is_media_type(gt));
 			break;
 		case XE_RTP_MATCH_INTEGRATED:
 			match = !xe->info.is_dgfx;
-- 
2.40.1


^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [Intel-xe] [PATCH v4 21/21] drm/xe/guc: Port Wa_14014475959 to xe_wa and fix it
  2023-05-25 21:33 [Intel-xe] [PATCH v4 00/21] Dump + OOB workarounds Lucas De Marchi
                   ` (19 preceding siblings ...)
  2023-05-25 21:34 ` [Intel-xe] [PATCH v4 20/21] drm/xe/rtp: Also check gt type Lucas De Marchi
@ 2023-05-25 21:34 ` Lucas De Marchi
  2023-05-25 23:35   ` Matt Roper
  2023-05-25 21:38 ` [Intel-xe] ✓ CI.Patch_applied: success for Dump + OOB workarounds Patchwork
  2023-05-25 21:39 ` [Intel-xe] ✗ CI.KUnit: failure " Patchwork
  22 siblings, 1 reply; 44+ messages in thread
From: Lucas De Marchi @ 2023-05-25 21:34 UTC (permalink / raw)
  To: intel-xe; +Cc: Lucas De Marchi, Matt Roper

Port Wa_14014475959 to xe_wa fixing its condition. The workaround should
only be applied on the primary GT, not on media. So just checking by
MTL platform is not enough: checking GT is of the right type is also
needed.

Since the GRAPHICS_STEP() does checks the GT type, we could leave the
first check as a platform one: it'd would be easier to understand and
not go out of sync with the graphics_ip_map[] in
drivers/gpu/drm/xe/xe_pci.c. However it also means that new platforms
using the same IP wouldn't match. Prefer using the IP version.

Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
---
 drivers/gpu/drm/xe/xe_guc.c        | 4 +---
 drivers/gpu/drm/xe/xe_wa_oob.rules | 2 ++
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/xe/xe_guc.c b/drivers/gpu/drm/xe/xe_guc.c
index 3ed460d3b6ca..ecc843d91f62 100644
--- a/drivers/gpu/drm/xe/xe_guc.c
+++ b/drivers/gpu/drm/xe/xe_guc.c
@@ -142,9 +142,7 @@ static u32 guc_ctl_wa_flags(struct xe_guc *guc)
 	if (XE_WA(gt, 16011759253))
 		flags |= GUC_WA_GAM_CREDITS;
 
-	/* Wa_14014475959 */
-	if (IS_PLATFORM_STEP(xe, XE_METEORLAKE, STEP_A0, STEP_B0) ||
-	    xe->info.platform == XE_DG2)
+	if (XE_WA(gt, 14014475959))
 		flags |= GUC_WA_HOLD_CCS_SWITCHOUT;
 
 	if (XE_WA(gt, 22011391025) || XE_WA(gt, 14012197797))
diff --git a/drivers/gpu/drm/xe/xe_wa_oob.rules b/drivers/gpu/drm/xe/xe_wa_oob.rules
index fc9846af460c..c58f3eb3e993 100644
--- a/drivers/gpu/drm/xe/xe_wa_oob.rules
+++ b/drivers/gpu/drm/xe/xe_wa_oob.rules
@@ -1,5 +1,7 @@
 22012773006	GRAPHICS_VERSION_RANGE(1200, 1250)
 16011759253	SUBPLATFORM(DG2, G10), GRAPHICS_STEP(A0, B0)
+14014475959	GRAPHICS_VERSION_RANGE(1270, 1271), GRAPHICS_STEP(A0, B0)
+		PLATFORM(DG2)
 22011391025	PLATFORM(DG2)
 14012197797	PLATFORM(DG2), GRAPHICS_STEP(A0, B0)
 16011777198	SUBPLATFORM(DG2, G10), GRAPHICS_STEP(A0, C0)
-- 
2.40.1


^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [Intel-xe] ✓ CI.Patch_applied: success for Dump + OOB workarounds
  2023-05-25 21:33 [Intel-xe] [PATCH v4 00/21] Dump + OOB workarounds Lucas De Marchi
                   ` (20 preceding siblings ...)
  2023-05-25 21:34 ` [Intel-xe] [PATCH v4 21/21] drm/xe/guc: Port Wa_14014475959 to xe_wa and fix it Lucas De Marchi
@ 2023-05-25 21:38 ` Patchwork
  2023-05-25 21:39 ` [Intel-xe] ✗ CI.KUnit: failure " Patchwork
  22 siblings, 0 replies; 44+ messages in thread
From: Patchwork @ 2023-05-25 21:38 UTC (permalink / raw)
  To: Lucas De Marchi; +Cc: intel-xe

== Series Details ==

Series: Dump + OOB workarounds
URL   : https://patchwork.freedesktop.org/series/118399/
State : success

== Summary ==

=== Applying kernel patches on branch 'drm-xe-next' with base: ===
Base commit: c6e45ef45 drm/xe: Add stepping support for GMD_ID platforms
=== git am output follows ===
Applying: drm/xe: Fix Wa_22011802037 annotation
Applying: drm/xe/rtp: Split rtp process initialization
Applying: drm/xe/rtp: Replace XE_WARN_ON
Applying: drm/xe/rtp: Add "_sr" to entry/function names
Applying: drm/xe/rtp: Allow to track active workarounds
Applying: drm/xe/wa: Track gt/engine/lrc active workarounds
Applying: drm/xe/debugfs: Dump active workarounds
Applying: drm/xe/rtp: Rename STEP to GRAPHICS_STEP
Applying: drm/xe/rtp: Add check for media stepping
Applying: drm/xe/rtp: Add support for entries with no action
Applying: drm/xe: Include build directory
Applying: drm/xe: Add support for OOB workarounds
Applying: drm/xe/guc: Port Wa_22012773006 to xe_wa
Applying: drm/xe/guc: Port Wa_16011759253 to xe_wa
Applying: drm/xe/guc: Port Wa_14012197797/Wa_22011391025 to xe_wa
Applying: drm/xe/guc: Port Wa_16011777198 to xe_wa
Applying: drm/xe/guc: Port Wa_22012727170/Wa_22012727685 to xe_wa
Applying: drm/xe/guc: Port Wa_16015675438/Wa_18020744125 to xe_wa
Applying: drm/xe/guc: Port Wa_1509372804 to xe_wa
Applying: drm/xe/rtp: Also check gt type
Applying: drm/xe/guc: Port Wa_14014475959 to xe_wa and fix it



^ permalink raw reply	[flat|nested] 44+ messages in thread

* [Intel-xe] ✗ CI.KUnit: failure for Dump + OOB workarounds
  2023-05-25 21:33 [Intel-xe] [PATCH v4 00/21] Dump + OOB workarounds Lucas De Marchi
                   ` (21 preceding siblings ...)
  2023-05-25 21:38 ` [Intel-xe] ✓ CI.Patch_applied: success for Dump + OOB workarounds Patchwork
@ 2023-05-25 21:39 ` Patchwork
  2023-05-25 21:44   ` Lucas De Marchi
  22 siblings, 1 reply; 44+ messages in thread
From: Patchwork @ 2023-05-25 21:39 UTC (permalink / raw)
  To: Lucas De Marchi; +Cc: intel-xe

== Series Details ==

Series: Dump + OOB workarounds
URL   : https://patchwork.freedesktop.org/series/118399/
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_guc.c:8:10: fatal error: generated/xe_wa_oob.h: No such file or directory
    8 | #include "generated/xe_wa_oob.h"
      |          ^~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
make[6]: *** [../scripts/Makefile.build:252: drivers/gpu/drm/xe/xe_guc.o] Error 1
make[6]: *** Waiting for unfinished jobs....
make[5]: *** [../scripts/Makefile.build:494: drivers/gpu/drm/xe] Error 2
make[5]: *** Waiting for unfinished jobs....
make[4]: *** [../scripts/Makefile.build:494: drivers/gpu/drm] Error 2
make[3]: *** [../scripts/Makefile.build:494: drivers/gpu] Error 2
make[2]: *** [../scripts/Makefile.build:494: drivers] Error 2
make[2]: *** Waiting for unfinished jobs....
make[1]: *** [/kernel/Makefile:2025: .] Error 2
make: *** [Makefile:226: __sub-make] Error 2

[21:38:39] Configuring KUnit Kernel ...
Generating .config ...
Populating config with:
$ make ARCH=um O=.kunit olddefconfig
[21:38:44] Building KUnit Kernel ...
Populating config with:
$ make ARCH=um O=.kunit olddefconfig
Building with:
$ make ARCH=um O=.kunit --jobs=48
+ cleanup
++ stat -c %u:%g /kernel
+ chown -R 1003:1003 /kernel



^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: [Intel-xe]  ✗ CI.KUnit: failure for Dump + OOB workarounds
  2023-05-25 21:39 ` [Intel-xe] ✗ CI.KUnit: failure " Patchwork
@ 2023-05-25 21:44   ` Lucas De Marchi
  0 siblings, 0 replies; 44+ messages in thread
From: Lucas De Marchi @ 2023-05-25 21:44 UTC (permalink / raw)
  To: intel-xe

On Thu, May 25, 2023 at 09:39:02PM +0000, Patchwork wrote:
>== Series Details ==
>
>Series: Dump + OOB workarounds
>URL   : https://patchwork.freedesktop.org/series/118399/
>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_guc.c:8:10: fatal error: generated/xe_wa_oob.h: No such file or directory
>    8 | #include "generated/xe_wa_oob.h"
>      |          ^~~~~~~~~~~~~~~~~~~~~~~

./tools/testing/kunit/kunit.py run --kunitconfig drivers/gpu/drm/xe/.kunitconfig

this passes consistently for me, and also building it out of tree

Lucas De Marchi

>compilation terminated.
>make[6]: *** [../scripts/Makefile.build:252: drivers/gpu/drm/xe/xe_guc.o] Error 1
>make[6]: *** Waiting for unfinished jobs....
>make[5]: *** [../scripts/Makefile.build:494: drivers/gpu/drm/xe] Error 2
>make[5]: *** Waiting for unfinished jobs....
>make[4]: *** [../scripts/Makefile.build:494: drivers/gpu/drm] Error 2
>make[3]: *** [../scripts/Makefile.build:494: drivers/gpu] Error 2
>make[2]: *** [../scripts/Makefile.build:494: drivers] Error 2
>make[2]: *** Waiting for unfinished jobs....
>make[1]: *** [/kernel/Makefile:2025: .] Error 2
>make: *** [Makefile:226: __sub-make] Error 2
>
>[21:38:39] Configuring KUnit Kernel ...
>Generating .config ...
>Populating config with:
>$ make ARCH=um O=.kunit olddefconfig
>[21:38:44] Building KUnit Kernel ...
>Populating config with:
>$ make ARCH=um O=.kunit olddefconfig
>Building with:
>$ make ARCH=um O=.kunit --jobs=48
>+ cleanup
>++ stat -c %u:%g /kernel
>+ chown -R 1003:1003 /kernel
>
>

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: [Intel-xe] [PATCH v4 03/21] drm/xe/rtp: Replace XE_WARN_ON
  2023-05-25 21:33 ` [Intel-xe] [PATCH v4 03/21] drm/xe/rtp: Replace XE_WARN_ON Lucas De Marchi
@ 2023-05-25 22:18   ` Matt Roper
  0 siblings, 0 replies; 44+ messages in thread
From: Matt Roper @ 2023-05-25 22:18 UTC (permalink / raw)
  To: Lucas De Marchi; +Cc: intel-xe

On Thu, May 25, 2023 at 02:33:49PM -0700, Lucas De Marchi wrote:
> Now that rule_matches() always has an xe pointer, replace the XE_WARN_ON
> with the more appropriate drm_warn().
> 
> Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>

Reviewed-by: Matt Roper <matthew.d.roper@intel.com>

> ---
>  drivers/gpu/drm/xe/xe_rtp.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/xe/xe_rtp.c b/drivers/gpu/drm/xe/xe_rtp.c
> index 5be25fe0e8e4..5dcdfe45f0cb 100644
> --- a/drivers/gpu/drm/xe/xe_rtp.c
> +++ b/drivers/gpu/drm/xe/xe_rtp.c
> @@ -84,7 +84,9 @@ static bool rule_matches(const struct xe_device *xe,
>  			match = r->match_func(gt, hwe);
>  			break;
>  		default:
> -			XE_WARN_ON(r->match_type);
> +			drm_warn(&xe->drm, "Invalid RTP match %u\n",
> +				 r->match_type);
> +			match = false;
>  		}
>  
>  		if (!match)
> -- 
> 2.40.1
> 

-- 
Matt Roper
Graphics Software Engineer
Linux GPU Platform Enablement
Intel Corporation

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: [Intel-xe] [PATCH v4 06/21] drm/xe/wa: Track gt/engine/lrc active workarounds
  2023-05-25 21:33 ` [Intel-xe] [PATCH v4 06/21] drm/xe/wa: Track gt/engine/lrc " Lucas De Marchi
@ 2023-05-25 22:28   ` Matt Roper
  0 siblings, 0 replies; 44+ messages in thread
From: Matt Roper @ 2023-05-25 22:28 UTC (permalink / raw)
  To: Lucas De Marchi; +Cc: intel-xe

On Thu, May 25, 2023 at 02:33:52PM -0700, Lucas De Marchi wrote:
> Allocate the data to track workarounds on each gt of the device,
> and pass that to RTP so the active workarounds are tracked.
> 
> Even if the workarounds available until know are mostly device

s/know/now/

> or platform centric, with the different IP versions for media and
> graphics starting with MTL, it's possible that some workarounds
> need to be applied only on select GTs. Also, given the workaround
> database is per IP block, for tracking purposes there is no need to
> differentiate the workarounds per engine class. Hence the bitmask
> tro track active workarounds can be tracked per GT.

s/tro/to/

> 
> v2: Move the tracking from per-device to per-GT basis (Matt Roper)
> 
> Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
> ---
>  drivers/gpu/drm/xe/xe_gt.c       |  5 +++++
>  drivers/gpu/drm/xe/xe_gt_types.h | 10 +++++++++
>  drivers/gpu/drm/xe/xe_wa.c       | 37 ++++++++++++++++++++++++++++++++
>  drivers/gpu/drm/xe/xe_wa.h       |  1 +
>  4 files changed, 53 insertions(+)
> 
> diff --git a/drivers/gpu/drm/xe/xe_gt.c b/drivers/gpu/drm/xe/xe_gt.c
> index 80d42c7c7cfa..d139554316d4 100644
> --- a/drivers/gpu/drm/xe/xe_gt.c
> +++ b/drivers/gpu/drm/xe/xe_gt.c
> @@ -315,6 +315,11 @@ int xe_gt_init_early(struct xe_gt *gt)
>  		return err;
>  
>  	xe_reg_sr_init(&gt->reg_sr, "GT", gt_to_xe(gt));
> +
> +	err = xe_wa_init(gt);
> +	if (err)
> +		return err;
> +
>  	xe_wa_process_gt(gt);
>  	xe_tuning_process_gt(gt);
>  
> diff --git a/drivers/gpu/drm/xe/xe_gt_types.h b/drivers/gpu/drm/xe/xe_gt_types.h
> index 7c47d67aa8be..017ab60f2498 100644
> --- a/drivers/gpu/drm/xe/xe_gt_types.h
> +++ b/drivers/gpu/drm/xe/xe_gt_types.h
> @@ -359,6 +359,16 @@ struct xe_gt {
>  	 *    of a steered operation
>  	 */
>  	spinlock_t mcr_lock;
> +
> +	/** @wa_active: keep track of active workarounds */
> +	struct {
> +		/** @gt: bitmap with active GT workarounds */
> +		unsigned long *gt;
> +		/** @engine: bitmap with active engine workarounds */
> +		unsigned long *engine;
> +		/** @lrc: bitmap with active LRC workarounds */
> +		unsigned long *lrc;
> +	} wa_active;
>  };
>  
>  #endif
> diff --git a/drivers/gpu/drm/xe/xe_wa.c b/drivers/gpu/drm/xe/xe_wa.c
> index 557e90d79f0b..3e2a3f678f36 100644
> --- a/drivers/gpu/drm/xe/xe_wa.c
> +++ b/drivers/gpu/drm/xe/xe_wa.c
> @@ -5,6 +5,7 @@
>  
>  #include "xe_wa.h"
>  
> +#include <drm/drm_managed.h>
>  #include <kunit/visibility.h>
>  #include <linux/compiler_types.h>
>  
> @@ -581,6 +582,8 @@ void xe_wa_process_gt(struct xe_gt *gt)
>  {
>  	struct xe_rtp_process_ctx ctx = XE_RTP_PROCESS_CTX_INITIALIZER(gt);
>  
> +	xe_rtp_process_ctx_enable_active_tracking(&ctx, gt->wa_active.gt,
> +						  ARRAY_SIZE(gt_was));
>  	xe_rtp_process_to_sr(&ctx, gt_was, &gt->reg_sr);
>  }
>  EXPORT_SYMBOL_IF_KUNIT(xe_wa_process_gt);
> @@ -597,6 +600,8 @@ void xe_wa_process_engine(struct xe_hw_engine *hwe)
>  {
>  	struct xe_rtp_process_ctx ctx = XE_RTP_PROCESS_CTX_INITIALIZER(hwe);
>  
> +	xe_rtp_process_ctx_enable_active_tracking(&ctx, hwe->gt->wa_active.engine,
> +						  ARRAY_SIZE(engine_was));
>  	xe_rtp_process_to_sr(&ctx, engine_was, &hwe->reg_sr);
>  }
>  
> @@ -612,5 +617,37 @@ void xe_wa_process_lrc(struct xe_hw_engine *hwe)
>  {
>  	struct xe_rtp_process_ctx ctx = XE_RTP_PROCESS_CTX_INITIALIZER(hwe);
>  
> +	xe_rtp_process_ctx_enable_active_tracking(&ctx, hwe->gt->wa_active.lrc,
> +						  ARRAY_SIZE(lrc_was));
>  	xe_rtp_process_to_sr(&ctx, lrc_was, &hwe->reg_lrc);
>  }
> +
> +/**
> + * xe_wa_init - initialize xe with workaround bookkeeping

s/xe/gt/

Aside from the typos,

        Reviewed-by: Matt Roper <matthew.d.roper@intel.com>

> + * @gt: GT instance to initialize
> + *
> + * Returns 0 for success, negative error code otherwise.
> + */
> +int xe_wa_init(struct xe_gt *gt)
> +{
> +	struct xe_device *xe = gt_to_xe(gt);
> +	size_t n_lrc, n_engine, n_gt, total;
> +	unsigned long *p;
> +
> +	n_gt = BITS_TO_LONGS(ARRAY_SIZE(gt_was));
> +	n_engine = BITS_TO_LONGS(ARRAY_SIZE(engine_was));
> +	n_lrc = BITS_TO_LONGS(ARRAY_SIZE(lrc_was));
> +	total = n_gt + n_engine + n_lrc;
> +
> +	p = drmm_kzalloc(&xe->drm, sizeof(*p) * total, GFP_KERNEL);
> +	if (!p)
> +		return -ENOMEM;
> +
> +	gt->wa_active.gt = p;
> +	p += n_gt;
> +	gt->wa_active.engine = p;
> +	p += n_engine;
> +	gt->wa_active.lrc = p;
> +
> +	return 0;
> +}
> diff --git a/drivers/gpu/drm/xe/xe_wa.h b/drivers/gpu/drm/xe/xe_wa.h
> index cd2307d58795..eae05bcecc68 100644
> --- a/drivers/gpu/drm/xe/xe_wa.h
> +++ b/drivers/gpu/drm/xe/xe_wa.h
> @@ -9,6 +9,7 @@
>  struct xe_gt;
>  struct xe_hw_engine;
>  
> +int xe_wa_init(struct xe_gt *gt);
>  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);
> -- 
> 2.40.1
> 

-- 
Matt Roper
Graphics Software Engineer
Linux GPU Platform Enablement
Intel Corporation

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: [Intel-xe] [PATCH v4 07/21] drm/xe/debugfs: Dump active workarounds
  2023-05-25 21:33 ` [Intel-xe] [PATCH v4 07/21] drm/xe/debugfs: Dump " Lucas De Marchi
@ 2023-05-25 22:29   ` Matt Roper
  0 siblings, 0 replies; 44+ messages in thread
From: Matt Roper @ 2023-05-25 22:29 UTC (permalink / raw)
  To: Lucas De Marchi; +Cc: intel-xe

On Thu, May 25, 2023 at 02:33:53PM -0700, Lucas De Marchi wrote:
> Add a "workarounds" node in debugfs that can dump all the active
> workarounds using the information recorded by rtp infra when those
> workarounds were processed.
> 
> v2: move workarounds to be reported per-GT
> 
> Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>

Reviewed-by: Matt Roper <matthew.d.roper@intel.com>

> ---
>  drivers/gpu/drm/xe/xe_gt_debugfs.c | 12 ++++++++++++
>  drivers/gpu/drm/xe/xe_wa.c         | 17 +++++++++++++++++
>  drivers/gpu/drm/xe/xe_wa.h         |  2 ++
>  3 files changed, 31 insertions(+)
> 
> diff --git a/drivers/gpu/drm/xe/xe_gt_debugfs.c b/drivers/gpu/drm/xe/xe_gt_debugfs.c
> index 8bf441e850a0..339ecd5fad9b 100644
> --- a/drivers/gpu/drm/xe/xe_gt_debugfs.c
> +++ b/drivers/gpu/drm/xe/xe_gt_debugfs.c
> @@ -19,6 +19,7 @@
>  #include "xe_reg_sr.h"
>  #include "xe_reg_whitelist.h"
>  #include "xe_uc_debugfs.h"
> +#include "xe_wa.h"
>  
>  static struct xe_gt *node_to_gt(struct drm_info_node *node)
>  {
> @@ -127,6 +128,16 @@ static int register_save_restore(struct seq_file *m, void *data)
>  	return 0;
>  }
>  
> +static int workarounds(struct seq_file *m, void *data)
> +{
> +	struct xe_gt *gt = node_to_gt(m->private);
> +	struct drm_printer p = drm_seq_file_printer(m);
> +
> +	xe_wa_dump(gt, &p);
> +
> +	return 0;
> +}
> +
>  static const struct drm_info_list debugfs_list[] = {
>  	{"hw_engines", hw_engines, 0},
>  	{"force_reset", force_reset, 0},
> @@ -135,6 +146,7 @@ static const struct drm_info_list debugfs_list[] = {
>  	{"steering", steering, 0},
>  	{"ggtt", ggtt, 0},
>  	{"register-save-restore", register_save_restore, 0},
> +	{"workarounds", workarounds, 0},
>  };
>  
>  void xe_gt_debugfs_register(struct xe_gt *gt)
> diff --git a/drivers/gpu/drm/xe/xe_wa.c b/drivers/gpu/drm/xe/xe_wa.c
> index 3e2a3f678f36..f578544c7646 100644
> --- a/drivers/gpu/drm/xe/xe_wa.c
> +++ b/drivers/gpu/drm/xe/xe_wa.c
> @@ -651,3 +651,20 @@ int xe_wa_init(struct xe_gt *gt)
>  
>  	return 0;
>  }
> +
> +void xe_wa_dump(struct xe_gt *gt, struct drm_printer *p)
> +{
> +	size_t idx;
> +
> +	drm_printf(p, "GT Workarounds\n");
> +	for_each_set_bit(idx, gt->wa_active.gt, ARRAY_SIZE(gt_was))
> +		drm_printf_indent(p, 1, "%s\n", gt_was[idx].name);
> +
> +	drm_printf(p, "\nEngine Workarounds\n");
> +	for_each_set_bit(idx, gt->wa_active.engine, ARRAY_SIZE(engine_was))
> +		drm_printf_indent(p, 1, "%s\n", engine_was[idx].name);
> +
> +	drm_printf(p, "\nLRC Workarounds\n");
> +	for_each_set_bit(idx, gt->wa_active.lrc, ARRAY_SIZE(lrc_was))
> +		drm_printf_indent(p, 1, "%s\n", lrc_was[idx].name);
> +}
> diff --git a/drivers/gpu/drm/xe/xe_wa.h b/drivers/gpu/drm/xe/xe_wa.h
> index eae05bcecc68..defefa5d9611 100644
> --- a/drivers/gpu/drm/xe/xe_wa.h
> +++ b/drivers/gpu/drm/xe/xe_wa.h
> @@ -6,6 +6,7 @@
>  #ifndef _XE_WA_
>  #define _XE_WA_
>  
> +struct drm_printer;
>  struct xe_gt;
>  struct xe_hw_engine;
>  
> @@ -15,5 +16,6 @@ void xe_wa_process_engine(struct xe_hw_engine *hwe);
>  void xe_wa_process_lrc(struct xe_hw_engine *hwe);
>  
>  void xe_reg_whitelist_process_engine(struct xe_hw_engine *hwe);
> +void xe_wa_dump(struct xe_gt *gt, struct drm_printer *p);
>  
>  #endif
> -- 
> 2.40.1
> 

-- 
Matt Roper
Graphics Software Engineer
Linux GPU Platform Enablement
Intel Corporation

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: [Intel-xe] [PATCH v4 08/21] drm/xe/rtp: Rename STEP to GRAPHICS_STEP
  2023-05-25 21:33 ` [Intel-xe] [PATCH v4 08/21] drm/xe/rtp: Rename STEP to GRAPHICS_STEP Lucas De Marchi
@ 2023-05-25 22:31   ` Matt Roper
  0 siblings, 0 replies; 44+ messages in thread
From: Matt Roper @ 2023-05-25 22:31 UTC (permalink / raw)
  To: Lucas De Marchi; +Cc: intel-xe

On Thu, May 25, 2023 at 02:33:54PM -0700, Lucas De Marchi wrote:
> Rename the RTP match in order to prepare the code base to check for the
> media version. Up until MTL, the graphics vs media distinction wrt to
> stepping was not ver relevant as they were the same GT. However, with
> MTL this is no longer true.
> 
> Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>

Reviewed-by: Matt Roper <matthew.d.roper@intel.com>

> ---
>  drivers/gpu/drm/xe/xe_rtp.c       |  2 +-
>  drivers/gpu/drm/xe/xe_rtp.h       | 16 ++++----
>  drivers/gpu/drm/xe/xe_rtp_types.h |  2 +-
>  drivers/gpu/drm/xe/xe_wa.c        | 64 ++++++++++++++++++-------------
>  4 files changed, 47 insertions(+), 37 deletions(-)
> 
> diff --git a/drivers/gpu/drm/xe/xe_rtp.c b/drivers/gpu/drm/xe/xe_rtp.c
> index 29cf92f9b7b3..2ac7b47942fe 100644
> --- a/drivers/gpu/drm/xe/xe_rtp.c
> +++ b/drivers/gpu/drm/xe/xe_rtp.c
> @@ -57,7 +57,7 @@ static bool rule_matches(const struct xe_device *xe,
>  			match = xe->info.media_verx100 >= r->ver_start &&
>  				xe->info.media_verx100 <= r->ver_end;
>  			break;
> -		case XE_RTP_MATCH_STEP:
> +		case XE_RTP_MATCH_GRAPHICS_STEP:
>  			/* TODO: match media/display */
>  			match = xe->info.step.graphics >= r->step_start &&
>  				xe->info.step.graphics < r->step_end;
> diff --git a/drivers/gpu/drm/xe/xe_rtp.h b/drivers/gpu/drm/xe/xe_rtp.h
> index e69f514ee6c4..7ba9d2ecab92 100644
> --- a/drivers/gpu/drm/xe/xe_rtp.h
> +++ b/drivers/gpu/drm/xe/xe_rtp.h
> @@ -35,8 +35,8 @@ struct xe_reg_sr;
>  	{ .match_type = XE_RTP_MATCH_SUBPLATFORM,				\
>  	  .platform = plat__, .subplatform = sub__ }
>  
> -#define _XE_RTP_RULE_STEP(start__, end__)					\
> -	{ .match_type = XE_RTP_MATCH_STEP,					\
> +#define _XE_RTP_RULE_GRAPHICS_STEP(start__, end__)				\
> +	{ .match_type = XE_RTP_MATCH_GRAPHICS_STEP,				\
>  	  .step_start = start__, .step_end = end__ }
>  
>  #define _XE_RTP_RULE_ENGINE_CLASS(cls__)					\
> @@ -63,17 +63,17 @@ struct xe_reg_sr;
>  	_XE_RTP_RULE_SUBPLATFORM(XE_##plat_, XE_SUBPLATFORM_##plat_##_##sub_)
>  
>  /**
> - * XE_RTP_RULE_STEP - Create rule matching platform stepping
> + * XE_RTP_RULE_GRAPHICS_STEP - Create rule matching graphics stepping
>   * @start_: First stepping matching the rule
>   * @end_: First stepping that does not match the rule
>   *
> - * Note that the range matching this rule [ @start_, @end_ ), i.e. inclusive on
> - * the left, exclusive on the right.
> + * Note that the range matching this rule is [ @start_, @end_ ), i.e. inclusive
> + * on the left, exclusive on the right.
>   *
>   * Refer to XE_RTP_RULES() for expected usage.
>   */
> -#define XE_RTP_RULE_STEP(start_, end_)						\
> -	_XE_RTP_RULE_STEP(STEP_##start_, STEP_##end_)
> +#define XE_RTP_RULE_GRAPHICS_STEP(start_, end_)					\
> +	_XE_RTP_RULE_GRAPHICS_STEP(STEP_##start_, STEP_##end_)
>  
>  /**
>   * XE_RTP_RULE_ENGINE_CLASS - Create rule matching an engine class
> @@ -317,7 +317,7 @@ struct xe_reg_sr;
>   *	const struct xe_rtp_entry_sr wa_entries[] = {
>   *		...
>   *		{ XE_RTP_NAME("test-entry"),
> - *		  XE_RTP_RULES(SUBPLATFORM(DG2, G10), STEP(A0, B0)),
> + *		  XE_RTP_RULES(SUBPLATFORM(DG2, G10), GRAPHICS_STEP(A0, B0)),
>   *		  ...
>   *		},
>   *		...
> diff --git a/drivers/gpu/drm/xe/xe_rtp_types.h b/drivers/gpu/drm/xe/xe_rtp_types.h
> index 03d97b666c64..52adbf7de752 100644
> --- a/drivers/gpu/drm/xe/xe_rtp_types.h
> +++ b/drivers/gpu/drm/xe/xe_rtp_types.h
> @@ -39,11 +39,11 @@ enum {
>  	XE_RTP_MATCH_SUBPLATFORM,
>  	XE_RTP_MATCH_GRAPHICS_VERSION,
>  	XE_RTP_MATCH_GRAPHICS_VERSION_RANGE,
> +	XE_RTP_MATCH_GRAPHICS_STEP,
>  	XE_RTP_MATCH_MEDIA_VERSION,
>  	XE_RTP_MATCH_MEDIA_VERSION_RANGE,
>  	XE_RTP_MATCH_INTEGRATED,
>  	XE_RTP_MATCH_DISCRETE,
> -	XE_RTP_MATCH_STEP,
>  	XE_RTP_MATCH_ENGINE_CLASS,
>  	XE_RTP_MATCH_NOT_ENGINE_CLASS,
>  	XE_RTP_MATCH_FUNC,
> diff --git a/drivers/gpu/drm/xe/xe_wa.c b/drivers/gpu/drm/xe/xe_wa.c
> index f578544c7646..b717e0025bd9 100644
> --- a/drivers/gpu/drm/xe/xe_wa.c
> +++ b/drivers/gpu/drm/xe/xe_wa.c
> @@ -122,7 +122,7 @@ static const struct xe_rtp_entry_sr gt_was[] = {
>  
>  	{ XE_RTP_NAME("16010515920"),
>  	  XE_RTP_RULES(SUBPLATFORM(DG2, G10),
> -		       STEP(A0, B0),
> +		       GRAPHICS_STEP(A0, B0),
>  		       ENGINE_CLASS(VIDEO_DECODE)),
>  	  XE_RTP_ACTIONS(SET(VDBOX_CGCTL3F18(0), ALNUNIT_CLKGATE_DIS)),
>  	  XE_RTP_ENTRY_FLAG(FOREACH_ENGINE),
> @@ -136,27 +136,27 @@ static const struct xe_rtp_entry_sr gt_was[] = {
>  	  XE_RTP_ACTIONS(SET(SUBSLICE_UNIT_LEVEL_CLKGATE, DSS_ROUTER_CLKGATE_DIS))
>  	},
>  	{ XE_RTP_NAME("14012362059"),
> -	  XE_RTP_RULES(SUBPLATFORM(DG2, G10), STEP(A0, B0)),
> +	  XE_RTP_RULES(SUBPLATFORM(DG2, G10), GRAPHICS_STEP(A0, B0)),
>  	  XE_RTP_ACTIONS(SET(XEHP_MERT_MOD_CTRL, FORCE_MISS_FTLB))
>  	},
>  	{ XE_RTP_NAME("14012362059"),
> -	  XE_RTP_RULES(SUBPLATFORM(DG2, G11), STEP(A0, B0)),
> +	  XE_RTP_RULES(SUBPLATFORM(DG2, G11), GRAPHICS_STEP(A0, B0)),
>  	  XE_RTP_ACTIONS(SET(XEHP_MERT_MOD_CTRL, FORCE_MISS_FTLB))
>  	},
>  	{ XE_RTP_NAME("14010948348"),
> -	  XE_RTP_RULES(SUBPLATFORM(DG2, G10), STEP(A0, B0)),
> +	  XE_RTP_RULES(SUBPLATFORM(DG2, G10), GRAPHICS_STEP(A0, B0)),
>  	  XE_RTP_ACTIONS(SET(UNSLCGCTL9430, MSQDUNIT_CLKGATE_DIS))
>  	},
>  	{ XE_RTP_NAME("14011037102"),
> -	  XE_RTP_RULES(SUBPLATFORM(DG2, G10), STEP(A0, B0)),
> +	  XE_RTP_RULES(SUBPLATFORM(DG2, G10), GRAPHICS_STEP(A0, B0)),
>  	  XE_RTP_ACTIONS(SET(UNSLCGCTL9444, LTCDD_CLKGATE_DIS))
>  	},
>  	{ XE_RTP_NAME("14011371254"),
> -	  XE_RTP_RULES(SUBPLATFORM(DG2, G10), STEP(A0, B0)),
> +	  XE_RTP_RULES(SUBPLATFORM(DG2, G10), GRAPHICS_STEP(A0, B0)),
>  	  XE_RTP_ACTIONS(SET(XEHP_SLICE_UNIT_LEVEL_CLKGATE, NODEDSS_CLKGATE_DIS))
>  	},
>  	{ XE_RTP_NAME("14011431319"),
> -	  XE_RTP_RULES(SUBPLATFORM(DG2, G10), STEP(A0, B0)),
> +	  XE_RTP_RULES(SUBPLATFORM(DG2, G10), GRAPHICS_STEP(A0, B0)),
>  	  XE_RTP_ACTIONS(SET(UNSLCGCTL9440,
>  			     GAMTLBOACS_CLKGATE_DIS |
>  			     GAMTLBVDBOX7_CLKGATE_DIS | GAMTLBVDBOX6_CLKGATE_DIS |
> @@ -176,15 +176,15 @@ static const struct xe_rtp_entry_sr gt_was[] = {
>  			     GAMTLBVEBOX1_CLKGATE_DIS | GAMTLBVEBOX0_CLKGATE_DIS))
>  	},
>  	{ XE_RTP_NAME("14010569222"),
> -	  XE_RTP_RULES(SUBPLATFORM(DG2, G10), STEP(A0, B0)),
> +	  XE_RTP_RULES(SUBPLATFORM(DG2, G10), GRAPHICS_STEP(A0, B0)),
>  	  XE_RTP_ACTIONS(SET(UNSLICE_UNIT_LEVEL_CLKGATE, GAMEDIA_CLKGATE_DIS))
>  	},
>  	{ XE_RTP_NAME("14011028019"),
> -	  XE_RTP_RULES(SUBPLATFORM(DG2, G10), STEP(A0, B0)),
> +	  XE_RTP_RULES(SUBPLATFORM(DG2, G10), GRAPHICS_STEP(A0, B0)),
>  	  XE_RTP_ACTIONS(SET(SSMCGCTL9530, RTFUNIT_CLKGATE_DIS))
>  	},
>  	{ XE_RTP_NAME("14010680813"),
> -	  XE_RTP_RULES(SUBPLATFORM(DG2, G10), STEP(A0, B0)),
> +	  XE_RTP_RULES(SUBPLATFORM(DG2, G10), GRAPHICS_STEP(A0, B0)),
>  	  XE_RTP_ACTIONS(SET(XEHP_GAMSTLB_CTRL,
>  			     CONTROL_BLOCK_CLKGATE_DIS |
>  			     EGRESS_BLOCK_CLKGATE_DIS |
> @@ -316,7 +316,7 @@ static const struct xe_rtp_entry_sr engine_was[] = {
>  			     POLYGON_TRIFAN_LINELOOP_DISABLE))
>  	},
>  	{ XE_RTP_NAME("22012826095, 22013059131"),
> -	  XE_RTP_RULES(SUBPLATFORM(DG2, G10), STEP(B0, C0),
> +	  XE_RTP_RULES(SUBPLATFORM(DG2, G10), GRAPHICS_STEP(B0, C0),
>  		       FUNC(xe_rtp_match_first_render_or_compute)),
>  	  XE_RTP_ACTIONS(FIELD_SET(LSC_CHICKEN_BIT_0_UDW,
>  				   MAXREQS_PER_BANK,
> @@ -330,7 +330,7 @@ static const struct xe_rtp_entry_sr engine_was[] = {
>  				   REG_FIELD_PREP(MAXREQS_PER_BANK, 2)))
>  	},
>  	{ XE_RTP_NAME("22013059131"),
> -	  XE_RTP_RULES(SUBPLATFORM(DG2, G10), STEP(B0, C0),
> +	  XE_RTP_RULES(SUBPLATFORM(DG2, G10), GRAPHICS_STEP(B0, C0),
>  		       FUNC(xe_rtp_match_first_render_or_compute)),
>  	  XE_RTP_ACTIONS(SET(LSC_CHICKEN_BIT_0, FORCE_1_SUB_MESSAGE_PER_FRAGMENT))
>  	},
> @@ -368,7 +368,7 @@ static const struct xe_rtp_entry_sr engine_was[] = {
>  	  XE_RTP_ACTIONS(SET(LSC_CHICKEN_BIT_0_UDW, DIS_CHAIN_2XSIMD8))
>  	},
>  	{ XE_RTP_NAME("22012654132"),
> -	  XE_RTP_RULES(SUBPLATFORM(DG2, G10), STEP(A0, C0),
> +	  XE_RTP_RULES(SUBPLATFORM(DG2, G10), GRAPHICS_STEP(A0, C0),
>  		       FUNC(xe_rtp_match_first_render_or_compute)),
>  	  XE_RTP_ACTIONS(SET(CACHE_MODE_SS, ENABLE_PREFETCH_INTO_IC,
>  			     /*
> @@ -396,21 +396,25 @@ static const struct xe_rtp_entry_sr engine_was[] = {
>  	  XE_RTP_ACTIONS(SET(ROW_CHICKEN2, DISABLE_READ_SUPPRESSION))
>  	},
>  	{ XE_RTP_NAME("14013392000"),
> -	  XE_RTP_RULES(SUBPLATFORM(DG2, G11), STEP(A0, B0), ENGINE_CLASS(RENDER)),
> +	  XE_RTP_RULES(SUBPLATFORM(DG2, G11), GRAPHICS_STEP(A0, B0),
> +		       ENGINE_CLASS(RENDER)),
>  	  XE_RTP_ACTIONS(SET(ROW_CHICKEN2, ENABLE_LARGE_GRF_MODE))
>  	},
>  	{ XE_RTP_NAME("14012419201"),
> -	  XE_RTP_RULES(SUBPLATFORM(DG2, G10), STEP(A0, B0), ENGINE_CLASS(RENDER)),
> +	  XE_RTP_RULES(SUBPLATFORM(DG2, G10), GRAPHICS_STEP(A0, B0),
> +		       ENGINE_CLASS(RENDER)),
>  	  XE_RTP_ACTIONS(SET(ROW_CHICKEN4,
>  			     DISABLE_HDR_PAST_PAYLOAD_HOLD_FIX))
>  	},
>  	{ XE_RTP_NAME("14012419201"),
> -	  XE_RTP_RULES(SUBPLATFORM(DG2, G11), STEP(A0, B0), ENGINE_CLASS(RENDER)),
> +	  XE_RTP_RULES(SUBPLATFORM(DG2, G11), GRAPHICS_STEP(A0, B0),
> +		       ENGINE_CLASS(RENDER)),
>  	  XE_RTP_ACTIONS(SET(ROW_CHICKEN4,
>  			     DISABLE_HDR_PAST_PAYLOAD_HOLD_FIX))
>  	},
>  	{ XE_RTP_NAME("1308578152"),
> -	  XE_RTP_RULES(SUBPLATFORM(DG2, G10), STEP(B0, C0), ENGINE_CLASS(RENDER),
> +	  XE_RTP_RULES(SUBPLATFORM(DG2, G10), GRAPHICS_STEP(B0, C0),
> +		       ENGINE_CLASS(RENDER),
>  		       FUNC(xe_rtp_match_first_gslice_fused_off)),
>  	  XE_RTP_ACTIONS(CLR(CS_DEBUG_MODE1,
>  			     REPLAY_MODE_GRANULARITY))
> @@ -426,30 +430,35 @@ static const struct xe_rtp_entry_sr engine_was[] = {
>  			     MDQ_ARBITRATION_MODE | UGM_BACKUP_MODE))
>  	},
>  	{ XE_RTP_NAME("22010430635"),
> -	  XE_RTP_RULES(SUBPLATFORM(DG2, G10), STEP(A0, B0), ENGINE_CLASS(RENDER)),
> +	  XE_RTP_RULES(SUBPLATFORM(DG2, G10), GRAPHICS_STEP(A0, B0),
> +		       ENGINE_CLASS(RENDER)),
>  	  XE_RTP_ACTIONS(SET(ROW_CHICKEN4,
>  			     DISABLE_GRF_CLEAR))
>  	},
>  	{ XE_RTP_NAME("14013202645"),
> -	  XE_RTP_RULES(SUBPLATFORM(DG2, G10), STEP(B0, C0), ENGINE_CLASS(RENDER)),
> +	  XE_RTP_RULES(SUBPLATFORM(DG2, G10), GRAPHICS_STEP(B0, C0),
> +		       ENGINE_CLASS(RENDER)),
>  	  XE_RTP_ACTIONS(SET(RT_CTRL, DIS_NULL_QUERY))
>  	},
>  	{ XE_RTP_NAME("14013202645"),
> -	  XE_RTP_RULES(SUBPLATFORM(DG2, G11), STEP(A0, B0), ENGINE_CLASS(RENDER)),
> +	  XE_RTP_RULES(SUBPLATFORM(DG2, G11), GRAPHICS_STEP(A0, B0),
> +		       ENGINE_CLASS(RENDER)),
>  	  XE_RTP_ACTIONS(SET(RT_CTRL, DIS_NULL_QUERY))
>  	},
>  	{ XE_RTP_NAME("22012532006"),
> -	  XE_RTP_RULES(SUBPLATFORM(DG2, G10), STEP(A0, C0), ENGINE_CLASS(RENDER)),
> +	  XE_RTP_RULES(SUBPLATFORM(DG2, G10), GRAPHICS_STEP(A0, C0),
> +		       ENGINE_CLASS(RENDER)),
>  	  XE_RTP_ACTIONS(SET(HALF_SLICE_CHICKEN7,
>  			     DG2_DISABLE_ROUND_ENABLE_ALLOW_FOR_SSLA))
>  	},
>  	{ XE_RTP_NAME("22012532006"),
> -	  XE_RTP_RULES(SUBPLATFORM(DG2, G11), STEP(A0, B0), ENGINE_CLASS(RENDER)),
> +	  XE_RTP_RULES(SUBPLATFORM(DG2, G11), GRAPHICS_STEP(A0, B0),
> +		       ENGINE_CLASS(RENDER)),
>  	  XE_RTP_ACTIONS(SET(HALF_SLICE_CHICKEN7,
>  			     DG2_DISABLE_ROUND_ENABLE_ALLOW_FOR_SSLA))
>  	},
>  	{ XE_RTP_NAME("22014600077"),
> -	  XE_RTP_RULES(SUBPLATFORM(DG2, G11), STEP(B0, FOREVER),
> +	  XE_RTP_RULES(SUBPLATFORM(DG2, G11), GRAPHICS_STEP(B0, FOREVER),
>  		       ENGINE_CLASS(RENDER)),
>  	  XE_RTP_ACTIONS(SET(CACHE_MODE_SS,
>  			     ENABLE_EU_COUNT_FOR_TDL_FLUSH,
> @@ -485,7 +494,8 @@ static const struct xe_rtp_entry_sr engine_was[] = {
>  	  XE_RTP_ACTIONS(SET(FF_SLICE_CS_CHICKEN2, PERF_FIX_BALANCING_CFE_DISABLE))
>  	},
>  	{ XE_RTP_NAME("14014999345"),
> -	  XE_RTP_RULES(PLATFORM(PVC), ENGINE_CLASS(COMPUTE), STEP(B0, C0)),
> +	  XE_RTP_RULES(PLATFORM(PVC), ENGINE_CLASS(COMPUTE),
> +		       GRAPHICS_STEP(B0, C0)),
>  	  XE_RTP_ACTIONS(SET(CACHE_MODE_SS, DISABLE_ECC))
>  	},
>  	{}
> @@ -528,17 +538,17 @@ static const struct xe_rtp_entry_sr lrc_was[] = {
>  	/* DG2 */
>  
>  	{ XE_RTP_NAME("16011186671"),
> -	  XE_RTP_RULES(SUBPLATFORM(DG2, G11), STEP(A0, B0)),
> +	  XE_RTP_RULES(SUBPLATFORM(DG2, G11), GRAPHICS_STEP(A0, B0)),
>  	  XE_RTP_ACTIONS(CLR(VFLSKPD, DIS_MULT_MISS_RD_SQUASH),
>  			 SET(VFLSKPD, DIS_OVER_FETCH_CACHE))
>  	},
>  	{ XE_RTP_NAME("14010469329"),
> -	  XE_RTP_RULES(SUBPLATFORM(DG2, G10), STEP(A0, B0)),
> +	  XE_RTP_RULES(SUBPLATFORM(DG2, G10), GRAPHICS_STEP(A0, B0)),
>  	  XE_RTP_ACTIONS(SET(XEHP_COMMON_SLICE_CHICKEN3,
>  			     XEHP_DUAL_SIMD8_SEQ_MERGE_DISABLE))
>  	},
>  	{ XE_RTP_NAME("14010698770, 22010613112, 22010465075"),
> -	  XE_RTP_RULES(SUBPLATFORM(DG2, G10), STEP(A0, B0)),
> +	  XE_RTP_RULES(SUBPLATFORM(DG2, G10), GRAPHICS_STEP(A0, B0)),
>  	  XE_RTP_ACTIONS(SET(XEHP_COMMON_SLICE_CHICKEN3,
>  			     DISABLE_CPS_AWARE_COLOR_PIPE))
>  	},
> -- 
> 2.40.1
> 

-- 
Matt Roper
Graphics Software Engineer
Linux GPU Platform Enablement
Intel Corporation

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: [Intel-xe] [PATCH v4 09/21] drm/xe/rtp: Add check for media stepping
  2023-05-25 21:33 ` [Intel-xe] [PATCH v4 09/21] drm/xe/rtp: Add check for media stepping Lucas De Marchi
@ 2023-05-25 22:39   ` Matt Roper
  0 siblings, 0 replies; 44+ messages in thread
From: Matt Roper @ 2023-05-25 22:39 UTC (permalink / raw)
  To: Lucas De Marchi; +Cc: intel-xe

On Thu, May 25, 2023 at 02:33:55PM -0700, Lucas De Marchi wrote:
> Start differentiating the media and graphics stepping as it will be
> important for MTL. Note that RTP is still not prepared to handle the
> different types of GT, i.e. checking for graphics version/range/stepping
> on a media gt or vice versa still matches regardless of the gt being
> passed as parameter. Changing it to accommodate MTL is left for a future
> patch.
> 
> Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>

As you noted, we can check that the current GT is of the proper type in
a future patch.

Reviewed-by: Matt Roper <matthew.d.roper@intel.com>

> ---
>  drivers/gpu/drm/xe/xe_rtp.c       | 12 +++++++-----
>  drivers/gpu/drm/xe/xe_rtp.h       | 17 +++++++++++++++++
>  drivers/gpu/drm/xe/xe_rtp_types.h |  1 +
>  3 files changed, 25 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/gpu/drm/xe/xe_rtp.c b/drivers/gpu/drm/xe/xe_rtp.c
> index 2ac7b47942fe..70769852a93d 100644
> --- a/drivers/gpu/drm/xe/xe_rtp.c
> +++ b/drivers/gpu/drm/xe/xe_rtp.c
> @@ -43,13 +43,16 @@ static bool rule_matches(const struct xe_device *xe,
>  				xe->info.subplatform == r->subplatform;
>  			break;
>  		case XE_RTP_MATCH_GRAPHICS_VERSION:
> -			/* TODO: match display */
>  			match = xe->info.graphics_verx100 == r->ver_start;
>  			break;
>  		case XE_RTP_MATCH_GRAPHICS_VERSION_RANGE:
>  			match = xe->info.graphics_verx100 >= r->ver_start &&
>  				xe->info.graphics_verx100 <= r->ver_end;
>  			break;
> +		case XE_RTP_MATCH_GRAPHICS_STEP:
> +			match = xe->info.step.graphics >= r->step_start &&
> +				xe->info.step.graphics < r->step_end;
> +			break;
>  		case XE_RTP_MATCH_MEDIA_VERSION:
>  			match = xe->info.media_verx100 == r->ver_start;
>  			break;
> @@ -57,10 +60,9 @@ static bool rule_matches(const struct xe_device *xe,
>  			match = xe->info.media_verx100 >= r->ver_start &&
>  				xe->info.media_verx100 <= r->ver_end;
>  			break;
> -		case XE_RTP_MATCH_GRAPHICS_STEP:
> -			/* TODO: match media/display */
> -			match = xe->info.step.graphics >= r->step_start &&
> -				xe->info.step.graphics < r->step_end;
> +		case XE_RTP_MATCH_MEDIA_STEP:
> +			match = xe->info.step.media >= r->step_start &&
> +				xe->info.step.media < r->step_end;
>  			break;
>  		case XE_RTP_MATCH_INTEGRATED:
>  			match = !xe->info.is_dgfx;
> diff --git a/drivers/gpu/drm/xe/xe_rtp.h b/drivers/gpu/drm/xe/xe_rtp.h
> index 7ba9d2ecab92..d55701d2f39b 100644
> --- a/drivers/gpu/drm/xe/xe_rtp.h
> +++ b/drivers/gpu/drm/xe/xe_rtp.h
> @@ -39,6 +39,10 @@ struct xe_reg_sr;
>  	{ .match_type = XE_RTP_MATCH_GRAPHICS_STEP,				\
>  	  .step_start = start__, .step_end = end__ }
>  
> +#define _XE_RTP_RULE_MEDIA_STEP(start__, end__)					\
> +	{ .match_type = XE_RTP_MATCH_MEDIA_STEP,				\
> +	  .step_start = start__, .step_end = end__ }
> +
>  #define _XE_RTP_RULE_ENGINE_CLASS(cls__)					\
>  	{ .match_type = XE_RTP_MATCH_ENGINE_CLASS,				\
>  	  .engine_class = (cls__) }
> @@ -75,6 +79,19 @@ struct xe_reg_sr;
>  #define XE_RTP_RULE_GRAPHICS_STEP(start_, end_)					\
>  	_XE_RTP_RULE_GRAPHICS_STEP(STEP_##start_, STEP_##end_)
>  
> +/**
> + * XE_RTP_RULE_MEDIA_STEP - Create rule matching media stepping
> + * @start_: First stepping matching the rule
> + * @end_: First stepping that does not match the rule
> + *
> + * Note that the range matching this rule is [ @start_, @end_ ), i.e. inclusive
> + * on the left, exclusive on the right.
> + *
> + * Refer to XE_RTP_RULES() for expected usage.
> + */
> +#define XE_RTP_RULE_MEDIA_STEP(start_, end_)					\
> +	_XE_RTP_RULE_MEDIA_STEP(STEP_##start_, STEP_##end_)
> +
>  /**
>   * XE_RTP_RULE_ENGINE_CLASS - Create rule matching an engine class
>   * @cls_: Engine class to match
> diff --git a/drivers/gpu/drm/xe/xe_rtp_types.h b/drivers/gpu/drm/xe/xe_rtp_types.h
> index 52adbf7de752..af49cbf98407 100644
> --- a/drivers/gpu/drm/xe/xe_rtp_types.h
> +++ b/drivers/gpu/drm/xe/xe_rtp_types.h
> @@ -42,6 +42,7 @@ enum {
>  	XE_RTP_MATCH_GRAPHICS_STEP,
>  	XE_RTP_MATCH_MEDIA_VERSION,
>  	XE_RTP_MATCH_MEDIA_VERSION_RANGE,
> +	XE_RTP_MATCH_MEDIA_STEP,
>  	XE_RTP_MATCH_INTEGRATED,
>  	XE_RTP_MATCH_DISCRETE,
>  	XE_RTP_MATCH_ENGINE_CLASS,
> -- 
> 2.40.1
> 

-- 
Matt Roper
Graphics Software Engineer
Linux GPU Platform Enablement
Intel Corporation

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: [Intel-xe] [PATCH v4 11/21] drm/xe: Include build directory
  2023-05-25 21:33 ` [Intel-xe] [PATCH v4 11/21] drm/xe: Include build directory Lucas De Marchi
@ 2023-05-25 22:41   ` Matt Roper
  0 siblings, 0 replies; 44+ messages in thread
From: Matt Roper @ 2023-05-25 22:41 UTC (permalink / raw)
  To: Lucas De Marchi; +Cc: intel-xe

On Thu, May 25, 2023 at 02:33:57PM -0700, Lucas De Marchi wrote:
> When doing out-of-tree builds with O= or KBUILD_OUTPUT=, it's important
> to also add the directory where the target is saved. Otherwise any file
> generated by the build system may not be available for other targets
> depending on it.
> 
> The $(obj) is added automatically when building the entire kernel,
> but it's not added when M=drivers/gpu/drm/xe is added.
> 
> Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>

Reviewed-by: Matt Roper <matthew.d.roper@intel.com>

> ---
>  drivers/gpu/drm/xe/Makefile | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/xe/Makefile b/drivers/gpu/drm/xe/Makefile
> index cd1614b68734..e058b1dda6e6 100644
> --- a/drivers/gpu/drm/xe/Makefile
> +++ b/drivers/gpu/drm/xe/Makefile
> @@ -24,7 +24,7 @@ subdir-ccflags-y += $(call cc-disable-warning, initializer-overrides)
>  subdir-ccflags-y += $(call cc-disable-warning, frame-address)
>  subdir-ccflags-$(CONFIG_DRM_XE_WERROR) += -Werror
>  
> -subdir-ccflags-y += -I$(srctree)/$(src)
> +subdir-ccflags-y += -I$(obj) -I$(srctree)/$(src)
>  
>  # Please keep these build lists sorted!
>  
> -- 
> 2.40.1
> 

-- 
Matt Roper
Graphics Software Engineer
Linux GPU Platform Enablement
Intel Corporation

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: [Intel-xe] [PATCH v4 12/21] drm/xe: Add support for OOB workarounds
  2023-05-25 21:33 ` [Intel-xe] [PATCH v4 12/21] drm/xe: Add support for OOB workarounds Lucas De Marchi
@ 2023-05-25 23:13   ` Matt Roper
  2023-05-26  4:59     ` Lucas De Marchi
  0 siblings, 1 reply; 44+ messages in thread
From: Matt Roper @ 2023-05-25 23:13 UTC (permalink / raw)
  To: Lucas De Marchi; +Cc: intel-xe

On Thu, May 25, 2023 at 02:33:58PM -0700, Lucas De Marchi wrote:
> There are WAs that, due to their nature, cannot be applied from a
> central place like xe_wa.c. Those are peppered around the rest of the
> code, as needed. Now they have a new name:  "out-of-band workarounds".
> 
> These workarounds have their names and rules still grouped in xe_wa.c,
> inside the xe_wa_oob array, which is generated at compile time by
> xe_wa_oob.rules and the hostprog xe_gen_wa_oob. The code generation
> guarantees that the header xe_wa_oob.h contains the IDs for the
> workarounds that match the index in the table. This way the runtime
> checks that are spread throughout the code are simple tests against the
> bitmap saved during initialization.
> 
> Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
> ---
>  drivers/gpu/drm/xe/Makefile        |  14 +++
>  drivers/gpu/drm/xe/xe_gen_wa_oob.c | 164 +++++++++++++++++++++++++++++
>  drivers/gpu/drm/xe/xe_gt.c         |   1 +
>  drivers/gpu/drm/xe/xe_gt_types.h   |   2 +
>  drivers/gpu/drm/xe/xe_wa.c         |  40 ++++++-
>  drivers/gpu/drm/xe/xe_wa.h         |   9 ++
>  drivers/gpu/drm/xe/xe_wa_oob.rules |   0
>  7 files changed, 226 insertions(+), 4 deletions(-)
>  create mode 100644 drivers/gpu/drm/xe/xe_gen_wa_oob.c
>  create mode 100644 drivers/gpu/drm/xe/xe_wa_oob.rules
> 
> diff --git a/drivers/gpu/drm/xe/Makefile b/drivers/gpu/drm/xe/Makefile
> index e058b1dda6e6..738975faaa05 100644
> --- a/drivers/gpu/drm/xe/Makefile
> +++ b/drivers/gpu/drm/xe/Makefile
> @@ -26,6 +26,20 @@ subdir-ccflags-$(CONFIG_DRM_XE_WERROR) += -Werror
>  
>  subdir-ccflags-y += -I$(obj) -I$(srctree)/$(src)
>  
> +# generated sources
> +hostprogs := xe_gen_wa_oob
> +
> +XE_WA_OOB := $(obj)/generated/xe_wa_oob.c $(obj)/generated/xe_wa_oob.h
> +
> +quiet_cmd_wa_oob = GEN     xe_wa_oob.[ch]

I think we could use "$(notdir $(XE_WA_OOB))" here to avoid hardcoding
the names?

Anyway, the rest looks okay.

Reviewed-by: Matt Roper <matthew.d.roper@intel.com>

> +      cmd_wa_oob = $^ $(XE_WA_OOB)
> +
> +$(XE_WA_OOB) &: $(obj)/xe_gen_wa_oob $(srctree)/$(src)/xe_wa_oob.rules
> +	@mkdir -p $(@D)
> +	$(call cmd,wa_oob)
> +
> +%.o:  $(XE_WA_OOB)
> +
>  # Please keep these build lists sorted!
>  
>  # core driver code
> diff --git a/drivers/gpu/drm/xe/xe_gen_wa_oob.c b/drivers/gpu/drm/xe/xe_gen_wa_oob.c
> new file mode 100644
> index 000000000000..930cdb7ccf52
> --- /dev/null
> +++ b/drivers/gpu/drm/xe/xe_gen_wa_oob.c
> @@ -0,0 +1,164 @@
> +// SPDX-License-Identifier: MIT
> +/*
> + * Copyright © 2023 Intel Corporation
> + */
> +
> +#define _GNU_SOURCE
> +#include <ctype.h>
> +#include <errno.h>
> +#include <stdbool.h>
> +#include <stdio.h>
> +#include <string.h>
> +
> +#define HEADER \
> +	"// SPDX-License-Identifier: MIT\n" \
> +	"\n" \
> +	"/*\n" \
> +	" * DO NOT MODIFY.\n" \
> +	" *\n" \
> +	" * This file was generated from rules: %s\n" \
> +	" */\n" \
> +	"#ifndef _GENERATED_XE_WA_OOB_\n" \
> +	"#define _GENERATED_XE_WA_OOB_\n" \
> +	"\n" \
> +	"enum {\n"
> +
> +#define FOOTER \
> +	"};\n" \
> +	"\n" \
> +	"#endif\n"
> +
> +static void print_usage(FILE *f)
> +{
> +	fprintf(f, "usage: %s <input-rule-file> <generated-c-source-file> <generated-c-header-file>\n",
> +		program_invocation_short_name);
> +}
> +
> +static void print_parse_error(const char *err_msg, const char *line,
> +			      unsigned int lineno)
> +{
> +	fprintf(stderr, "ERROR: %s\nERROR: %u: %.60s\n",
> +		err_msg, lineno, line);
> +}
> +
> +static char *strip(char *line, size_t linelen)
> +{
> +	while (isspace(*(line + linelen)))
> +		linelen--;
> +
> +	line[linelen - 1] = '\0';
> +
> +	return  line + strspn(line, " \f\n\r\t\v");
> +}
> +
> +#define MAX_LINE_LEN 4096
> +static int parse(FILE *input, FILE *csource, FILE *cheader)
> +{
> +	char line[MAX_LINE_LEN + 1];
> +	char *name, *prev_name = NULL, *rules;
> +	unsigned int lineno = 0, idx = 0;
> +
> +	while (fgets(line, sizeof(line), input)) {
> +		size_t linelen;
> +		bool is_continuation;
> +
> +		if (line[0] == '\0' || line[0] == '#' || line[0] == '\n') {
> +			lineno++;
> +			continue;
> +		}
> +
> +		linelen = strlen(line);
> +		if (linelen == MAX_LINE_LEN) {
> +			print_parse_error("line too long", line, lineno);
> +			return -EINVAL;
> +		}
> +
> +		is_continuation = isspace(line[0]);
> +		name = strip(line, linelen);
> +
> +		if (!is_continuation) {
> +			name = strtok(name, " \t");
> +			rules = strtok(NULL, "");
> +		} else {
> +			if (!prev_name) {
> +				print_parse_error("invalid rule continuation",
> +						  line, lineno);
> +				return -EINVAL;
> +			}
> +
> +			rules = name;
> +			name = NULL;
> +		}
> +
> +		if (rules[0] == '\0') {
> +			print_parse_error("invalid empty rule\n", line, lineno);
> +			return -EINVAL;
> +		}
> +
> +		if (name) {
> +			fprintf(cheader, "\tXE_WA_OOB_%s = %u,\n", name, idx);
> +			fprintf(csource, "{ XE_RTP_NAME(\"%s\"), XE_RTP_RULES(%s) },\n",
> +				name, rules);
> +		} else {
> +			fprintf(csource, "{ XE_RTP_NAME(NULL), XE_RTP_RULES(%s) },\n",
> +				rules);
> +		}
> +
> +		idx++;
> +		lineno++;
> +		prev_name = name;
> +	}
> +
> +	fprintf(cheader, "\t_XE_WA_OOB_COUNT = %u\n", idx);
> +
> +	return 0;
> +}
> +
> +int main(int argc, const char *argv[])
> +{
> +	enum {
> +		ARGS_INPUT,
> +		ARGS_CSOURCE,
> +		ARGS_CHEADER,
> +		_ARGS_COUNT
> +	};
> +	struct {
> +		const char *fn;
> +		const char *mode;
> +		FILE *f;
> +	} args[] = {
> +		[ARGS_INPUT] = { .fn = argv[1], .mode = "r" },
> +		[ARGS_CSOURCE] = { .fn = argv[2], .mode = "w" },
> +		[ARGS_CHEADER] = { .fn = argv[3], .mode = "w" },
> +	};
> +	int ret = 1;
> +
> +	if (argc < 3) {
> +		fprintf(stderr, "ERROR: wrong arguments\n");
> +		print_usage(stderr);
> +		return 1;
> +	}
> +
> +	for (int i = 0; i < _ARGS_COUNT; i++) {
> +		args[i].f = fopen(args[i].fn, args[i].mode);
> +		if (!args[i].f) {
> +			fprintf(stderr, "ERROR: Can't open %s: %m\n",
> +				args[i].fn);
> +			goto err;
> +		}
> +	}
> +
> +	fprintf(args[ARGS_CHEADER].f, HEADER, args[ARGS_INPUT].fn);
> +	ret = parse(args[ARGS_INPUT].f, args[ARGS_CSOURCE].f,
> +		    args[ARGS_CHEADER].f);
> +	if (!ret)
> +		fprintf(args[ARGS_CHEADER].f, FOOTER);
> +
> +err:
> +	for (int i = 0; i < _ARGS_COUNT; i++) {
> +		if (args[i].f)
> +			fclose(args[i].f);
> +	}
> +
> +	return ret;
> +}
> diff --git a/drivers/gpu/drm/xe/xe_gt.c b/drivers/gpu/drm/xe/xe_gt.c
> index d139554316d4..18eda5b1377f 100644
> --- a/drivers/gpu/drm/xe/xe_gt.c
> +++ b/drivers/gpu/drm/xe/xe_gt.c
> @@ -321,6 +321,7 @@ int xe_gt_init_early(struct xe_gt *gt)
>  		return err;
>  
>  	xe_wa_process_gt(gt);
> +	xe_wa_process_oob(gt);
>  	xe_tuning_process_gt(gt);
>  
>  	return 0;
> diff --git a/drivers/gpu/drm/xe/xe_gt_types.h b/drivers/gpu/drm/xe/xe_gt_types.h
> index 017ab60f2498..b83c834e7ced 100644
> --- a/drivers/gpu/drm/xe/xe_gt_types.h
> +++ b/drivers/gpu/drm/xe/xe_gt_types.h
> @@ -368,6 +368,8 @@ struct xe_gt {
>  		unsigned long *engine;
>  		/** @lrc: bitmap with active LRC workarounds */
>  		unsigned long *lrc;
> +		/** @oob: bitmap with active OOB workaroudns */
> +		unsigned long *oob;
>  	} wa_active;
>  };
>  
> diff --git a/drivers/gpu/drm/xe/xe_wa.c b/drivers/gpu/drm/xe/xe_wa.c
> index b717e0025bd9..ded100245479 100644
> --- a/drivers/gpu/drm/xe/xe_wa.c
> +++ b/drivers/gpu/drm/xe/xe_wa.c
> @@ -9,6 +9,7 @@
>  #include <kunit/visibility.h>
>  #include <linux/compiler_types.h>
>  
> +#include "generated/xe_wa_oob.h"
>  #include "regs/xe_engine_regs.h"
>  #include "regs/xe_gt_regs.h"
>  #include "regs/xe_regs.h"
> @@ -73,8 +74,8 @@
>   *      engine registers are restored in a context restore sequence. This is
>   *      currently not used in the driver.
>   *
> - * - Other:  There are WAs that, due to their nature, cannot be applied from a
> - *   central place. Those are peppered around the rest of the code, as needed.
> + * - Other/OOB:  There are WAs that, due to their nature, cannot be applied from
> + *   a central place. Those are peppered around the rest of the code, as needed.
>   *   Workarounds related to the display IP are the main example.
>   *
>   * .. [1] Technically, some registers are powercontext saved & restored, so they
> @@ -579,8 +580,31 @@ static const struct xe_rtp_entry_sr lrc_was[] = {
>  	{}
>  };
>  
> +static __maybe_unused const struct xe_rtp_entry oob_was[] = {
> +#include <generated/xe_wa_oob.c>
> +	{}
> +};
> +
> +static_assert(ARRAY_SIZE(oob_was) - 1 == _XE_WA_OOB_COUNT);
> +
>  __diag_pop();
>  
> +/**
> + * xe_wa_process_oob - process OOB workaround table
> + * @gt: GT instance to process workarounds for
> + *
> + * Process OOB workaround table for this platform, marking in @gt the
> + * workarounds that are active.
> + */
> +void xe_wa_process_oob(struct xe_gt *gt)
> +{
> +	struct xe_rtp_process_ctx ctx = XE_RTP_PROCESS_CTX_INITIALIZER(gt);
> +
> +	xe_rtp_process_ctx_enable_active_tracking(&ctx, gt->wa_active.oob,
> +						  ARRAY_SIZE(oob_was));
> +	xe_rtp_process(&ctx, oob_was);
> +}
> +
>  /**
>   * xe_wa_process_gt - process GT workaround table
>   * @gt: GT instance to process workarounds for
> @@ -641,13 +665,14 @@ void xe_wa_process_lrc(struct xe_hw_engine *hwe)
>  int xe_wa_init(struct xe_gt *gt)
>  {
>  	struct xe_device *xe = gt_to_xe(gt);
> -	size_t n_lrc, n_engine, n_gt, total;
> +	size_t n_oob, n_lrc, n_engine, n_gt, total;
>  	unsigned long *p;
>  
>  	n_gt = BITS_TO_LONGS(ARRAY_SIZE(gt_was));
>  	n_engine = BITS_TO_LONGS(ARRAY_SIZE(engine_was));
>  	n_lrc = BITS_TO_LONGS(ARRAY_SIZE(lrc_was));
> -	total = n_gt + n_engine + n_lrc;
> +	n_oob = BITS_TO_LONGS(ARRAY_SIZE(oob_was));
> +	total = n_gt + n_engine + n_lrc + n_oob;
>  
>  	p = drmm_kzalloc(&xe->drm, sizeof(*p) * total, GFP_KERNEL);
>  	if (!p)
> @@ -658,6 +683,8 @@ int xe_wa_init(struct xe_gt *gt)
>  	gt->wa_active.engine = p;
>  	p += n_engine;
>  	gt->wa_active.lrc = p;
> +	p += n_lrc;
> +	gt->wa_active.oob = p;
>  
>  	return 0;
>  }
> @@ -677,4 +704,9 @@ void xe_wa_dump(struct xe_gt *gt, struct drm_printer *p)
>  	drm_printf(p, "\nLRC Workarounds\n");
>  	for_each_set_bit(idx, gt->wa_active.lrc, ARRAY_SIZE(lrc_was))
>  		drm_printf_indent(p, 1, "%s\n", lrc_was[idx].name);
> +
> +	drm_printf(p, "\nOOB Workarounds\n");
> +	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);
>  }
> diff --git a/drivers/gpu/drm/xe/xe_wa.h b/drivers/gpu/drm/xe/xe_wa.h
> index defefa5d9611..cfe685989524 100644
> --- a/drivers/gpu/drm/xe/xe_wa.h
> +++ b/drivers/gpu/drm/xe/xe_wa.h
> @@ -11,6 +11,7 @@ struct xe_gt;
>  struct xe_hw_engine;
>  
>  int xe_wa_init(struct xe_gt *gt);
> +void xe_wa_process_oob(struct xe_gt *gt);
>  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);
> @@ -18,4 +19,12 @@ void xe_wa_process_lrc(struct xe_hw_engine *hwe);
>  void xe_reg_whitelist_process_engine(struct xe_hw_engine *hwe);
>  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
> + * @gt__: gt instance
> + * @id__: XE_OOB_<id__>, as generated by build system in generated/xe_wa_oob.h
> + */
> +#define XE_WA(gt__, id__) test_bit(XE_WA_OOB_ ## id__, (gt__)->wa_active.oob)
> +
>  #endif
> diff --git a/drivers/gpu/drm/xe/xe_wa_oob.rules b/drivers/gpu/drm/xe/xe_wa_oob.rules
> new file mode 100644
> index 000000000000..e69de29bb2d1
> -- 
> 2.40.1
> 

-- 
Matt Roper
Graphics Software Engineer
Linux GPU Platform Enablement
Intel Corporation

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: [Intel-xe] [PATCH v4 13/21] drm/xe/guc: Port Wa_22012773006 to xe_wa
  2023-05-25 21:33 ` [Intel-xe] [PATCH v4 13/21] drm/xe/guc: Port Wa_22012773006 to xe_wa Lucas De Marchi
@ 2023-05-25 23:14   ` Matt Roper
  0 siblings, 0 replies; 44+ messages in thread
From: Matt Roper @ 2023-05-25 23:14 UTC (permalink / raw)
  To: Lucas De Marchi; +Cc: intel-xe

On Thu, May 25, 2023 at 02:33:59PM -0700, Lucas De Marchi wrote:
> Let xe_guc.c start using XE_WA() for workarounds, starting from a simple
> one: Wa_22012773006. It's also changed to start with graphics version
> 12, since that is the first supported by xe.
> 
> Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>

Reviewed-by: Matt Roper <matthew.d.roper@intel.com>

> ---
>  drivers/gpu/drm/xe/xe_guc.c        | 6 +++---
>  drivers/gpu/drm/xe/xe_wa_oob.rules | 1 +
>  2 files changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/gpu/drm/xe/xe_guc.c b/drivers/gpu/drm/xe/xe_guc.c
> index a8e249205bff..08362db6a886 100644
> --- a/drivers/gpu/drm/xe/xe_guc.c
> +++ b/drivers/gpu/drm/xe/xe_guc.c
> @@ -5,6 +5,7 @@
>  
>  #include "xe_guc.h"
>  
> +#include "generated/xe_wa_oob.h"
>  #include "regs/xe_gt_regs.h"
>  #include "regs/xe_guc_regs.h"
>  #include "xe_bo.h"
> @@ -20,6 +21,7 @@
>  #include "xe_mmio.h"
>  #include "xe_platform_types.h"
>  #include "xe_uc_fw.h"
> +#include "xe_wa.h"
>  #include "xe_wopcm.h"
>  
>  static struct xe_gt *
> @@ -134,9 +136,7 @@ static u32 guc_ctl_wa_flags(struct xe_guc *guc)
>  	struct xe_gt *gt = guc_to_gt(guc);
>  	u32 flags = 0;
>  
> -	/* Wa_22012773006:gen11,gen12 < XeHP */
> -	if (GRAPHICS_VER(xe) >= 11 &&
> -	    GRAPHICS_VERx100(xe) < 1250)
> +	if (XE_WA(gt, 22012773006))
>  		flags |= GUC_WA_POLLCS;
>  
>  	/* Wa_16011759253 */
> diff --git a/drivers/gpu/drm/xe/xe_wa_oob.rules b/drivers/gpu/drm/xe/xe_wa_oob.rules
> index e69de29bb2d1..b54f70eeccf4 100644
> --- a/drivers/gpu/drm/xe/xe_wa_oob.rules
> +++ b/drivers/gpu/drm/xe/xe_wa_oob.rules
> @@ -0,0 +1 @@
> +22012773006	GRAPHICS_VERSION_RANGE(1200, 1250)
> -- 
> 2.40.1
> 

-- 
Matt Roper
Graphics Software Engineer
Linux GPU Platform Enablement
Intel Corporation

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: [Intel-xe] [PATCH v4 14/21] drm/xe/guc: Port Wa_16011759253 to xe_wa
  2023-05-25 21:34 ` [Intel-xe] [PATCH v4 14/21] drm/xe/guc: Port Wa_16011759253 " Lucas De Marchi
@ 2023-05-25 23:17   ` Matt Roper
  2023-05-26  4:42     ` Lucas De Marchi
  0 siblings, 1 reply; 44+ messages in thread
From: Matt Roper @ 2023-05-25 23:17 UTC (permalink / raw)
  To: Lucas De Marchi; +Cc: intel-xe

On Thu, May 25, 2023 at 02:34:00PM -0700, Lucas De Marchi wrote:
> Port Wa_16011759253 to oob. Wa_22011383443, that has the same action,
> doesn't need to be ported as it targets early PVC steppings.

Technically Wa_22011383443 is also targeting early steppings of DG2.
But we can come back and prune the DG2 pre-production workarounds later;
this is a correct conversion of the code that already exists today.

Reviewed-by: Matt Roper <matthew.d.roper@intel.com>

> 
> Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
> ---
>  drivers/gpu/drm/xe/xe_guc.c        | 4 +---
>  drivers/gpu/drm/xe/xe_wa_oob.rules | 1 +
>  2 files changed, 2 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/gpu/drm/xe/xe_guc.c b/drivers/gpu/drm/xe/xe_guc.c
> index 08362db6a886..1b3fbbd74923 100644
> --- a/drivers/gpu/drm/xe/xe_guc.c
> +++ b/drivers/gpu/drm/xe/xe_guc.c
> @@ -139,9 +139,7 @@ static u32 guc_ctl_wa_flags(struct xe_guc *guc)
>  	if (XE_WA(gt, 22012773006))
>  		flags |= GUC_WA_POLLCS;
>  
> -	/* Wa_16011759253 */
> -	/* Wa_22011383443 */
> -	if (IS_SUBPLATFORM_STEP(xe, XE_DG2, XE_SUBPLATFORM_DG2_G10, STEP_A0, STEP_B0))
> +	if (XE_WA(gt, 16011759253))
>  		flags |= GUC_WA_GAM_CREDITS;
>  
>  	/* Wa_14014475959 */
> diff --git a/drivers/gpu/drm/xe/xe_wa_oob.rules b/drivers/gpu/drm/xe/xe_wa_oob.rules
> index b54f70eeccf4..9b29a0dd0934 100644
> --- a/drivers/gpu/drm/xe/xe_wa_oob.rules
> +++ b/drivers/gpu/drm/xe/xe_wa_oob.rules
> @@ -1 +1,2 @@
>  22012773006	GRAPHICS_VERSION_RANGE(1200, 1250)
> +16011759253	SUBPLATFORM(DG2, G10), GRAPHICS_STEP(A0, B0)
> -- 
> 2.40.1
> 

-- 
Matt Roper
Graphics Software Engineer
Linux GPU Platform Enablement
Intel Corporation

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: [Intel-xe] [PATCH v4 15/21] drm/xe/guc: Port Wa_14012197797/Wa_22011391025 to xe_wa
  2023-05-25 21:34 ` [Intel-xe] [PATCH v4 15/21] drm/xe/guc: Port Wa_14012197797/Wa_22011391025 " Lucas De Marchi
@ 2023-05-25 23:18   ` Matt Roper
  0 siblings, 0 replies; 44+ messages in thread
From: Matt Roper @ 2023-05-25 23:18 UTC (permalink / raw)
  To: Lucas De Marchi; +Cc: intel-xe

On Thu, May 25, 2023 at 02:34:01PM -0700, Lucas De Marchi wrote:
> Wa_14012197797 and Wa_22011391025 apply to DG2 using the same action.
> They apply to slightly different conditions. Add both to the oob rules
> so they are both reported as active.
> 
> Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>

Reviewed-by: Matt Roper <matthew.d.roper@intel.com>

> ---
>  drivers/gpu/drm/xe/xe_guc.c        | 9 +--------
>  drivers/gpu/drm/xe/xe_wa_oob.rules | 2 ++
>  2 files changed, 3 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/gpu/drm/xe/xe_guc.c b/drivers/gpu/drm/xe/xe_guc.c
> index 1b3fbbd74923..54aaf6e6b577 100644
> --- a/drivers/gpu/drm/xe/xe_guc.c
> +++ b/drivers/gpu/drm/xe/xe_guc.c
> @@ -147,14 +147,7 @@ static u32 guc_ctl_wa_flags(struct xe_guc *guc)
>  	    xe->info.platform == XE_DG2)
>  		flags |= GUC_WA_HOLD_CCS_SWITCHOUT;
>  
> -	/*
> -	 * Wa_14012197797
> -	 * Wa_22011391025
> -	 *
> -	 * The same WA bit is used for both and 22011391025 is applicable to
> -	 * all DG2.
> -	 */
> -	if (xe->info.platform == XE_DG2)
> +	if (XE_WA(gt, 22011391025) || XE_WA(gt, 14012197797))
>  		flags |= GUC_WA_DUAL_QUEUE;
>  
>  	/*
> diff --git a/drivers/gpu/drm/xe/xe_wa_oob.rules b/drivers/gpu/drm/xe/xe_wa_oob.rules
> index 9b29a0dd0934..77ac4a4a3296 100644
> --- a/drivers/gpu/drm/xe/xe_wa_oob.rules
> +++ b/drivers/gpu/drm/xe/xe_wa_oob.rules
> @@ -1,2 +1,4 @@
>  22012773006	GRAPHICS_VERSION_RANGE(1200, 1250)
>  16011759253	SUBPLATFORM(DG2, G10), GRAPHICS_STEP(A0, B0)
> +22011391025	PLATFORM(DG2)
> +14012197797	PLATFORM(DG2), GRAPHICS_STEP(A0, B0)
> -- 
> 2.40.1
> 

-- 
Matt Roper
Graphics Software Engineer
Linux GPU Platform Enablement
Intel Corporation

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: [Intel-xe] [PATCH v4 16/21] drm/xe/guc: Port Wa_16011777198 to xe_wa
  2023-05-25 21:34 ` [Intel-xe] [PATCH v4 16/21] drm/xe/guc: Port Wa_16011777198 " Lucas De Marchi
@ 2023-05-25 23:19   ` Matt Roper
  0 siblings, 0 replies; 44+ messages in thread
From: Matt Roper @ 2023-05-25 23:19 UTC (permalink / raw)
  To: Lucas De Marchi; +Cc: intel-xe

On Thu, May 25, 2023 at 02:34:02PM -0700, Lucas De Marchi wrote:
> Port Wa_16011777198 to xe_wa so it's reported as active.
> 
> Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>

Reviewed-by: Matt Roper <matthew.d.roper@intel.com>

> ---
>  drivers/gpu/drm/xe/xe_guc.c        | 5 +----
>  drivers/gpu/drm/xe/xe_wa_oob.rules | 2 ++
>  2 files changed, 3 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/gpu/drm/xe/xe_guc.c b/drivers/gpu/drm/xe/xe_guc.c
> index 54aaf6e6b577..5eccc4b67381 100644
> --- a/drivers/gpu/drm/xe/xe_guc.c
> +++ b/drivers/gpu/drm/xe/xe_guc.c
> @@ -158,10 +158,7 @@ static u32 guc_ctl_wa_flags(struct xe_guc *guc)
>  	if (GRAPHICS_VERx100(xe) < 1270)
>  		flags |= GUC_WA_PRE_PARSER;
>  
> -	/* Wa_16011777198 */
> -	if (IS_SUBPLATFORM_STEP(xe, XE_DG2, XE_SUBPLATFORM_DG2_G10, STEP_A0, STEP_C0) ||
> -	    IS_SUBPLATFORM_STEP(xe, XE_DG2, XE_SUBPLATFORM_DG2_G11, STEP_A0,
> -				STEP_B0))
> +	if (XE_WA(gt, 16011777198))
>  		flags |= GUC_WA_RCS_RESET_BEFORE_RC6;
>  
>  	/*
> diff --git a/drivers/gpu/drm/xe/xe_wa_oob.rules b/drivers/gpu/drm/xe/xe_wa_oob.rules
> index 77ac4a4a3296..3d4304b7111e 100644
> --- a/drivers/gpu/drm/xe/xe_wa_oob.rules
> +++ b/drivers/gpu/drm/xe/xe_wa_oob.rules
> @@ -2,3 +2,5 @@
>  16011759253	SUBPLATFORM(DG2, G10), GRAPHICS_STEP(A0, B0)
>  22011391025	PLATFORM(DG2)
>  14012197797	PLATFORM(DG2), GRAPHICS_STEP(A0, B0)
> +16011777198	SUBPLATFORM(DG2, G10), GRAPHICS_STEP(A0, C0)
> +		SUBPLATFORM(DG2, G11), GRAPHICS_STEP(A0, B0)
> -- 
> 2.40.1
> 

-- 
Matt Roper
Graphics Software Engineer
Linux GPU Platform Enablement
Intel Corporation

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: [Intel-xe] [PATCH v4 17/21] drm/xe/guc: Port Wa_22012727170/Wa_22012727685 to xe_wa
  2023-05-25 21:34 ` [Intel-xe] [PATCH v4 17/21] drm/xe/guc: Port Wa_22012727170/Wa_22012727685 " Lucas De Marchi
@ 2023-05-25 23:25   ` Matt Roper
  2023-05-26  5:06     ` Lucas De Marchi
  0 siblings, 1 reply; 44+ messages in thread
From: Matt Roper @ 2023-05-25 23:25 UTC (permalink / raw)
  To: Lucas De Marchi; +Cc: intel-xe

On Thu, May 25, 2023 at 02:34:03PM -0700, Lucas De Marchi wrote:
> Wa_22012727170 and Wa_22012727685 apply to DG2 using the same action and
> conditions. Add both to the oob rules so they are both reported as
> active.
> 
> Do not Wa_22012727170 to PVC and MTL since only early A* steppings are
> affected.
> 
> Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
> ---
>  drivers/gpu/drm/xe/xe_guc.c        | 8 +-------
>  drivers/gpu/drm/xe/xe_wa_oob.rules | 4 ++++
>  2 files changed, 5 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/gpu/drm/xe/xe_guc.c b/drivers/gpu/drm/xe/xe_guc.c
> index 5eccc4b67381..1291f71348db 100644
> --- a/drivers/gpu/drm/xe/xe_guc.c
> +++ b/drivers/gpu/drm/xe/xe_guc.c
> @@ -161,13 +161,7 @@ static u32 guc_ctl_wa_flags(struct xe_guc *guc)
>  	if (XE_WA(gt, 16011777198))
>  		flags |= GUC_WA_RCS_RESET_BEFORE_RC6;
>  
> -	/*
> -	 * Wa_22012727170
> -	 * Wa_22012727685
> -	 */
> -	if (IS_SUBPLATFORM_STEP(xe, XE_DG2, XE_SUBPLATFORM_DG2_G10, STEP_A0, STEP_C0) ||
> -	    IS_SUBPLATFORM_STEP(xe, XE_DG2, XE_SUBPLATFORM_DG2_G11, STEP_A0,
> -				STEP_FOREVER))
> +	if (XE_WA(gt, 22012727170) || XE_WA(gt, 22012727685))
>  		flags |= GUC_WA_CONTEXT_ISOLATION;
>  
>  	/* Wa_16015675438, Wa_18020744125 */
> diff --git a/drivers/gpu/drm/xe/xe_wa_oob.rules b/drivers/gpu/drm/xe/xe_wa_oob.rules
> index 3d4304b7111e..fecf9dd431c5 100644
> --- a/drivers/gpu/drm/xe/xe_wa_oob.rules
> +++ b/drivers/gpu/drm/xe/xe_wa_oob.rules
> @@ -4,3 +4,7 @@
>  14012197797	PLATFORM(DG2), GRAPHICS_STEP(A0, B0)
>  16011777198	SUBPLATFORM(DG2, G10), GRAPHICS_STEP(A0, C0)
>  		SUBPLATFORM(DG2, G11), GRAPHICS_STEP(A0, B0)
> +22012727170	SUBPLATFORM(DG2, G10), GRAPHICS_STEP(A0, C0)
> +		SUBPLATFORM(DG2, G11), GRAPHICS_STEP(A0, FOREVER)
> +22012727685	SUBPLATFORM(DG2, G10), GRAPHICS_STEP(A0, C0)

I don't think the G10 condition applies to 22012727685 if I'm reading
the database right.


Matt

> +		SUBPLATFORM(DG2, G11), GRAPHICS_STEP(A0, FOREVER)
> -- 
> 2.40.1
> 

-- 
Matt Roper
Graphics Software Engineer
Linux GPU Platform Enablement
Intel Corporation

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: [Intel-xe] [PATCH v4 18/21] drm/xe/guc: Port Wa_16015675438/Wa_18020744125 to xe_wa
  2023-05-25 21:34 ` [Intel-xe] [PATCH v4 18/21] drm/xe/guc: Port Wa_16015675438/Wa_18020744125 " Lucas De Marchi
@ 2023-05-25 23:28   ` Matt Roper
  0 siblings, 0 replies; 44+ messages in thread
From: Matt Roper @ 2023-05-25 23:28 UTC (permalink / raw)
  To: Lucas De Marchi; +Cc: intel-xe

On Thu, May 25, 2023 at 02:34:04PM -0700, Lucas De Marchi wrote:
> Wa_16015675438 and Wa_18020744125 apply to DG2 using the same action and
> conditions. Add both to the oob rules so they are both reported as
> active. Note that previously they were not checking by platform or IP
> version, hence making them not future-proof.  Those workarounds should
> only be active in PVC and DG2, besides the check for "no render engine".
> 
> Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
> ---
>  drivers/gpu/drm/xe/xe_guc.c        | 4 ++--
>  drivers/gpu/drm/xe/xe_wa_oob.rules | 3 +++
>  2 files changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/gpu/drm/xe/xe_guc.c b/drivers/gpu/drm/xe/xe_guc.c
> index 1291f71348db..cc58a2092236 100644
> --- a/drivers/gpu/drm/xe/xe_guc.c
> +++ b/drivers/gpu/drm/xe/xe_guc.c
> @@ -164,8 +164,8 @@ static u32 guc_ctl_wa_flags(struct xe_guc *guc)
>  	if (XE_WA(gt, 22012727170) || XE_WA(gt, 22012727685))
>  		flags |= GUC_WA_CONTEXT_ISOLATION;
>  
> -	/* Wa_16015675438, Wa_18020744125 */
> -	if (!xe_hw_engine_mask_per_class(gt, XE_ENGINE_CLASS_RENDER))
> +	if ((XE_WA(gt, 16015675438) || XE_WA(gt, 18020744125)) &&
> +	    !xe_hw_engine_mask_per_class(gt, XE_ENGINE_CLASS_RENDER))
>  		flags |= GUC_WA_RCS_REGS_IN_CCS_REGS_LIST;
>  
>  	/* Wa_1509372804 */
> diff --git a/drivers/gpu/drm/xe/xe_wa_oob.rules b/drivers/gpu/drm/xe/xe_wa_oob.rules
> index fecf9dd431c5..05c821a50680 100644
> --- a/drivers/gpu/drm/xe/xe_wa_oob.rules
> +++ b/drivers/gpu/drm/xe/xe_wa_oob.rules
> @@ -8,3 +8,6 @@
>  		SUBPLATFORM(DG2, G11), GRAPHICS_STEP(A0, FOREVER)
>  22012727685	SUBPLATFORM(DG2, G10), GRAPHICS_STEP(A0, C0)
>  		SUBPLATFORM(DG2, G11), GRAPHICS_STEP(A0, FOREVER)
> +16015675438	PLATFORM(PVC)
> +		PLATFORM(DG2)

I see DG2-G10 and DG2-G12 listed, but not DG2-G11.  Platform-specific
ticket #14016276341 confirms that DG2-G11 should not be impacted.


Matt

> +18020744125	PLATFORM(PVC)
> -- 
> 2.40.1
> 

-- 
Matt Roper
Graphics Software Engineer
Linux GPU Platform Enablement
Intel Corporation

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: [Intel-xe] [PATCH v4 19/21] drm/xe/guc: Port Wa_1509372804 to xe_wa
  2023-05-25 21:34 ` [Intel-xe] [PATCH v4 19/21] drm/xe/guc: Port Wa_1509372804 " Lucas De Marchi
@ 2023-05-25 23:30   ` Matt Roper
  0 siblings, 0 replies; 44+ messages in thread
From: Matt Roper @ 2023-05-25 23:30 UTC (permalink / raw)
  To: Lucas De Marchi; +Cc: intel-xe

On Thu, May 25, 2023 at 02:34:05PM -0700, Lucas De Marchi wrote:
> Port Wa_1509372804 to xe_wa so it's reported as active.
> 
> Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>

Workaround database says this one starts from A0, but since that's a
preproduction stepping it doesn't matter if we omit it.

Reviewed-by: Matt Roper <matthew.d.roper@intel.com>

> ---
>  drivers/gpu/drm/xe/xe_guc.c        | 3 +--
>  drivers/gpu/drm/xe/xe_wa_oob.rules | 1 +
>  2 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/gpu/drm/xe/xe_guc.c b/drivers/gpu/drm/xe/xe_guc.c
> index cc58a2092236..3ed460d3b6ca 100644
> --- a/drivers/gpu/drm/xe/xe_guc.c
> +++ b/drivers/gpu/drm/xe/xe_guc.c
> @@ -168,8 +168,7 @@ static u32 guc_ctl_wa_flags(struct xe_guc *guc)
>  	    !xe_hw_engine_mask_per_class(gt, XE_ENGINE_CLASS_RENDER))
>  		flags |= GUC_WA_RCS_REGS_IN_CCS_REGS_LIST;
>  
> -	/* Wa_1509372804 */
> -	if (IS_PLATFORM_STEP(xe, XE_PVC, STEP_B0, STEP_C0))
> +	if (XE_WA(gt, 1509372804))
>  		flags |= GUC_WA_RENDER_RST_RC6_EXIT;
>  
>  	return flags;
> diff --git a/drivers/gpu/drm/xe/xe_wa_oob.rules b/drivers/gpu/drm/xe/xe_wa_oob.rules
> index 05c821a50680..fc9846af460c 100644
> --- a/drivers/gpu/drm/xe/xe_wa_oob.rules
> +++ b/drivers/gpu/drm/xe/xe_wa_oob.rules
> @@ -11,3 +11,4 @@
>  16015675438	PLATFORM(PVC)
>  		PLATFORM(DG2)
>  18020744125	PLATFORM(PVC)
> +1509372804	PLATFORM(PVC), GRAPHICS_STEP(B0, C0)
> -- 
> 2.40.1
> 

-- 
Matt Roper
Graphics Software Engineer
Linux GPU Platform Enablement
Intel Corporation

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: [Intel-xe] [PATCH v4 20/21] drm/xe/rtp: Also check gt type
  2023-05-25 21:34 ` [Intel-xe] [PATCH v4 20/21] drm/xe/rtp: Also check gt type Lucas De Marchi
@ 2023-05-25 23:34   ` Matt Roper
  0 siblings, 0 replies; 44+ messages in thread
From: Matt Roper @ 2023-05-25 23:34 UTC (permalink / raw)
  To: Lucas De Marchi; +Cc: intel-xe

On Thu, May 25, 2023 at 02:34:06PM -0700, Lucas De Marchi wrote:
> When running rules on MTL and beyond that have media as a standalone GT,
> the rule should only match if the gt passed as parameter match the
> version/range/stepping that the rule is checking. This allows
> workarounds affecting only the media GT to be applied only on that GT
> and vice-versa.
> 
> For platforms before MTL, the GT will not be of media type, even if it
> includes media engines. Make sure to cover that case by checking if the
> platforma has standalone media.
> 
> Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
> ---
>  drivers/gpu/drm/xe/xe_rtp.c | 23 +++++++++++++++++------
>  1 file changed, 17 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/gpu/drm/xe/xe_rtp.c b/drivers/gpu/drm/xe/xe_rtp.c
> index ebcfb04c391a..43a86358efb6 100644
> --- a/drivers/gpu/drm/xe/xe_rtp.c
> +++ b/drivers/gpu/drm/xe/xe_rtp.c
> @@ -23,6 +23,11 @@
>   * the values to the registers that have matching rules.
>   */
>  
> +static bool has_samedia(const struct xe_device *xe)
> +{
> +	return xe->info.media_verx100 >= 1300;

This could also be

        return MEDIA_VER(xe) > 13;

to reduce the number of places in the code that need to be changed if we
shuffle around the internal structures in the future.

Up to you whether you want to change it.

Reviewed-by: Matt Roper <matthew.d.roper@intel.com>

> +}
> +
>  static bool rule_matches(const struct xe_device *xe,
>  			 struct xe_gt *gt,
>  			 struct xe_hw_engine *hwe,
> @@ -43,26 +48,32 @@ static bool rule_matches(const struct xe_device *xe,
>  				xe->info.subplatform == r->subplatform;
>  			break;
>  		case XE_RTP_MATCH_GRAPHICS_VERSION:
> -			match = xe->info.graphics_verx100 == r->ver_start;
> +			match = xe->info.graphics_verx100 == r->ver_start &&
> +				(!has_samedia(xe) || !xe_gt_is_media_type(gt));
>  			break;
>  		case XE_RTP_MATCH_GRAPHICS_VERSION_RANGE:
>  			match = xe->info.graphics_verx100 >= r->ver_start &&
> -				xe->info.graphics_verx100 <= r->ver_end;
> +				xe->info.graphics_verx100 <= r->ver_end &&
> +				(!has_samedia(xe) || !xe_gt_is_media_type(gt));
>  			break;
>  		case XE_RTP_MATCH_GRAPHICS_STEP:
>  			match = xe->info.step.graphics >= r->step_start &&
> -				xe->info.step.graphics < r->step_end;
> +				xe->info.step.graphics < r->step_end &&
> +				(!has_samedia(xe) || !xe_gt_is_media_type(gt));
>  			break;
>  		case XE_RTP_MATCH_MEDIA_VERSION:
> -			match = xe->info.media_verx100 == r->ver_start;
> +			match = xe->info.media_verx100 == r->ver_start &&
> +				(!has_samedia(xe) || xe_gt_is_media_type(gt));
>  			break;
>  		case XE_RTP_MATCH_MEDIA_VERSION_RANGE:
>  			match = xe->info.media_verx100 >= r->ver_start &&
> -				xe->info.media_verx100 <= r->ver_end;
> +				xe->info.media_verx100 <= r->ver_end &&
> +				(!has_samedia(xe) || xe_gt_is_media_type(gt));
>  			break;
>  		case XE_RTP_MATCH_MEDIA_STEP:
>  			match = xe->info.step.media >= r->step_start &&
> -				xe->info.step.media < r->step_end;
> +				xe->info.step.media < r->step_end &&
> +				(!has_samedia(xe) || xe_gt_is_media_type(gt));
>  			break;
>  		case XE_RTP_MATCH_INTEGRATED:
>  			match = !xe->info.is_dgfx;
> -- 
> 2.40.1
> 

-- 
Matt Roper
Graphics Software Engineer
Linux GPU Platform Enablement
Intel Corporation

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: [Intel-xe] [PATCH v4 21/21] drm/xe/guc: Port Wa_14014475959 to xe_wa and fix it
  2023-05-25 21:34 ` [Intel-xe] [PATCH v4 21/21] drm/xe/guc: Port Wa_14014475959 to xe_wa and fix it Lucas De Marchi
@ 2023-05-25 23:35   ` Matt Roper
  0 siblings, 0 replies; 44+ messages in thread
From: Matt Roper @ 2023-05-25 23:35 UTC (permalink / raw)
  To: Lucas De Marchi; +Cc: intel-xe

On Thu, May 25, 2023 at 02:34:07PM -0700, Lucas De Marchi wrote:
> Port Wa_14014475959 to xe_wa fixing its condition. The workaround should
> only be applied on the primary GT, not on media. So just checking by
> MTL platform is not enough: checking GT is of the right type is also
> needed.
> 
> Since the GRAPHICS_STEP() does checks the GT type, we could leave the
> first check as a platform one: it'd would be easier to understand and
> not go out of sync with the graphics_ip_map[] in
> drivers/gpu/drm/xe/xe_pci.c. However it also means that new platforms
> using the same IP wouldn't match. Prefer using the IP version.
> 
> Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>

Reviewed-by: Matt Roper <matthew.d.roper@intel.com>

> ---
>  drivers/gpu/drm/xe/xe_guc.c        | 4 +---
>  drivers/gpu/drm/xe/xe_wa_oob.rules | 2 ++
>  2 files changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/gpu/drm/xe/xe_guc.c b/drivers/gpu/drm/xe/xe_guc.c
> index 3ed460d3b6ca..ecc843d91f62 100644
> --- a/drivers/gpu/drm/xe/xe_guc.c
> +++ b/drivers/gpu/drm/xe/xe_guc.c
> @@ -142,9 +142,7 @@ static u32 guc_ctl_wa_flags(struct xe_guc *guc)
>  	if (XE_WA(gt, 16011759253))
>  		flags |= GUC_WA_GAM_CREDITS;
>  
> -	/* Wa_14014475959 */
> -	if (IS_PLATFORM_STEP(xe, XE_METEORLAKE, STEP_A0, STEP_B0) ||
> -	    xe->info.platform == XE_DG2)
> +	if (XE_WA(gt, 14014475959))
>  		flags |= GUC_WA_HOLD_CCS_SWITCHOUT;
>  
>  	if (XE_WA(gt, 22011391025) || XE_WA(gt, 14012197797))
> diff --git a/drivers/gpu/drm/xe/xe_wa_oob.rules b/drivers/gpu/drm/xe/xe_wa_oob.rules
> index fc9846af460c..c58f3eb3e993 100644
> --- a/drivers/gpu/drm/xe/xe_wa_oob.rules
> +++ b/drivers/gpu/drm/xe/xe_wa_oob.rules
> @@ -1,5 +1,7 @@
>  22012773006	GRAPHICS_VERSION_RANGE(1200, 1250)
>  16011759253	SUBPLATFORM(DG2, G10), GRAPHICS_STEP(A0, B0)
> +14014475959	GRAPHICS_VERSION_RANGE(1270, 1271), GRAPHICS_STEP(A0, B0)
> +		PLATFORM(DG2)
>  22011391025	PLATFORM(DG2)
>  14012197797	PLATFORM(DG2), GRAPHICS_STEP(A0, B0)
>  16011777198	SUBPLATFORM(DG2, G10), GRAPHICS_STEP(A0, C0)
> -- 
> 2.40.1
> 

-- 
Matt Roper
Graphics Software Engineer
Linux GPU Platform Enablement
Intel Corporation

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: [Intel-xe] [PATCH v4 14/21] drm/xe/guc: Port Wa_16011759253 to xe_wa
  2023-05-25 23:17   ` Matt Roper
@ 2023-05-26  4:42     ` Lucas De Marchi
  0 siblings, 0 replies; 44+ messages in thread
From: Lucas De Marchi @ 2023-05-26  4:42 UTC (permalink / raw)
  To: Matt Roper; +Cc: intel-xe

On Thu, May 25, 2023 at 04:17:29PM -0700, Matt Roper wrote:
>On Thu, May 25, 2023 at 02:34:00PM -0700, Lucas De Marchi wrote:
>> Port Wa_16011759253 to oob. Wa_22011383443, that has the same action,
>> doesn't need to be ported as it targets early PVC steppings.
>
>Technically Wa_22011383443 is also targeting early steppings of DG2.
>But we can come back and prune the DG2 pre-production workarounds later;
>this is a correct conversion of the code that already exists today.

when we were porting the workarounds, due to the hw availalble and type
of WAs we'd need, we decided to support early steppings for DG2, but
skip for PVC and MTL.

Agreed we can come back later and remove the early steppings of DG2.

>
>Reviewed-by: Matt Roper <matthew.d.roper@intel.com>

thanks
Lucas De Marchi

>
>>
>> Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
>> ---
>>  drivers/gpu/drm/xe/xe_guc.c        | 4 +---
>>  drivers/gpu/drm/xe/xe_wa_oob.rules | 1 +
>>  2 files changed, 2 insertions(+), 3 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/xe/xe_guc.c b/drivers/gpu/drm/xe/xe_guc.c
>> index 08362db6a886..1b3fbbd74923 100644
>> --- a/drivers/gpu/drm/xe/xe_guc.c
>> +++ b/drivers/gpu/drm/xe/xe_guc.c
>> @@ -139,9 +139,7 @@ static u32 guc_ctl_wa_flags(struct xe_guc *guc)
>>  	if (XE_WA(gt, 22012773006))
>>  		flags |= GUC_WA_POLLCS;
>>
>> -	/* Wa_16011759253 */
>> -	/* Wa_22011383443 */
>> -	if (IS_SUBPLATFORM_STEP(xe, XE_DG2, XE_SUBPLATFORM_DG2_G10, STEP_A0, STEP_B0))
>> +	if (XE_WA(gt, 16011759253))
>>  		flags |= GUC_WA_GAM_CREDITS;
>>
>>  	/* Wa_14014475959 */
>> diff --git a/drivers/gpu/drm/xe/xe_wa_oob.rules b/drivers/gpu/drm/xe/xe_wa_oob.rules
>> index b54f70eeccf4..9b29a0dd0934 100644
>> --- a/drivers/gpu/drm/xe/xe_wa_oob.rules
>> +++ b/drivers/gpu/drm/xe/xe_wa_oob.rules
>> @@ -1 +1,2 @@
>>  22012773006	GRAPHICS_VERSION_RANGE(1200, 1250)
>> +16011759253	SUBPLATFORM(DG2, G10), GRAPHICS_STEP(A0, B0)
>> --
>> 2.40.1
>>
>
>-- 
>Matt Roper
>Graphics Software Engineer
>Linux GPU Platform Enablement
>Intel Corporation

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: [Intel-xe] [PATCH v4 12/21] drm/xe: Add support for OOB workarounds
  2023-05-25 23:13   ` Matt Roper
@ 2023-05-26  4:59     ` Lucas De Marchi
  0 siblings, 0 replies; 44+ messages in thread
From: Lucas De Marchi @ 2023-05-26  4:59 UTC (permalink / raw)
  To: Matt Roper; +Cc: intel-xe

On Thu, May 25, 2023 at 04:13:27PM -0700, Matt Roper wrote:
>On Thu, May 25, 2023 at 02:33:58PM -0700, Lucas De Marchi wrote:
>> There are WAs that, due to their nature, cannot be applied from a
>> central place like xe_wa.c. Those are peppered around the rest of the
>> code, as needed. Now they have a new name:  "out-of-band workarounds".
>>
>> These workarounds have their names and rules still grouped in xe_wa.c,
>> inside the xe_wa_oob array, which is generated at compile time by
>> xe_wa_oob.rules and the hostprog xe_gen_wa_oob. The code generation
>> guarantees that the header xe_wa_oob.h contains the IDs for the
>> workarounds that match the index in the table. This way the runtime
>> checks that are spread throughout the code are simple tests against the
>> bitmap saved during initialization.
>>
>> Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
>> ---
>>  drivers/gpu/drm/xe/Makefile        |  14 +++
>>  drivers/gpu/drm/xe/xe_gen_wa_oob.c | 164 +++++++++++++++++++++++++++++
>>  drivers/gpu/drm/xe/xe_gt.c         |   1 +
>>  drivers/gpu/drm/xe/xe_gt_types.h   |   2 +
>>  drivers/gpu/drm/xe/xe_wa.c         |  40 ++++++-
>>  drivers/gpu/drm/xe/xe_wa.h         |   9 ++
>>  drivers/gpu/drm/xe/xe_wa_oob.rules |   0
>>  7 files changed, 226 insertions(+), 4 deletions(-)
>>  create mode 100644 drivers/gpu/drm/xe/xe_gen_wa_oob.c
>>  create mode 100644 drivers/gpu/drm/xe/xe_wa_oob.rules
>>
>> diff --git a/drivers/gpu/drm/xe/Makefile b/drivers/gpu/drm/xe/Makefile
>> index e058b1dda6e6..738975faaa05 100644
>> --- a/drivers/gpu/drm/xe/Makefile
>> +++ b/drivers/gpu/drm/xe/Makefile
>> @@ -26,6 +26,20 @@ subdir-ccflags-$(CONFIG_DRM_XE_WERROR) += -Werror
>>
>>  subdir-ccflags-y += -I$(obj) -I$(srctree)/$(src)
>>
>> +# generated sources
>> +hostprogs := xe_gen_wa_oob
>> +
>> +XE_WA_OOB := $(obj)/generated/xe_wa_oob.c $(obj)/generated/xe_wa_oob.h
>> +
>> +quiet_cmd_wa_oob = GEN     xe_wa_oob.[ch]
>
>I think we could use "$(notdir $(XE_WA_OOB))" here to avoid hardcoding
>the names?

yeah, sounds good.

>
>Anyway, the rest looks okay.
>
>Reviewed-by: Matt Roper <matthew.d.roper@intel.com>
>
>> +      cmd_wa_oob = $^ $(XE_WA_OOB)
>> +
>> +$(XE_WA_OOB) &: $(obj)/xe_gen_wa_oob $(srctree)/$(src)/xe_wa_oob.rules
>> +	@mkdir -p $(@D)
>> +	$(call cmd,wa_oob)
>> +
>> +%.o:  $(XE_WA_OOB)

I don't know why, but when building for kunit this is not working for
me.  I'm having to replace it with:

$(obj)/xe_wa.o $(obj)/xe_guc.o: $(XE_WA_OOB)

but that is ugly and with the workarounds spread throughout the codebase
it will be a pain to maintain this in the build system. Any alternative?

Lucas De Marchi

>> +
>>  # Please keep these build lists sorted!
>>
>>  # core driver code
>> diff --git a/drivers/gpu/drm/xe/xe_gen_wa_oob.c b/drivers/gpu/drm/xe/xe_gen_wa_oob.c
>> new file mode 100644
>> index 000000000000..930cdb7ccf52
>> --- /dev/null
>> +++ b/drivers/gpu/drm/xe/xe_gen_wa_oob.c
>> @@ -0,0 +1,164 @@
>> +// SPDX-License-Identifier: MIT
>> +/*
>> + * Copyright © 2023 Intel Corporation
>> + */
>> +
>> +#define _GNU_SOURCE
>> +#include <ctype.h>
>> +#include <errno.h>
>> +#include <stdbool.h>
>> +#include <stdio.h>
>> +#include <string.h>
>> +
>> +#define HEADER \
>> +	"// SPDX-License-Identifier: MIT\n" \
>> +	"\n" \
>> +	"/*\n" \
>> +	" * DO NOT MODIFY.\n" \
>> +	" *\n" \
>> +	" * This file was generated from rules: %s\n" \
>> +	" */\n" \
>> +	"#ifndef _GENERATED_XE_WA_OOB_\n" \
>> +	"#define _GENERATED_XE_WA_OOB_\n" \
>> +	"\n" \
>> +	"enum {\n"
>> +
>> +#define FOOTER \
>> +	"};\n" \
>> +	"\n" \
>> +	"#endif\n"
>> +
>> +static void print_usage(FILE *f)
>> +{
>> +	fprintf(f, "usage: %s <input-rule-file> <generated-c-source-file> <generated-c-header-file>\n",
>> +		program_invocation_short_name);
>> +}
>> +
>> +static void print_parse_error(const char *err_msg, const char *line,
>> +			      unsigned int lineno)
>> +{
>> +	fprintf(stderr, "ERROR: %s\nERROR: %u: %.60s\n",
>> +		err_msg, lineno, line);
>> +}
>> +
>> +static char *strip(char *line, size_t linelen)
>> +{
>> +	while (isspace(*(line + linelen)))
>> +		linelen--;
>> +
>> +	line[linelen - 1] = '\0';
>> +
>> +	return  line + strspn(line, " \f\n\r\t\v");
>> +}
>> +
>> +#define MAX_LINE_LEN 4096
>> +static int parse(FILE *input, FILE *csource, FILE *cheader)
>> +{
>> +	char line[MAX_LINE_LEN + 1];
>> +	char *name, *prev_name = NULL, *rules;
>> +	unsigned int lineno = 0, idx = 0;
>> +
>> +	while (fgets(line, sizeof(line), input)) {
>> +		size_t linelen;
>> +		bool is_continuation;
>> +
>> +		if (line[0] == '\0' || line[0] == '#' || line[0] == '\n') {
>> +			lineno++;
>> +			continue;
>> +		}
>> +
>> +		linelen = strlen(line);
>> +		if (linelen == MAX_LINE_LEN) {
>> +			print_parse_error("line too long", line, lineno);
>> +			return -EINVAL;
>> +		}
>> +
>> +		is_continuation = isspace(line[0]);
>> +		name = strip(line, linelen);
>> +
>> +		if (!is_continuation) {
>> +			name = strtok(name, " \t");
>> +			rules = strtok(NULL, "");
>> +		} else {
>> +			if (!prev_name) {
>> +				print_parse_error("invalid rule continuation",
>> +						  line, lineno);
>> +				return -EINVAL;
>> +			}
>> +
>> +			rules = name;
>> +			name = NULL;
>> +		}
>> +
>> +		if (rules[0] == '\0') {
>> +			print_parse_error("invalid empty rule\n", line, lineno);
>> +			return -EINVAL;
>> +		}
>> +
>> +		if (name) {
>> +			fprintf(cheader, "\tXE_WA_OOB_%s = %u,\n", name, idx);
>> +			fprintf(csource, "{ XE_RTP_NAME(\"%s\"), XE_RTP_RULES(%s) },\n",
>> +				name, rules);
>> +		} else {
>> +			fprintf(csource, "{ XE_RTP_NAME(NULL), XE_RTP_RULES(%s) },\n",
>> +				rules);
>> +		}
>> +
>> +		idx++;
>> +		lineno++;
>> +		prev_name = name;
>> +	}
>> +
>> +	fprintf(cheader, "\t_XE_WA_OOB_COUNT = %u\n", idx);
>> +
>> +	return 0;
>> +}
>> +
>> +int main(int argc, const char *argv[])
>> +{
>> +	enum {
>> +		ARGS_INPUT,
>> +		ARGS_CSOURCE,
>> +		ARGS_CHEADER,
>> +		_ARGS_COUNT
>> +	};
>> +	struct {
>> +		const char *fn;
>> +		const char *mode;
>> +		FILE *f;
>> +	} args[] = {
>> +		[ARGS_INPUT] = { .fn = argv[1], .mode = "r" },
>> +		[ARGS_CSOURCE] = { .fn = argv[2], .mode = "w" },
>> +		[ARGS_CHEADER] = { .fn = argv[3], .mode = "w" },
>> +	};
>> +	int ret = 1;
>> +
>> +	if (argc < 3) {
>> +		fprintf(stderr, "ERROR: wrong arguments\n");
>> +		print_usage(stderr);
>> +		return 1;
>> +	}
>> +
>> +	for (int i = 0; i < _ARGS_COUNT; i++) {
>> +		args[i].f = fopen(args[i].fn, args[i].mode);
>> +		if (!args[i].f) {
>> +			fprintf(stderr, "ERROR: Can't open %s: %m\n",
>> +				args[i].fn);
>> +			goto err;
>> +		}
>> +	}
>> +
>> +	fprintf(args[ARGS_CHEADER].f, HEADER, args[ARGS_INPUT].fn);
>> +	ret = parse(args[ARGS_INPUT].f, args[ARGS_CSOURCE].f,
>> +		    args[ARGS_CHEADER].f);
>> +	if (!ret)
>> +		fprintf(args[ARGS_CHEADER].f, FOOTER);
>> +
>> +err:
>> +	for (int i = 0; i < _ARGS_COUNT; i++) {
>> +		if (args[i].f)
>> +			fclose(args[i].f);
>> +	}
>> +
>> +	return ret;
>> +}
>> diff --git a/drivers/gpu/drm/xe/xe_gt.c b/drivers/gpu/drm/xe/xe_gt.c
>> index d139554316d4..18eda5b1377f 100644
>> --- a/drivers/gpu/drm/xe/xe_gt.c
>> +++ b/drivers/gpu/drm/xe/xe_gt.c
>> @@ -321,6 +321,7 @@ int xe_gt_init_early(struct xe_gt *gt)
>>  		return err;
>>
>>  	xe_wa_process_gt(gt);
>> +	xe_wa_process_oob(gt);
>>  	xe_tuning_process_gt(gt);
>>
>>  	return 0;
>> diff --git a/drivers/gpu/drm/xe/xe_gt_types.h b/drivers/gpu/drm/xe/xe_gt_types.h
>> index 017ab60f2498..b83c834e7ced 100644
>> --- a/drivers/gpu/drm/xe/xe_gt_types.h
>> +++ b/drivers/gpu/drm/xe/xe_gt_types.h
>> @@ -368,6 +368,8 @@ struct xe_gt {
>>  		unsigned long *engine;
>>  		/** @lrc: bitmap with active LRC workarounds */
>>  		unsigned long *lrc;
>> +		/** @oob: bitmap with active OOB workaroudns */
>> +		unsigned long *oob;
>>  	} wa_active;
>>  };
>>
>> diff --git a/drivers/gpu/drm/xe/xe_wa.c b/drivers/gpu/drm/xe/xe_wa.c
>> index b717e0025bd9..ded100245479 100644
>> --- a/drivers/gpu/drm/xe/xe_wa.c
>> +++ b/drivers/gpu/drm/xe/xe_wa.c
>> @@ -9,6 +9,7 @@
>>  #include <kunit/visibility.h>
>>  #include <linux/compiler_types.h>
>>
>> +#include "generated/xe_wa_oob.h"
>>  #include "regs/xe_engine_regs.h"
>>  #include "regs/xe_gt_regs.h"
>>  #include "regs/xe_regs.h"
>> @@ -73,8 +74,8 @@
>>   *      engine registers are restored in a context restore sequence. This is
>>   *      currently not used in the driver.
>>   *
>> - * - Other:  There are WAs that, due to their nature, cannot be applied from a
>> - *   central place. Those are peppered around the rest of the code, as needed.
>> + * - Other/OOB:  There are WAs that, due to their nature, cannot be applied from
>> + *   a central place. Those are peppered around the rest of the code, as needed.
>>   *   Workarounds related to the display IP are the main example.
>>   *
>>   * .. [1] Technically, some registers are powercontext saved & restored, so they
>> @@ -579,8 +580,31 @@ static const struct xe_rtp_entry_sr lrc_was[] = {
>>  	{}
>>  };
>>
>> +static __maybe_unused const struct xe_rtp_entry oob_was[] = {
>> +#include <generated/xe_wa_oob.c>
>> +	{}
>> +};
>> +
>> +static_assert(ARRAY_SIZE(oob_was) - 1 == _XE_WA_OOB_COUNT);
>> +
>>  __diag_pop();
>>
>> +/**
>> + * xe_wa_process_oob - process OOB workaround table
>> + * @gt: GT instance to process workarounds for
>> + *
>> + * Process OOB workaround table for this platform, marking in @gt the
>> + * workarounds that are active.
>> + */
>> +void xe_wa_process_oob(struct xe_gt *gt)
>> +{
>> +	struct xe_rtp_process_ctx ctx = XE_RTP_PROCESS_CTX_INITIALIZER(gt);
>> +
>> +	xe_rtp_process_ctx_enable_active_tracking(&ctx, gt->wa_active.oob,
>> +						  ARRAY_SIZE(oob_was));
>> +	xe_rtp_process(&ctx, oob_was);
>> +}
>> +
>>  /**
>>   * xe_wa_process_gt - process GT workaround table
>>   * @gt: GT instance to process workarounds for
>> @@ -641,13 +665,14 @@ void xe_wa_process_lrc(struct xe_hw_engine *hwe)
>>  int xe_wa_init(struct xe_gt *gt)
>>  {
>>  	struct xe_device *xe = gt_to_xe(gt);
>> -	size_t n_lrc, n_engine, n_gt, total;
>> +	size_t n_oob, n_lrc, n_engine, n_gt, total;
>>  	unsigned long *p;
>>
>>  	n_gt = BITS_TO_LONGS(ARRAY_SIZE(gt_was));
>>  	n_engine = BITS_TO_LONGS(ARRAY_SIZE(engine_was));
>>  	n_lrc = BITS_TO_LONGS(ARRAY_SIZE(lrc_was));
>> -	total = n_gt + n_engine + n_lrc;
>> +	n_oob = BITS_TO_LONGS(ARRAY_SIZE(oob_was));
>> +	total = n_gt + n_engine + n_lrc + n_oob;
>>
>>  	p = drmm_kzalloc(&xe->drm, sizeof(*p) * total, GFP_KERNEL);
>>  	if (!p)
>> @@ -658,6 +683,8 @@ int xe_wa_init(struct xe_gt *gt)
>>  	gt->wa_active.engine = p;
>>  	p += n_engine;
>>  	gt->wa_active.lrc = p;
>> +	p += n_lrc;
>> +	gt->wa_active.oob = p;
>>
>>  	return 0;
>>  }
>> @@ -677,4 +704,9 @@ void xe_wa_dump(struct xe_gt *gt, struct drm_printer *p)
>>  	drm_printf(p, "\nLRC Workarounds\n");
>>  	for_each_set_bit(idx, gt->wa_active.lrc, ARRAY_SIZE(lrc_was))
>>  		drm_printf_indent(p, 1, "%s\n", lrc_was[idx].name);
>> +
>> +	drm_printf(p, "\nOOB Workarounds\n");
>> +	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);
>>  }
>> diff --git a/drivers/gpu/drm/xe/xe_wa.h b/drivers/gpu/drm/xe/xe_wa.h
>> index defefa5d9611..cfe685989524 100644
>> --- a/drivers/gpu/drm/xe/xe_wa.h
>> +++ b/drivers/gpu/drm/xe/xe_wa.h
>> @@ -11,6 +11,7 @@ struct xe_gt;
>>  struct xe_hw_engine;
>>
>>  int xe_wa_init(struct xe_gt *gt);
>> +void xe_wa_process_oob(struct xe_gt *gt);
>>  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);
>> @@ -18,4 +19,12 @@ void xe_wa_process_lrc(struct xe_hw_engine *hwe);
>>  void xe_reg_whitelist_process_engine(struct xe_hw_engine *hwe);
>>  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
>> + * @gt__: gt instance
>> + * @id__: XE_OOB_<id__>, as generated by build system in generated/xe_wa_oob.h
>> + */
>> +#define XE_WA(gt__, id__) test_bit(XE_WA_OOB_ ## id__, (gt__)->wa_active.oob)
>> +
>>  #endif
>> diff --git a/drivers/gpu/drm/xe/xe_wa_oob.rules b/drivers/gpu/drm/xe/xe_wa_oob.rules
>> new file mode 100644
>> index 000000000000..e69de29bb2d1
>> --
>> 2.40.1
>>
>
>-- 
>Matt Roper
>Graphics Software Engineer
>Linux GPU Platform Enablement
>Intel Corporation

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: [Intel-xe] [PATCH v4 17/21] drm/xe/guc: Port Wa_22012727170/Wa_22012727685 to xe_wa
  2023-05-25 23:25   ` Matt Roper
@ 2023-05-26  5:06     ` Lucas De Marchi
  0 siblings, 0 replies; 44+ messages in thread
From: Lucas De Marchi @ 2023-05-26  5:06 UTC (permalink / raw)
  To: Matt Roper; +Cc: intel-xe

On Thu, May 25, 2023 at 04:25:10PM -0700, Matt Roper wrote:
>On Thu, May 25, 2023 at 02:34:03PM -0700, Lucas De Marchi wrote:
>> Wa_22012727170 and Wa_22012727685 apply to DG2 using the same action and
>> conditions. Add both to the oob rules so they are both reported as
>> active.
>>
>> Do not Wa_22012727170 to PVC and MTL since only early A* steppings are
>> affected.
>>
>> Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
>> ---
>>  drivers/gpu/drm/xe/xe_guc.c        | 8 +-------
>>  drivers/gpu/drm/xe/xe_wa_oob.rules | 4 ++++
>>  2 files changed, 5 insertions(+), 7 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/xe/xe_guc.c b/drivers/gpu/drm/xe/xe_guc.c
>> index 5eccc4b67381..1291f71348db 100644
>> --- a/drivers/gpu/drm/xe/xe_guc.c
>> +++ b/drivers/gpu/drm/xe/xe_guc.c
>> @@ -161,13 +161,7 @@ static u32 guc_ctl_wa_flags(struct xe_guc *guc)
>>  	if (XE_WA(gt, 16011777198))
>>  		flags |= GUC_WA_RCS_RESET_BEFORE_RC6;
>>
>> -	/*
>> -	 * Wa_22012727170
>> -	 * Wa_22012727685
>> -	 */
>> -	if (IS_SUBPLATFORM_STEP(xe, XE_DG2, XE_SUBPLATFORM_DG2_G10, STEP_A0, STEP_C0) ||
>> -	    IS_SUBPLATFORM_STEP(xe, XE_DG2, XE_SUBPLATFORM_DG2_G11, STEP_A0,
>> -				STEP_FOREVER))
>> +	if (XE_WA(gt, 22012727170) || XE_WA(gt, 22012727685))
>>  		flags |= GUC_WA_CONTEXT_ISOLATION;
>>
>>  	/* Wa_16015675438, Wa_18020744125 */
>> diff --git a/drivers/gpu/drm/xe/xe_wa_oob.rules b/drivers/gpu/drm/xe/xe_wa_oob.rules
>> index 3d4304b7111e..fecf9dd431c5 100644
>> --- a/drivers/gpu/drm/xe/xe_wa_oob.rules
>> +++ b/drivers/gpu/drm/xe/xe_wa_oob.rules
>> @@ -4,3 +4,7 @@
>>  14012197797	PLATFORM(DG2), GRAPHICS_STEP(A0, B0)
>>  16011777198	SUBPLATFORM(DG2, G10), GRAPHICS_STEP(A0, C0)
>>  		SUBPLATFORM(DG2, G11), GRAPHICS_STEP(A0, B0)
>> +22012727170	SUBPLATFORM(DG2, G10), GRAPHICS_STEP(A0, C0)
>> +		SUBPLATFORM(DG2, G11), GRAPHICS_STEP(A0, FOREVER)
>> +22012727685	SUBPLATFORM(DG2, G10), GRAPHICS_STEP(A0, C0)
>
>I don't think the G10 condition applies to 22012727685 if I'm reading
>the database right.

yeah, you are right.

Lucas De Marchi

>
>
>Matt
>
>> +		SUBPLATFORM(DG2, G11), GRAPHICS_STEP(A0, FOREVER)
>> --
>> 2.40.1
>>
>
>-- 
>Matt Roper
>Graphics Software Engineer
>Linux GPU Platform Enablement
>Intel Corporation

^ permalink raw reply	[flat|nested] 44+ messages in thread

end of thread, other threads:[~2023-05-26  5:06 UTC | newest]

Thread overview: 44+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-25 21:33 [Intel-xe] [PATCH v4 00/21] Dump + OOB workarounds Lucas De Marchi
2023-05-25 21:33 ` [Intel-xe] [PATCH v4 01/21] drm/xe: Fix Wa_22011802037 annotation Lucas De Marchi
2023-05-25 21:33 ` [Intel-xe] [PATCH v4 02/21] drm/xe/rtp: Split rtp process initialization Lucas De Marchi
2023-05-25 21:33 ` [Intel-xe] [PATCH v4 03/21] drm/xe/rtp: Replace XE_WARN_ON Lucas De Marchi
2023-05-25 22:18   ` Matt Roper
2023-05-25 21:33 ` [Intel-xe] [PATCH v4 04/21] drm/xe/rtp: Add "_sr" to entry/function names Lucas De Marchi
2023-05-25 21:33 ` [Intel-xe] [PATCH v4 05/21] drm/xe/rtp: Allow to track active workarounds Lucas De Marchi
2023-05-25 21:33 ` [Intel-xe] [PATCH v4 06/21] drm/xe/wa: Track gt/engine/lrc " Lucas De Marchi
2023-05-25 22:28   ` Matt Roper
2023-05-25 21:33 ` [Intel-xe] [PATCH v4 07/21] drm/xe/debugfs: Dump " Lucas De Marchi
2023-05-25 22:29   ` Matt Roper
2023-05-25 21:33 ` [Intel-xe] [PATCH v4 08/21] drm/xe/rtp: Rename STEP to GRAPHICS_STEP Lucas De Marchi
2023-05-25 22:31   ` Matt Roper
2023-05-25 21:33 ` [Intel-xe] [PATCH v4 09/21] drm/xe/rtp: Add check for media stepping Lucas De Marchi
2023-05-25 22:39   ` Matt Roper
2023-05-25 21:33 ` [Intel-xe] [PATCH v4 10/21] drm/xe/rtp: Add support for entries with no action Lucas De Marchi
2023-05-25 21:33 ` [Intel-xe] [PATCH v4 11/21] drm/xe: Include build directory Lucas De Marchi
2023-05-25 22:41   ` Matt Roper
2023-05-25 21:33 ` [Intel-xe] [PATCH v4 12/21] drm/xe: Add support for OOB workarounds Lucas De Marchi
2023-05-25 23:13   ` Matt Roper
2023-05-26  4:59     ` Lucas De Marchi
2023-05-25 21:33 ` [Intel-xe] [PATCH v4 13/21] drm/xe/guc: Port Wa_22012773006 to xe_wa Lucas De Marchi
2023-05-25 23:14   ` Matt Roper
2023-05-25 21:34 ` [Intel-xe] [PATCH v4 14/21] drm/xe/guc: Port Wa_16011759253 " Lucas De Marchi
2023-05-25 23:17   ` Matt Roper
2023-05-26  4:42     ` Lucas De Marchi
2023-05-25 21:34 ` [Intel-xe] [PATCH v4 15/21] drm/xe/guc: Port Wa_14012197797/Wa_22011391025 " Lucas De Marchi
2023-05-25 23:18   ` Matt Roper
2023-05-25 21:34 ` [Intel-xe] [PATCH v4 16/21] drm/xe/guc: Port Wa_16011777198 " Lucas De Marchi
2023-05-25 23:19   ` Matt Roper
2023-05-25 21:34 ` [Intel-xe] [PATCH v4 17/21] drm/xe/guc: Port Wa_22012727170/Wa_22012727685 " Lucas De Marchi
2023-05-25 23:25   ` Matt Roper
2023-05-26  5:06     ` Lucas De Marchi
2023-05-25 21:34 ` [Intel-xe] [PATCH v4 18/21] drm/xe/guc: Port Wa_16015675438/Wa_18020744125 " Lucas De Marchi
2023-05-25 23:28   ` Matt Roper
2023-05-25 21:34 ` [Intel-xe] [PATCH v4 19/21] drm/xe/guc: Port Wa_1509372804 " Lucas De Marchi
2023-05-25 23:30   ` Matt Roper
2023-05-25 21:34 ` [Intel-xe] [PATCH v4 20/21] drm/xe/rtp: Also check gt type Lucas De Marchi
2023-05-25 23:34   ` Matt Roper
2023-05-25 21:34 ` [Intel-xe] [PATCH v4 21/21] drm/xe/guc: Port Wa_14014475959 to xe_wa and fix it Lucas De Marchi
2023-05-25 23:35   ` Matt Roper
2023-05-25 21:38 ` [Intel-xe] ✓ CI.Patch_applied: success for Dump + OOB workarounds Patchwork
2023-05-25 21:39 ` [Intel-xe] ✗ CI.KUnit: failure " Patchwork
2023-05-25 21:44   ` Lucas De Marchi

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.