Intel-XE Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Lucas De Marchi <lucas.demarchi@intel.com>
To: intel-xe@lists.freedesktop.org
Cc: Lucas De Marchi <lucas.demarchi@intel.com>,
	Matt Roper <matthew.d.roper@intel.com>
Subject: [Intel-xe] [PATCH v5 10/21] drm/xe/rtp: Add support for entries with no action
Date: Fri, 26 May 2023 09:43:47 -0700	[thread overview]
Message-ID: <20230526164358.86393-11-lucas.demarchi@intel.com> (raw)
In-Reply-To: <20230526164358.86393-1-lucas.demarchi@intel.com>

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


  parent reply	other threads:[~2023-05-26 16:44 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-26 16:43 [Intel-xe] [PATCH v5 00/21] Dump + OOB workarounds Lucas De Marchi
2023-05-26 16:43 ` [Intel-xe] [PATCH v5 01/21] drm/xe: Fix Wa_22011802037 annotation Lucas De Marchi
2023-05-26 16:43 ` [Intel-xe] [PATCH v5 02/21] drm/xe/rtp: Split rtp process initialization Lucas De Marchi
2023-05-26 16:43 ` [Intel-xe] [PATCH v5 03/21] drm/xe/rtp: Replace XE_WARN_ON Lucas De Marchi
2023-05-26 16:43 ` [Intel-xe] [PATCH v5 04/21] drm/xe/rtp: Add "_sr" to entry/function names Lucas De Marchi
2023-05-26 16:43 ` [Intel-xe] [PATCH v5 05/21] drm/xe/rtp: Allow to track active workarounds Lucas De Marchi
2023-05-26 16:43 ` [Intel-xe] [PATCH v5 06/21] drm/xe/wa: Track gt/engine/lrc " Lucas De Marchi
2023-05-26 16:43 ` [Intel-xe] [PATCH v5 07/21] drm/xe/debugfs: Dump " Lucas De Marchi
2023-05-26 16:43 ` [Intel-xe] [PATCH v5 08/21] drm/xe/rtp: Rename STEP to GRAPHICS_STEP Lucas De Marchi
2023-05-26 16:43 ` [Intel-xe] [PATCH v5 09/21] drm/xe/rtp: Add check for media stepping Lucas De Marchi
2023-05-26 16:43 ` Lucas De Marchi [this message]
2023-05-26 16:43 ` [Intel-xe] [PATCH v5 11/21] drm/xe: Include build directory Lucas De Marchi
2023-05-26 16:43 ` [Intel-xe] [PATCH v5 12/21] drm/xe: Add support for OOB workarounds Lucas De Marchi
2023-08-29  9:49   ` Jani Nikula
2023-05-26 16:43 ` [Intel-xe] [PATCH v5 13/21] drm/xe/guc: Port Wa_22012773006 to xe_wa Lucas De Marchi
2023-05-26 16:43 ` [Intel-xe] [PATCH v5 14/21] drm/xe/guc: Port Wa_16011759253 " Lucas De Marchi
2023-05-26 16:43 ` [Intel-xe] [PATCH v5 15/21] drm/xe/guc: Port Wa_14012197797/Wa_22011391025 " Lucas De Marchi
2023-05-26 16:43 ` [Intel-xe] [PATCH v5 16/21] drm/xe/guc: Port Wa_16011777198 " Lucas De Marchi
2023-05-26 16:43 ` [Intel-xe] [PATCH v5 17/21] drm/xe/guc: Port Wa_22012727170/Wa_22012727685 " Lucas De Marchi
2023-05-26 16:54   ` Matt Roper
2023-05-26 17:23     ` Lucas De Marchi
2023-05-26 16:43 ` [Intel-xe] [PATCH v5 18/21] drm/xe/guc: Port Wa_16015675438/Wa_18020744125 " Lucas De Marchi
2023-05-26 16:56   ` Matt Roper
2023-05-26 16:43 ` [Intel-xe] [PATCH v5 19/21] drm/xe/guc: Port Wa_1509372804 " Lucas De Marchi
2023-05-26 16:43 ` [Intel-xe] [PATCH v5 20/21] drm/xe/rtp: Also check gt type Lucas De Marchi
2023-05-26 16:43 ` [Intel-xe] [PATCH v5 21/21] drm/xe/guc: Port Wa_14014475959 to xe_wa and fix it Lucas De Marchi
2023-05-26 16:58 ` [Intel-xe] ✓ CI.Patch_applied: success for Dump + OOB workarounds Patchwork
2023-05-26 17:00 ` [Intel-xe] ✓ CI.KUnit: " Patchwork
2023-05-26 17:04 ` [Intel-xe] ✓ CI.Build: " Patchwork
2023-05-26 17:32 ` [Intel-xe] ○ CI.BAT: info " Patchwork

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230526164358.86393-11-lucas.demarchi@intel.com \
    --to=lucas.demarchi@intel.com \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=matthew.d.roper@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox