[Intel-xe] [PATCH 5/5] drm/xe: Initial selftests for xe_guc_ct

Michal Wajdeczko michal.wajdeczko at intel.com
Mon Mar 13 08:13:16 UTC 2023


Add few very basic mock and live selftests for the xe_guc_ct.

Signed-off-by: Michal Wajdeczko <michal.wajdeczko at intel.com>
---
 .../selftests/live/xe_guc_ct_live_selftest.c  | 52 +++++++++++++++++++
 .../selftests/mock/xe_guc_ct_mock_selftest.c  | 31 +++++++++++
 drivers/gpu/drm/xe/xe_guc_ct.c                |  6 +++
 3 files changed, 89 insertions(+)
 create mode 100644 drivers/gpu/drm/xe/selftests/live/xe_guc_ct_live_selftest.c
 create mode 100644 drivers/gpu/drm/xe/selftests/mock/xe_guc_ct_mock_selftest.c

diff --git a/drivers/gpu/drm/xe/selftests/live/xe_guc_ct_live_selftest.c b/drivers/gpu/drm/xe/selftests/live/xe_guc_ct_live_selftest.c
new file mode 100644
index 000000000000..73da4c5d6e81
--- /dev/null
+++ b/drivers/gpu/drm/xe/selftests/live/xe_guc_ct_live_selftest.c
@@ -0,0 +1,52 @@
+// SPDX-License-Identifier: GPL-2.0 AND MIT
+/*
+ * Copyright © 2023 Intel Corporation
+ */
+
+#include <kunit/test.h>
+
+#include "selftests/xe_selftests.h"
+
+static void test_ct_not_broken(struct kunit *test)
+{
+	struct xe_guc *guc = test->priv;
+	struct xe_guc_ct *ct = &guc->ct;
+
+	KUNIT_EXPECT_FALSE(test, ct->ctbs.h2g.broken);
+	KUNIT_EXPECT_FALSE(test, ct->ctbs.g2h.broken);
+}
+
+static int guc_ct_send_unknown_action(struct xe_guc_ct *ct)
+{
+	u32 request[] = {
+		FIELD_PREP(GUC_HXG_MSG_0_ORIGIN, GUC_HXG_ORIGIN_HOST) |
+		FIELD_PREP(GUC_HXG_MSG_0_TYPE, GUC_HXG_TYPE_REQUEST) |
+		FIELD_PREP(GUC_HXG_REQUEST_MSG_0_ACTION, 0xDEAD),
+	};
+
+	return xe_guc_ct_send_block(ct, request, ARRAY_SIZE(request));
+}
+
+static void test_ct_rejects_unknown_action(struct kunit *test)
+{
+	struct xe_guc *guc = test->priv;
+
+	KUNIT_EXPECT_NE(test, 0, guc_ct_send_unknown_action(&guc->ct));
+}
+
+static struct kunit_case ct_live_test_cases[] = {
+	KUNIT_CASE(test_ct_not_broken),
+	KUNIT_CASE(test_ct_rejects_unknown_action),
+	{}
+};
+
+static struct kunit_suite ct_live_suite = {
+	.name = "ct_live",
+	.test_cases = ct_live_test_cases,
+
+	.suite_init = init_xe_live_selftest_suite,
+	.init = init_xe_guc_selftest,
+	.exit = exit_xe_guc_selftest,
+};
+
+kunit_test_suite(ct_live_suite);
diff --git a/drivers/gpu/drm/xe/selftests/mock/xe_guc_ct_mock_selftest.c b/drivers/gpu/drm/xe/selftests/mock/xe_guc_ct_mock_selftest.c
new file mode 100644
index 000000000000..db6e08b7ad8b
--- /dev/null
+++ b/drivers/gpu/drm/xe/selftests/mock/xe_guc_ct_mock_selftest.c
@@ -0,0 +1,31 @@
+// SPDX-License-Identifier: GPL-2.0 AND MIT
+/*
+ * Copyright © 2023 Intel Corporation
+ */
+
+#include <kunit/test.h>
+
+#include "selftests/xe_selftests.h"
+
+static void test_basic(struct kunit *test)
+{
+	struct xe_guc *guc = test->priv;
+	struct xe_guc_ct *ct = &guc->ct;
+
+	KUNIT_ASSERT_NOT_NULL(test, ct);
+}
+
+static struct kunit_case guc_ct_mock_test_cases[] = {
+	KUNIT_CASE(test_basic),
+	{}
+};
+
+static struct kunit_suite guc_ct_mock_suite = {
+	.name = "guc_ct_mock",
+	.test_cases = guc_ct_mock_test_cases,
+
+	.init = init_xe_guc_selftest,
+	.exit = exit_xe_guc_selftest,
+};
+
+kunit_test_suite(guc_ct_mock_suite);
diff --git a/drivers/gpu/drm/xe/xe_guc_ct.c b/drivers/gpu/drm/xe/xe_guc_ct.c
index 5e00b75d3ca2..7ed360229087 100644
--- a/drivers/gpu/drm/xe/xe_guc_ct.c
+++ b/drivers/gpu/drm/xe/xe_guc_ct.c
@@ -1203,3 +1203,9 @@ void xe_guc_ct_selftest(struct xe_guc_ct *ct, struct drm_printer *p)
 	drm_printf(p, "GuC CT selftest done - %s\n", ret ? "FAIL" : "PASS");
 }
 #endif
+
+#if IS_ENABLED(CONFIG_DRM_XE_SELFTESTS_MOCK)
+#include "selftests/mock/xe_guc_ct_mock_selftest.c"
+#elif IS_ENABLED(CONFIG_DRM_XE_SELFTESTS_LIVE)
+#include "selftests/live/xe_guc_ct_live_selftest.c"
+#endif
-- 
2.25.1



More information about the Intel-xe mailing list