* [PATCH v2 0/4] Add KUnit tests for CPER GUID mappings
@ 2026-11-30 14:08 Mallesh Koujalagi
2026-11-30 14:08 ` [PATCH v2 1/4] drm/xe/cper: " Mallesh Koujalagi
` (3 more replies)
0 siblings, 4 replies; 7+ messages in thread
From: Mallesh Koujalagi @ 2026-11-30 14:08 UTC (permalink / raw)
To: intel-xe
Cc: rodrigo.vivi, anshuman.gupta, badal.nilawar, riana.tauro,
karthik.poosa, sk.anirban, raag.jadav, matthew.d.roper,
daniele.ceraolospurio, Mallesh Koujalagi
The patch series adds KUnit coverage for the Xe CPER platform GUID table.
Tests check PCI ID and GUID sync, uniqueness, UUIDv5 format etc.
v2:
- Rebase.
- Select UEFI_CPER properly. (Sashiko)
- Update GUIDs for device IDs 6753-6756.
Cc: Badal Nilawar <badal.nilawar@intel.com>
Cc: Matt Roper <matthew.d.roper@intel.com>
Cc: Daniele Ceraolo Spurio <daniele.ceraolospurio@intel.com>
Mallesh Koujalagi (4):
drm/xe/cper: Add KUnit tests for CPER GUID mappings
drm/xe/cper: Add KUnit tests for GUID uniqueness
drm/xe/cper: Validate platform GUIDs in KUnit tests
drm/xe/cper: Add PCI ID to GUID mapping verification in KUnit
drivers/gpu/drm/xe/Kconfig.debug | 1 +
drivers/gpu/drm/xe/tests/xe_cper_kunit.c | 192 +++++++++++++++++++++++
drivers/gpu/drm/xe/xe_cper.c | 4 +
3 files changed, 197 insertions(+)
create mode 100644 drivers/gpu/drm/xe/tests/xe_cper_kunit.c
--
2.48.1
^ permalink raw reply [flat|nested] 7+ messages in thread* [PATCH v2 1/4] drm/xe/cper: Add KUnit tests for CPER GUID mappings 2026-11-30 14:08 [PATCH v2 0/4] Add KUnit tests for CPER GUID mappings Mallesh Koujalagi @ 2026-11-30 14:08 ` Mallesh Koujalagi 2026-11-30 14:25 ` sashiko-bot 2026-11-30 14:08 ` [PATCH v2 2/4] drm/xe/cper: Add KUnit tests for GUID uniqueness Mallesh Koujalagi ` (2 subsequent siblings) 3 siblings, 1 reply; 7+ messages in thread From: Mallesh Koujalagi @ 2026-11-30 14:08 UTC (permalink / raw) To: intel-xe Cc: rodrigo.vivi, anshuman.gupta, badal.nilawar, riana.tauro, karthik.poosa, sk.anirban, raag.jadav, matthew.d.roper, daniele.ceraolospurio, Mallesh Koujalagi Verify that CRI PCI IDs and CPER GUID entries remain in sync and detect stale mappings. Cc: Badal Nilawar <badal.nilawar@intel.com> Signed-off-by: Mallesh Koujalagi <mallesh.koujalagi@intel.com> --- v2: - Select UEFI_CPER properly. (Sashiko) --- drivers/gpu/drm/xe/Kconfig.debug | 1 + drivers/gpu/drm/xe/tests/xe_cper_kunit.c | 76 ++++++++++++++++++++++++ drivers/gpu/drm/xe/xe_cper.c | 4 ++ 3 files changed, 81 insertions(+) create mode 100644 drivers/gpu/drm/xe/tests/xe_cper_kunit.c diff --git a/drivers/gpu/drm/xe/Kconfig.debug b/drivers/gpu/drm/xe/Kconfig.debug index 79118d9efd93..c55f90c494f1 100644 --- a/drivers/gpu/drm/xe/Kconfig.debug +++ b/drivers/gpu/drm/xe/Kconfig.debug @@ -77,6 +77,7 @@ config DRM_XE_KUNIT_TEST tristate "KUnit tests for the drm xe driver" if !KUNIT_ALL_TESTS depends on DRM_XE && KUNIT && DEBUG_FS default KUNIT_ALL_TESTS + select UEFI_CPER if !X86 || ACPI select DRM_EXPORT_FOR_TESTS if m help Choose this option to allow the driver to perform selftests under diff --git a/drivers/gpu/drm/xe/tests/xe_cper_kunit.c b/drivers/gpu/drm/xe/tests/xe_cper_kunit.c new file mode 100644 index 000000000000..6376f9e91d7e --- /dev/null +++ b/drivers/gpu/drm/xe/tests/xe_cper_kunit.c @@ -0,0 +1,76 @@ +// SPDX-License-Identifier: GPL-2.0 AND MIT +/* + * Copyright © 2026 Intel Corporation + */ + +#include <kunit/test.h> + +#include <drm/intel/pciids.h> + +/* + * PCI IDs for platforms that support CPER records. + * Must stay in sync with the xe PCI driver table. + */ +#define CPER_TEST_PCI_ID(id) (id) +static const u16 cper_test_pci_ids[] = { + INTEL_CRI_IDS(CPER_TEST_PCI_ID), +}; + +#undef CPER_TEST_PCI_ID + +static bool cper_test_pci_id_known(u16 device_id) +{ + unsigned int i; + + for (i = 0; i < ARRAY_SIZE(cper_test_pci_ids); i++) + if (cper_test_pci_ids[i] == device_id) + return true; + + return false; +} + +static const struct xe_device_guid_entry *cper_test_guid_entry(u16 device_id) +{ + unsigned int i; + + for (i = 0; i < ARRAY_SIZE(xe_device_guids); i++) + if (xe_device_guids[i].device_id == device_id) + return &xe_device_guids[i]; + + return NULL; +} + +static void cper_test_pci_ids_have_guid(struct kunit *test) +{ + unsigned int i; + + KUNIT_ASSERT_GT(test, ARRAY_SIZE(cper_test_pci_ids), 0); + + for (i = 0; i < ARRAY_SIZE(cper_test_pci_ids); i++) + KUNIT_EXPECT_NOT_NULL_MSG(test, cper_test_guid_entry(cper_test_pci_ids[i]), + "PCI ID %#06x has no entry in xe_device_guids[]", + cper_test_pci_ids[i]); +} + +static void cper_test_guids_have_pci_id(struct kunit *test) +{ + unsigned int i; + + for (i = 0; i < ARRAY_SIZE(xe_device_guids); i++) + KUNIT_EXPECT_TRUE_MSG(test, cper_test_pci_id_known(xe_device_guids[i].device_id), + "xe_device_guids[%u] PCI ID %#06x is not a known platform PCI ID", + i, xe_device_guids[i].device_id); +} + +static struct kunit_case xe_cper_test_cases[] = { + KUNIT_CASE(cper_test_pci_ids_have_guid), + KUNIT_CASE(cper_test_guids_have_pci_id), + {} +}; + +static struct kunit_suite xe_cper_suite = { + .name = "xe_cper", + .test_cases = xe_cper_test_cases, +}; + +kunit_test_suites(&xe_cper_suite); diff --git a/drivers/gpu/drm/xe/xe_cper.c b/drivers/gpu/drm/xe/xe_cper.c index 10a4085d47f0..cef9b2ce0999 100644 --- a/drivers/gpu/drm/xe/xe_cper.c +++ b/drivers/gpu/drm/xe/xe_cper.c @@ -620,3 +620,7 @@ int xe_cper_sysfs_init(struct xe_device *xe) { return devm_device_add_group(xe->drm.dev, &cper_group); } + +#if IS_ENABLED(CONFIG_DRM_XE_KUNIT_TEST) +#include "tests/xe_cper_kunit.c" +#endif -- 2.48.1 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH v2 1/4] drm/xe/cper: Add KUnit tests for CPER GUID mappings 2026-11-30 14:08 ` [PATCH v2 1/4] drm/xe/cper: " Mallesh Koujalagi @ 2026-11-30 14:25 ` sashiko-bot 0 siblings, 0 replies; 7+ messages in thread From: sashiko-bot @ 2026-11-30 14:25 UTC (permalink / raw) To: Mallesh Koujalagi, intel-xe Thank you for your contribution! Sashiko AI review found 1 potential issue to consider: - [Medium] drm/xe/cper: xe_cper.c includes KUnit suite under IS_ENABLED not IS_BUILTIN -- commit f07f36170256d3e8a2df6a694614b76a315a8b2d Author: Mallesh Koujalagi <mallesh.koujalagi@intel.com> drm/xe/cper: Add KUnit tests for CPER GUID mappings This commit adds a KUnit test suite to verify that CRI PCI IDs and CPER GUID entries in xe_device_guids[] stay in sync, and selects UEFI_CPER for DRM_XE_KUNIT_TEST. > diff --git a/drivers/gpu/drm/xe/tests/xe_cper_kunit.c b/drivers/gpu/drm/xe/tests/xe_cper_kunit.c > new file mode 100644 > index 0000000000000..6376f9e91d7eb > --- /dev/null > +++ b/drivers/gpu/drm/xe/tests/xe_cper_kunit.c [ ... ] > +static struct kunit_suite xe_cper_suite = { > + .name = "xe_cper", > + .test_cases = xe_cper_test_cases, > +}; > + > +kunit_test_suites(&xe_cper_suite); > diff --git a/drivers/gpu/drm/xe/xe_cper.c b/drivers/gpu/drm/xe/xe_cper.c > index 64bbb149e4e3e..ee00c7b31a7ac 100644 > --- a/drivers/gpu/drm/xe/xe_cper.c > +++ b/drivers/gpu/drm/xe/xe_cper.c > @@ -571,3 +571,7 @@ int xe_cper_sysfs_init(struct xe_device *xe) > { > return devm_device_add_group(xe->drm.dev, &cper_group); > } > + > +#if IS_ENABLED(CONFIG_DRM_XE_KUNIT_TEST) > +#include "tests/xe_cper_kunit.c" > +#endif [Severity: Medium] Should this include be guarded by IS_BUILTIN(CONFIG_DRM_XE_KUNIT_TEST) like the other inline KUnit test files in drivers/gpu/drm/xe/ that call kunit_test_suites()? xe_cper.o is linked into the main xe.ko module. When CONFIG_DRM_XE_KUNIT_TEST=m, IS_ENABLED(CONFIG_DRM_XE_KUNIT_TEST) is true, so kunit_test_suites(&xe_cper_suite) embeds a .kunit_test_suites section into xe.ko itself. Loading xe.ko then triggers kunit_module_notify() -> kunit_module_init(), running xe_cper_suite and tainting the kernel with TAINT_TEST during normal driver load even when no KUnit test module is loaded. -- Sashiko AI review · https://sashiko.dev/#/patchset/20261130140815.2227101-6-mallesh.koujalagi@intel.com?part=1 ^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH v2 2/4] drm/xe/cper: Add KUnit tests for GUID uniqueness 2026-11-30 14:08 [PATCH v2 0/4] Add KUnit tests for CPER GUID mappings Mallesh Koujalagi 2026-11-30 14:08 ` [PATCH v2 1/4] drm/xe/cper: " Mallesh Koujalagi @ 2026-11-30 14:08 ` Mallesh Koujalagi 2026-11-30 14:08 ` [PATCH v2 3/4] drm/xe/cper: Validate platform GUIDs in KUnit tests Mallesh Koujalagi 2026-11-30 14:08 ` [PATCH v2 4/4] drm/xe/cper: Add PCI ID to GUID mapping verification in KUnit Mallesh Koujalagi 3 siblings, 0 replies; 7+ messages in thread From: Mallesh Koujalagi @ 2026-11-30 14:08 UTC (permalink / raw) To: intel-xe Cc: rodrigo.vivi, anshuman.gupta, badal.nilawar, riana.tauro, karthik.poosa, sk.anirban, raag.jadav, matthew.d.roper, daniele.ceraolospurio, Mallesh Koujalagi Verify that CPER GUID entries have unique PCI IDs and platform GUIDs. Cc: Badal Nilawar <badal.nilawar@intel.com> Signed-off-by: Mallesh Koujalagi <mallesh.koujalagi@intel.com> --- drivers/gpu/drm/xe/tests/xe_cper_kunit.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/drivers/gpu/drm/xe/tests/xe_cper_kunit.c b/drivers/gpu/drm/xe/tests/xe_cper_kunit.c index 6376f9e91d7e..c28df26cc10e 100644 --- a/drivers/gpu/drm/xe/tests/xe_cper_kunit.c +++ b/drivers/gpu/drm/xe/tests/xe_cper_kunit.c @@ -62,9 +62,30 @@ static void cper_test_guids_have_pci_id(struct kunit *test) i, xe_device_guids[i].device_id); } +static void cper_test_guids_unique(struct kunit *test) +{ + unsigned int i, j; + + for (i = 0; i < ARRAY_SIZE(xe_device_guids); i++) { + for (j = i + 1; j < ARRAY_SIZE(xe_device_guids); j++) { + KUNIT_EXPECT_NE_MSG(test, xe_device_guids[i].device_id, + xe_device_guids[j].device_id, + "duplicate PCI ID %#06x at [%u] and [%u]", + xe_device_guids[i].device_id, i, j); + KUNIT_EXPECT_FALSE_MSG(test, guid_equal(&xe_device_guids[i].guid, + &xe_device_guids[j].guid), + "duplicate GUID %pUl for PCI IDs %#06x and %#06x", + &xe_device_guids[i].guid, + xe_device_guids[i].device_id, + xe_device_guids[j].device_id); + } + } +} + static struct kunit_case xe_cper_test_cases[] = { KUNIT_CASE(cper_test_pci_ids_have_guid), KUNIT_CASE(cper_test_guids_have_pci_id), + KUNIT_CASE(cper_test_guids_unique), {} }; -- 2.48.1 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH v2 3/4] drm/xe/cper: Validate platform GUIDs in KUnit tests 2026-11-30 14:08 [PATCH v2 0/4] Add KUnit tests for CPER GUID mappings Mallesh Koujalagi 2026-11-30 14:08 ` [PATCH v2 1/4] drm/xe/cper: " Mallesh Koujalagi 2026-11-30 14:08 ` [PATCH v2 2/4] drm/xe/cper: Add KUnit tests for GUID uniqueness Mallesh Koujalagi @ 2026-11-30 14:08 ` Mallesh Koujalagi 2026-11-30 14:08 ` [PATCH v2 4/4] drm/xe/cper: Add PCI ID to GUID mapping verification in KUnit Mallesh Koujalagi 3 siblings, 0 replies; 7+ messages in thread From: Mallesh Koujalagi @ 2026-11-30 14:08 UTC (permalink / raw) To: intel-xe Cc: rodrigo.vivi, anshuman.gupta, badal.nilawar, riana.tauro, karthik.poosa, sk.anirban, raag.jadav, matthew.d.roper, daniele.ceraolospurio, Mallesh Koujalagi Verify that platform GUIDs use the expected UUIDv5 format and do not overlap with reserved CPER GUIDs. Cc: Badal Nilawar <badal.nilawar@intel.com> Signed-off-by: Mallesh Koujalagi <mallesh.koujalagi@intel.com> --- drivers/gpu/drm/xe/tests/xe_cper_kunit.c | 32 ++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/drivers/gpu/drm/xe/tests/xe_cper_kunit.c b/drivers/gpu/drm/xe/tests/xe_cper_kunit.c index c28df26cc10e..5bd0bbcef566 100644 --- a/drivers/gpu/drm/xe/tests/xe_cper_kunit.c +++ b/drivers/gpu/drm/xe/tests/xe_cper_kunit.c @@ -82,10 +82,42 @@ static void cper_test_guids_unique(struct kunit *test) } } +/* + * GUIDs are UUIDv5 (RFC 9562): version in byte 7, variant in byte 8. + */ +static void cper_test_guids_are_uuidv5(struct kunit *test) +{ + static const guid_t reserved[] = { + INTEL_CPER_CREATOR_XEKMD, + INTEL_CPER_NOTIFY_GPU_ERROR, + INTEL_CPER_SECTION_ACCEL_GENERIC, + }; + unsigned int i, j; + + for (i = 0; i < ARRAY_SIZE(xe_device_guids); i++) { + const struct xe_device_guid_entry *e = &xe_device_guids[i]; + + KUNIT_EXPECT_FALSE_MSG(test, guid_is_null(&e->guid), + "PCI ID %#06x has a null GUID", e->device_id); + KUNIT_EXPECT_EQ_MSG(test, e->guid.b[7] >> 4, 5, + "PCI ID %#06x GUID %pUl is not UUIDv5", + e->device_id, &e->guid); + KUNIT_EXPECT_EQ_MSG(test, e->guid.b[8] & 0xc0, 0x80, + "PCI ID %#06x GUID %pUl has wrong variant", + e->device_id, &e->guid); + + for (j = 0; j < ARRAY_SIZE(reserved); j++) + KUNIT_EXPECT_FALSE_MSG(test, guid_equal(&e->guid, &reserved[j]), + "PCI ID %#06x GUID %pUl collides with a CPER type GUID", + e->device_id, &e->guid); + } +} + static struct kunit_case xe_cper_test_cases[] = { KUNIT_CASE(cper_test_pci_ids_have_guid), KUNIT_CASE(cper_test_guids_have_pci_id), KUNIT_CASE(cper_test_guids_unique), + KUNIT_CASE(cper_test_guids_are_uuidv5), {} }; -- 2.48.1 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH v2 4/4] drm/xe/cper: Add PCI ID to GUID mapping verification in KUnit 2026-11-30 14:08 [PATCH v2 0/4] Add KUnit tests for CPER GUID mappings Mallesh Koujalagi ` (2 preceding siblings ...) 2026-11-30 14:08 ` [PATCH v2 3/4] drm/xe/cper: Validate platform GUIDs in KUnit tests Mallesh Koujalagi @ 2026-11-30 14:08 ` Mallesh Koujalagi 2026-11-30 14:16 ` sashiko-bot 3 siblings, 1 reply; 7+ messages in thread From: Mallesh Koujalagi @ 2026-11-30 14:08 UTC (permalink / raw) To: intel-xe Cc: rodrigo.vivi, anshuman.gupta, badal.nilawar, riana.tauro, karthik.poosa, sk.anirban, raag.jadav, matthew.d.roper, daniele.ceraolospurio, Mallesh Koujalagi Add expected UUIDv5 mappings to verify each PCI ID maps to its correct GUID. Cc: Badal Nilawar <badal.nilawar@intel.com> Cc: Matt Roper <matthew.d.roper@intel.com> Cc: Daniele Ceraolo Spurio <daniele.ceraolospurio@intel.com> Signed-off-by: Mallesh Koujalagi <mallesh.koujalagi@intel.com> --- v2: - Update GUIDs for device IDs 6753-6756. --- drivers/gpu/drm/xe/tests/xe_cper_kunit.c | 63 ++++++++++++++++++++++++ 1 file changed, 63 insertions(+) diff --git a/drivers/gpu/drm/xe/tests/xe_cper_kunit.c b/drivers/gpu/drm/xe/tests/xe_cper_kunit.c index 5bd0bbcef566..72c86b7ea377 100644 --- a/drivers/gpu/drm/xe/tests/xe_cper_kunit.c +++ b/drivers/gpu/drm/xe/tests/xe_cper_kunit.c @@ -18,6 +18,32 @@ static const u16 cper_test_pci_ids[] = { #undef CPER_TEST_PCI_ID +/* UUIDv5 outputs for "platform/8086:<device_id>". */ +static const struct xe_device_guid_entry cper_test_expected_guids[] = { + { 0x674C, GUID_INIT(0x9046afe5, 0x9041, 0x5124, + 0x86, 0x14, 0x92, 0x55, 0x0d, 0x9e, 0x9d, 0xa6) }, + { 0x674D, GUID_INIT(0xf95911b8, 0x6564, 0x5905, + 0xa6, 0xa7, 0xb9, 0xbf, 0x54, 0xab, 0x6c, 0x27) }, + { 0x674E, GUID_INIT(0xb8d24106, 0x0108, 0x59f1, + 0x8f, 0xfc, 0x9f, 0xc4, 0xa9, 0xc9, 0xb7, 0xb0) }, + { 0x674F, GUID_INIT(0xdd8dd88e, 0xef2f, 0x59b1, + 0x99, 0x15, 0xdb, 0x6f, 0x1d, 0xc9, 0xb4, 0x5d) }, + { 0x6750, GUID_INIT(0x1dd66c44, 0x87d5, 0x524a, + 0xad, 0x6e, 0xfc, 0x18, 0x9d, 0x42, 0x6f, 0x1a) }, + { 0x6751, GUID_INIT(0x17d0dd04, 0x2fad, 0x5400, + 0x99, 0xc8, 0x9b, 0x45, 0x51, 0x3b, 0x67, 0xe3) }, + { 0x6752, GUID_INIT(0xb778ead8, 0x0009, 0x59a7, + 0xa1, 0x3a, 0x78, 0xce, 0x4d, 0xdd, 0xae, 0xf5) }, + { 0x6753, GUID_INIT(0x7fcd80a7, 0xca5a, 0x5d21, + 0x97, 0x0f, 0xe7, 0x6a, 0xc0, 0x27, 0xbb, 0x76) }, + { 0x6754, GUID_INIT(0xf87c6f75, 0x96c1, 0x5ce4, + 0x86, 0x75, 0xc7, 0xaa, 0x04, 0xbc, 0xc6, 0xd8) }, + { 0x6755, GUID_INIT(0x839514b4, 0xf269, 0x5e61, + 0xba, 0x2f, 0x79, 0x08, 0xa7, 0x59, 0x06, 0x5f) }, + { 0x6756, GUID_INIT(0x5003ffda, 0xab3f, 0x5ae1, + 0xb3, 0xbd, 0x19, 0x60, 0x0e, 0x0d, 0x4c, 0xc2) }, +}; + static bool cper_test_pci_id_known(u16 device_id) { unsigned int i; @@ -40,6 +66,17 @@ static const struct xe_device_guid_entry *cper_test_guid_entry(u16 device_id) return NULL; } +static const struct xe_device_guid_entry *cper_test_expected_guid_entry(u16 device_id) +{ + unsigned int i; + + for (i = 0; i < ARRAY_SIZE(cper_test_expected_guids); i++) + if (cper_test_expected_guids[i].device_id == device_id) + return &cper_test_expected_guids[i]; + + return NULL; +} + static void cper_test_pci_ids_have_guid(struct kunit *test) { unsigned int i; @@ -52,6 +89,31 @@ static void cper_test_pci_ids_have_guid(struct kunit *test) cper_test_pci_ids[i]); } +static void cper_test_guid_matches_pci_id(struct kunit *test) +{ + unsigned int i; + + KUNIT_ASSERT_EQ(test, ARRAY_SIZE(cper_test_expected_guids), + ARRAY_SIZE(cper_test_pci_ids)); + + for (i = 0; i < ARRAY_SIZE(cper_test_pci_ids); i++) { + u16 device_id = cper_test_pci_ids[i]; + const struct xe_device_guid_entry *actual = cper_test_guid_entry(device_id); + const struct xe_device_guid_entry *expected = + cper_test_expected_guid_entry(device_id); + + KUNIT_ASSERT_NOT_NULL_MSG(test, expected, + "PCI ID %#06x has no expected GUID", + device_id); + KUNIT_ASSERT_NOT_NULL_MSG(test, actual, + "PCI ID %#06x has no GUID entry", + device_id); + KUNIT_EXPECT_TRUE_MSG(test, guid_equal(&actual->guid, &expected->guid), + "PCI ID %#06x has GUID %pUl, expected %pUl", + device_id, &actual->guid, &expected->guid); + } +} + static void cper_test_guids_have_pci_id(struct kunit *test) { unsigned int i; @@ -115,6 +177,7 @@ static void cper_test_guids_are_uuidv5(struct kunit *test) static struct kunit_case xe_cper_test_cases[] = { KUNIT_CASE(cper_test_pci_ids_have_guid), + KUNIT_CASE(cper_test_guid_matches_pci_id), KUNIT_CASE(cper_test_guids_have_pci_id), KUNIT_CASE(cper_test_guids_unique), KUNIT_CASE(cper_test_guids_are_uuidv5), -- 2.48.1 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH v2 4/4] drm/xe/cper: Add PCI ID to GUID mapping verification in KUnit 2026-11-30 14:08 ` [PATCH v2 4/4] drm/xe/cper: Add PCI ID to GUID mapping verification in KUnit Mallesh Koujalagi @ 2026-11-30 14:16 ` sashiko-bot 0 siblings, 0 replies; 7+ messages in thread From: sashiko-bot @ 2026-11-30 14:16 UTC (permalink / raw) To: Mallesh Koujalagi, intel-xe Thank you for your contribution! Sashiko AI review found 1 potential issue to consider: - [Low] drm/xe/cper: cper_test_guid_matches_pci_id() duplicates xe_device_guids table -- commit 176ab22f8c81e3c66e0ddfd127c0940356bbfeeb Author: Mallesh Koujalagi <mallesh.koujalagi@intel.com> drm/xe/cper: Add PCI ID to GUID mapping verification in KUnit This commit adds a KUnit test case to verify that each supported PCI device ID maps to its expected CPER GUID. > diff --git a/drivers/gpu/drm/xe/tests/xe_cper_kunit.c b/drivers/gpu/drm/xe/tests/xe_cper_kunit.c > index 5bd0bbcef566f..72c86b7ea3772 100644 > --- a/drivers/gpu/drm/xe/tests/xe_cper_kunit.c > +++ b/drivers/gpu/drm/xe/tests/xe_cper_kunit.c > @@ -18,6 +18,32 @@ static const u16 cper_test_pci_ids[] = { > > #undef CPER_TEST_PCI_ID > > +/* UUIDv5 outputs for "platform/8086:<device_id>". */ > +static const struct xe_device_guid_entry cper_test_expected_guids[] = { > + { 0x674C, GUID_INIT(0x9046afe5, 0x9041, 0x5124, > + 0x86, 0x14, 0x92, 0x55, 0x0d, 0x9e, 0x9d, 0xa6) }, > + { 0x674D, GUID_INIT(0xf95911b8, 0x6564, 0x5905, > + 0xa6, 0xa7, 0xb9, 0xbf, 0x54, 0xab, 0x6c, 0x27) }, > + { 0x674E, GUID_INIT(0xb8d24106, 0x0108, 0x59f1, > + 0x8f, 0xfc, 0x9f, 0xc4, 0xa9, 0xc9, 0xb7, 0xb0) }, > + { 0x674F, GUID_INIT(0xdd8dd88e, 0xef2f, 0x59b1, > + 0x99, 0x15, 0xdb, 0x6f, 0x1d, 0xc9, 0xb4, 0x5d) }, > + { 0x6750, GUID_INIT(0x1dd66c44, 0x87d5, 0x524a, > + 0xad, 0x6e, 0xfc, 0x18, 0x9d, 0x42, 0x6f, 0x1a) }, > + { 0x6751, GUID_INIT(0x17d0dd04, 0x2fad, 0x5400, > + 0x99, 0xc8, 0x9b, 0x45, 0x51, 0x3b, 0x67, 0xe3) }, > + { 0x6752, GUID_INIT(0xb778ead8, 0x0009, 0x59a7, > + 0xa1, 0x3a, 0x78, 0xce, 0x4d, 0xdd, 0xae, 0xf5) }, > + { 0x6753, GUID_INIT(0x7fcd80a7, 0xca5a, 0x5d21, > + 0x97, 0x0f, 0xe7, 0x6a, 0xc0, 0x27, 0xbb, 0x76) }, > + { 0x6754, GUID_INIT(0xf87c6f75, 0x96c1, 0x5ce4, > + 0x86, 0x75, 0xc7, 0xaa, 0x04, 0xbc, 0xc6, 0xd8) }, > + { 0x6755, GUID_INIT(0x839514b4, 0xf269, 0x5e61, > + 0xba, 0x2f, 0x79, 0x08, 0xa7, 0x59, 0x06, 0x5f) }, > + { 0x6756, GUID_INIT(0x5003ffda, 0xab3f, 0x5ae1, > + 0xb3, 0xbd, 0x19, 0x60, 0x0e, 0x0d, 0x4c, 0xc2) }, > +}; > + > static bool cper_test_pci_id_known(u16 device_id) > { > unsigned int i; > @@ -40,6 +66,17 @@ static const struct xe_device_guid_entry *cper_test_guid_entry(u16 device_id) > return NULL; > } > > +static const struct xe_device_guid_entry *cper_test_expected_guid_entry(u16 device_id) > +{ > + unsigned int i; > + > + for (i = 0; i < ARRAY_SIZE(cper_test_expected_guids); i++) > + if (cper_test_expected_guids[i].device_id == device_id) > + return &cper_test_expected_guids[i]; > + > + return NULL; > +} > + > static void cper_test_pci_ids_have_guid(struct kunit *test) > { > unsigned int i; > @@ -52,6 +89,31 @@ static void cper_test_pci_ids_have_guid(struct kunit *test) > cper_test_pci_ids[i]); > } > > +static void cper_test_guid_matches_pci_id(struct kunit *test) > +{ > + unsigned int i; > + > + KUNIT_ASSERT_EQ(test, ARRAY_SIZE(cper_test_expected_guids), > + ARRAY_SIZE(cper_test_pci_ids)); > + > + for (i = 0; i < ARRAY_SIZE(cper_test_pci_ids); i++) { > + u16 device_id = cper_test_pci_ids[i]; > + const struct xe_device_guid_entry *actual = cper_test_guid_entry(device_id); > + const struct xe_device_guid_entry *expected = > + cper_test_expected_guid_entry(device_id); > + > + KUNIT_ASSERT_NOT_NULL_MSG(test, expected, > + "PCI ID %#06x has no expected GUID", > + device_id); > + KUNIT_ASSERT_NOT_NULL_MSG(test, actual, > + "PCI ID %#06x has no GUID entry", > + device_id); > + KUNIT_EXPECT_TRUE_MSG(test, guid_equal(&actual->guid, &expected->guid), > + "PCI ID %#06x has GUID %pUl, expected %pUl", > + device_id, &actual->guid, &expected->guid); > + } > +} [Severity: Low] Does cper_test_guid_matches_pci_id() just compare xe_device_guids[] against a verbatim copy of itself? cper_test_expected_guids[] duplicates the static xe_device_guids[] table defined in drivers/gpu/drm/xe/xe_cper.c, and cper_test_expected_guid_entry() duplicates the linear search in cper_test_guid_entry(). Because the test compares these two hardcoded tables using test-local helpers, it requires keeping two identical tables in sync without exercising lookup_device_guid() or computing the expected UUIDv5 from "platform/8086:<device_id>". -- Sashiko AI review · https://sashiko.dev/#/patchset/20261130140815.2227101-6-mallesh.koujalagi@intel.com?part=4 ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2026-11-30 14:25 UTC | newest] Thread overview: 7+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2026-11-30 14:08 [PATCH v2 0/4] Add KUnit tests for CPER GUID mappings Mallesh Koujalagi 2026-11-30 14:08 ` [PATCH v2 1/4] drm/xe/cper: " Mallesh Koujalagi 2026-11-30 14:25 ` sashiko-bot 2026-11-30 14:08 ` [PATCH v2 2/4] drm/xe/cper: Add KUnit tests for GUID uniqueness Mallesh Koujalagi 2026-11-30 14:08 ` [PATCH v2 3/4] drm/xe/cper: Validate platform GUIDs in KUnit tests Mallesh Koujalagi 2026-11-30 14:08 ` [PATCH v2 4/4] drm/xe/cper: Add PCI ID to GUID mapping verification in KUnit Mallesh Koujalagi 2026-11-30 14:16 ` sashiko-bot
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox