From: "Mallesh, Koujalagi" <mallesh.koujalagi@intel.com>
To: Michal Wajdeczko <michal.wajdeczko@intel.com>,
<intel-xe@lists.freedesktop.org>
Subject: Re: [PATCH v3 15/23] drm/xe/tests: Add kunit tests for xe_any
Date: Wed, 12 Aug 2026 17:03:35 +0530 [thread overview]
Message-ID: <7f4f5cef-ae7d-4224-b008-331f10f21cb6@intel.com> (raw)
In-Reply-To: <20260730152121.576-16-michal.wajdeczko@intel.com>
[-- Attachment #1: Type: text/plain, Size: 7988 bytes --]
On 30-07-2026 08:51 pm, Michal Wajdeczko wrote:
> Add simple sanity tests for all xe_any macros to make sure they
> are working as expected.
>
> Signed-off-by: Michal Wajdeczko<michal.wajdeczko@intel.com>
> ---
> drivers/gpu/drm/xe/tests/Makefile | 1 +
> drivers/gpu/drm/xe/tests/xe_any_kunit.c | 188 ++++++++++++++++++++++++
> 2 files changed, 189 insertions(+)
> create mode 100644 drivers/gpu/drm/xe/tests/xe_any_kunit.c
>
> diff --git a/drivers/gpu/drm/xe/tests/Makefile b/drivers/gpu/drm/xe/tests/Makefile
> index f7aa47f11a36..0b809a252cfa 100644
> --- a/drivers/gpu/drm/xe/tests/Makefile
> +++ b/drivers/gpu/drm/xe/tests/Makefile
> @@ -7,6 +7,7 @@ xe_live_test-y = xe_live_test_mod.o
> # Normal kunit tests
> obj-$(CONFIG_DRM_XE_KUNIT_TEST) += xe_test.o
> xe_test-y = xe_test_mod.o \
> + xe_any_kunit.o \
> xe_args_test.o \
> xe_pci_test.o \
> xe_rtp_tables_test.o \
> diff --git a/drivers/gpu/drm/xe/tests/xe_any_kunit.c b/drivers/gpu/drm/xe/tests/xe_any_kunit.c
> new file mode 100644
> index 000000000000..02540d3b5357
> --- /dev/null
> +++ b/drivers/gpu/drm/xe/tests/xe_any_kunit.c
> @@ -0,0 +1,188 @@
> +// SPDX-License-Identifier: GPL-2.0
> +/*
> + * Copyright © 2026 Intel Corporation
> + */
> +
> +#include <kunit/test.h>
> +
> +#include "tests/xe_kunit_helpers.h"
> +#include "tests/xe_pci_test.h"
> +#include "xe_any.h"
> +#include "xe_device.h"
> +
> +static void test_to_xe(struct kunit *test)
> +{
> + struct xe_device *xe = test->priv;
> + struct xe_tile *tile = xe_device_get_root_tile(xe);
> + struct xe_gt *gt = tile->primary_gt;
> + struct device *dev = xe->drm.dev;
> + struct pci_dev *pdev = to_pci_dev(dev);
> + const struct xe_device *cxe = xe;
> + const struct xe_tile *ctile = tile;
> + const struct xe_gt *cgt = gt;
> +
> + KUNIT_EXPECT_PTR_EQ(test, xe, xe_any_to_xe(xe));
> + KUNIT_EXPECT_PTR_EQ(test, xe, xe_any_to_xe(tile));
> + KUNIT_EXPECT_PTR_EQ(test, xe, xe_any_to_xe(gt));
> + KUNIT_EXPECT_PTR_EQ(test, xe, xe_any_to_xe(dev));
> + KUNIT_EXPECT_PTR_EQ(test, xe, xe_any_to_xe(pdev));
Please add struct drm_device *drm = &xe->drm; as well
> +
> + KUNIT_EXPECT_PTR_EQ(test, cxe, xe_any_to_xe(cxe));
> + KUNIT_EXPECT_PTR_EQ(test, cxe, xe_any_to_xe(ctile));
> + KUNIT_EXPECT_PTR_EQ(test, cxe, xe_any_to_xe(cgt));
> +}
> +
> +static void test_to_pdev(struct kunit *test)
> +{
> + struct xe_device *xe = test->priv;
> + struct xe_tile *tile = xe_device_get_root_tile(xe);
> + struct xe_gt *gt = tile->primary_gt;
> + struct device *dev = xe->drm.dev;
> + struct pci_dev *pdev = to_pci_dev(dev);
> +
> + KUNIT_EXPECT_PTR_EQ(test, pdev, xe_any_to_pdev(xe));
> + KUNIT_EXPECT_PTR_EQ(test, pdev, xe_any_to_pdev(tile));
> + KUNIT_EXPECT_PTR_EQ(test, pdev, xe_any_to_pdev(gt));
> + KUNIT_EXPECT_PTR_EQ(test, pdev, xe_any_to_pdev(dev));
> + KUNIT_EXPECT_PTR_EQ(test, pdev, xe_any_to_pdev(pdev));
> +
> + /* mimic early probe stage */
> + dev_set_drvdata(xe->drm.dev, NULL);
> + KUNIT_EXPECT_PTR_EQ(test, pdev, xe_any_to_pdev(dev));
> + KUNIT_EXPECT_PTR_EQ(test, pdev, xe_any_to_pdev(pdev));
> +}
> +
> +static void test_to_dev(struct kunit *test)
> +{
> + struct xe_device *xe = test->priv;
> + struct xe_tile *tile = xe_device_get_root_tile(xe);
> + struct xe_gt *gt = tile->primary_gt;
> + struct device *dev = xe->drm.dev;
> + struct pci_dev *pdev = to_pci_dev(dev);
> +
> + KUNIT_EXPECT_PTR_EQ(test, dev, xe_any_to_dev(xe));
> + KUNIT_EXPECT_PTR_EQ(test, dev, xe_any_to_dev(tile));
> + KUNIT_EXPECT_PTR_EQ(test, dev, xe_any_to_dev(gt));
> + KUNIT_EXPECT_PTR_EQ(test, dev, xe_any_to_dev(dev));
> + KUNIT_EXPECT_PTR_EQ(test, dev, xe_any_to_dev(pdev));
> +
> + /* mimic early probe stage */
> + dev_set_drvdata(xe->drm.dev, NULL);
> + KUNIT_EXPECT_PTR_EQ(test, dev, xe_any_to_dev(dev));
> + KUNIT_EXPECT_PTR_EQ(test, dev, xe_any_to_dev(pdev));
> +}
> +
> +static void test_to_drm(struct kunit *test)
> +{
> + struct xe_device *xe = test->priv;
> + struct drm_device *drm = &xe->drm;
> + struct xe_tile *tile = xe_device_get_root_tile(xe);
> + struct xe_gt *gt = tile->primary_gt;
> + struct device *dev = xe->drm.dev;
> + struct pci_dev *pdev = to_pci_dev(dev);
> +
> + KUNIT_EXPECT_PTR_EQ(test, drm, xe_any_to_drm(xe));
> + KUNIT_EXPECT_PTR_EQ(test, drm, xe_any_to_drm(drm));
> + KUNIT_EXPECT_PTR_EQ(test, drm, xe_any_to_drm(tile));
> + KUNIT_EXPECT_PTR_EQ(test, drm, xe_any_to_drm(gt));
> + KUNIT_EXPECT_PTR_EQ(test, drm, xe_any_to_drm(dev));
> + KUNIT_EXPECT_PTR_EQ(test, drm, xe_any_to_drm(pdev));
> +}
> +
Add test_if_pdev as well to check xe_any_if_pdev.
After updating those changes
Reviewed-by: Mallesh Koujalagi <mallesh.koujalagi@intel.com>
> +static void test_if_xe(struct kunit *test)
> +{
> + struct xe_device *xe = test->priv;
> + struct drm_device *drm = &xe->drm;
> + struct xe_tile *tile = xe_device_get_root_tile(xe);
> + struct xe_gt *gt = tile->primary_gt;
> + struct device *dev = xe->drm.dev;
> + struct pci_dev *pdev = to_pci_dev(dev);
> +
> + KUNIT_EXPECT_TRUE(test, xe && drm && tile && gt && dev && pdev);
> + KUNIT_EXPECT_PTR_EQ(test, xe, xe_any_if_xe(xe));
> + KUNIT_EXPECT_NULL(test, xe_any_if_xe(drm));
> + KUNIT_EXPECT_NULL(test, xe_any_if_xe(tile));
> + KUNIT_EXPECT_NULL(test, xe_any_if_xe(gt));
> + KUNIT_EXPECT_NULL(test, xe_any_if_xe(dev));
> + KUNIT_EXPECT_NULL(test, xe_any_if_xe(pdev));
> +}
> +
> +static void test_if_tile(struct kunit *test)
> +{
> + struct xe_device *xe = test->priv;
> + struct drm_device *drm = &xe->drm;
> + struct xe_tile *tile = xe_device_get_root_tile(xe);
> + struct xe_gt *gt = tile->primary_gt;
> + struct device *dev = xe->drm.dev;
> + struct pci_dev *pdev = to_pci_dev(dev);
> +
> + KUNIT_EXPECT_TRUE(test, xe && drm && tile && gt && dev && pdev);
> + KUNIT_EXPECT_NULL(test, xe_any_if_tile(xe));
> + KUNIT_EXPECT_NULL(test, xe_any_if_tile(drm));
> + KUNIT_EXPECT_PTR_EQ(test, tile, xe_any_if_tile(tile));
> + KUNIT_EXPECT_NULL(test, xe_any_if_tile(gt));
> + KUNIT_EXPECT_NULL(test, xe_any_if_tile(dev));
> + KUNIT_EXPECT_NULL(test, xe_any_if_tile(pdev));
> +}
> +
> +static void test_if_gt(struct kunit *test)
> +{
> + struct xe_device *xe = test->priv;
> + struct drm_device *drm = &xe->drm;
> + struct xe_tile *tile = xe_device_get_root_tile(xe);
> + struct xe_gt *gt = tile->primary_gt;
> + struct device *dev = xe->drm.dev;
> + struct pci_dev *pdev = to_pci_dev(dev);
> +
> + KUNIT_EXPECT_TRUE(test, xe && drm && tile && gt && dev && pdev);
> + KUNIT_EXPECT_NULL(test, xe_any_if_gt(xe));
> + KUNIT_EXPECT_NULL(test, xe_any_if_gt(drm));
> + KUNIT_EXPECT_NULL(test, xe_any_if_gt(tile));
> + KUNIT_EXPECT_PTR_EQ(test, gt, xe_any_if_gt(gt));
> + KUNIT_EXPECT_NULL(test, xe_any_if_gt(dev));
> + KUNIT_EXPECT_NULL(test, xe_any_if_gt(pdev));
> +}
> +
> +static void test_to_id(struct kunit *test)
> +{
> + struct xe_device *xe = test->priv;
> + struct xe_tile *tile = xe_device_get_root_tile(xe);
> + struct xe_gt *gt = tile->primary_gt;
> + struct device *dev = xe->drm.dev;
> + struct pci_dev *pdev = to_pci_dev(dev);
> + const struct xe_device *cxe = xe;
> + const struct xe_tile *ctile = tile;
> + const struct xe_gt *cgt = gt;
> +
> + tile->id = 1;
> + gt->info.id = 2;
> +
> + KUNIT_EXPECT_EQ(test, 0, xe_any_id(xe));
> + KUNIT_EXPECT_EQ(test, 1, xe_any_id(tile));
> + KUNIT_EXPECT_EQ(test, 2, xe_any_id(gt));
> + KUNIT_EXPECT_EQ(test, 0, xe_any_id(dev));
> + KUNIT_EXPECT_EQ(test, 0, xe_any_id(pdev));
> + KUNIT_EXPECT_EQ(test, 0, xe_any_id(cxe));
> + KUNIT_EXPECT_EQ(test, 1, xe_any_id(ctile));
> + KUNIT_EXPECT_EQ(test, 2, xe_any_id(cgt));
> +}
> +
> +static struct kunit_case xe_any_tests[] = {
> + KUNIT_CASE(test_to_xe),
> + KUNIT_CASE(test_to_dev),
> + KUNIT_CASE(test_to_pdev),
> + KUNIT_CASE(test_to_drm),
> + KUNIT_CASE(test_if_xe),
> + KUNIT_CASE(test_if_tile),
> + KUNIT_CASE(test_if_gt),
> + KUNIT_CASE(test_to_id),
> + {}
> +};
> +
> +static struct kunit_suite xe_any_test_suite = {
> + .name = "xe_any",
> + .test_cases = xe_any_tests,
> + .init = xe_kunit_helper_xe_device_test_init,
> +};
> +
> +kunit_test_suite(xe_any_test_suite);
[-- Attachment #2: Type: text/html, Size: 8790 bytes --]
prev parent reply other threads:[~2026-08-12 11:34 UTC|newest]
Thread overview: 73+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-30 15:20 [PATCH v3 00/23] drm/xe: Add structured SIGID error logging infrastructure Michal Wajdeczko
2026-07-30 15:20 ` [PATCH v3 02/23] drm/xe/log: " Michal Wajdeczko
2026-08-04 15:00 ` Tauro, Riana
2026-08-04 18:52 ` Rodrigo Vivi
2026-08-05 17:23 ` Michal Wajdeczko
2026-08-05 18:58 ` Rodrigo Vivi
2026-08-04 21:21 ` Summers, Stuart
2026-08-04 21:22 ` Summers, Stuart
2026-08-05 1:39 ` Rodrigo Vivi
2026-08-05 1:36 ` Rodrigo Vivi
2026-08-05 22:24 ` Summers, Stuart
2026-08-06 11:31 ` Michal Wajdeczko
2026-08-06 19:10 ` Summers, Stuart
2026-08-06 19:46 ` Rodrigo Vivi
2026-08-07 12:31 ` Mallesh, Koujalagi
2026-08-12 11:43 ` Nilawar, Badal
2026-07-30 15:21 ` [PATCH v3 05/23] drm/xe/log: Add SIGID log helpers for severity Michal Wajdeczko
2026-08-03 8:23 ` Mallesh, Koujalagi
2026-07-30 15:21 ` [PATCH v3 06/23] drm/xe/log: Add SIGID log helpers for location Michal Wajdeczko
2026-08-03 8:50 ` Mallesh, Koujalagi
2026-07-30 15:21 ` [PATCH v3 07/23] drm/xe/log: Add SIGID log helpers for location & severity Michal Wajdeczko
2026-08-03 8:58 ` Mallesh, Koujalagi
2026-07-30 15:21 ` [PATCH v3 08/23] drm/xe/log: Add SIGID log helpers for components Michal Wajdeczko
2026-08-03 12:42 ` Mallesh, Koujalagi
2026-07-30 15:21 ` [PATCH v3 09/23] drm/xe/log: Add SIGID log helpers for errno-only Michal Wajdeczko
2026-08-04 4:56 ` Mallesh, Koujalagi
2026-07-30 15:21 ` [PATCH v3 10/23] drm/xe/log: Add hardware error signatures Michal Wajdeczko
2026-07-31 11:41 ` Mallesh, Koujalagi
2026-08-04 15:56 ` Michal Wajdeczko
2026-08-12 7:00 ` Tauro, Riana
2026-08-12 8:24 ` Michal Wajdeczko
2026-08-12 9:29 ` Tauro, Riana
2026-08-12 10:19 ` Michal Wajdeczko
2026-07-30 15:21 ` [PATCH v3 12/23] drm/xe/ras: Check RAS and LOG component definitions Michal Wajdeczko
2026-08-10 11:31 ` Mallesh, Koujalagi
2026-07-30 15:21 ` [PATCH v3 13/23] drm/xe/kunit: Setup driver data in the test device Michal Wajdeczko
2026-08-11 14:25 ` Mallesh, Koujalagi
2026-07-30 15:21 ` [PATCH v3 14/23] drm/xe/tests: Add Kunit tests for xe_log Michal Wajdeczko
2026-08-12 11:15 ` Mallesh, Koujalagi
2026-07-30 15:21 ` [PATCH v3 16/23] drm/xe: Report 'probe blocked' error using SIGID Michal Wajdeczko
2026-08-11 9:11 ` Mallesh, Koujalagi
2026-07-30 15:21 ` [PATCH v3 17/23] drm/xe: Report 'device wedged' errors " Michal Wajdeczko
2026-08-07 9:56 ` Mallesh, Koujalagi
2026-08-07 10:24 ` Michal Wajdeczko
2026-08-12 0:32 ` Mallesh, Koujalagi
2026-07-30 15:21 ` [PATCH v3 18/23] drm/xe: Report 'Survivability Mode' " Michal Wajdeczko
2026-08-07 11:18 ` Mallesh, Koujalagi
2026-08-07 12:14 ` Michal Wajdeczko
2026-08-12 4:47 ` Mallesh, Koujalagi
2026-07-30 15:21 ` [PATCH v3 20/23] drm/xe/pcode: Report 'Mailbox failed' error " Michal Wajdeczko
2026-08-11 9:54 ` Mallesh, Koujalagi
2026-07-30 15:21 ` [PATCH v3 22/23] drm/xe/gt: Report 'pagefault' errors " Michal Wajdeczko
2026-08-12 6:40 ` Mallesh, Koujalagi
2026-07-30 15:21 ` [PATCH v3 23/23] drm/xe/pci: Report 'cannot re-enable' error " Michal Wajdeczko
2026-08-12 6:58 ` Mallesh, Koujalagi
2026-08-12 9:23 ` Michal Wajdeczko
2026-08-12 10:35 ` Mallesh, Koujalagi
2026-07-30 15:40 ` ✗ CI.checkpatch: warning for drm/xe: Add structured SIGID error logging infrastructure (rev3) Patchwork
2026-07-30 15:41 ` ✓ CI.KUnit: success " Patchwork
2026-07-30 16:17 ` ✗ Xe.CI.BAT: failure " Patchwork
2026-08-04 16:00 ` Michal Wajdeczko
2026-07-30 18:31 ` ✗ Xe.CI.FULL: " Patchwork
2026-08-04 16:05 ` Michal Wajdeczko
[not found] ` <20260730152121.576-4-michal.wajdeczko@intel.com>
2026-08-03 8:00 ` [PATCH v3 03/23] drm/xe/log: Introduce structured component/location identifiers Mallesh, Koujalagi
2026-08-04 15:19 ` Michal Wajdeczko
2026-08-12 0:09 ` Mallesh, Koujalagi
[not found] ` <20260730152121.576-12-michal.wajdeczko@intel.com>
2026-08-04 6:05 ` [PATCH v3 11/23] drm/xe/log: Extend components list with hardware items Mallesh, Koujalagi
2026-08-12 6:55 ` Tauro, Riana
2026-08-12 8:55 ` Michal Wajdeczko
2026-08-12 9:26 ` Tauro, Riana
[not found] ` <20260730152121.576-22-michal.wajdeczko@intel.com>
2026-08-12 6:31 ` [PATCH v3 21/23] drm/xe/gt: Report 'reset failed' errors using SIGID Mallesh, Koujalagi
[not found] ` <20260730152121.576-20-michal.wajdeczko@intel.com>
2026-08-12 10:52 ` [PATCH v3 19/23] drm/xe/guc: Report 'GuC mmio' " Mallesh, Koujalagi
[not found] ` <20260730152121.576-16-michal.wajdeczko@intel.com>
2026-08-12 11:33 ` Mallesh, Koujalagi [this message]
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=7f4f5cef-ae7d-4224-b008-331f10f21cb6@intel.com \
--to=mallesh.koujalagi@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.