Intel-XE Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Michal Wajdeczko <michal.wajdeczko@intel.com>
To: Lucas De Marchi <lucas.demarchi@intel.com>
Cc: intel-xe@lists.freedesktop.org
Subject: Re: [PATCH v4 06/10] drm/xe/kunit: Restore test->priv when done with fake xe device
Date: Sat, 16 Dec 2023 13:11:00 +0100	[thread overview]
Message-ID: <d1356030-2ee4-49a7-9886-77b689666b91@intel.com> (raw)
In-Reply-To: <3sc7ulh6z3t555u33wwxj77gwbmh4jvs3qwo3cn7dbs4vann4i@mjxlz45midfu>



On 15.12.2023 23:11, Lucas De Marchi wrote:
> On Fri, Dec 15, 2023 at 05:24:58PM +0100, Michal Wajdeczko wrote:
>> Current KUnit implementation does not reset test->priv in case of
>> parametrized tests and that may lead to wrongly treat our output
>> pointer to fake xe_device from first call as input pointer with
>> xe_pci_fake_data on subsequent calls.  Restore test->priv to
>> original value to avoid invalid access.
> 
> but wouldn't each parameterized test pass a different a data?

test->priv prepared by suit.init() should be the same
only test->param_value will change on each param iteration

> 
> not sure I'm following why this is a xe issue. Are you fixing it in xe
> while should be fixed in kunit?

who said I'm not fixing that in kunit ;)

[1]
https://lore.kernel.org/linux-kselftest/20231215151327.1835-1-michal.wajdeczko@intel.com/

Michal

> 
> Lucas De Marchi
> 
>>
>> Signed-off-by: Michal Wajdeczko <michal.wajdeczko@intel.com>
>> ---
>> drivers/gpu/drm/xe/tests/xe_kunit_helpers.c | 10 ++++++++++
>> 1 file changed, 10 insertions(+)
>>
>> diff --git a/drivers/gpu/drm/xe/tests/xe_kunit_helpers.c
>> b/drivers/gpu/drm/xe/tests/xe_kunit_helpers.c
>> index 6d72dbf06139..fefe79b3b75a 100644
>> --- a/drivers/gpu/drm/xe/tests/xe_kunit_helpers.c
>> +++ b/drivers/gpu/drm/xe/tests/xe_kunit_helpers.c
>> @@ -41,6 +41,13 @@ struct xe_device
>> *xe_kunit_helper_alloc_xe_device(struct kunit *test,
>> }
>> EXPORT_SYMBOL_IF_KUNIT(xe_kunit_helper_alloc_xe_device);
>>
>> +static void kunit_action_restore_priv(void *priv)
>> +{
>> +    struct kunit *test = kunit_get_current_test();
>> +
>> +    test->priv = priv;
>> +}
>> +
>> /**
>>  * 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
>> @@ -74,6 +81,9 @@ int xe_kunit_helper_xe_device_test_init(struct kunit
>> *test)
>>     err = xe_pci_fake_device_init(xe);
>>     KUNIT_ASSERT_EQ(test, err, 0);
>>
>> +    err = kunit_add_action_or_reset(test, kunit_action_restore_priv,
>> test->priv);
>> +    KUNIT_ASSERT_EQ(test, err, 0);
>> +
>>     test->priv = xe;
>>     return 0;
>> }
>> -- 
>> 2.25.1
>>

  reply	other threads:[~2023-12-16 12:11 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-15 16:24 [PATCH v4 00/10] Introduce GuC Doorbells Manager Michal Wajdeczko
2023-12-15 16:24 ` [PATCH v4 01/10] drm/xe: Add GT oriented drm_printers Michal Wajdeczko
2023-12-15 21:48   ` Lucas De Marchi
2023-12-15 16:24 ` [PATCH v4 02/10] drm/xe: Report TLB timeout using GT oriented functions Michal Wajdeczko
2023-12-15 21:50   ` Lucas De Marchi
2023-12-15 16:24 ` [PATCH v4 03/10] drm/xe: Introduce GuC Doorbells Manager Michal Wajdeczko
2023-12-15 16:24 ` [PATCH v4 04/10] drm/xe/kunit: Set SR-IOV mode of the fake device Michal Wajdeczko
2023-12-15 16:24 ` [PATCH v4 05/10] drm/xe/kunit: Define helper functions to allocate fake xe device Michal Wajdeczko
2023-12-15 22:01   ` Lucas De Marchi
2023-12-15 16:24 ` [PATCH v4 06/10] drm/xe/kunit: Restore test->priv when done with " Michal Wajdeczko
2023-12-15 22:11   ` Lucas De Marchi
2023-12-16 12:11     ` Michal Wajdeczko [this message]
2023-12-15 16:24 ` [PATCH v4 07/10] drm/xe/kunit: Use xe kunit helper in RTP test Michal Wajdeczko
2023-12-15 22:05   ` Lucas De Marchi
2023-12-15 16:25 ` [PATCH v4 08/10] drm/xe/kunit: Use xe kunit helper in WA test Michal Wajdeczko
2023-12-15 22:06   ` Lucas De Marchi
2023-12-15 16:25 ` [PATCH v4 09/10] drm/xe/kunit: Enable CONFIG_LOCKDEP in tests Michal Wajdeczko
2023-12-15 22:06   ` Lucas De Marchi
2023-12-15 16:25 ` [PATCH v4 10/10] drm/xe/kunit: Add GuC Doorbells Manager tests Michal Wajdeczko
2023-12-15 17:53 ` ✓ CI.Patch_applied: success for Introduce GuC Doorbells Manager (rev4) Patchwork
2023-12-15 17:53 ` ✗ CI.checkpatch: warning " Patchwork
2023-12-15 17:55 ` ✓ CI.KUnit: success " Patchwork
2023-12-15 18:02 ` ✓ CI.Build: " Patchwork
2023-12-15 18:02 ` ✓ CI.Hooks: " Patchwork
2023-12-15 18:04 ` ✓ CI.checksparse: " Patchwork
2023-12-15 18:36 ` ✓ CI.BAT: " 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=d1356030-2ee4-49a7-9886-77b689666b91@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