From: Michal Wajdeczko <michal.wajdeczko@intel.com>
To: intel-xe@lists.freedesktop.org
Cc: Michal Wajdeczko <michal.wajdeczko@intel.com>,
Gustavo Sousa <gustavo.sousa@intel.com>
Subject: [PATCH] drm/xe: Add helper to detect real vs kunit xe_device
Date: Tue, 12 May 2026 21:45:14 +0200 [thread overview]
Message-ID: <20260512194514.3414-1-michal.wajdeczko@intel.com> (raw)
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
next reply other threads:[~2026-05-12 19:45 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-12 19:45 Michal Wajdeczko [this message]
2026-05-13 6:29 ` ✓ CI.KUnit: success for drm/xe: Add helper to detect real vs kunit xe_device 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
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=20260512194514.3414-1-michal.wajdeczko@intel.com \
--to=michal.wajdeczko@intel.com \
--cc=gustavo.sousa@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