public inbox for intel-xe@lists.freedesktop.org
 help / color / mirror / Atom feed
From: Michal Wajdeczko <michal.wajdeczko@intel.com>
To: intel-xe@lists.freedesktop.org
Cc: Michal Wajdeczko <michal.wajdeczko@intel.com>
Subject: [PATCH 05/13] drm/xe/kunit: Promote GGTT initialization to test_init() helper
Date: Tue, 28 Apr 2026 16:27:12 +0200	[thread overview]
Message-ID: <20260428142722.582-6-michal.wajdeczko@intel.com> (raw)
In-Reply-To: <20260428142722.582-1-michal.wajdeczko@intel.com>

Our test_init() helper already do a minimal initialization of the
kunit fake xe_device, including basic setup of main components like
xe_tile and xe_gt, but some other main components, like xe_ggtt or
xe_mmio, were completely untouched. Move basic GGTT initialization
to the test_init() helper function, as it does not require much
work, and allows to simplify other tests init functions.

Signed-off-by: Michal Wajdeczko <michal.wajdeczko@intel.com>
---
 drivers/gpu/drm/xe/tests/xe_guc_buf_kunit.c |  9 +++------
 drivers/gpu/drm/xe/tests/xe_kunit_helpers.c | 20 ++++++++++++++++++++
 drivers/gpu/drm/xe/tests/xe_pci_test.h      |  2 ++
 3 files changed, 25 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/xe/tests/xe_guc_buf_kunit.c b/drivers/gpu/drm/xe/tests/xe_guc_buf_kunit.c
index 51e1e04001ac..0108316fa64a 100644
--- a/drivers/gpu/drm/xe/tests/xe_guc_buf_kunit.c
+++ b/drivers/gpu/drm/xe/tests/xe_guc_buf_kunit.c
@@ -51,19 +51,16 @@ static int guc_buf_test_init(struct kunit *test)
 		.sriov_mode = XE_SRIOV_MODE_PF,
 		.platform = XE_TIGERLAKE, /* some random platform */
 		.subplatform = XE_SUBPLATFORM_NONE,
+		.ggtt_start = DUT_GGTT_START,
+		.ggtt_size = DUT_GGTT_SIZE,
 	};
-	struct xe_ggtt *ggtt;
 	struct xe_guc *guc;
 
 	test->priv = &fake;
 	xe_kunit_helper_xe_device_test_init(test);
 
-	ggtt = xe_device_get_root_tile(test->priv)->mem.ggtt;
 	guc = &xe_device_get_gt(test->priv, 0)->uc.guc;
-
-	KUNIT_ASSERT_EQ(test, 0,
-			xe_ggtt_init_kunit(ggtt, DUT_GGTT_START,
-					   DUT_GGTT_SIZE));
+	KUNIT_ASSERT_NOT_ERR_OR_NULL(test, guc);
 
 	kunit_activate_static_stub(test, xe_managed_bo_create_pin_map,
 				   replacement_xe_managed_bo_create_pin_map);
diff --git a/drivers/gpu/drm/xe/tests/xe_kunit_helpers.c b/drivers/gpu/drm/xe/tests/xe_kunit_helpers.c
index bc5156966ce9..e4495a453f80 100644
--- a/drivers/gpu/drm/xe/tests/xe_kunit_helpers.c
+++ b/drivers/gpu/drm/xe/tests/xe_kunit_helpers.c
@@ -14,6 +14,7 @@
 #include "tests/xe_pci_test.h"
 #include "xe_device.h"
 #include "xe_device_types.h"
+#include "xe_ggtt.h"
 #include "xe_pm.h"
 
 /**
@@ -50,6 +51,18 @@ static void kunit_action_restore_priv(void *priv)
 	test->priv = priv;
 }
 
+static void fake_device_init_ggtt(struct xe_device *xe, u64 start, u64 size)
+{
+	struct kunit *test = kunit_get_current_test();
+	struct xe_tile *tile;
+	unsigned int id;
+
+	for_each_tile(tile, xe, id) {
+		KUNIT_ASSERT_NOT_ERR_OR_NULL(test, tile->mem.ggtt);
+		KUNIT_EXPECT_EQ(test, xe_ggtt_init_kunit(tile->mem.ggtt, start, size), 0);
+	}
+}
+
 /**
  * xe_kunit_helper_xe_device_test_init - Prepare a &xe_device for a KUnit test.
  * @test: the &kunit where this fake &xe_device will be used
@@ -64,12 +77,16 @@ static void kunit_action_restore_priv(void *priv)
  * in &kunit.priv pointer to the struct xe_pci_fake_data supplemented with
  * desired parameters prior to calling this function.
  *
+ * If xe_pci_fake_data->ggtt_size is set then this function will also do
+ * a minimal GGTT initialization.
+ *
  * This function uses KUNIT_ASSERT to detect any failures.
  *
  * Return: Always 0.
  */
 int xe_kunit_helper_xe_device_test_init(struct kunit *test)
 {
+	struct xe_pci_fake_data *data = test->priv;
 	struct xe_device *xe;
 	struct device *dev;
 	int err;
@@ -86,6 +103,9 @@ int xe_kunit_helper_xe_device_test_init(struct kunit *test)
 	err = kunit_add_action_or_reset(test, kunit_action_restore_priv, test->priv);
 	KUNIT_ASSERT_EQ(test, err, 0);
 
+	if (data && data->ggtt_size)
+		fake_device_init_ggtt(xe, data->ggtt_start, data->ggtt_size);
+
 	test->priv = xe;
 	return 0;
 }
diff --git a/drivers/gpu/drm/xe/tests/xe_pci_test.h b/drivers/gpu/drm/xe/tests/xe_pci_test.h
index 30505d1cbefc..e807585b88c2 100644
--- a/drivers/gpu/drm/xe/tests/xe_pci_test.h
+++ b/drivers/gpu/drm/xe/tests/xe_pci_test.h
@@ -22,6 +22,8 @@ struct xe_pci_fake_data {
 	struct xe_step_info step;
 	u32 graphics_verx100;
 	u32 media_verx100;
+	u64 ggtt_start;
+	u64 ggtt_size;
 };
 
 int xe_pci_fake_device_init(struct xe_device *xe);
-- 
2.47.1


  parent reply	other threads:[~2026-04-28 14:28 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-28 14:27 [PATCH 00/13] drm/xe/tests: Add kunit tests for memory based interrupts Michal Wajdeczko
2026-04-28 14:27 ` [PATCH 01/13] drm/xe/ggtt: Rename parameter name in xe_ggtt_init_kunit() Michal Wajdeczko
2026-04-29 20:29   ` Summers, Stuart
2026-04-30  8:32     ` Jani Nikula
2026-04-30 21:50       ` Summers, Stuart
2026-04-28 14:27 ` [PATCH 02/13] drm/xe/guc: Allow to replace xe_guc_irq_handler() with stub Michal Wajdeczko
2026-04-30  5:44   ` K V P, Satyanarayana
2026-04-28 14:27 ` [PATCH 03/13] drm/xe/hwe: Allow to replace xe_hw_engine_handle_irq() " Michal Wajdeczko
2026-04-30  5:47   ` K V P, Satyanarayana
2026-04-28 14:27 ` [PATCH 04/13] drm/xe/mmio: Allow to replace xe_mmio_read32|write32() " Michal Wajdeczko
2026-04-30  5:48   ` K V P, Satyanarayana
2026-04-28 14:27 ` Michal Wajdeczko [this message]
2026-04-28 14:27 ` [PATCH 06/13] drm/xe/kunit: Promote fake BO activation to test_init() helper Michal Wajdeczko
2026-04-28 14:27 ` [PATCH 07/13] drm/xe/kunit: Activate empty MMIO stubs in test_init() Michal Wajdeczko
2026-04-28 14:27 ` [PATCH 08/13] drm/xe/memirq: Make page layout macros private Michal Wajdeczko
2026-05-05  7:54   ` Levi, Ilia
2026-04-28 14:27 ` [PATCH 09/13] drm/xe/memirq: Introduce helper to calculate source page offset Michal Wajdeczko
2026-05-05  8:27   ` Levi, Ilia
2026-04-28 14:27 ` [PATCH 10/13] drm/xe/memirq: Introduce helper to calculate status vector offset Michal Wajdeczko
2026-05-05 12:40   ` Levi, Ilia
2026-04-28 14:27 ` [PATCH 11/13] drm/xe/memirq: Refactor xe_memirq_hwe_handler Michal Wajdeczko
2026-05-05 12:46   ` Levi, Ilia
2026-04-28 14:27 ` [PATCH 12/13] drm/xe/memirq: Dump additional source pages if MSI-X Michal Wajdeczko
2026-05-05 13:12   ` Levi, Ilia
2026-04-28 14:27 ` [PATCH 13/13] drm/xe/tests: Add kunit tests for memory based interrupts Michal Wajdeczko
2026-04-28 16:33 ` ✗ CI.checkpatch: warning for " Patchwork
2026-04-28 16:35 ` ✓ CI.KUnit: success " Patchwork
2026-04-28 17:43 ` ✓ Xe.CI.BAT: " Patchwork
2026-04-29  5:04 ` ✗ Xe.CI.FULL: failure " 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=20260428142722.582-6-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