Intel-XE Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm/xe: Add helper to detect real vs kunit xe_device
@ 2026-05-12 19:45 Michal Wajdeczko
  2026-05-13  6:29 ` ✓ CI.KUnit: success for " Patchwork
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Michal Wajdeczko @ 2026-05-12 19:45 UTC (permalink / raw)
  To: intel-xe; +Cc: Michal Wajdeczko, Gustavo Sousa

In some cases we might want to know if we are running our test
code on real vs kunit xe device; also use of static kunit stub
might be not possible as test code might be use other threads.

As only real xe_device instances will be on the true PCI bus,
and all kunit fake devices are attached to the kunit_bus_type,
add helper that checks underlying bus to determine xe status.

Signed-off-by: Michal Wajdeczko <michal.wajdeczko@intel.com>
Cc: Gustavo Sousa <gustavo.sousa@intel.com>
---
 drivers/gpu/drm/xe/tests/xe_kunit_helpers.c | 2 ++
 drivers/gpu/drm/xe/xe_device.h              | 5 +++++
 2 files changed, 7 insertions(+)

diff --git a/drivers/gpu/drm/xe/tests/xe_kunit_helpers.c b/drivers/gpu/drm/xe/tests/xe_kunit_helpers.c
index bc5156966ce9..28d7d1618638 100644
--- a/drivers/gpu/drm/xe/tests/xe_kunit_helpers.c
+++ b/drivers/gpu/drm/xe/tests/xe_kunit_helpers.c
@@ -39,6 +39,7 @@ struct xe_device *xe_kunit_helper_alloc_xe_device(struct kunit *test,
 					       struct xe_device,
 					       drm, DRIVER_GEM);
 	KUNIT_ASSERT_NOT_ERR_OR_NULL(test, xe);
+	KUNIT_ASSERT_FALSE(test, xe_device_is_real(xe));
 	return xe;
 }
 EXPORT_SYMBOL_IF_KUNIT(xe_kunit_helper_alloc_xe_device);
@@ -118,6 +119,7 @@ int xe_kunit_helper_xe_device_live_test_init(struct kunit *test)
 
 	KUNIT_ASSERT_NOT_ERR_OR_NULL(test, xe);
 	kunit_info(test, "running on %s device\n", xe->info.platform_name);
+	KUNIT_ASSERT_TRUE(test, xe_device_is_real(xe));
 
 	KUNIT_ASSERT_FALSE(test, xe_device_wedged(xe));
 	xe_pm_runtime_get(xe);
diff --git a/drivers/gpu/drm/xe/xe_device.h b/drivers/gpu/drm/xe/xe_device.h
index 355d69dc8f54..c14624a19808 100644
--- a/drivers/gpu/drm/xe/xe_device.h
+++ b/drivers/gpu/drm/xe/xe_device.h
@@ -220,6 +220,11 @@ static inline bool xe_device_is_admin_only(const struct xe_device *xe)
 }
 #endif
 
+static inline bool xe_device_is_real(const struct xe_device *xe)
+{
+	return xe->drm.dev->bus == &pci_bus_type;
+}
+
 /*
  * Occasionally it is seen that the G2H worker starts running after a delay of more than
  * a second even after being queued and activated by the Linux workqueue subsystem. This
-- 
2.47.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-05-14  5:27 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-12 19:45 [PATCH] drm/xe: Add helper to detect real vs kunit xe_device Michal Wajdeczko
2026-05-13  6:29 ` ✓ CI.KUnit: success for " Patchwork
2026-05-13  8:14 ` ✓ Xe.CI.BAT: " Patchwork
2026-05-13 12:49 ` [PATCH] " Gustavo Sousa
2026-05-14  5:27 ` ✗ Xe.CI.FULL: failure for " Patchwork

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox