[PATCH 3/4] drm/xe/kunit: Update RTP tests with SR-IOV rules

Michal Wajdeczko michal.wajdeczko at intel.com
Fri Feb 21 19:00:37 UTC 2025


Add more test cases that verifies use of RTP SRIOV() rules in
driver running as native, PF and VF mode.

Signed-off-by: Michal Wajdeczko <michal.wajdeczko at intel.com>
Cc: Lucas De Marchi <lucas.demarchi at intel.com>
---
 drivers/gpu/drm/xe/tests/xe_rtp_test.c | 112 ++++++++++++++++++++++++-
 1 file changed, 111 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/xe/tests/xe_rtp_test.c b/drivers/gpu/drm/xe/tests/xe_rtp_test.c
index 36a3b5420fef..b21474df933e 100644
--- a/drivers/gpu/drm/xe/tests/xe_rtp_test.c
+++ b/drivers/gpu/drm/xe/tests/xe_rtp_test.c
@@ -45,6 +45,8 @@ struct rtp_to_sr_test_case {
 struct rtp_test_case {
 	const char *name;
 	unsigned long expected_active;
+	unsigned long expected_active_pf;
+	unsigned long expected_active_vf;
 	const struct xe_rtp_entry *entries;
 };
 
@@ -469,6 +471,89 @@ static const struct rtp_test_case rtp_cases[] = {
 	},
 };
 
+static const struct rtp_test_case sriov_cases[] = {
+	{
+		.name = "non_vf",
+		.expected_active = BIT(0) | BIT(1),
+		.expected_active_pf = BIT(0) | BIT(1),
+		.expected_active_vf = 0,
+		.entries = (const struct xe_rtp_entry[]) {
+			{ XE_RTP_NAME("and"),
+			  XE_RTP_RULES(FUNC(match_yes)),
+			},
+			{ XE_RTP_NAME("or"),
+			  XE_RTP_RULES(FUNC(match_no), OR,
+				       FUNC(match_yes)),
+			},
+			{}
+		},
+	},
+	{
+		.name = "vf_ready",
+		.expected_active = BIT(0) | BIT(1),
+		.expected_active_pf = BIT(0) | BIT(1),
+		.expected_active_vf = BIT(0) | BIT(1),
+		.entries = (const struct xe_rtp_entry[]) {
+			{ XE_RTP_NAME("and"),
+			  XE_RTP_RULES(FUNC(match_yes), SRIOV(VF_READY)),
+			},
+			{ XE_RTP_NAME("or"),
+			  XE_RTP_RULES(FUNC(match_no), OR,
+				       FUNC(match_yes), SRIOV(VF_READY)),
+			},
+			{}
+		},
+	},
+	{
+		.name = "vf_only",
+		.expected_active = 0,
+		.expected_active_pf = 0,
+		.expected_active_vf = BIT(0) | BIT(1),
+		.entries = (const struct xe_rtp_entry[]) {
+			{ XE_RTP_NAME("and"),
+			  XE_RTP_RULES(FUNC(match_yes), SRIOV(VF_ONLY)),
+			},
+			{ XE_RTP_NAME("or"),
+			  XE_RTP_RULES(FUNC(match_no), OR,
+				       FUNC(match_yes), SRIOV(VF_ONLY)),
+			},
+			{}
+		},
+	},
+	{
+		.name = "pf_only",
+		.expected_active = 0,
+		.expected_active_pf = BIT(0) | BIT(1),
+		.expected_active_vf = 0,
+		.entries = (const struct xe_rtp_entry[]) {
+			{ XE_RTP_NAME("and"),
+			  XE_RTP_RULES(FUNC(match_yes), SRIOV(PF_ONLY)),
+			},
+			{ XE_RTP_NAME("or"),
+			  XE_RTP_RULES(FUNC(match_no), OR,
+				       FUNC(match_yes), SRIOV(PF_ONLY)),
+			},
+			{}
+		},
+	},
+	{
+		.name = "sriov_only",
+		.expected_active = 0,
+		.expected_active_pf = BIT(0) | BIT(1),
+		.expected_active_vf = BIT(0) | BIT(1),
+		.entries = (const struct xe_rtp_entry[]) {
+			{ XE_RTP_NAME("and"),
+			  XE_RTP_RULES(FUNC(match_yes), SRIOV(ONLY)),
+			},
+			{ XE_RTP_NAME("or"),
+			  XE_RTP_RULES(FUNC(match_no), OR,
+				       FUNC(match_yes), SRIOV(ONLY)),
+			},
+			{}
+		},
+	},
+};
+
 static void xe_rtp_process_tests(struct kunit *test)
 {
 	const struct rtp_test_case *param = test->param_value;
@@ -483,7 +568,28 @@ static void xe_rtp_process_tests(struct kunit *test)
 	xe_rtp_process_ctx_enable_active_tracking(&ctx, &active, count_rtp_entries);
 	xe_rtp_process(&ctx, param->entries);
 
-	KUNIT_EXPECT_EQ(test, active, param->expected_active);
+	if (IS_SRIOV_PF(xe))
+		KUNIT_EXPECT_EQ(test, active, param->expected_active_pf);
+	else if (IS_SRIOV_VF(xe))
+		KUNIT_EXPECT_EQ(test, active, param->expected_active_vf);
+	else
+		KUNIT_EXPECT_EQ(test, active, param->expected_active);
+}
+
+static void xe_rtp_process_tests_pf(struct kunit *test)
+{
+	struct xe_device *xe = test->priv;
+
+	xe->sriov.__mode = XE_SRIOV_MODE_PF;
+	xe_rtp_process_tests(test);
+}
+
+static void xe_rtp_process_tests_vf(struct kunit *test)
+{
+	struct xe_device *xe = test->priv;
+
+	xe->sriov.__mode = XE_SRIOV_MODE_VF;
+	xe_rtp_process_tests(test);
 }
 
 static void rtp_to_sr_desc(const struct rtp_to_sr_test_case *t, char *desc)
@@ -499,6 +605,7 @@ static void rtp_desc(const struct rtp_test_case *t, char *desc)
 }
 
 KUNIT_ARRAY_PARAM(rtp, rtp_cases, rtp_desc);
+KUNIT_ARRAY_PARAM(sriov, sriov_cases, rtp_desc);
 
 static int xe_rtp_test_init(struct kunit *test)
 {
@@ -533,6 +640,9 @@ static void xe_rtp_test_exit(struct kunit *test)
 static struct kunit_case xe_rtp_tests[] = {
 	KUNIT_CASE_PARAM(xe_rtp_process_to_sr_tests, rtp_to_sr_gen_params),
 	KUNIT_CASE_PARAM(xe_rtp_process_tests, rtp_gen_params),
+	KUNIT_CASE_PARAM(xe_rtp_process_tests, sriov_gen_params),
+	KUNIT_CASE_PARAM(xe_rtp_process_tests_pf, sriov_gen_params),
+	KUNIT_CASE_PARAM(xe_rtp_process_tests_vf, sriov_gen_params),
 	{}
 };
 
-- 
2.47.1



More information about the Intel-xe mailing list