From: Gustavo Sousa <gustavo.sousa@intel.com>
To: Michal Wajdeczko <michal.wajdeczko@intel.com>,
<intel-xe@lists.freedesktop.org>
Subject: Re: [PATCH 04/12] drm/xe/kunit: Add xe_kunit_is_live_test()
Date: Tue, 5 May 2026 15:32:03 -0300 [thread overview]
Message-ID: <87o6ityafw.fsf@intel.com> (raw)
In-Reply-To: <2f919dd4-e219-4230-a734-d67a280eec13@intel.com>
Michal Wajdeczko <michal.wajdeczko@intel.com> writes:
> On 1/16/2026 11:12 PM, Gustavo Sousa wrote:
>> In upcoming changes we will need to differentiate between regular and
>> live KUnit tests. Add the function xe_kunit_is_live_test() for that
>> purpose.
>
> since you are adding this function to xe_kunit_helper.h maybe it should be named as
>
> xe_kunit_helper_is_live_test(test)
>
> to follow other function names in this file?
Yep, makes sense. Let's do that.
I think in the future we could just rename the files to xe_kunit.[ch].
>
>>
>> Note that this is implemented in a rather hackish way, by leveraging
>> KUnit's static stubbing functionality. A better approach would be to
>> store a boolean somewhere in test->priv that would tell if a test is a
>> live one, however that's not quite feasible today given the inconsistent
>> usage of test->priv (there is not a single uniform type of data assigned
>> to it across existing test).
>
> all live tests code should finally have access to the xe_device so alternate option would be to add some flag(s) there
>
> struct xe_device {
> ...
> #if IS_ENABLED(CONFIG_DRM_XE_KUNIT_TEST)
> struct {
> bool live_testing_in_progress;
> } kunit;
> #endif
I think I would prefer that we would have a common struct that is
attached to test->priv.
>
> but IMO solution with static stub is fine
>
>>
>> Signed-off-by: Gustavo Sousa <gustavo.sousa@intel.com>
>> ---
>> drivers/gpu/drm/xe/tests/xe_kunit_helpers.c | 25 +++++++++++++++++++++++++
>> drivers/gpu/drm/xe/tests/xe_kunit_helpers.h | 4 ++++
>> 2 files changed, 29 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..369b26b3a32c 100644
>> --- a/drivers/gpu/drm/xe/tests/xe_kunit_helpers.c
>> +++ b/drivers/gpu/drm/xe/tests/xe_kunit_helpers.c
>> @@ -16,6 +16,18 @@
>> #include "xe_device_types.h"
>> #include "xe_pm.h"
>>
>> +/**
>> + * xe_kunit_is_live_test - Return true if @test is a live test.
>> + * @test: the &kunit test
>> + *
>> + * Return: True for a live test and false otherwise.
>> + */
>> +bool xe_kunit_is_live_test(struct kunit *test)
>> +{
>> + KUNIT_STATIC_STUB_REDIRECT(xe_kunit_is_live_test, test);
>> + return false;
>> +}
>> +
>> /**
>> * xe_kunit_helper_alloc_xe_device - Allocate a &xe_device for a KUnit test.
>> * @test: the &kunit where this &xe_device will be used
>> @@ -93,6 +105,11 @@ EXPORT_SYMBOL_IF_KUNIT(xe_kunit_helper_xe_device_test_init);
>>
>> KUNIT_DEFINE_ACTION_WRAPPER(put_xe_pm_runtime, xe_pm_runtime_put, struct xe_device *);
>>
>> +static bool xe_kunit_is_live_test_indeed(struct kunit *test)
>> +{
>> + return true;
>> +}
>> +
>> /**
>> * xe_kunit_helper_xe_device_live_test_init - Prepare a &xe_device for
>> * use in a live KUnit test.
>> @@ -116,6 +133,14 @@ int xe_kunit_helper_xe_device_live_test_init(struct kunit *test)
>> {
>> struct xe_device *xe = xe_device_const_cast(test->param_value);
>>
>> + /*
>> + * FIXME: This is a hack and a better solution is to have the "priv"
>> + * member of tests have a boolean to tell if a test is a live one.
>> + * Unfortunately that can't be done today because "priv" does not point
>> + * to a single unified type across existing tests.
>
> note that we use priv to pass xe, and likely if any other live init hook will replace it,
> priv will still point to either tile or gt or similar object, from which we should be able to reach xe again
>
Yep, but I would much rather have a common struct to contain common test
information and then a "data" member to point to test-specific data.
Today there is no easy way to predict what test->priv will contain and
it makes it harder to add common helpers (like the one I'm adding here)
that would work across different tests.
--
Gustavo Sousa
>> + */
>> + kunit_activate_static_stub(test, xe_kunit_is_live_test, xe_kunit_is_live_test_indeed);
>> +
>> KUNIT_ASSERT_NOT_ERR_OR_NULL(test, xe);
>> kunit_info(test, "running on %s device\n", xe->info.platform_name);
>>
>> diff --git a/drivers/gpu/drm/xe/tests/xe_kunit_helpers.h b/drivers/gpu/drm/xe/tests/xe_kunit_helpers.h
>> index 83665f7b1254..4b846cfb1f40 100644
>> --- a/drivers/gpu/drm/xe/tests/xe_kunit_helpers.h
>> +++ b/drivers/gpu/drm/xe/tests/xe_kunit_helpers.h
>> @@ -6,10 +6,14 @@
>> #ifndef _XE_KUNIT_HELPERS_H_
>> #define _XE_KUNIT_HELPERS_H_
>>
>> +#include <linux/types.h>
>> +
>> struct device;
>> struct kunit;
>> struct xe_device;
>>
>> +bool xe_kunit_is_live_test(struct kunit *test);
>> +
>> struct xe_device *xe_kunit_helper_alloc_xe_device(struct kunit *test,
>> struct device *dev);
>> int xe_kunit_helper_xe_device_test_init(struct kunit *test);
>>
next prev parent reply other threads:[~2026-05-05 18:32 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-16 22:12 [PATCH 00/12] Fix MCR inconsistencies in RTP tables Gustavo Sousa
2026-01-16 22:12 ` [PATCH 01/12] drm/xe: Define CACHE_MODE_1 as MCR register Gustavo Sousa
2026-01-21 0:04 ` Matt Roper
2026-01-16 22:12 ` [PATCH 02/12] drm/xe: Define and use MCR version of COMMON_SLICE_CHICKEN1 Gustavo Sousa
2026-01-21 0:06 ` Matt Roper
2026-01-16 22:12 ` [PATCH 03/12] drm/xe: Define and use MCR version of COMMON_SLICE_CHICKEN4 Gustavo Sousa
2026-01-21 0:08 ` Matt Roper
2026-01-16 22:12 ` [PATCH 04/12] drm/xe/kunit: Add xe_kunit_is_live_test() Gustavo Sousa
2026-01-16 22:59 ` Michal Wajdeczko
2026-05-05 18:32 ` Gustavo Sousa [this message]
2026-01-16 22:12 ` [PATCH 05/12] drm/xe/kunit: Abort test if MMIO operation is attempted Gustavo Sousa
2026-01-16 23:15 ` Michal Wajdeczko
2026-05-05 19:11 ` Gustavo Sousa
2026-01-16 22:12 ` [PATCH 06/12] drm/xe/kunit: Allow intercepting MMIO operations Gustavo Sousa
2026-01-16 22:12 ` [PATCH 07/12] drm/xe: Extract xe_hw_engine_setup_reg_lrc() Gustavo Sousa
2026-01-21 0:12 ` Matt Roper
2026-01-16 22:12 ` [PATCH 08/12] drm/xe: Extract xe_hw_engines_setup_runtime_mask() Gustavo Sousa
2026-01-28 18:07 ` Matt Roper
2026-01-16 22:12 ` [PATCH 09/12] drm/xe/kunit: Use KUNIT_EXPECT_EQ() in xe_wa_gt() Gustavo Sousa
2026-01-16 23:29 ` Michal Wajdeczko
2026-01-28 18:09 ` Matt Roper
2026-01-16 22:12 ` [PATCH 10/12] drm/xe/kunit: Include hw_engines in xe_wa test Gustavo Sousa
2026-01-28 21:08 ` Matt Roper
2026-01-16 22:12 ` [PATCH 11/12] drm/xe/mcr: Extract reg_in_steering_type_ranges() Gustavo Sousa
2026-01-28 21:11 ` Matt Roper
2026-01-16 22:12 ` [PATCH 12/12] drm/xe/reg_sr: Do sanity check for MCR vs non-MCR Gustavo Sousa
2026-01-28 23:59 ` Matt Roper
2026-05-05 19:39 ` Gustavo Sousa
2026-01-16 23:15 ` ✗ CI.checkpatch: warning for Fix MCR inconsistencies in RTP tables Patchwork
2026-01-16 23:16 ` ✓ CI.KUnit: success " 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=87o6ityafw.fsf@intel.com \
--to=gustavo.sousa@intel.com \
--cc=intel-xe@lists.freedesktop.org \
--cc=michal.wajdeczko@intel.com \
/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