Intel-XE Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Michal Wajdeczko <michal.wajdeczko@intel.com>
To: intel-xe@lists.freedesktop.org
Subject: [PATCH v3 11/13] drm/xe/tests: Add GuC KLV printer test
Date: Sat, 11 Jul 2026 09:36:08 +0200	[thread overview]
Message-ID: <20260711073608.7829-1-michal.wajdeczko@intel.com> (raw)
In-Reply-To: <20260707220816.677-12-michal.wajdeczko@intel.com>

For completeness, add a simple test to exercise the KLV printer
to make sure it doesn't crash at least.

Signed-off-by: Michal Wajdeczko <michal.wajdeczko@intel.com>
Reviewed-by: Michał Winiarski <michal.winiarski@intel.com>
---
 .../drm/xe/tests/xe_guc_klv_helpers_kunit.c   | 41 +++++++++++++++++++
 1 file changed, 41 insertions(+)

diff --git a/drivers/gpu/drm/xe/tests/xe_guc_klv_helpers_kunit.c b/drivers/gpu/drm/xe/tests/xe_guc_klv_helpers_kunit.c
index 33d7a52f6bf8..82869363ab7e 100644
--- a/drivers/gpu/drm/xe/tests/xe_guc_klv_helpers_kunit.c
+++ b/drivers/gpu/drm/xe/tests/xe_guc_klv_helpers_kunit.c
@@ -10,6 +10,11 @@
 #define TEST_GROUP_KEY	(GUC_KLV_RESERVED_RANGE_START + 0x3f0)
 #define TEST_PAD	0xdeadbeef
 
+static bool fake_is_group_key(u16 key)
+{
+	return is_reserved_key(key) && key >= TEST_GROUP_KEY;
+}
+
 static void test_count(struct kunit *test)
 {
 	u32 value = 0x12345678;
@@ -368,6 +373,41 @@ static void test_encode_object_basic(struct kunit *test)
 						     obj_echo_encoder));
 }
 
+static void __drm_printfn_kunit(struct drm_printer *p, struct va_format *vaf)
+{
+	struct kunit *test = p->arg;
+
+	kunit_info(test, "%pV", vaf);
+}
+
+static struct drm_printer drm_kunit_printer(void)
+{
+	struct drm_printer p = {
+		.printfn = __drm_printfn_kunit,
+		.arg = kunit_get_current_test(),
+	};
+	return p;
+}
+
+static void test_print(struct kunit *test)
+{
+	struct drm_printer p = drm_kunit_printer();
+	u32 zeros[] = { 0, 0, 0, /* padding */ };
+	u32 klvs[] = {
+		PREP_GUC_KLV(GUC_KLV_OPT_IN_FEATURE_EXT_CAT_ERR_TYPE_KEY, 0),
+		PREP_GUC_KLV(GUC_KLV_VF_CFG_NUM_CONTEXTS_KEY, 1), 1234,
+		PREP_GUC_KLV(GUC_KLV_VF_CFG_GGTT_SIZE_KEY, 2), 0x4000, 0x0123,
+		PREP_GUC_KLV(TEST_KEY, 3), 1, 2, 3,
+		PREP_GUC_KLV(TEST_GROUP_KEY, 5),
+		PREP_GUC_KLV(TEST_KEY + 1, 1), 1,
+		PREP_GUC_KLV(TEST_KEY + 2, 2), 1, 2,
+	};
+
+	kunit_activate_static_stub(test, is_group_key, fake_is_group_key);
+	xe_guc_klv_print(zeros, ARRAY_SIZE(zeros), &p);
+	xe_guc_klv_print(klvs, ARRAY_SIZE(klvs), &p);
+}
+
 static struct kunit_case guc_klv_helpers_test_cases[] = {
 	KUNIT_CASE(test_count),
 	KUNIT_CASE(test_encode_u32),
@@ -377,6 +417,7 @@ static struct kunit_case guc_klv_helpers_test_cases[] = {
 	KUNIT_CASE(test_encode_object_klv),
 	KUNIT_CASE(test_encode_object_nested),
 	KUNIT_CASE(test_encode_object_basic),
+	KUNIT_CASE(test_print),
 	{}
 };
 
-- 
2.47.1


  reply	other threads:[~2026-07-11  7:36 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-07 22:08 [PATCH v2 00/13] drm/xe: Add and use more KLV helpers Michal Wajdeczko
2026-07-07 22:08 ` [PATCH v2 01/13] drm/xe/guc: Allow to print single KLV Michal Wajdeczko
2026-07-07 22:08 ` [PATCH v2 02/13] drm/xe/guc: Prepare to print group KLVs Michal Wajdeczko
2026-07-07 22:08 ` [PATCH v2 03/13] drm/xe/guc: Add basic KLV encoding helpers Michal Wajdeczko
2026-07-07 22:08 ` [PATCH v2 04/13] drm/xe/guc: Add string KLV encoding helper Michal Wajdeczko
2026-07-09 12:51   ` Michał Winiarski
2026-07-07 22:08 ` [PATCH v2 05/13] drm/xe/guc: Add object " Michal Wajdeczko
2026-07-09 12:53   ` Michał Winiarski
2026-07-07 22:08 ` [PATCH v2 06/13] drm/xe/guc: Add KLV parsing helper Michal Wajdeczko
2026-07-07 22:08 ` [PATCH v2 07/13] drm/xe/guc: Formalize Reserved KLVs Michal Wajdeczko
2026-07-10 17:25   ` [PATCH v3 " Michal Wajdeczko
2026-07-07 22:08 ` [PATCH v2 08/13] drm/xe/tests: Add GuC KLV helpers basic tests Michal Wajdeczko
2026-07-07 22:08 ` [PATCH v2 09/13] drm/xe/tests: Add string encoding helper test Michal Wajdeczko
2026-07-08 18:07   ` [PATCH v3 " Michal Wajdeczko
2026-07-07 22:08 ` [PATCH v2 10/13] drm/xe/tests: Add object " Michal Wajdeczko
2026-07-10 19:59   ` [PATCH v3 " Michal Wajdeczko
2026-07-07 22:08 ` [PATCH v2 11/13] drm/xe/tests: Add GuC KLV printer test Michal Wajdeczko
2026-07-11  7:36   ` Michal Wajdeczko [this message]
2026-07-07 22:08 ` [PATCH v2 12/13] drm/xe/tests: Add migration packet test Michal Wajdeczko
2026-07-08 18:09   ` [PATCH v3 " Michal Wajdeczko
2026-07-07 22:08 ` [PATCH v2 13/13] drm/xe/pf: Handle migration descriptor using KLV helpers Michal Wajdeczko
2026-07-07 22:16 ` ✗ CI.checkpatch: warning for drm/xe: Add and use more KLV helpers (rev2) Patchwork
2026-07-07 22:18 ` ✓ CI.KUnit: success " Patchwork
2026-07-07 23:04 ` ✓ Xe.CI.BAT: " Patchwork
2026-07-08  0:20 ` ✓ Xe.CI.FULL: " Patchwork
2026-07-08 19:04 ` ✗ CI.checkpatch: warning for drm/xe: Add and use more KLV helpers (rev4) Patchwork
2026-07-08 19:05 ` ✓ CI.KUnit: success " Patchwork
2026-07-08 19:55 ` ✓ Xe.CI.BAT: " Patchwork
2026-07-08 23:56 ` ✓ Xe.CI.FULL: " Patchwork
2026-07-10 17:31 ` ✗ CI.checkpatch: warning for drm/xe: Add and use more KLV helpers (rev5) Patchwork
2026-07-10 17:32 ` ✓ CI.KUnit: success " Patchwork
2026-07-10 18:22 ` ✓ Xe.CI.BAT: " Patchwork
2026-07-11  4:04 ` ✓ Xe.CI.FULL: " Patchwork
2026-07-11  7:42 ` ✗ CI.checkpatch: warning for drm/xe: Add and use more KLV helpers (rev7) Patchwork
2026-07-11  7:43 ` ✓ CI.KUnit: success " Patchwork
2026-07-11  8:18 ` ✓ Xe.CI.BAT: " Patchwork
2026-07-11 11:12 ` ✓ Xe.CI.FULL: " 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=20260711073608.7829-1-michal.wajdeczko@intel.com \
    --to=michal.wajdeczko@intel.com \
    --cc=intel-xe@lists.freedesktop.org \
    /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