Intel-XE Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: "Mallesh, Koujalagi" <mallesh.koujalagi@intel.com>
To: Michal Wajdeczko <michal.wajdeczko@intel.com>,
	<intel-xe@lists.freedesktop.org>
Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>,
	Aravind Iddamsetty <aravind.iddamsetty@intel.com>,
	Yoni Levitt <yoni.levitt@intel.com>
Subject: Re: [PATCH v3 14/23] drm/xe/tests: Add Kunit tests for xe_log
Date: Wed, 12 Aug 2026 16:45:06 +0530	[thread overview]
Message-ID: <a7830adb-e8b6-4c42-97f0-a848adcdc0f2@intel.com> (raw)
In-Reply-To: <20260730152121.576-15-michal.wajdeczko@intel.com>


On 30-07-2026 08:51 pm, Michal Wajdeczko wrote:
> All dmesg log lines generated by the xe_log() functions or helper
> macros are expected to have a stable format. Add tests to verify
> that generated output is not accidentally changed. Add demo pseudo
> tests to show how to use all variants of the xe_log() helpers.
>
> Signed-off-by: Michal Wajdeczko <michal.wajdeczko@intel.com>
> Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
> ---
> Cc: Aravind Iddamsetty <aravind.iddamsetty@intel.com>
> Cc: Yoni Levitt <yoni.levitt@intel.com>
> Cc: Mallesh Koujalagi <mallesh.koujalagi@intel.com>
> ---
> v2: less demos/more tests (Michal)
> v3: expect tile.id is already set (Michal)
>      add invalid params test (Michal)
> ---
>   drivers/gpu/drm/xe/tests/xe_log_kunit.c | 545 ++++++++++++++++++++++++
>   drivers/gpu/drm/xe/xe_log.c             |  11 +
>   2 files changed, 556 insertions(+)
>   create mode 100644 drivers/gpu/drm/xe/tests/xe_log_kunit.c
>
> diff --git a/drivers/gpu/drm/xe/tests/xe_log_kunit.c b/drivers/gpu/drm/xe/tests/xe_log_kunit.c
> new file mode 100644
> index 000000000000..27f3c322cc26
> --- /dev/null
> +++ b/drivers/gpu/drm/xe/tests/xe_log_kunit.c
> @@ -0,0 +1,545 @@
> +// SPDX-License-Identifier: GPL-2.0 AND MIT
> +/*
> + * Copyright © 2026 Intel Corporation
> + */
> +
> +#include <kunit/static_stub.h>
> +#include <kunit/test.h>
> +#include <kunit/test-bug.h>
> +
> +#include "tests/xe_kunit_helpers.h"
> +#include "tests/xe_pci_test.h"
> +#include "xe_device.h"
> +#include "xe_log.h"
> +
> +static void nop_dmesg_vprintk(struct pci_dev *pdev, int cper_sev, struct va_format *vaf)
> +{
> +}
> +
> +static void nop_emit_cper(struct pci_dev *pdev, int cper_sev,
> +			  enum xe_sigid sigid, u32 component, u32 location,
> +			  const void *data, size_t len, struct va_format *vaf)
> +{
> +}
> +
> +static const char *component_name(u32 component)
> +{
> +	switch (component) {
> +#define make_component_tag_case(_CLASS, _ID, _TAG, _SIG, _NAME) \
> +	case XE_LOG_COMPONENT_##_TAG: return _NAME;
> +	DEFINE_XE_LOG_COMPONENTS(make_component_tag_case)
> +#undef make_component_tag_case
> +	}
> +	return component ? "???" : "";
> +}
> +
> +static const char *location_type(u32 location)
> +{
> +	u32 type = FIELD_GET(XE_LOG_LOCATION_TYPE_MASK, location);
> +
> +	return type == XE_LOG_LOCATION_TYPE_DEVICE ? "DEVICE" :
> +	       type == XE_LOG_LOCATION_TYPE_TILE ? "TILE" :
> +	       type == XE_LOG_LOCATION_TYPE_GT ? "GT" :
> +	       location ? "?" : "";
> +}
> +
> +static void fake_emit_cper(struct pci_dev *pdev, int cper_sev,
> +			   enum xe_sigid sigid, u32 component, u32 location,
> +			   const void *data, size_t len, struct va_format *vaf)
> +{
> +	char msg[64];
> +	int n, err;
> +
> +	pr_info("\n");
> +	pr_info("CPER SEV=%u SIGID=%u\n", cper_sev, sigid);
> +	pr_info("CPER DEVICE=%s\n", dev_name(&pdev->dev));
> +	if (location)
> +		pr_info("CPER LOCATION=%#x \t# %s.%u\n",
> +			location, location_type(location),
> +			FIELD_GET(XE_LOG_LOCATION_ID_MASK, location));
> +	if (component)
> +		pr_info("CPER COMPONENT=%#x \t# %s\n",
> +			component, component_name(component));
> +	if (IS_ERR(data)) {

Please move 'err' variable within the block.

after changing that

LGTM,

Reviewed-by: Mallesh Koujalagi <mallesh.koujalagi@intel.com>

> +		err = PTR_ERR(data);
> +		pr_info("CPER ERR=%d \t\t# %pe\n", err, data);
> +	} else if (len) {
> +		print_hex_dump(KERN_INFO, "CPER BIN=", DUMP_PREFIX_OFFSET,
> +			       16, 1, data, len, false);
> +	}
> +
> +	n = vscnprintf(msg, sizeof(msg), vaf->fmt, *vaf->va);
> +	print_hex_dump(KERN_INFO, "CPER MSG=", DUMP_PREFIX_OFFSET, 16, 1, msg, n, true);
> +	pr_info("CPER END\n");
> +}
> +
> +static const u8 blob[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 };
> +static const u8 dead[] = { 0xde, 0xad, 0xbe, 0xef };
> +
> +static struct xe_tile *to_tile_safe(struct xe_device *xe)
> +{
> +	return xe ? &xe->tiles[1] : NULL;
> +}
> +
> +static struct xe_gt *to_gt_safe(struct xe_device *xe)
> +{
> +	return xe ? to_tile_safe(xe)->primary_gt : NULL;
> +}
> +
> +static struct pci_dev *to_pdev_safe(struct xe_device *xe)
> +{
> +	return xe ? xe_any_to_pdev(xe) : NULL;
> +}
> +
> +static void demo(struct xe_device *xe)
> +{
> +	struct pci_dev *pdev = xe_any_to_pdev(xe);
> +	struct xe_tile *tile = to_tile_safe(xe);
> +	struct xe_gt *gt = to_gt_safe(xe);
> +
> +	/* SW errno */
> +	xe_log_emit(pdev, CPER_SEV_FATAL, XE_SIGID_PROBE,
> +		    XE_LOG_COMPONENT_NONE, XE_LOG_LOCATION_NONE,
> +		    ERR_PTR(-ENODEV), 0, "testing %s signature\n", "software");
> +
> +	xe_log_err(tile, PROBE, -ENODEV, "testing %s signature\n", "software");
> +	xe_log_err_corrected(gt, PROBE, -ENODEV, "testing %s signature\n", "software");
> +	xe_log_info(gt, PROBE, "testing %s signature\n", "software");
> +
> +	/* HW data */
> +	xe_log_emit(pdev, CPER_SEV_FATAL, XE_SIGID_PCIE,
> +		    XE_LOG_COMPONENT_NONE, XE_LOG_LOCATION_NONE,
> +		    blob, sizeof(blob), "testing %s signature\n", "HARDWARE");
> +	xe_log_emit_recoverable(pdev, XE_SIGID_FABRIC,
> +				XE_LOG_COMPONENT_NONE, XE_LOG_LOCATION_NONE,
> +				blob, sizeof(blob), "testing %s signature\n", "HARDWARE");
> +	xe_log_from_corrected(tile, XE_SIGID_DEVICE_MEMORY, XE_LOG_COMPONENT_NONE,
> +			      blob, sizeof(blob), "testing %s signature\n", "HARDWARE");
> +	xe_log_from_info(gt, XE_SIGID_CORE_COMPUTE, XE_LOG_COMPONENT_NONE,
> +			 blob, sizeof(blob), "testing %s signature\n", "HARDWARE");
> +}
> +
> +static void demo_dmesg(struct kunit *test)
> +{
> +	kunit_activate_static_stub(test, log_emit_cper, nop_emit_cper);
> +	demo(test->priv);
> +}
> +
> +static void demo_cper(struct kunit *test)
> +{
> +	kunit_activate_static_stub(test, log_emit_cper, fake_emit_cper);
> +	kunit_activate_static_stub(test, log_dmesg_vprintk, nop_dmesg_vprintk);
> +	demo(test->priv);
> +}
> +
> +static const char *test_fatal(struct xe_device *xe)
> +{
> +	struct pci_dev *pdev = to_pdev_safe(xe);
> +
> +	if (pdev)
> +		xe_log_emit_fatal(pdev, XE_SIGID_PROBE,
> +				  XE_LOG_COMPONENT_NONE, XE_LOG_LOCATION_NONE,
> +				  NULL, 0, "testing %d\n", 123);
> +	return "SIGID=101 FATAL testing 123\n";
> +}
> +
> +static const char *test_fatal_tile(struct xe_device *xe)
> +{
> +	struct xe_tile *tile = to_tile_safe(xe);
> +
> +	if (tile)
> +		xe_log_from_fatal(tile, XE_SIGID_PROBE, XE_LOG_COMPONENT_NONE,
> +				  ERR_PTR(-ENODEV), 0, "testing %d\n", 123);
> +	return "SIGID=101 FATAL (-ENODEV) Tile1: testing 123\n";
> +}
> +
> +static const char *test_fatal_gt(struct xe_device *xe)
> +{
> +	struct xe_gt *gt = to_gt_safe(xe);
> +
> +	if (gt)
> +		xe_log_from_fatal(gt, XE_SIGID_PROBE, XE_LOG_COMPONENT_NONE,
> +				  ERR_PTR(-ENODEV), 0, "testing %d\n", 123);
> +	return "SIGID=101 FATAL (-ENODEV) Tile1: GT1: testing 123\n";
> +}
> +
> +static const char *test_fatal_comp(struct xe_device *xe)
> +{
> +	struct pci_dev *pdev = to_pdev_safe(xe);
> +
> +	if (pdev)
> +		xe_log_err_fatal(pdev, PROBE, -ENODEV, "testing %d\n", 123);
> +	return "SIGID=101 FATAL (-ENODEV) PROBE: testing 123\n";
> +}
> +
> +static const char *test_fatal_comp_tile(struct xe_device *xe)
> +{
> +	struct xe_tile *tile = to_tile_safe(xe);
> +
> +	if (tile)
> +		xe_log_err_fatal(tile, PROBE, -ENODEV, "testing %d\n", 123);
> +	return "SIGID=101 FATAL (-ENODEV) Tile1: PROBE: testing 123\n";
> +}
> +
> +static const char *test_fatal_comp_gt(struct xe_device *xe)
> +{
> +	struct xe_gt *gt = to_gt_safe(xe);
> +
> +	if (gt)
> +		xe_log_err_fatal(gt, PROBE, -ENODEV, "testing %d\n", 123);
> +	return "SIGID=101 FATAL (-ENODEV) Tile1: GT1: PROBE: testing 123\n";
> +}
> +
> +static const char *test_fatal_all(struct xe_device *xe)
> +{
> +	struct pci_dev *pdev = to_pdev_safe(xe);
> +	struct xe_gt *gt = to_gt_safe(xe);
> +
> +	if (pdev)
> +		xe_log_emit(pdev, CPER_SEV_FATAL, XE_SIGID_PROBE,
> +			    XE_LOG_COMPONENT_PROBE, MAKE_XE_LOG_LOCATION(GT, gt->info.id),
> +			    ERR_PTR(-ENODEV), 0, "testing %d\n", 123);
> +	return "SIGID=101 FATAL (-ENODEV) Tile1: GT1: PROBE: testing 123\n";
> +}
> +
> +static const char *test_recoverable(struct xe_device *xe)
> +{
> +	struct pci_dev *pdev = to_pdev_safe(xe);
> +
> +	if (pdev)
> +		xe_log_emit_recoverable(pdev, XE_SIGID_RUNTIME_FW,
> +					XE_LOG_COMPONENT_NONE, XE_LOG_LOCATION_NONE,
> +					ERR_PTR(-EIO), 0, "testing %d\n", 123);
> +	return "SIGID=104 (-EIO) testing 123\n";
> +}
> +
> +static const char *test_recoverable_tile(struct xe_device *xe)
> +{
> +	struct xe_tile *tile = to_tile_safe(xe);
> +
> +	if (tile)
> +		xe_log_from_recoverable(tile, XE_SIGID_RUNTIME_FW, XE_LOG_COMPONENT_NONE,
> +					ERR_PTR(-EIO), 0, "testing %d\n", 123);
> +	return "SIGID=104 (-EIO) Tile1: testing 123\n";
> +}
> +
> +static const char *test_recoverable_gt(struct xe_device *xe)
> +{
> +	struct xe_gt *gt = to_gt_safe(xe);
> +
> +	if (gt)
> +		xe_log_from_recoverable(gt, XE_SIGID_RUNTIME_FW, XE_LOG_COMPONENT_NONE,
> +					ERR_PTR(-EIO), 0, "testing %d\n", 123);
> +	return "SIGID=104 (-EIO) Tile1: GT1: testing 123\n";
> +}
> +
> +static const char *test_recoverable_comp(struct xe_device *xe)
> +{
> +	struct pci_dev *pdev = to_pdev_safe(xe);
> +
> +	if (pdev)
> +		xe_log_err(pdev, GUC, -EIO, "testing %d\n", 123);
> +	return "SIGID=104 (-EIO) GUC: testing 123\n";
> +}
> +
> +static const char *test_recoverable_comp_tile(struct xe_device *xe)
> +{
> +	struct xe_tile *tile = to_tile_safe(xe);
> +
> +	if (tile)
> +		xe_log_err(tile, GUC, -EIO, "testing %d\n", 123);
> +	return "SIGID=104 (-EIO) Tile1: GUC: testing 123\n";
> +}
> +
> +static const char *test_recoverable_comp_gt(struct xe_device *xe)
> +{
> +	struct xe_gt *gt = to_gt_safe(xe);
> +
> +	if (gt)
> +		xe_log_err(gt, GUC, -EIO, "testing %d\n", 123);
> +	return "SIGID=104 (-EIO) Tile1: GT1: GUC: testing 123\n";
> +}
> +
> +static const char *test_recoverable_all(struct xe_device *xe)
> +{
> +	struct pci_dev *pdev = to_pdev_safe(xe);
> +	struct xe_gt *gt = to_gt_safe(xe);
> +
> +	if (pdev)
> +		xe_log_emit(pdev, CPER_SEV_RECOVERABLE, XE_SIGID_RUNTIME_FW,
> +			    XE_LOG_COMPONENT_GUC, MAKE_XE_LOG_LOCATION(GT, gt->info.id),
> +			    ERR_PTR(-EIO), 0, "testing %d\n", 123);
> +	return "SIGID=104 (-EIO) Tile1: GT1: GUC: testing 123\n";
> +}
> +
> +static const char *test_info(struct xe_device *xe)
> +{
> +	struct pci_dev *pdev = to_pdev_safe(xe);
> +
> +	if (pdev)
> +		xe_log_emit(pdev, CPER_SEV_INFORMATIONAL, XE_SIGID_DEVICE_FW,
> +			    XE_LOG_COMPONENT_NONE, XE_LOG_LOCATION_NONE,
> +			    NULL, 0, "testing %d\n", 123);
> +	return "SIGID=105 testing 123\n";
> +}
> +
> +static const char *test_info_tile(struct xe_device *xe)
> +{
> +	struct xe_tile *tile = to_tile_safe(xe);
> +
> +	if (tile)
> +		xe_log_from_info(tile, XE_SIGID_DEVICE_FW, XE_LOG_COMPONENT_NONE,
> +				 NULL, 0, "testing %d\n", 123);
> +	return "SIGID=105 Tile1: testing 123\n";
> +}
> +
> +static const char *test_info_gt(struct xe_device *xe)
> +{
> +	struct xe_gt *gt = to_gt_safe(xe);
> +
> +	if (gt)
> +		xe_log_from_info(gt, XE_SIGID_DEVICE_FW, XE_LOG_COMPONENT_NONE,
> +				 NULL, 0, "testing %d\n", 123);
> +	return "SIGID=105 Tile1: GT1: testing 123\n";
> +}
> +
> +static const char *test_info_comp(struct xe_device *xe)
> +{
> +	struct pci_dev *pdev = to_pdev_safe(xe);
> +
> +	if (pdev)
> +		xe_log_info(pdev, PCODE, "testing %d\n", 123);
> +	return "SIGID=105 PCODE: testing 123\n";
> +}
> +
> +static const char *test_info_comp_tile(struct xe_device *xe)
> +{
> +	struct xe_tile *tile = to_tile_safe(xe);
> +
> +	if (tile)
> +		xe_log_info(tile, PCODE, "testing %d\n", 123);
> +	return "SIGID=105 Tile1: PCODE: testing 123\n";
> +}
> +
> +static const char *test_info_comp_gt(struct xe_device *xe)
> +{
> +	struct xe_gt *gt = to_gt_safe(xe);
> +
> +	if (gt)
> +		xe_log_info(gt, PCODE, "testing %d\n", 123);
> +	return "SIGID=105 Tile1: GT1: PCODE: testing 123\n";
> +}
> +
> +static const char *test_info_all(struct xe_device *xe)
> +{
> +	struct pci_dev *pdev = to_pdev_safe(xe);
> +	struct xe_gt *gt = to_gt_safe(xe);
> +
> +	if (pdev)
> +		xe_log_emit(pdev, CPER_SEV_INFORMATIONAL, XE_SIGID_DEVICE_FW,
> +			    XE_LOG_COMPONENT_PCODE, MAKE_XE_LOG_LOCATION(GT, gt->info.id),
> +			    NULL, 0, "testing %d\n", 123);
> +	return "SIGID=105 Tile1: GT1: PCODE: testing 123\n";
> +}
> +
> +static const char *test_hw_fatal(struct xe_device *xe)
> +{
> +	struct pci_dev *pdev = to_pdev_safe(xe);
> +
> +	if (pdev)
> +		xe_log_emit_fatal(pdev, XE_SIGID_PCIE,
> +				  XE_LOG_COMPONENT_NONE, XE_LOG_LOCATION_NONE,
> +				  dead, sizeof(dead), "testing %d\n", 123);
> +	return "SIGID=201 FATAL (deadbeef) " HW_ERR "testing 123\n";
> +}
> +
> +static const char *test_hw_recoverable(struct xe_device *xe)
> +{
> +	struct pci_dev *pdev = to_pdev_safe(xe);
> +
> +	if (pdev)
> +		xe_log_emit_recoverable(pdev, XE_SIGID_DEVICE_MEMORY,
> +					XE_LOG_COMPONENT_NONE, XE_LOG_LOCATION_NONE,
> +					dead, sizeof(dead), "testing %d\n", 123);
> +	return "SIGID=202 (deadbeef) " HW_ERR "testing 123\n";
> +}
> +
> +static const char *test_hw_corrected(struct xe_device *xe)
> +{
> +	struct pci_dev *pdev = to_pdev_safe(xe);
> +
> +	if (pdev)
> +		xe_log_emit_corrected(pdev, XE_SIGID_DEVICE_MEMORY,
> +				      XE_LOG_COMPONENT_NONE, XE_LOG_LOCATION_NONE,
> +				      dead, sizeof(dead), "testing %d\n", 123);
> +	return "SIGID=202 CORRECTED (deadbeef) " HW_ERR "testing 123\n";
> +}
> +
> +static const char *test_hw_informational(struct xe_device *xe)
> +{
> +	struct pci_dev *pdev = to_pdev_safe(xe);
> +
> +	if (pdev)
> +		xe_log_emit_info(pdev, XE_SIGID_DEVICE_MEMORY,
> +				 XE_LOG_COMPONENT_NONE, XE_LOG_LOCATION_NONE,
> +				 dead, sizeof(dead), "testing %d\n", 123);
> +	return "SIGID=202 (deadbeef) testing 123\n";
> +}
> +
> +static const struct log_test_param {
> +	const char *(*func)(struct xe_device *xe);
> +} log_test_params[] = {
> +	{ .func = test_fatal },
> +	{ .func = test_fatal_tile },
> +	{ .func = test_fatal_gt },
> +	{ .func = test_fatal_comp },
> +	{ .func = test_fatal_comp_tile },
> +	{ .func = test_fatal_comp_gt },
> +	{ .func = test_fatal_all },
> +	{ .func = test_recoverable },
> +	{ .func = test_recoverable_tile },
> +	{ .func = test_recoverable_gt },
> +	{ .func = test_recoverable_comp },
> +	{ .func = test_recoverable_comp_tile },
> +	{ .func = test_recoverable_comp_gt },
> +	{ .func = test_recoverable_all },
> +	{ .func = test_info },
> +	{ .func = test_info_tile },
> +	{ .func = test_info_gt },
> +	{ .func = test_info_comp },
> +	{ .func = test_info_comp_tile },
> +	{ .func = test_info_comp_gt },
> +	{ .func = test_info_all },
> +	{ .func = test_hw_fatal },
> +	{ .func = test_hw_recoverable },
> +	{ .func = test_hw_corrected },
> +	{ .func = test_hw_informational },
> +};
> +
> +static void log_param_get_desc(const struct log_test_param *p, char *desc)
> +{
> +	snprintf(desc, KUNIT_PARAM_DESC_SIZE, "%ps", p->func);
> +}
> +
> +KUNIT_ARRAY_PARAM(log, log_test_params, log_param_get_desc);
> +
> +static void check_dmesg_vprintk(struct pci_dev *pdev, int cper_sev, struct va_format *vaf)
> +{
> +	struct kunit *test = kunit_get_current_test();
> +	const struct log_test_param *param = test->param_value;
> +	const char *exp = param->func(NULL);
> +	char msg[64];
> +	int n;
> +
> +	n = vsnprintf(msg, sizeof(msg), vaf->fmt, *vaf->va);
> +	KUNIT_EXPECT_LT(test, n, sizeof(msg));
> +	KUNIT_EXPECT_STREQ(test, msg, exp);
> +}
> +
> +static void test_dmesg(struct kunit *test)
> +{
> +	const struct log_test_param *param = test->param_value;
> +
> +	kunit_activate_static_stub(test, log_emit_cper, nop_emit_cper);
> +	kunit_activate_static_stub(test, log_dmesg_vprintk, check_dmesg_vprintk);
> +
> +	param->func(test->priv);
> +}
> +
> +#define INVALID_TILEID	(XE_MAX_TILES_PER_DEVICE + 1)
> +#define INVALID_GTID	(XE_MAX_TILES_PER_DEVICE * XE_MAX_GT_PER_TILE + 1)
> +
> +#define PREP_TEST_LOCATION(type, id) \
> +	(FIELD_PREP_CONST(XE_LOG_LOCATION_TYPE_MASK, (type)) | \
> +	 FIELD_PREP_CONST(XE_LOG_LOCATION_ID_MASK, (id)))
> +#define PREP_TEST_COMPONENT(class, type) \
> +	(FIELD_PREP_CONST(XE_LOG_COMPONENT_CLASS_MASK, (class)) | \
> +	 FIELD_PREP_CONST(XE_LOG_COMPONENT_TYPE_MASK, (type)))
> +
> +static const struct {
> +	u32 comp;
> +	u32 loc;
> +	const char *name;
> +} invalid_params[] = {
> +	{	.name = "no-component no-location no-warn" },
> +	{	.loc = PREP_TEST_LOCATION(0, 1),
> +		.name = "reserved location" },
> +	{	.loc = PREP_TEST_LOCATION(255, 0),
> +		.name = "unknown location" },
> +	{	.loc = PREP_TEST_LOCATION(XE_LOG_LOCATION_TYPE_DEVICE, 1),
> +		.name = "nonzero-device-id location" },
> +	{	.loc = PREP_TEST_LOCATION(XE_LOG_LOCATION_TYPE_TILE, INVALID_TILEID),
> +		.name = "invalid-tile-id location" },
> +	{	.loc = PREP_TEST_LOCATION(XE_LOG_LOCATION_TYPE_GT, INVALID_GTID),
> +		.name = "invalid-gt-id location" },
> +	{	.comp = PREP_TEST_COMPONENT(255, 0),
> +		.name = "unknown component class" },
> +	{	.comp = PREP_TEST_COMPONENT(XE_LOG_COMPONENT_CLASS_SYSTEM, 255),
> +		.name = "unknown system component" },
> +	{	.comp = PREP_TEST_COMPONENT(XE_LOG_COMPONENT_CLASS_HARDWARE, 255),
> +		.name = "unknown hardware component" },
> +	{	.comp = PREP_TEST_COMPONENT(255, 1),
> +		.loc = PREP_TEST_LOCATION(255, 1),
> +		.name = "unknown component and location" },
> +};
> +
> +KUNIT_ARRAY_PARAM_DESC(invalid_param, invalid_params, name);
> +
> +static void test_invalid(struct kunit *test)
> +{
> +	struct xe_device *xe = test->priv;
> +	typeof(invalid_params[0]) *param = test->param_value;
> +
> +	struct pci_dev *pdev = xe_any_to_pdev(xe);
> +
> +	if (!IS_ENABLED(CONFIG_DRM_XE_DEBUG))
> +		kunit_skip(test, "requires CONFIG_DRM_XE_DEBUG\n");
> +
> +	kunit_activate_static_stub(test, log_emit_cper, nop_emit_cper);
> +	kunit_activate_static_stub(test, log_dmesg_vprintk, nop_dmesg_vprintk);
> +
> +	kunit_warning_suppress(test) {
> +		xe_log_emit(pdev, CPER_SEV_FATAL, XE_SIGID_PROBE,
> +			param->comp, param->loc,
> +			NULL, 0, "testing %s\n", param->name);
> +		KUNIT_EXPECT_SUPPRESSED_WARNING_COUNT(test, !!param->comp + !!param->loc);
> +	}
> +}
> +
> +static int xe_log_test_init(struct kunit *test)
> +{
> +	struct xe_pci_fake_data fake = {
> +		.platform = XE_PVC, /* with max_remote_tiles != 0 */
> +		.subplatform = XE_SUBPLATFORM_NONE,
> +		.graphics_verx100 = 2001,
> +		.media_verx100 = 2001,
> +	};
> +	struct xe_device *xe;
> +
> +	test->priv = &fake;
> +	xe_kunit_helper_xe_device_test_init(test);
> +	xe = test->priv;
> +
> +	KUNIT_ASSERT_NOT_NULL(test, to_tile_safe(xe));
> +	KUNIT_ASSERT_NOT_NULL(test, to_gt_safe(xe));
> +	KUNIT_EXPECT_EQ(test, 1, xe_any_id(to_tile_safe(xe)));
> +	KUNIT_EXPECT_EQ(test, 1, xe_any_id(to_gt_safe(xe)));
> +
> +	return 0;
> +}
> +
> +static struct kunit_case xe_log_test_cases[] = {
> +	KUNIT_CASE(demo_cper),
> +	KUNIT_CASE(demo_dmesg),
> +	KUNIT_CASE_PARAM(test_dmesg, log_gen_params),
> +	KUNIT_CASE_PARAM(test_invalid, invalid_param_gen_params),
> +	{}
> +};
> +
> +static struct kunit_suite xe_log_suite = {
> +	.name = "xe_log",
> +	.test_cases = xe_log_test_cases,
> +	.init = xe_log_test_init,
> +};
> +
> +kunit_test_suites(&xe_log_suite);
> diff --git a/drivers/gpu/drm/xe/xe_log.c b/drivers/gpu/drm/xe/xe_log.c
> index ff6a61f1ac7c..b462e75d4ad0 100644
> --- a/drivers/gpu/drm/xe/xe_log.c
> +++ b/drivers/gpu/drm/xe/xe_log.c
> @@ -3,6 +3,9 @@
>    * Copyright © 2026 Intel Corporation
>    */
>   
> +#include <kunit/static_stub.h>
> +#include <kunit/visibility.h>
> +
>   #include "abi/xe_log_abi.h"
>   
>   #include "xe_device.h"
> @@ -13,6 +16,8 @@ static void log_emit_cper(struct pci_dev *pdev, int cper_sev, enum xe_sigid sigi
>   			  u32 component, u32 location, const void *data, size_t len,
>   			  struct va_format *vaf)
>   {
> +	KUNIT_STATIC_STUB_REDIRECT(log_emit_cper, pdev, cper_sev, sigid,
> +				   component, location, data, len, vaf);
>   	/* TODO */
>   }
>   
> @@ -129,6 +134,8 @@ static const char *log_sev_prefix(int cper_sev)
>   
>   static void log_dmesg_vprintk(struct pci_dev *pdev, int cper_sev, struct va_format *vaf)
>   {
> +	KUNIT_STATIC_STUB_REDIRECT(log_dmesg_vprintk, pdev, cper_sev, vaf);
> +
>   	if (cper_sev == CPER_SEV_INFORMATIONAL)
>   		pci_info(pdev, __LOG_DRM_PRINTK_FMT("%pV", vaf));
>   	else
> @@ -219,3 +226,7 @@ void xe_log_emit(struct pci_dev *pdev, int cper_sev, enum xe_sigid sigid,
>   
>   	va_end(args);
>   }
> +
> +#if IS_BUILTIN(CONFIG_DRM_XE_KUNIT_TEST)
> +#include "tests/xe_log_kunit.c"
> +#endif

  reply	other threads:[~2026-08-12 11:15 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 [this message]
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   ` [PATCH v3 15/23] drm/xe/tests: Add kunit tests for xe_any Mallesh, Koujalagi

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=a7830adb-e8b6-4c42-97f0-a848adcdc0f2@intel.com \
    --to=mallesh.koujalagi@intel.com \
    --cc=aravind.iddamsetty@intel.com \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=michal.wajdeczko@intel.com \
    --cc=rodrigo.vivi@intel.com \
    --cc=yoni.levitt@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