From: "Michał Winiarski" <michal.winiarski@intel.com>
To: Michal Wajdeczko <michal.wajdeczko@intel.com>
Cc: <intel-xe@lists.freedesktop.org>
Subject: Re: [PATCH 12/13] drm/xe/tests: Add migration packet test
Date: Fri, 3 Jul 2026 15:44:08 +0200 [thread overview]
Message-ID: <ake6DS7ZfTjXUwox@nostramo> (raw)
In-Reply-To: <20260630132633.32804-13-michal.wajdeczko@intel.com>
On Tue, Jun 30, 2026 at 03:26:31PM +0200, Michal Wajdeczko wrote:
> One of our migration data packet (descriptor) is based on the KLV
> encoding. Add a simple descriptor initialization test, as we plan
> to use new KLV helper functions there.
>
> Signed-off-by: Michal Wajdeczko <michal.wajdeczko@intel.com>
> ---
> .../gpu/drm/xe/tests/xe_sriov_packet_kunit.c | 83 +++++++++++++++++++
> drivers/gpu/drm/xe/xe_sriov_packet.c | 4 +
> 2 files changed, 87 insertions(+)
> create mode 100644 drivers/gpu/drm/xe/tests/xe_sriov_packet_kunit.c
>
> diff --git a/drivers/gpu/drm/xe/tests/xe_sriov_packet_kunit.c b/drivers/gpu/drm/xe/tests/xe_sriov_packet_kunit.c
> new file mode 100644
> index 000000000000..9af066875671
> --- /dev/null
> +++ b/drivers/gpu/drm/xe/tests/xe_sriov_packet_kunit.c
> @@ -0,0 +1,83 @@
> +// SPDX-License-Identifier: GPL-2.0 AND MIT
> +/*
> + * Copyright © 2026 Intel Corporation
> + */
> +
> +#include <kunit/test.h>
> +#include <kunit/test-bug.h>
> +
> +#include "xe_device.h"
> +#include "xe_guc_klv_helpers.h"
> +#include "xe_kunit_helpers.h"
> +#include "xe_pci_test.h"
> +
> +#define TEST_VF VFID(1)
> +
> +static int sriov_packet_test_init(struct kunit *test)
> +{
> + struct xe_pci_fake_data fake = {
> + .sriov_mode = XE_SRIOV_MODE_PF,
> + .platform = XE_PANTHERLAKE, /* we need MEMIRQ */
> + .subplatform = XE_SUBPLATFORM_NONE,
> + .graphics_verx100 = 3000,
> + .media_verx100 = 3000,
> + };
> + struct xe_device *xe;
> +
> + test->priv = &fake;
> + xe_kunit_helper_xe_device_test_init(test);
> + xe = test->priv;
> +
> + /* pretend we can support at least VF1 */
> + xe->sriov.pf.device_total_vfs = 1;
> + xe->sriov.pf.driver_max_vfs = 1;
> +
> + KUNIT_ASSERT_EQ(test, 0, xe_sriov_init(xe));
> + KUNIT_ASSERT_TRUE(test, xe_sriov_pf_migration_supported(xe));
> +
> + return 0;
> +}
> +
> +static void test_descriptor_init(struct kunit *test)
> +{
> + struct xe_device *xe = test->priv;
> + struct xe_sriov_packet **desc;
> +
> + guard(mutex)(pf_migration_mutex(xe, TEST_VF));
Sashiko complains that we'll never release the lock if we're mixing
scope-managed locks with KUNIT_ASSERT.
We might want to convert this to test-managed resource.
LGTM otherwise:
Reviewed-by: Michał Winiarski <michal.winiarski@intel.com>
Thanks,
-Michał
> +
> + KUNIT_ASSERT_EQ(test, 0, pf_descriptor_init(xe, TEST_VF));
> + desc = pf_pick_descriptor(xe, TEST_VF);
> + KUNIT_ASSERT_NOT_ERR_OR_NULL(test, *desc);
> + KUNIT_EXPECT_NE(test, (*desc)->hdr.version, 0);
> + KUNIT_EXPECT_EQ(test, (*desc)->hdr.version, XE_SRIOV_PACKET_SUPPORTED_VERSION);
> + KUNIT_EXPECT_EQ(test, (*desc)->hdr.type, XE_SRIOV_PACKET_TYPE_DESCRIPTOR);
> + KUNIT_EXPECT_NE(test, (*desc)->hdr.size, 0);
> + KUNIT_ASSERT_NOT_ERR_OR_NULL(test, (*desc)->vaddr);
> + KUNIT_EXPECT_EQ(test, 0, xe_sriov_packet_process_descriptor(xe, TEST_VF, *desc));
> +
> + switch ((*desc)->hdr.version) {
> + case 1:
> + /* v1 is KLV based */
> + KUNIT_EXPECT_TRUE(test, IS_ALIGNED((*desc)->hdr.size, sizeof(u32)));
> + /* v1 has at least DEVID and REVID KLVs */
> + KUNIT_EXPECT_LE(test, 2,
> + xe_guc_klv_count((*desc)->vaddr,
> + (*desc)->hdr.size / sizeof(u32)));
> + break;
> + default:
> + kunit_skip(test, "missing test code for version %u\n", (*desc)->hdr.version);
> + }
> +}
> +
> +static struct kunit_case sriov_packet_test_cases[] = {
> + KUNIT_CASE(test_descriptor_init),
> + {}
> +};
> +
> +static struct kunit_suite sriov_packet_suite = {
> + .name = "sriov_packet",
> + .test_cases = sriov_packet_test_cases,
> + .init = sriov_packet_test_init,
> +};
> +
> +kunit_test_suite(sriov_packet_suite);
> diff --git a/drivers/gpu/drm/xe/xe_sriov_packet.c b/drivers/gpu/drm/xe/xe_sriov_packet.c
> index e581e8e6c1d1..558a3697d639 100644
> --- a/drivers/gpu/drm/xe/xe_sriov_packet.c
> +++ b/drivers/gpu/drm/xe/xe_sriov_packet.c
> @@ -516,3 +516,7 @@ int xe_sriov_packet_save_init(struct xe_device *xe, unsigned int vfid)
>
> return 0;
> }
> +
> +#if IS_BUILTIN(CONFIG_DRM_XE_KUNIT_TEST)
> +#include "tests/xe_sriov_packet_kunit.c"
> +#endif
> --
> 2.47.1
>
next prev parent reply other threads:[~2026-07-03 13:44 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-30 13:26 [PATCH 00/13] drm/xe: Add and use more KLV helpers Michal Wajdeczko
2026-06-30 13:26 ` [PATCH 01/13] drm/xe/guc: Allow to print single KLV Michal Wajdeczko
2026-07-03 11:10 ` Michał Winiarski
2026-06-30 13:26 ` [PATCH 02/13] drm/xe/guc: Prepare to print group KLVs Michal Wajdeczko
2026-07-03 11:11 ` Michał Winiarski
2026-06-30 13:26 ` [PATCH 03/13] drm/xe/guc: Add basic KLV encoding helpers Michal Wajdeczko
2026-07-03 12:58 ` Michał Winiarski
2026-06-30 13:26 ` [PATCH 04/13] drm/xe/guc: Add string KLV encoding helper Michal Wajdeczko
2026-07-03 13:29 ` Michał Winiarski
2026-07-06 16:04 ` Michal Wajdeczko
2026-06-30 13:26 ` [PATCH 05/13] drm/xe/guc: Add object " Michal Wajdeczko
2026-07-03 14:33 ` Michał Winiarski
2026-06-30 13:26 ` [PATCH 06/13] drm/xe/guc: Add KLV parsing helper Michal Wajdeczko
2026-07-03 14:40 ` Michał Winiarski
2026-06-30 13:26 ` [PATCH 07/13] drm/xe/guc: Formalize Reserved KLVs Michal Wajdeczko
2026-07-03 13:31 ` Michał Winiarski
2026-06-30 13:26 ` [PATCH 08/13] drm/xe/tests: Add GuC KLV helpers basic tests Michal Wajdeczko
2026-07-03 14:17 ` Michał Winiarski
2026-06-30 13:26 ` [PATCH 09/13] drm/xe/tests: Add string encoding helper test Michal Wajdeczko
2026-07-03 20:40 ` Michał Winiarski
2026-06-30 13:26 ` [PATCH 10/13] drm/xe/tests: Add object " Michal Wajdeczko
2026-07-03 20:47 ` Michał Winiarski
2026-07-06 16:34 ` Michal Wajdeczko
2026-06-30 13:26 ` [PATCH 11/13] drm/xe/tests: Add GuC KLV printer test Michal Wajdeczko
2026-07-03 20:49 ` Michał Winiarski
2026-06-30 13:26 ` [PATCH 12/13] drm/xe/tests: Add migration packet test Michal Wajdeczko
2026-07-03 13:44 ` Michał Winiarski [this message]
2026-07-06 16:42 ` Michal Wajdeczko
2026-06-30 13:26 ` [PATCH 13/13] drm/xe/pf: Handle migration descriptor using KLV helpers Michal Wajdeczko
2026-07-03 20:50 ` Michał Winiarski
2026-06-30 13:47 ` ✗ CI.checkpatch: warning for drm/xe: Add and use more " Patchwork
2026-06-30 13:49 ` ✓ CI.KUnit: success " Patchwork
2026-06-30 14:42 ` ✓ Xe.CI.BAT: " Patchwork
2026-07-01 5:22 ` ✓ Xe.CI.FULL: " 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=ake6DS7ZfTjXUwox@nostramo \
--to=michal.winiarski@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