From: Michal Wajdeczko <michal.wajdeczko@intel.com>
To: Lucas De Marchi <lucas.demarchi@intel.com>
Cc: intel-xe@lists.freedesktop.org
Subject: Re: [PATCH v2 2/7] drm/xe/tests: Add helpers for use in live tests
Date: Fri, 19 Jul 2024 19:20:37 +0200 [thread overview]
Message-ID: <653951c8-e922-448d-928f-d2213e9a5045@intel.com> (raw)
In-Reply-To: <oobqld5nhkmzotfrmcr6o55vpto2jagrybddrurojsfvrfrd2h@m5vcqrlxkdts>
On 19.07.2024 18:37, Lucas De Marchi wrote:
> On Wed, Jul 17, 2024 at 09:51:50PM GMT, Michal Wajdeczko wrote:
>> Instead of iterating over available Xe devices within a testcase,
>> without being able to distinguish potential failures from different
>> devices on system with many Xe devices, introduce helpers that will
>> allow to treat each Xe device as a parameter for the testcase like:
>>
>> static void bar(struct kunit *test)
>> {
>> struct xe_device *xe = test->priv;
>> ...
>> }
>>
>> struct kunit_case foo_live_tests[] = {
>> KUNIT_CASE_PARAM(bar, xe_pci_live_device_gen_param),
>> {}
>> };
>>
>> struct kunit_suite foo_suite = {
>> .name = "foo_live",
>> .test_cases = foo_live_tests,
>> .init = xe_kunit_helper_xe_device_live_test_init,
>> };
>>
>> Signed-off-by: Michal Wajdeczko <michal.wajdeczko@intel.com>
>> ---
>> v2: can't rely on test->priv in .exit helper (CI)
>> for cleanup use kunit_add_action_or_reset() instead
>> ---
>> drivers/gpu/drm/xe/tests/xe_kunit_helpers.c | 39 +++++++++++++++++++++
>> drivers/gpu/drm/xe/tests/xe_kunit_helpers.h | 2 ++
>> drivers/gpu/drm/xe/tests/xe_pci.c | 30 ++++++++++++++++
>> drivers/gpu/drm/xe/tests/xe_pci_test.h | 2 ++
>> 4 files changed, 73 insertions(+)
>>
>> diff --git a/drivers/gpu/drm/xe/tests/xe_kunit_helpers.c
>> b/drivers/gpu/drm/xe/tests/xe_kunit_helpers.c
>> index fefe79b3b75a..bc5156966ce9 100644
>> --- a/drivers/gpu/drm/xe/tests/xe_kunit_helpers.c
>> +++ b/drivers/gpu/drm/xe/tests/xe_kunit_helpers.c
>> @@ -12,7 +12,9 @@
>>
>> #include "tests/xe_kunit_helpers.h"
>> #include "tests/xe_pci_test.h"
>> +#include "xe_device.h"
>> #include "xe_device_types.h"
>> +#include "xe_pm.h"
>>
>> /**
>> * xe_kunit_helper_alloc_xe_device - Allocate a &xe_device for a KUnit
>> test.
>> @@ -88,3 +90,40 @@ int xe_kunit_helper_xe_device_test_init(struct
>> kunit *test)
>> return 0;
>> }
>> 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 *);
>> +
>> +/**
>> + * xe_kunit_helper_xe_device_live_test_init - Prepare a &xe_device for
>> + * use in a live KUnit test.
>> + * @test: the &kunit where live &xe_device will be used
>> + *
>> + * This function expects pointer to the &xe_device in the
>> &test.param_value,
>> + * like it is prepared by the &xe_pci_live_device_gen_param and
>> stores that
>> + * pointer as &kunit.priv to allow the test code to access it.
>> + *
>> + * This function makes sure that device is not wedged and then
>> resumes it
>> + * to avoid waking up the device inside the test. It uses deferred
>> cleanup
>> + * action to release a runtime_pm reference.
>> + *
>> + * This function can be used as custom implementation of
>> &kunit_suite.init.
>> + *
>> + * This function uses KUNIT_ASSERT to detect any failures.
>> + *
>> + * Return: Always 0.
>> + */
>> +int xe_kunit_helper_xe_device_live_test_init(struct kunit *test)
>> +{
>> + struct xe_device *xe = xe_device_const_cast(test->param_value);
>> +
>> + KUNIT_ASSERT_NOT_ERR_OR_NULL(test, xe);
>> + kunit_info(test, "running on %s device\n", xe->info.platform_name);
>> +
>> + KUNIT_ASSERT_FALSE(test, xe_device_wedged(xe));
>> + xe_pm_runtime_get(xe);
>> + KUNIT_ASSERT_EQ(test, 0, kunit_add_action_or_reset(test,
>> put_xe_pm_runtime, xe));
>> +
>> + test->priv = xe;
>> + return 0;
>> +}
>> +EXPORT_SYMBOL_IF_KUNIT(xe_kunit_helper_xe_device_live_test_init);
>> diff --git a/drivers/gpu/drm/xe/tests/xe_kunit_helpers.h
>> b/drivers/gpu/drm/xe/tests/xe_kunit_helpers.h
>> index 067a1babf049..83665f7b1254 100644
>> --- a/drivers/gpu/drm/xe/tests/xe_kunit_helpers.h
>> +++ b/drivers/gpu/drm/xe/tests/xe_kunit_helpers.h
>> @@ -14,4 +14,6 @@ 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);
>>
>> +int xe_kunit_helper_xe_device_live_test_init(struct kunit *test);
>> +
>> #endif
>> diff --git a/drivers/gpu/drm/xe/tests/xe_pci.c
>> b/drivers/gpu/drm/xe/tests/xe_pci.c
>> index f62809ca8b51..ab570dbb71ac 100644
>> --- a/drivers/gpu/drm/xe/tests/xe_pci.c
>> +++ b/drivers/gpu/drm/xe/tests/xe_pci.c
>> @@ -167,3 +167,33 @@ int xe_pci_fake_device_init(struct xe_device *xe)
>> return 0;
>> }
>> EXPORT_SYMBOL_IF_KUNIT(xe_pci_fake_device_init);
>> +
>> +/**
>> + * xe_pci_live_device_gen_param - Helper to iterate Xe devices as a
>> KUnit parameters
>
> s/a KUnit parameters/KUnit parameters/ , or remove plural.
>
> Can we filter by device or is this something coming in future?
not now, but it's the same gap as today, where we do live testing of all
found xe devices, without any way to apply any filter
last year I was looking how to add support at kunit level to filter
tests by parameter names, but didn't finish that nor post anything -
will try again if time permits
alternatively we can quickly add something specific to
xe_pci_live_device_gen_param(), like custom xe.modparam, to allow
filtering devices that will be generated as params
>
> Reviewed-by: Lucas De Marchi <lucas.demarchi@intel.com>
>
> Lucas De Marchi
next prev parent reply other threads:[~2024-07-19 17:20 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-17 19:51 [PATCH v2 0/7] Convert live tests to parameterized style Michal Wajdeczko
2024-07-17 19:51 ` [PATCH v2 1/7] drm/xe: Introduce const cast helper Michal Wajdeczko
2024-07-17 20:07 ` Cavitt, Jonathan
2024-07-17 21:38 ` Michal Wajdeczko
2024-07-19 16:32 ` Lucas De Marchi
2024-07-19 16:55 ` Michal Wajdeczko
2024-07-19 17:06 ` Lucas De Marchi
2024-07-17 19:51 ` [PATCH v2 2/7] drm/xe/tests: Add helpers for use in live tests Michal Wajdeczko
2024-07-17 20:14 ` Cavitt, Jonathan
2024-07-19 16:37 ` Lucas De Marchi
2024-07-19 17:20 ` Michal Wajdeczko [this message]
2024-07-17 19:51 ` [PATCH v2 3/7] drm/xe/tests: Convert xe_bo " Michal Wajdeczko
2024-07-17 20:15 ` Cavitt, Jonathan
2024-07-17 19:51 ` [PATCH v2 4/7] drm/xe/tests: Convert xe_dma_buf " Michal Wajdeczko
2024-07-17 20:17 ` Cavitt, Jonathan
2024-07-17 21:54 ` Michal Wajdeczko
2024-07-17 19:51 ` [PATCH v2 5/7] drm/xe/tests: Convert xe_migrate " Michal Wajdeczko
2024-07-17 20:17 ` Cavitt, Jonathan
2024-07-17 19:51 ` [PATCH v2 6/7] drm/xe/tests: Convert xe_mocs " Michal Wajdeczko
2024-07-17 20:18 ` Cavitt, Jonathan
2024-07-19 16:40 ` Lucas De Marchi
2024-07-17 19:51 ` [PATCH v2 7/7] drm/xe/tests: Skip xe_mocs live tests on VF device Michal Wajdeczko
2024-07-17 20:19 ` Cavitt, Jonathan
2024-07-19 16:41 ` Lucas De Marchi
2024-07-17 19:58 ` ✓ CI.Patch_applied: success for Convert live tests to parameterized style (rev2) Patchwork
2024-07-17 19:59 ` ✓ CI.checkpatch: " Patchwork
2024-07-17 20:00 ` ✓ CI.KUnit: " Patchwork
2024-07-17 20:12 ` ✓ CI.Build: " Patchwork
2024-07-17 20:14 ` ✓ CI.Hooks: " Patchwork
2024-07-17 20:16 ` ✓ CI.checksparse: " Patchwork
2024-07-17 20:40 ` ✗ CI.BAT: failure " Patchwork
2024-07-17 21:34 ` Michal Wajdeczko
2024-07-18 1:53 ` ✗ CI.FULL: " Patchwork
2024-07-18 7:11 ` Michal Wajdeczko
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=653951c8-e922-448d-928f-d2213e9a5045@intel.com \
--to=michal.wajdeczko@intel.com \
--cc=intel-xe@lists.freedesktop.org \
--cc=lucas.demarchi@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