[PATCH 1/2] drm/xe/rtp: Prepare RTP for VF rules

Michal Wajdeczko michal.wajdeczko at intel.com
Fri Jun 14 21:48:20 UTC 2024


We don't want any current RTP actions to be processed by the VF
drivers, but instead of blocking them completely, add new match
types that would allow new VF-ready or VF-only rules to be added.

Signed-off-by: Michal Wajdeczko <michal.wajdeczko at intel.com>
Cc: Lucas De Marchi <lucas.demarchi at intel.com>
---
 drivers/gpu/drm/xe/xe_rtp.c       | 13 ++++++++++++-
 drivers/gpu/drm/xe/xe_rtp.h       | 16 ++++++++++++++++
 drivers/gpu/drm/xe/xe_rtp_types.h |  2 ++
 3 files changed, 30 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/xe/xe_rtp.c b/drivers/gpu/drm/xe/xe_rtp.c
index eff1c9c2f5cc..0bea1f374f6a 100644
--- a/drivers/gpu/drm/xe/xe_rtp.c
+++ b/drivers/gpu/drm/xe/xe_rtp.c
@@ -13,6 +13,7 @@
 #include "xe_gt_topology.h"
 #include "xe_macros.h"
 #include "xe_reg_sr.h"
+#include "xe_sriov.h"
 
 /**
  * DOC: Register Table Processing
@@ -36,6 +37,8 @@ static bool rule_matches(const struct xe_device *xe,
 {
 	const struct xe_rtp_rule *r;
 	unsigned int i;
+	bool is_vf = IS_SRIOV_VF(gt_to_xe(gt));
+	bool match_vf = false;
 	bool match;
 
 	for (r = rules, i = 0; i < n_rules; r = &rules[++i]) {
@@ -96,6 +99,14 @@ static bool rule_matches(const struct xe_device *xe,
 		case XE_RTP_MATCH_FUNC:
 			match = r->match_func(gt, hwe);
 			break;
+		case XE_RTP_MATCH_VF_READY:
+			match_vf = true;
+			match = true;
+			break;
+		case XE_RTP_MATCH_VF_ONLY:
+			match_vf = true;
+			match = is_vf;
+			break;
 		default:
 			drm_warn(&xe->drm, "Invalid RTP match %u\n",
 				 r->match_type);
@@ -106,7 +117,7 @@ static bool rule_matches(const struct xe_device *xe,
 			return false;
 	}
 
-	return true;
+	return is_vf ? match_vf : true;
 }
 
 static void rtp_add_sr_entry(const struct xe_rtp_action *action,
diff --git a/drivers/gpu/drm/xe/xe_rtp.h b/drivers/gpu/drm/xe/xe_rtp.h
index 337b1ef1959c..5a4194d0d208 100644
--- a/drivers/gpu/drm/xe/xe_rtp.h
+++ b/drivers/gpu/drm/xe/xe_rtp.h
@@ -179,6 +179,22 @@ struct xe_reg_sr;
 #define XE_RTP_RULE_IS_DISCRETE							\
 	{ .match_type = XE_RTP_MATCH_DISCRETE }
 
+/**
+ * XE_RTP_RULE_VF_READY - Create a rule matching also virtual function device
+ *
+ * Refer to XE_RTP_RULES() for expected usage.
+ */
+#define XE_RTP_RULE_VF_READY							\
+	{ .match_type = XE_RTP_MATCH_VF_READY }
+
+/**
+ * XE_RTP_RULE_VF_ONLY - Create a rule matching only virtual function device
+ *
+ * Refer to XE_RTP_RULES() for expected usage.
+ */
+#define XE_RTP_RULE_VF_ONLY							\
+	{ .match_type = XE_RTP_MATCH_VF_ONLY }
+
 /**
  * XE_RTP_ACTION_WR - Helper to write a value to the register, overriding all
  *                    the bits
diff --git a/drivers/gpu/drm/xe/xe_rtp_types.h b/drivers/gpu/drm/xe/xe_rtp_types.h
index 637acc7626a4..f322c8f273ea 100644
--- a/drivers/gpu/drm/xe/xe_rtp_types.h
+++ b/drivers/gpu/drm/xe/xe_rtp_types.h
@@ -51,6 +51,8 @@ enum {
 	XE_RTP_MATCH_ENGINE_CLASS,
 	XE_RTP_MATCH_NOT_ENGINE_CLASS,
 	XE_RTP_MATCH_FUNC,
+	XE_RTP_MATCH_VF_READY,
+	XE_RTP_MATCH_VF_ONLY,
 };
 
 /** struct xe_rtp_rule - match rule for processing entry */
-- 
2.43.0



More information about the Intel-xe mailing list