Skip to contentSkip to conversation

drm/xe: Add structured SIGID error logging infrastructure

PATCH Superseded Michal Wajdeczko 10 participants 109 messages Aug 12 – Aug 14 Page 1 of 2

Subsystems (4)

v4 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

v4 cover drm/xe: Add structured SIGID error logging infrastructure

Today the driver reports faults with ad-hoc drm_err()/xe_gt_err() strings that have no stable shape. That is readable for a human, but it gives fleet tooling nothing durable to match on: the wording changes between releases, lines can be rate-limited or dropped under an error storm, and there is no consistent way to ask "which recognised fault just happened?".

Introduce a signature identifier (SIGID): a small, stable integer that names one recognised Xe fault situation and serves as the primary handle for triage. A SIGID maps, through published end-user documentation, to a description and a recommended action; the driver only has to emit the right SIGID next to the usual human-readable text.

Design decisions:

- Software-emitted signatures only. This header enumerates just the situations the driver detects and reports itself. Signatures that originate in firmware or hardware are identified by those layers (via their own records/counters) and are logged as received -- minting a driver-side id for them would duplicate an id the reporting layer already owns.

- Flat catalogue, chosen per report site. Each site emits the single most specific situation for that site, so a multi-layer failure produces a chain of reports rather than one ambiguous classification (e.g. a failed GT reset reports GT_TDR and then WEDGED). A site that matches no defined situation keeps using ordinary xe_err() / xe_gt_err() rather than forcing a wrong id.

- Stable numbering. A single flat list numbered sequentially from 1, in introduction order. Values are only ever appended, never renumbered or reused.

- Severity is decoupled from the SIGID and chosen at the call site via xe_ras_log_fatal() / _recoverable() / _info(); the same situation can be reported at different severities depending on the instance.

- dmesg stays close to a normal xe error line by reusing xe_err() / xe_gt_err() (and their Tile/GT decoration); the only stable, machine-matchable token added is SIGID=<n>. dmesg is not an ABI -- the durable machine record is the CPER carrying the same SIGID (a planned follow-up, left as a TODO).

Wire up a representative site for each software signature so the set is exercised rather than merely declared.

Cc Thomas Hellström <[email protected]>
Cc Matthew Brost <[email protected]>
Cc Aravind Iddamsetty <[email protected]>
Cc Riana Tauro <[email protected]>
Cc Raag Jadav <[email protected]>
Cc Badal Nilawar <[email protected]>

v1: https://patchwork.freedesktop.org/series/171022/#rev1
v2: https://patchwork.freedesktop.org/series/171022/#rev2
component/location dmesg decorations moved away from macros HW component identifiers related to RAS/FW enum values CORRECTED severity rendered as an error
more support for const pointers
log 'probe blocked' as INFO
fix kunit device setup
more tests
v3: https://patchwork.freedesktop.org/series/171022/#rev3
fix typos, args list and to_dev() corner case (Sashiko) use assoc macros in xe_any (Jani)
add xe_any kunit test suite (Michal)
add more xe_log test cases (Michal)
v4: more patches with SIGID usage (Michal)
support for printk index (Jani)
more macros and other fixes (Mallesh)
no recovery buckets (all)

Mallesh Koujalagi (1):
drm/xe/log: Add structured SIGID error logging infrastructure

Michal Wajdeczko (31):
drm/xe: Introduce xe_any helpers
drm/xe/log: Introduce structured component/location identifiers drm/xe/log: Add component/location decorations to dmesg drm/xe/log: Add SIGID log helpers for severity
drm/xe/log: Add SIGID log helpers for location
drm/xe/log: Add SIGID log helpers for location & severity drm/xe/log: Add SIGID log helpers for components drm/xe/log: Add SIGID log helpers for component & severity drm/xe/log: Add SIGID log helpers for errno-only drm/xe/log: Index all SIGID printk messages
drm/xe/log: Add hardware error signatures
drm/xe/log: Extend components list with hardware items drm/xe/ras: Check RAS and LOG component definitions drm/xe/kunit: Setup driver data in the test device drm/xe/tests: Add Kunit tests for xe_log
drm/xe/tests: Add kunit tests for xe_any
drm/xe: Report 'probe blocked' error using SIGID
drm/xe: Report all probe errors using SIGID drm/xe/survivability: Report 'boot status' using SIGID drm/xe/survivability: Report 'sysfs failure' error using SIGID drm/xe/survivability: Report 'Boot Mode enabled' status using SIGID drm/xe/survivability: Report 'Runtime Mode enabled' status using SIGID drm/xe: Report 'device wedged' errors using SIGID drm/xe/pcode: Report 'Mailbox failed' error using SIGID drm/xe/pcode: Report 'timeout, retrying' error using SIGID drm/xe/pcode: Report 'initialization timedout' error using SIGID drm/xe/guc: Report 'GuC mmio' errors using SIGID drm/xe/gt: Report 'reset failed' errors using SIGID drm/xe/gt: Report 'Fault response' pagefault error using SIGID drm/xe/gt: Report 'Queue full' pagefault error using SIGID drm/xe/pci: Report 'cannot re-enable' error using SIGID

 Documentation/gpu/xe/index.rst              |   1 +
 Documentation/gpu/xe/xe_sigid.rst           |  14 +
 drivers/gpu/drm/xe/Makefile                 |   1 +
 drivers/gpu/drm/xe/abi/xe_log_abi.h         | 199 +++++++
 drivers/gpu/drm/xe/abi/xe_sigid_abi.h       | 172 +++++++
 drivers/gpu/drm/xe/tests/Makefile           |   1 +
 drivers/gpu/drm/xe/tests/xe_any_kunit.c     | 213 ++++++++
 drivers/gpu/drm/xe/tests/xe_kunit_helpers.c |   4 +
 drivers/gpu/drm/xe/tests/xe_log_kunit.c     | 543 ++++++++++++++++++++
 drivers/gpu/drm/xe/xe_any.h                 | 137 +++++
 drivers/gpu/drm/xe/xe_device.c              |  16 +-
 drivers/gpu/drm/xe/xe_gt.c                  |   7 +-
 drivers/gpu/drm/xe/xe_guc.c                 |  18 +-
 drivers/gpu/drm/xe/xe_log.c                 | 235 +++++++++
 drivers/gpu/drm/xe/xe_log.h                 | 178 +++++++
 drivers/gpu/drm/xe/xe_pagefault.c           |   8 +-
 drivers/gpu/drm/xe/xe_pci.c                 |  32 +-
 drivers/gpu/drm/xe/xe_pci_error.c           |   7 +-
 drivers/gpu/drm/xe/xe_pcode.c               |  14 +-
 drivers/gpu/drm/xe/xe_ras.c                 |  11 +
 drivers/gpu/drm/xe/xe_survivability_mode.c  |  84 +--
 21 files changed, 1821 insertions(+), 74 deletions(-)
 create mode 100644 Documentation/gpu/xe/xe_sigid.rst
 create mode 100644 drivers/gpu/drm/xe/abi/xe_log_abi.h
 create mode 100644 drivers/gpu/drm/xe/abi/xe_sigid_abi.h
 create mode 100644 drivers/gpu/drm/xe/tests/xe_any_kunit.c
 create mode 100644 drivers/gpu/drm/xe/tests/xe_log_kunit.c
 create mode 100644 drivers/gpu/drm/xe/xe_any.h
 create mode 100644 drivers/gpu/drm/xe/xe_log.c
 create mode 100644 drivers/gpu/drm/xe/xe_log.h
Signature · 1 line
2.47.1
#1 lore raw

PATCH v4 1/32 drm/xe: Introduce xe_any helpers

In upcoming patches we want to define macros that will work with either xe_device or xe_tile or xe_gt pointers. To make them work and to allow compiler optimizations, introduce set of helpers that will return either expected pointer type or NULL or make necessary conversions to/from the struct xe/device/pci_dev.

---
v2: add include (Sashiko) and const support (Mallesh)
reuse existing to_xe() helpers (Michal)
v3: fix another typo and fix to_pdev (Sashiko)
use assoc macros/helpers (Jani)
add support for drm_device (Michal)

---
 drivers/gpu/drm/xe/xe_any.h | 137 ++++++++++++++++++++++++++++++++++++
 1 file changed, 137 insertions(+)
 create mode 100644 drivers/gpu/drm/xe/xe_any.h
drivers/gpu/drm/xe/xe_any.h new file +137 -0
new file mode 100644
index 000000000000..5d97afa76915
@@ -0,0 +1,137 @@
+/* SPDX-License-Identifier: MIT */
+/*
+ * Copyright © 2026 Intel Corporation
+ */
+
+#ifndef _XE_ANY_H_
+#define _XE_ANY_H_
+
+#include "xe_device.h"
+
+#define __xe_any_to_self_assoc(type, any) \
+	const type * : (any), \
+	type * : (any)
+
+/**
+ * xe_any_if_type() - Get the pointer only if it is @type pointer.
+ * @any: any pointer
+ * @type: data type to look for
+ *
+ * Return: the @type pointer or NULL.
+ */
+#define xe_any_if_type(any, type)						\
+	_Generic((any),								\
+		 __xe_any_to_self_assoc(type, (any)),				\
+		 default : NULL)
+
+/**
+ * xe_any_if_gt() - Get the pointer only if it is &xe_gt.
+ * @any: any pointer
+ *
+ * Return: the @xe_gt pointer or NULL.
+ */
+#define xe_any_if_gt(any)	xe_any_if_type((any), struct xe_gt)
+
+/**
+ * xe_any_if_tile() - Get the pointer only if it is &xe_tile.
+ * @any: any pointer
+ *
+ * Return: the @xe_tile pointer or NULL.
+ */
+#define xe_any_if_tile(any)	xe_any_if_type((any), struct xe_tile)
+
+/**
+ * xe_any_if_xe() - Get the pointer only if it is &xe_device.
+ * @any: any pointer
+ *
+ * Return: the @xe_device pointer or NULL.
+ */
+#define xe_any_if_xe(any)	xe_any_if_type((any), struct xe_device)
+
+/**
+ * xe_any_if_pdev() - Get the pointer only if it is &pci_dev.
+ * @any: any pointer
+ *
+ * Return: the @pci_dev pointer or NULL.
+ */
+#define xe_any_if_pdev(any)	xe_any_if_type((any), struct pci_dev)
+
+#define __xe_any_to_other_assoc(const, from, other, p) \
+	const struct from * : __##from##_to_##other((const struct from *)(p))
+
+#define __xe_tile_to_xe_device(p)	tile_to_xe(p)
+#define __xe_gt_to_xe_device(p)		gt_to_xe(p)
+#define __pci_dev_to_xe_device(p)	pdev_to_xe_device(p)
+#define __device_to_xe_device(p)	kdev_to_xe_device(p)
+#define __drm_device_to_xe_device(p)	to_xe_device(p)
+#define __pci_dev_to_device(p)		(&(p)->dev)
+
+/**
+ * xe_any_to_xe() - Obtain the &xe_device pointer.
+ * @any: the &pci_dev or the &xe_device or &xe_tile or &xe_gt pointer
+ *
+ * Return: the @xe_device pointer or backpointer.
+ */
+#define xe_any_to_xe(any)							\
+	_Generic((any),								\
+		 __xe_any_to_self_assoc(struct xe_device, (any)),		\
+		 __xe_any_to_other_assoc(/* */, xe_tile, xe_device, (any)),	\
+		 __xe_any_to_other_assoc(const, xe_tile, xe_device, (any)),	\
+		 __xe_any_to_other_assoc(/* */, xe_gt, xe_device, (any)),	\
+		 __xe_any_to_other_assoc(const, xe_gt, xe_device, (any)),	\
+		 __xe_any_to_other_assoc(, drm_device, xe_device, (any)),	\
+		 __xe_any_to_other_assoc(, pci_dev, xe_device, (any)),		\
+		 __xe_any_to_other_assoc(, device, xe_device, (any)))
+
+/**
+ * xe_any_to_drm() - Obtain the &drm_device pointer.
+ * @any: the &pci_dev or the &xe_device or &xe_tile or &xe_gt pointer
+ *
+ * Return: the @drm_device pointer or backpointer.
+ */
+#define xe_any_to_drm(any)							\
+	_Generic((any),								\
+		 __xe_any_to_self_assoc(struct drm_device, (any)),		\
+		 default : &xe_any_to_xe(any)->drm)
+
+/**
+ * xe_any_to_dev() - Obtain the &device pointer.
+ * @any: the &pci_dev or the &xe_device or &xe_tile or &xe_gt pointer
+ *
+ * Return: the @device pointer or backpointer.
+ */
+#define xe_any_to_dev(any)							\
+	_Generic((any),								\
+		 __xe_any_to_self_assoc(struct device, (any)),			\
+		 __xe_any_to_other_assoc(, pci_dev, device, (any)),		\
+		 default : xe_any_to_drm(any)->dev)
+
+/**
+ * xe_any_to_pdev() - Obtain the &pci_dev pointer.
+ * @any: the &pci_dev or the &xe_device or &xe_tile or &xe_gt pointer
+ *
+ * Return: the @pci_dev pointer or backpointer.
+ */
+#define xe_any_to_pdev(any)							\
+	_Generic((any),								\
+		 __xe_any_to_self_assoc(struct pci_dev, (any)),			\
+		 default : to_pci_dev(xe_any_to_dev(any)))
+
+#define __xe_tile_to_id(p)		((p)->id)
+#define __xe_gt_to_id(p)		((p)->info.id)
+
+/**
+ * xe_any_id() - Get the identifier of the underlying object.
+ * @any: the &pci_dev or the &xe_device or &xe_tile or &xe_gt pointer
+ *
+ * Return: the identifier of the object, or 0 if not applicable/available.
+ */
+#define xe_any_id(any)								\
+	_Generic((any),								\
+		 __xe_any_to_other_assoc(/* */, xe_tile, id, (any)),		\
+		 __xe_any_to_other_assoc(const, xe_tile, id, (any)),		\
+		 __xe_any_to_other_assoc(/* */, xe_gt, id, (any)),		\
+		 __xe_any_to_other_assoc(const, xe_gt, id, (any)),		\
+		 default : 0)
+
+#endif
Signature · 1 line
2.47.1
#2 lore raw

Re: [PATCH v4 01/32] drm/xe: Introduce xe_any helpers

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider: - [Low] Macros xe_any_to_drm, xe_any_to_dev, and xe_any_to_pdev fail to compile when passed const pointers…

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Low] Macros xe_any_to_drm, xe_any_to_dev, and xe_any_to_pdev fail to compile when passed const pointers due to a C11 constraint violation in the underlying xe_any_to_xe macro.
- [Low] The macros xe_any_if_type and xe_any_id silently discard side effects for unmatched types.
--

--- Patch [1]: [PATCH v4 01/32] drm/xe: Introduce xe_any helpers --- commit 933eba9892b749844655f0d89de25fa2cfc22f5b
Author: Michal Wajdeczko <[email protected]>
Subject: drm/xe: Introduce xe_any helpers

This commit introduces a set of macros using _Generic to convert between xe_device, xe_tile, xe_gt, drm_device, pci_dev, and device pointers. It provides type-checking helpers and object identifier retrievals across the xe driver.

Quoted 5 lines
drivers/gpu/drm/xe/xe_any.h new file +0 -0
new file mode 100644
index 0000000000000..5d97afa76915a

[ ... ]

drivers/gpu/drm/xe/xe_any.h line 25

Quoted 11 lines
drivers/gpu/drm/xe/xe_any.h new file +11 -0
+/**
+ * xe_any_if_type() - Get the pointer only if it is @type pointer.
+ * @any: any pointer
+ * @type: data type to look for
+ *
+ * Return: the @type pointer or NULL.
+ */
+#define xe_any_if_type(any, type)						\
+	_Generic((any),								\
+		 __xe_any_to_self_assoc(type, (any)),				\
+		 default : NULL)

[Severity: Low]
Could this macro discard side effects for unmatched types?

If a caller passes an expression with side effects, like a function call or pointer increment, to xe_any_if_type() or any macro that uses it, the side effects will be evaluated if the type matches.

However, if the type falls to the default branch, the side effects will be completely discarded because (any) is not evaluated in the default : NULL association.

[ ... ]

Quoted 17 lines
drivers/gpu/drm/xe/xe_any.h new file +17 -0
+/**
+ * xe_any_to_xe() - Obtain the &xe_device pointer.
+ * @any: the &pci_dev or the &xe_device or &xe_tile or &xe_gt pointer
+ *
+ * Return: the @xe_device pointer or backpointer.
+ */
+#define xe_any_to_xe(any)							\
+	_Generic((any),								\
+		 __xe_any_to_self_assoc(struct xe_device, (any)),		\
+		 __xe_any_to_other_assoc(/* */, xe_tile, xe_device, (any)),	\
+		 __xe_any_to_other_assoc(const, xe_tile, xe_device, (any)),	\
+		 __xe_any_to_other_assoc(/* */, xe_gt, xe_device, (any)),	\
+		 __xe_any_to_other_assoc(const, xe_gt, xe_device, (any)),	\
+		 __xe_any_to_other_assoc(, drm_device, xe_device, (any)),	\
+		 __xe_any_to_other_assoc(, pci_dev, xe_device, (any)),		\
+		 __xe_any_to_other_assoc(, device, xe_device, (any)))
+

drivers/gpu/drm/xe/xe_any.h line 95

Quoted 10 lines
drivers/gpu/drm/xe/xe_any.h new file +10 -0
+/**
+ * xe_any_to_drm() - Obtain the &drm_device pointer.
+ * @any: the &pci_dev or the &xe_device or &xe_tile or &xe_gt pointer
+ *
+ * Return: the @drm_device pointer or backpointer.
+ */
+#define xe_any_to_drm(any)							\
+	_Generic((any),								\
+		 __xe_any_to_self_assoc(struct drm_device, (any)),		\
+		 default : &xe_any_to_xe(any)->drm)

[Severity: Low]
Will this cause a C11 constraint violation during compilation if the parameter is a const struct drm_device pointer?

When xe_any_to_drm is called with a const struct drm_device pointer, it falls to the default branch which contains xe_any_to_xe(any).

The xe_any_to_xe macro lacks const associations for drm_device, pci_dev, and device, and it does not have a default branch. This will cause compilation to fail even though it is inside an unselected branch of the outer _Generic block.

[ ... ]

drivers/gpu/drm/xe/xe_any.h line 135

Quoted 13 lines
drivers/gpu/drm/xe/xe_any.h new file +13 -0
+/**
+ * xe_any_id() - Get the identifier of the underlying object.
+ * @any: the &pci_dev or the &xe_device or &xe_tile or &xe_gt pointer
+ *
+ * Return: the identifier of the object, or 0 if not applicable/available.
+ */
+#define xe_any_id(any)								\
+	_Generic((any),								\
+		 __xe_any_to_other_assoc(/* */, xe_tile, id, (any)),		\
+		 __xe_any_to_other_assoc(const, xe_tile, id, (any)),		\
+		 __xe_any_to_other_assoc(/* */, xe_gt, id, (any)),		\
+		 __xe_any_to_other_assoc(const, xe_gt, id, (any)),		\
+		 default : 0)

[Severity: Low]
Does this macro also discard side effects for unmatched types, similar to xe_any_if_type?

If (any) is an expression with side effects, they are evaluated if the type matches, but are lost in the default : 0 branch because (any) is omitted.

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
maintainer Reviewed-by on v4 1/32
#3 lore raw

Re: [PATCH v4 01/32] drm/xe: Introduce xe_any helpers

In reply to Michal Wajdeczko
Quoted 11 lines · Michal Wajdeczko

In upcoming patches we want to define macros that will work with either xe_device or xe_tile or xe_gt pointers. To make them work and to allow compiler optimizations, introduce set of helpers that will return either expected pointer type or NULL or make necessary conversions to/from the struct xe/device/pci_dev.

Cc Rodrigo Vivi <[email protected]>
Cc Thomas Hellström <[email protected]>
Cc Matthew Brost <[email protected]>
Quoted 159 lines

---
v2: add include (Sashiko) and const support (Mallesh)
reuse existing to_xe() helpers (Michal)
v3: fix another typo and fix to_pdev (Sashiko)
use assoc macros/helpers (Jani)
add support for drm_device (Michal)

---
 drivers/gpu/drm/xe/xe_any.h | 137 ++++++++++++++++++++++++++++++++++++
 1 file changed, 137 insertions(+)
 create mode 100644 drivers/gpu/drm/xe/xe_any.h
drivers/gpu/drm/xe/xe_any.h new file +137 -0
new file mode 100644
index 000000000000..5d97afa76915
@@ -0,0 +1,137 @@
+/* SPDX-License-Identifier: MIT */
+/*
+ * Copyright © 2026 Intel Corporation
+ */
+
+#ifndef _XE_ANY_H_
+#define _XE_ANY_H_
+
+#include "xe_device.h"
+
+#define __xe_any_to_self_assoc(type, any) \
+	const type * : (any), \
+	type * : (any)
+
+/**
+ * xe_any_if_type() - Get the pointer only if it is @type pointer.
+ * @any: any pointer
+ * @type: data type to look for
+ *
+ * Return: the @type pointer or NULL.
+ */
+#define xe_any_if_type(any, type)						\
+	_Generic((any),								\
+		 __xe_any_to_self_assoc(type, (any)),				\
+		 default : NULL)
+
+/**
+ * xe_any_if_gt() - Get the pointer only if it is &xe_gt.
+ * @any: any pointer
+ *
+ * Return: the @xe_gt pointer or NULL.
+ */
+#define xe_any_if_gt(any)	xe_any_if_type((any), struct xe_gt)
+
+/**
+ * xe_any_if_tile() - Get the pointer only if it is &xe_tile.
+ * @any: any pointer
+ *
+ * Return: the @xe_tile pointer or NULL.
+ */
+#define xe_any_if_tile(any)	xe_any_if_type((any), struct xe_tile)
+
+/**
+ * xe_any_if_xe() - Get the pointer only if it is &xe_device.
+ * @any: any pointer
+ *
+ * Return: the @xe_device pointer or NULL.
+ */
+#define xe_any_if_xe(any)	xe_any_if_type((any), struct xe_device)
+
+/**
+ * xe_any_if_pdev() - Get the pointer only if it is &pci_dev.
+ * @any: any pointer
+ *
+ * Return: the @pci_dev pointer or NULL.
+ */
+#define xe_any_if_pdev(any)	xe_any_if_type((any), struct pci_dev)
+
+#define __xe_any_to_other_assoc(const, from, other, p) \
+	const struct from * : __##from##_to_##other((const struct from *)(p))
+
+#define __xe_tile_to_xe_device(p)	tile_to_xe(p)
+#define __xe_gt_to_xe_device(p)		gt_to_xe(p)
+#define __pci_dev_to_xe_device(p)	pdev_to_xe_device(p)
+#define __device_to_xe_device(p)	kdev_to_xe_device(p)
+#define __drm_device_to_xe_device(p)	to_xe_device(p)
+#define __pci_dev_to_device(p)		(&(p)->dev)
+
+/**
+ * xe_any_to_xe() - Obtain the &xe_device pointer.
+ * @any: the &pci_dev or the &xe_device or &xe_tile or &xe_gt pointer
+ *
+ * Return: the @xe_device pointer or backpointer.
+ */
+#define xe_any_to_xe(any)							\
+	_Generic((any),								\
+		 __xe_any_to_self_assoc(struct xe_device, (any)),		\
+		 __xe_any_to_other_assoc(/* */, xe_tile, xe_device, (any)),	\
+		 __xe_any_to_other_assoc(const, xe_tile, xe_device, (any)),	\
+		 __xe_any_to_other_assoc(/* */, xe_gt, xe_device, (any)),	\
+		 __xe_any_to_other_assoc(const, xe_gt, xe_device, (any)),	\
+		 __xe_any_to_other_assoc(, drm_device, xe_device, (any)),	\
+		 __xe_any_to_other_assoc(, pci_dev, xe_device, (any)),		\
+		 __xe_any_to_other_assoc(, device, xe_device, (any)))
+
+/**
+ * xe_any_to_drm() - Obtain the &drm_device pointer.
+ * @any: the &pci_dev or the &xe_device or &xe_tile or &xe_gt pointer
+ *
+ * Return: the @drm_device pointer or backpointer.
+ */
+#define xe_any_to_drm(any)							\
+	_Generic((any),								\
+		 __xe_any_to_self_assoc(struct drm_device, (any)),		\
+		 default : &xe_any_to_xe(any)->drm)
+
+/**
+ * xe_any_to_dev() - Obtain the &device pointer.
+ * @any: the &pci_dev or the &xe_device or &xe_tile or &xe_gt pointer
+ *
+ * Return: the @device pointer or backpointer.
+ */
+#define xe_any_to_dev(any)							\
+	_Generic((any),								\
+		 __xe_any_to_self_assoc(struct device, (any)),			\
+		 __xe_any_to_other_assoc(, pci_dev, device, (any)),		\
+		 default : xe_any_to_drm(any)->dev)
+
+/**
+ * xe_any_to_pdev() - Obtain the &pci_dev pointer.
+ * @any: the &pci_dev or the &xe_device or &xe_tile or &xe_gt pointer
+ *
+ * Return: the @pci_dev pointer or backpointer.
+ */
+#define xe_any_to_pdev(any)							\
+	_Generic((any),								\
+		 __xe_any_to_self_assoc(struct pci_dev, (any)),			\
+		 default : to_pci_dev(xe_any_to_dev(any)))
+
+#define __xe_tile_to_id(p)		((p)->id)
+#define __xe_gt_to_id(p)		((p)->info.id)
+
+/**
+ * xe_any_id() - Get the identifier of the underlying object.
+ * @any: the &pci_dev or the &xe_device or &xe_tile or &xe_gt pointer
+ *
+ * Return: the identifier of the object, or 0 if not applicable/available.
+ */
+#define xe_any_id(any)								\
+	_Generic((any),								\
+		 __xe_any_to_other_assoc(/* */, xe_tile, id, (any)),		\
+		 __xe_any_to_other_assoc(const, xe_tile, id, (any)),		\
+		 __xe_any_to_other_assoc(/* */, xe_gt, id, (any)),		\
+		 __xe_any_to_other_assoc(const, xe_gt, id, (any)),		\
+		 default : 0)
+
+#endif
Signature · 1 line
2.47.1
Reviewed-by on v4 1/32
#4 lore raw

Re: [PATCH v4 01/32] drm/xe: Introduce xe_any helpers

In reply to Michal Wajdeczko
Quoted 6 lines · Michal Wajdeczko

In upcoming patches we want to define macros that will work with either xe_device or xe_tile or xe_gt pointers. To make them work and to allow compiler optimizations, introduce set of helpers that will return either expected pointer type or NULL or make necessary conversions to/from the struct xe/device/pci_dev.

Quoted 6 lines
Quoted 155 lines
Cc Jani Nikula <[email protected]>

---
v2: add include (Sashiko) and const support (Mallesh)
reuse existing to_xe() helpers (Michal)
v3: fix another typo and fix to_pdev (Sashiko)
use assoc macros/helpers (Jani)
add support for drm_device (Michal)

---
  drivers/gpu/drm/xe/xe_any.h | 137 ++++++++++++++++++++++++++++++++++++
  1 file changed, 137 insertions(+)

create mode 100644 drivers/gpu/drm/xe/xe_any.h

drivers/gpu/drm/xe/xe_any.h new file +137 -0
new file mode 100644
index 000000000000..5d97afa76915
@@ -0,0 +1,137 @@
+/* SPDX-License-Identifier: MIT */
+/*
+ * Copyright © 2026 Intel Corporation
+ */
+
+#ifndef _XE_ANY_H_
+#define _XE_ANY_H_
+
+#include "xe_device.h"
+
+#define __xe_any_to_self_assoc(type, any) \
+	const type * : (any), \
+	type * : (any)
+
+/**
+ * xe_any_if_type() - Get the pointer only if it is @type pointer.
+ * @any: any pointer
+ * @type: data type to look for
+ *
+ * Return: the @type pointer or NULL.
+ */
+#define xe_any_if_type(any, type)						\
+	_Generic((any),								\
+		 __xe_any_to_self_assoc(type, (any)),				\
+		 default : NULL)
+
+/**
+ * xe_any_if_gt() - Get the pointer only if it is &xe_gt.
+ * @any: any pointer
+ *
+ * Return: the @xe_gt pointer or NULL.
+ */
+#define xe_any_if_gt(any)	xe_any_if_type((any), struct xe_gt)
+
+/**
+ * xe_any_if_tile() - Get the pointer only if it is &xe_tile.
+ * @any: any pointer
+ *
+ * Return: the @xe_tile pointer or NULL.
+ */
+#define xe_any_if_tile(any)	xe_any_if_type((any), struct xe_tile)
+
+/**
+ * xe_any_if_xe() - Get the pointer only if it is &xe_device.
+ * @any: any pointer
+ *
+ * Return: the @xe_device pointer or NULL.
+ */
+#define xe_any_if_xe(any)	xe_any_if_type((any), struct xe_device)
+
+/**
+ * xe_any_if_pdev() - Get the pointer only if it is &pci_dev.
+ * @any: any pointer
+ *
+ * Return: the @pci_dev pointer or NULL.
+ */
+#define xe_any_if_pdev(any)	xe_any_if_type((any), struct pci_dev)
+
+#define __xe_any_to_other_assoc(const, from, other, p) \
+	const struct from * : __##from##_to_##other((const struct from *)(p))
+
+#define __xe_tile_to_xe_device(p)	tile_to_xe(p)
+#define __xe_gt_to_xe_device(p)		gt_to_xe(p)
+#define __pci_dev_to_xe_device(p)	pdev_to_xe_device(p)
+#define __device_to_xe_device(p)	kdev_to_xe_device(p)
+#define __drm_device_to_xe_device(p)	to_xe_device(p)
+#define __pci_dev_to_device(p)		(&(p)->dev)
+
+/**
+ * xe_any_to_xe() - Obtain the &xe_device pointer.
+ * @any: the &pci_dev or the &xe_device or &xe_tile or &xe_gt pointer
+ *
+ * Return: the @xe_device pointer or backpointer.
+ */
+#define xe_any_to_xe(any)							\
+	_Generic((any),								\
+		 __xe_any_to_self_assoc(struct xe_device, (any)),		\
+		 __xe_any_to_other_assoc(/* */, xe_tile, xe_device, (any)),	\
+		 __xe_any_to_other_assoc(const, xe_tile, xe_device, (any)),	\
+		 __xe_any_to_other_assoc(/* */, xe_gt, xe_device, (any)),	\
+		 __xe_any_to_other_assoc(const, xe_gt, xe_device, (any)),	\
+		 __xe_any_to_other_assoc(, drm_device, xe_device, (any)),	\
+		 __xe_any_to_other_assoc(, pci_dev, xe_device, (any)),		\
+		 __xe_any_to_other_assoc(, device, xe_device, (any)))
+
+/**
+ * xe_any_to_drm() - Obtain the &drm_device pointer.
+ * @any: the &pci_dev or the &xe_device or &xe_tile or &xe_gt pointer
+ *
+ * Return: the @drm_device pointer or backpointer.
+ */
+#define xe_any_to_drm(any)							\
+	_Generic((any),								\
+		 __xe_any_to_self_assoc(struct drm_device, (any)),		\
+		 default : &xe_any_to_xe(any)->drm)
+
+/**
+ * xe_any_to_dev() - Obtain the &device pointer.
+ * @any: the &pci_dev or the &xe_device or &xe_tile or &xe_gt pointer
+ *
+ * Return: the @device pointer or backpointer.
+ */
+#define xe_any_to_dev(any)							\
+	_Generic((any),								\
+		 __xe_any_to_self_assoc(struct device, (any)),			\
+		 __xe_any_to_other_assoc(, pci_dev, device, (any)),		\
+		 default : xe_any_to_drm(any)->dev)
+
+/**
+ * xe_any_to_pdev() - Obtain the &pci_dev pointer.
+ * @any: the &pci_dev or the &xe_device or &xe_tile or &xe_gt pointer
+ *
+ * Return: the @pci_dev pointer or backpointer.
+ */
+#define xe_any_to_pdev(any)							\
+	_Generic((any),								\
+		 __xe_any_to_self_assoc(struct pci_dev, (any)),			\
+		 default : to_pci_dev(xe_any_to_dev(any)))
+
+#define __xe_tile_to_id(p)		((p)->id)
+#define __xe_gt_to_id(p)		((p)->info.id)
+
+/**
+ * xe_any_id() - Get the identifier of the underlying object.
+ * @any: the &pci_dev or the &xe_device or &xe_tile or &xe_gt pointer
+ *
+ * Return: the identifier of the object, or 0 if not applicable/available.
+ */
+#define xe_any_id(any)								\
+	_Generic((any),								\
+		 __xe_any_to_other_assoc(/* */, xe_tile, id, (any)),		\
+		 __xe_any_to_other_assoc(const, xe_tile, id, (any)),		\
+		 __xe_any_to_other_assoc(/* */, xe_gt, id, (any)),		\
+		 __xe_any_to_other_assoc(const, xe_gt, id, (any)),		\
+		 default : 0)
+
+#endif
#5 lore raw

PATCH v4 2/32 drm/xe/log: Add structured SIGID error logging infrastructure

In reply to Michal Wajdeczko

From: Mallesh Koujalagi <[email protected]>

Today the driver reports faults with ad-hoc drm_err()/xe_gt_err() strings that have no stable shape. That is readable for a human, but it gives fleet tooling nothing durable to match on: the wording changes between releases, lines can be rate-limited or dropped under an error storm, and there is no consistent way to ask "which recognised fault just happened?".

Introduce a signature identifier (SIGID): a small, stable integer that names one recognised Xe fault site and serves as the primary handle for triage. A SIGID maps, through published end-user documentation, to a description and a recommended action; the driver only has to emit the right SIGID next to the usual human-readable text.

Assisted-by Copilot:Opus-4.8
Cc Riana Tauro <[email protected]>
Cc Stuart Summers <[email protected]>

---
Cc: Yoni Levitt <[email protected]>
Cc: Aravind Iddamsetty <[email protected]>
Cc: Raag Jadav <[email protected]>
---
v2: CORRECTED is still an error (Michal)
prepare to decorate dmesg with comp/loc (Michal)
v3: update SIGID DOC section (Riana/Aravind)
warn about unknown severity (Mallesh)

---
 Documentation/gpu/xe/index.rst        |   1 +
 Documentation/gpu/xe/xe_sigid.rst     |  14 +++
 drivers/gpu/drm/xe/Makefile           |   1 +
 drivers/gpu/drm/xe/abi/xe_sigid_abi.h | 159 ++++++++++++++++++++++++++
 drivers/gpu/drm/xe/xe_log.c           | 138 ++++++++++++++++++++++
 drivers/gpu/drm/xe/xe_log.h           |  20 ++++
 6 files changed, 333 insertions(+)
 create mode 100644 Documentation/gpu/xe/xe_sigid.rst
 create mode 100644 drivers/gpu/drm/xe/abi/xe_sigid_abi.h
 create mode 100644 drivers/gpu/drm/xe/xe_log.c
 create mode 100644 drivers/gpu/drm/xe/xe_log.h
Documentation/gpu/xe/index.rst +1 -0
index 665c0e93601c..0247a255f7e6 100644
@@ -35,3 +35,4 @@ The display, or :ref:`drm-kms`, support for drm/xe is provided by
    xe-drm-usage-stats.rst
    xe_configfs
    xe_gt_stats
+   xe_sigid
Documentation/gpu/xe/xe_sigid.rst new file +14 -0
new file mode 100644
index 000000000000..45d84a62f185
@@ -0,0 +1,14 @@
+.. SPDX-License-Identifier: (GPL-2.0+ OR MIT)
+
+========
+Xe SIGID
+========
+
+.. kernel-doc:: drivers/gpu/drm/xe/abi/xe_sigid_abi.h
+   :doc: Xe Error Signatures (SIGID)
+
+Signature Identifiers
+=====================
+
+.. kernel-doc:: drivers/gpu/drm/xe/abi/xe_sigid_abi.h
+   :internal:
drivers/gpu/drm/xe/Makefile +1 -0
index 44ed055439d4..92134709d998 100644
@@ -87,6 +87,7 @@ xe-y += xe_bb.o \
 	xe_hw_fence.o \
 	xe_irq.o \
 	xe_late_bind_fw.o \
+	xe_log.o \
 	xe_lrc.o \
 	xe_mem_pool.o \
 	xe_migrate.o \
drivers/gpu/drm/xe/abi/xe_sigid_abi.h new file +159 -0

159 lines not on this page · raw message

drivers/gpu/drm/xe/xe_log.c new file +138 -0

138 lines not on this page · raw message

drivers/gpu/drm/xe/xe_log.h new file +20 -0
new file mode 100644
index 000000000000..d475e816ee0b
@@ -0,0 +1,20 @@
+/* SPDX-License-Identifier: MIT */
+/*
+ * Copyright © 2026 Intel Corporation
+ */
+
+#ifndef _XE_LOG_H_
+#define _XE_LOG_H_
+
+#include <linux/cper.h>
+
+#include "abi/xe_sigid_abi.h"
+
+struct pci_dev;
+
+__printf(8, 9)
+void xe_log_emit(struct pci_dev *pdev, int cper_sev, enum xe_sigid sigid,
+		 u32 component, u32 location, const void *data, size_t len,
+		 const char *fmt, ...);
+
+#endif
Signature · 1 line
2.47.1
#6 lore raw

Re: [PATCH v4 02/32] drm/xe/log: Add structured SIGID error logging infrastructure

Quoted 267 lines · Michal Wajdeczko

From: Mallesh Koujalagi<[email protected]>

Today the driver reports faults with ad-hoc drm_err()/xe_gt_err() strings that have no stable shape. That is readable for a human, but it gives fleet tooling nothing durable to match on: the wording changes between releases, lines can be rate-limited or dropped under an error storm, and there is no consistent way to ask "which recognised fault just happened?".

Introduce a signature identifier (SIGID): a small, stable integer that names one recognised Xe fault site and serves as the primary handle for triage. A SIGID maps, through published end-user documentation, to a description and a recommended action; the driver only has to emit the right SIGID next to the usual human-readable text.

Assisted-by Copilot:Opus-4.8
Cc Riana Tauro<[email protected]>
Cc Stuart Summers<[email protected]>

---
Cc: Yoni Levitt<[email protected]>
Cc: Aravind Iddamsetty<[email protected]>
Cc: Raag Jadav<[email protected]>
---
v2: CORRECTED is still an error (Michal)
prepare to decorate dmesg with comp/loc (Michal)
v3: update SIGID DOC section (Riana/Aravind)
warn about unknown severity (Mallesh)

---
  Documentation/gpu/xe/index.rst        |   1 +
  Documentation/gpu/xe/xe_sigid.rst     |  14 +++
  drivers/gpu/drm/xe/Makefile           |   1 +
  drivers/gpu/drm/xe/abi/xe_sigid_abi.h | 159 ++++++++++++++++++++++++++
  drivers/gpu/drm/xe/xe_log.c           | 138 ++++++++++++++++++++++
  drivers/gpu/drm/xe/xe_log.h           |  20 ++++
  6 files changed, 333 insertions(+)

create mode 100644 Documentation/gpu/xe/xe_sigid.rst create mode 100644 drivers/gpu/drm/xe/abi/xe_sigid_abi.h create mode 100644 drivers/gpu/drm/xe/xe_log.c create mode 100644 drivers/gpu/drm/xe/xe_log.h

Documentation/gpu/xe/index.rst +1 -0
index 665c0e93601c..0247a255f7e6 100644
@@ -35,3 +35,4 @@ The display, or :ref:`drm-kms`, support for drm/xe is provided by
     xe-drm-usage-stats.rst
     xe_configfs
     xe_gt_stats
+   xe_sigid
Documentation/gpu/xe/xe_sigid.rst new file +14 -0
new file mode 100644
index 000000000000..45d84a62f185
@@ -0,0 +1,14 @@
+.. SPDX-License-Identifier: (GPL-2.0+ OR MIT)
+
+========
+Xe SIGID
+========
+
+.. kernel-doc:: drivers/gpu/drm/xe/abi/xe_sigid_abi.h
+   :doc: Xe Error Signatures (SIGID)
+
+Signature Identifiers
+=====================
+
+.. kernel-doc:: drivers/gpu/drm/xe/abi/xe_sigid_abi.h
+   :internal:
drivers/gpu/drm/xe/Makefile +1 -0
index 44ed055439d4..92134709d998 100644
@@ -87,6 +87,7 @@ xe-y += xe_bb.o \
  	xe_hw_fence.o \
  	xe_irq.o \
  	xe_late_bind_fw.o \
+	xe_log.o \
  	xe_lrc.o \
  	xe_mem_pool.o \
  	xe_migrate.o \
drivers/gpu/drm/xe/abi/xe_sigid_abi.h new file +81 -0
new file mode 100644
index 000000000000..93967183ae51
@@ -0,0 +1,159 @@
+/* SPDX-License-Identifier: MIT */
+/*
+ * Copyright © 2026 Intel Corporation
+ */
+
+#ifndef _ABI_XE_SIGID_ABI_H_
+#define _ABI_XE_SIGID_ABI_H_
+
+/**
+ * DOC: Xe Error Signatures (SIGID)
+ *
+ * What SIGID stands for
+ * ---------------------
+ *
+ * SIGID is short for *Signature Identifier*. It is a small, stable integer
+ * that names one of *recognised fault site* -- nothing more. It is the
+ * primary handle used for triage and maps directly to specific report site.
+ *
+ * Numbering
+ * ---------
+ *
+ * SIGIDs are a single flat list numbered sequentially within the assigned range,
+ * in the order the fault sites were introduced. Values are stable: once assigned
+ * they are only ever appended, never renumbered or reused. A retired fault site
+ * SIGID value is deprecated in place, never re-purposed.
+ *
+ * Why this exists
+ * ---------------
+ *
+ * Today the driver reports faults with ad-hoc ``xe_err()`` / ``xe_gt_err()``
+ * strings that have no stable shape. That is fine for a human reading dmesg,
+ * but it gives fleet tooling nothing durable to match on: the wording changes
+ * between releases, lines can be rate-limited or dropped under an error storm,
+ * and there is no consistent way to ask "which recognised fault just happened?"
+ *
+ * A SIGID answers exactly that one question, identically across driver and
+ * firmware versions, and (eventually) across other Intel devices in a node.
+ *
+ * What a SIGID is not
+ * -------------------
+ *
+ * SIGID deliberately does not encode the detailed reason or the outcome. Those
+ * are carried alongside it::
+ *
+ *   SIGID    -> which recognised fault site is being reported
+ *   severity -> how serious this instance is
+ *   errno    -> the failing operation's error, if available, shown with %pe
+ *   message  -> free-form human-readable context
+ *
+ * Severity is independent of the SIGID. The same SIGID can be reported at
+ * different severities depending on the instance and the recovery taken.
+ *
+ * When to use SIGID logging
+ * -------------------------
+ *
+ * The xe_log_*() helpers are for these recognised fault sites only --
+ * important, operator-relevant faults and events. The driver's only job is to
+ * emit the right SIGID next to the usual human-readable text.
+
+ * They are not a replacement for ``xe_info()`` / ``xe_dbg()`` / tracing, nor
+ * for one-off diagnostics; using them for ordinary logging would dilute the
+ * fault stream. Not every ``xe_err()`` needs to become a SIGID report -- only
+ * those that correspond to a published fault sites.
+ *
+ * SIGID log output (dmesg vs. the machine record)
+ * -----------------------------------------------
+ *
+ * The dmesg line stays close to a normal xe error message so it remains
+ * readable for admins; the only stable, machine-matchable token on it is
+ * ``SIGID=<n>`` (``dmesg | grep SIGID=``).
+ *
+ * The full dmesg line is not an ABI: the surrounding text may change freely,
+ * and lines may be dropped. The durable record for tooling is the CPER record
+ * carrying the same SIGID (generation is a planned follow-up).
+ *
+ * How to pick a SIGID (the uniqueness rule)
+ * -----------------------------------------
+ *
+ * Pick per *report site*, not per incident. Each site emits the single most
+ * specific recognised SIGID *for that site* -- so the question is never
+ * "classify this whole failure", it is "what does this site detect?", which has + * one answer. A single underlying failure therefore 

legitimately produces a + * *chain* of reports from different layers, each with its own SIGID -- e.g. a + * GuC communication failure is reported as %XE_SIGID_RUNTIME_FW by the firmware + * path, the failed recovery as %XE_SIGID_GT_TDR by the reset path, and an + * aborted bind as %XE_SIGID_PROBE by the probe path. That chain lets triage + * follow a fault from origin to final effect; it is not a duplicate. + *
+ * If a site does not match any defined SIGID, keep using the
ordinary + * ``xe_err()`` / ``xe_gt_err()`` logging rather than forcing a SIGID: a wrong + * or over-broad classification is harder to retire than a missing one. When a + * new report site is genuinely worth triaging, add it to the list below. + * + * Usage of the existing SIGID reports must reevaluated according to this section + * after making significant changes to the site that emits this SIGID. + * + * Scope: software vs hardware emitted signatures + *
---------------------------------------------- + * + * Some SIGID
represents fault sites that the *driver itself* detects and + * reports from the software POV: probe abort, wedged, survivability, driver- + * detected firmware failures, engine TDR, memory faults and IO/bus faults. + * These are the only values the driver assigns on its own. + * + * Signatures that *originate* in firmware or hardware are a different thing: + * they are produced and identified by the firmware or the hardware itself + * (e.g. via their own records or error counters), and the driver merely logs + * them as they are given to us. They are deliberately enumerated separately. + * + * The two driver-detected firmware report sites below (%XE_SIGID_RUNTIME_FW, + * %XE_SIGID_DEVICE_FW) are software signatures: they mark that *the driver* + * observed a firmware problem, not a signature reported by the firmware. + */ + +/* + * Top level Intel Error Signature Identifiers. + */ +#define INTEL_SIGID_INVALID 0 +#define INTEL_SIGID_BATCH 100 +#define INTEL_SIGID_RANGE_START(n) ((n) * INTEL_SIGID_BATCH) +#define INTEL_SIGID_RANGE_END(n) (INTEL_SIGID_RANGE_START((n) + 1) - 1) + +/* SIGIDs 1xx are reserved for Xe GPU software and 2xx for Xe GPU hardware */ +#define INTEL_SIGID_GPU_XE_SOFTWARE_START INTEL_SIGID_RANGE_START(1) +#define INTEL_SIGID_GPU_XE_SOFTWARE_END INTEL_SIGID_RANGE_END(1) +#define INTEL_SIGID_GPU_XE_HARDWARE_START INTEL_SIGID_RANGE_START(2) +#define INTEL_SIGID_GPU_XE_HARDWARE_END INTEL_SIGID_RANGE_END(2) + +/** + * enum xe_sigid - Stable Xe Error Signature Identifiers (SIGID). + * @XE_SIGID_SW: Software component failure. + * @XE_SIGID_PROBE: Device
probe/bind was aborted. + * @XE_SIGID_WEDGED: Device was declared wedged and is no longer usable. + * @XE_SIGID_SURVIVABILITY: Device entered survivability mode. + * @XE_SIGID_RUNTIME_FW: Driver-detected runtime firmware failure, GuC/HuC/GSC. + * @XE_SIGID_DEVICE_FW: Driver-detected device firmware failure, PCODE/sysctrl. + *
@XE_SIGID_GT_TDR: Engine hang / timeout detection and recovery
(reset). + * @XE_SIGID_MEM_FAULT: VM bind, page fault or GTT fault. + * @XE_SIGID_IO_BUS: Runtime PCIe / IOMMU / MMIO access fault. + * + * Each SIGID represents the report sites the driver detects and reports.
+ * Values are numbered sequentially, are only ever appended, and are
never + * renumbered or reused. + * + * Firmware- and hardware-originated signatures are not listed yet here. + */ +enum xe_sigid { + XE_SIGID_SW = INTEL_SIGID_GPU_XE_SOFTWARE_START, + XE_SIGID_PROBE = INTEL_SIGID_GPU_XE_SOFTWARE_START + 1, + XE_SIGID_WEDGED = INTEL_SIGID_GPU_XE_SOFTWARE_START + 2, + XE_SIGID_SURVIVABILITY = INTEL_SIGID_GPU_XE_SOFTWARE_START + 3, + XE_SIGID_RUNTIME_FW = INTEL_SIGID_GPU_XE_SOFTWARE_START + 4, + XE_SIGID_DEVICE_FW = INTEL_SIGID_GPU_XE_SOFTWARE_START + 5, + XE_SIGID_GT_TDR = INTEL_SIGID_GPU_XE_SOFTWARE_START + 6, + XE_SIGID_MEM_FAULT = INTEL_SIGID_GPU_XE_SOFTWARE_START + 7, + XE_SIGID_IO_BUS = INTEL_SIGID_GPU_XE_SOFTWARE_START + 8, +}; + +#endif diff --git a/drivers/gpu/drm/xe/xe_log.c b/drivers/gpu/drm/xe/xe_log.c new file mode 100644 index 000000000000..ae4f6e33f5b8 --- /dev/null
+++ b/drivers/gpu/drm/xe/xe_log.c @@ -0,0 +1,138 @@ +//
SPDX-License-Identifier: MIT +/* + * Copyright © 2026 Intel Corporation + */ + +#include "xe_log.h"

drivers/gpu/drm/xe/abi/xe_sigid_abi.h new file +82 -0
+#include "xe_printk.h"
+
+static void log_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)
+{
+	/* TODO */
+}
+
+static bool is_hw_sigid(enum xe_sigid sigid)
+{
+	return (int)sigid >= INTEL_SIGID_GPU_XE_HARDWARE_START;
+}
+
+static bool is_sev_error(int cper_sev)
+{
+	return cper_sev != CPER_SEV_INFORMATIONAL;
+}
+
+static const char *log_hwe_prefix(int cper_sev, enum xe_sigid sigid)
+{
+	return is_sev_error(cper_sev) && is_hw_sigid(sigid) ? HW_ERR : "";
+}
+
+static const char *log_sev_prefix(int cper_sev)
+{
+	switch (cper_sev) {
+	case CPER_SEV_FATAL:
+		return "FATAL ";
+	case CPER_SEV_RECOVERABLE:
+		return "";
+	case CPER_SEV_CORRECTED:
+		return "CORRECTED ";
+	case CPER_SEV_INFORMATIONAL:
+		return "";
+	default:
+		WARN(IS_ENABLED(CONFIG_DRM_XE_DEBUG), "LOG: unknown severity %d\n", cper_sev);
+		return "";
+	}
+}
+
+#define __LOG_DRM_PRINTK_FMT(fmt, args...)	"[drm] " fmt, ##args
+#define __LOG_DRM_PRINTK_ERR_FMT(fmt, args...)	__LOG_DRM_PRINTK_FMT("*ERROR* " fmt, args)
+
+static void log_dmesg_vprintk(struct pci_dev *pdev, int cper_sev, struct va_format *vaf)
+{
+	if (cper_sev == CPER_SEV_INFORMATIONAL)
+		pci_info(pdev, __LOG_DRM_PRINTK_FMT("%pV", vaf));
+	else
+		pci_err(pdev, __LOG_DRM_PRINTK_ERR_FMT("%pV", vaf));
+}
+
+static void log_dmesg_printf(struct pci_dev *pdev, int cper_sev, const char *fmt, ...)
+{
+	struct va_format vaf;
+	va_list args;
+
+	va_start(args, fmt);
+	vaf.fmt = fmt;
+	vaf.va = &args;
+
+	log_dmesg_vprintk(pdev, cper_sev, &vaf);
+
+	va_end(args);
+}
+
+static void log_emit_dmesg(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)
+{
+	const char *hwe_prefix = log_hwe_prefix(cper_sev, sigid);
+	const char *sev_prefix = log_sev_prefix(cper_sev);
+
+	/* TODO: add component/location details */
+
+	if (IS_ERR(data))
+		log_dmesg_printf(pdev, cper_sev, "SIGID=%u %s(%pe) %s%pV",
+				 sigid, sev_prefix, data, hwe_prefix, vaf);
+	else if (data && len)
+		log_dmesg_printf(pdev, cper_sev, "SIGID=%u %s(%*phN) %s%pV",
+				 sigid, sev_prefix, (int)len, data, hwe_prefix, vaf);
+	else

drivers/gpu/drm/xe/abi/xe_sigid_abi.h

Quoted 10 lines
drivers/gpu/drm/xe/abi/xe_sigid_abi.h new file +10 -0
+		log_dmesg_printf(pdev, cper_sev, "SIGID=%u %s%s%pV",
+				 sigid, sev_prefix, hwe_prefix, vaf);
+}
+
+/**
+ * xe_log_emit() - Emit a structured SIGID log entry
+ * @pdev: the &pci_dev device
+ * @cper_sev: CPER severity (CPER_SEV_FATAL, CPER_SEV_RECOVERABLE, ...)
+ * @sigid: signature identifier, see &enum xe_sigid
+ * @component: component identifer

Typo "identifier"

Quoted 13 lines

+ * @location: location details of the @component
+ * @data: pointer to the additional details, or ERR_PTR, or NULL if not applicable
+ * @len: length of the @data in bytes, or 0 if not applicable
+ * @fmt: printf-style format string
+ * @...: format arguments
+ *
+ * Emits a dmesg line that includes a single stable, machine-matchable token
+ * ``SIGID=<n>`` followed by the optional severity token (like ``FATAL``) and,
+ * when @data pointer is set, either the error printed with %pe or a packed hex
+ * dump of the @data binary blob. The dmesg line will also include printf-style
+ * text message.
+ *
+ * Note that the full dmesg line, with the free text message, is only a debugging

Quoted 8 lines

+ * aid, not an interface! Only the ``SIGID=<n>`` token is stable there.
+ * The durable machine record is the CPER carrying the same SIGID.
+ *
+ * Note: generation of the CPER record is a planned follow-up.
+ *
+ * Examples::
+ *
+ * <3> xe 0000:03:00.0: [drm] *ERROR* SIGID=104 FATAL (-EPROTO) Invalid GuC reply

Missing TAG: in this case GuC/HuC/GSC:

right?

Quoted 1 line

+ * <3> xe 0000:03:00.0: [drm] *ERROR* SIGID=106 (-ETIMEDOUT) Engine 'rcs0' hung

ditto

Quoted 44 lines

+ * <6> xe 0000:03:00.0: [drm] SIGID=103 In survivability mode
+ */

drivers/gpu/drm/xe/abi/xe_sigid_abi.h new file +16 -0
+void xe_log_emit(struct pci_dev *pdev, int cper_sev, enum xe_sigid sigid,
+		 u32 component, u32 location, const void *data, size_t len,
+		 const char *fmt, ...)
+{
+	struct va_format vaf;
+	va_list args;
+
+	va_start(args, fmt);
+	vaf.fmt = fmt;
+	vaf.va = &args;
+
+	log_emit_dmesg(pdev, cper_sev, sigid, component, location, data, len, &vaf);
+	log_emit_cper(pdev, cper_sev, sigid, component, location, data, len, &vaf);
+
+	va_end(args);
+}
drivers/gpu/drm/xe/xe_log.h new file +20 -0
new file mode 100644
index 000000000000..d475e816ee0b
@@ -0,0 +1,20 @@
+/* SPDX-License-Identifier: MIT */
+/*
+ * Copyright © 2026 Intel Corporation
+ */
+
+#ifndef _XE_LOG_H_
+#define _XE_LOG_H_
+
+#include <linux/cper.h>
+
+#include "abi/xe_sigid_abi.h"
+
+struct pci_dev;
+
+__printf(8, 9)
+void xe_log_emit(struct pci_dev *pdev, int cper_sev, enum xe_sigid sigid,
+		 u32 component, u32 location, const void *data, size_t len,
+		 const char *fmt, ...);
+
+#endif
#7 lore raw

Re: [PATCH v4 02/32] drm/xe/log: Add structured SIGID error logging infrastructure

Quoted 293 lines · Koujalagi
Quoted 258 lines · Michal Wajdeczko

From: Mallesh Koujalagi <[email protected]>

Today the driver reports faults with ad-hoc drm_err()/xe_gt_err() strings that have no stable shape. That is readable for a human, but it gives fleet tooling nothing durable to match on: the wording changes between releases, lines can be rate-limited or dropped under an error storm, and there is no consistent way to ask "which recognised fault just happened?".

Introduce a signature identifier (SIGID): a small, stable integer that names one recognised Xe fault site and serves as the primary handle for triage. A SIGID maps, through published end-user documentation, to a description and a recommended action; the driver only has to emit the right SIGID next to the usual human-readable text.

Assisted-by Copilot:Opus-4.8
Cc Riana Tauro <[email protected]>
Cc Stuart Summers <[email protected]>

---
Cc: Yoni Levitt <[email protected]>
Cc: Aravind Iddamsetty <[email protected]>
Cc: Raag Jadav <[email protected]>
---
v2: CORRECTED is still an error (Michal)
prepare to decorate dmesg with comp/loc (Michal)
v3: update SIGID DOC section (Riana/Aravind)
warn about unknown severity (Mallesh)

---
 Documentation/gpu/xe/index.rst        |   1 +
 Documentation/gpu/xe/xe_sigid.rst     |  14 +++
 drivers/gpu/drm/xe/Makefile           |   1 +
 drivers/gpu/drm/xe/abi/xe_sigid_abi.h | 159 ++++++++++++++++++++++++++
 drivers/gpu/drm/xe/xe_log.c           | 138 ++++++++++++++++++++++
 drivers/gpu/drm/xe/xe_log.h           |  20 ++++
 6 files changed, 333 insertions(+)
 create mode 100644 Documentation/gpu/xe/xe_sigid.rst
 create mode 100644 drivers/gpu/drm/xe/abi/xe_sigid_abi.h
 create mode 100644 drivers/gpu/drm/xe/xe_log.c
 create mode 100644 drivers/gpu/drm/xe/xe_log.h
Documentation/gpu/xe/index.rst +1 -0
index 665c0e93601c..0247a255f7e6 100644
@@ -35,3 +35,4 @@ The display, or :ref:`drm-kms`, support for drm/xe is provided by
    xe-drm-usage-stats.rst
    xe_configfs
    xe_gt_stats
+   xe_sigid
Documentation/gpu/xe/xe_sigid.rst new file +14 -0
new file mode 100644
index 000000000000..45d84a62f185
@@ -0,0 +1,14 @@
+.. SPDX-License-Identifier: (GPL-2.0+ OR MIT)
+
+========
+Xe SIGID
+========
+
+.. kernel-doc:: drivers/gpu/drm/xe/abi/xe_sigid_abi.h
+   :doc: Xe Error Signatures (SIGID)
+
+Signature Identifiers
+=====================
+
+.. kernel-doc:: drivers/gpu/drm/xe/abi/xe_sigid_abi.h
+   :internal:
drivers/gpu/drm/xe/Makefile +1 -0
index 44ed055439d4..92134709d998 100644
@@ -87,6 +87,7 @@ xe-y += xe_bb.o \
 	xe_hw_fence.o \
 	xe_irq.o \
 	xe_late_bind_fw.o \
+	xe_log.o \
 	xe_lrc.o \
 	xe_mem_pool.o \
 	xe_migrate.o \
drivers/gpu/drm/xe/abi/xe_sigid_abi.h new file +81 -0
new file mode 100644
index 000000000000..93967183ae51
@@ -0,0 +1,159 @@
+/* SPDX-License-Identifier: MIT */
+/*
+ * Copyright © 2026 Intel Corporation
+ */
+
+#ifndef _ABI_XE_SIGID_ABI_H_
+#define _ABI_XE_SIGID_ABI_H_
+
+/**
+ * DOC: Xe Error Signatures (SIGID)
+ *
+ * What SIGID stands for
+ * ---------------------
+ *
+ * SIGID is short for *Signature Identifier*. It is a small, stable integer
+ * that names one of *recognised fault site* -- nothing more. It is the
+ * primary handle used for triage and maps directly to specific report site.
+ *
+ * Numbering
+ * ---------
+ *
+ * SIGIDs are a single flat list numbered sequentially within the assigned range,
+ * in the order the fault sites were introduced. Values are stable: once assigned
+ * they are only ever appended, never renumbered or reused. A retired fault site
+ * SIGID value is deprecated in place, never re-purposed.
+ *
+ * Why this exists
+ * ---------------
+ *
+ * Today the driver reports faults with ad-hoc ``xe_err()`` / ``xe_gt_err()``
+ * strings that have no stable shape. That is fine for a human reading dmesg,
+ * but it gives fleet tooling nothing durable to match on: the wording changes
+ * between releases, lines can be rate-limited or dropped under an error storm,
+ * and there is no consistent way to ask "which recognised fault just happened?"
+ *
+ * A SIGID answers exactly that one question, identically across driver and
+ * firmware versions, and (eventually) across other Intel devices in a node.
+ *
+ * What a SIGID is not
+ * -------------------
+ *
+ * SIGID deliberately does not encode the detailed reason or the outcome. Those
+ * are carried alongside it::
+ *
+ *   SIGID    -> which recognised fault site is being reported
+ *   severity -> how serious this instance is
+ *   errno    -> the failing operation's error, if available, shown with %pe
+ *   message  -> free-form human-readable context
+ *
+ * Severity is independent of the SIGID. The same SIGID can be reported at
+ * different severities depending on the instance and the recovery taken.
+ *
+ * When to use SIGID logging
+ * -------------------------
+ *
+ * The xe_log_*() helpers are for these recognised fault sites only --
+ * important, operator-relevant faults and events. The driver's only job is to
+ * emit the right SIGID next to the usual human-readable text.
+
+ * They are not a replacement for ``xe_info()`` / ``xe_dbg()`` / tracing, nor
+ * for one-off diagnostics; using them for ordinary logging would dilute the
+ * fault stream. Not every ``xe_err()`` needs to become a SIGID report -- only
+ * those that correspond to a published fault sites.
+ *
+ * SIGID log output (dmesg vs. the machine record)
+ * -----------------------------------------------
+ *
+ * The dmesg line stays close to a normal xe error message so it remains
+ * readable for admins; the only stable, machine-matchable token on it is
+ * ``SIGID=<n>`` (``dmesg | grep SIGID=``).
+ *
+ * The full dmesg line is not an ABI: the surrounding text may change freely,
+ * and lines may be dropped. The durable record for tooling is the CPER record
+ * carrying the same SIGID (generation is a planned follow-up).
+ *
+ * How to pick a SIGID (the uniqueness rule)
+ * -----------------------------------------
+ *
+ * Pick per *report site*, not per incident. Each site emits the single most
+ * specific recognised SIGID *for that site* -- so the question is never
+ * "classify this whole failure", it is "what does this site detect?", which has + * one answer. A single underlying failure therefore legitimately produces a + * *chain* of reports from different layers, each with its own SIGID -- e.g. a + * GuC communication failure is reported as %XE_SIGID_RUNTIME_FW by the firmware + * path, the failed recovery as %XE_SIGID_GT_TDR by the reset path, and an + * aborted bind as %XE_SIGID_PROBE by the probe path. That chain lets triage + * follow a fault from origin to final effect; it is not a duplicate. + * + * If a site does not match any defined SIGID, keep using the ordinary + * ``xe_err()`` / ``xe_gt_err()`` logging rather than forcing a SIGID: a wrong + * or over-broad classification is harder to retire than a missing one. When a + * new report site is genuinely worth triaging, add it to the list below. + * + * Usage of the existing SIGID reports must reevaluated according to this section + * after making significant changes to the site that emits this SIGID. + * + * Scope: software vs hardware

emitted signatures + * ---------------------------------------------- + * + * Some SIGID represents fault sites that the *driver itself* detects and + * reports from the software POV: probe abort, wedged, survivability, driver- + * detected firmware failures, engine TDR, memory faults and IO/bus faults. + * These are the only values the driver assigns on its own. + * + * Signatures that *originate* in firmware or hardware are a different thing: + * they are produced and identified by the firmware or the hardware itself + * (e.g. via their own records or error counters), and the driver merely logs + * them as they are given to us. They are deliberately enumerated separately. + * + * The two driver-detected firmware report sites below (%XE_SIGID_RUNTIME_FW, + * %XE_SIGID_DEVICE_FW) are software signatures: they mark that *the driver* + * observed a firmware problem, not a signature reported by the firmware. + */ + +/* + * Top level Intel Error Signature Identifiers. + */ +#define INTEL_SIGID_INVALID 0 +#define INTEL_SIGID_BATCH 100 +#define INTEL_SIGID_RANGE_START(n) ((n) * INTEL_SIGID_BATCH) +#define INTEL_SIGID_RANGE_END(n) (INTEL_SIGID_RANGE_START((n) + 1) - 1) + +/* SIGIDs 1xx are reserved for Xe GPU software and 2xx for Xe GPU hardware */ +#define INTEL_SIGID_GPU_XE_SOFTWARE_START INTEL_SIGID_RANGE_START(1) +#define INTEL_SIGID_GPU_XE_SOFTWARE_END INTEL_SIGID_RANGE_END(1) +#define INTEL_SIGID_GPU_XE_HARDWARE_START INTEL_SIGID_RANGE_START(2) +#define INTEL_SIGID_GPU_XE_HARDWARE_END INTEL_SIGID_RANGE_END(2) + +/** + * enum xe_sigid - Stable Xe Error Signature Identifiers (SIGID). + * @XE_SIGID_SW: Software component failure. + * @XE_SIGID_PROBE: Device probe/bind was aborted. + * @XE_SIGID_WEDGED: Device was declared wedged and is no longer usable. + * @XE_SIGID_SURVIVABILITY: Device entered survivability mode. + * @XE_SIGID_RUNTIME_FW: Driver-detected runtime firmware failure, GuC/HuC/GSC. + * @XE_SIGID_DEVICE_FW: Driver-detected device firmware failure, PCODE/sysctrl. + * @XE_SIGID_GT_TDR: Engine hang / timeout detection and recovery (reset). + * @XE_SIGID_MEM_FAULT: VM bind, page fault or GTT fault. + * @XE_SIGID_IO_BUS: Runtime PCIe / IOMMU / MMIO access fault. + * + * Each SIGID represents the report sites the driver detects and reports. + * Values are numbered sequentially, are only ever appended, and are never + * renumbered or reused. + * + * Firmware- and hardware-originated signatures are not listed yet here. + */ +enum xe_sigid { + XE_SIGID_SW = INTEL_SIGID_GPU_XE_SOFTWARE_START, + XE_SIGID_PROBE = INTEL_SIGID_GPU_XE_SOFTWARE_START + 1, + XE_SIGID_WEDGED = INTEL_SIGID_GPU_XE_SOFTWARE_START + 2, + XE_SIGID_SURVIVABILITY = INTEL_SIGID_GPU_XE_SOFTWARE_START + 3, + XE_SIGID_RUNTIME_FW = INTEL_SIGID_GPU_XE_SOFTWARE_START + 4, + XE_SIGID_DEVICE_FW = INTEL_SIGID_GPU_XE_SOFTWARE_START + 5, + XE_SIGID_GT_TDR = INTEL_SIGID_GPU_XE_SOFTWARE_START + 6, + XE_SIGID_MEM_FAULT = INTEL_SIGID_GPU_XE_SOFTWARE_START
+ 7, + XE_SIGID_IO_BUS = INTEL_SIGID_GPU_XE_SOFTWARE_START + 8, +}; + +#endif diff --git a/drivers/gpu/drm/xe/xe_log.c b/drivers/gpu/drm/xe/xe_log.c new file mode 100644 index 000000000000..ae4f6e33f5b8 --- /dev/null +++ b/drivers/gpu/drm/xe/xe_log.c @@ -0,0 +1,138 @@ +// SPDX-License-Identifier: MIT +/* + * Copyright © 2026 Intel Corporation + */ + +#include "xe_log.h"

drivers/gpu/drm/xe/abi/xe_sigid_abi.h new file +82 -0
+#include "xe_printk.h"
+
+static void log_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)
+{
+	/* TODO */
+}
+
+static bool is_hw_sigid(enum xe_sigid sigid)
+{
+	return (int)sigid >= INTEL_SIGID_GPU_XE_HARDWARE_START;
+}
+
+static bool is_sev_error(int cper_sev)
+{
+	return cper_sev != CPER_SEV_INFORMATIONAL;
+}
+
+static const char *log_hwe_prefix(int cper_sev, enum xe_sigid sigid)
+{
+	return is_sev_error(cper_sev) && is_hw_sigid(sigid) ? HW_ERR : "";
+}
+
+static const char *log_sev_prefix(int cper_sev)
+{
+	switch (cper_sev) {
+	case CPER_SEV_FATAL:
+		return "FATAL ";
+	case CPER_SEV_RECOVERABLE:
+		return "";
+	case CPER_SEV_CORRECTED:
+		return "CORRECTED ";
+	case CPER_SEV_INFORMATIONAL:
+		return "";
+	default:
+		WARN(IS_ENABLED(CONFIG_DRM_XE_DEBUG), "LOG: unknown severity %d\n", cper_sev);
+		return "";
+	}
+}
+
+#define __LOG_DRM_PRINTK_FMT(fmt, args...)	"[drm] " fmt, ##args
+#define __LOG_DRM_PRINTK_ERR_FMT(fmt, args...)	__LOG_DRM_PRINTK_FMT("*ERROR* " fmt, args)
+
+static void log_dmesg_vprintk(struct pci_dev *pdev, int cper_sev, struct va_format *vaf)
+{
+	if (cper_sev == CPER_SEV_INFORMATIONAL)
+		pci_info(pdev, __LOG_DRM_PRINTK_FMT("%pV", vaf));
+	else
+		pci_err(pdev, __LOG_DRM_PRINTK_ERR_FMT("%pV", vaf));
+}
+
+static void log_dmesg_printf(struct pci_dev *pdev, int cper_sev, const char *fmt, ...)
+{
+	struct va_format vaf;
+	va_list args;
+
+	va_start(args, fmt);
+	vaf.fmt = fmt;
+	vaf.va = &args;
+
+	log_dmesg_vprintk(pdev, cper_sev, &vaf);
+
+	va_end(args);
+}
+
+static void log_emit_dmesg(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)
+{
+	const char *hwe_prefix = log_hwe_prefix(cper_sev, sigid);
+	const char *sev_prefix = log_sev_prefix(cper_sev);
+
+	/* TODO: add component/location details */
+
+	if (IS_ERR(data))
+		log_dmesg_printf(pdev, cper_sev, "SIGID=%u %s(%pe) %s%pV",
+				 sigid, sev_prefix, data, hwe_prefix, vaf);
+	else if (data && len)
+		log_dmesg_printf(pdev, cper_sev, "SIGID=%u %s(%*phN) %s%pV",
+				 sigid, sev_prefix, (int)len, data, hwe_prefix, vaf);
+	else

drivers/gpu/drm/xe/abi/xe_sigid_abi.h

Quoted 10 lines
drivers/gpu/drm/xe/abi/xe_sigid_abi.h new file +10 -0
+		log_dmesg_printf(pdev, cper_sev, "SIGID=%u %s%s%pV",
+				 sigid, sev_prefix, hwe_prefix, vaf);
+}
+
+/**
+ * xe_log_emit() - Emit a structured SIGID log entry
+ * @pdev: the &pci_dev device
+ * @cper_sev: CPER severity (CPER_SEV_FATAL, CPER_SEV_RECOVERABLE, ...)
+ * @sigid: signature identifier, see &enum xe_sigid
+ * @component: component identifer

Typo "identifier"

Quoted 13 lines

+ * @location: location details of the @component
+ * @data: pointer to the additional details, or ERR_PTR, or NULL if not applicable
+ * @len: length of the @data in bytes, or 0 if not applicable
+ * @fmt: printf-style format string
+ * @...: format arguments
+ *
+ * Emits a dmesg line that includes a single stable, machine-matchable token
+ * ``SIGID=<n>`` followed by the optional severity token (like ``FATAL``) and,
+ * when @data pointer is set, either the error printed with %pe or a packed hex
+ * dump of the @data binary blob. The dmesg line will also include printf-style
+ * text message.
+ *
+ * Note that the full dmesg line, with the free text message, is only a debugging

Quoted 8 lines

+ * aid, not an interface! Only the ``SIGID=<n>`` token is stable there.
+ * The durable machine record is the CPER carrying the same SIGID.
+ *
+ * Note: generation of the CPER record is a planned follow-up.
+ *
+ * Examples::
+ *
+ * <3> xe 0000:03:00.0: [drm] *ERROR* SIGID=104 FATAL (-EPROTO) Invalid GuC reply

Quoted 3 lines

Missing TAG: in this case GuC/HuC/GSC:

right?

not really

at the current patch there is only xe_log_emit() function available, there is no other macros, no component definitions, so for the call like this:

	xe_log_emit(pdev, CPER_SEV_FATAL, XE_SIGID_RUNTIME_FW,
			ERR_PTR(-EPROTO), 0, "Invalid GuC reply");

the output will be:

	<3> xe 0000:03:00.0: [drm] *ERROR* SIGID=104 FATAL (-EPROTO) Invalid GuC reply

but later, after introducing more macros and component/location definitions, one can use this instead:

	xe_log_err_fatal(gt, GUC, -EPROTO, "Invalid GuC reply");

and then indeed the output will be decorated with location/component info:

	<3> xe 0000:03:00.0: [drm] *ERROR* SIGID=104 FATAL (-EPROTO) Tile0: GT1: GUC: Invalid GuC reply
Quoted 49 lines
Quoted 2 lines

+ * <3> xe 0000:03:00.0: [drm] *ERROR* SIGID=106 (-ETIMEDOUT) Engine 'rcs0' hung

ditto

Quoted 44 lines

+ * <6> xe 0000:03:00.0: [drm] SIGID=103 In survivability mode
+ */

drivers/gpu/drm/xe/abi/xe_sigid_abi.h new file +16 -0
+void xe_log_emit(struct pci_dev *pdev, int cper_sev, enum xe_sigid sigid,
+		 u32 component, u32 location, const void *data, size_t len,
+		 const char *fmt, ...)
+{
+	struct va_format vaf;
+	va_list args;
+
+	va_start(args, fmt);
+	vaf.fmt = fmt;
+	vaf.va = &args;
+
+	log_emit_dmesg(pdev, cper_sev, sigid, component, location, data, len, &vaf);
+	log_emit_cper(pdev, cper_sev, sigid, component, location, data, len, &vaf);
+
+	va_end(args);
+}
drivers/gpu/drm/xe/xe_log.h new file +20 -0
new file mode 100644
index 000000000000..d475e816ee0b
@@ -0,0 +1,20 @@
+/* SPDX-License-Identifier: MIT */
+/*
+ * Copyright © 2026 Intel Corporation
+ */
+
+#ifndef _XE_LOG_H_
+#define _XE_LOG_H_
+
+#include <linux/cper.h>
+
+#include "abi/xe_sigid_abi.h"
+
+struct pci_dev;
+
+__printf(8, 9)
+void xe_log_emit(struct pci_dev *pdev, int cper_sev, enum xe_sigid sigid,
+		 u32 component, u32 location, const void *data, size_t len,
+		 const char *fmt, ...);
+
+#endif
#8 lore raw

Re: [PATCH v4 02/32] drm/xe/log: Add structured SIGID error logging infrastructure

In reply to Michal Wajdeczko

Hi Michal,

Couple of comments, on rate-limiting and XE_SIGID_WEDGED, from v3 https://patchwork.freedesktop.org/patch/743308/?series=171022&rev=3#comment_1373861

are not answered/addressed.

Quoted 382 lines · Michal Wajdeczko

From: Mallesh Koujalagi <[email protected]>

Today the driver reports faults with ad-hoc drm_err()/xe_gt_err() strings that have no stable shape. That is readable for a human, but it gives fleet tooling nothing durable to match on: the wording changes between releases, lines can be rate-limited or dropped under an error storm, and there is no consistent way to ask "which recognised fault just happened?".

Introduce a signature identifier (SIGID): a small, stable integer that names one recognised Xe fault site and serves as the primary handle for triage. A SIGID maps, through published end-user documentation, to a description and a recommended action; the driver only has to emit the right SIGID next to the usual human-readable text.

Assisted-by Copilot:Opus-4.8
Cc Riana Tauro <[email protected]>
Cc Stuart Summers <[email protected]>

---
Cc: Yoni Levitt <[email protected]>
Cc: Aravind Iddamsetty <[email protected]>
Cc: Raag Jadav <[email protected]>
---
v2: CORRECTED is still an error (Michal)
prepare to decorate dmesg with comp/loc (Michal)
v3: update SIGID DOC section (Riana/Aravind)
warn about unknown severity (Mallesh)

---
  Documentation/gpu/xe/index.rst        |   1 +
  Documentation/gpu/xe/xe_sigid.rst     |  14 +++
  drivers/gpu/drm/xe/Makefile           |   1 +
  drivers/gpu/drm/xe/abi/xe_sigid_abi.h | 159 ++++++++++++++++++++++++++
  drivers/gpu/drm/xe/xe_log.c           | 138 ++++++++++++++++++++++
  drivers/gpu/drm/xe/xe_log.h           |  20 ++++
  6 files changed, 333 insertions(+)

create mode 100644 Documentation/gpu/xe/xe_sigid.rst create mode 100644 drivers/gpu/drm/xe/abi/xe_sigid_abi.h create mode 100644 drivers/gpu/drm/xe/xe_log.c create mode 100644 drivers/gpu/drm/xe/xe_log.h

Documentation/gpu/xe/index.rst +1 -0
index 665c0e93601c..0247a255f7e6 100644
@@ -35,3 +35,4 @@ The display, or :ref:`drm-kms`, support for drm/xe is provided by
     xe-drm-usage-stats.rst
     xe_configfs
     xe_gt_stats
+   xe_sigid
Documentation/gpu/xe/xe_sigid.rst new file +14 -0
new file mode 100644
index 000000000000..45d84a62f185
@@ -0,0 +1,14 @@
+.. SPDX-License-Identifier: (GPL-2.0+ OR MIT)
+
+========
+Xe SIGID
+========
+
+.. kernel-doc:: drivers/gpu/drm/xe/abi/xe_sigid_abi.h
+   :doc: Xe Error Signatures (SIGID)
+
+Signature Identifiers
+=====================
+
+.. kernel-doc:: drivers/gpu/drm/xe/abi/xe_sigid_abi.h
+   :internal:
drivers/gpu/drm/xe/Makefile +1 -0
index 44ed055439d4..92134709d998 100644
@@ -87,6 +87,7 @@ xe-y += xe_bb.o \
  	xe_hw_fence.o \
  	xe_irq.o \
  	xe_late_bind_fw.o \
+	xe_log.o \
  	xe_lrc.o \
  	xe_mem_pool.o \
  	xe_migrate.o \
drivers/gpu/drm/xe/abi/xe_sigid_abi.h new file +159 -0
new file mode 100644
index 000000000000..93967183ae51
@@ -0,0 +1,159 @@
+/* SPDX-License-Identifier: MIT */
+/*
+ * Copyright © 2026 Intel Corporation
+ */
+
+#ifndef _ABI_XE_SIGID_ABI_H_
+#define _ABI_XE_SIGID_ABI_H_
+
+/**
+ * DOC: Xe Error Signatures (SIGID)
+ *
+ * What SIGID stands for
+ * ---------------------
+ *
+ * SIGID is short for *Signature Identifier*. It is a small, stable integer
+ * that names one of *recognised fault site* -- nothing more. It is the
+ * primary handle used for triage and maps directly to specific report site.
+ *
+ * Numbering
+ * ---------
+ *
+ * SIGIDs are a single flat list numbered sequentially within the assigned range,
+ * in the order the fault sites were introduced. Values are stable: once assigned
+ * they are only ever appended, never renumbered or reused. A retired fault site
+ * SIGID value is deprecated in place, never re-purposed.
+ *
+ * Why this exists
+ * ---------------
+ *
+ * Today the driver reports faults with ad-hoc ``xe_err()`` / ``xe_gt_err()``
+ * strings that have no stable shape. That is fine for a human reading dmesg,
+ * but it gives fleet tooling nothing durable to match on: the wording changes
+ * between releases, lines can be rate-limited or dropped under an error storm,
+ * and there is no consistent way to ask "which recognised fault just happened?"
+ *
+ * A SIGID answers exactly that one question, identically across driver and
+ * firmware versions, and (eventually) across other Intel devices in a node.
+ *
+ * What a SIGID is not
+ * -------------------
+ *
+ * SIGID deliberately does not encode the detailed reason or the outcome. Those
+ * are carried alongside it::
+ *
+ *   SIGID    -> which recognised fault site is being reported
+ *   severity -> how serious this instance is
+ *   errno    -> the failing operation's error, if available, shown with %pe
+ *   message  -> free-form human-readable context
+ *
+ * Severity is independent of the SIGID. The same SIGID can be reported at
+ * different severities depending on the instance and the recovery taken.
+ *
+ * When to use SIGID logging
+ * -------------------------
+ *
+ * The xe_log_*() helpers are for these recognised fault sites only --
+ * important, operator-relevant faults and events. The driver's only job is to
+ * emit the right SIGID next to the usual human-readable text.
+
+ * They are not a replacement for ``xe_info()`` / ``xe_dbg()`` / tracing, nor
+ * for one-off diagnostics; using them for ordinary logging would dilute the
+ * fault stream. Not every ``xe_err()`` needs to become a SIGID report -- only
+ * those that correspond to a published fault sites.
+ *
+ * SIGID log output (dmesg vs. the machine record)
+ * -----------------------------------------------
+ *
+ * The dmesg line stays close to a normal xe error message so it remains
+ * readable for admins; the only stable, machine-matchable token on it is
+ * ``SIGID=<n>`` (``dmesg | grep SIGID=``).
+ *
+ * The full dmesg line is not an ABI: the surrounding text may change freely,
+ * and lines may be dropped. The durable record for tooling is the CPER record
+ * carrying the same SIGID (generation is a planned follow-up).
+ *
+ * How to pick a SIGID (the uniqueness rule)
+ * -----------------------------------------
+ *
+ * Pick per *report site*, not per incident. Each site emits the single most
+ * specific recognised SIGID *for that site* -- so the question is never
+ * "classify this whole failure", it is "what does this site detect?", which has
+ * one answer. A single underlying failure therefore legitimately produces a
+ * *chain* of reports from different layers, each with its own SIGID -- e.g. a
+ * GuC communication failure is reported as %XE_SIGID_RUNTIME_FW by the firmware
+ * path, the failed recovery as %XE_SIGID_GT_TDR by the reset path, and an
+ * aborted bind as %XE_SIGID_PROBE by the probe path. That chain lets triage
+ * follow a fault from origin to final effect; it is not a duplicate.
+ *
+ * If a site does not match any defined SIGID, keep using the ordinary
+ * ``xe_err()`` / ``xe_gt_err()`` logging rather than forcing a SIGID: a wrong
+ * or over-broad classification is harder to retire than a missing one. When a
+ * new report site is genuinely worth triaging, add it to the list below.
+ *
+ * Usage of the existing SIGID reports must reevaluated according to this section
+ * after making significant changes to the site that emits this SIGID.
+ *
+ * Scope: software vs hardware emitted signatures
+ * ----------------------------------------------
+ *
+ * Some SIGID represents fault sites that the *driver itself* detects and
+ * reports from the software POV: probe abort, wedged, survivability, driver-
+ * detected firmware failures, engine TDR, memory faults and IO/bus faults.
+ * These are the only values the driver assigns on its own.
+ *
+ * Signatures that *originate* in firmware or hardware are a different thing:
+ * they are produced and identified by the firmware or the hardware itself
+ * (e.g. via their own records or error counters), and the driver merely logs
+ * them as they are given to us. They are deliberately enumerated separately.
+ *
+ * The two driver-detected firmware report sites below (%XE_SIGID_RUNTIME_FW,
+ * %XE_SIGID_DEVICE_FW) are software signatures: they mark that *the driver*
+ * observed a firmware problem, not a signature reported by the firmware.
+ */
+
+/*
+ * Top level Intel Error Signature Identifiers.
+ */
+#define INTEL_SIGID_INVALID			0
+#define INTEL_SIGID_BATCH			100
+#define INTEL_SIGID_RANGE_START(n)		((n) * INTEL_SIGID_BATCH)
+#define INTEL_SIGID_RANGE_END(n)		(INTEL_SIGID_RANGE_START((n) + 1) - 1)
+
+/* SIGIDs 1xx are reserved for Xe GPU software and 2xx for Xe GPU hardware */
+#define INTEL_SIGID_GPU_XE_SOFTWARE_START	INTEL_SIGID_RANGE_START(1)
+#define INTEL_SIGID_GPU_XE_SOFTWARE_END		INTEL_SIGID_RANGE_END(1)
+#define INTEL_SIGID_GPU_XE_HARDWARE_START	INTEL_SIGID_RANGE_START(2)
+#define INTEL_SIGID_GPU_XE_HARDWARE_END		INTEL_SIGID_RANGE_END(2)
+
+/**
+ * enum xe_sigid - Stable Xe Error Signature Identifiers (SIGID).
+ * @XE_SIGID_SW: Software component failure.
+ * @XE_SIGID_PROBE: Device probe/bind was aborted.
+ * @XE_SIGID_WEDGED: Device was declared wedged and is no longer usable.
+ * @XE_SIGID_SURVIVABILITY: Device entered survivability mode.
+ * @XE_SIGID_RUNTIME_FW: Driver-detected runtime firmware failure, GuC/HuC/GSC.
+ * @XE_SIGID_DEVICE_FW: Driver-detected device firmware failure, PCODE/sysctrl.
+ * @XE_SIGID_GT_TDR: Engine hang / timeout detection and recovery (reset).
+ * @XE_SIGID_MEM_FAULT: VM bind, page fault or GTT fault.
+ * @XE_SIGID_IO_BUS: Runtime PCIe / IOMMU / MMIO access fault.
+ *
+ * Each SIGID represents the report sites the driver detects and reports.
+ * Values are numbered sequentially, are only ever appended, and are never
+ * renumbered or reused.
+ *
+ * Firmware- and hardware-originated signatures are not listed yet here.
+ */
+enum xe_sigid {
+	XE_SIGID_SW			= INTEL_SIGID_GPU_XE_SOFTWARE_START,
+	XE_SIGID_PROBE			= INTEL_SIGID_GPU_XE_SOFTWARE_START + 1,
+	XE_SIGID_WEDGED			= INTEL_SIGID_GPU_XE_SOFTWARE_START + 2,
+	XE_SIGID_SURVIVABILITY		= INTEL_SIGID_GPU_XE_SOFTWARE_START + 3,
+	XE_SIGID_RUNTIME_FW		= INTEL_SIGID_GPU_XE_SOFTWARE_START + 4,
+	XE_SIGID_DEVICE_FW		= INTEL_SIGID_GPU_XE_SOFTWARE_START + 5,
+	XE_SIGID_GT_TDR			= INTEL_SIGID_GPU_XE_SOFTWARE_START + 6,
+	XE_SIGID_MEM_FAULT		= INTEL_SIGID_GPU_XE_SOFTWARE_START + 7,
+	XE_SIGID_IO_BUS			= INTEL_SIGID_GPU_XE_SOFTWARE_START + 8,
+};
+
+#endif
drivers/gpu/drm/xe/xe_log.c new file +126 -0
new file mode 100644
index 000000000000..ae4f6e33f5b8
@@ -0,0 +1,138 @@
+// SPDX-License-Identifier: MIT
+/*
+ * Copyright © 2026 Intel Corporation
+ */
+
+#include "xe_log.h"
+#include "xe_printk.h"
+
+static void log_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)
+{
+	/* TODO */
+}
+
+static bool is_hw_sigid(enum xe_sigid sigid)
+{
+	return (int)sigid >= INTEL_SIGID_GPU_XE_HARDWARE_START;
+}
+
+static bool is_sev_error(int cper_sev)
+{
+	return cper_sev != CPER_SEV_INFORMATIONAL;
+}
+
+static const char *log_hwe_prefix(int cper_sev, enum xe_sigid sigid)
+{
+	return is_sev_error(cper_sev) && is_hw_sigid(sigid) ? HW_ERR : "";
+}
+
+static const char *log_sev_prefix(int cper_sev)
+{
+	switch (cper_sev) {
+	case CPER_SEV_FATAL:
+		return "FATAL ";
+	case CPER_SEV_RECOVERABLE:
+		return "";
+	case CPER_SEV_CORRECTED:
+		return "CORRECTED ";
+	case CPER_SEV_INFORMATIONAL:
+		return "";
+	default:
+		WARN(IS_ENABLED(CONFIG_DRM_XE_DEBUG), "LOG: unknown severity %d\n", cper_sev);
+		return "";
+	}
+}
+
+#define __LOG_DRM_PRINTK_FMT(fmt, args...)	"[drm] " fmt, ##args
+#define __LOG_DRM_PRINTK_ERR_FMT(fmt, args...)	__LOG_DRM_PRINTK_FMT("*ERROR* " fmt, args)
+
+static void log_dmesg_vprintk(struct pci_dev *pdev, int cper_sev, struct va_format *vaf)
+{
+	if (cper_sev == CPER_SEV_INFORMATIONAL)
+		pci_info(pdev, __LOG_DRM_PRINTK_FMT("%pV", vaf));
+	else
+		pci_err(pdev, __LOG_DRM_PRINTK_ERR_FMT("%pV", vaf));
+}
+
+static void log_dmesg_printf(struct pci_dev *pdev, int cper_sev, const char *fmt, ...)
+{
+	struct va_format vaf;
+	va_list args;
+
+	va_start(args, fmt);
+	vaf.fmt = fmt;
+	vaf.va = &args;
+
+	log_dmesg_vprintk(pdev, cper_sev, &vaf);
+
+	va_end(args);
+}
+
+static void log_emit_dmesg(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)
+{
+	const char *hwe_prefix = log_hwe_prefix(cper_sev, sigid);
+	const char *sev_prefix = log_sev_prefix(cper_sev);
+
+	/* TODO: add component/location details */
+
+	if (IS_ERR(data))
+		log_dmesg_printf(pdev, cper_sev, "SIGID=%u %s(%pe) %s%pV",
+				 sigid, sev_prefix, data, hwe_prefix, vaf);
+	else if (data && len)
+		log_dmesg_printf(pdev, cper_sev, "SIGID=%u %s(%*phN) %s%pV",
+				 sigid, sev_prefix, (int)len, data, hwe_prefix, vaf);
+	else
+		log_dmesg_printf(pdev, cper_sev, "SIGID=%u %s%s%pV",
+				 sigid, sev_prefix, hwe_prefix, vaf);
+}
+
+/**
+ * xe_log_emit() - Emit a structured SIGID log entry
+ * @pdev: the &pci_dev device
+ * @cper_sev: CPER severity (CPER_SEV_FATAL, CPER_SEV_RECOVERABLE, ...)
+ * @sigid: signature identifier, see &enum xe_sigid
+ * @component: component identifer
+ * @location: location details of the @component
+ * @data: pointer to the additional details, or ERR_PTR, or NULL if not applicable
+ * @len: length of the @data in bytes, or 0 if not applicable
+ * @fmt: printf-style format string
+ * @...: format arguments
+ *
+ * Emits a dmesg line that includes a single stable, machine-matchable token
+ * ``SIGID=<n>`` followed by the optional severity token (like ``FATAL``) and,
+ * when @data pointer is set, either the error printed with %pe or a packed hex
+ * dump of the @data binary blob. The dmesg line will also include printf-style
+ * text message.
+ *
+ * Note that the full dmesg line, with the free text message, is only a debugging
+ * aid, not an interface! Only the ``SIGID=<n>`` token is stable there.
+ * The durable machine record is the CPER carrying the same SIGID.
+ *
+ * Note: generation of the CPER record is a planned follow-up.
+ *
+ * Examples::
+ *
+ *   <3> xe 0000:03:00.0: [drm] *ERROR* SIGID=104 FATAL (-EPROTO) Invalid GuC reply
+ *   <3> xe 0000:03:00.0: [drm] *ERROR* SIGID=106 (-ETIMEDOUT) Engine 'rcs0' hung
+ *   <6> xe 0000:03:00.0: [drm] SIGID=103 In survivability mode
+ */
+void xe_log_emit(struct pci_dev *pdev, int cper_sev, enum xe_sigid sigid,
+		 u32 component, u32 location, const void *data, size_t len,
+		 const char *fmt, ...)
+{

drivers/gpu/drm/xe/xe_log.c line 136

Quoted 10 lines
drivers/gpu/drm/xe/xe_log.c new file +10 -0
+	struct va_format vaf;
+	va_list args;
+
+	va_start(args, fmt);
+	vaf.fmt = fmt;
+	vaf.va = &args;
+
+	log_emit_dmesg(pdev, cper_sev, sigid, component, location, data, len, &vaf);
+	log_emit_cper(pdev, cper_sev, sigid, component, location, data, len, &vaf);
+

From kunit example I got this output for hardware errors.
drm-kunit-mock-device demo_dmesg.drm-kunit-mock-device: [drm] *ERROR* SIGID=204 (0102030405060708090a0b0c) [Hardware Error]: testing HARDWARE signature drm-kunit-mock-device demo_dmesg.drm-kunit-mock-device: [drm] *ERROR* SIGID=202 CORRECTED (0102030405060708090a0b0c) [Hardware Error]: Tile1: testing HARDWARE signature

SIGIDs 202 and 204 correspond to the XE_RAS_COMP_DEVICE_MEMORY and XE_RAS_COMP_FABRIC components returned by firmware via xe_ras_error_class.
If we want the component name to be included in the error message, what should be passed to the logging helper? The current KUnit test uses XE_LOG_COMPONENT_NONE, so no component information is being emitted.

Thanks,
Badal

Quoted 28 lines
drivers/gpu/drm/xe/xe_log.c new file +2 -0
+	va_end(args);
+}
drivers/gpu/drm/xe/xe_log.h new file +20 -0
new file mode 100644
index 000000000000..d475e816ee0b
@@ -0,0 +1,20 @@
+/* SPDX-License-Identifier: MIT */
+/*
+ * Copyright © 2026 Intel Corporation
+ */
+
+#ifndef _XE_LOG_H_
+#define _XE_LOG_H_
+
+#include <linux/cper.h>
+
+#include "abi/xe_sigid_abi.h"
+
+struct pci_dev;
+
+__printf(8, 9)
+void xe_log_emit(struct pci_dev *pdev, int cper_sev, enum xe_sigid sigid,
+		 u32 component, u32 location, const void *data, size_t len,
+		 const char *fmt, ...);
+
+#endif
maintainer
#9 lore raw

Re: [PATCH v4 02/32] drm/xe/log: Add structured SIGID error logging infrastructure

Quoted 5 lines · Badal

Hi Michal,

Couple of comments, on rate-limiting and XE_SIGID_WEDGED, from v3 https://patchwork.freedesktop.org/patch/743308/?series=171022&rev=3#comment_1373861

are not answered/addressed.

Hi Badal, could you please be more specific about the questions and repeat them here? I couldn't find from the provided url...

But as we chatted, this series doesn't change the behavior of that and the comment of rate-limit is exactly to ensure this is documented. To ensure it is clear dmesg is not an ABI. It should not be reliable in any way or shape. It is simpler a helper.

On the wedge, the resolution buckets were removed, but I'm not sure if there were more questions around that.

Quoted 29 lines
Quoted 10 lines

+ * Examples::
+ *

+ *   <3> xe 0000:03:00.0: [drm] *ERROR* SIGID=104 FATAL (-EPROTO) Invalid GuC reply
+ *   <3> xe 0000:03:00.0: [drm] *ERROR* SIGID=106 (-ETIMEDOUT) Engine 'rcs0' hung
+ *   <6> xe 0000:03:00.0: [drm] SIGID=103 In survivability mode

+ */

drivers/gpu/drm/xe/xe_log.c new file +4 -0
+void xe_log_emit(struct pci_dev *pdev, int cper_sev, enum xe_sigid sigid,
+		 u32 component, u32 location, const void *data, size_t len,
+		 const char *fmt, ...)
+{

drivers/gpu/drm/xe/xe_log.c line 136

Quoted 10 lines
drivers/gpu/drm/xe/xe_log.c new file +10 -0
+	struct va_format vaf;
+	va_list args;
+
+	va_start(args, fmt);
+	vaf.fmt = fmt;
+	vaf.va = &args;
+
+	log_emit_dmesg(pdev, cper_sev, sigid, component, location, data, len, &vaf);
+	log_emit_cper(pdev, cper_sev, sigid, component, location, data, len, &vaf);
+

From kunit example I got this output for hardware errors. drm-kunit-mock-device demo_dmesg.drm-kunit-mock-device: [drm] *ERROR* SIGID=204 (0102030405060708090a0b0c) [Hardware Error]: testing HARDWARE signature
drm-kunit-mock-device demo_dmesg.drm-kunit-mock-device: [drm] *ERROR* SIGID=202 CORRECTED (0102030405060708090a0b0c) [Hardware Error]: Tile1:
testing HARDWARE signature

Quoted 5 lines

SIGIDs 202 and 204 correspond to the XE_RAS_COMP_DEVICE_MEMORY and XE_RAS_COMP_FABRIC components returned by firmware via xe_ras_error_class. If we want the component name to be included in the error message, what should be passed to the logging helper? The current KUnit test uses XE_LOG_COMPONENT_NONE, so no component information is being emitted.

Our design goal here was to minimize the SIGIDs and make it per site due to maintenability concerns.

There will be a field in the actual CPER with location and that can also be printed in the msg if needed. In a matter of fact, this is what we currently do anyway.

Increasing this to a per case id is a big no!

Thanks,
Rodrigo.

Quoted 32 lines

Thanks,
Badal

Quoted 28 lines
(quoted diff) +2 -0
+	va_end(args);
+}
drivers/gpu/drm/xe/xe_log.h new file +20 -0
new file mode 100644
index 000000000000..d475e816ee0b
@@ -0,0 +1,20 @@
+/* SPDX-License-Identifier: MIT */
+/*
+ * Copyright © 2026 Intel Corporation
+ */
+
+#ifndef _XE_LOG_H_
+#define _XE_LOG_H_
+
+#include <linux/cper.h>
+
+#include "abi/xe_sigid_abi.h"
+
+struct pci_dev;
+
+__printf(8, 9)
+void xe_log_emit(struct pci_dev *pdev, int cper_sev, enum xe_sigid sigid,
+		 u32 component, u32 location, const void *data, size_t len,
+		 const char *fmt, ...);
+
+#endif
#10 lore raw

Re: [PATCH v4 02/32] drm/xe/log: Add structured SIGID error logging infrastructure

Quoted 5 lines · Rodrigo Vivi
Quoted 4 lines · Badal

Hi Michal,

Couple of comments, on rate-limiting and XE_SIGID_WEDGED, from v3 https://patchwork.freedesktop.org/patch/743308/?series=171022&rev=3#comment_1373861

Quoted 8 lines
Quoted 1 line

are not answered/addressed.

Hi Badal, could you please be more specific about the questions and repeat them here? I couldn't find from the provided url...

But as we chatted, this series doesn't change the behavior of that and the comment of rate-limit is exactly to ensure this is documented. To ensure it is clear dmesg is not an ABI. It should not be reliable in any way or shape. It is simpler a helper.

Ok.

Quoted 3 lines

On the wedge, the resolution buckets were removed, but I'm not sure if there were more questions around that.

My concern is about statement "Pick per *report site*, not per incident", XE_SIGID_WEDGED is not site specific SIGID. It can be reported from multiple sites.

Quoted 34 lines
Quoted 29 lines
Quoted 11 lines

+ * Examples::
+ *

+ *   <3> xe 0000:03:00.0: [drm] *ERROR* SIGID=104 FATAL (-EPROTO) Invalid GuC reply
+ *   <3> xe 0000:03:00.0: [drm] *ERROR* SIGID=106 (-ETIMEDOUT) Engine 'rcs0' hung
+ *   <6> xe 0000:03:00.0: [drm] SIGID=103 In survivability mode

+ */

drivers/gpu/drm/xe/xe_log.c new file +4 -0
+void xe_log_emit(struct pci_dev *pdev, int cper_sev, enum xe_sigid sigid,
+		 u32 component, u32 location, const void *data, size_t len,
+		 const char *fmt, ...)
+{

drivers/gpu/drm/xe/xe_log.c line 136

Quoted 10 lines
drivers/gpu/drm/xe/xe_log.c new file +10 -0
+	struct va_format vaf;
+	va_list args;
+
+	va_start(args, fmt);
+	vaf.fmt = fmt;
+	vaf.va = &args;
+
+	log_emit_dmesg(pdev, cper_sev, sigid, component, location, data, len, &vaf);
+	log_emit_cper(pdev, cper_sev, sigid, component, location, data, len, &vaf);
+

From kunit example I got this output for hardware errors.
drm-kunit-mock-device demo_dmesg.drm-kunit-mock-device: [drm] *ERROR* SIGID=204 (0102030405060708090a0b0c) [Hardware Error]: testing HARDWARE signature
drm-kunit-mock-device demo_dmesg.drm-kunit-mock-device: [drm] *ERROR* SIGID=202 CORRECTED (0102030405060708090a0b0c) [Hardware Error]: Tile1:
testing HARDWARE signature

Quoted 5 lines

SIGIDs 202 and 204 correspond to the XE_RAS_COMP_DEVICE_MEMORY and XE_RAS_COMP_FABRIC components returned by firmware via xe_ras_error_class. If we want the component name to be included in the error message, what should be passed to the logging helper? The current KUnit test uses XE_LOG_COMPONENT_NONE, so no component information is being emitted.

Quoted 8 lines

Our design goal here was to minimize the SIGIDs and make it per site due to maintenability concerns.

There will be a field in the actual CPER with location and that can also be printed in the msg if needed. In a matter of fact, this is what we currently do anyway.

Increasing this to a per case id is a big no!

Agreed.

Thanks,
Badal

Quoted 35 lines

Thanks,
Rodrigo.

Quoted 31 lines

Thanks,
Badal

Quoted 28 lines
(quoted diff) +2 -0
+	va_end(args);
+}
drivers/gpu/drm/xe/xe_log.h new file +20 -0
new file mode 100644
index 000000000000..d475e816ee0b
@@ -0,0 +1,20 @@
+/* SPDX-License-Identifier: MIT */
+/*
+ * Copyright © 2026 Intel Corporation
+ */
+
+#ifndef _XE_LOG_H_
+#define _XE_LOG_H_
+
+#include <linux/cper.h>
+
+#include "abi/xe_sigid_abi.h"
+
+struct pci_dev;
+
+__printf(8, 9)
+void xe_log_emit(struct pci_dev *pdev, int cper_sev, enum xe_sigid sigid,
+		 u32 component, u32 location, const void *data, size_t len,
+		 const char *fmt, ...);
+
+#endif
#11 lore raw

Re: [PATCH v4 02/32] drm/xe/log: Add structured SIGID error logging infrastructure

Quoted 14 lines · Badal
Quoted 5 lines · Rodrigo Vivi
Quoted 4 lines · Badal

Hi Michal,

Couple of comments, on rate-limiting and XE_SIGID_WEDGED, from v3 https://patchwork.freedesktop.org/patch/743308/?series=171022&rev=3#comment_1373861

Quoted 8 lines
Quoted 1 line

are not answered/addressed.

Hi Badal, could you please be more specific about the questions and repeat them here? I couldn't find from the provided url...

But as we chatted, this series doesn't change the behavior of that and the comment of rate-limit is exactly to ensure this is documented. To ensure it is clear dmesg is not an ABI. It should not be reliable in any way or shape. It is simpler a helper.

Quoted 6 lines

Ok.

Quoted 3 lines

On the wedge, the resolution buckets were removed, but I'm not sure if there were more questions around that.

My concern is about statement "Pick per *report site*, not per incident", XE_SIGID_WEDGED is not site specific SIGID. It can be reported from multiple sites.

the XE_SIGID_WEDGED is specific to xe_device_declare_wedged() which we treated here as a separate "site"

and whoever triggers the wedge state, should use its own SIGID to reports its own errors, should not use the SIGID_WEDGED

Quoted 84 lines
Quoted 35 lines
Quoted 30 lines
Quoted 12 lines

+ * Examples::
+ *
+ *   <3> xe 0000:03:00.0: [drm] *ERROR* SIGID=104 FATAL (-EPROTO) Invalid GuC reply
+ *   <3> xe 0000:03:00.0: [drm] *ERROR* SIGID=106 (-ETIMEDOUT) Engine 'rcs0' hung
+ *   <6> xe 0000:03:00.0: [drm] SIGID=103 In survivability mode
+ */

drivers/gpu/drm/xe/xe_log.c new file +4 -0
+void xe_log_emit(struct pci_dev *pdev, int cper_sev, enum xe_sigid sigid,
+         u32 component, u32 location, const void *data, size_t len,
+         const char *fmt, ...)
+{

drivers/gpu/drm/xe/xe_log.c line 136

Quoted 10 lines
drivers/gpu/drm/xe/xe_log.c new file +10 -0
+    struct va_format vaf;
+    va_list args;
+
+    va_start(args, fmt);
+    vaf.fmt = fmt;
+    vaf.va = &args;
+
+    log_emit_dmesg(pdev, cper_sev, sigid, component, location, data, len, &vaf);
+    log_emit_cper(pdev, cper_sev, sigid, component, location, data, len, &vaf);
+

 From kunit example I got this output for hardware errors. drm-kunit-mock-device demo_dmesg.drm-kunit-mock-device: [drm] *ERROR* SIGID=204 (0102030405060708090a0b0c) [Hardware Error]: testing HARDWARE signature
drm-kunit-mock-device demo_dmesg.drm-kunit-mock-device: [drm] *ERROR* SIGID=202 CORRECTED (0102030405060708090a0b0c) [Hardware Error]: Tile1:
testing HARDWARE signature

Quoted 5 lines

SIGIDs 202 and 204 correspond to the XE_RAS_COMP_DEVICE_MEMORY and XE_RAS_COMP_FABRIC components returned by firmware via xe_ras_error_class. If we want the component name to be included in the error message, what should be passed to the logging helper? The current KUnit test uses XE_LOG_COMPONENT_NONE, so no component information is being emitted.

Quoted 8 lines

Our design goal here was to minimize the SIGIDs and make it per site due to maintenability concerns.

There will be a field in the actual CPER with location and that can also be printed in the msg if needed. In a matter of fact, this is what we currently do anyway.

Increasing this to a per case id is a big no!

Agreed.

Thanks,
Badal

Quoted 35 lines

Thanks,
Rodrigo.

Quoted 31 lines

Thanks,
Badal

Quoted 28 lines

+    va_end(args);

(quoted diff) +1 -0
+}
drivers/gpu/drm/xe/xe_log.h new file +20 -0
new file mode 100644
index 000000000000..d475e816ee0b
@@ -0,0 +1,20 @@
+/* SPDX-License-Identifier: MIT */
+/*
+ * Copyright © 2026 Intel Corporation
+ */
+
+#ifndef _XE_LOG_H_
+#define _XE_LOG_H_
+
+#include <linux/cper.h>
+
+#include "abi/xe_sigid_abi.h"
+
+struct pci_dev;
+
+__printf(8, 9)
+void xe_log_emit(struct pci_dev *pdev, int cper_sev, enum xe_sigid sigid,
+         u32 component, u32 location, const void *data, size_t len,
+         const char *fmt, ...);
+
+#endif
#12 lore raw

Re: [PATCH v4 02/32] drm/xe/log: Add structured SIGID error logging infrastructure

In reply to Nilawar, Badal
Quoted 1 line · Badal

Hi Michal,

...

Quoted 7 lines

From kunit example I got this output for hardware errors.
drm-kunit-mock-device demo_dmesg.drm-kunit-mock-device: [drm] *ERROR* SIGID=204 (0102030405060708090a0b0c) [Hardware Error]: testing HARDWARE signature drm-kunit-mock-device demo_dmesg.drm-kunit-mock-device: [drm] *ERROR* SIGID=202 CORRECTED (0102030405060708090a0b0c) [Hardware Error]: Tile1: testing HARDWARE signature

SIGIDs 202 and 204 correspond to the XE_RAS_COMP_DEVICE_MEMORY and XE_RAS_COMP_FABRIC components returned by firmware via xe_ras_error_class.
If we want the component name to be included in the error message, what should be passed to the logging helper? The current KUnit test uses XE_LOG_COMPONENT_NONE, so no component information is being emitted.

if you want HW component name to be explicitly included like we do for SW errors, use xe_log_comp_xxx() macros:

- xe_log_emit_recoverable(pdev, XE_SIGID_FABRIC,
- XE_LOG_COMPONENT_NONE, XE_LOG_LOCATION_NONE,
+ xe_log_comp_recoverable(pdev, FABRIC,

                                blob, sizeof(blob), "testing %s signature\n", "HARDWARE");
-       xe_log_from_corrected(tile, XE_SIGID_DEVICE_MEMORY, XE_LOG_COMPONENT_NONE,
+       xe_log_comp_corrected(tile, DEVICE_MEMORY,
                              blob, sizeof(blob), "testing %s signature\n", "HARDWARE");

then you will get:

.. [drm] *ERROR* SIGID=204 (0102030405060708090a0b0c) [Hardware Error]: FABRIC: testing HARDWARE signature
.. [drm] *ERROR* SIGID=202 CORRECTED (0102030405060708090a0b0c) [Hardware Error]: Tile1: DEVICE_MEMORY: testing HARDWARE signature

and btw, I will ask again, whether we want LOCATION/COMPONENT decoration as here:

Tile1: GT1: PROBE: testing software signature
Tile1: DEVICE_MEMORY: testing HARDWARE signature

or maybe in COMPONENT/LOCATION order:

PROBE: Tile1: GT1: testing software signature
DEVICE_MEMORY: Tile1: testing HARDWARE signature

if latter, then please comment patch 4/32

Quoted 4 lines

Thanks,
Badal

#13 lore raw

Re: [PATCH v4 02/32] drm/xe/log: Add structured SIGID error logging infrastructure

Quoted 22 lines · Michal Wajdeczko
Quoted 1 line · Badal

Hi Michal,

...

Quoted 6 lines

From kunit example I got this output for hardware errors.
drm-kunit-mock-device demo_dmesg.drm-kunit-mock-device: [drm] *ERROR* SIGID=204 (0102030405060708090a0b0c) [Hardware Error]: testing HARDWARE signature drm-kunit-mock-device demo_dmesg.drm-kunit-mock-device: [drm] *ERROR* SIGID=202 CORRECTED (0102030405060708090a0b0c) [Hardware Error]: Tile1: testing HARDWARE signature

SIGIDs 202 and 204 correspond to the XE_RAS_COMP_DEVICE_MEMORY and XE_RAS_COMP_FABRIC components returned by firmware via xe_ras_error_class.
If we want the component name to be included in the error message, what should be passed to the logging helper? The current KUnit test uses XE_LOG_COMPONENT_NONE, so no component information is being emitted.

if you want HW component name to be explicitly included like we do for SW errors, use xe_log_comp_xxx() macros:

(quoted diff) +2 -3
-       xe_log_emit_recoverable(pdev, XE_SIGID_FABRIC,
-                               XE_LOG_COMPONENT_NONE, XE_LOG_LOCATION_NONE,
+       xe_log_comp_recoverable(pdev, FABRIC,
                                 blob, sizeof(blob), "testing %s signature\n", "HARDWARE");
-       xe_log_from_corrected(tile, XE_SIGID_DEVICE_MEMORY, XE_LOG_COMPONENT_NONE,
+       xe_log_comp_corrected(tile, DEVICE_MEMORY,
                               blob, sizeof(blob), "testing %s signature\n", "HARDWARE");
Quoted 3 lines

then you will get:

.. [drm] *ERROR* SIGID=204 (0102030405060708090a0b0c) [Hardware Error]: FABRIC: testing HARDWARE signature

CORRECTABLE should also be printed, as for hardware errors it represents uncorrected errors.

Quoted 8 lines

.. [drm] *ERROR* SIGID=202 CORRECTED (0102030405060708090a0b0c) [Hardware Error]: Tile1: DEVICE_MEMORY: testing HARDWARE signature

and btw, I will ask again, whether we want LOCATION/COMPONENT decoration as here:

Tile1: GT1: PROBE: testing software signature
Tile1: DEVICE_MEMORY: testing HARDWARE signature

I am aligned with this, we should print location/component.

Thanks,
Badal

Quoted 11 lines

or maybe in COMPONENT/LOCATION order:

PROBE: Tile1: GT1: testing software signature
DEVICE_MEMORY: Tile1: testing HARDWARE signature

if latter, then please comment patch 4/32

Quoted 3 lines

Thanks,
Badal

maintainer
#14 lore raw

Re: [PATCH v4 02/32] drm/xe/log: Add structured SIGID error logging infrastructure

In reply to Michal Wajdeczko
Quoted 97 lines · Michal Wajdeczko

From: Mallesh Koujalagi <[email protected]>

Today the driver reports faults with ad-hoc drm_err()/xe_gt_err() strings that have no stable shape. That is readable for a human, but it gives fleet tooling nothing durable to match on: the wording changes between releases, lines can be rate-limited or dropped under an error storm, and there is no consistent way to ask "which recognised fault just happened?".

Introduce a signature identifier (SIGID): a small, stable integer that names one recognised Xe fault site and serves as the primary handle for triage. A SIGID maps, through published end-user documentation, to a description and a recommended action; the driver only has to emit the right SIGID next to the usual human-readable text.

Assisted-by Copilot:Opus-4.8
Cc Riana Tauro <[email protected]>
Cc Stuart Summers <[email protected]>

---
Cc: Yoni Levitt <[email protected]>
Cc: Aravind Iddamsetty <[email protected]>
Cc: Raag Jadav <[email protected]>
---
v2: CORRECTED is still an error (Michal)
prepare to decorate dmesg with comp/loc (Michal)
v3: update SIGID DOC section (Riana/Aravind)
warn about unknown severity (Mallesh)

---
 Documentation/gpu/xe/index.rst        |   1 +
 Documentation/gpu/xe/xe_sigid.rst     |  14 +++
 drivers/gpu/drm/xe/Makefile           |   1 +
 drivers/gpu/drm/xe/abi/xe_sigid_abi.h | 159 ++++++++++++++++++++++++++
 drivers/gpu/drm/xe/xe_log.c           | 138 ++++++++++++++++++++++
 drivers/gpu/drm/xe/xe_log.h           |  20 ++++
 6 files changed, 333 insertions(+)
 create mode 100644 Documentation/gpu/xe/xe_sigid.rst
 create mode 100644 drivers/gpu/drm/xe/abi/xe_sigid_abi.h
 create mode 100644 drivers/gpu/drm/xe/xe_log.c
 create mode 100644 drivers/gpu/drm/xe/xe_log.h
Documentation/gpu/xe/index.rst +1 -0
index 665c0e93601c..0247a255f7e6 100644
@@ -35,3 +35,4 @@ The display, or :ref:`drm-kms`, support for drm/xe is provided by
    xe-drm-usage-stats.rst
    xe_configfs
    xe_gt_stats
+   xe_sigid
Documentation/gpu/xe/xe_sigid.rst new file +14 -0
new file mode 100644
index 000000000000..45d84a62f185
@@ -0,0 +1,14 @@
+.. SPDX-License-Identifier: (GPL-2.0+ OR MIT)
+
+========
+Xe SIGID
+========
+
+.. kernel-doc:: drivers/gpu/drm/xe/abi/xe_sigid_abi.h
+   :doc: Xe Error Signatures (SIGID)
+
+Signature Identifiers
+=====================
+
+.. kernel-doc:: drivers/gpu/drm/xe/abi/xe_sigid_abi.h
+   :internal:
drivers/gpu/drm/xe/Makefile +1 -0
index 44ed055439d4..92134709d998 100644
@@ -87,6 +87,7 @@ xe-y += xe_bb.o \
 	xe_hw_fence.o \
 	xe_irq.o \
 	xe_late_bind_fw.o \
+	xe_log.o \
 	xe_lrc.o \
 	xe_mem_pool.o \
 	xe_migrate.o \
drivers/gpu/drm/xe/abi/xe_sigid_abi.h new file +6 -0
new file mode 100644
index 000000000000..93967183ae51
@@ -0,0 +1,159 @@
+/* SPDX-License-Identifier: MIT */
+/*
+ * Copyright © 2026 Intel Corporation
+ */
+
+#ifndef _ABI_XE_SIGID_ABI_H_

drivers/gpu/drm/xe/abi/xe_sigid_abi.h line 16

Quoted 10 lines
drivers/gpu/drm/xe/abi/xe_sigid_abi.h new file +10 -0
+#define _ABI_XE_SIGID_ABI_H_
+
+/**
+ * DOC: Xe Error Signatures (SIGID)
+ *
+ * What SIGID stands for
+ * ---------------------
+ *
+ * SIGID is short for *Signature Identifier*. It is a small, stable integer
+ * that names one of *recognised fault site* -- nothing more. It is the

read better without the 'of'... or one of the ... sites (plural).

drivers/gpu/drm/xe/abi/xe_sigid_abi.h line 17

Quoted 1 line
drivers/gpu/drm/xe/abi/xe_sigid_abi.h new file +1 -0
+ * primary handle used for triage and maps directly to specific report site.

s/directly to specific/directly to a specific/

Quoted 36 lines
drivers/gpu/drm/xe/abi/xe_sigid_abi.h new file +36 -0
+ *
+ * Numbering
+ * ---------
+ *
+ * SIGIDs are a single flat list numbered sequentially within the assigned range,
+ * in the order the fault sites were introduced. Values are stable: once assigned
+ * they are only ever appended, never renumbered or reused. A retired fault site
+ * SIGID value is deprecated in place, never re-purposed.
+ *
+ * Why this exists
+ * ---------------
+ *
+ * Today the driver reports faults with ad-hoc ``xe_err()`` / ``xe_gt_err()``
+ * strings that have no stable shape. That is fine for a human reading dmesg,
+ * but it gives fleet tooling nothing durable to match on: the wording changes
+ * between releases, lines can be rate-limited or dropped under an error storm,
+ * and there is no consistent way to ask "which recognised fault just happened?"
+ *
+ * A SIGID answers exactly that one question, identically across driver and
+ * firmware versions, and (eventually) across other Intel devices in a node.
+ *
+ * What a SIGID is not
+ * -------------------
+ *
+ * SIGID deliberately does not encode the detailed reason or the outcome. Those
+ * are carried alongside it::
+ *
+ *   SIGID    -> which recognised fault site is being reported
+ *   severity -> how serious this instance is
+ *   errno    -> the failing operation's error, if available, shown with %pe
+ *   message  -> free-form human-readable context
+ *
+ * Severity is independent of the SIGID. The same SIGID can be reported at
+ * different severities depending on the instance and the recovery taken.
+ *
+ * When to use SIGID logging

drivers/gpu/drm/xe/abi/xe_sigid_abi.h line 63

Quoted 10 lines
drivers/gpu/drm/xe/abi/xe_sigid_abi.h new file +10 -0
+ * -------------------------
+ *
+ * The xe_log_*() helpers are for these recognised fault sites only --
+ * important, operator-relevant faults and events. The driver's only job is to
+ * emit the right SIGID next to the usual human-readable text.
+
+ * They are not a replacement for ``xe_info()`` / ``xe_dbg()`` / tracing, nor
+ * for one-off diagnostics; using them for ordinary logging would dilute the
+ * fault stream. Not every ``xe_err()`` needs to become a SIGID report -- only
+ * those that correspond to a published fault sites.

s/sites/site

correspond to a site (singular)

Quoted 190 lines
drivers/gpu/drm/xe/abi/xe_sigid_abi.h new file +96 -0
+ *
+ * SIGID log output (dmesg vs. the machine record)
+ * -----------------------------------------------
+ *
+ * The dmesg line stays close to a normal xe error message so it remains
+ * readable for admins; the only stable, machine-matchable token on it is
+ * ``SIGID=<n>`` (``dmesg | grep SIGID=``).
+ *
+ * The full dmesg line is not an ABI: the surrounding text may change freely,
+ * and lines may be dropped. The durable record for tooling is the CPER record
+ * carrying the same SIGID (generation is a planned follow-up).
+ *
+ * How to pick a SIGID (the uniqueness rule)
+ * -----------------------------------------
+ *
+ * Pick per *report site*, not per incident. Each site emits the single most
+ * specific recognised SIGID *for that site* -- so the question is never
+ * "classify this whole failure", it is "what does this site detect?", which has
+ * one answer. A single underlying failure therefore legitimately produces a
+ * *chain* of reports from different layers, each with its own SIGID -- e.g. a
+ * GuC communication failure is reported as %XE_SIGID_RUNTIME_FW by the firmware
+ * path, the failed recovery as %XE_SIGID_GT_TDR by the reset path, and an
+ * aborted bind as %XE_SIGID_PROBE by the probe path. That chain lets triage
+ * follow a fault from origin to final effect; it is not a duplicate.
+ *
+ * If a site does not match any defined SIGID, keep using the ordinary
+ * ``xe_err()`` / ``xe_gt_err()`` logging rather than forcing a SIGID: a wrong
+ * or over-broad classification is harder to retire than a missing one. When a
+ * new report site is genuinely worth triaging, add it to the list below.
+ *
+ * Usage of the existing SIGID reports must reevaluated according to this section
+ * after making significant changes to the site that emits this SIGID.
+ *
+ * Scope: software vs hardware emitted signatures
+ * ----------------------------------------------
+ *
+ * Some SIGID represents fault sites that the *driver itself* detects and
+ * reports from the software POV: probe abort, wedged, survivability, driver-
+ * detected firmware failures, engine TDR, memory faults and IO/bus faults.
+ * These are the only values the driver assigns on its own.
+ *
+ * Signatures that *originate* in firmware or hardware are a different thing:
+ * they are produced and identified by the firmware or the hardware itself
+ * (e.g. via their own records or error counters), and the driver merely logs
+ * them as they are given to us. They are deliberately enumerated separately.
+ *
+ * The two driver-detected firmware report sites below (%XE_SIGID_RUNTIME_FW,
+ * %XE_SIGID_DEVICE_FW) are software signatures: they mark that *the driver*
+ * observed a firmware problem, not a signature reported by the firmware.
+ */
+
+/*
+ * Top level Intel Error Signature Identifiers.
+ */
+#define INTEL_SIGID_INVALID			0
+#define INTEL_SIGID_BATCH			100
+#define INTEL_SIGID_RANGE_START(n)		((n) * INTEL_SIGID_BATCH)
+#define INTEL_SIGID_RANGE_END(n)		(INTEL_SIGID_RANGE_START((n) + 1) - 1)
+
+/* SIGIDs 1xx are reserved for Xe GPU software and 2xx for Xe GPU hardware */
+#define INTEL_SIGID_GPU_XE_SOFTWARE_START	INTEL_SIGID_RANGE_START(1)
+#define INTEL_SIGID_GPU_XE_SOFTWARE_END		INTEL_SIGID_RANGE_END(1)
+#define INTEL_SIGID_GPU_XE_HARDWARE_START	INTEL_SIGID_RANGE_START(2)
+#define INTEL_SIGID_GPU_XE_HARDWARE_END		INTEL_SIGID_RANGE_END(2)
+
+/**
+ * enum xe_sigid - Stable Xe Error Signature Identifiers (SIGID).
+ * @XE_SIGID_SW: Software component failure.
+ * @XE_SIGID_PROBE: Device probe/bind was aborted.
+ * @XE_SIGID_WEDGED: Device was declared wedged and is no longer usable.
+ * @XE_SIGID_SURVIVABILITY: Device entered survivability mode.
+ * @XE_SIGID_RUNTIME_FW: Driver-detected runtime firmware failure, GuC/HuC/GSC.
+ * @XE_SIGID_DEVICE_FW: Driver-detected device firmware failure, PCODE/sysctrl.
+ * @XE_SIGID_GT_TDR: Engine hang / timeout detection and recovery (reset).
+ * @XE_SIGID_MEM_FAULT: VM bind, page fault or GTT fault.
+ * @XE_SIGID_IO_BUS: Runtime PCIe / IOMMU / MMIO access fault.
+ *
+ * Each SIGID represents the report sites the driver detects and reports.
+ * Values are numbered sequentially, are only ever appended, and are never
+ * renumbered or reused.
+ *
+ * Firmware- and hardware-originated signatures are not listed yet here.
+ */
+enum xe_sigid {
+	XE_SIGID_SW			= INTEL_SIGID_GPU_XE_SOFTWARE_START,
+	XE_SIGID_PROBE			= INTEL_SIGID_GPU_XE_SOFTWARE_START + 1,
+	XE_SIGID_WEDGED			= INTEL_SIGID_GPU_XE_SOFTWARE_START + 2,
+	XE_SIGID_SURVIVABILITY		= INTEL_SIGID_GPU_XE_SOFTWARE_START + 3,
+	XE_SIGID_RUNTIME_FW		= INTEL_SIGID_GPU_XE_SOFTWARE_START + 4,
+	XE_SIGID_DEVICE_FW		= INTEL_SIGID_GPU_XE_SOFTWARE_START + 5,
+	XE_SIGID_GT_TDR			= INTEL_SIGID_GPU_XE_SOFTWARE_START + 6,
+	XE_SIGID_MEM_FAULT		= INTEL_SIGID_GPU_XE_SOFTWARE_START + 7,
+	XE_SIGID_IO_BUS			= INTEL_SIGID_GPU_XE_SOFTWARE_START + 8,
+};
+
+#endif
drivers/gpu/drm/xe/xe_log.c new file +88 -0
new file mode 100644
index 000000000000..ae4f6e33f5b8
@@ -0,0 +1,138 @@
+// SPDX-License-Identifier: MIT
+/*
+ * Copyright © 2026 Intel Corporation
+ */
+
+#include "xe_log.h"
+#include "xe_printk.h"
+
+static void log_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)
+{
+	/* TODO */
+}
+
+static bool is_hw_sigid(enum xe_sigid sigid)
+{
+	return (int)sigid >= INTEL_SIGID_GPU_XE_HARDWARE_START;
+}
+
+static bool is_sev_error(int cper_sev)
+{
+	return cper_sev != CPER_SEV_INFORMATIONAL;
+}
+
+static const char *log_hwe_prefix(int cper_sev, enum xe_sigid sigid)
+{
+	return is_sev_error(cper_sev) && is_hw_sigid(sigid) ? HW_ERR : "";
+}
+
+static const char *log_sev_prefix(int cper_sev)
+{
+	switch (cper_sev) {
+	case CPER_SEV_FATAL:
+		return "FATAL ";
+	case CPER_SEV_RECOVERABLE:
+		return "";
+	case CPER_SEV_CORRECTED:
+		return "CORRECTED ";
+	case CPER_SEV_INFORMATIONAL:
+		return "";
+	default:
+		WARN(IS_ENABLED(CONFIG_DRM_XE_DEBUG), "LOG: unknown severity %d\n", cper_sev);
+		return "";
+	}
+}
+
+#define __LOG_DRM_PRINTK_FMT(fmt, args...)	"[drm] " fmt, ##args
+#define __LOG_DRM_PRINTK_ERR_FMT(fmt, args...)	__LOG_DRM_PRINTK_FMT("*ERROR* " fmt, args)
+
+static void log_dmesg_vprintk(struct pci_dev *pdev, int cper_sev, struct va_format *vaf)
+{
+	if (cper_sev == CPER_SEV_INFORMATIONAL)
+		pci_info(pdev, __LOG_DRM_PRINTK_FMT("%pV", vaf));
+	else
+		pci_err(pdev, __LOG_DRM_PRINTK_ERR_FMT("%pV", vaf));
+}
+
+static void log_dmesg_printf(struct pci_dev *pdev, int cper_sev, const char *fmt, ...)
+{
+	struct va_format vaf;
+	va_list args;
+
+	va_start(args, fmt);
+	vaf.fmt = fmt;
+	vaf.va = &args;
+
+	log_dmesg_vprintk(pdev, cper_sev, &vaf);
+
+	va_end(args);
+}
+
+static void log_emit_dmesg(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)
+{
+	const char *hwe_prefix = log_hwe_prefix(cper_sev, sigid);
+	const char *sev_prefix = log_sev_prefix(cper_sev);
+
+	/* TODO: add component/location details */
+
+	if (IS_ERR(data))
+		log_dmesg_printf(pdev, cper_sev, "SIGID=%u %s(%pe) %s%pV",
+				 sigid, sev_prefix, data, hwe_prefix, vaf);
+	else if (data && len)
+		log_dmesg_printf(pdev, cper_sev, "SIGID=%u %s(%*phN) %s%pV",
+				 sigid, sev_prefix, (int)len, data, hwe_prefix, vaf);
+	else

drivers/gpu/drm/xe/xe_log.c line 98

Quoted 10 lines
drivers/gpu/drm/xe/xe_log.c new file +10 -0
+		log_dmesg_printf(pdev, cper_sev, "SIGID=%u %s%s%pV",
+				 sigid, sev_prefix, hwe_prefix, vaf);
+}
+
+/**
+ * xe_log_emit() - Emit a structured SIGID log entry
+ * @pdev: the &pci_dev device
+ * @cper_sev: CPER severity (CPER_SEV_FATAL, CPER_SEV_RECOVERABLE, ...)
+ * @sigid: signature identifier, see &enum xe_sigid
+ * @component: component identifer

identifier

Quoted 69 lines
drivers/gpu/drm/xe/xe_log.c new file +40 -0
+ * @location: location details of the @component
+ * @data: pointer to the additional details, or ERR_PTR, or NULL if not applicable
+ * @len: length of the @data in bytes, or 0 if not applicable
+ * @fmt: printf-style format string
+ * @...: format arguments
+ *
+ * Emits a dmesg line that includes a single stable, machine-matchable token
+ * ``SIGID=<n>`` followed by the optional severity token (like ``FATAL``) and,
+ * when @data pointer is set, either the error printed with %pe or a packed hex
+ * dump of the @data binary blob. The dmesg line will also include printf-style
+ * text message.
+ *
+ * Note that the full dmesg line, with the free text message, is only a debugging
+ * aid, not an interface! Only the ``SIGID=<n>`` token is stable there.
+ * The durable machine record is the CPER carrying the same SIGID.
+ *
+ * Note: generation of the CPER record is a planned follow-up.
+ *
+ * Examples::
+ *
+ *   <3> xe 0000:03:00.0: [drm] *ERROR* SIGID=104 FATAL (-EPROTO) Invalid GuC reply
+ *   <3> xe 0000:03:00.0: [drm] *ERROR* SIGID=106 (-ETIMEDOUT) Engine 'rcs0' hung
+ *   <6> xe 0000:03:00.0: [drm] SIGID=103 In survivability mode
+ */
+void xe_log_emit(struct pci_dev *pdev, int cper_sev, enum xe_sigid sigid,
+		 u32 component, u32 location, const void *data, size_t len,
+		 const char *fmt, ...)
+{
+	struct va_format vaf;
+	va_list args;
+
+	va_start(args, fmt);
+	vaf.fmt = fmt;
+	vaf.va = &args;
+
+	log_emit_dmesg(pdev, cper_sev, sigid, component, location, data, len, &vaf);
+	log_emit_cper(pdev, cper_sev, sigid, component, location, data, len, &vaf);
+
+	va_end(args);
+}
drivers/gpu/drm/xe/xe_log.h new file +20 -0
new file mode 100644
index 000000000000..d475e816ee0b
@@ -0,0 +1,20 @@
+/* SPDX-License-Identifier: MIT */
+/*
+ * Copyright © 2026 Intel Corporation
+ */
+
+#ifndef _XE_LOG_H_
+#define _XE_LOG_H_
+
+#include <linux/cper.h>
+
+#include "abi/xe_sigid_abi.h"
+
+struct pci_dev;
+
+__printf(8, 9)
+void xe_log_emit(struct pci_dev *pdev, int cper_sev, enum xe_sigid sigid,
+		 u32 component, u32 location, const void *data, size_t len,
+		 const char *fmt, ...);
+
+#endif
Signature · 1 line
2.47.1
#15 lore raw

Re: [PATCH v4 02/32] drm/xe/log: Add structured SIGID error logging infrastructure

In reply to Michal Wajdeczko

Adding a few more review comments.

Quoted 185 lines · Michal Wajdeczko

From: Mallesh Koujalagi<[email protected]>

Today the driver reports faults with ad-hoc drm_err()/xe_gt_err() strings that have no stable shape. That is readable for a human, but it gives fleet tooling nothing durable to match on: the wording changes between releases, lines can be rate-limited or dropped under an error storm, and there is no consistent way to ask "which recognised fault just happened?".

Introduce a signature identifier (SIGID): a small, stable integer that names one recognised Xe fault site and serves as the primary handle for triage. A SIGID maps, through published end-user documentation, to a description and a recommended action; the driver only has to emit the right SIGID next to the usual human-readable text.

Assisted-by Copilot:Opus-4.8
Cc Riana Tauro<[email protected]>
Cc Stuart Summers<[email protected]>

---
Cc: Yoni Levitt<[email protected]>
Cc: Aravind Iddamsetty<[email protected]>
Cc: Raag Jadav<[email protected]>
---
v2: CORRECTED is still an error (Michal)
prepare to decorate dmesg with comp/loc (Michal)
v3: update SIGID DOC section (Riana/Aravind)
warn about unknown severity (Mallesh)

---
  Documentation/gpu/xe/index.rst        |   1 +
  Documentation/gpu/xe/xe_sigid.rst     |  14 +++
  drivers/gpu/drm/xe/Makefile           |   1 +
  drivers/gpu/drm/xe/abi/xe_sigid_abi.h | 159 ++++++++++++++++++++++++++
  drivers/gpu/drm/xe/xe_log.c           | 138 ++++++++++++++++++++++
  drivers/gpu/drm/xe/xe_log.h           |  20 ++++
  6 files changed, 333 insertions(+)

create mode 100644 Documentation/gpu/xe/xe_sigid.rst create mode 100644 drivers/gpu/drm/xe/abi/xe_sigid_abi.h create mode 100644 drivers/gpu/drm/xe/xe_log.c create mode 100644 drivers/gpu/drm/xe/xe_log.h

Documentation/gpu/xe/index.rst +1 -0
index 665c0e93601c..0247a255f7e6 100644
@@ -35,3 +35,4 @@ The display, or :ref:`drm-kms`, support for drm/xe is provided by
     xe-drm-usage-stats.rst
     xe_configfs
     xe_gt_stats
+   xe_sigid
Documentation/gpu/xe/xe_sigid.rst new file +14 -0
new file mode 100644
index 000000000000..45d84a62f185
@@ -0,0 +1,14 @@
+.. SPDX-License-Identifier: (GPL-2.0+ OR MIT)
+
+========
+Xe SIGID
+========
+
+.. kernel-doc:: drivers/gpu/drm/xe/abi/xe_sigid_abi.h
+   :doc: Xe Error Signatures (SIGID)
+
+Signature Identifiers
+=====================
+
+.. kernel-doc:: drivers/gpu/drm/xe/abi/xe_sigid_abi.h
+   :internal:
drivers/gpu/drm/xe/Makefile +1 -0
index 44ed055439d4..92134709d998 100644
@@ -87,6 +87,7 @@ xe-y += xe_bb.o \
  	xe_hw_fence.o \
  	xe_irq.o \
  	xe_late_bind_fw.o \
+	xe_log.o \
  	xe_lrc.o \
  	xe_mem_pool.o \
  	xe_migrate.o \
drivers/gpu/drm/xe/abi/xe_sigid_abi.h new file +81 -0
new file mode 100644
index 000000000000..93967183ae51
@@ -0,0 +1,159 @@
+/* SPDX-License-Identifier: MIT */
+/*
+ * Copyright © 2026 Intel Corporation
+ */
+
+#ifndef _ABI_XE_SIGID_ABI_H_
+#define _ABI_XE_SIGID_ABI_H_
+
+/**
+ * DOC: Xe Error Signatures (SIGID)
+ *
+ * What SIGID stands for
+ * ---------------------
+ *
+ * SIGID is short for *Signature Identifier*. It is a small, stable integer
+ * that names one of *recognised fault site* -- nothing more. It is the
+ * primary handle used for triage and maps directly to specific report site.
+ *
+ * Numbering
+ * ---------
+ *
+ * SIGIDs are a single flat list numbered sequentially within the assigned range,
+ * in the order the fault sites were introduced. Values are stable: once assigned
+ * they are only ever appended, never renumbered or reused. A retired fault site
+ * SIGID value is deprecated in place, never re-purposed.
+ *
+ * Why this exists
+ * ---------------
+ *
+ * Today the driver reports faults with ad-hoc ``xe_err()`` / ``xe_gt_err()``
+ * strings that have no stable shape. That is fine for a human reading dmesg,
+ * but it gives fleet tooling nothing durable to match on: the wording changes
+ * between releases, lines can be rate-limited or dropped under an error storm,
+ * and there is no consistent way to ask "which recognised fault just happened?"
+ *
+ * A SIGID answers exactly that one question, identically across driver and
+ * firmware versions, and (eventually) across other Intel devices in a node.
+ *
+ * What a SIGID is not
+ * -------------------
+ *
+ * SIGID deliberately does not encode the detailed reason or the outcome. Those
+ * are carried alongside it::
+ *
+ *   SIGID    -> which recognised fault site is being reported
+ *   severity -> how serious this instance is
+ *   errno    -> the failing operation's error, if available, shown with %pe
+ *   message  -> free-form human-readable context
+ *
+ * Severity is independent of the SIGID. The same SIGID can be reported at
+ * different severities depending on the instance and the recovery taken.
+ *
+ * When to use SIGID logging
+ * -------------------------
+ *
+ * The xe_log_*() helpers are for these recognised fault sites only --
+ * important, operator-relevant faults and events. The driver's only job is to
+ * emit the right SIGID next to the usual human-readable text.
+
+ * They are not a replacement for ``xe_info()`` / ``xe_dbg()`` / tracing, nor
+ * for one-off diagnostics; using them for ordinary logging would dilute the
+ * fault stream. Not every ``xe_err()`` needs to become a SIGID report -- only
+ * those that correspond to a published fault sites.
+ *
+ * SIGID log output (dmesg vs. the machine record)
+ * -----------------------------------------------
+ *
+ * The dmesg line stays close to a normal xe error message so it remains
+ * readable for admins; the only stable, machine-matchable token on it is
+ * ``SIGID=<n>`` (``dmesg | grep SIGID=``).
+ *
+ * The full dmesg line is not an ABI: the surrounding text may change freely,
+ * and lines may be dropped. The durable record for tooling is the CPER record
+ * carrying the same SIGID (generation is a planned follow-up).
+ *
+ * How to pick a SIGID (the uniqueness rule)
+ * -----------------------------------------
+ *
+ * Pick per *report site*, not per incident. Each site emits the single most
+ * specific recognised SIGID *for that site* -- so the question is never
+ * "classify this whole failure", it is "what does this site detect?", which has + * one answer. A single underlying failure therefore 

legitimately produces a + * *chain* of reports from different layers, each with its own SIGID -- e.g. a + * GuC communication failure is reported as %XE_SIGID_RUNTIME_FW by the firmware + * path, the failed recovery as %XE_SIGID_GT_TDR by the reset path, and an + * aborted bind as %XE_SIGID_PROBE by the probe path. That chain lets triage + * follow a fault from origin to final effect; it is not a duplicate. + *
+ * If a site does not match any defined SIGID, keep using the
ordinary + * ``xe_err()`` / ``xe_gt_err()`` logging rather than forcing a SIGID: a wrong + * or over-broad classification is harder to retire than a missing one. When a + * new report site is genuinely worth triaging, add it to the list below. + * + * Usage of the existing SIGID reports must reevaluated according to this section + * after making significant changes to the site that emits this SIGID. + * + * Scope: software vs hardware emitted signatures + *
---------------------------------------------- + * + * Some SIGID
represents fault sites that the *driver itself* detects and + * reports from the software POV: probe abort, wedged, survivability, driver- + * detected firmware failures, engine TDR, memory faults and IO/bus faults. + * These are the only values the driver assigns on its own. + * + * Signatures that *originate* in firmware or hardware are a different thing: + * they are produced and identified by the firmware or the hardware itself + * (e.g. via their own records or error counters), and the driver merely logs + * them as they are given to us. They are deliberately enumerated separately. + * + * The two driver-detected firmware report sites below (%XE_SIGID_RUNTIME_FW, + * %XE_SIGID_DEVICE_FW) are software signatures: they mark that *the driver* + * observed a firmware problem, not a signature reported by the firmware. + */ + +/* + * Top level Intel Error Signature Identifiers. + */ +#define INTEL_SIGID_INVALID 0 +#define INTEL_SIGID_BATCH 100 +#define INTEL_SIGID_RANGE_START(n) ((n) * INTEL_SIGID_BATCH) +#define INTEL_SIGID_RANGE_END(n) (INTEL_SIGID_RANGE_START((n) + 1) - 1) + +/* SIGIDs 1xx are reserved for Xe GPU software and 2xx for Xe GPU hardware */ +#define INTEL_SIGID_GPU_XE_SOFTWARE_START INTEL_SIGID_RANGE_START(1) +#define INTEL_SIGID_GPU_XE_SOFTWARE_END INTEL_SIGID_RANGE_END(1) +#define INTEL_SIGID_GPU_XE_HARDWARE_START INTEL_SIGID_RANGE_START(2) +#define INTEL_SIGID_GPU_XE_HARDWARE_END INTEL_SIGID_RANGE_END(2) + +/** + * enum xe_sigid - Stable Xe Error Signature Identifiers (SIGID). + * @XE_SIGID_SW: Software component failure. + * @XE_SIGID_PROBE: Device
probe/bind was aborted. + * @XE_SIGID_WEDGED: Device was declared wedged and is no longer usable. + * @XE_SIGID_SURVIVABILITY: Device entered survivability mode. + * @XE_SIGID_RUNTIME_FW: Driver-detected runtime firmware failure, GuC/HuC/GSC. + * @XE_SIGID_DEVICE_FW: Driver-detected device firmware failure, PCODE/sysctrl. + *
@XE_SIGID_GT_TDR: Engine hang / timeout detection and recovery
(reset). + * @XE_SIGID_MEM_FAULT: VM bind, page fault or GTT fault. + * @XE_SIGID_IO_BUS: Runtime PCIe / IOMMU / MMIO access fault. + * + * Each SIGID represents the report sites the driver detects and reports.
+ * Values are numbered sequentially, are only ever appended, and are
never + * renumbered or reused. + * + * Firmware- and hardware-originated signatures are not listed yet here. + */ +enum xe_sigid { + XE_SIGID_SW = INTEL_SIGID_GPU_XE_SOFTWARE_START, + XE_SIGID_PROBE = INTEL_SIGID_GPU_XE_SOFTWARE_START + 1, + XE_SIGID_WEDGED = INTEL_SIGID_GPU_XE_SOFTWARE_START + 2, + XE_SIGID_SURVIVABILITY = INTEL_SIGID_GPU_XE_SOFTWARE_START + 3, + XE_SIGID_RUNTIME_FW = INTEL_SIGID_GPU_XE_SOFTWARE_START + 4, + XE_SIGID_DEVICE_FW = INTEL_SIGID_GPU_XE_SOFTWARE_START + 5, + XE_SIGID_GT_TDR = INTEL_SIGID_GPU_XE_SOFTWARE_START + 6, + XE_SIGID_MEM_FAULT = INTEL_SIGID_GPU_XE_SOFTWARE_START + 7, + XE_SIGID_IO_BUS = INTEL_SIGID_GPU_XE_SOFTWARE_START + 8, +}; + +#endif diff --git a/drivers/gpu/drm/xe/xe_log.c b/drivers/gpu/drm/xe/xe_log.c new file mode 100644 index 000000000000..ae4f6e33f5b8 --- /dev/null
+++ b/drivers/gpu/drm/xe/xe_log.c @@ -0,0 +1,138 @@ +//
SPDX-License-Identifier: MIT +/* + * Copyright © 2026 Intel Corporation + */ + +#include "xe_log.h"

drivers/gpu/drm/xe/abi/xe_sigid_abi.h

Quoted 7 lines
drivers/gpu/drm/xe/abi/xe_sigid_abi.h new file +7 -0
+#include "xe_printk.h"
+
+static void log_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)
+{
+	/* TODO */

Just for information, CPER log construction for hardware errors involves a system controller mailbox interaction, with the error_class passed via the data payload.

Quoted 14 lines
drivers/gpu/drm/xe/abi/xe_sigid_abi.h new file +14 -0
+}
+
+static bool is_hw_sigid(enum xe_sigid sigid)
+{
+	return (int)sigid >= INTEL_SIGID_GPU_XE_HARDWARE_START;
+}
+
+static bool is_sev_error(int cper_sev)
+{
+	return cper_sev != CPER_SEV_INFORMATIONAL;
+}
+
+static const char *log_hwe_prefix(int cper_sev, enum xe_sigid sigid)
+{

drivers/gpu/drm/xe/abi/xe_sigid_abi.h

Quoted 10 lines
drivers/gpu/drm/xe/abi/xe_sigid_abi.h new file +10 -0
+	return is_sev_error(cper_sev) && is_hw_sigid(sigid) ? HW_ERR : "";
+}
+
+static const char *log_sev_prefix(int cper_sev)
+{
+	switch (cper_sev) {
+	case CPER_SEV_FATAL:
+		return "FATAL ";
+	case CPER_SEV_RECOVERABLE:
+		return "";

Can we print "RECOVERABLE" here? In my earlier comment I mistakenly used "CORRECTABLE"; I meant "RECOVERABLE".

Thanks,
Badal

Quoted 127 lines
drivers/gpu/drm/xe/abi/xe_sigid_abi.h new file +101 -0
+	case CPER_SEV_CORRECTED:
+		return "CORRECTED ";
+	case CPER_SEV_INFORMATIONAL:
+		return "";
+	default:
+		WARN(IS_ENABLED(CONFIG_DRM_XE_DEBUG), "LOG: unknown severity %d\n", cper_sev);
+		return "";
+	}
+}
+
+#define __LOG_DRM_PRINTK_FMT(fmt, args...)	"[drm] " fmt, ##args
+#define __LOG_DRM_PRINTK_ERR_FMT(fmt, args...)	__LOG_DRM_PRINTK_FMT("*ERROR* " fmt, args)
+
+static void log_dmesg_vprintk(struct pci_dev *pdev, int cper_sev, struct va_format *vaf)
+{
+	if (cper_sev == CPER_SEV_INFORMATIONAL)
+		pci_info(pdev, __LOG_DRM_PRINTK_FMT("%pV", vaf));
+	else
+		pci_err(pdev, __LOG_DRM_PRINTK_ERR_FMT("%pV", vaf));
+}
+
+static void log_dmesg_printf(struct pci_dev *pdev, int cper_sev, const char *fmt, ...)
+{
+	struct va_format vaf;
+	va_list args;
+
+	va_start(args, fmt);
+	vaf.fmt = fmt;
+	vaf.va = &args;
+
+	log_dmesg_vprintk(pdev, cper_sev, &vaf);
+
+	va_end(args);
+}
+
+static void log_emit_dmesg(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)
+{
+	const char *hwe_prefix = log_hwe_prefix(cper_sev, sigid);
+	const char *sev_prefix = log_sev_prefix(cper_sev);
+
+	/* TODO: add component/location details */
+
+	if (IS_ERR(data))
+		log_dmesg_printf(pdev, cper_sev, "SIGID=%u %s(%pe) %s%pV",
+				 sigid, sev_prefix, data, hwe_prefix, vaf);
+	else if (data && len)
+		log_dmesg_printf(pdev, cper_sev, "SIGID=%u %s(%*phN) %s%pV",
+				 sigid, sev_prefix, (int)len, data, hwe_prefix, vaf);
+	else
+		log_dmesg_printf(pdev, cper_sev, "SIGID=%u %s%s%pV",
+				 sigid, sev_prefix, hwe_prefix, vaf);
+}
+
+/**
+ * xe_log_emit() - Emit a structured SIGID log entry
+ * @pdev: the &pci_dev device
+ * @cper_sev: CPER severity (CPER_SEV_FATAL, CPER_SEV_RECOVERABLE, ...)
+ * @sigid: signature identifier, see &enum xe_sigid
+ * @component: component identifer
+ * @location: location details of the @component
+ * @data: pointer to the additional details, or ERR_PTR, or NULL if not applicable
+ * @len: length of the @data in bytes, or 0 if not applicable
+ * @fmt: printf-style format string
+ * @...: format arguments
+ *
+ * Emits a dmesg line that includes a single stable, machine-matchable token
+ * ``SIGID=<n>`` followed by the optional severity token (like ``FATAL``) and,
+ * when @data pointer is set, either the error printed with %pe or a packed hex
+ * dump of the @data binary blob. The dmesg line will also include printf-style
+ * text message.
+ *
+ * Note that the full dmesg line, with the free text message, is only a debugging
+ * aid, not an interface! Only the ``SIGID=<n>`` token is stable there.
+ * The durable machine record is the CPER carrying the same SIGID.
+ *
+ * Note: generation of the CPER record is a planned follow-up.
+ *
+ * Examples::
+ *
+ *   <3> xe 0000:03:00.0: [drm] *ERROR* SIGID=104 FATAL (-EPROTO) Invalid GuC reply
+ *   <3> xe 0000:03:00.0: [drm] *ERROR* SIGID=106 (-ETIMEDOUT) Engine 'rcs0' hung
+ *   <6> xe 0000:03:00.0: [drm] SIGID=103 In survivability mode
+ */
+void xe_log_emit(struct pci_dev *pdev, int cper_sev, enum xe_sigid sigid,
+		 u32 component, u32 location, const void *data, size_t len,
+		 const char *fmt, ...)
+{
+	struct va_format vaf;
+	va_list args;
+
+	va_start(args, fmt);
+	vaf.fmt = fmt;
+	vaf.va = &args;
+
+	log_emit_dmesg(pdev, cper_sev, sigid, component, location, data, len, &vaf);
+	log_emit_cper(pdev, cper_sev, sigid, component, location, data, len, &vaf);
+
+	va_end(args);
+}
drivers/gpu/drm/xe/xe_log.h new file +20 -0
new file mode 100644
index 000000000000..d475e816ee0b
@@ -0,0 +1,20 @@
+/* SPDX-License-Identifier: MIT */
+/*
+ * Copyright © 2026 Intel Corporation
+ */
+
+#ifndef _XE_LOG_H_
+#define _XE_LOG_H_
+
+#include <linux/cper.h>
+
+#include "abi/xe_sigid_abi.h"
+
+struct pci_dev;
+
+__printf(8, 9)
+void xe_log_emit(struct pci_dev *pdev, int cper_sev, enum xe_sigid sigid,
+		 u32 component, u32 location, const void *data, size_t len,
+		 const char *fmt, ...);
+
+#endif
#16 lore raw

Re: [PATCH v4 02/32] drm/xe/log: Add structured SIGID error logging infrastructure

Quoted 5 lines · Badal

Adding a few more review comments.

Quoted 2 lines · Michal Wajdeczko

From: Mallesh Koujalagi <[email protected]>

...

Quoted 27 lines

drivers/gpu/drm/xe/xe_log.c line 13

Quoted 6 lines
drivers/gpu/drm/xe/xe_log.c new file +6 -0
+
+static void log_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)
+{
+	/* TODO */

Just for information, CPER log construction for hardware errors involves a system controller mailbox interaction, with the error_class passed via the data payload.

Quoted 18 lines
drivers/gpu/drm/xe/xe_log.c new file +18 -0
+}
+
+static bool is_hw_sigid(enum xe_sigid sigid)
+{
+	return (int)sigid >= INTEL_SIGID_GPU_XE_HARDWARE_START;
+}
+
+static bool is_sev_error(int cper_sev)
+{
+	return cper_sev != CPER_SEV_INFORMATIONAL;
+}
+
+static const char *log_hwe_prefix(int cper_sev, enum xe_sigid sigid)
+{
+	return is_sev_error(cper_sev) && is_hw_sigid(sigid) ? HW_ERR : "";
+}
+
+static const char *log_sev_prefix(int cper_sev)
Quoted 8 lines

drivers/gpu/drm/xe/xe_log.c line 37

Quoted 6 lines
drivers/gpu/drm/xe/xe_log.c new file +6 -0
+{
+	switch (cper_sev) {
+	case CPER_SEV_FATAL:
+		return "FATAL ";
+	case CPER_SEV_RECOVERABLE:
+		return "";

Can we print "RECOVERABLE" here? In my earlier comment I mistakenly used "CORRECTABLE"; I meant "RECOVERABLE".

but this is to some extend redundant information:
if it isn't a FATAL or CORRECTED, then it must be RECOVERABLE, no?

the same as we don't add "INFORMATIONAL" since dmesg is already using KERN_INFO level

Quoted 14 lines

Thanks,
Badal

Quoted 10 lines
drivers/gpu/drm/xe/xe_log.c new file +10 -0
+	case CPER_SEV_CORRECTED:
+		return "CORRECTED ";
+	case CPER_SEV_INFORMATIONAL:
+		return "";
+	default:
+		WARN(IS_ENABLED(CONFIG_DRM_XE_DEBUG), "LOG: unknown severity %d\n", cper_sev);
+		return "";
+	}
+}
+
#17 lore raw

PATCH v4 3/32 drm/xe/log: Introduce structured component/location identifiers

In reply to Michal Wajdeczko

Introduce structured identifiers for each component type that could emit a SIGID log entry and for their locations. We plan to store those IDs in the CPER records for better filtering. Define also structured identifiers for the supported locations.

---
Cc: Aravind Iddamsetty <[email protected]>
Cc: Mallesh Koujalagi <[email protected]>
Cc: Raag Jadav <[email protected]>
Cc: Riana Tauro <[email protected]>
---
v2: fix typo, define reserved ids (Michal)
v3: fix kernel-doc to match code (Sashiko)
v4: update comment (Michal)

---
 drivers/gpu/drm/xe/abi/xe_log_abi.h | 187 ++++++++++++++++++++++++++++
 1 file changed, 187 insertions(+)
 create mode 100644 drivers/gpu/drm/xe/abi/xe_log_abi.h
drivers/gpu/drm/xe/abi/xe_log_abi.h new file +187 -0
new file mode 100644
index 000000000000..92547805326f
@@ -0,0 +1,187 @@
+/* SPDX-License-Identifier: MIT */
+/*
+ * Copyright © 2026 Intel Corporation
+ */
+
+#ifndef _ABI_XE_LOG_ABI_H_
+#define _ABI_XE_LOG_ABI_H_
+
+#include <linux/bits.h>
+#include <linux/bitfield.h>
+
+#include "abi/xe_sigid_abi.h"
+
+/**
+ * enum xe_log_component_bits - bits for components structure definitions
+ *
+ * Component identifiers are structured based on::
+ *
+ *     COMPONENT = CLASS(8b).TYPE(8b)
+ *
+ * and the structure looks like this::
+ *
+ *     ├── SYSTEM(0)
+ *     │   └── ...
+ *     ├── DRIVER(1)
+ *     │   └── ...
+ *     ├── FEATURE(2)
+ *     │   └── ...
+ *     ├── FIRMWARE(4)
+ *     │   └── ...
+ *     └── HARDWARE(8)
+ *         └── ...
+ *
+ * Examples::
+ *
+ *     COMPONENT(0.type) = SYSTEM.type = system component
+ *     COMPONENT(1.type) = DRIVER.type = driver core component
+ *     COMPONENT(3.type) = DRIVER_FEATURE.type = driver feature
+ *     COMPONENT(5.type) = DRIVER_FIRMWARE.type = firmware driver component
+ *     COMPONENT(9.type) = DRIVER_HARDWARE.type = hardware driver component
+ *
+ */
+enum xe_log_component_bits {
+	/* private: */
+	XE_LOG_COMPONENT_CLASS_MASK = GENMASK_U16(7, 0),
+	XE_LOG_COMPONENT_TYPE_MASK = GENMASK_U16(15, 8),
+	/* private: component classes */
+	XE_LOG_COMPONENT_CLASS_SYSTEM = 0u,
+	XE_LOG_COMPONENT_CLASS_DRIVER = 1u,
+	XE_LOG_COMPONENT_CLASS_FEATURE = 2u,
+	XE_LOG_COMPONENT_CLASS_FIRMWARE = 4u,
+	XE_LOG_COMPONENT_CLASS_HARDWARE = 8u,
+	XE_LOG_COMPONENT_CLASS_DRIVER_FEATURE = XE_LOG_COMPONENT_CLASS_DRIVER |
+						XE_LOG_COMPONENT_CLASS_FEATURE,
+	XE_LOG_COMPONENT_CLASS_DRIVER_FIRMWARE = XE_LOG_COMPONENT_CLASS_DRIVER |
+						 XE_LOG_COMPONENT_CLASS_FIRMWARE,
+	XE_LOG_COMPONENT_CLASS_DRIVER_HARDWARE = XE_LOG_COMPONENT_CLASS_DRIVER |
+						 XE_LOG_COMPONENT_CLASS_HARDWARE,
+	/* private: reserved identifiers */
+	XE_LOG_COMPONENT_NONE = 0u,
+};
+
+#define MAKE_XE_LOG_COMPONENT(_CLASS, type) \
+	(FIELD_PREP_CONST(XE_LOG_COMPONENT_CLASS_MASK, \
+			  XE_LOG_COMPONENT_CLASS_##_CLASS) | \
+	 FIELD_PREP_CONST(XE_LOG_COMPONENT_TYPE_MASK, (type)))
+
+/**
+ * enum xe_log_location_bits - bits for location structure definitions
+ *
+ * Location identifiers are structured based on::
+ *
+ *     LOCATION = TYPE(8b).ID(8b)
+ *
+ * and the structure looks like this::
+ *
+ *     ├── DEVICE(0)
+ *     │   └── MBZ(0)
+ *     ├── TILE(1)
+ *     │   ├── Tile0(0)
+ *     │   ├── ...
+ *     │   └── TileN(n)
+ *     ├── GT(1)
+ *     │   ├── GT0(0)
+ *     │   ├── ...
+ *     │   └── GTn(n)
+ *     └── ...
+ *
+ * Examples::
+ *
+ *     LOCATION(0.0) = NONE
+ *     LOCATION(1.0) = DEVICE.0 = "Device"
+ *     LOCATION(2.1) = TILE.1 = "Tile1"
+ *     LOCATION(3.2) = GT.2 = "GT2"
+ *
+ */
+enum xe_log_location_bits {
+	/* private: */
+	XE_LOG_LOCATION_TYPE_MASK = GENMASK_U16(7, 0),
+	XE_LOG_LOCATION_ID_MASK = GENMASK_U16(15, 8),
+	/* private: location types */
+	XE_LOG_LOCATION_TYPE_DEVICE = 1u,
+	XE_LOG_LOCATION_TYPE_TILE = 2u,
+	XE_LOG_LOCATION_TYPE_GT = 3u,
+	/* private: reserved identifiers */
+	XE_LOG_LOCATION_NONE = 0u,
+};
+
+#define PREP_XE_LOG_LOCATION(type, id) \
+	(FIELD_PREP(XE_LOG_LOCATION_TYPE_MASK, (type)) | \
+	 FIELD_PREP(XE_LOG_LOCATION_ID_MASK, (id)))
+
+#define MAKE_XE_LOG_LOCATION(_TYPE, id) \
+	PREP_XE_LOG_LOCATION(XE_LOG_LOCATION_TYPE_##_TYPE, (id))
+
+/**
+ * DEFINE_XE_LOG_COMPONENTS() - Define log components.
+ * @define: name of the inner macro to expand.
+ *
+ * Use this super macro to define custom code for the log components.
+ * The following parameters are available for each component::
+ *
+ *     define(CLASS, ID, TAG, SIGID, NAME)
+ *
+ * where:
+ *
+ *     @CLASS is the component class name (without the XE_LOG_COMPONENT_CLASS_ prefix)
+ *     @ID is the unique component identifier within @CLASS
+ *     @TAG is unique component tag (across all components)
+ *     @SIGID is the default xe_sigid for the component (without the XE_SIGID_ prefix)
+ */
+#define DEFINE_XE_LOG_COMPONENTS(define) \
+	/* */									\
+	define(SYSTEM, 1, PCI, SW, "Linux PCI Subsystem")			\
+	define(SYSTEM, 2, DRM, SW, "DRM")					\
+	/* */									\
+	define(DRIVER, 1, XE, SW, "Xe Driver")					\
+	define(DRIVER, 2, PROBE, PROBE, "Driver Initialization")		\
+	define(DRIVER, 3, WEDGED, WEDGED, "Device Malfunction")			\
+	define(DRIVER, 4, RTP, SW, "Register Table Processing")			\
+	define(DRIVER, 5, WA, SW, "Workarounds")				\
+	define(DRIVER, 6, PAGEFAULT, MEM_FAULT, "Page Fault")			\
+	/* */									\
+	define(DRIVER_HARDWARE, 1, REGS, IO_BUS, "Registers")			\
+	define(DRIVER_HARDWARE, 2, GGTT, IO_BUS, "Global GTT")			\
+	define(DRIVER_HARDWARE, 3, GT, GT_TDR, "Graphics Technology")		\
+	define(DRIVER_HARDWARE, 4, LMTT, IO_BUS, "LMEM Translation Table")	\
+	define(DRIVER_HARDWARE, 5, MEMIRQ, IO_BUS, "Memory Based IRQ")		\
+	/* */									\
+	define(DRIVER_FEATURE, 1, PF, SW, "SR-IOV Physical Function")		\
+	define(DRIVER_FEATURE, 2, VF, SW, "SR-IOV Virtual Function")		\
+	define(DRIVER_FEATURE, 3, SURVIVABILITY, SURVIVABILITY, "Survivability") \
+	define(DRIVER_FEATURE, 4, RAS, SW, "Reliability, Accessibility, Serviceability") \
+	/* */									\
+	define(DRIVER_FIRMWARE, 1, GUC, RUNTIME_FW, "GuC")			\
+	define(DRIVER_FIRMWARE, 2, HUC, RUNTIME_FW, "HuC")			\
+	define(DRIVER_FIRMWARE, 3, GSC, RUNTIME_FW, "GSC")			\
+	define(DRIVER_FIRMWARE, 16, PCODE, DEVICE_FW, "PCode")			\
+	define(DRIVER_FIRMWARE, 17, SYSCTRL, DEVICE_FW, "System Controller")	\
+	/* eod */
+
+/**
+ * enum xe_log_component_tags - TAGs of all supported components
+ */
+enum xe_log_component_tags {
+	/* private: */
+#define MAKE_XE_LOG_COMPONENT_ENUM(_CLASS, _ID, _TAG, _SIG, _NAME) \
+	XE_LOG_COMPONENT_##_TAG = MAKE_XE_LOG_COMPONENT(_CLASS, (_ID)), \
+	XE_LOG_COMPONENT_##_CLASS##_##_ID = XE_LOG_COMPONENT_##_TAG, \
+	/* eod */
+	DEFINE_XE_LOG_COMPONENTS(MAKE_XE_LOG_COMPONENT_ENUM)
+#undef MAKE_XE_LOG_COMPONENT_ENUM
+};
+
+/**
+ * enum xe_log_component_sigids - SIGIDs of all supported components
+ */
+enum xe_log_component_sigids {
+	/* private: */
+#define MAKE_XE_LOG_COMPONENT_SIGID(_CLASS, _ID, _TAG, _SIG, _NAME) \
+	XE_LOG_COMPONENT_##_TAG##_SIGID = XE_SIGID_##_SIG, \
+	/* eod */
+	DEFINE_XE_LOG_COMPONENTS(MAKE_XE_LOG_COMPONENT_SIGID)
+#undef MAKE_XE_LOG_COMPONENT_SIGID
+};
+
+#endif
Signature · 1 line
2.47.1
maintainer
#18 lore raw

Re: [PATCH v4 03/32] drm/xe/log: Introduce structured component/location identifiers

Quoted 153 lines · Michal Wajdeczko

Introduce structured identifiers for each component type that could emit a SIGID log entry and for their locations. We plan to store those IDs in the CPER records for better filtering. Define also structured identifiers for the supported locations.

---
Cc: Aravind Iddamsetty <[email protected]>
Cc: Mallesh Koujalagi <[email protected]>
Cc: Raag Jadav <[email protected]>
Cc: Riana Tauro <[email protected]>
---
v2: fix typo, define reserved ids (Michal)
v3: fix kernel-doc to match code (Sashiko)
v4: update comment (Michal)

---
 drivers/gpu/drm/xe/abi/xe_log_abi.h | 187 ++++++++++++++++++++++++++++
 1 file changed, 187 insertions(+)
 create mode 100644 drivers/gpu/drm/xe/abi/xe_log_abi.h
drivers/gpu/drm/xe/abi/xe_log_abi.h new file +124 -0
new file mode 100644
index 000000000000..92547805326f
@@ -0,0 +1,187 @@
+/* SPDX-License-Identifier: MIT */
+/*
+ * Copyright © 2026 Intel Corporation
+ */
+
+#ifndef _ABI_XE_LOG_ABI_H_
+#define _ABI_XE_LOG_ABI_H_
+
+#include <linux/bits.h>
+#include <linux/bitfield.h>
+
+#include "abi/xe_sigid_abi.h"
+
+/**
+ * enum xe_log_component_bits - bits for components structure definitions
+ *
+ * Component identifiers are structured based on::
+ *
+ *     COMPONENT = CLASS(8b).TYPE(8b)
+ *
+ * and the structure looks like this::
+ *
+ *     ├── SYSTEM(0)
+ *     │   └── ...
+ *     ├── DRIVER(1)
+ *     │   └── ...
+ *     ├── FEATURE(2)
+ *     │   └── ...
+ *     ├── FIRMWARE(4)
+ *     │   └── ...
+ *     └── HARDWARE(8)
+ *         └── ...
+ *
+ * Examples::
+ *
+ *     COMPONENT(0.type) = SYSTEM.type = system component
+ *     COMPONENT(1.type) = DRIVER.type = driver core component
+ *     COMPONENT(3.type) = DRIVER_FEATURE.type = driver feature
+ *     COMPONENT(5.type) = DRIVER_FIRMWARE.type = firmware driver component
+ *     COMPONENT(9.type) = DRIVER_HARDWARE.type = hardware driver component
+ *
+ */
+enum xe_log_component_bits {
+	/* private: */
+	XE_LOG_COMPONENT_CLASS_MASK = GENMASK_U16(7, 0),
+	XE_LOG_COMPONENT_TYPE_MASK = GENMASK_U16(15, 8),
+	/* private: component classes */
+	XE_LOG_COMPONENT_CLASS_SYSTEM = 0u,
+	XE_LOG_COMPONENT_CLASS_DRIVER = 1u,
+	XE_LOG_COMPONENT_CLASS_FEATURE = 2u,
+	XE_LOG_COMPONENT_CLASS_FIRMWARE = 4u,
+	XE_LOG_COMPONENT_CLASS_HARDWARE = 8u,
+	XE_LOG_COMPONENT_CLASS_DRIVER_FEATURE = XE_LOG_COMPONENT_CLASS_DRIVER |
+						XE_LOG_COMPONENT_CLASS_FEATURE,
+	XE_LOG_COMPONENT_CLASS_DRIVER_FIRMWARE = XE_LOG_COMPONENT_CLASS_DRIVER |
+						 XE_LOG_COMPONENT_CLASS_FIRMWARE,
+	XE_LOG_COMPONENT_CLASS_DRIVER_HARDWARE = XE_LOG_COMPONENT_CLASS_DRIVER |
+						 XE_LOG_COMPONENT_CLASS_HARDWARE,
+	/* private: reserved identifiers */
+	XE_LOG_COMPONENT_NONE = 0u,
+};
+
+#define MAKE_XE_LOG_COMPONENT(_CLASS, type) \
+	(FIELD_PREP_CONST(XE_LOG_COMPONENT_CLASS_MASK, \
+			  XE_LOG_COMPONENT_CLASS_##_CLASS) | \
+	 FIELD_PREP_CONST(XE_LOG_COMPONENT_TYPE_MASK, (type)))
+
+/**
+ * enum xe_log_location_bits - bits for location structure definitions
+ *
+ * Location identifiers are structured based on::
+ *
+ *     LOCATION = TYPE(8b).ID(8b)
+ *
+ * and the structure looks like this::
+ *
+ *     ├── DEVICE(0)
+ *     │   └── MBZ(0)
+ *     ├── TILE(1)
+ *     │   ├── Tile0(0)
+ *     │   ├── ...
+ *     │   └── TileN(n)
+ *     ├── GT(1)
+ *     │   ├── GT0(0)
+ *     │   ├── ...
+ *     │   └── GTn(n)
+ *     └── ...
+ *
+ * Examples::
+ *
+ *     LOCATION(0.0) = NONE
+ *     LOCATION(1.0) = DEVICE.0 = "Device"
+ *     LOCATION(2.1) = TILE.1 = "Tile1"
+ *     LOCATION(3.2) = GT.2 = "GT2"
+ *
+ */
+enum xe_log_location_bits {
+	/* private: */
+	XE_LOG_LOCATION_TYPE_MASK = GENMASK_U16(7, 0),
+	XE_LOG_LOCATION_ID_MASK = GENMASK_U16(15, 8),
+	/* private: location types */
+	XE_LOG_LOCATION_TYPE_DEVICE = 1u,
+	XE_LOG_LOCATION_TYPE_TILE = 2u,
+	XE_LOG_LOCATION_TYPE_GT = 3u,
+	/* private: reserved identifiers */
+	XE_LOG_LOCATION_NONE = 0u,
+};
+
+#define PREP_XE_LOG_LOCATION(type, id) \
+	(FIELD_PREP(XE_LOG_LOCATION_TYPE_MASK, (type)) | \
+	 FIELD_PREP(XE_LOG_LOCATION_ID_MASK, (id)))
+
+#define MAKE_XE_LOG_LOCATION(_TYPE, id) \
+	PREP_XE_LOG_LOCATION(XE_LOG_LOCATION_TYPE_##_TYPE, (id))
+
+/**
+ * DEFINE_XE_LOG_COMPONENTS() - Define log components.
+ * @define: name of the inner macro to expand.
+ *
+ * Use this super macro to define custom code for the log components.
+ * The following parameters are available for each component::
+ *
+ *     define(CLASS, ID, TAG, SIGID, NAME)
+ *

drivers/gpu/drm/xe/abi/xe_log_abi.h line 134

Quoted 10 lines
drivers/gpu/drm/xe/abi/xe_log_abi.h new file +10 -0
+ * where:
+ *
+ *     @CLASS is the component class name (without the XE_LOG_COMPONENT_CLASS_ prefix)
+ *     @ID is the unique component identifier within @CLASS
+ *     @TAG is unique component tag (across all components)
+ *     @SIGID is the default xe_sigid for the component (without the XE_SIGID_ prefix)
+ */
+#define DEFINE_XE_LOG_COMPONENTS(define) \
+	/* */									\
+	define(SYSTEM, 1, PCI, SW, "Linux PCI Subsystem")			\

As we discussed offline, based on the review of the last patch of this series it becomes clear that this PCI bucket should be IO_BUS.

Let's change this and keep my rv-b...

Quoted 56 lines
drivers/gpu/drm/xe/abi/xe_log_abi.h new file +53 -0
+	define(SYSTEM, 2, DRM, SW, "DRM")					\
+	/* */									\
+	define(DRIVER, 1, XE, SW, "Xe Driver")					\
+	define(DRIVER, 2, PROBE, PROBE, "Driver Initialization")		\
+	define(DRIVER, 3, WEDGED, WEDGED, "Device Malfunction")			\
+	define(DRIVER, 4, RTP, SW, "Register Table Processing")			\
+	define(DRIVER, 5, WA, SW, "Workarounds")				\
+	define(DRIVER, 6, PAGEFAULT, MEM_FAULT, "Page Fault")			\
+	/* */									\
+	define(DRIVER_HARDWARE, 1, REGS, IO_BUS, "Registers")			\
+	define(DRIVER_HARDWARE, 2, GGTT, IO_BUS, "Global GTT")			\
+	define(DRIVER_HARDWARE, 3, GT, GT_TDR, "Graphics Technology")		\
+	define(DRIVER_HARDWARE, 4, LMTT, IO_BUS, "LMEM Translation Table")	\
+	define(DRIVER_HARDWARE, 5, MEMIRQ, IO_BUS, "Memory Based IRQ")		\
+	/* */									\
+	define(DRIVER_FEATURE, 1, PF, SW, "SR-IOV Physical Function")		\
+	define(DRIVER_FEATURE, 2, VF, SW, "SR-IOV Virtual Function")		\
+	define(DRIVER_FEATURE, 3, SURVIVABILITY, SURVIVABILITY, "Survivability") \
+	define(DRIVER_FEATURE, 4, RAS, SW, "Reliability, Accessibility, Serviceability") \
+	/* */									\
+	define(DRIVER_FIRMWARE, 1, GUC, RUNTIME_FW, "GuC")			\
+	define(DRIVER_FIRMWARE, 2, HUC, RUNTIME_FW, "HuC")			\
+	define(DRIVER_FIRMWARE, 3, GSC, RUNTIME_FW, "GSC")			\
+	define(DRIVER_FIRMWARE, 16, PCODE, DEVICE_FW, "PCode")			\
+	define(DRIVER_FIRMWARE, 17, SYSCTRL, DEVICE_FW, "System Controller")	\
+	/* eod */
+
+/**
+ * enum xe_log_component_tags - TAGs of all supported components
+ */
+enum xe_log_component_tags {
+	/* private: */
+#define MAKE_XE_LOG_COMPONENT_ENUM(_CLASS, _ID, _TAG, _SIG, _NAME) \
+	XE_LOG_COMPONENT_##_TAG = MAKE_XE_LOG_COMPONENT(_CLASS, (_ID)), \
+	XE_LOG_COMPONENT_##_CLASS##_##_ID = XE_LOG_COMPONENT_##_TAG, \
+	/* eod */
+	DEFINE_XE_LOG_COMPONENTS(MAKE_XE_LOG_COMPONENT_ENUM)
+#undef MAKE_XE_LOG_COMPONENT_ENUM
+};
+
+/**
+ * enum xe_log_component_sigids - SIGIDs of all supported components
+ */
+enum xe_log_component_sigids {
+	/* private: */
+#define MAKE_XE_LOG_COMPONENT_SIGID(_CLASS, _ID, _TAG, _SIG, _NAME) \
+	XE_LOG_COMPONENT_##_TAG##_SIGID = XE_SIGID_##_SIG, \
+	/* eod */
+	DEFINE_XE_LOG_COMPONENTS(MAKE_XE_LOG_COMPONENT_SIGID)
+#undef MAKE_XE_LOG_COMPONENT_SIGID
+};
+
+#endif
Signature · 1 line
2.47.1
#19 lore raw

PATCH v4 4/32 drm/xe/log: Add component/location decorations to dmesg

In reply to Michal Wajdeczko

While we can't directly use our xe_tile|gt_err|info helpers to get nice Tile/GT decorations, we can still add them manually based on the structured location parameter. Similarly, we can add component name prefix based on the component identifier.

---
Cc: Aravind Iddamsetty <[email protected]>
Cc: Mallesh Koujalagi <[email protected]>
---
v2: check against info->tile_count (Sashiko)
more diagnostics on bad usage (Michal)

---
 drivers/gpu/drm/xe/xe_log.c | 102 +++++++++++++++++++++++++++++++++---
 1 file changed, 94 insertions(+), 8 deletions(-)
drivers/gpu/drm/xe/xe_log.c +94 -8
index ae4f6e33f5b8..0b423ed121cd 100644
@@ -3,6 +3,9 @@
  * Copyright © 2026 Intel Corporation
  */
 
+#include "abi/xe_log_abi.h"
+
+#include "xe_device.h"
 #include "xe_log.h"
 #include "xe_printk.h"
 
@@ -13,6 +16,85 @@ static void log_emit_cper(struct pci_dev *pdev, int cper_sev, enum xe_sigid sigi
 	/* TODO */
 }
 
+static const char *log_unknown_component_prefix(u32 component)
+{
+	u32 class = FIELD_GET(XE_LOG_COMPONENT_CLASS_MASK, component);
+	u32 type = FIELD_GET(XE_LOG_COMPONENT_TYPE_MASK, component);
+
+	WARN(IS_ENABLED(CONFIG_DRM_XE_DEBUG), "LOG: unrecognized component %u.%u\n", class, type);
+	switch (class) {
+#define MAKE_XE_LOG_COMPONENT_CLASS_PREFIX(_CLASS) \
+	case XE_LOG_COMPONENT_CLASS_##_CLASS: return #_CLASS "? ";
+	MAKE_XE_LOG_COMPONENT_CLASS_PREFIX(SYSTEM)
+	MAKE_XE_LOG_COMPONENT_CLASS_PREFIX(DRIVER)
+	MAKE_XE_LOG_COMPONENT_CLASS_PREFIX(FEATURE)
+	MAKE_XE_LOG_COMPONENT_CLASS_PREFIX(FIRMWARE)
+	MAKE_XE_LOG_COMPONENT_CLASS_PREFIX(HARDWARE)
+#undef MAKE_XE_LOG_COMPONENT_CLASS_PREFIX
+	}
+	return "COMP? ";
+}
+
+static const char *log_component_prefix(u32 component)
+{
+	switch (component) {
+#define MAKE_XE_LOG_COMPONENT_CASE_PREFIX(_CLASS, _ID, _TAG, _SIG, _NAME) \
+	case XE_LOG_COMPONENT_##_TAG: return #_TAG ": ";
+	DEFINE_XE_LOG_COMPONENTS(MAKE_XE_LOG_COMPONENT_CASE_PREFIX)
+#undef MAKE_XE_LOG_COMPONENT_CASE_PREFIX
+	}
+
+	return component ? log_unknown_component_prefix(component) : "";
+}
+
+static struct xe_gt *get_gt_safe(struct pci_dev *pdev, u8 id)
+{
+	struct xe_device *xe = pdev_to_xe_device(pdev);
+
+	return xe ? xe_device_get_gt(xe, id) : NULL;
+}
+
+static struct xe_tile *get_tile_safe(struct pci_dev *pdev, u8 id)
+{
+	struct xe_device *xe = pdev_to_xe_device(pdev);
+
+	return xe && id < xe->info.tile_count ? &xe->tiles[id] : NULL;
+}
+
+static const char *log_location_prefix(struct pci_dev *pdev, u32 location, char *buf, size_t size)
+{
+	u32 type = FIELD_GET(XE_LOG_LOCATION_TYPE_MASK, location);
+	u32 id = FIELD_GET(XE_LOG_LOCATION_ID_MASK, location);
+
+	if (!location || type == XE_LOG_LOCATION_TYPE_DEVICE) {
+		if (id)
+			goto unrecognized;
+		strscpy(buf, "", size);
+	} else if (type == XE_LOG_LOCATION_TYPE_TILE) {
+		struct xe_tile *tile = get_tile_safe(pdev, id);
+
+		if (!tile)
+			goto unrecognized;
+		snprintf(buf, size, "Tile%u: ", id);
+	} else if (type == XE_LOG_LOCATION_TYPE_GT) {
+		struct xe_gt *gt = get_gt_safe(pdev, id);
+
+		if (!gt)
+			goto unrecognized;
+		snprintf(buf, size, "Tile%u: GT%u: ", gt->tile->id, id);
+	} else {
+		goto unrecognized;
+	}
+
+	return buf;
+
+unrecognized:
+	pci_WARN(pdev, IS_ENABLED(CONFIG_DRM_XE_DEBUG),
+		 "LOG: unrecognized location %u.%u\n", type, id);
+	snprintf(buf, size, "LOC%u.%u? ", type, id);
+	return buf;
+}
+
 static bool is_hw_sigid(enum xe_sigid sigid)
 {
 	return (int)sigid >= INTEL_SIGID_GPU_XE_HARDWARE_START;
@@ -74,20 +156,24 @@ static void log_emit_dmesg(struct pci_dev *pdev, int cper_sev, enum xe_sigid sig
 			   u32 component, u32 location, const void *data, size_t len,
 			   struct va_format *vaf)
 {
+	char buf[32];
+	const char *loc_prefix = log_location_prefix(pdev, location, buf, sizeof(buf));
+	const char *comp_prefix = log_component_prefix(component);
 	const char *hwe_prefix = log_hwe_prefix(cper_sev, sigid);
 	const char *sev_prefix = log_sev_prefix(cper_sev);
 
-	/* TODO: add component/location details */
-
 	if (IS_ERR(data))
-		log_dmesg_printf(pdev, cper_sev, "SIGID=%u %s(%pe) %s%pV",
-				 sigid, sev_prefix, data, hwe_prefix, vaf);
+		log_dmesg_printf(pdev, cper_sev, "SIGID=%u %s(%pe) %s%s%s%pV",
+				 sigid, sev_prefix, data, hwe_prefix,
+				 loc_prefix, comp_prefix, vaf);
 	else if (data && len)
-		log_dmesg_printf(pdev, cper_sev, "SIGID=%u %s(%*phN) %s%pV",
-				 sigid, sev_prefix, (int)len, data, hwe_prefix, vaf);
+		log_dmesg_printf(pdev, cper_sev, "SIGID=%u %s(%*phN) %s%s%s%pV",
+				 sigid, sev_prefix, (int)len, data, hwe_prefix,
+				 loc_prefix, comp_prefix, vaf);
 	else
-		log_dmesg_printf(pdev, cper_sev, "SIGID=%u %s%s%pV",
-				 sigid, sev_prefix, hwe_prefix, vaf);
+		log_dmesg_printf(pdev, cper_sev, "SIGID=%u %s%s%s%s%pV",
+				 sigid, sev_prefix, hwe_prefix,
+				 loc_prefix, comp_prefix, vaf);
 }
 
 /**
Signature · 1 line
2.47.1
Reviewed-by on v4 4/32
#20 lore raw

Re: [PATCH v4 04/32] drm/xe/log: Add component/location decorations to dmesg

Quoted 6 lines · Michal Wajdeczko

While we can't directly use our xe_tile|gt_err|info helpers to get nice Tile/GT decorations, we can still add them manually based on the structured location parameter. Similarly, we can add component name prefix based on the component identifier.

LGTM,

Quoted 145 lines

---
Cc: Aravind Iddamsetty <[email protected]>
Cc: Mallesh Koujalagi <[email protected]>
---
v2: check against info->tile_count (Sashiko)
more diagnostics on bad usage (Michal)

---
  drivers/gpu/drm/xe/xe_log.c | 102 +++++++++++++++++++++++++++++++++---
  1 file changed, 94 insertions(+), 8 deletions(-)
drivers/gpu/drm/xe/xe_log.c +94 -8
index ae4f6e33f5b8..0b423ed121cd 100644
@@ -3,6 +3,9 @@
   * Copyright © 2026 Intel Corporation
   */
 
+#include "abi/xe_log_abi.h"
+
+#include "xe_device.h"
  #include "xe_log.h"
  #include "xe_printk.h"
 
@@ -13,6 +16,85 @@ static void log_emit_cper(struct pci_dev *pdev, int cper_sev, enum xe_sigid sigi
  	/* TODO */
  }
 
+static const char *log_unknown_component_prefix(u32 component)
+{
+	u32 class = FIELD_GET(XE_LOG_COMPONENT_CLASS_MASK, component);
+	u32 type = FIELD_GET(XE_LOG_COMPONENT_TYPE_MASK, component);
+
+	WARN(IS_ENABLED(CONFIG_DRM_XE_DEBUG), "LOG: unrecognized component %u.%u\n", class, type);
+	switch (class) {
+#define MAKE_XE_LOG_COMPONENT_CLASS_PREFIX(_CLASS) \
+	case XE_LOG_COMPONENT_CLASS_##_CLASS: return #_CLASS "? ";
+	MAKE_XE_LOG_COMPONENT_CLASS_PREFIX(SYSTEM)
+	MAKE_XE_LOG_COMPONENT_CLASS_PREFIX(DRIVER)
+	MAKE_XE_LOG_COMPONENT_CLASS_PREFIX(FEATURE)
+	MAKE_XE_LOG_COMPONENT_CLASS_PREFIX(FIRMWARE)
+	MAKE_XE_LOG_COMPONENT_CLASS_PREFIX(HARDWARE)
+#undef MAKE_XE_LOG_COMPONENT_CLASS_PREFIX
+	}
+	return "COMP? ";
+}
+
+static const char *log_component_prefix(u32 component)
+{
+	switch (component) {
+#define MAKE_XE_LOG_COMPONENT_CASE_PREFIX(_CLASS, _ID, _TAG, _SIG, _NAME) \
+	case XE_LOG_COMPONENT_##_TAG: return #_TAG ": ";
+	DEFINE_XE_LOG_COMPONENTS(MAKE_XE_LOG_COMPONENT_CASE_PREFIX)
+#undef MAKE_XE_LOG_COMPONENT_CASE_PREFIX
+	}
+
+	return component ? log_unknown_component_prefix(component) : "";
+}
+
+static struct xe_gt *get_gt_safe(struct pci_dev *pdev, u8 id)
+{
+	struct xe_device *xe = pdev_to_xe_device(pdev);
+
+	return xe ? xe_device_get_gt(xe, id) : NULL;
+}
+
+static struct xe_tile *get_tile_safe(struct pci_dev *pdev, u8 id)
+{
+	struct xe_device *xe = pdev_to_xe_device(pdev);
+
+	return xe && id < xe->info.tile_count ? &xe->tiles[id] : NULL;
+}
+
+static const char *log_location_prefix(struct pci_dev *pdev, u32 location, char *buf, size_t size)
+{
+	u32 type = FIELD_GET(XE_LOG_LOCATION_TYPE_MASK, location);
+	u32 id = FIELD_GET(XE_LOG_LOCATION_ID_MASK, location);
+
+	if (!location || type == XE_LOG_LOCATION_TYPE_DEVICE) {
+		if (id)
+			goto unrecognized;
+		strscpy(buf, "", size);
+	} else if (type == XE_LOG_LOCATION_TYPE_TILE) {
+		struct xe_tile *tile = get_tile_safe(pdev, id);
+
+		if (!tile)
+			goto unrecognized;
+		snprintf(buf, size, "Tile%u: ", id);
+	} else if (type == XE_LOG_LOCATION_TYPE_GT) {
+		struct xe_gt *gt = get_gt_safe(pdev, id);
+
+		if (!gt)
+			goto unrecognized;
+		snprintf(buf, size, "Tile%u: GT%u: ", gt->tile->id, id);
+	} else {
+		goto unrecognized;
+	}
+
+	return buf;
+
+unrecognized:
+	pci_WARN(pdev, IS_ENABLED(CONFIG_DRM_XE_DEBUG),
+		 "LOG: unrecognized location %u.%u\n", type, id);
+	snprintf(buf, size, "LOC%u.%u? ", type, id);
+	return buf;
+}
+
  static bool is_hw_sigid(enum xe_sigid sigid)
  {
  	return (int)sigid >= INTEL_SIGID_GPU_XE_HARDWARE_START;
@@ -74,20 +156,24 @@ static void log_emit_dmesg(struct pci_dev *pdev, int cper_sev, enum xe_sigid sig
  			   u32 component, u32 location, const void *data, size_t len,
  			   struct va_format *vaf)
  {
+	char buf[32];
+	const char *loc_prefix = log_location_prefix(pdev, location, buf, sizeof(buf));
+	const char *comp_prefix = log_component_prefix(component);
  	const char *hwe_prefix = log_hwe_prefix(cper_sev, sigid);
  	const char *sev_prefix = log_sev_prefix(cper_sev);
 
-	/* TODO: add component/location details */
-
  	if (IS_ERR(data))
-		log_dmesg_printf(pdev, cper_sev, "SIGID=%u %s(%pe) %s%pV",
-				 sigid, sev_prefix, data, hwe_prefix, vaf);
+		log_dmesg_printf(pdev, cper_sev, "SIGID=%u %s(%pe) %s%s%s%pV",
+				 sigid, sev_prefix, data, hwe_prefix,
+				 loc_prefix, comp_prefix, vaf);
  	else if (data && len)
-		log_dmesg_printf(pdev, cper_sev, "SIGID=%u %s(%*phN) %s%pV",
-				 sigid, sev_prefix, (int)len, data, hwe_prefix, vaf);
+		log_dmesg_printf(pdev, cper_sev, "SIGID=%u %s(%*phN) %s%s%s%pV",
+				 sigid, sev_prefix, (int)len, data, hwe_prefix,
+				 loc_prefix, comp_prefix, vaf);
  	else
-		log_dmesg_printf(pdev, cper_sev, "SIGID=%u %s%s%pV",
-				 sigid, sev_prefix, hwe_prefix, vaf);
+		log_dmesg_printf(pdev, cper_sev, "SIGID=%u %s%s%s%s%pV",
+				 sigid, sev_prefix, hwe_prefix,
+				 loc_prefix, comp_prefix, vaf);
  }
 
  /**
#21 lore raw

PATCH v4 5/32 drm/xe/log: Add SIGID log helpers for severity

In reply to Michal Wajdeczko

There are only few CPER severity levels defined, add simple helper for each of them, to avoid forcing developers to write full severity name in every function call.

---
v2: drop support for any_to_pdev (Michal)

---
 drivers/gpu/drm/xe/xe_log.h | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
drivers/gpu/drm/xe/xe_log.h +16 -0
index d475e816ee0b..73daf37d6463 100644
@@ -17,4 +17,20 @@ void xe_log_emit(struct pci_dev *pdev, int cper_sev, enum xe_sigid sigid,
 		 u32 component, u32 location, const void *data, size_t len,
 		 const char *fmt, ...);
 
+#define xe_log_emit_fatal(pdev, sig, comp, loc, data, len, fmt, args...) \
+	xe_log_emit((pdev), CPER_SEV_FATAL, (sig), (comp), (loc), \
+		    (data), (len), fmt, ##args)
+
+#define xe_log_emit_recoverable(pdev, sig, comp, loc, data, len, fmt, args...) \
+	xe_log_emit((pdev), CPER_SEV_RECOVERABLE, (sig), (comp), (loc), \
+		    (data), (len), fmt, ##args)
+
+#define xe_log_emit_corrected(pdev, sig, comp, loc, data, len, fmt, args...) \
+	xe_log_emit((pdev), CPER_SEV_CORRECTED, (sig), (comp), (loc), \
+		    (data), (len), fmt, ##args)
+
+#define xe_log_emit_info(pdev, sig, comp, loc, data, len, fmt, args...) \
+	xe_log_emit((pdev), CPER_SEV_INFORMATIONAL, (sig), (comp), (loc), \
+		    (data), (len), fmt, ##args)
+
 #endif
Signature · 1 line
2.47.1
#22 lore raw

PATCH v4 6/32 drm/xe/log: Add SIGID log helpers for location

In reply to Michal Wajdeczko

We can determine the location of the SIGID error source based on the type of the xe pointer being currently available. Add helper macros that will accept any of xe_device, xe_tile or xe_gt pointers instead of plain pci_dev to generate valid XE_LOG_LOCATION identifier and then call low-level xe_log_emit(pdev) function.

---
Cc: Aravind Iddamsetty <[email protected]>
Cc: Mallesh Koujalagi <[email protected]>

---
 drivers/gpu/drm/xe/xe_log.h | 36 ++++++++++++++++++++++++++++++++++++
 1 file changed, 36 insertions(+)
drivers/gpu/drm/xe/xe_log.h +36 -0
index 73daf37d6463..510cedae6e14 100644
@@ -8,7 +8,9 @@
 
 #include <linux/cper.h>
 
+#include "abi/xe_log_abi.h"
 #include "abi/xe_sigid_abi.h"
+#include "xe_any.h"
 
 struct pci_dev;
 
@@ -33,4 +35,38 @@ void xe_log_emit(struct pci_dev *pdev, int cper_sev, enum xe_sigid sigid,
 	xe_log_emit((pdev), CPER_SEV_INFORMATIONAL, (sig), (comp), (loc), \
 		    (data), (len), fmt, ##args)
 
+#define xe_log_location_type(any)							\
+	_Generic((any),									\
+		 struct xe_gt * : XE_LOG_LOCATION_TYPE_GT,				\
+		 const struct xe_gt * : XE_LOG_LOCATION_TYPE_GT,			\
+		 struct xe_tile * : XE_LOG_LOCATION_TYPE_TILE,				\
+		 const struct xe_tile * : XE_LOG_LOCATION_TYPE_TILE,			\
+		 struct xe_device * : XE_LOG_LOCATION_TYPE_DEVICE,			\
+		 const struct xe_device * : XE_LOG_LOCATION_TYPE_DEVICE,		\
+		 struct pci_dev * : XE_LOG_LOCATION_TYPE_DEVICE,			\
+		 struct device * : XE_LOG_LOCATION_TYPE_DEVICE)
+
+#define xe_log_location(any) \
+	PREP_XE_LOG_LOCATION(xe_log_location_type(any), xe_any_id(any))
+
+/**
+ * xe_log_from() - Emit a structured SIGID log entry using @any pointer as location.
+ * @any: the &xe_device or &xe_tile or &xe_gt pointer this report relates to
+ * @cper_sev: CPER severity (CPER_SEV_FATAL, CPER_SEV_RECOVERABLE, ...)
+ * @sigid: signature identifier, see &enum xe_sigid
+ * @component: component identifer
+ * @data: pointer to the additional details, or ERR_PTR, or NULL if not applicable
+ * @len: length of the @data in bytes, or 0 if not applicable
+ * @fmt: printf-style format string
+ * @args: arguments for the @fmt format string
+ *
+ * The location used to emit SIGID entry will be based on the @any pointer type.
+ * See xe_log_emit() for more details.
+ */
+#define xe_log_from(any, cper_sev, sigid, component, data, len, fmt, args...) do {	\
+	typeof(any) ___any = (any);							\
+	xe_log_emit(xe_any_to_pdev(___any), (cper_sev), (sigid), (component),		\
+		    xe_log_location(___any), (data), (len), fmt, ##args);		\
+} while (0)
+
 #endif
Signature · 1 line
2.47.1
#23 lore raw

PATCH v4 7/32 drm/xe/log: Add SIGID log helpers for location & severity

In reply to Michal Wajdeczko

There are only few CPER severity levels defined, add more helpers to avoid forcing developers to write full CPER severity name in every function call.

---
v2: fix argument list (Sashiko)

---
 drivers/gpu/drm/xe/xe_log.h | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
drivers/gpu/drm/xe/xe_log.h +16 -0
index 510cedae6e14..916218560297 100644
@@ -69,4 +69,20 @@ void xe_log_emit(struct pci_dev *pdev, int cper_sev, enum xe_sigid sigid,
 		    xe_log_location(___any), (data), (len), fmt, ##args);		\
 } while (0)
 
+#define xe_log_from_fatal(any, sig, comp, data, len, fmt, args...) \
+	xe_log_from((any), CPER_SEV_FATAL, (sig), (comp), \
+		    (data), (len), fmt, ##args)
+
+#define xe_log_from_recoverable(any, sig, comp, data, len, fmt, args...) \
+	xe_log_from((any), CPER_SEV_RECOVERABLE, (sig), (comp), \
+		    (data), (len), fmt, ##args)
+
+#define xe_log_from_corrected(any, sig, comp, data, len, fmt, args...) \
+	xe_log_from((any), CPER_SEV_CORRECTED, (sig), (comp), \
+		    (data), (len), fmt, ##args)
+
+#define xe_log_from_info(any, sig, comp, data, len, fmt, args...) \
+	xe_log_from((any), CPER_SEV_INFORMATIONAL, (sig), (comp), \
+		    (data), (len), fmt, ##args)
+
 #endif
Signature · 1 line
2.47.1
#24 lore raw

PATCH v4 8/32 drm/xe/log: Add SIGID log helpers for components

In reply to Michal Wajdeczko

Our component list already defines relation between the component name, identified by the TAG, and its numerical identifier and the assigned SIGID. We can also already prepare location identifier based on the pointer type used to emit the log entry. Add helper that will prepare SIGID, COMPONENT and LOCATION parameters for xe_log_emit() using provided components TAG and the pointer.

---
Cc: Aravind Iddamsetty <[email protected]>
---
v2: rebased/simplified (Michal)

---
 drivers/gpu/drm/xe/xe_log.h | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
drivers/gpu/drm/xe/xe_log.h +18 -0
index 916218560297..c30db02950b0 100644
@@ -85,4 +85,22 @@ void xe_log_emit(struct pci_dev *pdev, int cper_sev, enum xe_sigid sigid,
 	xe_log_from((any), CPER_SEV_INFORMATIONAL, (sig), (comp), \
 		    (data), (len), fmt, ##args)
 
+/**
+ * xe_log_comp() - Emit a structured SIGID log entry on the component behalf.
+ * @any: the &xe_device or &xe_tile or &xe_gt pointer this report relates to
+ * @cper_sev: CPER severity (CPER_SEV_FATAL, CPER_SEV_RECOVERABLE, ...)
+ * @TAG: the component tag to use
+ * @data: pointer to the additional details, or ERR_PTR, or NULL if not applicable
+ * @len: length of the @data in bytes, or 0 if not applicable
+ * @fmt: printf-style free text format string (not a stable interface)
+ * @args: arguments for the @fmt format string
+ *
+ * The SIGID will be determined from the component's @TAG.
+ * The component identifier will be determined from the component's @TAG.
+ * The location used to emit SIGID entry will be based on the @any pointer type.
+ */
+#define xe_log_comp(any, cper_sev, TAG, data, len, fmt, args...) \
+	xe_log_from((any), (cper_sev), (int)XE_LOG_COMPONENT_##TAG##_SIGID, \
+		    XE_LOG_COMPONENT_##TAG, (data), (len), fmt, ##args)
+
 #endif
Signature · 1 line
2.47.1
#25 lore raw

PATCH v4 9/32 drm/xe/log: Add SIGID log helpers for component & severity

In reply to Michal Wajdeczko

There are only few CPER severity levels defined, add some helpers to avoid forcing developers to write full CPER severity enum name in every macro call.

Cc Rodrigo Vivi <[email protected]>
Cc Mallesh Koujalagi <[email protected]>
---
 drivers/gpu/drm/xe/xe_log.h | 12 ++++++++++++
 1 file changed, 12 insertions(+)
drivers/gpu/drm/xe/xe_log.h +12 -0
index c30db02950b0..c56306a183e7 100644
@@ -103,4 +103,16 @@ void xe_log_emit(struct pci_dev *pdev, int cper_sev, enum xe_sigid sigid,
 	xe_log_from((any), (cper_sev), (int)XE_LOG_COMPONENT_##TAG##_SIGID, \
 		    XE_LOG_COMPONENT_##TAG, (data), (len), fmt, ##args)
 
+#define xe_log_comp_fatal(any, TAG, data, len, fmt, args...) \
+	xe_log_comp((any), CPER_SEV_FATAL, TAG, (data), (len), fmt, ##args)
+
+#define xe_log_comp_recoverable(any, TAG, data, len, fmt, args...) \
+	xe_log_comp((any), CPER_SEV_RECOVERABLE, TAG, (data), (len), fmt, ##args)
+
+#define xe_log_comp_corrected(any, TAG, data, len, fmt, args...) \
+	xe_log_comp((any), CPER_SEV_CORRECTED, TAG, (data), (len), fmt, ##args)
+
+#define xe_log_comp_info(any, TAG, data, len, fmt, args...) \
+	xe_log_comp((any), CPER_SEV_INFORMATIONAL, TAG, (data), (len), fmt, ##args)
+
 #endif
Signature · 1 line
2.47.1
Reviewed-by on v4 9/32
#26 lore raw

Re: [PATCH v4 09/32] drm/xe/log: Add SIGID log helpers for component & severity

Quoted 5 lines · Michal Wajdeczko

There are only few CPER severity levels defined, add some helpers to avoid forcing developers to write full CPER severity enum name in every macro call.

LGTM,

Quoted 27 lines
Cc Rodrigo Vivi <[email protected]>
Cc Mallesh Koujalagi <[email protected]>
---
  drivers/gpu/drm/xe/xe_log.h | 12 ++++++++++++
  1 file changed, 12 insertions(+)
drivers/gpu/drm/xe/xe_log.h +12 -0
index c30db02950b0..c56306a183e7 100644
@@ -103,4 +103,16 @@ void xe_log_emit(struct pci_dev *pdev, int cper_sev, enum xe_sigid sigid,
  	xe_log_from((any), (cper_sev), (int)XE_LOG_COMPONENT_##TAG##_SIGID, \
  		    XE_LOG_COMPONENT_##TAG, (data), (len), fmt, ##args)
 
+#define xe_log_comp_fatal(any, TAG, data, len, fmt, args...) \
+	xe_log_comp((any), CPER_SEV_FATAL, TAG, (data), (len), fmt, ##args)
+
+#define xe_log_comp_recoverable(any, TAG, data, len, fmt, args...) \
+	xe_log_comp((any), CPER_SEV_RECOVERABLE, TAG, (data), (len), fmt, ##args)
+
+#define xe_log_comp_corrected(any, TAG, data, len, fmt, args...) \
+	xe_log_comp((any), CPER_SEV_CORRECTED, TAG, (data), (len), fmt, ##args)
+
+#define xe_log_comp_info(any, TAG, data, len, fmt, args...) \
+	xe_log_comp((any), CPER_SEV_INFORMATIONAL, TAG, (data), (len), fmt, ##args)
+
  #endif
#27 lore raw

PATCH v4 10/32 drm/xe/log: Add SIGID log helpers for errno-only

In reply to Michal Wajdeczko

For the software based SIGID errors, we will usually want to pass only the errno value as the data to be logged in the dmesg line or the CPER record. Add simple wrappers for that.

---
Cc: Aravind Iddamsetty <[email protected]>
---
v2: include linux/err.h (Sashiko)
add xe_log_err_corrected (Michal)
v3: use xe_log_comp_sev helpers (Mallesh)

---
 drivers/gpu/drm/xe/xe_log.h | 52 +++++++++++++++++++++++++++++++++++++
 1 file changed, 52 insertions(+)
drivers/gpu/drm/xe/xe_log.h +52 -0
index c56306a183e7..0928b0866617 100644
@@ -7,6 +7,7 @@
 #define _XE_LOG_H_
 
 #include <linux/cper.h>
+#include <linux/err.h>
 
 #include "abi/xe_log_abi.h"
 #include "abi/xe_sigid_abi.h"
@@ -115,4 +116,55 @@ void xe_log_emit(struct pci_dev *pdev, int cper_sev, enum xe_sigid sigid,
 #define xe_log_comp_info(any, TAG, data, len, fmt, args...) \
 	xe_log_comp((any), CPER_SEV_INFORMATIONAL, TAG, (data), (len), fmt, ##args)
 
+/**
+ * xe_log_err() - Emit a structured SIGID error log entry on the component behalf.
+ * @any: the &xe_device or &xe_tile or &xe_gt pointer this report relates to
+ * @TAG: the component tag to use
+ * @err: negative errno for the failing operation, or 0 if not applicable
+ * @fmt: printf-style free text format string (not a stable interface)
+ * @args: arguments for the @fmt format string
+ *
+ * The log entry will be emitted with @CPER_SEV_RECOVERABLE severity.
+ */
+#define xe_log_err(any, TAG, err, fmt, args...) \
+	xe_log_comp_recoverable((any), TAG, ERR_PTR(err), 0, fmt, ##args)
+
+/**
+ * xe_log_err_fatal() - Emit a structured SIGID error log entry on the component behalf.
+ * @any: the &xe_device or &xe_tile or &xe_gt pointer this report relates to
+ * @TAG: the component tag to use
+ * @err: negative errno for the failing operation, or 0 if not applicable
+ * @fmt: printf-style free text format string (not a stable interface)
+ * @args: arguments for the @fmt format string
+ *
+ * The log entry will be emitted with @CPER_SEV_FATAL severity.
+ */
+#define xe_log_err_fatal(any, TAG, err, fmt, args...) \
+	xe_log_comp_fatal((any), TAG, ERR_PTR(err), 0, fmt, ##args)
+
+/**
+ * xe_log_err_corrected() - Emit a structured SIGID error log entry on the component behalf.
+ * @any: the &xe_device or &xe_tile or &xe_gt pointer this report relates to
+ * @TAG: the component tag to use
+ * @err: negative errno for the failing operation, or 0 if not applicable
+ * @fmt: printf-style free text format string (not a stable interface)
+ * @args: arguments for the @fmt format string
+ *
+ * The log entry will be emitted with @CPER_SEV_CORRECTED severity.
+ */
+#define xe_log_err_corrected(any, TAG, err, fmt, args...) \
+	xe_log_comp_corrected((any), TAG, ERR_PTR(err), 0, fmt, ##args)
+
+/**
+ * xe_log_info() - Emit a structured SIGID information log entry on the component behalf.
+ * @any: the &xe_device or &xe_tile or &xe_gt pointer this report relates to
+ * @TAG: the component tag to use
+ * @fmt: printf-style free text format string (not a stable interface)
+ * @args: arguments for the @fmt format string
+ *
+ * The log entry will be emitted with @CPER_SEV_INFORMATIONAL severity.
+ */
+#define xe_log_info(any, TAG, fmt, args...) \
+	xe_log_comp_info((any), TAG, NULL, 0, fmt, ##args)
+
 #endif
Signature · 1 line
2.47.1
#28 lore raw

PATCH v4 11/32 drm/xe/log: Index all SIGID printk messages

In reply to Michal Wajdeczko

When CONFIG_PRINTK_INDEX is enabled, it is expected that all device level printk messages are indexed for audit. While usually this is done automatically behind the scenes when code is using regular dev_printk macros, since we are generating different dmesg messages inside xe_log_emit() based on the severity, component and location, we only get those entries in /sys/kernel/debug/printk/index/xe:

<3> drivers/gpu/drm/xe/xe_log.c:142 log_dmesg_vprintk "%s %s: [drm] *ERROR* %pV" <6> drivers/gpu/drm/xe/xe_log.c:140 log_dmesg_vprintk "%s %s: [drm] %pV"

Explicitly generate printk index using dev_printk_index_emit() with some generic prefix that includes the SIGID tag.

---
 drivers/gpu/drm/xe/xe_log.c |  8 ++++----
 drivers/gpu/drm/xe/xe_log.h | 14 +++++++++++---
 2 files changed, 15 insertions(+), 7 deletions(-)
drivers/gpu/drm/xe/xe_log.c +4 -4
index 0b423ed121cd..50a9b35e5b3e 100644
@@ -177,7 +177,7 @@ static void log_emit_dmesg(struct pci_dev *pdev, int cper_sev, enum xe_sigid sig
 }
 
 /**
- * xe_log_emit() - Emit a structured SIGID log entry
+ * __xe_log_emit() - Emit a structured SIGID log entry
  * @pdev: the &pci_dev device
  * @cper_sev: CPER severity (CPER_SEV_FATAL, CPER_SEV_RECOVERABLE, ...)
  * @sigid: signature identifier, see &enum xe_sigid
@@ -206,9 +206,9 @@ static void log_emit_dmesg(struct pci_dev *pdev, int cper_sev, enum xe_sigid sig
  *   <3> xe 0000:03:00.0: [drm] *ERROR* SIGID=106 (-ETIMEDOUT) Engine 'rcs0' hung
  *   <6> xe 0000:03:00.0: [drm] SIGID=103 In survivability mode
  */
-void xe_log_emit(struct pci_dev *pdev, int cper_sev, enum xe_sigid sigid,
-		 u32 component, u32 location, const void *data, size_t len,
-		 const char *fmt, ...)
+void __xe_log_emit(struct pci_dev *pdev, int cper_sev, enum xe_sigid sigid,
+		   u32 component, u32 location, const void *data, size_t len,
+		   const char *fmt, ...)
 {
 	struct va_format vaf;
 	va_list args;
drivers/gpu/drm/xe/xe_log.h +11 -3
index 0928b0866617..53fe2bb7ddd3 100644
@@ -16,9 +16,17 @@
 struct pci_dev;
 
 __printf(8, 9)
-void xe_log_emit(struct pci_dev *pdev, int cper_sev, enum xe_sigid sigid,
-		 u32 component, u32 location, const void *data, size_t len,
-		 const char *fmt, ...);
+void __xe_log_emit(struct pci_dev *pdev, int cper_sev, enum xe_sigid sigid,
+		   u32 component, u32 location, const void *data, size_t len,
+		   const char *fmt, ...);
+
+#define __xe_log_emit_printk_index(fmt) \
+	dev_printk_index_emit(NULL, "[drm]%s SIGID=%u %s(%s)%s%s%s: " fmt);
+
+#define xe_log_emit(pdev, sev, sig, comp, loc, data, len, fmt, args...) ({		\
+	__xe_log_emit_printk_index(fmt);						\
+	__xe_log_emit((pdev), (sev), (sig), (comp), (loc), (data), (len), fmt, ##args); \
+})
 
 #define xe_log_emit_fatal(pdev, sig, comp, loc, data, len, fmt, args...) \
 	xe_log_emit((pdev), CPER_SEV_FATAL, (sig), (comp), (loc), \
Signature · 1 line
2.47.1
#29 lore raw

Re: [PATCH v4 11/32] drm/xe/log: Index all SIGID printk messages

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Medium] The generic format string injected into the printk index does not structurally match the actual…

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] The generic format string injected into the printk index does not structurally match the actual strings emitted to dmesg, breaking userspace log matching. --

--- Patch [11]: [PATCH v4 11/32] drm/xe/log: Index all SIGID printk messages --- commit f6d6ae64e4098e49206f6df0c6d973a867e46f50
Author: Michal Wajdeczko <[email protected]>

drm/xe/log: Index all SIGID printk messages

This commit explicitly generates printk index entries using dev_printk_index_emit() for xe_log_emit() messages. This ensures that device level printk messages generated with varying prefixes are correctly indexed for audit.

Quoted 7 lines
drivers/gpu/drm/xe/xe_log.h +0 -0
index 0928b08666171..53fe2bb7ddd37 100644
@@ -16,9 +16,17 @@
 struct pci_dev;
 

drivers/gpu/drm/xe/xe_log.h line 24

Quoted 10 lines
drivers/gpu/drm/xe/xe_log.h +6 -3
 __printf(8, 9)
-void xe_log_emit(struct pci_dev *pdev, int cper_sev, enum xe_sigid sigid,
-		 u32 component, u32 location, const void *data, size_t len,
-		 const char *fmt, ...);
+void __xe_log_emit(struct pci_dev *pdev, int cper_sev, enum xe_sigid sigid,
+		   u32 component, u32 location, const void *data, size_t len,
+		   const char *fmt, ...);
+
+#define __xe_log_emit_printk_index(fmt) \
+	dev_printk_index_emit(NULL, "[drm]%s SIGID=%u %s(%s)%s%s%s: " fmt);

[Severity: Medium]
Does this hardcoded format string structurally diverge from the actual strings emitted to dmesg?

Looking at log_emit_dmesg() in drivers/gpu/drm/xe/xe_log.c, when the data parameter is NULL, the format string dynamically omits the parentheses:

	else
		log_dmesg_printf(pdev, cper_sev, "SIGID=%u %s%s%s%s%pV",
				 sigid, sev_prefix, hwe_prefix,
				 loc_prefix, comp_prefix, vaf);

Since the static string registered here contains literal parentheses and a trailing colon, but these characters are dynamically omitted when data is NULL or component is 0, will this mismatch cause regexes or exact-match parsers generated from the index to fail to match the logs?

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=11
Reviewed-by on v4 11/32
#30 lore raw

Re: [PATCH v4 11/32] drm/xe/log: Index all SIGID printk messages

In reply to Michal Wajdeczko
Quoted 55 lines · Michal Wajdeczko

When CONFIG_PRINTK_INDEX is enabled, it is expected that all device level printk messages are indexed for audit. While usually this is done automatically behind the scenes when code is using regular dev_printk macros, since we are generating different dmesg messages inside xe_log_emit() based on the severity, component and location, we only get those entries in /sys/kernel/debug/printk/index/xe:

   <3> drivers/gpu/drm/xe/xe_log.c:142 log_dmesg_vprintk "%s %s: [drm] *ERROR* %pV"
   <6> drivers/gpu/drm/xe/xe_log.c:140 log_dmesg_vprintk "%s %s: [drm] %pV"

Explicitly generate printk index using dev_printk_index_emit() with some generic prefix that includes the SIGID tag.

---
  drivers/gpu/drm/xe/xe_log.c |  8 ++++----
  drivers/gpu/drm/xe/xe_log.h | 14 +++++++++++---
  2 files changed, 15 insertions(+), 7 deletions(-)
drivers/gpu/drm/xe/xe_log.c +4 -4
index 0b423ed121cd..50a9b35e5b3e 100644
@@ -177,7 +177,7 @@ static void log_emit_dmesg(struct pci_dev *pdev, int cper_sev, enum xe_sigid sig
  }
 
  /**
- * xe_log_emit() - Emit a structured SIGID log entry
+ * __xe_log_emit() - Emit a structured SIGID log entry
   * @pdev: the &pci_dev device
   * @cper_sev: CPER severity (CPER_SEV_FATAL, CPER_SEV_RECOVERABLE, ...)
   * @sigid: signature identifier, see &enum xe_sigid
@@ -206,9 +206,9 @@ static void log_emit_dmesg(struct pci_dev *pdev, int cper_sev, enum xe_sigid sig
   *   <3> xe 0000:03:00.0: [drm] *ERROR* SIGID=106 (-ETIMEDOUT) Engine 'rcs0' hung
   *   <6> xe 0000:03:00.0: [drm] SIGID=103 In survivability mode
   */
-void xe_log_emit(struct pci_dev *pdev, int cper_sev, enum xe_sigid sigid,
-		 u32 component, u32 location, const void *data, size_t len,
-		 const char *fmt, ...)
+void __xe_log_emit(struct pci_dev *pdev, int cper_sev, enum xe_sigid sigid,
+		   u32 component, u32 location, const void *data, size_t len,
+		   const char *fmt, ...)
  {
  	struct va_format vaf;
  	va_list args;
drivers/gpu/drm/xe/xe_log.h +0 -0
index 0928b0866617..53fe2bb7ddd3 100644
@@ -16,9 +16,17 @@
  struct pci_dev;
 

drivers/gpu/drm/xe/xe_log.h line 24

Quoted 10 lines
drivers/gpu/drm/xe/xe_log.h +6 -3
  __printf(8, 9)
-void xe_log_emit(struct pci_dev *pdev, int cper_sev, enum xe_sigid sigid,
-		 u32 component, u32 location, const void *data, size_t len,
-		 const char *fmt, ...);
+void __xe_log_emit(struct pci_dev *pdev, int cper_sev, enum xe_sigid sigid,
+		   u32 component, u32 location, const void *data, size_t len,
+		   const char *fmt, ...);
+
+#define __xe_log_emit_printk_index(fmt) \
+	dev_printk_index_emit(NULL, "[drm]%s SIGID=%u %s(%s)%s%s%s: " fmt);

We need to change format for a. error path b. blob path c. plain or info path right?

drivers/gpu/drm/xe/xe_log.h line 29

Quoted 5 lines
drivers/gpu/drm/xe/xe_log.h +5 -0
+
+#define xe_log_emit(pdev, sev, sig, comp, loc, data, len, fmt, args...) ({		\
+	__xe_log_emit_printk_index(fmt);						\
+	__xe_log_emit((pdev), (sev), (sig), (comp), (loc), (data), (len), fmt, ##args); \
+})

nit: use do{} while (0)

Quoted 3 lines
drivers/gpu/drm/xe/xe_log.h +0 -0
  #define xe_log_emit_fatal(pdev, sig, comp, loc, data, len, fmt, args...) \
  	xe_log_emit((pdev), CPER_SEV_FATAL, (sig), (comp), (loc), \
#31 lore raw

Re: [PATCH v4 11/32] drm/xe/log: Index all SIGID printk messages

Quoted 58 lines · Koujalagi
Quoted 56 lines · Michal Wajdeczko

When CONFIG_PRINTK_INDEX is enabled, it is expected that all device level printk messages are indexed for audit. While usually this is done automatically behind the scenes when code is using regular dev_printk macros, since we are generating different dmesg messages inside xe_log_emit() based on the severity, component and location, we only get those entries in /sys/kernel/debug/printk/index/xe:

   <3> drivers/gpu/drm/xe/xe_log.c:142 log_dmesg_vprintk "%s %s: [drm] *ERROR* %pV" <6> drivers/gpu/drm/xe/xe_log.c:140 log_dmesg_vprintk "%s %s: [drm] %pV"

Explicitly generate printk index using dev_printk_index_emit() with some generic prefix that includes the SIGID tag.

---
  drivers/gpu/drm/xe/xe_log.c |  8 ++++----
  drivers/gpu/drm/xe/xe_log.h | 14 +++++++++++---

  2 files changed, 15 insertions(+), 7 deletions(-)
drivers/gpu/drm/xe/xe_log.c +4 -4
index 0b423ed121cd..50a9b35e5b3e 100644
@@ -177,7 +177,7 @@ static void log_emit_dmesg(struct pci_dev *pdev, int cper_sev, enum xe_sigid sig
   }
     /**
- * xe_log_emit() - Emit a structured SIGID log entry
+ * __xe_log_emit() - Emit a structured SIGID log entry
    * @pdev: the &pci_dev device
    * @cper_sev: CPER severity (CPER_SEV_FATAL, CPER_SEV_RECOVERABLE, ...)
    * @sigid: signature identifier, see &enum xe_sigid
@@ -206,9 +206,9 @@ static void log_emit_dmesg(struct pci_dev *pdev, int cper_sev, enum xe_sigid sig
    *   <3> xe 0000:03:00.0: [drm] *ERROR* SIGID=106 (-ETIMEDOUT) Engine 'rcs0' hung
    *   <6> xe 0000:03:00.0: [drm] SIGID=103 In survivability mode
    */
-void xe_log_emit(struct pci_dev *pdev, int cper_sev, enum xe_sigid sigid,
-         u32 component, u32 location, const void *data, size_t len,
-         const char *fmt, ...)
+void __xe_log_emit(struct pci_dev *pdev, int cper_sev, enum xe_sigid sigid,
+           u32 component, u32 location, const void *data, size_t len,
+           const char *fmt, ...)
   {
       struct va_format vaf;
       va_list args;
drivers/gpu/drm/xe/xe_log.h +0 -2
index 0928b0866617..53fe2bb7ddd3 100644
@@ -16,9 +16,17 @@
   struct pci_dev;
     __printf(8, 9)
-void xe_log_emit(struct pci_dev *pdev, int cper_sev, enum xe_sigid sigid,
-         u32 component, u32 location, const void *data, size_t len,
Quoted 8 lines

drivers/gpu/drm/xe/xe_log.h line 24

Quoted 7 lines
drivers/gpu/drm/xe/xe_log.h +6 -1
-         const char *fmt, ...);
+void __xe_log_emit(struct pci_dev *pdev, int cper_sev, enum xe_sigid sigid,
+           u32 component, u32 location, const void *data, size_t len,
+           const char *fmt, ...);
+
+#define __xe_log_emit_printk_index(fmt) \
+    dev_printk_index_emit(NULL, "[drm]%s SIGID=%u %s(%s)%s%s%s: " fmt);

We need to change format for a. error path b. blob path c. plain or info path right?

well, that's not doable as final format/output depends on the severity and data value, which could be non-const at compile time, while printk-index requires this to emit right entry

I can change that to a something more generic (and unfriendly), like:

    dev_printk_index_emit(NULL, "%sSIGID=%u %s" fmt);

but that will catch and match all our outputs.

@Jani, are you OK with that?

Quoted 12 lines

drivers/gpu/drm/xe/xe_log.h line 29

Quoted 5 lines
drivers/gpu/drm/xe/xe_log.h +5 -0
+
+#define xe_log_emit(pdev, sev, sig, comp, loc, data, len, fmt, args...) ({        \
+    __xe_log_emit_printk_index(fmt);                        \
+    __xe_log_emit((pdev), (sev), (sig), (comp), (loc), (data), (len), fmt, ##args); \
+})

nit: use do{} while (0)

Quoted 2 lines
drivers/gpu/drm/xe/xe_log.h +0 -0
     #define xe_log_emit_fatal(pdev, sig, comp, loc, data, len, fmt, args...) \
       xe_log_emit((pdev), CPER_SEV_FATAL, (sig), (comp), (loc), \
#32 lore raw

Re: [PATCH v4 11/32] drm/xe/log: Index all SIGID printk messages

Quoted 74 lines · Michal Wajdeczko
Quoted 58 lines · Koujalagi
Quoted 56 lines · Michal Wajdeczko

When CONFIG_PRINTK_INDEX is enabled, it is expected that all device level printk messages are indexed for audit. While usually this is done automatically behind the scenes when code is using regular dev_printk macros, since we are generating different dmesg messages inside xe_log_emit() based on the severity, component and location, we only get those entries in /sys/kernel/debug/printk/index/xe:

   <3> drivers/gpu/drm/xe/xe_log.c:142 log_dmesg_vprintk "%s %s: [drm] *ERROR* %pV" <6> drivers/gpu/drm/xe/xe_log.c:140 log_dmesg_vprintk "%s %s: [drm] %pV"

Explicitly generate printk index using dev_printk_index_emit() with some generic prefix that includes the SIGID tag.

---
  drivers/gpu/drm/xe/xe_log.c |  8 ++++----
  drivers/gpu/drm/xe/xe_log.h | 14 +++++++++++---

  2 files changed, 15 insertions(+), 7 deletions(-)
drivers/gpu/drm/xe/xe_log.c +4 -4
index 0b423ed121cd..50a9b35e5b3e 100644
@@ -177,7 +177,7 @@ static void log_emit_dmesg(struct pci_dev *pdev, int cper_sev, enum xe_sigid sig
   }
     /**
- * xe_log_emit() - Emit a structured SIGID log entry
+ * __xe_log_emit() - Emit a structured SIGID log entry
    * @pdev: the &pci_dev device
    * @cper_sev: CPER severity (CPER_SEV_FATAL, CPER_SEV_RECOVERABLE, ...)
    * @sigid: signature identifier, see &enum xe_sigid
@@ -206,9 +206,9 @@ static void log_emit_dmesg(struct pci_dev *pdev, int cper_sev, enum xe_sigid sig
    *   <3> xe 0000:03:00.0: [drm] *ERROR* SIGID=106 (-ETIMEDOUT) Engine 'rcs0' hung
    *   <6> xe 0000:03:00.0: [drm] SIGID=103 In survivability mode
    */
-void xe_log_emit(struct pci_dev *pdev, int cper_sev, enum xe_sigid sigid,
-         u32 component, u32 location, const void *data, size_t len,
-         const char *fmt, ...)
+void __xe_log_emit(struct pci_dev *pdev, int cper_sev, enum xe_sigid sigid,
+           u32 component, u32 location, const void *data, size_t len,
+           const char *fmt, ...)
   {
       struct va_format vaf;
       va_list args;
drivers/gpu/drm/xe/xe_log.h +0 -2
index 0928b0866617..53fe2bb7ddd3 100644
@@ -16,9 +16,17 @@
   struct pci_dev;
     __printf(8, 9)
-void xe_log_emit(struct pci_dev *pdev, int cper_sev, enum xe_sigid sigid,
-         u32 component, u32 location, const void *data, size_t len,
Quoted 8 lines

drivers/gpu/drm/xe/xe_log.h line 24

Quoted 7 lines
drivers/gpu/drm/xe/xe_log.h +6 -1
-         const char *fmt, ...);
+void __xe_log_emit(struct pci_dev *pdev, int cper_sev, enum xe_sigid sigid,
+           u32 component, u32 location, const void *data, size_t len,
+           const char *fmt, ...);
+
+#define __xe_log_emit_printk_index(fmt) \
+    dev_printk_index_emit(NULL, "[drm]%s SIGID=%u %s(%s)%s%s%s: " fmt);

We need to change format for a. error path b. blob path c. plain or info path right?

well, that's not doable as final format/output depends on the severity and data value, which could be non-const at compile time, while printk-index requires this to emit right entry

Quoted 5 lines

I can change that to a something more generic (and unfriendly), like:

    dev_printk_index_emit(NULL, "%sSIGID=%u %s" fmt);

but that will catch and match all our outputs.

and this is how this will look like for current series:

$ sudo cat /sys/kernel/debug/printk/index/xe | grep SIGID
<3> drivers/gpu/drm/xe/xe_device.c:1481 xe_device_declare_wedged "%s %s: %s SIGID=%u %sDevice declared wedged!\n"
<3> drivers/gpu/drm/xe/xe_gt.c:977 gt_reset_worker "%s %s: %s SIGID=%u %sreset failed\n"
<6> drivers/gpu/drm/xe/xe_gt.c:968 gt_reset_worker "%s %s: %s SIGID=%u %sreset done\n"
<6> drivers/gpu/drm/xe/xe_gt.c:929 gt_reset_worker "%s %s: %s SIGID=%u %sreset started\n"
<3> drivers/gpu/drm/xe/xe_guc.c:1620 xe_guc_mmio_send_recv "%s %s: %s SIGID=%u %sMMIO request %#x: unexpected reply %#x\n"
<3> drivers/gpu/drm/xe/xe_guc.c:1612 xe_guc_mmio_send_recv "%s %s: %s SIGID=%u %sMMIO request %#x: failure %#x hint %#x\n"
<3> drivers/gpu/drm/xe/xe_guc.c:1556 xe_guc_mmio_send_recv "%s %s: %s SIGID=%u %sMMIO request %#x: no reply %#x\n"
<3> drivers/gpu/drm/xe/xe_guc.c:1546 xe_guc_mmio_send_recv "%s %s: %s SIGID=%u %sMMIO request %#x: lost, too many retries %u\n"
<3> drivers/gpu/drm/xe/xe_pagefault.c:631 xe_pagefault_queue_work "%s %s: %s SIGID=%u %sUnsuccessful response\n"
<3> drivers/gpu/drm/xe/xe_pagefault.c:332 xe_pagefault_queue_add "%s %s: %s SIGID=%u %sQueue full!\n"
<3> drivers/gpu/drm/xe/xe_pci.c:1181 xe_pci_probe "%s %s: %s SIGID=%u %sdriver loading failed for device '%04x'\n"
<6> drivers/gpu/drm/xe/xe_pci.c:1171 xe_pci_probe "%s %s: %s SIGID=%u %sdriver loading blocked for device '%04x'\n"
<3> drivers/gpu/drm/xe/xe_pci_error.c:102 xe_pci_error_slot_reset "%s %s: %s SIGID=%u %sCannot re-enable PCI device after reset\n"
<3> drivers/gpu/drm/xe/xe_pcode.c:321 xe_pcode_ready "%s %s: %s SIGID=%u %sinitialization timedout after %ld seconds\n"
<3> drivers/gpu/drm/xe/xe_pcode.c:221 xe_pcode_request "%s %s: %s SIGID=%u %stimeout, retrying with preemption disabled\n"
<3> drivers/gpu/drm/xe/xe_pcode.c:65 pcode_mailbox_status "%s %s: %s SIGID=%u %sMailbox failed: %s\n"
<6> drivers/gpu/drm/xe/xe_survivability_mode.c:440 log_survivability_info "%s %s: %s SIGID=%u %s%s: %#x\n"
<3> drivers/gpu/drm/xe/xe_survivability_mode.c:433 log_survivability_info "%s %s: %s SIGID=%u %sBoot Status: %s (%u)\n"
<6> drivers/gpu/drm/xe/xe_survivability_mode.c:422 xe_survivability_mode_runtime_enable "%s %s: %s SIGID=%u %sFirmware flash required!\n"
<6> drivers/gpu/drm/xe/xe_survivability_mode.c:417 xe_survivability_mode_runtime_enable "%s %s: %s SIGID=%u %sRuntime Mode enabled!\n"
<3> drivers/gpu/drm/xe/xe_survivability_mode.c:409 xe_survivability_mode_runtime_enable "%s %s: %s SIGID=%u %sRuntime Mode not supported!\n"
<3> drivers/gpu/drm/xe/xe_survivability_mode.c:344 enable_boot_survivability_mode "%s %s: %s SIGID=%u %sFailed to enable Boot Mode!\n"
<6> drivers/gpu/drm/xe/xe_survivability_mode.c:339 enable_boot_survivability_mode "%s %s: %s SIGID=%u %sBoot Mode enabled!\n"
<3> drivers/gpu/drm/xe/xe_survivability_mode.c:334 enable_boot_survivability_mode "%s %s: %s SIGID=%u %sBoot Mode enabled!\n"
<3> drivers/gpu/drm/xe/xe_survivability_mode.c:302 create_survivability_sysfs "%s %s: %s SIGID=%u %sFailed to create sysfs files!\n"
Quoted 16 lines

@Jani, are you OK with that?

Quoted 12 lines

drivers/gpu/drm/xe/xe_log.h line 29

Quoted 5 lines
drivers/gpu/drm/xe/xe_log.h +5 -0
+
+#define xe_log_emit(pdev, sev, sig, comp, loc, data, len, fmt, args...) ({        \
+    __xe_log_emit_printk_index(fmt);                        \
+    __xe_log_emit((pdev), (sev), (sig), (comp), (loc), (data), (len), fmt, ##args); \
+})

nit: use do{} while (0)

Quoted 2 lines
drivers/gpu/drm/xe/xe_log.h +0 -0
     #define xe_log_emit_fatal(pdev, sig, comp, loc, data, len, fmt, args...) \
       xe_log_emit((pdev), CPER_SEV_FATAL, (sig), (comp), (loc), \
#33 lore raw

PATCH v4 12/32 drm/xe/log: Add hardware error signatures

In reply to Michal Wajdeczko

Extend our error signatures definitions xe_sigid to cover also hardware-originated errors and make them distinguishable from initially defined software-initiated errors.

Cc Rodrigo Vivi <[email protected]>
Cc Yoni Levitt <[email protected]>
Cc Mallesh Koujalagi <[email protected]>

---
v2: update comment (Sashiko)
v3: rebased

---
 drivers/gpu/drm/xe/abi/xe_sigid_abi.h | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)
drivers/gpu/drm/xe/abi/xe_sigid_abi.h +14 -1
index 93967183ae51..8e3c7ef579b9 100644
@@ -137,12 +137,18 @@
  * @XE_SIGID_GT_TDR: Engine hang / timeout detection and recovery (reset).
  * @XE_SIGID_MEM_FAULT: VM bind, page fault or GTT fault.
  * @XE_SIGID_IO_BUS: Runtime PCIe / IOMMU / MMIO access fault.
+ * @XE_SIGID_HW: Generic hardware failure.
+ * @XE_SIGID_PCIE: PCIe interface errors.
+ * @XE_SIGID_DEVICE_MEMORY: Device memory errors.
+ * @XE_SIGID_CORE_COMPUTE: Compute/shader core errors.
+ * @XE_SIGID_FABRIC: Fabric errors.
+ * @XE_SIGID_SOC_INTERNAL: SoC-internal errors.
  *
  * Each SIGID represents the report sites the driver detects and reports.
  * Values are numbered sequentially, are only ever appended, and are never
  * renumbered or reused.
  *
- * Firmware- and hardware-originated signatures are not listed yet here.
+ * Firmware- and hardware-originated signatures are numbered separately.
  */
 enum xe_sigid {
 	XE_SIGID_SW			= INTEL_SIGID_GPU_XE_SOFTWARE_START,
@@ -154,6 +160,13 @@ enum xe_sigid {
 	XE_SIGID_GT_TDR			= INTEL_SIGID_GPU_XE_SOFTWARE_START + 6,
 	XE_SIGID_MEM_FAULT		= INTEL_SIGID_GPU_XE_SOFTWARE_START + 7,
 	XE_SIGID_IO_BUS			= INTEL_SIGID_GPU_XE_SOFTWARE_START + 8,
+
+	XE_SIGID_HW			= INTEL_SIGID_GPU_XE_HARDWARE_START,
+	XE_SIGID_PCIE			= INTEL_SIGID_GPU_XE_HARDWARE_START + 1,
+	XE_SIGID_DEVICE_MEMORY		= INTEL_SIGID_GPU_XE_HARDWARE_START + 2,
+	XE_SIGID_CORE_COMPUTE		= INTEL_SIGID_GPU_XE_HARDWARE_START + 3,
+	XE_SIGID_FABRIC			= INTEL_SIGID_GPU_XE_HARDWARE_START + 4,
+	XE_SIGID_SOC_INTERNAL		= INTEL_SIGID_GPU_XE_HARDWARE_START + 5,
 };
 
 #endif
Signature · 1 line
2.47.1
Reviewed-by on v4 12/32
#34 lore raw

Re: [PATCH v4 12/32] drm/xe/log: Add hardware error signatures

Quoted 5 lines · Michal Wajdeczko

Extend our error signatures definitions xe_sigid to cover also hardware-originated errors and make them distinguishable from initially defined software-initiated errors.

Please add "firmware/hardware-originated errors" in comment message.

Quoted 48 lines
Cc Rodrigo Vivi <[email protected]>
Cc Yoni Levitt <[email protected]>
Cc Mallesh Koujalagi <[email protected]>

---
v2: update comment (Sashiko)
v3: rebased

---
  drivers/gpu/drm/xe/abi/xe_sigid_abi.h | 15 ++++++++++++++-
  1 file changed, 14 insertions(+), 1 deletion(-)
drivers/gpu/drm/xe/abi/xe_sigid_abi.h +14 -1
index 93967183ae51..8e3c7ef579b9 100644
@@ -137,12 +137,18 @@
   * @XE_SIGID_GT_TDR: Engine hang / timeout detection and recovery (reset).
   * @XE_SIGID_MEM_FAULT: VM bind, page fault or GTT fault.
   * @XE_SIGID_IO_BUS: Runtime PCIe / IOMMU / MMIO access fault.
+ * @XE_SIGID_HW: Generic hardware failure.
+ * @XE_SIGID_PCIE: PCIe interface errors.
+ * @XE_SIGID_DEVICE_MEMORY: Device memory errors.
+ * @XE_SIGID_CORE_COMPUTE: Compute/shader core errors.
+ * @XE_SIGID_FABRIC: Fabric errors.
+ * @XE_SIGID_SOC_INTERNAL: SoC-internal errors.
   *
   * Each SIGID represents the report sites the driver detects and reports.
   * Values are numbered sequentially, are only ever appended, and are never
   * renumbered or reused.
   *
- * Firmware- and hardware-originated signatures are not listed yet here.
+ * Firmware- and hardware-originated signatures are numbered separately.
   */
  enum xe_sigid {
  	XE_SIGID_SW			= INTEL_SIGID_GPU_XE_SOFTWARE_START,
@@ -154,6 +160,13 @@ enum xe_sigid {
  	XE_SIGID_GT_TDR			= INTEL_SIGID_GPU_XE_SOFTWARE_START + 6,
  	XE_SIGID_MEM_FAULT		= INTEL_SIGID_GPU_XE_SOFTWARE_START + 7,
  	XE_SIGID_IO_BUS			= INTEL_SIGID_GPU_XE_SOFTWARE_START + 8,
+
+	XE_SIGID_HW			= INTEL_SIGID_GPU_XE_HARDWARE_START,
+	XE_SIGID_PCIE			= INTEL_SIGID_GPU_XE_HARDWARE_START + 1,
+	XE_SIGID_DEVICE_MEMORY		= INTEL_SIGID_GPU_XE_HARDWARE_START + 2,
+	XE_SIGID_CORE_COMPUTE		= INTEL_SIGID_GPU_XE_HARDWARE_START + 3,
+	XE_SIGID_FABRIC			= INTEL_SIGID_GPU_XE_HARDWARE_START + 4,
+	XE_SIGID_SOC_INTERNAL		= INTEL_SIGID_GPU_XE_HARDWARE_START + 5,
  };
 
  #endif
#35 lore raw

PATCH v4 13/32 drm/xe/log: Extend components list with hardware items

In reply to Michal Wajdeczko

Update our super macro with new top level hardware components.

---
v2: follow enum xe_ras_component values (Aravind)
v3: use same COMP tags as in SIGID (Riana)

---
 drivers/gpu/drm/xe/abi/xe_log_abi.h | 12 ++++++++++++
 1 file changed, 12 insertions(+)
drivers/gpu/drm/xe/abi/xe_log_abi.h +12 -0
index 92547805326f..bb29003e2646 100644
@@ -130,6 +130,10 @@ enum xe_log_location_bits {
  *     @SIGID is the default xe_sigid for the component (without the XE_SIGID_ prefix)
  */
 #define DEFINE_XE_LOG_COMPONENTS(define) \
+	DEFINE_XE_LOG_SOFTWARE_COMPONENTS(define) \
+	DEFINE_XE_LOG_HARDWARE_COMPONENTS(define)
+
+#define DEFINE_XE_LOG_SOFTWARE_COMPONENTS(define) \
 	/* */									\
 	define(SYSTEM, 1, PCI, SW, "Linux PCI Subsystem")			\
 	define(SYSTEM, 2, DRM, SW, "DRM")					\
@@ -157,6 +161,14 @@ enum xe_log_location_bits {
 	define(DRIVER_FIRMWARE, 3, GSC, RUNTIME_FW, "GSC")			\
 	define(DRIVER_FIRMWARE, 16, PCODE, DEVICE_FW, "PCode")			\
 	define(DRIVER_FIRMWARE, 17, SYSCTRL, DEVICE_FW, "System Controller")	\
+
+#define DEFINE_XE_LOG_HARDWARE_COMPONENTS(define) \
+	define(HARDWARE, 1, DEVICE_MEMORY, DEVICE_MEMORY, "Device Memory")	\
+	define(HARDWARE, 2, CORE_COMPUTE, CORE_COMPUTE, "Core Compute")		\
+	/*     HARDWARE, 3, RESERVED */						\
+	define(HARDWARE, 4, PCIE, PCIE, "PCIe Interface")			\
+	define(HARDWARE, 5, FABRIC, FABRIC, "Fabric")				\
+	define(HARDWARE, 6, SOC_INTERNAL, SOC_INTERNAL, "SoC Internal")		\
 	/* eod */
 
 /**
Signature · 1 line
2.47.1
#36 lore raw

PATCH v4 14/32 drm/xe/ras: Check RAS and LOG component definitions

In reply to Michal Wajdeczko

While not strictly required, we want to make sure that components definitions used by the RAS firmware are in the same fixed relation with HW components definitions used by the LOG infrastructure to allow code simplification. Add static asserts to enforce that.

---
v2: rebased after comp tag renames (Michal)

---
 drivers/gpu/drm/xe/xe_ras.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
drivers/gpu/drm/xe/xe_ras.c +11 -0
index 93e45ef49bae..18f05a55fc61 100644
@@ -5,6 +5,7 @@
 
 #include "xe_device.h"
 #include "xe_drm_ras.h"
+#include "xe_log.h"
 #include "xe_pm.h"
 #include "xe_printk.h"
 #include "xe_ras.h"
@@ -45,6 +46,16 @@ enum xe_ras_component {
 	XE_RAS_COMP_MAX
 };
 
+#define CHECK_COMPONENT(RAS_COMP, LOG_COMP) \
+	static_assert(MAKE_XE_LOG_COMPONENT(HARDWARE, (RAS_COMP)) == (LOG_COMP))
+	/* make sure components definitions maintain stable relation */
+	CHECK_COMPONENT(XE_RAS_COMP_DEVICE_MEMORY, XE_LOG_COMPONENT_DEVICE_MEMORY);
+	CHECK_COMPONENT(XE_RAS_COMP_CORE_COMPUTE, XE_LOG_COMPONENT_CORE_COMPUTE);
+	CHECK_COMPONENT(XE_RAS_COMP_PCIE, XE_LOG_COMPONENT_PCIE);
+	CHECK_COMPONENT(XE_RAS_COMP_FABRIC, XE_LOG_COMPONENT_FABRIC);
+	CHECK_COMPONENT(XE_RAS_COMP_SOC_INTERNAL, XE_LOG_COMPONENT_SOC_INTERNAL);
+#undef CHECK_COMPONENT
+
 /* RAS response status codes */
 enum xe_ras_response_status {
 	XE_RAS_STATUS_SUCCESS = 0,
Signature · 1 line
2.47.1
#37 lore raw

PATCH v4 15/32 drm/xe/kunit: Setup driver data in the test device

In reply to Michal Wajdeczko

While we have helpers pdev_to_xe_device() and kdev_to_xe_device() to obtain the xe_device pointer from the struct device pointer or from the struct pci_dev pointer, we must also setup the drm_device pointer as driver data in the device to make them work.

---
 drivers/gpu/drm/xe/tests/xe_kunit_helpers.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/gpu/drm/xe/tests/xe_kunit_helpers.c +4 -0
index bc5156966ce9..27740b40c8ae 100644
@@ -39,6 +39,10 @@ struct xe_device *xe_kunit_helper_alloc_xe_device(struct kunit *test,
 					       struct xe_device,
 					       drm, DRIVER_GEM);
 	KUNIT_ASSERT_NOT_ERR_OR_NULL(test, xe);
+
+	dev_set_drvdata(xe->drm.dev, &xe->drm);
+	KUNIT_ASSERT_PTR_EQ(test, xe, kdev_to_xe_device(dev));
+
 	return xe;
 }
 EXPORT_SYMBOL_IF_KUNIT(xe_kunit_helper_alloc_xe_device);
Signature · 1 line
2.47.1
#38 lore raw

PATCH v4 16/32 drm/xe/tests: Add Kunit tests for xe_log

In reply to Michal Wajdeczko

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.

---
Cc: Aravind Iddamsetty <[email protected]>
Cc: Yoni Levitt <[email protected]>
---
v2: less demos/more tests (Michal)
v3: expect tile.id is already set (Michal)
add invalid params test (Michal)
v4: move/drop err local var (Mallesh/Michal)

---
 drivers/gpu/drm/xe/tests/xe_log_kunit.c | 543 ++++++++++++++++++++++++
 drivers/gpu/drm/xe/xe_log.c             |  11 +
 2 files changed, 554 insertions(+)
 create mode 100644 drivers/gpu/drm/xe/tests/xe_log_kunit.c
drivers/gpu/drm/xe/tests/xe_log_kunit.c new file +543 -0
new file mode 100644
index 000000000000..b524db818f8b
@@ -0,0 +1,543 @@
+// 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;
+
+	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))
+		pr_info("CPER ERR=%ld \t\t# %pe\n", PTR_ERR(data), 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);
drivers/gpu/drm/xe/xe_log.c +11 -0
index 50a9b35e5b3e..5b56f69ce559 100644
@@ -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 */
 }
 
@@ -132,6 +137,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
@@ -222,3 +229,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
Signature · 1 line
2.47.1
#39 lore raw

Re: [PATCH v4 16/32] drm/xe/tests: Add Kunit tests for xe_log

Quoted 90 lines · Michal Wajdeczko

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.

---
Cc: Aravind Iddamsetty<[email protected]>
Cc: Yoni Levitt<[email protected]>
---
v2: less demos/more tests (Michal)
v3: expect tile.id is already set (Michal)
add invalid params test (Michal)
v4: move/drop err local var (Mallesh/Michal)

---
  drivers/gpu/drm/xe/tests/xe_log_kunit.c | 543 ++++++++++++++++++++++++
  drivers/gpu/drm/xe/xe_log.c             |  11 +
  2 files changed, 554 insertions(+)

create mode 100644 drivers/gpu/drm/xe/tests/xe_log_kunit.c

drivers/gpu/drm/xe/tests/xe_log_kunit.c new file +62 -0
new file mode 100644
index 000000000000..b524db818f8b
@@ -0,0 +1,543 @@
+// 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;
+
+	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));

drivers/gpu/drm/xe/tests/xe_log_kunit.c line 72

Quoted 10 lines
drivers/gpu/drm/xe/tests/xe_log_kunit.c new file +10 -0
+	if (IS_ERR(data))
+		pr_info("CPER ERR=%ld \t\t# %pe\n", PTR_ERR(data), 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");
+}

As I understood this is to validate parameters passed. Otherwise, the optional CPER dump would simply contain the raw CPER buffer, for example:

|[ 12.413289] xe 0000:03:00.0: [drm] <cper dump> 43 50 45 52 00 01 ff ff ff ff 02 00 00 00 00 00 ...|

Thanks,
Badal

Quoted 511 lines
drivers/gpu/drm/xe/tests/xe_log_kunit.c new file +471 -0
+
+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);
drivers/gpu/drm/xe/xe_log.c +11 -0
index 50a9b35e5b3e..5b56f69ce559 100644
@@ -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 */
  }
 
@@ -132,6 +137,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
@@ -222,3 +229,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
#40 lore raw

Re: [PATCH v4 16/32] drm/xe/tests: Add Kunit tests for xe_log

Quoted 6 lines · Badal
Quoted 4 lines · Michal Wajdeczko

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.

..

Quoted 20 lines
Quoted 20 lines
drivers/gpu/drm/xe/tests/xe_log_kunit.c new file +20 -0
+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;
+
+	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))
+		pr_info("CPER ERR=%ld \t\t# %pe\n", PTR_ERR(data), data);
+	else if (len)
Quoted 8 lines

drivers/gpu/drm/xe/tests/xe_log_kunit.c line 72

Quoted 7 lines
drivers/gpu/drm/xe/tests/xe_log_kunit.c new file +7 -0
+		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");
+}

As I understood this is to validate parameters passed.

yes, this demo is more to prove that the right params are passed to the log_emit_cper() which today is just a placeholder

Quoted 3 lines

Otherwise, the optional CPER dump would simply contain the raw CPER buffer, for example:

|[ 12.413289] xe 0000:03:00.0: [drm] <cper dump> 43 50 45 52 00 01 ff ff ff ff 02 00 00 00 00 00 ...|

whatever you do after creating full CPER is up to you likely we will need another STUB_REDIRECT to check raw CPER records, but that's another discussion

Quoted 4 lines

Thanks,
Badal

Quoted 1 line

+

#41 lore raw

PATCH v4 17/32 drm/xe/tests: Add kunit tests for xe_any

In reply to Michal Wajdeczko

Add simple sanity tests for all xe_any macros to make sure they are working as expected.

---
v2: add test_if_pdev, check drm casts (Mallesh)

---
 drivers/gpu/drm/xe/tests/Makefile       |   1 +
 drivers/gpu/drm/xe/tests/xe_any_kunit.c | 213 ++++++++++++++++++++++++
 2 files changed, 214 insertions(+)
 create mode 100644 drivers/gpu/drm/xe/tests/xe_any_kunit.c
drivers/gpu/drm/xe/tests/Makefile +1 -0
index f7aa47f11a36..0b809a252cfa 100644
@@ -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 \
drivers/gpu/drm/xe/tests/xe_any_kunit.c new file +213 -0

213 lines not on this page · raw message

Signature · 1 line
2.47.1
#42 lore raw

PATCH v4 18/32 drm/xe: Report 'probe blocked' error using SIGID

In reply to Michal Wajdeczko

Report 'driver loading blocked' error using xe_log_info() helper.

Cc Rodrigo Vivi <[email protected]>
Cc Aravind Iddamsetty <[email protected]>
Cc Mallesh Koujalagi <[email protected]>

---
v2: use info severity (Aravind)
v3: drop "Probe " prefix (Mallesh)
drop redundant vendor code, update message (Michal)

---
 drivers/gpu/drm/xe/xe_pci.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/gpu/drm/xe/xe_pci.c +3 -2
index 36d62927b969..b19efef1c5cd 100644
@@ -25,6 +25,7 @@
 #include "xe_gt_printk.h"
 #include "xe_gt_sriov_vf.h"
 #include "xe_guc.h"
+#include "xe_log.h"
 #include "xe_mmio.h"
 #include "xe_module.h"
 #include "xe_pci_error.h"
@@ -1172,8 +1173,8 @@ static int xe_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 	}
 
 	if (id_blocked(pdev->device)) {
-		dev_info(&pdev->dev, "Probe blocked for device [%04x:%04x].\n",
-			 pdev->vendor, pdev->device);
+		xe_log_info(pdev, PROBE, "driver loading blocked for device '%04x'\n",
+			    pdev->device);
 		return -ENODEV;
 	}
 
Signature · 1 line
2.47.1
Reviewed-by on v4 18/32
#43 lore raw

Re: [PATCH v4 18/32] drm/xe: Report 'probe blocked' error using SIGID

Quoted 3 lines · Michal Wajdeczko

Report 'driver loading blocked' error using xe_log_info() helper.

Simply we are logging information using xe_log_info right? not error.

If you want to log as error then please use xe_log_err right?

Please update commit accordingly.

After above changes

Quoted 34 lines
Cc Rodrigo Vivi <[email protected]>
Cc Aravind Iddamsetty <[email protected]>
Cc Mallesh Koujalagi <[email protected]>

---
v2: use info severity (Aravind)
v3: drop "Probe " prefix (Mallesh)
drop redundant vendor code, update message (Michal)

---
  drivers/gpu/drm/xe/xe_pci.c | 5 +++--
  1 file changed, 3 insertions(+), 2 deletions(-)
drivers/gpu/drm/xe/xe_pci.c +3 -2
index 36d62927b969..b19efef1c5cd 100644
@@ -25,6 +25,7 @@
  #include "xe_gt_printk.h"
  #include "xe_gt_sriov_vf.h"
  #include "xe_guc.h"
+#include "xe_log.h"
  #include "xe_mmio.h"
  #include "xe_module.h"
  #include "xe_pci_error.h"
@@ -1172,8 +1173,8 @@ static int xe_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
  	}
 
  	if (id_blocked(pdev->device)) {
-		dev_info(&pdev->dev, "Probe blocked for device [%04x:%04x].\n",
-			 pdev->vendor, pdev->device);
+		xe_log_info(pdev, PROBE, "driver loading blocked for device '%04x'\n",
+			    pdev->device);
  		return -ENODEV;
  	}
 
#44 lore raw

PATCH v4 19/32 drm/xe: Report all probe errors using SIGID

In reply to Michal Wajdeczko

For completeness, we should catch and report all probe errors, not just the ones that have explicit error message. Split xe_pci_probe() function after a display check to avoid reporting -EPROBE_DEFER and use xe_log_err_fatal() helper to report all returned errors.

Cc Rodrigo Vivi <[email protected]>
Cc Aravind Iddamsetty <[email protected]>
Cc Mallesh Koujalagi <[email protected]>

---
Cc: Dnyaneshwar Bhadane <[email protected]>

---
 drivers/gpu/drm/xe/xe_pci.c | 27 +++++++++++++++++++++------
 1 file changed, 21 insertions(+), 6 deletions(-)
drivers/gpu/drm/xe/xe_pci.c +21 -6
index b19efef1c5cd..ab4da1d9a9f1 100644
@@ -1147,17 +1147,12 @@ static void xe_pci_remove(struct pci_dev *pdev)
  * caller. Therefore there is no consequence on those specific callers when
  * function error injection skips the whole function.
  */
+static int __xe_pci_probe(struct pci_dev *pdev, const struct xe_device_desc *desc);
 static int xe_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 {
-	struct xe_probed_info probed_info = {};
 	const struct xe_device_desc *desc = (const void *)ent->driver_data;
-	const struct xe_subplatform_desc *subplatform_desc;
-	struct xe_device *xe;
-	void *group;
 	int err;
 
-	subplatform_desc = find_subplatform(desc, pdev->device);
-
 	xe_configfs_check_device(pdev);
 
 	if (desc->require_force_probe && !id_forced(pdev->device)) {
@@ -1181,6 +1176,26 @@ static int xe_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 	if (xe_display_driver_probe_defer(pdev))
 		return -EPROBE_DEFER;
 
+	err = __xe_pci_probe(pdev, desc);
+	if (err) {
+		xe_log_err_fatal(pdev, PROBE, err, "driver loading failed for device '%04x'\n",
+				 pdev->device);
+		return err;
+	}
+
+	return 0;
+}
+
+static int __xe_pci_probe(struct pci_dev *pdev, const struct xe_device_desc *desc)
+{
+	const struct xe_subplatform_desc *subplatform_desc;
+	struct xe_probed_info probed_info = {};
+	struct xe_device *xe;
+	void *group;
+	int err;
+
+	subplatform_desc = find_subplatform(desc, pdev->device);
+
 	/* Group all devres so xe_pci_error_slot_reset() can release them as a unit. */
 	group = devres_open_group(&pdev->dev, NULL, GFP_KERNEL);
 	if (!group)
Signature · 1 line
2.47.1
Reviewed-by on v4 19/32
#45 lore raw

Re: [PATCH v4 19/32] drm/xe: Report all probe errors using SIGID

Quoted 20 lines · Michal Wajdeczko

For completeness, we should catch and report all probe errors, not just the ones that have explicit error message. Split xe_pci_probe() function after a display check to avoid reporting -EPROBE_DEFER and use xe_log_err_fatal() helper to report all returned errors.

Cc Rodrigo Vivi <[email protected]>
Cc Aravind Iddamsetty <[email protected]>
Cc Mallesh Koujalagi <[email protected]>

---
Cc: Dnyaneshwar Bhadane <[email protected]>

---
  drivers/gpu/drm/xe/xe_pci.c | 27 +++++++++++++++++++++------
  1 file changed, 21 insertions(+), 6 deletions(-)
drivers/gpu/drm/xe/xe_pci.c +0 -0
index b19efef1c5cd..ab4da1d9a9f1 100644

drivers/gpu/drm/xe/xe_pci.c static void xe_pci_remove(struct pci_dev *pdev) · line 1149

Quoted 3 lines
drivers/gpu/drm/xe/xe_pci.c +0 -0
@@ -1147,17 +1147,12 @@ static void xe_pci_remove(struct pci_dev *pdev)
   * caller. Therefore there is no consequence on those specific callers when
   * function error injection skips the whole function.
   */

nit: Align xe_pci_probe comment message with latest changes.

Quoted 42 lines
drivers/gpu/drm/xe/xe_pci.c +21 -6
+static int __xe_pci_probe(struct pci_dev *pdev, const struct xe_device_desc *desc);
  static int xe_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
  {
-	struct xe_probed_info probed_info = {};
  	const struct xe_device_desc *desc = (const void *)ent->driver_data;
-	const struct xe_subplatform_desc *subplatform_desc;
-	struct xe_device *xe;
-	void *group;
  	int err;
 
-	subplatform_desc = find_subplatform(desc, pdev->device);
-
  	xe_configfs_check_device(pdev);
 
  	if (desc->require_force_probe && !id_forced(pdev->device)) {
@@ -1181,6 +1176,26 @@ static int xe_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
  	if (xe_display_driver_probe_defer(pdev))
  		return -EPROBE_DEFER;
 
+	err = __xe_pci_probe(pdev, desc);
+	if (err) {
+		xe_log_err_fatal(pdev, PROBE, err, "driver loading failed for device '%04x'\n",
+				 pdev->device);
+		return err;
+	}
+
+	return 0;
+}
+
+static int __xe_pci_probe(struct pci_dev *pdev, const struct xe_device_desc *desc)
+{
+	const struct xe_subplatform_desc *subplatform_desc;
+	struct xe_probed_info probed_info = {};
+	struct xe_device *xe;
+	void *group;
+	int err;
+
+	subplatform_desc = find_subplatform(desc, pdev->device);
+
  	/* Group all devres so xe_pci_error_slot_reset() can release them as a unit. */
  	group = devres_open_group(&pdev->dev, NULL, GFP_KERNEL);
  	if (!group)
#46 lore raw

Re: [PATCH v4 19/32] drm/xe: Report all probe errors using SIGID

Quoted 17 lines · Koujalagi
Quoted 15 lines · Michal Wajdeczko

For completeness, we should catch and report all probe errors, not just the ones that have explicit error message. Split xe_pci_probe() function after a display check to avoid reporting -EPROBE_DEFER and use xe_log_err_fatal() helper to report all returned errors.

Cc Rodrigo Vivi <[email protected]>
Cc Aravind Iddamsetty <[email protected]>
Cc Mallesh Koujalagi <[email protected]>

---
Cc: Dnyaneshwar Bhadane <[email protected]>
---
  drivers/gpu/drm/xe/xe_pci.c | 27 +++++++++++++++++++++------

  1 file changed, 21 insertions(+), 6 deletions(-)
Quoted 10 lines

drivers/gpu/drm/xe/xe_pci.c static void xe_pci_remove(struct pci_dev *pdev) · line 1149

Quoted 8 lines
drivers/gpu/drm/xe/xe_pci.c +0 -0
index b19efef1c5cd..ab4da1d9a9f1 100644
@@ -1147,17 +1147,12 @@ static void xe_pci_remove(struct pci_dev *pdev)
    * caller. Therefore there is no consequence on those specific callers when
    * function error injection skips the whole function.
    */

nit: Align xe_pci_probe comment message with latest changes.

hmm, what exactly do you want to change here?

comment above is about "Probe the PCI device" sequence in general not about the specific xe_pci_probe() function

Quoted 2 lines

thanks!

Quoted 40 lines
Quoted 40 lines
drivers/gpu/drm/xe/xe_pci.c +20 -5
+static int __xe_pci_probe(struct pci_dev *pdev, const struct xe_device_desc *desc);
   static int xe_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
   {
-    struct xe_probed_info probed_info = {};
       const struct xe_device_desc *desc = (const void *)ent->driver_data;
-    const struct xe_subplatform_desc *subplatform_desc;
-    struct xe_device *xe;
-    void *group;
       int err;
   -    subplatform_desc = find_subplatform(desc, pdev->device);
-
       xe_configfs_check_device(pdev);
         if (desc->require_force_probe && !id_forced(pdev->device)) {
@@ -1181,6 +1176,26 @@ static int xe_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
       if (xe_display_driver_probe_defer(pdev))
           return -EPROBE_DEFER;
   +    err = __xe_pci_probe(pdev, desc);
+    if (err) {
+        xe_log_err_fatal(pdev, PROBE, err, "driver loading failed for device '%04x'\n",
+                 pdev->device);
+        return err;
+    }
+
+    return 0;
+}
+
+static int __xe_pci_probe(struct pci_dev *pdev, const struct xe_device_desc *desc)
+{
+    const struct xe_subplatform_desc *subplatform_desc;
+    struct xe_probed_info probed_info = {};
+    struct xe_device *xe;
+    void *group;
+    int err;
+
+    subplatform_desc = find_subplatform(desc, pdev->device);
+
       /* Group all devres so xe_pci_error_slot_reset() can release them as a unit. */
       group = devres_open_group(&pdev->dev, NULL, GFP_KERNEL);
       if (!group)
#47 lore raw

Re: [PATCH v4 19/32] drm/xe: Report all probe errors using SIGID

Quoted 27 lines · Michal Wajdeczko
Quoted 16 lines · Koujalagi
Quoted 15 lines · Michal Wajdeczko

For completeness, we should catch and report all probe errors, not just the ones that have explicit error message. Split xe_pci_probe() function after a display check to avoid reporting -EPROBE_DEFER and use xe_log_err_fatal() helper to report all returned errors.

Cc Rodrigo Vivi <[email protected]>
Cc Aravind Iddamsetty <[email protected]>
Cc Mallesh Koujalagi <[email protected]>

---
Cc: Dnyaneshwar Bhadane <[email protected]>

---
   drivers/gpu/drm/xe/xe_pci.c | 27 +++++++++++++++++++++------
   1 file changed, 21 insertions(+), 6 deletions(-)
Quoted 9 lines

drivers/gpu/drm/xe/xe_pci.c static void xe_pci_remove(struct pci_dev *pdev) · line 1149

Quoted 8 lines
drivers/gpu/drm/xe/xe_pci.c +0 -0
index b19efef1c5cd..ab4da1d9a9f1 100644
@@ -1147,17 +1147,12 @@ static void xe_pci_remove(struct pci_dev *pdev)
    * caller. Therefore there is no consequence on those specific callers when
    * function error injection skips the whole function.
    */

nit: Align xe_pci_probe comment message with latest changes.

Quoted 1 line

hmm, what exactly do you want to change here?

Since after refactoring the code, xe_device_probe move to __xe_pci_probe so

we need to change "functions called directly from __xe_pci_probe() or indirectly" right?

Quoted 3 lines

comment above is about "Probe the PCI device" sequence in general not about the specific xe_pci_probe() function

Agreed! however the are using xe_device_probe function name etc, which is part of  __xe_pci_probe right.

Thanks,

-/Mallesh

Quoted 42 lines
Quoted 1 line

thanks!

Quoted 39 lines
Quoted 39 lines
drivers/gpu/drm/xe/xe_pci.c +20 -5
+static int __xe_pci_probe(struct pci_dev *pdev, const struct xe_device_desc *desc);
   static int xe_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
   {
-    struct xe_probed_info probed_info = {};
       const struct xe_device_desc *desc = (const void *)ent->driver_data;
-    const struct xe_subplatform_desc *subplatform_desc;
-    struct xe_device *xe;
-    void *group;
       int err;
   -    subplatform_desc = find_subplatform(desc, pdev->device);
-
       xe_configfs_check_device(pdev);
         if (desc->require_force_probe && !id_forced(pdev->device)) {
@@ -1181,6 +1176,26 @@ static int xe_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
       if (xe_display_driver_probe_defer(pdev))
           return -EPROBE_DEFER;
   +    err = __xe_pci_probe(pdev, desc);
+    if (err) {
+        xe_log_err_fatal(pdev, PROBE, err, "driver loading failed for device '%04x'\n",
+                 pdev->device);
+        return err;
+    }
+
+    return 0;
+}
+
+static int __xe_pci_probe(struct pci_dev *pdev, const struct xe_device_desc *desc)
+{
+    const struct xe_subplatform_desc *subplatform_desc;
+    struct xe_probed_info probed_info = {};
+    struct xe_device *xe;
+    void *group;
+    int err;
+
+    subplatform_desc = find_subplatform(desc, pdev->device);
+
       /* Group all devres so xe_pci_error_slot_reset() can release them as a unit. */
       group = devres_open_group(&pdev->dev, NULL, GFP_KERNEL);
       if (!group)
#48 lore raw

Re: [PATCH v4 19/32] drm/xe: Report all probe errors using SIGID

Quoted 29 lines · Koujalagi
Quoted 27 lines · Michal Wajdeczko
Quoted 25 lines · Koujalagi
Quoted 20 lines · Michal Wajdeczko

For completeness, we should catch and report all probe errors, not just the ones that have explicit error message. Split xe_pci_probe() function after a display check to avoid reporting -EPROBE_DEFER and use xe_log_err_fatal() helper to report all returned errors.

Cc Rodrigo Vivi <[email protected]>
Cc Aravind Iddamsetty <[email protected]>
Cc Mallesh Koujalagi <[email protected]>

---
Cc: Dnyaneshwar Bhadane <[email protected]>
---
   drivers/gpu/drm/xe/xe_pci.c | 27 +++++++++++++++++++++------

   1 file changed, 21 insertions(+), 6 deletions(-)
drivers/gpu/drm/xe/xe_pci.c +0 -0
index b19efef1c5cd..ab4da1d9a9f1 100644

drivers/gpu/drm/xe/xe_pci.c static void xe_pci_remove(struct pci_dev *pdev) · line 1149

Quoted 3 lines
drivers/gpu/drm/xe/xe_pci.c +0 -0
@@ -1147,17 +1147,12 @@ static void xe_pci_remove(struct pci_dev *pdev)
     * caller. Therefore there is no consequence on those specific callers when
     * function error injection skips the whole function.
     */

nit: Align xe_pci_probe comment message with latest changes.

Quoted 5 lines
Quoted 1 line

hmm, what exactly do you want to change here?

Since after refactoring the code, xe_device_probe move to __xe_pci_probe so

we need to change "functions called directly from __xe_pci_probe() or indirectly" right?

I guess it's a matter or the missing comma in the comment

"directly from xe_pci_probe() or indirectly, for example through xe_device_probe()"

                                           ^
                                           here
Quoted 6 lines
Quoted 4 lines

comment above is about "Probe the PCI device" sequence in general not about the specific xe_pci_probe() function

Agreed! however the are using xe_device_probe function name etc, which is part of  __xe_pci_probe right.

which IMO still makes xe_device_probe part of the xe_pci_probe()

those are just technical code splits, to avoid large refactoring or error prone use of goto's - either way not worth to be mentioned in a general comment which is more about error injection anyway

Quoted 47 lines

Thanks,

-/Mallesh

Quoted 42 lines
Quoted 1 line

thanks!

Quoted 39 lines
Quoted 39 lines
drivers/gpu/drm/xe/xe_pci.c +20 -5
+static int __xe_pci_probe(struct pci_dev *pdev, const struct xe_device_desc *desc);
    static int xe_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
    {
-    struct xe_probed_info probed_info = {};
        const struct xe_device_desc *desc = (const void *)ent->driver_data;
-    const struct xe_subplatform_desc *subplatform_desc;
-    struct xe_device *xe;
-    void *group;
        int err;
    -    subplatform_desc = find_subplatform(desc, pdev->device);
-
        xe_configfs_check_device(pdev);
          if (desc->require_force_probe && !id_forced(pdev->device)) {
@@ -1181,6 +1176,26 @@ static int xe_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
        if (xe_display_driver_probe_defer(pdev))
            return -EPROBE_DEFER;
    +    err = __xe_pci_probe(pdev, desc);
+    if (err) {
+        xe_log_err_fatal(pdev, PROBE, err, "driver loading failed for device '%04x'\n",
+                 pdev->device);
+        return err;
+    }
+
+    return 0;
+}
+
+static int __xe_pci_probe(struct pci_dev *pdev, const struct xe_device_desc *desc)
+{
+    const struct xe_subplatform_desc *subplatform_desc;
+    struct xe_probed_info probed_info = {};
+    struct xe_device *xe;
+    void *group;
+    int err;
+
+    subplatform_desc = find_subplatform(desc, pdev->device);
+
        /* Group all devres so xe_pci_error_slot_reset() can release them as a unit. */
        group = devres_open_group(&pdev->dev, NULL, GFP_KERNEL);
        if (!group)
#49 lore raw

PATCH v4 20/32 drm/xe/survivability: Report 'boot status' using SIGID

In reply to Michal Wajdeczko

Report 'boot status' details using xe_log_err_fatal/info() macros. While around, move static helper code closer to the caller and let it take xe instead of pdev.

Cc Rodrigo Vivi <[email protected]>
Cc Riana Tauro <[email protected]>
Cc Aravind Iddamsetty <[email protected]>
Cc Mallesh Koujalagi <[email protected]>
---
 drivers/gpu/drm/xe/xe_survivability_mode.c | 35 ++++++++++++----------
 1 file changed, 19 insertions(+), 16 deletions(-)
drivers/gpu/drm/xe/xe_survivability_mode.c +19 -16
index 4c506027fa94..85b4c125a217 100644
@@ -14,6 +14,7 @@
 #include "xe_device.h"
 #include "xe_heci_gsc.h"
 #include "xe_i2c.h"
+#include "xe_log.h"
 #include "xe_mmio.h"
 #include "xe_nvm.h"
 #include "xe_pcode_api.h"
@@ -172,21 +173,6 @@ static void populate_survivability_info(struct xe_device *xe)
 	}
 }
 
-static void log_survivability_info(struct pci_dev *pdev)
-{
-	struct xe_device *xe = pdev_to_xe_device(pdev);
-	struct xe_survivability *survivability = &xe->survivability;
-	u32 *info = survivability->info;
-	int id;
-
-	dev_info(&pdev->dev, "Survivability Boot Status : Critical Failure (%d)\n",
-		 survivability->boot_status);
-	for (id = 0; id < MAX_SCRATCH_REG; id++) {
-		if (info[id])
-			dev_info(&pdev->dev, "%s: 0x%x\n", reg_map[id], info[id]);
-	}
-}
-
 static int check_boot_failure(struct xe_device *xe)
 {
 	struct xe_survivability *survivability = &xe->survivability;
@@ -429,6 +415,23 @@ void xe_survivability_mode_runtime_enable(struct xe_device *xe)
 	dev_err(&pdev->dev, "Firmware flash required, Please refer to the userspace documentation for more details!\n");
 }
 
+static void log_survivability_info(struct xe_device *xe)
+{
+	struct xe_survivability *survivability = &xe->survivability;
+	u32 *info = survivability->info;
+	int id;
+
+	xe_log_err_fatal(xe, SURVIVABILITY, -ENXIO, "Boot Status: %s (%u)\n",
+			 survivability->boot_status == CRITICAL_FAILURE ?
+			 "Critical Failure" : "Other", survivability->boot_status);
+
+	for (id = 0; id < MAX_SCRATCH_REG; id++) {
+		if (!info[id])
+			continue;
+		xe_log_info(xe, SURVIVABILITY, "%s: %#x\n", reg_map[id], info[id]);
+	}
+}
+
 /**
  * xe_survivability_mode_boot_enable - Initialize and enable boot survivability mode
  * @xe: xe device instance
@@ -452,7 +455,7 @@ int xe_survivability_mode_boot_enable(struct xe_device *xe)
 	 * v2 supports survivability mode for critical errors
 	 */
 	if (survivability->version < 2  && survivability->boot_status == CRITICAL_FAILURE) {
-		log_survivability_info(pdev);
+		log_survivability_info(xe);
 		return -ENXIO;
 	}
 
Signature · 1 line
2.47.1
Reviewed-by on v4 20/32
#50 lore raw

Re: [PATCH v4 20/32] drm/xe/survivability: Report 'boot status' using SIGID

Quoted 50 lines · Michal Wajdeczko

Report 'boot status' details using xe_log_err_fatal/info() macros. While around, move static helper code closer to the caller and let it take xe instead of pdev.

Cc Rodrigo Vivi<[email protected]>
Cc Riana Tauro<[email protected]>
Cc Aravind Iddamsetty<[email protected]>
Cc Mallesh Koujalagi<[email protected]>
---
  drivers/gpu/drm/xe/xe_survivability_mode.c | 35 ++++++++++++----------
  1 file changed, 19 insertions(+), 16 deletions(-)
drivers/gpu/drm/xe/xe_survivability_mode.c +1 -15
index 4c506027fa94..85b4c125a217 100644
@@ -14,6 +14,7 @@
  #include "xe_device.h"
  #include "xe_heci_gsc.h"
  #include "xe_i2c.h"
+#include "xe_log.h"
  #include "xe_mmio.h"
  #include "xe_nvm.h"
  #include "xe_pcode_api.h"
@@ -172,21 +173,6 @@ static void populate_survivability_info(struct xe_device *xe)
  	}
  }
 
-static void log_survivability_info(struct pci_dev *pdev)
-{
-	struct xe_device *xe = pdev_to_xe_device(pdev);
-	struct xe_survivability *survivability = &xe->survivability;
-	u32 *info = survivability->info;
-	int id;
-
-	dev_info(&pdev->dev, "Survivability Boot Status : Critical Failure (%d)\n",
-		 survivability->boot_status);
-	for (id = 0; id < MAX_SCRATCH_REG; id++) {
-		if (info[id])
-			dev_info(&pdev->dev, "%s: 0x%x\n", reg_map[id], info[id]);
-	}
-}
-
  static int check_boot_failure(struct xe_device *xe)
  {
  	struct xe_survivability *survivability = &xe->survivability;
@@ -429,6 +415,23 @@ void xe_survivability_mode_runtime_enable(struct xe_device *xe)
  	dev_err(&pdev->dev, "Firmware flash required, Please refer to the userspace documentation for more details!\n");
  }

drivers/gpu/drm/xe/xe_survivability_mode.c void xe_survivability_mode_runtime_enable(struct xe_device *xe) · line 426

Quoted 10 lines
drivers/gpu/drm/xe/xe_survivability_mode.c +9 -0
 
+static void log_survivability_info(struct xe_device *xe)
+{
+	struct xe_survivability *survivability = &xe->survivability;
+	u32 *info = survivability->info;
+	int id;
+
+	xe_log_err_fatal(xe, SURVIVABILITY, -ENXIO, "Boot Status: %s (%u)\n",
+			 survivability->boot_status == CRITICAL_FAILURE ?
+			 "Critical Failure" : "Other", survivability->boot_status);

Since log_survivability_info is called when survivability->boot_status == CRITICAL_FAILURE true, so please use "Critical Failure"  string directly.

Quoted 20 lines
drivers/gpu/drm/xe/xe_survivability_mode.c +9 -1
+
+	for (id = 0; id < MAX_SCRATCH_REG; id++) {
+		if (!info[id])
+			continue;
+		xe_log_info(xe, SURVIVABILITY, "%s: %#x\n", reg_map[id], info[id]);
+	}
+}
+
  /**
   * xe_survivability_mode_boot_enable - Initialize and enable boot survivability mode
   * @xe: xe device instance
@@ -452,7 +455,7 @@ int xe_survivability_mode_boot_enable(struct xe_device *xe)
  	 * v2 supports survivability mode for critical errors
  	 */
  	if (survivability->version < 2  && survivability->boot_status == CRITICAL_FAILURE) {
-		log_survivability_info(pdev);
+		log_survivability_info(xe);
  		return -ENXIO;
  	}
 
#51 lore raw

Re: [PATCH v4 20/32] drm/xe/survivability: Report 'boot status' using SIGID

Quoted 53 lines · Koujalagi
Quoted 51 lines · Michal Wajdeczko

Report 'boot status' details using xe_log_err_fatal/info() macros. While around, move static helper code closer to the caller and let it take xe instead of pdev.

Cc Rodrigo Vivi <[email protected]>
Cc Riana Tauro <[email protected]>
Cc Aravind Iddamsetty <[email protected]>
Cc Mallesh Koujalagi <[email protected]>
---
 drivers/gpu/drm/xe/xe_survivability_mode.c | 35 ++++++++++++----------
 1 file changed, 19 insertions(+), 16 deletions(-)
drivers/gpu/drm/xe/xe_survivability_mode.c +1 -15
index 4c506027fa94..85b4c125a217 100644
@@ -14,6 +14,7 @@
 #include "xe_device.h"
 #include "xe_heci_gsc.h"
 #include "xe_i2c.h"
+#include "xe_log.h"
 #include "xe_mmio.h"
 #include "xe_nvm.h"
 #include "xe_pcode_api.h"
@@ -172,21 +173,6 @@ static void populate_survivability_info(struct xe_device *xe)
 	}
 }
 
-static void log_survivability_info(struct pci_dev *pdev)
-{
-	struct xe_device *xe = pdev_to_xe_device(pdev);
-	struct xe_survivability *survivability = &xe->survivability;
-	u32 *info = survivability->info;
-	int id;
-
-	dev_info(&pdev->dev, "Survivability Boot Status : Critical Failure (%d)\n",
-		 survivability->boot_status);
-	for (id = 0; id < MAX_SCRATCH_REG; id++) {
-		if (info[id])
-			dev_info(&pdev->dev, "%s: 0x%x\n", reg_map[id], info[id]);
-	}
-}
-
 static int check_boot_failure(struct xe_device *xe)
 {
 	struct xe_survivability *survivability = &xe->survivability;
@@ -429,6 +415,23 @@ void xe_survivability_mode_runtime_enable(struct xe_device *xe)
 	dev_err(&pdev->dev, "Firmware flash required, Please refer to the userspace documentation for more details!\n");
 }
 
Quoted 11 lines

drivers/gpu/drm/xe/xe_survivability_mode.c void xe_survivability_mode_runtime_enable(struct xe_device *xe) · line 426

Quoted 9 lines
drivers/gpu/drm/xe/xe_survivability_mode.c +9 -0
+static void log_survivability_info(struct xe_device *xe)
+{
+	struct xe_survivability *survivability = &xe->survivability;
+	u32 *info = survivability->info;
+	int id;
+
+	xe_log_err_fatal(xe, SURVIVABILITY, -ENXIO, "Boot Status: %s (%u)\n",
+			 survivability->boot_status == CRITICAL_FAILURE ?
+			 "Critical Failure" : "Other", survivability->boot_status);

Since log_survivability_info is called when survivability->boot_status == CRITICAL_FAILURE true, so please use "Critical Failure"  string directly.

well, that's the current usage and function name didn't strictly say "log critical failure" only

btw, printing fixed "Critical Failure" string followed by flexible %d also doesn't make sense IMO

that's why I decided to make this function more flexible and reusable if needed

Quoted 23 lines
Quoted 20 lines
drivers/gpu/drm/xe/xe_survivability_mode.c +9 -1
+
+	for (id = 0; id < MAX_SCRATCH_REG; id++) {
+		if (!info[id])
+			continue;
+		xe_log_info(xe, SURVIVABILITY, "%s: %#x\n", reg_map[id], info[id]);
+	}
+}
+
 /**
  * xe_survivability_mode_boot_enable - Initialize and enable boot survivability mode
  * @xe: xe device instance
@@ -452,7 +455,7 @@ int xe_survivability_mode_boot_enable(struct xe_device *xe)
 	 * v2 supports survivability mode for critical errors
 	 */
 	if (survivability->version < 2  && survivability->boot_status == CRITICAL_FAILURE) {
-		log_survivability_info(pdev);
+		log_survivability_info(xe);
 		return -ENXIO;
 	}
 
#52 lore raw

Re: [PATCH v4 20/32] drm/xe/survivability: Report 'boot status' using SIGID

Quoted 64 lines · Michal Wajdeczko
Quoted 52 lines · Koujalagi
Quoted 51 lines · Michal Wajdeczko

Report 'boot status' details using xe_log_err_fatal/info() macros. While around, move static helper code closer to the caller and let it take xe instead of pdev.

Cc Rodrigo Vivi <[email protected]>
Cc Riana Tauro <[email protected]>
Cc Aravind Iddamsetty <[email protected]>
Cc Mallesh Koujalagi <[email protected]>
---
  drivers/gpu/drm/xe/xe_survivability_mode.c | 35 ++++++++++++----------
  1 file changed, 19 insertions(+), 16 deletions(-)
drivers/gpu/drm/xe/xe_survivability_mode.c +1 -15
index 4c506027fa94..85b4c125a217 100644
@@ -14,6 +14,7 @@
  #include "xe_device.h"
  #include "xe_heci_gsc.h"
  #include "xe_i2c.h"
+#include "xe_log.h"
  #include "xe_mmio.h"
  #include "xe_nvm.h"
  #include "xe_pcode_api.h"
@@ -172,21 +173,6 @@ static void populate_survivability_info(struct xe_device *xe)
  	}
  }
 
-static void log_survivability_info(struct pci_dev *pdev)
-{
-	struct xe_device *xe = pdev_to_xe_device(pdev);
-	struct xe_survivability *survivability = &xe->survivability;
-	u32 *info = survivability->info;
-	int id;
-
-	dev_info(&pdev->dev, "Survivability Boot Status : Critical Failure (%d)\n",
-		 survivability->boot_status);
-	for (id = 0; id < MAX_SCRATCH_REG; id++) {
-		if (info[id])
-			dev_info(&pdev->dev, "%s: 0x%x\n", reg_map[id], info[id]);
-	}
-}
-
  static int check_boot_failure(struct xe_device *xe)
  {
  	struct xe_survivability *survivability = &xe->survivability;
@@ -429,6 +415,23 @@ void xe_survivability_mode_runtime_enable(struct xe_device *xe)
  	dev_err(&pdev->dev, "Firmware flash required, Please refer to the userspace documentation for more details!\n");
  }
 
Quoted 10 lines

drivers/gpu/drm/xe/xe_survivability_mode.c void xe_survivability_mode_runtime_enable(struct xe_device *xe) · line 426

Quoted 9 lines
drivers/gpu/drm/xe/xe_survivability_mode.c +9 -0
+static void log_survivability_info(struct xe_device *xe)
+{
+	struct xe_survivability *survivability = &xe->survivability;
+	u32 *info = survivability->info;
+	int id;
+
+	xe_log_err_fatal(xe, SURVIVABILITY, -ENXIO, "Boot Status: %s (%u)\n",
+			 survivability->boot_status == CRITICAL_FAILURE ?
+			 "Critical Failure" : "Other", survivability->boot_status);

Since log_survivability_info is called when survivability->boot_status == CRITICAL_FAILURE true, so please use "Critical Failure"  string directly.

Quoted 5 lines

well, that's the current usage and function name didn't strictly say "log critical failure" only

btw, printing fixed "Critical Failure" string followed by flexible %d also doesn't make sense IMO

that's why I decided to make this function more flexible and reusable if needed

Totally agreed, u made it generic one, however current usage, we never going to hit "Other" case, which is dead here.

btw, "Other" is "Non Critical Failure" right?

Thanks,

-/Mallesh

Quoted 23 lines
Quoted 23 lines
Quoted 20 lines
drivers/gpu/drm/xe/xe_survivability_mode.c +9 -1
+
+	for (id = 0; id < MAX_SCRATCH_REG; id++) {
+		if (!info[id])
+			continue;
+		xe_log_info(xe, SURVIVABILITY, "%s: %#x\n", reg_map[id], info[id]);
+	}
+}
+
  /**
   * xe_survivability_mode_boot_enable - Initialize and enable boot survivability mode
   * @xe: xe device instance
@@ -452,7 +455,7 @@ int xe_survivability_mode_boot_enable(struct xe_device *xe)
  	 * v2 supports survivability mode for critical errors
  	 */
  	if (survivability->version < 2  && survivability->boot_status == CRITICAL_FAILURE) {
-		log_survivability_info(pdev);
+		log_survivability_info(xe);
  		return -ENXIO;
  	}
 
#53 lore raw

Re: [PATCH v4 20/32] drm/xe/survivability: Report 'boot status' using SIGID

Quoted 66 lines · Koujalagi
Quoted 64 lines · Michal Wajdeczko
Quoted 52 lines · Koujalagi
Quoted 51 lines · Michal Wajdeczko

Report 'boot status' details using xe_log_err_fatal/info() macros. While around, move static helper code closer to the caller and let it take xe instead of pdev.

Cc Rodrigo Vivi <[email protected]>
Cc Riana Tauro <[email protected]>
Cc Aravind Iddamsetty <[email protected]>
Cc Mallesh Koujalagi <[email protected]>

---
  drivers/gpu/drm/xe/xe_survivability_mode.c | 35 ++++++++++++----------

  1 file changed, 19 insertions(+), 16 deletions(-)
drivers/gpu/drm/xe/xe_survivability_mode.c +2 -14
index 4c506027fa94..85b4c125a217 100644
@@ -14,6 +14,7 @@
   #include "xe_device.h"
   #include "xe_heci_gsc.h"
   #include "xe_i2c.h"
+#include "xe_log.h"
   #include "xe_mmio.h"
   #include "xe_nvm.h"
   #include "xe_pcode_api.h"
@@ -172,21 +173,6 @@ static void populate_survivability_info(struct xe_device *xe)
       }
   }
   -static void log_survivability_info(struct pci_dev *pdev)
-{
-    struct xe_device *xe = pdev_to_xe_device(pdev);
-    struct xe_survivability *survivability = &xe->survivability;
-    u32 *info = survivability->info;
-    int id;
-
-    dev_info(&pdev->dev, "Survivability Boot Status : Critical Failure (%d)\n",
-         survivability->boot_status);
-    for (id = 0; id < MAX_SCRATCH_REG; id++) {
-        if (info[id])
-            dev_info(&pdev->dev, "%s: 0x%x\n", reg_map[id], info[id]);
-    }
-}
-
   static int check_boot_failure(struct xe_device *xe)
   {
       struct xe_survivability *survivability = &xe->survivability;
@@ -429,6 +415,23 @@ void xe_survivability_mode_runtime_enable(struct xe_device *xe)
       dev_err(&pdev->dev, "Firmware flash required, Please refer to the userspace documentation for more details!\n");
   }
   +static void log_survivability_info(struct xe_device *xe)
+{
Quoted 8 lines

drivers/gpu/drm/xe/xe_survivability_mode.c void xe_survivability_mode_runtime_enable(struct xe_device *xe) · line 426

Quoted 7 lines
drivers/gpu/drm/xe/xe_survivability_mode.c +7 -0
+    struct xe_survivability *survivability = &xe->survivability;
+    u32 *info = survivability->info;
+    int id;
+
+    xe_log_err_fatal(xe, SURVIVABILITY, -ENXIO, "Boot Status: %s (%u)\n",
+             survivability->boot_status == CRITICAL_FAILURE ?
+             "Critical Failure" : "Other", survivability->boot_status);

Since log_survivability_info is called when survivability->boot_status == CRITICAL_FAILURE true, so please use "Critical Failure"  string directly.

well, that's the current usage and function name didn't strictly say "log critical failure" only

Quoted 7 lines
Quoted 3 lines

btw, printing fixed "Critical Failure" string followed by flexible %d also doesn't make sense IMO

that's why I decided to make this function more flexible and reusable if needed

Totally agreed, u made it generic one, however current usage, we never going to hit "Other" case, which is dead here.

btw, "Other" is "Non Critical Failure" right?

only if boot_status == 7

but since BOOT_STATUS is REG_GENMASK(3, 1) I assume that there might be other values, beyond currently documented 4 & 7

so even if we print "Other" there will be still numerical value "(7)" or "(1)" that could be used for debug/triage

but I can add helper

static const char *boot_status_str(u8 boot_status)

to return friendly name for all currently known codes (and "Other" or NULL for unknown codes)

Quoted 29 lines

Thanks,

-/Mallesh

Quoted 23 lines
Quoted 23 lines
Quoted 20 lines
drivers/gpu/drm/xe/xe_survivability_mode.c +9 -1
+
+    for (id = 0; id < MAX_SCRATCH_REG; id++) {
+        if (!info[id])
+            continue;
+        xe_log_info(xe, SURVIVABILITY, "%s: %#x\n", reg_map[id], info[id]);
+    }
+}
+
   /**
    * xe_survivability_mode_boot_enable - Initialize and enable boot survivability mode
    * @xe: xe device instance
@@ -452,7 +455,7 @@ int xe_survivability_mode_boot_enable(struct xe_device *xe)
        * v2 supports survivability mode for critical errors
        */
       if (survivability->version < 2  && survivability->boot_status == CRITICAL_FAILURE) {
-        log_survivability_info(pdev);
+        log_survivability_info(xe);
           return -ENXIO;
       }

#54 lore raw

Re: [PATCH v4 20/32] drm/xe/survivability: Report 'boot status' using SIGID

Quoted 68 lines · Michal Wajdeczko
Quoted 66 lines · Koujalagi
Quoted 65 lines · Michal Wajdeczko
Quoted 52 lines · Koujalagi
Quoted 51 lines · Michal Wajdeczko

Report 'boot status' details using xe_log_err_fatal/info() macros. While around, move static helper code closer to the caller and let it take xe instead of pdev.

Cc Rodrigo Vivi <[email protected]>
Cc Riana Tauro <[email protected]>
Cc Aravind Iddamsetty <[email protected]>
Cc Mallesh Koujalagi <[email protected]>
---
   drivers/gpu/drm/xe/xe_survivability_mode.c | 35 ++++++++++++----------
   1 file changed, 19 insertions(+), 16 deletions(-)
drivers/gpu/drm/xe/xe_survivability_mode.c +2 -14
index 4c506027fa94..85b4c125a217 100644
@@ -14,6 +14,7 @@
   #include "xe_device.h"
   #include "xe_heci_gsc.h"
   #include "xe_i2c.h"
+#include "xe_log.h"
   #include "xe_mmio.h"
   #include "xe_nvm.h"
   #include "xe_pcode_api.h"
@@ -172,21 +173,6 @@ static void populate_survivability_info(struct xe_device *xe)
       }
   }
   -static void log_survivability_info(struct pci_dev *pdev)
-{
-    struct xe_device *xe = pdev_to_xe_device(pdev);
-    struct xe_survivability *survivability = &xe->survivability;
-    u32 *info = survivability->info;
-    int id;
-
-    dev_info(&pdev->dev, "Survivability Boot Status : Critical Failure (%d)\n",
-         survivability->boot_status);
-    for (id = 0; id < MAX_SCRATCH_REG; id++) {
-        if (info[id])
-            dev_info(&pdev->dev, "%s: 0x%x\n", reg_map[id], info[id]);
-    }
-}
-
   static int check_boot_failure(struct xe_device *xe)
   {
       struct xe_survivability *survivability = &xe->survivability;
@@ -429,6 +415,23 @@ void xe_survivability_mode_runtime_enable(struct xe_device *xe)
       dev_err(&pdev->dev, "Firmware flash required, Please refer to the userspace documentation for more details!\n");
   }
   +static void log_survivability_info(struct xe_device *xe)
+{
Quoted 8 lines

drivers/gpu/drm/xe/xe_survivability_mode.c void xe_survivability_mode_runtime_enable(struct xe_device *xe) · line 426

Quoted 7 lines
drivers/gpu/drm/xe/xe_survivability_mode.c +7 -0
+    struct xe_survivability *survivability = &xe->survivability;
+    u32 *info = survivability->info;
+    int id;
+
+    xe_log_err_fatal(xe, SURVIVABILITY, -ENXIO, "Boot Status: %s (%u)\n",
+             survivability->boot_status == CRITICAL_FAILURE ?
+             "Critical Failure" : "Other", survivability->boot_status);

Since log_survivability_info is called when survivability->boot_status == CRITICAL_FAILURE true, so please use "Critical Failure"  string directly.

well, that's the current usage and function name didn't strictly say "log critical failure" only

btw, printing fixed "Critical Failure" string followed by flexible %d also doesn't make sense IMO

Quoted 8 lines
Quoted 4 lines
Quoted 1 line

that's why I decided to make this function more flexible and reusable if needed

Totally agreed, u made it generic one, however current usage, we never going to hit "Other" case, which is dead here.

btw, "Other" is "Non Critical Failure" right?

only if boot_status == 7

but since BOOT_STATUS is REG_GENMASK(3, 1) I assume that there might be other values, beyond currently documented 4 & 7

Yeah there are other values apart from 4 and 7. When this patch was initially added, it was suggested not to log the duplicate information as part of dmesg as it is already part of sysfs. That is the reason we print this only in version 1 of survivability for critical errors.

In v1, we do not enter survivability mode for critical errors and only log additional information in dmesg to aid with debug.

So generic is not necessary based on previous review decisions. But will leave it upto you.

Thanks
Riana

Quoted 37 lines

so even if we print "Other" there will be still numerical value "(7)" or "(1)" that could be used for debug/triage

but I can add helper

static const char *boot_status_str(u8 boot_status)

to return friendly name for all currently known codes (and "Other" or NULL for unknown codes)

Quoted 27 lines

Thanks,

-/Mallesh

Quoted 22 lines
Quoted 22 lines
Quoted 20 lines
drivers/gpu/drm/xe/xe_survivability_mode.c +9 -1
+
+    for (id = 0; id < MAX_SCRATCH_REG; id++) {
+        if (!info[id])
+            continue;
+        xe_log_info(xe, SURVIVABILITY, "%s: %#x\n", reg_map[id], info[id]);
+    }
+}
+
   /**
    * xe_survivability_mode_boot_enable - Initialize and enable boot survivability mode
    * @xe: xe device instance
@@ -452,7 +455,7 @@ int xe_survivability_mode_boot_enable(struct xe_device *xe)
        * v2 supports survivability mode for critical errors
        */
       if (survivability->version < 2  && survivability->boot_status == CRITICAL_FAILURE) {
-        log_survivability_info(pdev);
+        log_survivability_info(xe);
           return -ENXIO;
       }
 
#55 lore raw

Re: [PATCH v4 20/32] drm/xe/survivability: Report 'boot status' using SIGID

Quoted 74 lines · Riana
Quoted 72 lines · Michal Wajdeczko
Quoted 70 lines · Koujalagi
Quoted 61 lines · Michal Wajdeczko
Quoted 52 lines · Koujalagi
Quoted 51 lines · Michal Wajdeczko

Report 'boot status' details using xe_log_err_fatal/info() macros. While around, move static helper code closer to the caller and let it take xe instead of pdev.

Cc Rodrigo Vivi <[email protected]>
Cc Riana Tauro <[email protected]>
Cc Aravind Iddamsetty <[email protected]>
Cc Mallesh Koujalagi <[email protected]>

---
   drivers/gpu/drm/xe/xe_survivability_mode.c | 35 ++++++++++++----------

   1 file changed, 19 insertions(+), 16 deletions(-)
drivers/gpu/drm/xe/xe_survivability_mode.c +2 -14
index 4c506027fa94..85b4c125a217 100644
@@ -14,6 +14,7 @@
    #include "xe_device.h"
    #include "xe_heci_gsc.h"
    #include "xe_i2c.h"
+#include "xe_log.h"
    #include "xe_mmio.h"
    #include "xe_nvm.h"
    #include "xe_pcode_api.h"
@@ -172,21 +173,6 @@ static void populate_survivability_info(struct xe_device *xe)
        }
    }
    -static void log_survivability_info(struct pci_dev *pdev)
-{
-    struct xe_device *xe = pdev_to_xe_device(pdev);
-    struct xe_survivability *survivability = &xe->survivability;
-    u32 *info = survivability->info;
-    int id;
-
-    dev_info(&pdev->dev, "Survivability Boot Status : Critical Failure (%d)\n",
-         survivability->boot_status);
-    for (id = 0; id < MAX_SCRATCH_REG; id++) {
-        if (info[id])
-            dev_info(&pdev->dev, "%s: 0x%x\n", reg_map[id], info[id]);
-    }
-}
-
    static int check_boot_failure(struct xe_device *xe)
    {
        struct xe_survivability *survivability = &xe->survivability;
@@ -429,6 +415,23 @@ void xe_survivability_mode_runtime_enable(struct xe_device *xe)
        dev_err(&pdev->dev, "Firmware flash required, Please refer to the userspace documentation for more details!\n");
    }
    +static void log_survivability_info(struct xe_device *xe)
+{
Quoted 8 lines

drivers/gpu/drm/xe/xe_survivability_mode.c void xe_survivability_mode_runtime_enable(struct xe_device *xe) · line 426

Quoted 7 lines
drivers/gpu/drm/xe/xe_survivability_mode.c +7 -0
+    struct xe_survivability *survivability = &xe->survivability;
+    u32 *info = survivability->info;
+    int id;
+
+    xe_log_err_fatal(xe, SURVIVABILITY, -ENXIO, "Boot Status: %s (%u)\n",
+             survivability->boot_status == CRITICAL_FAILURE ?
+             "Critical Failure" : "Other", survivability->boot_status);

Since log_survivability_info is called when survivability->boot_status == CRITICAL_FAILURE true, so please use "Critical Failure"  string directly.

Quoted 5 lines

well, that's the current usage and function name didn't strictly say "log critical failure" only

btw, printing fixed "Critical Failure" string followed by flexible %d also doesn't make sense IMO

that's why I decided to make this function more flexible and reusable if needed

Totally agreed, u made it generic one, however current usage, we never going to hit "Other" case, which is dead here.

btw, "Other" is "Non Critical Failure" right?

Quoted 8 lines
Quoted 4 lines

only if boot_status == 7

but since BOOT_STATUS is REG_GENMASK(3, 1) I assume that there might be other values, beyond currently documented 4 & 7

Yeah there are other values apart from 4 and 7. When this patch was initially added, it was suggested not to log the duplicate information as part of dmesg as it is already part of sysfs.

what about the case when we failed to add sysfs files? then user is left with nothing ...

Quoted 6 lines

That is the reason we print this only in version 1 of survivability for critical errors.

In v1, we do not enter survivability mode for critical errors and only log additional information in dmesg to aid with debug.

So generic is not necessary based on previous review decisions. But will leave it upto you.

I'll add boot_status_str() helper to make log function even more generic 7) and likely keep it in current place as a preparation step for future patch to use it when sysfs fails

Quoted 42 lines

Thanks
Riana

Quoted 37 lines

so even if we print "Other" there will be still numerical value "(7)" or "(1)" that could be used for debug/triage

but I can add helper

    static const char *boot_status_str(u8 boot_status)

to return friendly name for all currently known codes (and "Other" or NULL for unknown codes)

Quoted 27 lines

Thanks,

-/Mallesh

Quoted 22 lines
Quoted 22 lines
Quoted 20 lines
drivers/gpu/drm/xe/xe_survivability_mode.c +9 -1
+
+    for (id = 0; id < MAX_SCRATCH_REG; id++) {
+        if (!info[id])
+            continue;
+        xe_log_info(xe, SURVIVABILITY, "%s: %#x\n", reg_map[id], info[id]);
+    }
+}
+
    /**
     * xe_survivability_mode_boot_enable - Initialize and enable boot survivability mode
     * @xe: xe device instance
@@ -452,7 +455,7 @@ int xe_survivability_mode_boot_enable(struct xe_device *xe)
         * v2 supports survivability mode for critical errors
         */
        if (survivability->version < 2  && survivability->boot_status == CRITICAL_FAILURE) {
-        log_survivability_info(pdev);
+        log_survivability_info(xe);
            return -ENXIO;
        }

#56 lore raw

PATCH v4 21/32 drm/xe/survivability: Report 'sysfs failure' error using SIGID

In reply to Michal Wajdeczko

Report 'failed to create sysfs files' error using xe_log_err() helper from all sysfs failure points and for all call sites.

Cc Rodrigo Vivi <[email protected]>
Cc Riana Tauro <[email protected]>
Cc Aravind Iddamsetty <[email protected]>
Cc Mallesh Koujalagi <[email protected]>
---
 drivers/gpu/drm/xe/xe_survivability_mode.c | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)
drivers/gpu/drm/xe/xe_survivability_mode.c +9 -9
index 85b4c125a217..2d8c532157fd 100644
@@ -280,24 +280,26 @@ static int create_survivability_sysfs(struct pci_dev *pdev)
 	int ret;
 
 	ret = device_create_file(dev, &dev_attr_survivability_mode);
-	if (ret) {
-		dev_warn(dev, "Failed to create survivability sysfs files\n");
-		return ret;
-	}
+	if (ret)
+		goto failed;
 
 	ret = devm_add_action_or_reset(xe->drm.dev,
 				       xe_survivability_mode_fini, xe);
 	if (ret)
-		return ret;
+		goto failed;
 
 	/* Survivability info is not required if enabled via configfs */
 	if (!xe_configfs_get_survivability_mode(pdev)) {
 		ret = devm_device_add_group(dev, &survivability_info_group);
 		if (ret)
-			return ret;
+			goto failed;
 	}
 
 	return 0;
+
+failed:
+	xe_log_err(xe, SURVIVABILITY, ret, "Failed to create sysfs files!\n");
+	return ret;
 }
 
 static int enable_boot_survivability_mode(struct pci_dev *pdev)
@@ -403,9 +405,7 @@ void xe_survivability_mode_runtime_enable(struct xe_device *xe)
 	}
 
 	populate_survivability_info(xe);
-
-	if (create_survivability_sysfs(pdev))
-		dev_err(&pdev->dev, "Failed to create survivability sysfs\n");
+	create_survivability_sysfs(pdev);
 
 	survivability->type = XE_SURVIVABILITY_TYPE_RUNTIME;
 	dev_err(&pdev->dev, "Runtime Survivability mode enabled\n");
Signature · 1 line
2.47.1
Reviewed-by on v4 21/32
#57 lore raw

Re: [PATCH v4 21/32] drm/xe/survivability: Report 'sysfs failure' error using SIGID

Quoted 4 lines · Michal Wajdeczko

Report 'failed to create sysfs files' error using xe_log_err() helper from all sysfs failure points and for all call sites.

LGTM,

Quoted 56 lines
Cc Rodrigo Vivi <[email protected]>
Cc Riana Tauro <[email protected]>
Cc Aravind Iddamsetty <[email protected]>
Cc Mallesh Koujalagi <[email protected]>
---
  drivers/gpu/drm/xe/xe_survivability_mode.c | 18 +++++++++---------
  1 file changed, 9 insertions(+), 9 deletions(-)
drivers/gpu/drm/xe/xe_survivability_mode.c +9 -9
index 85b4c125a217..2d8c532157fd 100644
@@ -280,24 +280,26 @@ static int create_survivability_sysfs(struct pci_dev *pdev)
  	int ret;
 
  	ret = device_create_file(dev, &dev_attr_survivability_mode);
-	if (ret) {
-		dev_warn(dev, "Failed to create survivability sysfs files\n");
-		return ret;
-	}
+	if (ret)
+		goto failed;
 
  	ret = devm_add_action_or_reset(xe->drm.dev,
  				       xe_survivability_mode_fini, xe);
  	if (ret)
-		return ret;
+		goto failed;
 
  	/* Survivability info is not required if enabled via configfs */
  	if (!xe_configfs_get_survivability_mode(pdev)) {
  		ret = devm_device_add_group(dev, &survivability_info_group);
  		if (ret)
-			return ret;
+			goto failed;
  	}
 
  	return 0;
+
+failed:
+	xe_log_err(xe, SURVIVABILITY, ret, "Failed to create sysfs files!\n");
+	return ret;
  }
 
  static int enable_boot_survivability_mode(struct pci_dev *pdev)
@@ -403,9 +405,7 @@ void xe_survivability_mode_runtime_enable(struct xe_device *xe)
  	}
 
  	populate_survivability_info(xe);
-
-	if (create_survivability_sysfs(pdev))
-		dev_err(&pdev->dev, "Failed to create survivability sysfs\n");
+	create_survivability_sysfs(pdev);
 
  	survivability->type = XE_SURVIVABILITY_TYPE_RUNTIME;
  	dev_err(&pdev->dev, "Runtime Survivability mode enabled\n");
#58 lore raw

Re: [PATCH v4 21/32] drm/xe/survivability: Report 'sysfs failure' error using SIGID

In reply to Michal Wajdeczko
Quoted 2 lines · Michal Wajdeczko

Report 'failed to create sysfs files' error using xe_log_err() helper from all sysfs failure points and for all call sites.

Is SIGID appropriate here? My understanding is that SIGIDs are meant for failures requiring corrective action either from driver itself or external.
A sysfs creation failure is a internal issue and may not belong in that category.

Thanks
Riana

Quoted 58 lines
Cc Rodrigo Vivi <[email protected]>
Cc Riana Tauro <[email protected]>
Cc Aravind Iddamsetty <[email protected]>
Cc Mallesh Koujalagi <[email protected]>
---
  drivers/gpu/drm/xe/xe_survivability_mode.c | 18 +++++++++---------
  1 file changed, 9 insertions(+), 9 deletions(-)
drivers/gpu/drm/xe/xe_survivability_mode.c +9 -9
index 85b4c125a217..2d8c532157fd 100644
@@ -280,24 +280,26 @@ static int create_survivability_sysfs(struct pci_dev *pdev)
  	int ret;
 
  	ret = device_create_file(dev, &dev_attr_survivability_mode);
-	if (ret) {
-		dev_warn(dev, "Failed to create survivability sysfs files\n");
-		return ret;
-	}
+	if (ret)
+		goto failed;
 
  	ret = devm_add_action_or_reset(xe->drm.dev,
  				       xe_survivability_mode_fini, xe);
  	if (ret)
-		return ret;
+		goto failed;
 
  	/* Survivability info is not required if enabled via configfs */
  	if (!xe_configfs_get_survivability_mode(pdev)) {
  		ret = devm_device_add_group(dev, &survivability_info_group);
  		if (ret)
-			return ret;
+			goto failed;
  	}
 
  	return 0;
+
+failed:
+	xe_log_err(xe, SURVIVABILITY, ret, "Failed to create sysfs files!\n");
+	return ret;
  }
 
  static int enable_boot_survivability_mode(struct pci_dev *pdev)
@@ -403,9 +405,7 @@ void xe_survivability_mode_runtime_enable(struct xe_device *xe)
  	}
 
  	populate_survivability_info(xe);
-
-	if (create_survivability_sysfs(pdev))
-		dev_err(&pdev->dev, "Failed to create survivability sysfs\n");
+	create_survivability_sysfs(pdev);
 
  	survivability->type = XE_SURVIVABILITY_TYPE_RUNTIME;
  	dev_err(&pdev->dev, "Runtime Survivability mode enabled\n");
#59 lore raw

Re: [PATCH v4 21/32] drm/xe/survivability: Report 'sysfs failure' error using SIGID

Quoted 8 lines · Riana
Quoted 2 lines · Michal Wajdeczko

Report 'failed to create sysfs files' error using xe_log_err() helper from all sysfs failure points and for all call sites.

Is SIGID appropriate here? My understanding is that SIGIDs are meant for failures requiring corrective action either from driver itself or external.
A sysfs creation failure is a internal issue and may not belong in that category.

but it will eventually lead to probe failure without enabling boot-mode, so IMO it is better to have errors like:

[drm] ERROR SIGID=103 (-EXXX) SURVIVABILITY: Failed to create sysfs files! [drm] ERROR SIGID=103 (-EXXX) SURVIVABILITY: Failed to enable boot-mode! [drm] ERROR SIGID=101 FATAL (-EXXX) PROBE: driver loading failed for device XXXX

than just the last one

Quoted 55 lines

Thanks
Riana

Quoted 51 lines
Cc Rodrigo Vivi <[email protected]>
Cc Riana Tauro <[email protected]>
Cc Aravind Iddamsetty <[email protected]>
Cc Mallesh Koujalagi <[email protected]>

---
  drivers/gpu/drm/xe/xe_survivability_mode.c | 18 +++++++++---------

  1 file changed, 9 insertions(+), 9 deletions(-)
drivers/gpu/drm/xe/xe_survivability_mode.c +9 -9
index 85b4c125a217..2d8c532157fd 100644
@@ -280,24 +280,26 @@ static int create_survivability_sysfs(struct pci_dev *pdev)
       int ret;
         ret = device_create_file(dev, &dev_attr_survivability_mode);
-    if (ret) {
-        dev_warn(dev, "Failed to create survivability sysfs files\n");
-        return ret;
-    }
+    if (ret)
+        goto failed;
         ret = devm_add_action_or_reset(xe->drm.dev,
                          xe_survivability_mode_fini, xe);
       if (ret)
-        return ret;
+        goto failed;
         /* Survivability info is not required if enabled via configfs */
       if (!xe_configfs_get_survivability_mode(pdev)) {
           ret = devm_device_add_group(dev, &survivability_info_group);
           if (ret)
-            return ret;
+            goto failed;
       }
         return 0;
+
+failed:
+    xe_log_err(xe, SURVIVABILITY, ret, "Failed to create sysfs files!\n");
+    return ret;
   }
     static int enable_boot_survivability_mode(struct pci_dev *pdev)
@@ -403,9 +405,7 @@ void xe_survivability_mode_runtime_enable(struct xe_device *xe)
       }
         populate_survivability_info(xe);
-
-    if (create_survivability_sysfs(pdev))
-        dev_err(&pdev->dev, "Failed to create survivability sysfs\n");
+    create_survivability_sysfs(pdev);
         survivability->type = XE_SURVIVABILITY_TYPE_RUNTIME;
       dev_err(&pdev->dev, "Runtime Survivability mode enabled\n");
#60 lore raw

PATCH v4 22/32 drm/xe/survivability: Report 'Boot Mode enabled' status using SIGID

In reply to Michal Wajdeczko

Report 'Boot Mode' status or failure using various xe_log() helpers.

Cc Rodrigo Vivi <[email protected]>
Cc Riana Tauro <[email protected]>
Cc Aravind Iddamsetty <[email protected]>
Cc Mallesh Koujalagi <[email protected]>
---
 drivers/gpu/drm/xe/xe_survivability_mode.c | 21 +++++++++++++--------
 1 file changed, 13 insertions(+), 8 deletions(-)
drivers/gpu/drm/xe/xe_survivability_mode.c +13 -8
index 2d8c532157fd..ebd288986c11 100644
@@ -304,14 +304,13 @@ static int create_survivability_sysfs(struct pci_dev *pdev)
 
 static int enable_boot_survivability_mode(struct pci_dev *pdev)
 {
-	struct device *dev = &pdev->dev;
 	struct xe_device *xe = pdev_to_xe_device(pdev);
 	struct xe_survivability *survivability = &xe->survivability;
-	int ret = 0;
+	int ret;
 
 	ret = create_survivability_sysfs(pdev);
 	if (ret)
-		return ret;
+		goto failed;
 
 	/* Make sure xe_heci_gsc_init() and xe_i2c_probe() are aware of survivability */
 	survivability->mode = true;
@@ -323,19 +322,25 @@ static int enable_boot_survivability_mode(struct pci_dev *pdev)
 	if (survivability->fdo_mode) {
 		ret = xe_nvm_init(xe);
 		if (ret)
-			goto err;
+			goto failed;
 	}
 
 	ret = xe_i2c_probe(xe);
 	if (ret)
-		goto err;
+		goto failed;
 
-	dev_err(dev, "In Survivability Mode\n");
+	if (check_boot_failure(xe))
+		xe_log_comp_fatal(pdev, SURVIVABILITY,
+				  &survivability->boot_status,
+				  sizeof(survivability->boot_status),
+				  "Boot Mode enabled!\n");
+	else
+		xe_log_info(pdev, SURVIVABILITY, "Boot Mode enabled!\n");
 
 	return 0;
 
-err:
-	dev_err(dev, "Failed to enable Survivability Mode\n");
+failed:
+	xe_log_err_fatal(pdev, SURVIVABILITY, ret, "Failed to enable Boot Mode!\n");
 	survivability->mode = false;
 	return ret;
 }
Signature · 1 line
2.47.1
Reviewed-by on v4 22/32
#61 lore raw

Re: [PATCH v4 22/32] drm/xe/survivability: Report 'Boot Mode enabled' status using SIGID

Quoted 41 lines · Michal Wajdeczko

Report 'Boot Mode' status or failure using various xe_log() helpers.

Cc Rodrigo Vivi <[email protected]>
Cc Riana Tauro <[email protected]>
Cc Aravind Iddamsetty <[email protected]>
Cc Mallesh Koujalagi <[email protected]>
---
  drivers/gpu/drm/xe/xe_survivability_mode.c | 21 +++++++++++++--------
  1 file changed, 13 insertions(+), 8 deletions(-)
drivers/gpu/drm/xe/xe_survivability_mode.c +3 -4
index 2d8c532157fd..ebd288986c11 100644
@@ -304,14 +304,13 @@ static int create_survivability_sysfs(struct pci_dev *pdev)
 
  static int enable_boot_survivability_mode(struct pci_dev *pdev)
  {
-	struct device *dev = &pdev->dev;
  	struct xe_device *xe = pdev_to_xe_device(pdev);
  	struct xe_survivability *survivability = &xe->survivability;
-	int ret = 0;
+	int ret;
 
  	ret = create_survivability_sysfs(pdev);
  	if (ret)
-		return ret;
+		goto failed;
 
  	/* Make sure xe_heci_gsc_init() and xe_i2c_probe() are aware of survivability */
  	survivability->mode = true;
@@ -323,19 +322,25 @@ static int enable_boot_survivability_mode(struct pci_dev *pdev)
  	if (survivability->fdo_mode) {
  		ret = xe_nvm_init(xe);
  		if (ret)
-			goto err;
+			goto failed;
  	}
 
  	ret = xe_i2c_probe(xe);

drivers/gpu/drm/xe/xe_survivability_mode.c static int enable_boot_survivability_mode(struct pci_dev *pdev) · line 336

Quoted 10 lines
drivers/gpu/drm/xe/xe_survivability_mode.c +6 -2
  	if (ret)
-		goto err;
+		goto failed;
 
-	dev_err(dev, "In Survivability Mode\n");
+	if (check_boot_failure(xe))
+		xe_log_comp_fatal(pdev, SURVIVABILITY,
+				  &survivability->boot_status,
+				  sizeof(survivability->boot_status),
+				  "Boot Mode enabled!\n");

In case of fatal, will make sense to return "0" OR we can add return as -ENXIO right? any thoughts?

After handling fatal case

Quoted 12 lines
drivers/gpu/drm/xe/xe_survivability_mode.c +4 -2
+	else
+		xe_log_info(pdev, SURVIVABILITY, "Boot Mode enabled!\n");
 
  	return 0;
 
-err:
-	dev_err(dev, "Failed to enable Survivability Mode\n");
+failed:
+	xe_log_err_fatal(pdev, SURVIVABILITY, ret, "Failed to enable Boot Mode!\n");
  	survivability->mode = false;
  	return ret;
  }
#62 lore raw

Re: [PATCH v4 22/32] drm/xe/survivability: Report 'Boot Mode enabled' status using SIGID

Quoted 42 lines · Koujalagi
Quoted 40 lines · Michal Wajdeczko

Report 'Boot Mode' status or failure using various xe_log() helpers.

Cc Rodrigo Vivi <[email protected]>
Cc Riana Tauro <[email protected]>
Cc Aravind Iddamsetty <[email protected]>
Cc Mallesh Koujalagi <[email protected]>

---
  drivers/gpu/drm/xe/xe_survivability_mode.c | 21 +++++++++++++--------

  1 file changed, 13 insertions(+), 8 deletions(-)
drivers/gpu/drm/xe/xe_survivability_mode.c +4 -5
index 2d8c532157fd..ebd288986c11 100644
@@ -304,14 +304,13 @@ static int create_survivability_sysfs(struct pci_dev *pdev)
     static int enable_boot_survivability_mode(struct pci_dev *pdev)
   {
-    struct device *dev = &pdev->dev;
       struct xe_device *xe = pdev_to_xe_device(pdev);
       struct xe_survivability *survivability = &xe->survivability;
-    int ret = 0;
+    int ret;
         ret = create_survivability_sysfs(pdev);
       if (ret)
-        return ret;
+        goto failed;
         /* Make sure xe_heci_gsc_init() and xe_i2c_probe() are aware of survivability */
       survivability->mode = true;
@@ -323,19 +322,25 @@ static int enable_boot_survivability_mode(struct pci_dev *pdev)
       if (survivability->fdo_mode) {
           ret = xe_nvm_init(xe);
           if (ret)
-            goto err;
+            goto failed;
       }
         ret = xe_i2c_probe(xe);
       if (ret)
-        goto err;
+        goto failed;
Quoted 8 lines

drivers/gpu/drm/xe/xe_survivability_mode.c static int enable_boot_survivability_mode(struct pci_dev *pdev) · line 336

Quoted 6 lines
drivers/gpu/drm/xe/xe_survivability_mode.c +5 -0
   -    dev_err(dev, "In Survivability Mode\n");
+    if (check_boot_failure(xe))
+        xe_log_comp_fatal(pdev, SURVIVABILITY,
+                  &survivability->boot_status,
+                  sizeof(survivability->boot_status),
+                  "Boot Mode enabled!\n");

In case of fatal, will make sense to return "0" OR we can add return as -ENXIO right? any thoughts?

you're a reviewer here ;)

but seriously, enable_boot_survivability_mode() is called from xe_survivability_mode_boot_enable() which says:

* Return: 0 if boot survivability mode is enabled or not requested, negative error
* code otherwise.

so returning 0 as success code in enabling boot mode is the correct one returning -ENXIO will be no different than failing to enter boot mode

@Riana, this is your code, can you please confirm that

Quoted 15 lines

After handling fatal case

Quoted 10 lines
drivers/gpu/drm/xe/xe_survivability_mode.c +2 -0
+    else
+        xe_log_info(pdev, SURVIVABILITY, "Boot Mode enabled!\n");
         return 0;

  -err:
-    dev_err(dev, "Failed to enable Survivability Mode\n");
+failed:
+    xe_log_err_fatal(pdev, SURVIVABILITY, ret, "Failed to enable Boot Mode!\n"); survivability->mode = false;
      return ret;
  }

#63 lore raw

Re: [PATCH v4 22/32] drm/xe/survivability: Report 'Boot Mode enabled' status using SIGID

Quoted 41 lines · Michal Wajdeczko
Quoted 39 lines · Koujalagi
Quoted 38 lines · Michal Wajdeczko

Report 'Boot Mode' status or failure using various xe_log() helpers.

Cc Rodrigo Vivi <[email protected]>
Cc Riana Tauro <[email protected]>
Cc Aravind Iddamsetty <[email protected]>
Cc Mallesh Koujalagi <[email protected]>
---
   drivers/gpu/drm/xe/xe_survivability_mode.c | 21 +++++++++++++--------
   1 file changed, 13 insertions(+), 8 deletions(-)
drivers/gpu/drm/xe/xe_survivability_mode.c +3 -4
index 2d8c532157fd..ebd288986c11 100644
@@ -304,14 +304,13 @@ static int create_survivability_sysfs(struct pci_dev *pdev)
     static int enable_boot_survivability_mode(struct pci_dev *pdev)
   {
-    struct device *dev = &pdev->dev;
       struct xe_device *xe = pdev_to_xe_device(pdev);
       struct xe_survivability *survivability = &xe->survivability;
-    int ret = 0;
+    int ret;
         ret = create_survivability_sysfs(pdev);
       if (ret)
-        return ret;
+        goto failed;
         /* Make sure xe_heci_gsc_init() and xe_i2c_probe() are aware of survivability */
       survivability->mode = true;
@@ -323,19 +322,25 @@ static int enable_boot_survivability_mode(struct pci_dev *pdev)
       if (survivability->fdo_mode) {
           ret = xe_nvm_init(xe);
           if (ret)
-            goto err;
+            goto failed;
       }
         ret = xe_i2c_probe(xe);
       if (ret)
Quoted 8 lines
Quoted 8 lines

drivers/gpu/drm/xe/xe_survivability_mode.c static int enable_boot_survivability_mode(struct pci_dev *pdev) · line 336

Quoted 8 lines
drivers/gpu/drm/xe/xe_survivability_mode.c +6 -1
-        goto err;
+        goto failed;
   -    dev_err(dev, "In Survivability Mode\n");
+    if (check_boot_failure(xe))
+        xe_log_comp_fatal(pdev, SURVIVABILITY,
+                  &survivability->boot_status,
+                  sizeof(survivability->boot_status),
+                  "Boot Mode enabled!\n");

Do we need this check? This function is only called if it is a boot failure.

We can have a error log with the type here. We don't need if else.

How about something like this? and remove else

<3> xe 0000:03:00.0: [drm] *ERROR* SIGID=<N> FATAL (01000000) SURVIVABILITY: mode=Boot

Quoted 1 line
Quoted 1 line

In case of fatal, will make sense to return "0" OR we can add return as -ENXIO right? any thoughts?

Mallesh, you cannot change return codes here. This defeats the purpose of survivability mode

Quoted 5 lines

you're a reviewer here ;)

but seriously, enable_boot_survivability_mode() is called from xe_survivability_mode_boot_enable() which says:

Quoted 19 lines

* Return: 0 if boot survivability mode is enabled or not requested, negative error
* code otherwise.

so returning 0 as success code in enabling boot mode is the correct one returning -ENXIO will be no different than failing to enter boot mode

@Riana, this is your code, can you please confirm that

Quoted 11 lines

After handling fatal case

Quoted 7 lines
drivers/gpu/drm/xe/xe_survivability_mode.c +4 -1
+    else
+        xe_log_info(pdev, SURVIVABILITY, "Boot Mode enabled!\n");
         return 0;
   -err:
-    dev_err(dev, "Failed to enable Survivability Mode\n");
+failed:
+    xe_log_err_fatal(pdev, SURVIVABILITY, ret, "Failed to enable Boot Mode!\n");

Can we retain the previous dmesg?

Thanks
Riana

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
drivers/gpu/drm/xe/xe_survivability_mode.c +0 -0
       survivability->mode = false;
       return ret;
   }
#64 lore raw

Re: [PATCH v4 22/32] drm/xe/survivability: Report 'Boot Mode enabled' status using SIGID

Quoted 44 lines · Riana
Quoted 42 lines · Michal Wajdeczko
Quoted 40 lines · Koujalagi
Quoted 39 lines · Michal Wajdeczko

Report 'Boot Mode' status or failure using various xe_log() helpers.

Cc Rodrigo Vivi <[email protected]>
Cc Riana Tauro <[email protected]>
Cc Aravind Iddamsetty <[email protected]>
Cc Mallesh Koujalagi <[email protected]>

---
   drivers/gpu/drm/xe/xe_survivability_mode.c | 21 +++++++++++++--------

   1 file changed, 13 insertions(+), 8 deletions(-)
drivers/gpu/drm/xe/xe_survivability_mode.c +3 -5
index 2d8c532157fd..ebd288986c11 100644
@@ -304,14 +304,13 @@ static int create_survivability_sysfs(struct pci_dev *pdev)
      static int enable_boot_survivability_mode(struct pci_dev *pdev)
    {
-    struct device *dev = &pdev->dev;
        struct xe_device *xe = pdev_to_xe_device(pdev);
        struct xe_survivability *survivability = &xe->survivability;
-    int ret = 0;
+    int ret;
          ret = create_survivability_sysfs(pdev);
        if (ret)
-        return ret;
+        goto failed;
          /* Make sure xe_heci_gsc_init() and xe_i2c_probe() are aware of survivability */
        survivability->mode = true;
@@ -323,19 +322,25 @@ static int enable_boot_survivability_mode(struct pci_dev *pdev)
        if (survivability->fdo_mode) {
            ret = xe_nvm_init(xe);
            if (ret)
-            goto err;
+            goto failed;
        }
          ret = xe_i2c_probe(xe);
        if (ret)
-        goto err;
Quoted 8 lines
Quoted 7 lines
Quoted 7 lines

drivers/gpu/drm/xe/xe_survivability_mode.c static int enable_boot_survivability_mode(struct pci_dev *pdev) · line 336

Quoted 7 lines
drivers/gpu/drm/xe/xe_survivability_mode.c +6 -0
+        goto failed;
    -    dev_err(dev, "In Survivability Mode\n");
+    if (check_boot_failure(xe))
+        xe_log_comp_fatal(pdev, SURVIVABILITY,
+                  &survivability->boot_status,
+                  sizeof(survivability->boot_status),
+                  "Boot Mode enabled!\n");

Do we need this check? This function is only called if it is a boot failure.

are you sure?

in xe_device_probe_early() there is:

	err = xe_pcode_probe_early(xe);
	if (err || xe_survivability_mode_is_requested(xe)) {
		err = xe_survivability_mode_boot_enable(xe);

and xe_survivability_mode_is_requested() may return true based on the xe_configfs_get_survivability_mode() settings

Quoted 2 lines

We can have a error log with the type here. We don't need if else.

based on [1] all survivability mode SIGID are FATAL
and based on 21] it was an arch choice to go with info level for all

but IMO if the boot mode was selected via configfs it doesn't make sense to call it FATAL, but if there was real problem detected we should make it FATAL (like we do with failed PROBE)

[1] https://patchwork.freedesktop.org/patch/732271/?series=168333&rev=1
[2] https://patchwork.freedesktop.org/patch/743324/?series=171022&rev=3#comment_1373731

Quoted 5 lines

How about something like this? and remove else

<3> xe 0000:03:00.0: [drm] *ERROR* SIGID=<N> FATAL (01000000) SURVIVABILITY: mode=Boot

                                                      ^^^^^^^^

boot_status is u8 so it will be at most (01)

and I don't think we should be so cryptic in the user facing error messages

Quoted 29 lines
Quoted 1 line
Quoted 1 line

In case of fatal, will make sense to return "0" OR we can add return as -ENXIO right? any thoughts?

Mallesh, you cannot change return codes here. This defeats the purpose of survivability mode

Quoted 5 lines

you're a reviewer here ;)

but seriously, enable_boot_survivability_mode() is called from xe_survivability_mode_boot_enable() which says:

Quoted 19 lines

  * Return: 0 if boot survivability mode is enabled or not requested, negative error
  * code otherwise.

so returning 0 as success code in enabling boot mode is the correct one returning -ENXIO will be no different than failing to enter boot mode

@Riana, this is your code, can you please confirm that

Quoted 11 lines

After handling fatal case

Quoted 7 lines
drivers/gpu/drm/xe/xe_survivability_mode.c +2 -0
+    else
+        xe_log_info(pdev, SURVIVABILITY, "Boot Mode enabled!\n");
          return 0;

   -err:
-    dev_err(dev, "Failed to enable Survivability Mode\n");
+failed:
+    xe_log_err_fatal(pdev, SURVIVABILITY, ret, "Failed to enable Boot Mode!\n");

Quoted 1 line

Can we retain the previous dmesg?

there will be already "SURVIVABILITY: " prefix included, so IMO instead of generic:

[drm] *ERROR* SIGID=103 (-EXXX) SURVIVABILITY: Failed to enable Survivability Mode

it's better to have more clearer message:

[drm] *ERROR* SIGID=103 (-EXXX) SURVIVABILITY: Failed to enable Boot Mode!

Quoted 7 lines

Thanks
Riana

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

       survivability->mode = false;
       return ret;
   }

#65 lore raw

Re: [PATCH v4 22/32] drm/xe/survivability: Report 'Boot Mode enabled' status using SIGID

Quoted 54 lines · Michal Wajdeczko
Quoted 42 lines · Riana
Quoted 41 lines · Michal Wajdeczko
Quoted 40 lines · Koujalagi
Quoted 39 lines · Michal Wajdeczko

Report 'Boot Mode' status or failure using various xe_log() helpers.

Cc Rodrigo Vivi <[email protected]>
Cc Riana Tauro <[email protected]>
Cc Aravind Iddamsetty <[email protected]>
Cc Mallesh Koujalagi <[email protected]>
---
    drivers/gpu/drm/xe/xe_survivability_mode.c | 21 +++++++++++++--------
    1 file changed, 13 insertions(+), 8 deletions(-)
drivers/gpu/drm/xe/xe_survivability_mode.c +3 -5
index 2d8c532157fd..ebd288986c11 100644
@@ -304,14 +304,13 @@ static int create_survivability_sysfs(struct pci_dev *pdev)
      static int enable_boot_survivability_mode(struct pci_dev *pdev)
    {
-    struct device *dev = &pdev->dev;
        struct xe_device *xe = pdev_to_xe_device(pdev);
        struct xe_survivability *survivability = &xe->survivability;
-    int ret = 0;
+    int ret;
          ret = create_survivability_sysfs(pdev);
        if (ret)
-        return ret;
+        goto failed;
          /* Make sure xe_heci_gsc_init() and xe_i2c_probe() are aware of survivability */
        survivability->mode = true;
@@ -323,19 +322,25 @@ static int enable_boot_survivability_mode(struct pci_dev *pdev)
        if (survivability->fdo_mode) {
            ret = xe_nvm_init(xe);
            if (ret)
-            goto err;
+            goto failed;
        }
          ret = xe_i2c_probe(xe);
        if (ret)
-        goto err;
Quoted 8 lines
Quoted 7 lines
Quoted 7 lines

drivers/gpu/drm/xe/xe_survivability_mode.c static int enable_boot_survivability_mode(struct pci_dev *pdev) · line 336

Quoted 7 lines
drivers/gpu/drm/xe/xe_survivability_mode.c +6 -0
+        goto failed;
    -    dev_err(dev, "In Survivability Mode\n");
+    if (check_boot_failure(xe))
+        xe_log_comp_fatal(pdev, SURVIVABILITY,
+                  &survivability->boot_status,
+                  sizeof(survivability->boot_status),
+                  "Boot Mode enabled!\n");

Do we need this check? This function is only called if it is a boot failure.

are you sure?

Quoted 8 lines

in xe_device_probe_early() there is:

	err = xe_pcode_probe_early(xe);
	if (err || xe_survivability_mode_is_requested(xe)) {
		err = xe_survivability_mode_boot_enable(xe);

and xe_survivability_mode_is_requested() may return true based on the xe_configfs_get_survivability_mode() settings

Configfs also is provided for users to enable boot survivability mode. So one log should be sufficient.

If we do need to add a blob instead of error no we should go ahead with all the scratch registers as they contain the error details instead of just boot status. Can't we just add 0 for now and come up with something that we can decode in future.?

Quoted 5 lines
Quoted 2 lines

We can have a error log with the type here. We don't need if else.

based on [1] all survivability mode SIGID are FATAL
and based on 21] it was an arch choice to go with info level for all

Quoted 11 lines

but IMO if the boot mode was selected via configfs it doesn't make sense to call it FATAL, but if there was real problem detected we should make it FATAL (like we do with failed PROBE)

[1] https://patchwork.freedesktop.org/patch/732271/?series=168333&rev=1
[2] https://patchwork.freedesktop.org/patch/743324/?series=171022&rev=3#comment_1373731

Quoted 4 lines

How about something like this? and remove else

<3> xe 0000:03:00.0: [drm] *ERROR* SIGID=<N> FATAL (01000000) SURVIVABILITY: mode=Boot

I am still trying to understand this series. Apologies if it is wrong, i tried to generate log using AI.

Quoted 33 lines
                                                       ^^^^^^^^

boot_status is u8 so it will be at most (01)

and I don't think we should be so cryptic in the user facing error messages

Quoted 20 lines
Quoted 1 line
Quoted 1 line

In case of fatal, will make sense to return "0" OR we can add return as -ENXIO right? any thoughts?

Mallesh, you cannot change return codes here. This defeats the purpose of survivability mode

Quoted 17 lines

you're a reviewer here ;)

but seriously, enable_boot_survivability_mode() is called from xe_survivability_mode_boot_enable() which says:

  * Return: 0 if boot survivability mode is enabled or not requested, negative error
  * code otherwise.

so returning 0 as success code in enabling boot mode is the correct one returning -ENXIO will be no different than failing to enter boot mode

@Riana, this is your code, can you please confirm that

Quoted 4 lines

After handling fatal case

Quoted 8 lines
Quoted 7 lines
Quoted 7 lines

drivers/gpu/drm/xe/xe_survivability_mode.c static int enable_boot_survivability_mode(struct pci_dev *pdev) · line 343

Quoted 7 lines
drivers/gpu/drm/xe/xe_survivability_mode.c +4 -1
+    else
+        xe_log_info(pdev, SURVIVABILITY, "Boot Mode enabled!\n");
          return 0;
    -err:
-    dev_err(dev, "Failed to enable Survivability Mode\n");
+failed:
+    xe_log_err_fatal(pdev, SURVIVABILITY, ret, "Failed to enable Boot Mode!\n");

Can we retain the previous dmesg?

Quoted 8 lines

there will be already "SURVIVABILITY: " prefix included, so IMO instead of generic:

[drm] *ERROR* SIGID=103 (-EXXX) SURVIVABILITY: Failed to enable Survivability Mode

it's better to have more clearer message:

[drm] *ERROR* SIGID=103 (-EXXX) SURVIVABILITY: Failed to enable Boot Mode!

Boot Mode and Runtime mode doesn't sound right. But i don't have any better suggestions here due to repetition.Since its message and can be changed . Will replace it if i can come up with something better in the future.

Thanks
Riana

Quoted 7 lines
Quoted 7 lines

Thanks
Riana

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
drivers/gpu/drm/xe/xe_survivability_mode.c +0 -0
        survivability->mode = false;
        return ret;
    }
#66 lore raw

Re: [PATCH v4 22/32] drm/xe/survivability: Report 'Boot Mode enabled' status using SIGID

Quoted 62 lines · Riana
Quoted 60 lines · Michal Wajdeczko
Quoted 42 lines · Riana
Quoted 41 lines · Michal Wajdeczko
Quoted 40 lines · Koujalagi
Quoted 39 lines · Michal Wajdeczko

Report 'Boot Mode' status or failure using various xe_log() helpers.

Cc Rodrigo Vivi <[email protected]>
Cc Riana Tauro <[email protected]>
Cc Aravind Iddamsetty <[email protected]>
Cc Mallesh Koujalagi <[email protected]>

---
    drivers/gpu/drm/xe/xe_survivability_mode.c | 21 +++++++++++++--------

    1 file changed, 13 insertions(+), 8 deletions(-)
drivers/gpu/drm/xe/xe_survivability_mode.c +3 -5
index 2d8c532157fd..ebd288986c11 100644
@@ -304,14 +304,13 @@ static int create_survivability_sysfs(struct pci_dev *pdev)
       static int enable_boot_survivability_mode(struct pci_dev *pdev)
     {
-    struct device *dev = &pdev->dev;
         struct xe_device *xe = pdev_to_xe_device(pdev);
         struct xe_survivability *survivability = &xe->survivability;
-    int ret = 0;
+    int ret;
           ret = create_survivability_sysfs(pdev);
         if (ret)
-        return ret;
+        goto failed;
           /* Make sure xe_heci_gsc_init() and xe_i2c_probe() are aware of survivability */
         survivability->mode = true;
@@ -323,19 +322,25 @@ static int enable_boot_survivability_mode(struct pci_dev *pdev)
         if (survivability->fdo_mode) {
             ret = xe_nvm_init(xe);
             if (ret)
-            goto err;
+            goto failed;
         }
           ret = xe_i2c_probe(xe);
         if (ret)
-        goto err;
Quoted 8 lines
Quoted 7 lines
Quoted 7 lines

drivers/gpu/drm/xe/xe_survivability_mode.c static int enable_boot_survivability_mode(struct pci_dev *pdev) · line 336

Quoted 7 lines
drivers/gpu/drm/xe/xe_survivability_mode.c +6 -0
+        goto failed;
     -    dev_err(dev, "In Survivability Mode\n");
+    if (check_boot_failure(xe))
+        xe_log_comp_fatal(pdev, SURVIVABILITY,
+                  &survivability->boot_status,
+                  sizeof(survivability->boot_status),
+                  "Boot Mode enabled!\n");

Do we need this check? This function is only called if it is a boot failure.

are you sure?

in xe_device_probe_early() there is:

    err = xe_pcode_probe_early(xe);
    if (err || xe_survivability_mode_is_requested(xe)) { err = xe_survivability_mode_boot_enable(xe);

Quoted 6 lines
Quoted 2 lines

and xe_survivability_mode_is_requested() may return true based on the xe_configfs_get_survivability_mode() settings

Configfs also is provided for users to enable boot survivability mode. So one log should be sufficient.

there will be still one log entry but it will be with different severity based on the configfs vs bootstatus origin

Quoted 4 lines

If we do need to add a blob instead of error no we should go ahead with all the scratch registers as they contain the error details instead of just boot status. Can't we just add 0 for now and come up with something that we can decode in future.?

including boot_status value here was requested by Mallesh in [1]

and logging all boot status registers is already done in [2] but only if boot mode was not triggered by configfs

[1] https://patchwork.freedesktop.org/patch/743324/?series=171022&rev=3#comment_1372191
[2] https://patchwork.freedesktop.org/patch/746002/?series=171022&rev=4

Quoted 57 lines
Quoted 7 lines
Quoted 4 lines

We can have a error log with the type here. We don't need if else.

based on [1] all survivability mode SIGID are FATAL
and based on 21] it was an arch choice to go with info level for all

Quoted 11 lines

but IMO if the boot mode was selected via configfs it doesn't make sense to call it FATAL, but if there was real problem detected we should make it FATAL (like we do with failed PROBE)

[1] https://patchwork.freedesktop.org/patch/732271/?series=168333&rev=1
[2] https://patchwork.freedesktop.org/patch/743324/?series=171022&rev=3#comment_1373731

Quoted 4 lines

How about something like this? and remove else

<3> xe 0000:03:00.0: [drm] *ERROR* SIGID=<N> FATAL (01000000) SURVIVABILITY: mode=Boot

I am still trying to understand this series. Apologies if it is wrong, i tried to generate log using AI.

Quoted 36 lines

                                                       ^^^^^^^^ boot_status is u8 so it will be at most (01)

and I don't think we should be so cryptic in the user facing error messages

Quoted 20 lines
Quoted 1 line
Quoted 1 line

In case of fatal, will make sense to return "0" OR we can add return as -ENXIO right? any thoughts?

Mallesh, you cannot change return codes here. This defeats the purpose of survivability mode

Quoted 17 lines

you're a reviewer here ;)

but seriously, enable_boot_survivability_mode() is called from xe_survivability_mode_boot_enable() which says:

   * Return: 0 if boot survivability mode is enabled or not requested, negative error
   * code otherwise.

so returning 0 as success code in enabling boot mode is the correct one returning -ENXIO will be no different than failing to enter boot mode

@Riana, this is your code, can you please confirm that

Quoted 4 lines

After handling fatal case

Quoted 8 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
drivers/gpu/drm/xe/xe_survivability_mode.c +2 -0
+    else
+        xe_log_info(pdev, SURVIVABILITY, "Boot Mode enabled!\n");
           return 0;

    -err:
-    dev_err(dev, "Failed to enable Survivability Mode\n");
+failed:
+    xe_log_err_fatal(pdev, SURVIVABILITY, ret, "Failed to enable Boot Mode!\n");

Can we retain the previous dmesg?

there will be already "SURVIVABILITY: " prefix included, so IMO instead of generic:

Quoted 7 lines
Quoted 5 lines

   [drm] *ERROR* SIGID=103 (-EXXX) SURVIVABILITY: Failed to enable Survivability Mode

it's better to have more clearer message:

   [drm] *ERROR* SIGID=103 (-EXXX) SURVIVABILITY: Failed to enable Boot Mode!

Boot Mode and Runtime mode doesn't sound right.

both "Boot Mode" and "Runtime mode" were existing names in the code ;)

Quoted 3 lines

But i don't have any better suggestions here due
to repetition.Since its message and can be changed . Will replace it if i can come up with something better in the future.

I take it as an ack-by then

Quoted 12 lines

Thanks
Riana

Quoted 7 lines
Quoted 7 lines

Thanks
Riana

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

        survivability->mode = false;
        return ret;
    }

#67 lore raw

Re: [PATCH v4 22/32] drm/xe/survivability: Report 'Boot Mode enabled' status using SIGID

Quoted 62 lines · Michal Wajdeczko
Quoted 60 lines · Riana
Quoted 59 lines · Michal Wajdeczko
Quoted 42 lines · Riana
Quoted 41 lines · Michal Wajdeczko
Quoted 40 lines · Koujalagi
Quoted 39 lines · Michal Wajdeczko

Report 'Boot Mode' status or failure using various xe_log() helpers.

Cc Rodrigo Vivi <[email protected]>
Cc Riana Tauro <[email protected]>
Cc Aravind Iddamsetty <[email protected]>
Cc Mallesh Koujalagi <[email protected]>
---
     drivers/gpu/drm/xe/xe_survivability_mode.c | 21 +++++++++++++--------
     1 file changed, 13 insertions(+), 8 deletions(-)
drivers/gpu/drm/xe/xe_survivability_mode.c +3 -5
index 2d8c532157fd..ebd288986c11 100644
@@ -304,14 +304,13 @@ static int create_survivability_sysfs(struct pci_dev *pdev)
       static int enable_boot_survivability_mode(struct pci_dev *pdev)
     {
-    struct device *dev = &pdev->dev;
         struct xe_device *xe = pdev_to_xe_device(pdev);
         struct xe_survivability *survivability = &xe->survivability;
-    int ret = 0;
+    int ret;
           ret = create_survivability_sysfs(pdev);
         if (ret)
-        return ret;
+        goto failed;
           /* Make sure xe_heci_gsc_init() and xe_i2c_probe() are aware of survivability */
         survivability->mode = true;
@@ -323,19 +322,25 @@ static int enable_boot_survivability_mode(struct pci_dev *pdev)
         if (survivability->fdo_mode) {
             ret = xe_nvm_init(xe);
             if (ret)
-            goto err;
+            goto failed;
         }
           ret = xe_i2c_probe(xe);
         if (ret)
-        goto err;
Quoted 8 lines
Quoted 7 lines
Quoted 7 lines

drivers/gpu/drm/xe/xe_survivability_mode.c static int enable_boot_survivability_mode(struct pci_dev *pdev) · line 335

Quoted 7 lines
drivers/gpu/drm/xe/xe_survivability_mode.c +6 -0
+        goto failed;
     -    dev_err(dev, "In Survivability Mode\n");
+    if (check_boot_failure(xe))
+        xe_log_comp_fatal(pdev, SURVIVABILITY,
+                  &survivability->boot_status,
+                  sizeof(survivability->boot_status),
+                  "Boot Mode enabled!\n");

Do we need this check? This function is only called if it is a boot failure.

are you sure?

in xe_device_probe_early() there is:

    err = xe_pcode_probe_early(xe);
    if (err || xe_survivability_mode_is_requested(xe)) { err = xe_survivability_mode_boot_enable(xe);

Quoted 7 lines
Quoted 5 lines
Quoted 2 lines

and xe_survivability_mode_is_requested() may return true based on the xe_configfs_get_survivability_mode() settings

Configfs also is provided for users to enable boot survivability mode. So one log should be sufficient.

there will be still one log entry but it will be with different severity based on the configfs vs bootstatus origin

configfs should also result in fatal because it also enters survivability mode and it was user's decision.

Quoted 5 lines
Quoted 4 lines

If we do need to add a blob instead of error no we should go ahead with all the scratch registers as they contain the error details instead of just boot status. Can't we just add 0 for now and come up with something that we can decode in future.?

including boot_status value here was requested by Mallesh in [1]

Don't agree with [1].

[2] prints only for critical errors. As responded on that patch, it was a intentional change based on review feedback.

No error no should be good here or a hardware error (-EIO). Lets not use boot status

Thanks
Riana

Quoted 85 lines

and logging all boot status registers is already done in [2] but only if boot mode was not triggered by configfs

[1] https://patchwork.freedesktop.org/patch/743324/?series=171022&rev=3#comment_1372191
[2] https://patchwork.freedesktop.org/patch/746002/?series=171022&rev=4

Quoted 54 lines
Quoted 5 lines
Quoted 2 lines

We can have a error log with the type here. We don't need if else.

based on [1] all survivability mode SIGID are FATAL
and based on 21] it was an arch choice to go with info level for all

Quoted 11 lines

but IMO if the boot mode was selected via configfs it doesn't make sense to call it FATAL, but if there was real problem detected we should make it FATAL (like we do with failed PROBE)

[1] https://patchwork.freedesktop.org/patch/732271/?series=168333&rev=1
[2] https://patchwork.freedesktop.org/patch/743324/?series=171022&rev=3#comment_1373731

Quoted 4 lines

How about something like this? and remove else

<3> xe 0000:03:00.0: [drm] *ERROR* SIGID=<N> FATAL (01000000) SURVIVABILITY: mode=Boot

I am still trying to understand this series. Apologies if it is wrong, i tried to generate log using AI.

Quoted 36 lines

                                                       ^^^^^^^^
boot_status is u8 so it will be at most (01)

and I don't think we should be so cryptic in the user facing error messages

Quoted 20 lines
Quoted 1 line
Quoted 1 line

In case of fatal, will make sense to return "0" OR we can add return as -ENXIO right? any thoughts?

Mallesh, you cannot change return codes here. This defeats the purpose of survivability mode

Quoted 17 lines

you're a reviewer here ;)

but seriously, enable_boot_survivability_mode() is called from xe_survivability_mode_boot_enable() which says:

   * Return: 0 if boot survivability mode is enabled or not requested, negative error
   * code otherwise.

so returning 0 as success code in enabling boot mode is the correct one returning -ENXIO will be no different than failing to enter boot mode

@Riana, this is your code, can you please confirm that

Quoted 4 lines

After handling fatal case

Quoted 8 lines
Quoted 7 lines
Quoted 7 lines

drivers/gpu/drm/xe/xe_survivability_mode.c static int enable_boot_survivability_mode(struct pci_dev *pdev) · line 341

Quoted 7 lines
drivers/gpu/drm/xe/xe_survivability_mode.c +4 -1
+    else
+        xe_log_info(pdev, SURVIVABILITY, "Boot Mode enabled!\n");
           return 0;
     -err:
-    dev_err(dev, "Failed to enable Survivability Mode\n");
+failed:
+    xe_log_err_fatal(pdev, SURVIVABILITY, ret, "Failed to enable Boot Mode!\n");

Can we retain the previous dmesg?

there will be already "SURVIVABILITY: " prefix included, so IMO instead of generic:

Quoted 6 lines
Quoted 5 lines

   [drm] *ERROR* SIGID=103 (-EXXX) SURVIVABILITY: Failed to enable Survivability Mode

it's better to have more clearer message:

   [drm] *ERROR* SIGID=103 (-EXXX) SURVIVABILITY: Failed to enable Boot Mode!

Boot Mode and Runtime mode doesn't sound right.

both "Boot Mode" and "Runtime mode" were existing names in the code ;)

Quoted 3 lines

But i don't have any better suggestions here due
to repetition.Since its message and can be changed . Will replace it if i can come up with something better in the future.

I take it as an ack-by then

Quoted 10 lines

Thanks
Riana

Quoted 6 lines
Quoted 6 lines

Thanks
Riana

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
drivers/gpu/drm/xe/xe_survivability_mode.c +0 -0
         survivability->mode = false;
         return ret;
     }
#68 lore raw

Re: [PATCH v4 22/32] drm/xe/survivability: Report 'Boot Mode enabled' status using SIGID

Quoted 67 lines · Riana
Quoted 65 lines · Michal Wajdeczko
Quoted 63 lines · Riana
Quoted 61 lines · Michal Wajdeczko
Quoted 42 lines · Riana
Quoted 41 lines · Michal Wajdeczko
Quoted 40 lines · Koujalagi
Quoted 39 lines · Michal Wajdeczko

Report 'Boot Mode' status or failure using various xe_log() helpers.

Cc Rodrigo Vivi <[email protected]>
Cc Riana Tauro <[email protected]>
Cc Aravind Iddamsetty <[email protected]>
Cc Mallesh Koujalagi <[email protected]>

---
     drivers/gpu/drm/xe/xe_survivability_mode.c | 21 +++++++++++++--------

     1 file changed, 13 insertions(+), 8 deletions(-)
drivers/gpu/drm/xe/xe_survivability_mode.c +3 -5
index 2d8c532157fd..ebd288986c11 100644
@@ -304,14 +304,13 @@ static int create_survivability_sysfs(struct pci_dev *pdev)
        static int enable_boot_survivability_mode(struct pci_dev *pdev)
      {
-    struct device *dev = &pdev->dev;
          struct xe_device *xe = pdev_to_xe_device(pdev);
          struct xe_survivability *survivability = &xe->survivability;
-    int ret = 0;
+    int ret;
            ret = create_survivability_sysfs(pdev);
          if (ret)
-        return ret;
+        goto failed;
            /* Make sure xe_heci_gsc_init() and xe_i2c_probe() are aware of survivability */
          survivability->mode = true;
@@ -323,19 +322,25 @@ static int enable_boot_survivability_mode(struct pci_dev *pdev)
          if (survivability->fdo_mode) {
              ret = xe_nvm_init(xe);
              if (ret)
-            goto err;
+            goto failed;
          }
            ret = xe_i2c_probe(xe);
          if (ret)
-        goto err;
Quoted 8 lines
Quoted 7 lines
Quoted 7 lines

drivers/gpu/drm/xe/xe_survivability_mode.c static int enable_boot_survivability_mode(struct pci_dev *pdev) · line 335

Quoted 7 lines
drivers/gpu/drm/xe/xe_survivability_mode.c +6 -0
+        goto failed;
      -    dev_err(dev, "In Survivability Mode\n");
+    if (check_boot_failure(xe))
+        xe_log_comp_fatal(pdev, SURVIVABILITY,
+                  &survivability->boot_status,
+                  sizeof(survivability->boot_status),
+                  "Boot Mode enabled!\n");

Do we need this check? This function is only called if it is a boot failure.

are you sure?

in xe_device_probe_early() there is:

     err = xe_pcode_probe_early(xe);
     if (err || xe_survivability_mode_is_requested(xe)) { err = xe_survivability_mode_boot_enable(xe);

and xe_survivability_mode_is_requested() may return true based on the xe_configfs_get_survivability_mode() settings

Quoted 6 lines
Quoted 4 lines
Quoted 2 lines

Configfs also is provided for users to enable boot survivability mode. So one log should be sufficient.

there will be still one log entry but it will be with different severity based on the configfs vs bootstatus origin

configfs should also result in fatal because it also enters survivability mode and it was user's decision.

then I guess we should be more consistent in reporting user initiated actions, as in case of blocked PROBE (with modparam) we are now using info [1] as requested by Aravind in [2] as it was also an user initiated action

[1] https://patchwork.freedesktop.org/patch/746003/?series=171022&rev=4
[2] https://patchwork.freedesktop.org/patch/742259/?series=171022&rev=1#comment_1367587

Quoted 102 lines
Quoted 6 lines
Quoted 5 lines

If we do need to add a blob instead of error no we should go ahead with all the scratch registers as they contain the error details instead of just boot status. Can't we just add 0 for now and come up with something that we can decode in future.?

including boot_status value here was requested by Mallesh in [1]

Don't agree with [1].

[2] prints only for critical errors. As responded on that patch, it was a intentional change based on review feedback.

No error no should be good here or a hardware error (-EIO). Lets not use boot status

Thanks
Riana

Quoted 85 lines

and logging all boot status registers is already done in [2] but only if boot mode was not triggered by configfs

[1] https://patchwork.freedesktop.org/patch/743324/?series=171022&rev=3#comment_1372191
[2] https://patchwork.freedesktop.org/patch/746002/?series=171022&rev=4

Quoted 54 lines
Quoted 5 lines
Quoted 2 lines

We can have a error log with the type here. We don't need if else.

based on [1] all survivability mode SIGID are FATAL
and based on 21] it was an arch choice to go with info level for all

Quoted 11 lines

but IMO if the boot mode was selected via configfs it doesn't make sense to call it FATAL, but if there was real problem detected we should make it FATAL (like we do with failed PROBE)

[1] https://patchwork.freedesktop.org/patch/732271/?series=168333&rev=1
[2] https://patchwork.freedesktop.org/patch/743324/?series=171022&rev=3#comment_1373731

Quoted 4 lines

How about something like this? and remove else

<3> xe 0000:03:00.0: [drm] *ERROR* SIGID=<N> FATAL (01000000) SURVIVABILITY: mode=Boot

I am still trying to understand this series. Apologies if it is wrong, i tried to generate log using AI.

Quoted 36 lines

                                                        ^^^^^^^^ boot_status is u8 so it will be at most (01)

and I don't think we should be so cryptic in the user facing error messages

Quoted 20 lines
Quoted 1 line
Quoted 1 line

In case of fatal, will make sense to return "0" OR we can add return as -ENXIO right? any thoughts?

Mallesh, you cannot change return codes here. This defeats the purpose of survivability mode

Quoted 17 lines

you're a reviewer here ;)

but seriously, enable_boot_survivability_mode() is called from xe_survivability_mode_boot_enable() which says:

    * Return: 0 if boot survivability mode is enabled or not requested, negative error
    * code otherwise.

so returning 0 as success code in enabling boot mode is the correct one returning -ENXIO will be no different than failing to enter boot mode

@Riana, this is your code, can you please confirm that

Quoted 4 lines

After handling fatal case

Quoted 8 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
drivers/gpu/drm/xe/xe_survivability_mode.c +2 -0
+    else
+        xe_log_info(pdev, SURVIVABILITY, "Boot Mode enabled!\n");
            return 0;

     -err:
-    dev_err(dev, "Failed to enable Survivability Mode\n");
+failed:
+    xe_log_err_fatal(pdev, SURVIVABILITY, ret, "Failed to enable Boot Mode!\n");

Can we retain the previous dmesg?

there will be already "SURVIVABILITY: " prefix included, so IMO instead of generic:

Quoted 6 lines
Quoted 5 lines

    [drm] *ERROR* SIGID=103 (-EXXX) SURVIVABILITY: Failed to enable Survivability Mode

it's better to have more clearer message:

    [drm] *ERROR* SIGID=103 (-EXXX) SURVIVABILITY: Failed to enable Boot Mode!

Boot Mode and Runtime mode doesn't sound right.

both "Boot Mode" and "Runtime mode" were existing names in the code ;)

Quoted 3 lines

But i don't have any better suggestions here due
to repetition.Since its message and can be changed . Will replace it if i can come up with something better in the future.

I take it as an ack-by then

Quoted 10 lines

Thanks
Riana

Quoted 6 lines
Quoted 6 lines

Thanks
Riana

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

         survivability->mode = false;
         return ret;
     }

#69 lore raw

Re: [PATCH v4 22/32] drm/xe/survivability: Report 'Boot Mode enabled' status using SIGID

In reply to Tauro, Riana
Quoted 58 lines · Riana
Quoted 44 lines · Michal Wajdeczko
Quoted 42 lines · Koujalagi
Quoted 41 lines · Michal Wajdeczko

Report 'Boot Mode' status or failure using various xe_log() helpers.

Cc Rodrigo Vivi <[email protected]>
Cc Riana Tauro <[email protected]>
Cc Aravind Iddamsetty <[email protected]>
Cc Mallesh Koujalagi <[email protected]>

---
   drivers/gpu/drm/xe/xe_survivability_mode.c | 21
+++++++++++++--------

   1 file changed, 13 insertions(+), 8 deletions(-)
drivers/gpu/drm/xe/xe_survivability_mode.c +3 -4
index 2d8c532157fd..ebd288986c11 100644
@@ -304,14 +304,13 @@ static int create_survivability_sysfs(struct 
 pci_dev *pdev)
      static int enable_boot_survivability_mode(struct pci_dev *pdev)
    {
-    struct device *dev = &pdev->dev;
        struct xe_device *xe = pdev_to_xe_device(pdev);
        struct xe_survivability *survivability = &xe->survivability;
-    int ret = 0;
+    int ret;
          ret = create_survivability_sysfs(pdev);
        if (ret)
-        return ret;
+        goto failed;
          /* Make sure xe_heci_gsc_init() and xe_i2c_probe() are aware of survivability */
        survivability->mode = true;
@@ -323,19 +322,25 @@ static int 
 enable_boot_survivability_mode(struct pci_dev *pdev)
        if (survivability->fdo_mode) {
            ret = xe_nvm_init(xe);
            if (ret)
-            goto err;
+            goto failed;
        }
          ret = xe_i2c_probe(xe);
        if (ret)
Quoted 8 lines
Quoted 8 lines

drivers/gpu/drm/xe/xe_survivability_mode.c static int enable_boot_survivability_mode(struct pci_dev *pdev) · line 336

Quoted 8 lines
drivers/gpu/drm/xe/xe_survivability_mode.c +6 -1
-        goto err;
+        goto failed;
    -    dev_err(dev, "In Survivability Mode\n");
+    if (check_boot_failure(xe))
+        xe_log_comp_fatal(pdev, SURVIVABILITY,
+                  &survivability->boot_status,
+                  sizeof(survivability->boot_status),
+                  "Boot Mode enabled!\n");

Do we need this check? This function is only called if it is a boot failure.

We can have a error log with the type here. We don't need if else.

Quoted 7 lines

How about something like this? and remove else

<3> xe 0000:03:00.0: [drm] *ERROR* SIGID=<N> FATAL (01000000) SURVIVABILITY: mode=Boot

Quoted 1 line
Quoted 1 line

In case of fatal, will make sense to return "0" OR we can add return as -ENXIO right? any thoughts?

Mallesh, you cannot change return codes here. This defeats the purpose of survivability mode

In that case, discard my suggestion for return 0 or -ENXIO.

Please post complete changes, will check it.

Thanks,

-/Mallesh

Quoted 35 lines
Quoted 6 lines

you're a reviewer here ;)

but seriously, enable_boot_survivability_mode() is called from xe_survivability_mode_boot_enable() which says:

Quoted 20 lines

  * Return: 0 if boot survivability mode is enabled or not requested, negative error
  * code otherwise.

so returning 0 as success code in enabling boot mode is the correct one returning -ENXIO will be no different than failing to enter boot mode

@Riana, this is your code, can you please confirm that

Quoted 12 lines

After handling fatal case

Quoted 8 lines
drivers/gpu/drm/xe/xe_survivability_mode.c +2 -0
+    else
+        xe_log_info(pdev, SURVIVABILITY, "Boot Mode enabled!\n");
          return 0;

   -err:
-    dev_err(dev, "Failed to enable Survivability Mode\n"); +failed:
+    xe_log_err_fatal(pdev, SURVIVABILITY, ret, "Failed to enable Boot Mode!\n");

Can we retain the previous dmesg?

Thanks
Riana

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

       survivability->mode = false;
       return ret;
   }

#70 lore raw

PATCH v4 23/32 drm/xe/survivability: Report 'Runtime Mode enabled' status using SIGID

In reply to Michal Wajdeczko

Report 'Runtime Mode' status using various xe_log() helpers.

Cc Rodrigo Vivi <[email protected]>
Cc Riana Tauro <[email protected]>
Cc Aravind Iddamsetty <[email protected]>
Cc Mallesh Koujalagi <[email protected]>
---
 drivers/gpu/drm/xe/xe_survivability_mode.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)
drivers/gpu/drm/xe/xe_survivability_mode.c +7 -3
index ebd288986c11..5d3315ac735c 100644
@@ -18,6 +18,7 @@
 #include "xe_mmio.h"
 #include "xe_nvm.h"
 #include "xe_pcode_api.h"
+#include "xe_printk.h"
 #include "xe_vsec.h"
 
 /**
@@ -405,7 +406,7 @@ void xe_survivability_mode_runtime_enable(struct xe_device *xe)
 	struct pci_dev *pdev = to_pci_dev(xe->drm.dev);
 
 	if (!IS_DGFX(xe) || IS_SRIOV_VF(xe) || xe->info.platform < XE_BATTLEMAGE) {
-		dev_err(&pdev->dev, "Runtime Survivability Mode not supported\n");
+		xe_log_err(xe, SURVIVABILITY, -EOPNOTSUPP, "Runtime Mode not supported!\n");
 		return;
 	}
 
@@ -413,11 +414,14 @@ void xe_survivability_mode_runtime_enable(struct xe_device *xe)
 	create_survivability_sysfs(pdev);
 
 	survivability->type = XE_SURVIVABILITY_TYPE_RUNTIME;
-	dev_err(&pdev->dev, "Runtime Survivability mode enabled\n");
+	xe_log_info(xe, SURVIVABILITY, "Runtime Mode enabled!\n");
 
 	xe_device_set_wedged_method(xe, DRM_WEDGE_RECOVERY_VENDOR);
 	xe_device_declare_wedged(xe);
-	dev_err(&pdev->dev, "Firmware flash required, Please refer to the userspace documentation for more details!\n");
+
+	xe_log_info(xe, SURVIVABILITY, "Firmware flash required!\n");
+	xe_info(xe, "Please refer to the userspace documentation for more details how to flash the firmware on %s!\n",
+		xe->info.platform_name);
 }
 
 static void log_survivability_info(struct xe_device *xe)
Signature · 1 line
2.47.1
Reviewed-by on v4 23/32
#71 lore raw

Re: [PATCH v4 23/32] drm/xe/survivability: Report 'Runtime Mode enabled' status using SIGID

Quoted 34 lines · Michal Wajdeczko

Report 'Runtime Mode' status using various xe_log() helpers.

Cc Rodrigo Vivi<[email protected]>
Cc Riana Tauro<[email protected]>
Cc Aravind Iddamsetty<[email protected]>
Cc Mallesh Koujalagi<[email protected]>
---
  drivers/gpu/drm/xe/xe_survivability_mode.c | 10 +++++++---
  1 file changed, 7 insertions(+), 3 deletions(-)
drivers/gpu/drm/xe/xe_survivability_mode.c +2 -1
index ebd288986c11..5d3315ac735c 100644
@@ -18,6 +18,7 @@
  #include "xe_mmio.h"
  #include "xe_nvm.h"
  #include "xe_pcode_api.h"
+#include "xe_printk.h"
  #include "xe_vsec.h"
 
  /**
@@ -405,7 +406,7 @@ void xe_survivability_mode_runtime_enable(struct xe_device *xe)
  	struct pci_dev *pdev = to_pci_dev(xe->drm.dev);
 
  	if (!IS_DGFX(xe) || IS_SRIOV_VF(xe) || xe->info.platform < XE_BATTLEMAGE) {
-		dev_err(&pdev->dev, "Runtime Survivability Mode not supported\n");
+		xe_log_err(xe, SURVIVABILITY, -EOPNOTSUPP, "Runtime Mode not supported!\n");
  		return;
  	}
 
@@ -413,11 +414,14 @@ void xe_survivability_mode_runtime_enable(struct xe_device *xe)
  	create_survivability_sysfs(pdev);

drivers/gpu/drm/xe/xe_survivability_mode.c void xe_survivability_mode_runtime_enable(struct xe_device *xe) · line 422

Quoted 10 lines
drivers/gpu/drm/xe/xe_survivability_mode.c +3 -2
 
  	survivability->type = XE_SURVIVABILITY_TYPE_RUNTIME;
-	dev_err(&pdev->dev, "Runtime Survivability mode enabled\n");
+	xe_log_info(xe, SURVIVABILITY, "Runtime Mode enabled!\n");
 
  	xe_device_set_wedged_method(xe, DRM_WEDGE_RECOVERY_VENDOR);
  	xe_device_declare_wedged(xe);
-	dev_err(&pdev->dev, "Firmware flash required, Please refer to the userspace documentation for more details!\n");
+
+	xe_log_info(xe, SURVIVABILITY, "Firmware flash required!\n");

IMO, we need to use xe_log_err (recoverable) here instead of xe_log_info.

Already mentioned in original changes [1], runtime firmware errors cause device unstable:

[1] https://gitlab.freedesktop.org/drm/tip/-/commit/a2ca0633a0fef925a0d8125d8f3e4495a5ecb310

As I know xe_survivability_mode_runtime_enable function need to carry errno as parameter to pass into xe_log_err,

however we need to create separate refactor patch for that in future.

With above changes:

Quoted 5 lines
drivers/gpu/drm/xe/xe_survivability_mode.c +2 -0
+	xe_info(xe, "Please refer to the userspace documentation for more details how to flash the firmware on %s!\n",
+		xe->info.platform_name);
  }
 
  static void log_survivability_info(struct xe_device *xe)
#72 lore raw

Re: [PATCH v4 23/32] drm/xe/survivability: Report 'Runtime Mode enabled' status using SIGID

Quoted 49 lines · Koujalagi
Quoted 34 lines · Michal Wajdeczko

Report 'Runtime Mode' status using various xe_log() helpers.

Cc Rodrigo Vivi <[email protected]>
Cc Riana Tauro <[email protected]>
Cc Aravind Iddamsetty <[email protected]>
Cc Mallesh Koujalagi <[email protected]>
---
 drivers/gpu/drm/xe/xe_survivability_mode.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)
drivers/gpu/drm/xe/xe_survivability_mode.c +2 -1
index ebd288986c11..5d3315ac735c 100644
@@ -18,6 +18,7 @@
 #include "xe_mmio.h"
 #include "xe_nvm.h"
 #include "xe_pcode_api.h"
+#include "xe_printk.h"
 #include "xe_vsec.h"
 
 /**
@@ -405,7 +406,7 @@ void xe_survivability_mode_runtime_enable(struct xe_device *xe)
 	struct pci_dev *pdev = to_pci_dev(xe->drm.dev);
 
 	if (!IS_DGFX(xe) || IS_SRIOV_VF(xe) || xe->info.platform < XE_BATTLEMAGE) {
-		dev_err(&pdev->dev, "Runtime Survivability Mode not supported\n");
+		xe_log_err(xe, SURVIVABILITY, -EOPNOTSUPP, "Runtime Mode not supported!\n");
 		return;
 	}
 
@@ -413,11 +414,14 @@ void xe_survivability_mode_runtime_enable(struct xe_device *xe)
 	create_survivability_sysfs(pdev);

drivers/gpu/drm/xe/xe_survivability_mode.c void xe_survivability_mode_runtime_enable(struct xe_device *xe) · line 422

Quoted 10 lines
drivers/gpu/drm/xe/xe_survivability_mode.c +3 -2
 
 	survivability->type = XE_SURVIVABILITY_TYPE_RUNTIME;
-	dev_err(&pdev->dev, "Runtime Survivability mode enabled\n");
+	xe_log_info(xe, SURVIVABILITY, "Runtime Mode enabled!\n");
 
 	xe_device_set_wedged_method(xe, DRM_WEDGE_RECOVERY_VENDOR);
 	xe_device_declare_wedged(xe);
-	dev_err(&pdev->dev, "Firmware flash required, Please refer to the userspace documentation for more details!\n");
+
+	xe_log_info(xe, SURVIVABILITY, "Firmware flash required!\n");

IMO, we need to use xe_log_err (recoverable) here instead of xe_log_info.

Quoted 3 lines

Already mentioned in original changes [1], runtime firmware errors cause device unstable:

[1] https://gitlab.freedesktop.org/drm/tip/-/commit/a2ca0633a0fef925a0d8125d8f3e4495a5ecb310

but in recent comment [2] you said that Arch team wanted that to be logged as info rather than fatal

[2] https://patchwork.freedesktop.org/patch/743324/?series=171022&rev=3#comment_1373731

@Riana, @Rodrigo, @Aravind ?

I need a decider here

Quoted 16 lines

As I know xe_survivability_mode_runtime_enable function need to carry errno as parameter to pass into xe_log_err,

however we need to create separate refactor patch for that in future.

With above changes:

Quoted 5 lines
drivers/gpu/drm/xe/xe_survivability_mode.c +2 -0
+	xe_info(xe, "Please refer to the userspace documentation for more details how to flash the firmware on %s!\n",
+		xe->info.platform_name);
 }
 
 static void log_survivability_info(struct xe_device *xe)
#73 lore raw

Re: [PATCH v4 23/32] drm/xe/survivability: Report 'Runtime Mode enabled' status using SIGID

Quoted 49 lines · Michal Wajdeczko
Quoted 47 lines · Koujalagi
Quoted 34 lines · Michal Wajdeczko

Report 'Runtime Mode' status using various xe_log() helpers.

Cc Rodrigo Vivi <[email protected]>
Cc Riana Tauro <[email protected]>
Cc Aravind Iddamsetty <[email protected]>
Cc Mallesh Koujalagi <[email protected]>
---
  drivers/gpu/drm/xe/xe_survivability_mode.c | 10 +++++++---
  1 file changed, 7 insertions(+), 3 deletions(-)
drivers/gpu/drm/xe/xe_survivability_mode.c +2 -1
index ebd288986c11..5d3315ac735c 100644
@@ -18,6 +18,7 @@
  #include "xe_mmio.h"
  #include "xe_nvm.h"
  #include "xe_pcode_api.h"
+#include "xe_printk.h"
  #include "xe_vsec.h"
 
  /**
@@ -405,7 +406,7 @@ void xe_survivability_mode_runtime_enable(struct xe_device *xe)
  	struct pci_dev *pdev = to_pci_dev(xe->drm.dev);
 
  	if (!IS_DGFX(xe) || IS_SRIOV_VF(xe) || xe->info.platform < XE_BATTLEMAGE) {
-		dev_err(&pdev->dev, "Runtime Survivability Mode not supported\n");
+		xe_log_err(xe, SURVIVABILITY, -EOPNOTSUPP, "Runtime Mode not supported!\n");
  		return;
  	}
 
@@ -413,11 +414,14 @@ void xe_survivability_mode_runtime_enable(struct xe_device *xe)
  	create_survivability_sysfs(pdev);

drivers/gpu/drm/xe/xe_survivability_mode.c void xe_survivability_mode_runtime_enable(struct xe_device *xe) · line 422

Quoted 10 lines
drivers/gpu/drm/xe/xe_survivability_mode.c +3 -2
 
  	survivability->type = XE_SURVIVABILITY_TYPE_RUNTIME;
-	dev_err(&pdev->dev, "Runtime Survivability mode enabled\n");
+	xe_log_info(xe, SURVIVABILITY, "Runtime Mode enabled!\n");
 
  	xe_device_set_wedged_method(xe, DRM_WEDGE_RECOVERY_VENDOR);
  	xe_device_declare_wedged(xe);
-	dev_err(&pdev->dev, "Firmware flash required, Please refer to the userspace documentation for more details!\n");
+
+	xe_log_info(xe, SURVIVABILITY, "Firmware flash required!\n");

IMO, we need to use xe_log_err (recoverable) here instead of xe_log_info.

Quoted 6 lines
Quoted 3 lines

Already mentioned in original changes [1], runtime firmware errors cause device unstable:

[1] https://gitlab.freedesktop.org/drm/tip/-/commit/a2ca0633a0fef925a0d8125d8f3e4495a5ecb310

but in recent comment [2] you said that Arch team wanted that to be logged as info rather than fatal

[2] https://patchwork.freedesktop.org/patch/743324/?series=171022&rev=3#comment_1373731

When we pass zero as errno, that time we can use it *_info  (boot survivability mode), that's what Arch team told me.

@Aravind, can u please comment here.

Thanks,

-/Mallesh

Quoted 20 lines

@Riana, @Rodrigo, @Aravind ?

I need a decider here

Quoted 15 lines

As I know xe_survivability_mode_runtime_enable function need to carry errno as parameter to pass into xe_log_err,

however we need to create separate refactor patch for that in future.

With above changes:

Quoted 5 lines
drivers/gpu/drm/xe/xe_survivability_mode.c +2 -0
+	xe_info(xe, "Please refer to the userspace documentation for more details how to flash the firmware on %s!\n",
+		xe->info.platform_name);
  }
 
  static void log_survivability_info(struct xe_device *xe)
#74 lore raw

Re: [PATCH v4 23/32] drm/xe/survivability: Report 'Runtime Mode enabled' status using SIGID

In reply to Michal Wajdeczko
Quoted 35 lines · Michal Wajdeczko
Quoted 33 lines · Koujalagi
Quoted 32 lines · Michal Wajdeczko

Report 'Runtime Mode' status using various xe_log() helpers.

Cc Rodrigo Vivi <[email protected]>
Cc Riana Tauro <[email protected]>
Cc Aravind Iddamsetty <[email protected]>
Cc Mallesh Koujalagi <[email protected]>
---
  drivers/gpu/drm/xe/xe_survivability_mode.c | 10 +++++++---
  1 file changed, 7 insertions(+), 3 deletions(-)
drivers/gpu/drm/xe/xe_survivability_mode.c +2 -1
index ebd288986c11..5d3315ac735c 100644
@@ -18,6 +18,7 @@
  #include "xe_mmio.h"
  #include "xe_nvm.h"
  #include "xe_pcode_api.h"
+#include "xe_printk.h"
  #include "xe_vsec.h"
 
  /**
@@ -405,7 +406,7 @@ void xe_survivability_mode_runtime_enable(struct xe_device *xe)
  	struct pci_dev *pdev = to_pci_dev(xe->drm.dev);
 
  	if (!IS_DGFX(xe) || IS_SRIOV_VF(xe) || xe->info.platform < XE_BATTLEMAGE) {
-		dev_err(&pdev->dev, "Runtime Survivability Mode not supported\n");
+		xe_log_err(xe, SURVIVABILITY, -EOPNOTSUPP, "Runtime Mode not supported!\n");
  		return;
  	}
 
Quoted 6 lines
Quoted 6 lines

drivers/gpu/drm/xe/xe_survivability_mode.c void xe_survivability_mode_runtime_enable(struct xe_device *xe) · line 417

Quoted 6 lines
drivers/gpu/drm/xe/xe_survivability_mode.c +1 -1
@@ -413,11 +414,14 @@ void xe_survivability_mode_runtime_enable(struct xe_device *xe)
  	create_survivability_sysfs(pdev);
 
  	survivability->type = XE_SURVIVABILITY_TYPE_RUNTIME;
-	dev_err(&pdev->dev, "Runtime Survivability mode enabled\n");
+	xe_log_info(xe, SURVIVABILITY, "Runtime Mode enabled!\n");

This should be xe_log_err

Quoted 7 lines
Quoted 7 lines

drivers/gpu/drm/xe/xe_survivability_mode.c void xe_survivability_mode_runtime_enable(struct xe_device *xe) · line 422

Quoted 6 lines
drivers/gpu/drm/xe/xe_survivability_mode.c +2 -1
  	xe_device_set_wedged_method(xe, DRM_WEDGE_RECOVERY_VENDOR);
  	xe_device_declare_wedged(xe);
-	dev_err(&pdev->dev, "Firmware flash required, Please refer to the userspace documentation for more details!\n");
+
+	xe_log_info(xe, SURVIVABILITY, "Firmware flash required!\n");

IMO, we need to use xe_log_err (recoverable) here instead of xe_log_info.

Same here.

Quoted 16 lines
Quoted 4 lines

Already mentioned in original changes [1], runtime firmware errors cause device unstable:

[1] https://gitlab.freedesktop.org/drm/tip/-/commit/a2ca0633a0fef925a0d8125d8f3e4495a5ecb310

but in recent comment [2] you said that Arch team wanted that to be logged as info rather than fatal

[2] https://patchwork.freedesktop.org/patch/743324/?series=171022&rev=3#comment_1373731

@Riana, @Rodrigo, @Aravind ?

I need a decider here

Quoted 4 lines

As I know xe_survivability_mode_runtime_enable function need to carry errno as parameter to pass into xe_log_err,

however we need to create separate refactor patch for that in future.

Why do we need error no here? It should be 0.

Thanks
Riana

Quoted 11 lines
Quoted 11 lines

With above changes:

Quoted 5 lines
drivers/gpu/drm/xe/xe_survivability_mode.c +2 -0
+	xe_info(xe, "Please refer to the userspace documentation for more details how to flash the firmware on %s!\n",
+		xe->info.platform_name);
  }
 
  static void log_survivability_info(struct xe_device *xe)
#75 lore raw

Re: [PATCH v4 23/32] drm/xe/survivability: Report 'Runtime Mode enabled' status using SIGID

Quoted 34 lines · Riana
Quoted 31 lines · Michal Wajdeczko
Quoted 29 lines · Koujalagi
Quoted 28 lines · Michal Wajdeczko

Report 'Runtime Mode' status using various xe_log() helpers.

Cc Rodrigo Vivi <[email protected]>
Cc Riana Tauro <[email protected]>
Cc Aravind Iddamsetty <[email protected]>
Cc Mallesh Koujalagi <[email protected]>

---
  drivers/gpu/drm/xe/xe_survivability_mode.c | 10 +++++++---

  1 file changed, 7 insertions(+), 3 deletions(-)
drivers/gpu/drm/xe/xe_survivability_mode.c +2 -1
index ebd288986c11..5d3315ac735c 100644
@@ -18,6 +18,7 @@
   #include "xe_mmio.h"
   #include "xe_nvm.h"
   #include "xe_pcode_api.h"
+#include "xe_printk.h"
   #include "xe_vsec.h"
     /**
@@ -405,7 +406,7 @@ void xe_survivability_mode_runtime_enable(struct xe_device *xe)
       struct pci_dev *pdev = to_pci_dev(xe->drm.dev);
         if (!IS_DGFX(xe) || IS_SRIOV_VF(xe) || xe->info.platform < XE_BATTLEMAGE) {
-        dev_err(&pdev->dev, "Runtime Survivability Mode not supported\n");
+        xe_log_err(xe, SURVIVABILITY, -EOPNOTSUPP, "Runtime Mode not supported!\n");
           return;
Quoted 8 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
drivers/gpu/drm/xe/xe_survivability_mode.c +0 -0
       }
   @@ -413,11 +414,14 @@ void xe_survivability_mode_runtime_enable(struct xe_device *xe)
       create_survivability_sysfs(pdev);

        survivability->type = XE_SURVIVABILITY_TYPE_RUNTIME; -    dev_err(&pdev->dev, "Runtime Survivability mode enabled\n"); +    xe_log_info(xe, SURVIVABILITY, "Runtime Mode enabled!\n");

This should be xe_log_err

do you want to include any specific errno here (like -ESTALE) or just use 0 to do not include it in the message?

asking now, as I don't want to respin the whole series after I make a wrong decision based on dice roll

having an extra errno in the dmesg/CPER along with SIGID will likely help us write better documentation with resolutions

Quoted 8 lines
Quoted 6 lines
Quoted 6 lines
Quoted 5 lines

        xe_device_set_wedged_method(xe, DRM_WEDGE_RECOVERY_VENDOR);
      xe_device_declare_wedged(xe);
-    dev_err(&pdev->dev, "Firmware flash required, Please refer to the userspace documentation for more details!\n"); +
+    xe_log_info(xe, SURVIVABILITY, "Firmware flash required!\n");

IMO, we need to use xe_log_err (recoverable) here instead of xe_log_info.

Same here.

ditto

Quoted 34 lines
Quoted 4 lines
Quoted 4 lines

Already mentioned in original changes [1], runtime firmware errors cause device unstable:

Quoted 13 lines
Quoted 1 line

[1] https://gitlab.freedesktop.org/drm/tip/-/commit/a2ca0633a0fef925a0d8125d8f3e4495a5ecb310

but in recent comment [2] you said that Arch team wanted that to be logged as info rather than fatal

[2] https://patchwork.freedesktop.org/patch/743324/?series=171022&rev=3#comment_1373731

@Riana, @Rodrigo, @Aravind ?

I need a decider here

Quoted 4 lines

As I know xe_survivability_mode_runtime_enable function need to carry errno as parameter to pass into xe_log_err,

however we need to create separate refactor patch for that in future.

Why do we need error no here? It should be 0.

Thanks
Riana

Quoted 10 lines
Quoted 10 lines

With above changes:

Quoted 4 lines

+    xe_info(xe, "Please refer to the userspace documentation for more details how to flash the firmware on %s!\n", +        xe->info.platform_name);
  }
    static void log_survivability_info(struct xe_device *xe)

#76 lore raw

Re: [PATCH v4 23/32] drm/xe/survivability: Report 'Runtime Mode enabled' status using SIGID

Quoted 41 lines · Michal Wajdeczko
Quoted 31 lines · Riana
Quoted 29 lines · Michal Wajdeczko
Quoted 28 lines · Koujalagi
Quoted 27 lines · Michal Wajdeczko

Report 'Runtime Mode' status using various xe_log() helpers.

Cc Rodrigo Vivi <[email protected]>
Cc Riana Tauro <[email protected]>
Cc Aravind Iddamsetty <[email protected]>
Cc Mallesh Koujalagi <[email protected]>
---
   drivers/gpu/drm/xe/xe_survivability_mode.c | 10 +++++++---
   1 file changed, 7 insertions(+), 3 deletions(-)
drivers/gpu/drm/xe/xe_survivability_mode.c +2 -1
index ebd288986c11..5d3315ac735c 100644
@@ -18,6 +18,7 @@
   #include "xe_mmio.h"
   #include "xe_nvm.h"
   #include "xe_pcode_api.h"
+#include "xe_printk.h"
   #include "xe_vsec.h"
     /**
@@ -405,7 +406,7 @@ void xe_survivability_mode_runtime_enable(struct xe_device *xe)
       struct pci_dev *pdev = to_pci_dev(xe->drm.dev);
         if (!IS_DGFX(xe) || IS_SRIOV_VF(xe) || xe->info.platform < XE_BATTLEMAGE) {
-        dev_err(&pdev->dev, "Runtime Survivability Mode not supported\n");
+        xe_log_err(xe, SURVIVABILITY, -EOPNOTSUPP, "Runtime Mode not supported!\n");
Quoted 8 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
drivers/gpu/drm/xe/xe_survivability_mode.c +0 -0
           return;
       }
   @@ -413,11 +414,14 @@ void xe_survivability_mode_runtime_enable(struct xe_device *xe)
       create_survivability_sysfs(pdev);

        survivability->type = XE_SURVIVABILITY_TYPE_RUNTIME;
-    dev_err(&pdev->dev, "Runtime Survivability mode enabled\n"); +    xe_log_info(xe, SURVIVABILITY, "Runtime Mode enabled!\n");

This should be xe_log_err

Quoted 2 lines

do you want to include any specific errno here (like -ESTALE) or just use 0 to do not include it in the message?

Can we skip errorno for now based on comment in the last patch?
@Rodrigo I was thinking we could add the detailed error information from scratch registers here in a future patch but will need to come up with some format
Let me know your thoughts?

Quoted 5 lines

asking now, as I don't want to respin the whole series after I make a wrong decision based on dice roll

having an extra errno in the dmesg/CPER along with SIGID will likely help us write better documentation with resolutions

For survivability, UMD's need to check sysfs always before taking a decision of recovery as we have multiple recovery methods.
We cannot have generic recovery documentation based on error no here.

Thanks
Riana

Quoted 39 lines
Quoted 8 lines
Quoted 7 lines
Quoted 7 lines
Quoted 6 lines

        xe_device_set_wedged_method(xe, DRM_WEDGE_RECOVERY_VENDOR);
      xe_device_declare_wedged(xe);
-    dev_err(&pdev->dev, "Firmware flash required, Please refer to the userspace documentation for more details!\n"); +
+    xe_log_info(xe, SURVIVABILITY, "Firmware flash required!\n");

IMO, we need to use xe_log_err (recoverable) here instead of xe_log_info.

Same here.

ditto

Quoted 29 lines
Quoted 14 lines
Quoted 3 lines

Already mentioned in original changes [1], runtime firmware errors cause device unstable:

[1] https://gitlab.freedesktop.org/drm/tip/-/commit/a2ca0633a0fef925a0d8125d8f3e4495a5ecb310

but in recent comment [2] you said that Arch team wanted that to be logged as info rather than fatal

[2] https://patchwork.freedesktop.org/patch/743324/?series=171022&rev=3#comment_1373731

@Riana, @Rodrigo, @Aravind ?

I need a decider here

Quoted 3 lines

As I know xe_survivability_mode_runtime_enable function need to carry errno as parameter to pass into xe_log_err,

however we need to create separate refactor patch for that in future.

Why do we need error no here? It should be 0.

Thanks
Riana

Quoted 9 lines
Quoted 9 lines

With above changes:

Quoted 4 lines

+    xe_info(xe, "Please refer to the userspace documentation for more details how to flash the firmware on %s!\n", +        xe->info.platform_name);
  }
    static void log_survivability_info(struct xe_device *xe)

#77 lore raw

Re: [PATCH v4 23/32] drm/xe/survivability: Report 'Runtime Mode enabled' status using SIGID

Quoted 43 lines · Riana
Quoted 41 lines · Michal Wajdeczko
Quoted 39 lines · Riana
Quoted 28 lines · Michal Wajdeczko
Quoted 27 lines · Koujalagi
Quoted 26 lines · Michal Wajdeczko

Report 'Runtime Mode' status using various xe_log() helpers.

Cc Rodrigo Vivi <[email protected]>
Cc Riana Tauro <[email protected]>
Cc Aravind Iddamsetty <[email protected]>
Cc Mallesh Koujalagi <[email protected]>

---
   drivers/gpu/drm/xe/xe_survivability_mode.c | 10 +++++++---

   1 file changed, 7 insertions(+), 3 deletions(-)
drivers/gpu/drm/xe/xe_survivability_mode.c +1 -1
index ebd288986c11..5d3315ac735c 100644
@@ -18,6 +18,7 @@
    #include "xe_mmio.h"
    #include "xe_nvm.h"
    #include "xe_pcode_api.h"
+#include "xe_printk.h"
    #include "xe_vsec.h"
      /**
@@ -405,7 +406,7 @@ void xe_survivability_mode_runtime_enable(struct xe_device *xe)
        struct pci_dev *pdev = to_pci_dev(xe->drm.dev);
          if (!IS_DGFX(xe) || IS_SRIOV_VF(xe) || xe->info.platform < XE_BATTLEMAGE) {
-        dev_err(&pdev->dev, "Runtime Survivability Mode not supported\n");
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
drivers/gpu/drm/xe/xe_survivability_mode.c +1 -0
+        xe_log_err(xe, SURVIVABILITY, -EOPNOTSUPP, "Runtime Mode not supported!\n");
            return;
        }
    @@ -413,11 +414,14 @@ void xe_survivability_mode_runtime_enable(struct xe_device *xe)
        create_survivability_sysfs(pdev);

         survivability->type = XE_SURVIVABILITY_TYPE_RUNTIME; -    dev_err(&pdev->dev, "Runtime Survivability mode enabled\n"); +    xe_log_info(xe, SURVIVABILITY, "Runtime Mode enabled!\n");

This should be xe_log_err

Quoted 4 lines
Quoted 2 lines

do you want to include any specific errno here (like -ESTALE) or just use 0 to do not include it in the message?

Can we skip errorno for now based on comment in the last patch?

ok

Quoted 3 lines

@Rodrigo I was thinking we could add the detailed error information from scratch registers here in a future patch but will need to come up with some format
Let me know your thoughts?

btw, is this something more than what the log_survivability_info() is currently doing ? we log that with SIGID already (but not always)

Quoted 10 lines
Quoted 6 lines

asking now, as I don't want to respin the whole series after I make a wrong decision based on dice roll

having an extra errno in the dmesg/CPER along with SIGID will likely help us write better documentation with resolutions

For survivability, UMD's need to check sysfs always before taking a decision of recovery as we have multiple recovery methods.

btw, there is a chance that sysfs creation will fail. maybe in such case we should unconditionally call log_survivability_info() to collect all info at least in the dmesg?

Quoted 1 line

We cannot have generic recovery documentation based on error no here.

it looks that providing valuable resolution based just on the SIGID alone will be even more challenging ;)

Quoted 44 lines

Thanks
Riana

Quoted 39 lines
Quoted 8 lines
Quoted 7 lines
Quoted 7 lines
Quoted 6 lines

         xe_device_set_wedged_method(xe, DRM_WEDGE_RECOVERY_VENDOR);
       xe_device_declare_wedged(xe);
-    dev_err(&pdev->dev, "Firmware flash required, Please refer to the userspace documentation for more details!\n"); +
+    xe_log_info(xe, SURVIVABILITY, "Firmware flash required!\n");

IMO, we need to use xe_log_err (recoverable) here instead of xe_log_info.

Same here.

ditto

Quoted 29 lines
Quoted 14 lines
Quoted 3 lines

Already mentioned in original changes [1], runtime firmware errors cause device unstable:

[1] https://gitlab.freedesktop.org/drm/tip/-/commit/a2ca0633a0fef925a0d8125d8f3e4495a5ecb310

but in recent comment [2] you said that Arch team wanted that to be logged as info rather than fatal

[2] https://patchwork.freedesktop.org/patch/743324/?series=171022&rev=3#comment_1373731

@Riana, @Rodrigo, @Aravind ?

I need a decider here

Quoted 3 lines

As I know xe_survivability_mode_runtime_enable function need to carry errno as parameter to pass into xe_log_err,

however we need to create separate refactor patch for that in future.

Why do we need error no here? It should be 0.

Thanks
Riana

Quoted 9 lines
Quoted 9 lines

With above changes:

Quoted 4 lines

+    xe_info(xe, "Please refer to the userspace documentation for more details how to flash the firmware on %s!\n", +        xe->info.platform_name);
   }
     static void log_survivability_info(struct xe_device *xe)

#78 lore raw

Re: [PATCH v4 23/32] drm/xe/survivability: Report 'Runtime Mode enabled' status using SIGID

In reply to Tauro, Riana
Quoted 65 lines · Riana
Quoted 32 lines · Michal Wajdeczko
Quoted 30 lines · Koujalagi
Quoted 29 lines · Michal Wajdeczko

Report 'Runtime Mode' status using various xe_log() helpers.

Cc Rodrigo Vivi <[email protected]>
Cc Riana Tauro <[email protected]>
Cc Aravind Iddamsetty <[email protected]>
Cc Mallesh Koujalagi <[email protected]>

---
  drivers/gpu/drm/xe/xe_survivability_mode.c | 10 +++++++---

  1 file changed, 7 insertions(+), 3 deletions(-)
drivers/gpu/drm/xe/xe_survivability_mode.c +2 -1
index ebd288986c11..5d3315ac735c 100644
@@ -18,6 +18,7 @@
   #include "xe_mmio.h"
   #include "xe_nvm.h"
   #include "xe_pcode_api.h"
+#include "xe_printk.h"
   #include "xe_vsec.h"
     /**
@@ -405,7 +406,7 @@ void 
 xe_survivability_mode_runtime_enable(struct xe_device *xe)
       struct pci_dev *pdev = to_pci_dev(xe->drm.dev);
         if (!IS_DGFX(xe) || IS_SRIOV_VF(xe) || xe->info.platform < XE_BATTLEMAGE) {
-        dev_err(&pdev->dev, "Runtime Survivability Mode not 
 supported\n");
+        xe_log_err(xe, SURVIVABILITY, -EOPNOTSUPP, "Runtime Mode 
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
drivers/gpu/drm/xe/xe_survivability_mode.c +0 -0
 not supported!\n");
           return;

      }
  @@ -413,11 +414,14 @@ void xe_survivability_mode_runtime_enable(struct xe_device *xe) create_survivability_sysfs(pdev);
        survivability->type = XE_SURVIVABILITY_TYPE_RUNTIME;
-    dev_err(&pdev->dev, "Runtime Survivability mode enabled\n");
+    xe_log_info(xe, SURVIVABILITY, "Runtime Mode enabled!\n");

This should be xe_log_err

Quoted 7 lines
Quoted 7 lines
Quoted 6 lines

xe_device_set_wedged_method(xe, DRM_WEDGE_RECOVERY_VENDOR); xe_device_declare_wedged(xe);
-    dev_err(&pdev->dev, "Firmware flash required, Please refer to the userspace documentation for more details!\n");
+
+    xe_log_info(xe, SURVIVABILITY, "Firmware flash required!\n");

IMO, we need to use xe_log_err (recoverable) here instead of xe_log_info.

Same here.

Quoted 10 lines
Quoted 4 lines

Already mentioned in original changes [1], runtime firmware errors cause device unstable:

[1] https://gitlab.freedesktop.org/drm/tip/-/commit/a2ca0633a0fef925a0d8125d8f3e4495a5ecb310

but in recent comment [2] you said that Arch team wanted that to be logged as info rather than fatal

[2] https://patchwork.freedesktop.org/patch/743324/?series=171022&rev=3#comment_1373731

@Riana, @Rodrigo, @Aravind ?

Quoted 8 lines
Quoted 6 lines

I need a decider here

Quoted 4 lines

As I know xe_survivability_mode_runtime_enable function need to carry errno as parameter to pass into xe_log_err,

however we need to create separate refactor patch for that in future.

Why do we need error no here? It should be 0.

To pass correct errno to SIGID helper function.

btw, for that we need refactor code, which we can handle in future.

@Michal

Please post complete code to check.

Thanks,

-/Mallesh

Quoted 16 lines

Thanks
Riana

Quoted 11 lines
Quoted 11 lines

With above changes:

Quoted 5 lines

+    xe_info(xe, "Please refer to the userspace documentation for more details how to flash the firmware on %s!\n",
+        xe->info.platform_name);
  }
    static void log_survivability_info(struct xe_device *xe)

#79 lore raw

Re: [PATCH v4 23/32] drm/xe/survivability: Report 'Runtime Mode enabled' status using SIGID

Quoted 72 lines · Koujalagi
Quoted 61 lines · Riana
Quoted 29 lines · Michal Wajdeczko
Quoted 27 lines · Koujalagi
Quoted 26 lines · Michal Wajdeczko

Report 'Runtime Mode' status using various xe_log() helpers.

Cc Rodrigo Vivi <[email protected]>
Cc Riana Tauro <[email protected]>
Cc Aravind Iddamsetty <[email protected]>
Cc Mallesh Koujalagi <[email protected]>

---
  drivers/gpu/drm/xe/xe_survivability_mode.c | 10 +++++++---

  1 file changed, 7 insertions(+), 3 deletions(-)
drivers/gpu/drm/xe/xe_survivability_mode.c +1 -1
index ebd288986c11..5d3315ac735c 100644
@@ -18,6 +18,7 @@
   #include "xe_mmio.h"
   #include "xe_nvm.h"
   #include "xe_pcode_api.h"
+#include "xe_printk.h"
   #include "xe_vsec.h"
     /**
@@ -405,7 +406,7 @@ void xe_survivability_mode_runtime_enable(struct xe_device *xe)
       struct pci_dev *pdev = to_pci_dev(xe->drm.dev);
         if (!IS_DGFX(xe) || IS_SRIOV_VF(xe) || xe->info.platform < XE_BATTLEMAGE) {
-        dev_err(&pdev->dev, "Runtime Survivability Mode not supported\n");
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
drivers/gpu/drm/xe/xe_survivability_mode.c +1 -0
+        xe_log_err(xe, SURVIVABILITY, -EOPNOTSUPP, "Runtime Mode not supported!\n");
           return;
       }
   @@ -413,11 +414,14 @@ void xe_survivability_mode_runtime_enable(struct xe_device *xe)
       create_survivability_sysfs(pdev);

        survivability->type = XE_SURVIVABILITY_TYPE_RUNTIME; -    dev_err(&pdev->dev, "Runtime Survivability mode enabled\n"); +    xe_log_info(xe, SURVIVABILITY, "Runtime Mode enabled!\n");

This should be xe_log_err

Quoted 6 lines
Quoted 6 lines
Quoted 5 lines

xe_device_set_wedged_method(xe, DRM_WEDGE_RECOVERY_VENDOR);
      xe_device_declare_wedged(xe);
-    dev_err(&pdev->dev, "Firmware flash required, Please refer to the userspace documentation for more details!\n"); +
+    xe_log_info(xe, SURVIVABILITY, "Firmware flash required!\n");

IMO, we need to use xe_log_err (recoverable) here instead of xe_log_info.

Same here.

Quoted 10 lines
Quoted 4 lines

Already mentioned in original changes [1], runtime firmware errors cause device unstable:

[1] https://gitlab.freedesktop.org/drm/tip/-/commit/a2ca0633a0fef925a0d8125d8f3e4495a5ecb310

but in recent comment [2] you said that Arch team wanted that to be logged as info rather than fatal

[2] https://patchwork.freedesktop.org/patch/743324/?series=171022&rev=3#comment_1373731

@Riana, @Rodrigo, @Aravind ?

Quoted 8 lines
Quoted 6 lines

I need a decider here

Quoted 4 lines

As I know xe_survivability_mode_runtime_enable function need to carry errno as parameter to pass into xe_log_err,

however we need to create separate refactor patch for that in future.

Why do we need error no here? It should be 0.

Quoted 8 lines

To pass correct errno to SIGID helper function.

btw, for that we need refactor code, which we can handle in future.

@Michal

Please post complete code to check.

but errno-only SIGID helpers already support 0 as err in such case, there will be just no "(%pe)" emitted similar to what we have in case of info level helper

what refactor/complete code do you want here?

Quoted 22 lines

Thanks,

-/Mallesh

Quoted 15 lines

Thanks
Riana

Quoted 10 lines
Quoted 10 lines

With above changes:

Quoted 4 lines

+    xe_info(xe, "Please refer to the userspace documentation for more details how to flash the firmware on %s!\n", +        xe->info.platform_name);
  }
    static void log_survivability_info(struct xe_device *xe)

#80 lore raw

PATCH v4 24/32 drm/xe: Report 'device wedged' errors using SIGID

In reply to Michal Wajdeczko

Report 'device wedged' error using xe_log_err_fatal() helper. Use -EIO as the error cause, as nothing else is provided here. The hints about the recovery method and bug filing are now separated as it only needs to be printed once.

Cc Rodrigo Vivi <[email protected]>
Cc Aravind Iddamsetty <[email protected]>
Cc Mallesh Koujalagi <[email protected]>
---
 drivers/gpu/drm/xe/xe_device.c | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)
drivers/gpu/drm/xe/xe_device.c +10 -6
index 71111ad32465..74d566693dfd 100644
@@ -48,6 +48,7 @@
 #include "xe_i2c.h"
 #include "xe_irq.h"
 #include "xe_late_bind_fw.h"
+#include "xe_log.h"
 #include "xe_mmio.h"
 #include "xe_module.h"
 #include "xe_nvm.h"
@@ -1442,6 +1443,9 @@ void xe_device_set_wedged_method(struct xe_device *xe, unsigned long method)
 	xe->wedged.method = method;
 }
 
+#define WEDGED_URL	"https://docs.kernel.org/gpu/drm-uapi.html#device-wedging"
+#define XE_BUG_URL	"https://gitlab.freedesktop.org/drm/xe/kernel/issues/new"
+
 /**
  * xe_device_declare_wedged - Declare device wedged
  * @xe: xe device instance
@@ -1473,12 +1477,12 @@ void xe_device_declare_wedged(struct xe_device *xe)
 	if (!atomic_xchg(&xe->wedged.flag, 1)) {
 		xe->needs_flr_on_fini = true;
 		xe_pm_runtime_get_noresume(xe);
-		drm_err(&xe->drm,
-			"CRITICAL: Xe has declared device %s as wedged.\n"
-			"IOCTLs and executions are blocked.\n"
-			"For recovery procedure, refer to https://docs.kernel.org/gpu/drm-uapi.html#device-wedging\n"
-			"Please file a _new_ bug report at https://gitlab.freedesktop.org/drm/xe/kernel/issues/new\n",
-			dev_name(xe->drm.dev));
+
+		xe_log_err_fatal(xe, WEDGED, -EIO, "Device declared wedged!\n");
+		xe_err_once(xe, "IOCTLs and executions are now blocked!\n"
+			    "For recovery procedure, refer to %s\n"
+			    "Please file a _new_ bug report at %s\n",
+			    WEDGED_URL, XE_BUG_URL);
 	}
 
 	for_each_gt(gt, xe, id)
Signature · 1 line
2.47.1
maintainer Reviewed-by on v4 24/32
#81 lore raw

Re: [PATCH v4 24/32] drm/xe: Report 'device wedged' errors using SIGID

Quoted 26 lines · Michal Wajdeczko

Report 'device wedged' error using xe_log_err_fatal() helper. Use -EIO as the error cause, as nothing else is provided here. The hints about the recovery method and bug filing are now separated as it only needs to be printed once.

Cc Rodrigo Vivi <[email protected]>
Cc Aravind Iddamsetty <[email protected]>
Cc Mallesh Koujalagi <[email protected]>
---
 drivers/gpu/drm/xe/xe_device.c | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)
drivers/gpu/drm/xe/xe_device.c +1 -0
index 71111ad32465..74d566693dfd 100644
@@ -48,6 +48,7 @@
 #include "xe_i2c.h"
 #include "xe_irq.h"
 #include "xe_late_bind_fw.h"
+#include "xe_log.h"
 #include "xe_mmio.h"
 #include "xe_module.h"
 #include "xe_nvm.h"

drivers/gpu/drm/xe/xe_device.c void xe_device_set_wedged_method(struct xe_device *xe, unsigned long method) · line 1447

Quoted 5 lines
drivers/gpu/drm/xe/xe_device.c +2 -0
@@ -1442,6 +1443,9 @@ void xe_device_set_wedged_method(struct xe_device *xe, unsigned long method)
 	xe->wedged.method = method;
 }
 
+#define WEDGED_URL	"https://docs.kernel.org/gpu/drm-uapi.html#device-wedging"
+#define XE_BUG_URL	"https://gitlab.freedesktop.org/drm/xe/kernel/issues/new"

From the old comments:

yes, let's keep these defines as is and where they are. No need for changes.

Quoted 10 lines
drivers/gpu/drm/xe/xe_device.c +1 -2
+
 /**
  * xe_device_declare_wedged - Declare device wedged
  * @xe: xe device instance
@@ -1473,12 +1477,12 @@ void xe_device_declare_wedged(struct xe_device *xe)
 	if (!atomic_xchg(&xe->wedged.flag, 1)) {
 		xe->needs_flr_on_fini = true;
 		xe_pm_runtime_get_noresume(xe);
-		drm_err(&xe->drm,
-			"CRITICAL: Xe has declared device %s as wedged.\n"

drivers/gpu/drm/xe/xe_device.c void xe_device_declare_wedged(struct xe_device *xe) · line 1485

Quoted 10 lines
drivers/gpu/drm/xe/xe_device.c +6 -4
-			"IOCTLs and executions are blocked.\n"
-			"For recovery procedure, refer to https://docs.kernel.org/gpu/drm-uapi.html#device-wedging\n"
-			"Please file a _new_ bug report at https://gitlab.freedesktop.org/drm/xe/kernel/issues/new\n",
-			dev_name(xe->drm.dev));
+
+		xe_log_err_fatal(xe, WEDGED, -EIO, "Device declared wedged!\n");
+		xe_err_once(xe, "IOCTLs and executions are now blocked!\n"
+			    "For recovery procedure, refer to %s\n"
+			    "Please file a _new_ bug report at %s\n",
+			    WEDGED_URL, XE_BUG_URL);

I like the idea of refactor the wedge functions to give a proper errno, but definitely for a separate future thought.

Quoted 6 lines
drivers/gpu/drm/xe/xe_device.c +0 -0
 	}
 
 	for_each_gt(gt, xe, id)
Signature · 1 line
2.47.1
Reviewed-by on v4 24/32
#82 lore raw

Re: [PATCH v4 24/32] drm/xe: Report 'device wedged' errors using SIGID

In reply to Michal Wajdeczko
Quoted 6 lines · Michal Wajdeczko

Report 'device wedged' error using xe_log_err_fatal() helper. Use -EIO as the error cause, as nothing else is provided here. The hints about the recovery method and bug filing are now separated as it only needs to be printed once.

LGTM,

Quoted 48 lines
Cc Rodrigo Vivi <[email protected]>
Cc Aravind Iddamsetty <[email protected]>
Cc Mallesh Koujalagi <[email protected]>
---
  drivers/gpu/drm/xe/xe_device.c | 16 ++++++++++------
  1 file changed, 10 insertions(+), 6 deletions(-)
drivers/gpu/drm/xe/xe_device.c +10 -6
index 71111ad32465..74d566693dfd 100644
@@ -48,6 +48,7 @@
  #include "xe_i2c.h"
  #include "xe_irq.h"
  #include "xe_late_bind_fw.h"
+#include "xe_log.h"
  #include "xe_mmio.h"
  #include "xe_module.h"
  #include "xe_nvm.h"
@@ -1442,6 +1443,9 @@ void xe_device_set_wedged_method(struct xe_device *xe, unsigned long method)
  	xe->wedged.method = method;
  }
 
+#define WEDGED_URL	"https://docs.kernel.org/gpu/drm-uapi.html#device-wedging"
+#define XE_BUG_URL	"https://gitlab.freedesktop.org/drm/xe/kernel/issues/new"
+
  /**
   * xe_device_declare_wedged - Declare device wedged
   * @xe: xe device instance
@@ -1473,12 +1477,12 @@ void xe_device_declare_wedged(struct xe_device *xe)
  	if (!atomic_xchg(&xe->wedged.flag, 1)) {
  		xe->needs_flr_on_fini = true;
  		xe_pm_runtime_get_noresume(xe);
-		drm_err(&xe->drm,
-			"CRITICAL: Xe has declared device %s as wedged.\n"
-			"IOCTLs and executions are blocked.\n"
-			"For recovery procedure, refer to https://docs.kernel.org/gpu/drm-uapi.html#device-wedging\n"
-			"Please file a _new_ bug report at https://gitlab.freedesktop.org/drm/xe/kernel/issues/new\n",
-			dev_name(xe->drm.dev));
+
+		xe_log_err_fatal(xe, WEDGED, -EIO, "Device declared wedged!\n");
+		xe_err_once(xe, "IOCTLs and executions are now blocked!\n"
+			    "For recovery procedure, refer to %s\n"
+			    "Please file a _new_ bug report at %s\n",
+			    WEDGED_URL, XE_BUG_URL);
  	}
 
  	for_each_gt(gt, xe, id)
#83 lore raw

PATCH v4 25/32 drm/xe/pcode: Report 'Mailbox failed' error using SIGID

In reply to Michal Wajdeczko

Report 'Mailbox failed' error using xe_log_err() helper.

Cc Rodrigo Vivi <[email protected]>
Cc Riana Tauro <[email protected]>
Cc Aravind Iddamsetty <[email protected]>
Cc Mallesh Koujalagi <[email protected]>

---
v2: say xe_log_err() in commit msg (Mallesh)

---
 drivers/gpu/drm/xe/xe_pcode.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/gpu/drm/xe/xe_pcode.c +2 -3
index ccc3bdeed6bb..014632e11338 100644
@@ -14,6 +14,7 @@
 #include "regs/xe_pmt.h"
 #include "xe_assert.h"
 #include "xe_device.h"
+#include "xe_log.h"
 #include "xe_mmio.h"
 #include "xe_pcode_api.h"
 #include "xe_pm.h"
@@ -61,9 +62,7 @@ static int pcode_mailbox_status(struct xe_tile *tile)
 	}
 
 	if (err) {
-		drm_err(&tile_to_xe(tile)->drm, "PCODE Mailbox failed: %d %s",
-			err_decode, err_str);
-
+		xe_log_err(tile, PCODE, err_decode, "Mailbox failed: %s\n", err_str);
 		return err_decode;
 	}
 
Signature · 1 line
2.47.1
#84 lore raw

RE: [PATCH v4 25/32] drm/xe/pcode: Report 'Mailbox failed' error using SIGID

Quoted 41 lines

-----Original Message-----
From: Intel-xe <[email protected]> On Behalf Of Michal Wajdeczko
Sent: Thursday, August 13, 2026 12:45 AM
To: [email protected]
Cc: Wajdeczko, Michal <[email protected]>; Vivi, Rodrigo <[email protected]>; Tauro, Riana <[email protected]>; Iddamsetty, Aravind <[email protected]>; Koujalagi, Mallesh <[email protected]>
Subject: [PATCH v4 25/32] drm/xe/pcode: Report 'Mailbox failed' error using SIGID

Report 'Mailbox failed' error using xe_log_err() helper.

Cc Rodrigo Vivi <[email protected]>
Cc Riana Tauro <[email protected]>
Cc Aravind Iddamsetty <[email protected]>
Cc Mallesh Koujalagi <[email protected]>

---
v2: say xe_log_err() in commit msg (Mallesh)

---
 drivers/gpu/drm/xe/xe_pcode.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/gpu/drm/xe/xe_pcode.c +1 -0
index ccc3bdeed6bb..014632e11338 100644
@@ -14,6 +14,7 @@
 #include "regs/xe_pmt.h"
 #include "xe_assert.h"
 #include "xe_device.h"
+#include "xe_log.h"
 #include "xe_mmio.h"
 #include "xe_pcode_api.h"
 #include "xe_pm.h"

drivers/gpu/drm/xe/xe_pcode.c static int pcode_mailbox_status(struct xe_tile *tile) · line 67

Quoted 9 lines
drivers/gpu/drm/xe/xe_pcode.c +1 -3
@@ -61,9 +62,7 @@ static int pcode_mailbox_status(struct xe_tile *tile)
 	}
 
 	if (err) {
-		drm_err(&tile_to_xe(tile)->drm, "PCODE Mailbox failed: %d %s",
-			err_decode, err_str);
-
+		xe_log_err(tile, PCODE, err_decode, "Mailbox failed: %s\n",
 err_str);
 		return err_decode;

Hey,
Could you please merge patch number #25, #26 and #27 into single patch ? Or is there any thought to kept as separate. ?

Regards,
Dnyaneshwar

Quoted 4 lines
drivers/gpu/drm/xe/xe_pcode.c +0 -1
 	}
 
--

2.47.1

#85 lore raw

Re: [PATCH v4 25/32] drm/xe/pcode: Report 'Mailbox failed' error using SIGID

Quoted 43 lines · Dnyaneshwar
Quoted 43 lines

-----Original Message-----
From: Intel-xe <[email protected]> On Behalf Of Michal Wajdeczko
Sent: Thursday, August 13, 2026 12:45 AM
To: [email protected]
Cc: Wajdeczko, Michal <[email protected]>; Vivi, Rodrigo <[email protected]>; Tauro, Riana <[email protected]>; Iddamsetty, Aravind <[email protected]>; Koujalagi, Mallesh <[email protected]>
Subject: [PATCH v4 25/32] drm/xe/pcode: Report 'Mailbox failed' error using SIGID

Report 'Mailbox failed' error using xe_log_err() helper.

Cc Rodrigo Vivi <[email protected]>
Cc Riana Tauro <[email protected]>
Cc Aravind Iddamsetty <[email protected]>
Cc Mallesh Koujalagi <[email protected]>

---
v2: say xe_log_err() in commit msg (Mallesh)

---
 drivers/gpu/drm/xe/xe_pcode.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/gpu/drm/xe/xe_pcode.c +1 -0
index ccc3bdeed6bb..014632e11338 100644
@@ -14,6 +14,7 @@
 #include "regs/xe_pmt.h"
 #include "xe_assert.h"
 #include "xe_device.h"
+#include "xe_log.h"
 #include "xe_mmio.h"
 #include "xe_pcode_api.h"
 #include "xe_pm.h"
@@ -61,9 +62,7 @@ static int pcode_mailbox_status(struct xe_tile *tile)
 	}
 
Quoted 10 lines

drivers/gpu/drm/xe/xe_pcode.c static int pcode_mailbox_status(struct xe_tile *tile) · line 66

Quoted 7 lines
drivers/gpu/drm/xe/xe_pcode.c +1 -3
 	if (err) {
-		drm_err(&tile_to_xe(tile)->drm, "PCODE Mailbox failed: %d %s",
-			err_decode, err_str);
-
+		xe_log_err(tile, PCODE, err_decode, "Mailbox failed: %s\n",
 err_str);
 		return err_decode;

Hey,
Could you please merge patch number #25, #26 and #27 into single patch ? Or is there any thought to kept as separate. ?

the idea was to have proper discussion on each new SIGID usage then we can merge each acked/r-b'ed patch separately if needed

and as the side-effect we indicate that we don't aim to have single giant patch per each SIGID and after that topic is closed

as you know, earlier attempt like [1] to do everything in single patch was far from ready to merge and it would be hard to finish that in a finite time

[1] https://patchwork.freedesktop.org/patch/744652/?series=171725&rev=1

Quoted 8 lines

Regards,
Dnyaneshwar

Quoted 4 lines
drivers/gpu/drm/xe/xe_pcode.c +0 -1
 	}
 
--

2.47.1

#86 lore raw

PATCH v4 26/32 drm/xe/pcode: Report 'timeout, retrying' error using SIGID

In reply to Michal Wajdeczko

Report 'timeout, retrying with preemption disabled' error using xe_log_err() helper.

Cc Rodrigo Vivi <[email protected]>
Cc Riana Tauro <[email protected]>
Cc Aravind Iddamsetty <[email protected]>
Cc Mallesh Koujalagi <[email protected]>
---
 drivers/gpu/drm/xe/xe_pcode.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/gpu/drm/xe/xe_pcode.c +1 -2
index 014632e11338..14b13a11d1d6 100644
@@ -218,8 +218,7 @@ int xe_pcode_request(struct xe_tile *tile, u32 mbox, u32 request,
 	 * requests, and for any quirks of the PCODE firmware that delays
 	 * the request completion.
 	 */
-	drm_err(&tile_to_xe(tile)->drm,
-		"PCODE timeout, retrying with preemption disabled\n");
+	xe_log_err(tile, PCODE, ret, "timeout, retrying with preemption disabled\n");
 	preempt_disable();
 	ret = pcode_try_request(tile, mbox, request, reply_mask, reply, &status,
 				true, 50 * 1000, true);
Signature · 1 line
2.47.1
#87 lore raw

Re: [PATCH v4 26/32] drm/xe/pcode: Report 'timeout, retrying' error using SIGID

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Pre-existing issues:
- [High] Uncapped exponential backoff causes udelay() to exceed architecture limits, risking integer overflow and undefined delay times. --

--- Patch [26]: [PATCH v4 26/32] drm/xe/pcode: Report 'timeout, retrying' error using SIGID --- commit 75f6f9c4d8c1d251fab2b4d894d2352070119c43
Author: Michal Wajdeczko <[email protected]>

drm/xe/pcode: Report 'timeout, retrying' error using SIGID

This commit replaces a drm_err message with the xe_log_err helper to report PCODE timeout retries using the SIGID tagging infrastructure.

Quoted 4 lines
drivers/gpu/drm/xe/xe_pcode.c +0 -0
index 014632e113388..14b13a11d1d6d 100644

[ ... ]

drivers/gpu/drm/xe/xe_pcode.c int xe_pcode_request(struct xe_tile *tile, u32 mbox, u32 request, · line 224

Quoted 10 lines
drivers/gpu/drm/xe/xe_pcode.c +1 -2
@@ -218,8 +218,7 @@ int xe_pcode_request(struct xe_tile *tile, u32 mbox, u32 request,
 	 * requests, and for any quirks of the PCODE firmware that delays
 	 * the request completion.
 	 */
-	drm_err(&tile_to_xe(tile)->drm,
-		"PCODE timeout, retrying with preemption disabled\n");
+	xe_log_err(tile, PCODE, ret, "timeout, retrying with preemption disabled\n");
 	preempt_disable();
 	ret = pcode_try_request(tile, mbox, request, reply_mask, reply, &status,
 				true, 50 * 1000, true);

[Severity: High]
This is a pre-existing issue, but does this 50ms atomic timeout risk integer overflow in udelay?

Looking at pcode_try_request, which is called here with atomic set to true:

static int pcode_try_request(..., bool atomic, int timeout_us, ...)

{
        int slept, wait = 10;
        ...
        for (slept = 0; slept < timeout_us; slept += wait) {
                ...
                if (atomic)
                        udelay(wait);
                else
                        usleep_range(wait, wait << 1);
                wait <<= 1;
        }
        ...
}

The wait variable grows exponentially without a cap. For a 50,000us timeout loop, wait will repeatedly double and can reach well over 20,000us before the timeout expires. This significantly exceeds typical architecture limits for udelay, which are often around 1 to 2 milliseconds.

Can this uncapped exponential growth cause internal timer math to overflow and trigger the hard lockup detector when firmware becomes unresponsive?

Quoted 1 line

preempt_enable();

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=26
#88 lore raw

Re: [PATCH v4 26/32] drm/xe/pcode: Report 'timeout, retrying' error using SIGID

In reply to Michal Wajdeczko
Quoted 17 lines · Michal Wajdeczko

Report 'timeout, retrying with preemption disabled' error using xe_log_err() helper.

Cc Rodrigo Vivi <[email protected]>
Cc Riana Tauro <[email protected]>
Cc Aravind Iddamsetty <[email protected]>
Cc Mallesh Koujalagi <[email protected]>

---
drivers/gpu/drm/xe/xe_pcode.c | 3 +--

1 file changed, 1 insertion(+), 2 deletions(-)
drivers/gpu/drm/xe/xe_pcode.c +0 -0
index 014632e11338..14b13a11d1d6 100644

drivers/gpu/drm/xe/xe_pcode.c int xe_pcode_request(struct xe_tile *tile, u32 mbox, u32 request, · line 224

Quoted 9 lines
drivers/gpu/drm/xe/xe_pcode.c +1 -2
@@ -218,8 +218,7 @@ int xe_pcode_request(struct xe_tile *tile, u32 mbox, u32 request,
 	 * requests, and for any quirks of the PCODE firmware that delays
 	 * the request completion.
 	 */
-	drm_err(&tile_to_xe(tile)->drm,
-		"PCODE timeout, retrying with preemption disabled\n");
+	xe_log_err(tile, PCODE, ret, "timeout, retrying with preemption disabled\n");
 	preempt_disable();
 	ret = pcode_try_request(tile, mbox, request, reply_mask, reply, &status,
 				true, 50 * 1000, true);

+ Badal

Should we report the drm_err before retrying?

Should we add a new log to report a failure after retry?

Thanks,
Umesh

Quoted 2 lines

-- 2.47.1

maintainer Reviewed-by
#89 lore raw

Re: [PATCH v4 26/32] drm/xe/pcode: Report 'timeout, retrying' error using SIGID

Quoted 30 lines · Umesh Nerlige Ramappa
Quoted 17 lines · Michal Wajdeczko

Report 'timeout, retrying with preemption disabled' error using xe_log_err() helper.

Cc Rodrigo Vivi <[email protected]>
Cc Riana Tauro <[email protected]>
Cc Aravind Iddamsetty <[email protected]>
Cc Mallesh Koujalagi <[email protected]>

---
drivers/gpu/drm/xe/xe_pcode.c | 3 +--

1 file changed, 1 insertion(+), 2 deletions(-)
drivers/gpu/drm/xe/xe_pcode.c +0 -0
index 014632e11338..14b13a11d1d6 100644

drivers/gpu/drm/xe/xe_pcode.c int xe_pcode_request(struct xe_tile *tile, u32 mbox, u32 request, · line 224

Quoted 9 lines
drivers/gpu/drm/xe/xe_pcode.c +1 -2
@@ -218,8 +218,7 @@ int xe_pcode_request(struct xe_tile *tile, u32 mbox, u32 request,
 	 * requests, and for any quirks of the PCODE firmware that delays
 	 * the request completion.
 	 */
-	drm_err(&tile_to_xe(tile)->drm,
-		"PCODE timeout, retrying with preemption disabled\n");
+	xe_log_err(tile, PCODE, ret, "timeout, retrying with preemption disabled\n");
 	preempt_disable();
 	ret = pcode_try_request(tile, mbox, request, reply_mask, reply, &status,
 				true, 50 * 1000, true);

+ Badal

Quoted 1 line

Should we report the drm_err before retrying?

agreed. This should be an info at this point...

Quoted 2 lines

Should we add a new log to report a failure after retry?

right, and an error after that if not already there...

But this can be done as a follow-up. Don't block the conversion imho

Quoted 6 lines

Thanks,
Umesh

Quoted 2 lines

-- 2.47.1

#90 lore raw

PATCH v4 27/32 drm/xe/pcode: Report 'initialization timedout' error using SIGID

In reply to Michal Wajdeczko

Report 'initialization timedout' error using xe_log_err() helper.

Cc Rodrigo Vivi <[email protected]>
Cc Riana Tauro <[email protected]>
Cc Aravind Iddamsetty <[email protected]>
Cc Mallesh Koujalagi <[email protected]>
Cc Umesh Nerlige Ramappa <[email protected]>
---
 drivers/gpu/drm/xe/xe_pcode.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/gpu/drm/xe/xe_pcode.c +3 -3
index 14b13a11d1d6..e1b8062541a9 100644
@@ -297,7 +297,7 @@ int xe_pcode_ready(struct xe_device *xe, bool locked)
 {
 	u32 status, request = DGFX_GET_INIT_STATUS;
 	struct xe_tile *tile = xe_device_get_root_tile(xe);
-	int timeout_us = 180000000; /* 3 min */
+	long timeout_us = 3 * 60 * USEC_PER_SEC; /* 3 min */
 	int ret;
 
 	if (xe->info.skip_pcode)
@@ -318,8 +318,8 @@ int xe_pcode_ready(struct xe_device *xe, bool locked)
 		mutex_unlock(&tile->pcode.lock);
 
 	if (ret)
-		drm_err(&xe->drm,
-			"PCODE initialization timedout after: 3 min\n");
+		xe_log_err(tile, PCODE, ret, "initialization timedout after %ld seconds\n",
+			   timeout_us / USEC_PER_SEC);
 
 	return ret;
 }
Signature · 1 line
2.47.1
#91 lore raw

Re: [PATCH v4 27/32] drm/xe/pcode: Report 'initialization timedout' error using SIGID

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Pre-existing issues:
- [High] Uncapped exponential backoff causes massive over-sleeping and potential kernel panic. --

--- Patch [27]: [PATCH v4 27/32] drm/xe/pcode: Report 'initialization timedout' error using SIGID --- commit 3feb217014d673b0d9d119f4debacacb0e357e77
Author: Michal Wajdeczko <[email protected]>

drm/xe/pcode: Report 'initialization timedout' error using SIGID

This commit updates the PCODE initialization timeout error to use the xe_log_err() helper instead of drm_err(). It also refactors the 3 minute timeout constant to use USEC_PER_SEC.

Quoted 5 lines
drivers/gpu/drm/xe/xe_pcode.c +0 -0
index 14b13a11d1d6d..e1b8062541a91 100644
@@ -297,7 +297,7 @@ int xe_pcode_ready(struct xe_device *xe, bool locked)

[ ... ]

drivers/gpu/drm/xe/xe_pcode.c

Quoted 7 lines
drivers/gpu/drm/xe/xe_pcode.c +0 -0
 	if (locked)
 		mutex_lock(&tile->pcode.lock);
 
 	ret = pcode_try_request(tile, DGFX_PCODE_STATUS, request,
 				DGFX_INIT_STATUS_COMPLETE,
 				DGFX_INIT_STATUS_COMPLETE,
 				&status, false, timeout_us, locked);

[Severity: High]
This is a pre-existing issue, but can the 3-minute timeout passed here trigger a kernel panic via the Hung Task Detector if PCODE is unresponsive?

Looking at pcode_try_request() in drivers/gpu/drm/xe/xe_pcode.c, the wait duration is exponentially increased without any cap:

	usleep_range(wait, wait << 1);
	wait <<= 1;

When the timeout is 180,000,000 us (3 minutes), the polling loop doubles the wait variable every iteration. When the total slept time reaches ~167 seconds, the wait variable becomes ~83.8 seconds. The loop then executes:

	usleep_range(83886080, 167772160);

Since usleep_range() sleeps in TASK_UNINTERRUPTIBLE, sleeping for up to 167.7 seconds exceeds the default 120-second hung task watchdog timeout, causing a panic. Furthermore, if atomic=true was used with a large timeout, it would result in a massive udelay(), violating architectural limits with preemption disabled.

Could a cap be added to the maximum wait time in pcode_try_request() to prevent massive over-sleeping?

Quoted 12 lines
drivers/gpu/drm/xe/xe_pcode.c +2 -2
 	if (locked)
 		mutex_unlock(&tile->pcode.lock);
 
 	if (ret)
-		drm_err(&xe->drm,
-			"PCODE initialization timedout after: 3 min\n");
+		xe_log_err(tile, PCODE, ret, "initialization timedout after %ld seconds\n",
+			   timeout_us / USEC_PER_SEC);
 
 	return ret;
 }
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=27
maintainer Reviewed-by on v4 27/32
#92 lore raw

Re: [PATCH v4 27/32] drm/xe/pcode: Report 'initialization timedout' error using SIGID

In reply to Michal Wajdeczko
Quoted 8 lines · Michal Wajdeczko

Report 'initialization timedout' error using xe_log_err() helper.

Cc Rodrigo Vivi <[email protected]>
Cc Riana Tauro <[email protected]>
Cc Aravind Iddamsetty <[email protected]>
Cc Mallesh Koujalagi <[email protected]>
Cc Umesh Nerlige Ramappa <[email protected]>
Quoted 31 lines
---
 drivers/gpu/drm/xe/xe_pcode.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/gpu/drm/xe/xe_pcode.c +3 -3
index 14b13a11d1d6..e1b8062541a9 100644
@@ -297,7 +297,7 @@ int xe_pcode_ready(struct xe_device *xe, bool locked)
 {
 	u32 status, request = DGFX_GET_INIT_STATUS;
 	struct xe_tile *tile = xe_device_get_root_tile(xe);
-	int timeout_us = 180000000; /* 3 min */
+	long timeout_us = 3 * 60 * USEC_PER_SEC; /* 3 min */
 	int ret;
 
 	if (xe->info.skip_pcode)
@@ -318,8 +318,8 @@ int xe_pcode_ready(struct xe_device *xe, bool locked)
 		mutex_unlock(&tile->pcode.lock);
 
 	if (ret)
-		drm_err(&xe->drm,
-			"PCODE initialization timedout after: 3 min\n");
+		xe_log_err(tile, PCODE, ret, "initialization timedout after %ld seconds\n",
+			   timeout_us / USEC_PER_SEC);
 
 	return ret;
 }
Signature · 1 line
2.47.1
#93 lore raw

PATCH v4 28/32 drm/xe/guc: Report 'GuC mmio' errors using SIGID

In reply to Michal Wajdeczko

Report various 'GuC mmio' errors using xe_log() helpers.

Cc Rodrigo Vivi <[email protected]>
Cc Daniele Ceraolo Spurio <[email protected]>
Cc Aravind Iddamsetty <[email protected]>
Cc Mallesh Koujalagi <[email protected]>
---
 drivers/gpu/drm/xe/xe_guc.c | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)
drivers/gpu/drm/xe/xe_guc.c +10 -8
index 4286bd05c686..c7f8bbd4cb92 100644
@@ -39,6 +39,7 @@
 #include "xe_guc_rc.h"
 #include "xe_guc_relay.h"
 #include "xe_guc_submit.h"
+#include "xe_log.h"
 #include "xe_memirq.h"
 #include "xe_mmio.h"
 #include "xe_platform_types.h"
@@ -1542,8 +1543,9 @@ int xe_guc_mmio_send_recv(struct xe_guc *guc, const u32 *request,
 		/* scratch registers might be cleared during FLR, try once more */
 		if (!header) {
 			if (++lost > MAX_RETRIES_ON_FLR) {
-				xe_gt_err(gt, "GuC mmio request %#x: lost, too many retries %u\n",
-					  request[0], lost);
+				xe_log_err(gt, GUC, -ENOLINK,
+					   "MMIO request %#x: lost, too many retries %u\n",
+					   request[0], lost);
 				return -ENOLINK;
 			}
 			xe_gt_dbg(gt, "GuC mmio request %#x: lost, trying again\n", request[0]);
@@ -1551,8 +1553,8 @@ int xe_guc_mmio_send_recv(struct xe_guc *guc, const u32 *request,
 			goto retry;
 		}
 timeout:
-		xe_gt_err(gt, "GuC mmio request %#x: no reply %#x\n",
-			  request[0], header);
+		xe_log_err(gt, GUC, ret, "MMIO request %#x: no reply %#x\n",
+			   request[0], header);
 		return ret;
 	}
 
@@ -1607,16 +1609,16 @@ int xe_guc_mmio_send_recv(struct xe_guc *guc, const u32 *request,
 			return -EREMCHG;
 		}
 
-		xe_gt_err(gt, "GuC mmio request %#x: failure %#x hint %#x\n",
-			  request[0], error, hint);
+		xe_log_err(gt, GUC, -ENXIO, "MMIO request %#x: failure %#x hint %#x\n",
+			   request[0], error, hint);
 		return -ENXIO;
 	}
 
 	if (FIELD_GET(GUC_HXG_MSG_0_TYPE, header) !=
 	    GUC_HXG_TYPE_RESPONSE_SUCCESS) {
 proto:
-		xe_gt_err(gt, "GuC mmio request %#x: unexpected reply %#x\n",
-			  request[0], header);
+		xe_log_err(gt, GUC, -EPROTO, "MMIO request %#x: unexpected reply %#x\n",
+			   request[0], header);
 		return -EPROTO;
 	}
 
Signature · 1 line
2.47.1
#94 lore raw

PATCH v4 29/32 drm/xe/gt: Report 'reset failed' errors using SIGID

In reply to Michal Wajdeczko

Report 'reset' related err/info messages using xe_log() helpers.

Cc Rodrigo Vivi <[email protected]>
Cc Matthew Brost <[email protected]>
Cc Daniele Ceraolo Spurio <[email protected]>
Cc Aravind Iddamsetty <[email protected]>
Cc Mallesh Koujalagi <[email protected]>
---
 drivers/gpu/drm/xe/xe_gt.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/gpu/drm/xe/xe_gt.c +4 -3
index dfdacc0f6de9..6805e0d3bf21 100644
@@ -48,6 +48,7 @@
 #include "xe_hw_engine_class_sysfs.h"
 #include "xe_irq.h"
 #include "xe_lmtt.h"
+#include "xe_log.h"
 #include "xe_lrc.h"
 #include "xe_map.h"
 #include "xe_migrate.h"
@@ -925,7 +926,7 @@ static void gt_reset_worker(struct work_struct *w)
 	if (!xe_device_uc_enabled(gt_to_xe(gt)))
 		goto err_pm_put;
 
-	xe_gt_info(gt, "reset started\n");
+	xe_log_info(gt, GT, "reset started\n");
 
 	if (xe_fault_gt_reset()) {
 		err = -ECANCELED;
@@ -964,7 +965,7 @@ static void gt_reset_worker(struct work_struct *w)
 	/* Pair with get while enqueueing the work in xe_gt_reset_async() */
 	xe_pm_runtime_put(gt_to_xe(gt));
 
-	xe_gt_info(gt, "reset done\n");
+	xe_log_info(gt, GT, "reset done\n");
 
 	return;
 
@@ -973,7 +974,7 @@ static void gt_reset_worker(struct work_struct *w)
 	XE_WARN_ON(xe_uc_start(&gt->uc));
 
 err_fail:
-	xe_gt_err(gt, "reset failed (%pe)\n", ERR_PTR(err));
+	xe_log_err_fatal(gt, GT, err, "reset failed\n");
 	xe_device_declare_wedged(gt_to_xe(gt));
 err_pm_put:
 	xe_pm_runtime_put(gt_to_xe(gt));
Signature · 1 line
2.47.1
#95 lore raw

PATCH v4 30/32 drm/xe/gt: Report 'Fault response' pagefault error using SIGID

In reply to Michal Wajdeczko

Report 'Unsuccessful response' error using xe_log_err() helper.

Cc Rodrigo Vivi <[email protected]>
Cc Matthew Brost <[email protected]>
Cc Daniele Ceraolo Spurio <[email protected]>
Cc Aravind Iddamsetty <[email protected]>
Cc Mallesh Koujalagi <[email protected]>

---
v2: rebased (Michal) reword message (Mallesh)

---
 drivers/gpu/drm/xe/xe_pagefault.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/xe/xe_pagefault.c +2 -2
index 7e829c61387f..eb600c466187 100644
@@ -14,6 +14,7 @@
 #include "xe_gt_types.h"
 #include "xe_gt_stats.h"
 #include "xe_hw_engine.h"
+#include "xe_log.h"
 #include "xe_pagefault.h"
 #include "xe_pagefault_types.h"
 #include "xe_svm.h"
@@ -625,8 +626,7 @@ static void xe_pagefault_queue_work(struct work_struct *w)
 				xe_pagefault_save_to_vm(gt_to_xe(gt), pf);
 				xe_pagefault_cache_start_invalidate(cache_start);
 				xe_pagefault_print(pf);
-				xe_gt_info(pf->gt, "Fault response: Unsuccessful %pe\n",
-					   ERR_PTR(err));
+				xe_log_err(pf->gt, PAGEFAULT, err, "Unsuccessful response\n");
 			} else {
 				xe_gt_stats_incr(pf->gt, XE_GT_STATS_ID_INVALID_PREFETCH_PAGEFAULT_COUNT, 1);
 				xe_gt_dbg(pf->gt, "Prefetch Fault response: Unsuccessful %pe\n",
Signature · 1 line
2.47.1
maintainer
#96 lore raw

Re: [PATCH v4 30/32] drm/xe/gt: Report 'Fault response' pagefault error using SIGID

Quoted 27 lines · Michal Wajdeczko

Report 'Unsuccessful response' error using xe_log_err() helper.

Cc Rodrigo Vivi <[email protected]>
Cc Matthew Brost <[email protected]>
Cc Daniele Ceraolo Spurio <[email protected]>
Cc Aravind Iddamsetty <[email protected]>
Cc Mallesh Koujalagi <[email protected]>

---
v2: rebased (Michal) reword message (Mallesh)

---
 drivers/gpu/drm/xe/xe_pagefault.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/xe/xe_pagefault.c +1 -0
index 7e829c61387f..eb600c466187 100644
@@ -14,6 +14,7 @@
 #include "xe_gt_types.h"
 #include "xe_gt_stats.h"
 #include "xe_hw_engine.h"
+#include "xe_log.h"
 #include "xe_pagefault.h"
 #include "xe_pagefault_types.h"
 #include "xe_svm.h"

drivers/gpu/drm/xe/xe_pagefault.c static void xe_pagefault_queue_work(struct work_struct *w) · line 629

Quoted 6 lines
drivers/gpu/drm/xe/xe_pagefault.c +1 -2
@@ -625,8 +626,7 @@ static void xe_pagefault_queue_work(struct work_struct *w)
 				xe_pagefault_save_to_vm(gt_to_xe(gt), pf);
 				xe_pagefault_cache_start_invalidate(cache_start);
 				xe_pagefault_print(pf);
-				xe_gt_info(pf->gt, "Fault response: Unsuccessful %pe\n",
-					   ERR_PTR(err));
+				xe_log_err(pf->gt, PAGEFAULT, err, "Unsuccessful response\n");

I'm wondering if we should really go from info to err here...

Why not staying with xe_log_info or now?

But also, why err and not ERR_PTR(err)?

Quoted 6 lines
drivers/gpu/drm/xe/xe_pagefault.c +0 -0
 			} else {
 				xe_gt_stats_incr(pf->gt, XE_GT_STATS_ID_INVALID_PREFETCH_PAGEFAULT_COUNT, 1);
 				xe_gt_dbg(pf->gt, "Prefetch Fault response: Unsuccessful %pe\n",
Signature · 1 line
2.47.1
#97 lore raw

Re: [PATCH v4 30/32] drm/xe/gt: Report 'Fault response' pagefault error using SIGID

Quoted 28 lines · Rodrigo Vivi
Quoted 27 lines · Michal Wajdeczko

Report 'Unsuccessful response' error using xe_log_err() helper.

Cc Rodrigo Vivi <[email protected]>
Cc Matthew Brost <[email protected]>
Cc Daniele Ceraolo Spurio <[email protected]>
Cc Aravind Iddamsetty <[email protected]>
Cc Mallesh Koujalagi <[email protected]>

---
v2: rebased (Michal) reword message (Mallesh)

---
 drivers/gpu/drm/xe/xe_pagefault.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/xe/xe_pagefault.c +1 -0
index 7e829c61387f..eb600c466187 100644
@@ -14,6 +14,7 @@
 #include "xe_gt_types.h"
 #include "xe_gt_stats.h"
 #include "xe_hw_engine.h"
+#include "xe_log.h"
 #include "xe_pagefault.h"
 #include "xe_pagefault_types.h"
 #include "xe_svm.h"
@@ -625,8 +626,7 @@ static void xe_pagefault_queue_work(struct work_struct *w)
Quoted 8 lines

drivers/gpu/drm/xe/xe_pagefault.c static void xe_pagefault_queue_work(struct work_struct *w) · line 629

Quoted 6 lines
drivers/gpu/drm/xe/xe_pagefault.c +1 -2
 				xe_pagefault_save_to_vm(gt_to_xe(gt), pf);
 				xe_pagefault_cache_start_invalidate(cache_start);
 				xe_pagefault_print(pf);
-				xe_gt_info(pf->gt, "Fault response: Unsuccessful %pe\n",
-					   ERR_PTR(err));
+				xe_log_err(pf->gt, PAGEFAULT, err, "Unsuccessful response\n");

I'm wondering if we should really go from info to err here...

my question was different:
"why this err is only reported as info level?"
as once we hit this condition we also print large dump (see xe_pagefault_print) likely for debug/diagnostics so it seems important

@Matthew, comments?

Quoted 2 lines

Why not staying with xe_log_info or now?

I can change that for xe_log_info, but then (by design) we will not print an error

Quoted 2 lines

But also, why err and not ERR_PTR(err)?

patch 10/32 [1] introduced helpers that take just errno value and convert that into data { ERR_PTR(err), 0 } pair

[1] https://patchwork.freedesktop.org/patch/745993/?series=171022&rev=4

Quoted 7 lines
Quoted 7 lines
drivers/gpu/drm/xe/xe_pagefault.c +0 -0
 			} else {
 				xe_gt_stats_incr(pf->gt, XE_GT_STATS_ID_INVALID_PREFETCH_PAGEFAULT_COUNT, 1);
 				xe_gt_dbg(pf->gt, "Prefetch Fault response: Unsuccessful %pe\n",
Signature · 1 line
2.47.1
#98 lore raw

Re: [PATCH v4 30/32] drm/xe/gt: Report 'Fault response' pagefault error using SIGID

Quoted 37 lines · Michal Wajdeczko
Quoted 27 lines · Rodrigo Vivi
Quoted 26 lines · Michal Wajdeczko

Report 'Unsuccessful response' error using xe_log_err() helper.

Cc Rodrigo Vivi <[email protected]>
Cc Matthew Brost <[email protected]>
Cc Daniele Ceraolo Spurio <[email protected]>
Cc Aravind Iddamsetty <[email protected]>
Cc Mallesh Koujalagi <[email protected]>

---
v2: rebased (Michal) reword message (Mallesh)

---
  drivers/gpu/drm/xe/xe_pagefault.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/xe/xe_pagefault.c +1 -0
index 7e829c61387f..eb600c466187 100644
@@ -14,6 +14,7 @@
  #include "xe_gt_types.h"
  #include "xe_gt_stats.h"
  #include "xe_hw_engine.h"
+#include "xe_log.h"
  #include "xe_pagefault.h"
  #include "xe_pagefault_types.h"
  #include "xe_svm.h"
Quoted 8 lines

drivers/gpu/drm/xe/xe_pagefault.c static void xe_pagefault_queue_work(struct work_struct *w) · line 629

Quoted 7 lines
drivers/gpu/drm/xe/xe_pagefault.c +1 -2
@@ -625,8 +626,7 @@ static void xe_pagefault_queue_work(struct work_struct *w)
  				xe_pagefault_save_to_vm(gt_to_xe(gt), pf);
  				xe_pagefault_cache_start_invalidate(cache_start);
  				xe_pagefault_print(pf);
-				xe_gt_info(pf->gt, "Fault response: Unsuccessful %pe\n",
-					   ERR_PTR(err));
+				xe_log_err(pf->gt, PAGEFAULT, err, "Unsuccessful response\n");

I'm wondering if we should really go from info to err here...

Quoted 5 lines

my question was different:
"why this err is only reported as info level?"
as once we hit this condition we also print large dump (see xe_pagefault_print) likely for debug/diagnostics so it seems important

drive-by comment, but AFAIU this error can be intentionally triggered by UMD by simply accessing an invalid PPGTT address (see e.g. xe_exec_fault_mode@invalid-va), and we usually avoid using error-level logs for something that UMD can cause on demand.

Daniele

Quoted 19 lines

@Matthew, comments?

Quoted 1 line

Why not staying with xe_log_info or now?

I can change that for xe_log_info, but then (by design) we will not print an error

Quoted 1 line

But also, why err and not ERR_PTR(err)?

patch 10/32 [1] introduced helpers that take just errno value and convert that into data { ERR_PTR(err), 0 } pair

[1] https://patchwork.freedesktop.org/patch/745993/?series=171022&rev=4

Quoted 6 lines
Quoted 6 lines
drivers/gpu/drm/xe/xe_pagefault.c +0 -0
  			} else {
  				xe_gt_stats_incr(pf->gt, XE_GT_STATS_ID_INVALID_PREFETCH_PAGEFAULT_COUNT, 1);
  				xe_gt_dbg(pf->gt, "Prefetch Fault response: Unsuccessful %pe\n",
Signature · 1 line
2.47.1
#99 lore raw

Re: [PATCH v4 30/32] drm/xe/gt: Report 'Fault response' pagefault error using SIGID

Quoted 40 lines · Daniele Ceraolo Spurio
Quoted 37 lines · Michal Wajdeczko
Quoted 35 lines · Rodrigo Vivi
Quoted 27 lines · Michal Wajdeczko

Report 'Unsuccessful response' error using xe_log_err() helper.

Cc Rodrigo Vivi <[email protected]>
Cc Matthew Brost <[email protected]>
Cc Daniele Ceraolo Spurio <[email protected]>
Cc Aravind Iddamsetty <[email protected]>
Cc Mallesh Koujalagi <[email protected]>

---
v2: rebased (Michal) reword message (Mallesh)
---
  drivers/gpu/drm/xe/xe_pagefault.c | 4 ++--

  1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/xe/xe_pagefault.c +1 -0
index 7e829c61387f..eb600c466187 100644
@@ -14,6 +14,7 @@
   #include "xe_gt_types.h"
   #include "xe_gt_stats.h"
   #include "xe_hw_engine.h"
+#include "xe_log.h"
   #include "xe_pagefault.h"
   #include "xe_pagefault_types.h"
   #include "xe_svm.h"

drivers/gpu/drm/xe/xe_pagefault.c static void xe_pagefault_queue_work(struct work_struct *w) · line 629

Quoted 6 lines
drivers/gpu/drm/xe/xe_pagefault.c +1 -2
@@ -625,8 +626,7 @@ static void xe_pagefault_queue_work(struct work_struct *w)
                   xe_pagefault_save_to_vm(gt_to_xe(gt), pf);
                   xe_pagefault_cache_start_invalidate(cache_start);
                   xe_pagefault_print(pf);
-                xe_gt_info(pf->gt, "Fault response: Unsuccessful %pe\n",
-                       ERR_PTR(err));
+                xe_log_err(pf->gt, PAGEFAULT, err, "Unsuccessful response\n");

I'm wondering if we should really go from info to err here...

Quoted 7 lines
Quoted 5 lines

my question was different:
    "why this err is only reported as info level?" as once we hit this condition we also print large dump (see xe_pagefault_print) likely for debug/diagnostics so it seems important

drive-by comment, but AFAIU this error can be intentionally triggered by UMD by simply accessing an invalid PPGTT address (see e.g. xe_exec_fault_mode@invalid-va), and we usually avoid using error-level logs for something that UMD can cause on demand.

thanks for explanation!

so we have two choices here:

1) drop this patch completely, or
2) switch to SIGID reporting with INFO severity

but currently xe_log_info() does not take an 'err' parameter so we will not print the actual error code as it is today

so we have two more choices:

a) update xe_log_info() macro to accept 'err', or
b) add new xe_log_err_info() macro that takes 'err' but it will still use CPER_SEV_INFO severity

I'm in favor for 2) + b)

Quoted 23 lines

Daniele

Quoted 19 lines

@Matthew, comments?

Quoted 1 line

Why not staying with xe_log_info or now?

I can change that for xe_log_info, but then (by design) we will not print an error

Quoted 1 line

But also, why err and not ERR_PTR(err)?

patch 10/32 [1] introduced helpers that take just errno value and convert that into data { ERR_PTR(err), 0 } pair

[1] https://patchwork.freedesktop.org/patch/745993/?series=171022&rev=4

Quoted 6 lines
Quoted 6 lines
drivers/gpu/drm/xe/xe_pagefault.c +0 -0
               } else {
                   xe_gt_stats_incr(pf->gt, XE_GT_STATS_ID_INVALID_PREFETCH_PAGEFAULT_COUNT, 1);
                   xe_gt_dbg(pf->gt, "Prefetch Fault response: Unsuccessful %pe\n",

--
2.47.1

maintainer
#100 lore raw

Re: [PATCH v4 30/32] drm/xe/gt: Report 'Fault response' pagefault error using SIGID

Quoted 61 lines · Michal Wajdeczko
Quoted 40 lines · Daniele Ceraolo Spurio
Quoted 37 lines · Michal Wajdeczko
Quoted 35 lines · Rodrigo Vivi
Quoted 27 lines · Michal Wajdeczko

Report 'Unsuccessful response' error using xe_log_err() helper.

Cc Rodrigo Vivi <[email protected]>
Cc Matthew Brost <[email protected]>
Cc Daniele Ceraolo Spurio <[email protected]>
Cc Aravind Iddamsetty <[email protected]>
Cc Mallesh Koujalagi <[email protected]>

---
v2: rebased (Michal) reword message (Mallesh)
---
  drivers/gpu/drm/xe/xe_pagefault.c | 4 ++--

  1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/xe/xe_pagefault.c +1 -0
index 7e829c61387f..eb600c466187 100644
@@ -14,6 +14,7 @@
   #include "xe_gt_types.h"
   #include "xe_gt_stats.h"
   #include "xe_hw_engine.h"
+#include "xe_log.h"
   #include "xe_pagefault.h"
   #include "xe_pagefault_types.h"
   #include "xe_svm.h"

drivers/gpu/drm/xe/xe_pagefault.c static void xe_pagefault_queue_work(struct work_struct *w) · line 629

Quoted 6 lines
drivers/gpu/drm/xe/xe_pagefault.c +1 -2
@@ -625,8 +626,7 @@ static void xe_pagefault_queue_work(struct work_struct *w)
                   xe_pagefault_save_to_vm(gt_to_xe(gt), pf);
                   xe_pagefault_cache_start_invalidate(cache_start);
                   xe_pagefault_print(pf);
-                xe_gt_info(pf->gt, "Fault response: Unsuccessful %pe\n",
-                       ERR_PTR(err));
+                xe_log_err(pf->gt, PAGEFAULT, err, "Unsuccessful response\n");

I'm wondering if we should really go from info to err here...

Quoted 7 lines
Quoted 5 lines

my question was different:
    "why this err is only reported as info level?" as once we hit this condition we also print large dump (see xe_pagefault_print) likely for debug/diagnostics so it seems important

drive-by comment, but AFAIU this error can be intentionally triggered by UMD by simply accessing an invalid PPGTT address (see e.g. xe_exec_fault_mode@invalid-va), and we usually avoid using error-level logs for something that UMD can cause on demand.

thanks for explanation!

so we have two choices here:

1) drop this patch completely, or
2) switch to SIGID reporting with INFO severity

but currently xe_log_info() does not take an 'err' parameter so we will not print the actual error code as it is today

Quoted 7 lines

so we have two more choices:

a) update xe_log_info() macro to accept 'err', or
b) add new xe_log_err_info() macro that takes 'err' but it will still use CPER_SEV_INFO severity

I'm in favor for 2) + b)

I agree

Quoted 25 lines
Quoted 24 lines

Daniele

Quoted 19 lines

@Matthew, comments?

Quoted 1 line

Why not staying with xe_log_info or now?

I can change that for xe_log_info, but then (by design) we will not print an error

Quoted 1 line

But also, why err and not ERR_PTR(err)?

patch 10/32 [1] introduced helpers that take just errno value and convert that into data { ERR_PTR(err), 0 } pair

[1] https://patchwork.freedesktop.org/patch/745993/?series=171022&rev=4

Quoted 6 lines
Quoted 6 lines
drivers/gpu/drm/xe/xe_pagefault.c +0 -0
               } else {
                   xe_gt_stats_incr(pf->gt, XE_GT_STATS_ID_INVALID_PREFETCH_PAGEFAULT_COUNT, 1);
                   xe_gt_dbg(pf->gt, "Prefetch Fault response: Unsuccessful %pe\n",

--
2.47.1

#101 lore raw

PATCH v4 31/32 drm/xe/gt: Report 'Queue full' pagefault error using SIGID

In reply to Michal Wajdeczko

Report 'Queue full' error using xe_log_err() helper.

Cc Rodrigo Vivi <[email protected]>
Cc Matthew Brost <[email protected]>
Cc Daniele Ceraolo Spurio <[email protected]>
Cc Aravind Iddamsetty <[email protected]>
Cc Mallesh Koujalagi <[email protected]>
---
 drivers/gpu/drm/xe/xe_pagefault.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/gpu/drm/xe/xe_pagefault.c +3 -1
index eb600c466187..f0e173a251e4 100644
@@ -328,8 +328,10 @@ xe_pagefault_queue_add(struct xe_pagefault_queue *pf_queue,
 
 	do {
 		/* Not possible, warn on and drop page fault */
-		if (WARN_ON(xe_pagefault_queue_full(pf_queue)))
+		if (WARN_ON_ONCE(xe_pagefault_queue_full(pf_queue))) {
+			xe_log_err(xe, PAGEFAULT, -ENOSPC, "Queue full!\n");
 			return NULL;
+		}
 
 		lpf = (pf_queue->data + pf_queue->head);
 		pf_queue->head = (pf_queue->head + xe_pagefault_entry_size()) %
Signature · 1 line
2.47.1
maintainer Reviewed-by on v4 31/32
#102 lore raw

Re: [PATCH v4 31/32] drm/xe/gt: Report 'Queue full' pagefault error using SIGID

Quoted 17 lines · Michal Wajdeczko

Report 'Queue full' error using xe_log_err() helper.

Cc Rodrigo Vivi <[email protected]>
Cc Matthew Brost <[email protected]>
Cc Daniele Ceraolo Spurio <[email protected]>
Cc Aravind Iddamsetty <[email protected]>
Cc Mallesh Koujalagi <[email protected]>
---
 drivers/gpu/drm/xe/xe_pagefault.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/gpu/drm/xe/xe_pagefault.c +0 -0
index eb600c466187..f0e173a251e4 100644

drivers/gpu/drm/xe/xe_pagefault.c xe_pagefault_queue_add(struct xe_pagefault_queue *pf_queue, · line 331

Quoted 5 lines
drivers/gpu/drm/xe/xe_pagefault.c +1 -1
@@ -328,8 +328,10 @@ xe_pagefault_queue_add(struct xe_pagefault_queue *pf_queue,
 
 	do {
 		/* Not possible, warn on and drop page fault */
-		if (WARN_ON(xe_pagefault_queue_full(pf_queue)))
+		if (WARN_ON_ONCE(xe_pagefault_queue_full(pf_queue))) {

Please mention in the commit message that we are replacing the WARN_ON per WARN_ON_ONCE to avoid the extra noise and also because once is enough anyway.

Quoted 9 lines
drivers/gpu/drm/xe/xe_pagefault.c +2 -0
+			xe_log_err(xe, PAGEFAULT, -ENOSPC, "Queue full!\n");
 			return NULL;
+		}
 
 		lpf = (pf_queue->data + pf_queue->head);
 		pf_queue->head = (pf_queue->head + xe_pagefault_entry_size()) %
Signature · 1 line
2.47.1
#103 lore raw

PATCH v4 32/32 drm/xe/pci: Report 'cannot re-enable' error using SIGID

In reply to Michal Wajdeczko

Report 'cannot re-enable PCI device' error using xe_log() helper.

Cc Rodrigo Vivi <[email protected]>
Cc Riana Tauro <[email protected]>
Cc Aravind Iddamsetty <[email protected]>
Cc Mallesh Koujalagi <[email protected]>
---
 drivers/gpu/drm/xe/xe_pci_error.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/gpu/drm/xe/xe_pci_error.c +5 -2
index e41af2ac7f23..fb965f52be5e 100644
@@ -7,6 +7,7 @@
 
 #include "xe_device.h"
 #include "xe_gt.h"
+#include "xe_log.h"
 #include "xe_pci.h"
 #include "xe_pm.h"
 #include "xe_printk.h"
@@ -90,13 +91,15 @@ static pci_ers_result_t xe_pci_error_slot_reset(struct pci_dev *pdev)
 {
 	const struct pci_device_id *ent = pci_match_id(pdev->driver->id_table, pdev);
 	struct xe_device *xe = pdev_to_xe_device(pdev);
+	int err;
 
 	xe_info(xe, "PCI error: slot reset\n");
 
 	pci_restore_state(pdev);
 
-	if (pci_enable_device(pdev)) {
-		xe_err(xe, "Cannot re-enable PCI device after reset\n");
+	err = pci_enable_device(pdev);
+	if (err) {
+		xe_log_err_fatal(xe, PCI, err, "Cannot re-enable PCI device after reset\n");
 		return PCI_ERS_RESULT_DISCONNECT;
 	}
 
Signature · 1 line
2.47.1
maintainer Reviewed-by on v4 32/32
#104 lore raw

Re: [PATCH v4 32/32] drm/xe/pci: Report 'cannot re-enable' error using SIGID

Quoted 24 lines · Michal Wajdeczko

Report 'cannot re-enable PCI device' error using xe_log() helper.

Cc Rodrigo Vivi <[email protected]>
Cc Riana Tauro <[email protected]>
Cc Aravind Iddamsetty <[email protected]>
Cc Mallesh Koujalagi <[email protected]>
---
 drivers/gpu/drm/xe/xe_pci_error.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/gpu/drm/xe/xe_pci_error.c +1 -0
index e41af2ac7f23..fb965f52be5e 100644
@@ -7,6 +7,7 @@
 
 #include "xe_device.h"
 #include "xe_gt.h"
+#include "xe_log.h"
 #include "xe_pci.h"
 #include "xe_pm.h"
 #include "xe_printk.h"

drivers/gpu/drm/xe/xe_pci_error.c static pci_ers_result_t xe_pci_error_slot_reset(struct pci_dev *pdev) · line 98

Quoted 10 lines
drivers/gpu/drm/xe/xe_pci_error.c +1 -1
@@ -90,13 +91,15 @@ static pci_ers_result_t xe_pci_error_slot_reset(struct pci_dev *pdev)
 {
 	const struct pci_device_id *ent = pci_match_id(pdev->driver->id_table, pdev);
 	struct xe_device *xe = pdev_to_xe_device(pdev);
+	int err;
 
 	xe_info(xe, "PCI error: slot reset\n");
 
 	pci_restore_state(pdev);
 
-	if (pci_enable_device(pdev)) {

this looks IO_BUS more than SW... But that is the change for the patch 3.

This patch here is great.

Quoted 10 lines
drivers/gpu/drm/xe/xe_pci_error.c +3 -1
-		xe_err(xe, "Cannot re-enable PCI device after reset\n");
+	err = pci_enable_device(pdev);
+	if (err) {
+		xe_log_err_fatal(xe, PCI, err, "Cannot re-enable PCI device after reset\n");
 		return PCI_ERS_RESULT_DISCONNECT;
 	}
 
Signature · 1 line
2.47.1
#105 lore raw

✗ CI.checkpatch: warning for drm/xe: Add structured SIGID error logging infrastructure (rev4)

In reply to Michal Wajdeczko
== Series Details ==

== Series Details ==

Series: drm/xe: Add structured SIGID error logging infrastructure (rev4)
URL : https://patchwork.freedesktop.org/series/171022/
State : warning

== Summary ==

+ KERNEL=/kernel
+ git clone https://gitlab.freedesktop.org/drm/maintainer-tools mt Cloning into 'mt'...
warning: redirecting to https://gitlab.freedesktop.org/drm/maintainer-tools.git/
+ git -C mt rev-list -n1 origin/master 061140b9bc586ae7f40abc1249c97e1cc72d1b9d
+ cd /kernel
+ git config --global --add safe.directory /kernel
+ git log -n1
commit 08c65472290df95ed8b8b2f9230739e07a5c91e6

Author: Michal Wajdeczko <[email protected]>
Date:   Wed Aug 12 21:14:48 2026 +0200

drm/xe/pci: Report 'cannot re-enable' error using SIGID

Report 'cannot re-enable PCI device' error using xe_log() helper.

Cc Rodrigo Vivi <[email protected]>
Cc Riana Tauro <[email protected]>
Cc Aravind Iddamsetty <[email protected]>
Cc Mallesh Koujalagi <[email protected]>

+ /mt/dim checkpatch 43db79ba5c8eac68b393cca2faa0b13a6505de1a drm-intel 9a9e651fdd25 drm/xe: Introduce xe_any helpers
-:24: WARNING:FILE_PATH_CHANGES: added, moved or deleted file(s), does MAINTAINERS need updating? #24:
new file mode 100644

-:39: ERROR:COMPLEX_MACRO: Macros with complex values should be enclosed in parentheses #39: FILE: drivers/gpu/drm/xe/xe_any.h:11:
+#define __xe_any_to_self_assoc(type, any) \
+ const type * : (any), \
+ type * : (any)

BUT SEE:

do {} while (0) advice is over-stated in a few situations:

The more obvious case is macros, like MODULE_PARM_DESC, invoked at file-scope, where C disallows code (it must be in functions). See $exceptions if you have one to add by name.

More troublesome is declarative macros used at top of new scope, like DECLARE_PER_CPU. These might just compile with a do-while-0 wrapper, but would be incorrect. Most of these are handled by detecting struct,union,etc declaration primitives in $exceptions.

Theres also macros called inside an if (block), which "return" an expression. These cannot do-while, and need a ({}) wrapper.

Enjoy this qualification while we work to improve our heuristics.

-:39: CHECK:MACRO_ARG_REUSE: Macro argument reuse 'any' - possible side-effects? #39: FILE: drivers/gpu/drm/xe/xe_any.h:11:
+#define __xe_any_to_self_assoc(type, any) \
+ const type * : (any), \
+ type * : (any)

-:50: CHECK:MACRO_ARG_REUSE: Macro argument reuse 'any' - possible side-effects? #50: FILE: drivers/gpu/drm/xe/xe_any.h:22:
+#define xe_any_if_type(any, type) \
+ _Generic((any), \
+ __xe_any_to_self_assoc(type, (any)), \
+ default : NULL)

-:53: WARNING:TABSTOP: Statements should start on a tabstop #53: FILE: drivers/gpu/drm/xe/xe_any.h:25:
+ default : NULL)

-:53: ERROR:TRAILING_STATEMENTS: trailing statements should be on next line #53: FILE: drivers/gpu/drm/xe/xe_any.h:25:
+ default : NULL)

-:87: CHECK:MACRO_ARG_REUSE: Macro argument reuse 'const' - possible side-effects? #87: FILE: drivers/gpu/drm/xe/xe_any.h:59:
+#define __xe_any_to_other_assoc(const, from, other, p) \
+ const struct from * : __##from##_to_##other((const struct from *)(p))

-:87: CHECK:MACRO_ARG_REUSE: Macro argument reuse 'from' - possible side-effects? #87: FILE: drivers/gpu/drm/xe/xe_any.h:59:
+#define __xe_any_to_other_assoc(const, from, other, p) \
+ const struct from * : __##from##_to_##other((const struct from *)(p))

-:87: CHECK:MACRO_ARG_PRECEDENCE: Macro argument 'from' may be better as '(from)' to avoid precedence issues #87: FILE: drivers/gpu/drm/xe/xe_any.h:59:
+#define __xe_any_to_other_assoc(const, from, other, p) \
+ const struct from * : __##from##_to_##other((const struct from *)(p))

-:103: CHECK:MACRO_ARG_REUSE: Macro argument reuse 'any' - possible side-effects? #103: FILE: drivers/gpu/drm/xe/xe_any.h:75:
+#define xe_any_to_xe(any) \
+ _Generic((any), \
+ __xe_any_to_self_assoc(struct xe_device, (any)), \
+ __xe_any_to_other_assoc(/* */, xe_tile, xe_device, (any)), \
+ __xe_any_to_other_assoc(const, xe_tile, xe_device, (any)), \
+ __xe_any_to_other_assoc(/* */, xe_gt, xe_device, (any)), \
+ __xe_any_to_other_assoc(const, xe_gt, xe_device, (any)), \
+ __xe_any_to_other_assoc(, drm_device, xe_device, (any)), \
+ __xe_any_to_other_assoc(, pci_dev, xe_device, (any)), \
+ __xe_any_to_other_assoc(, device, xe_device, (any)))

-:120: CHECK:MACRO_ARG_REUSE: Macro argument reuse 'any' - possible side-effects? #120: FILE: drivers/gpu/drm/xe/xe_any.h:92:
+#define xe_any_to_drm(any) \
+ _Generic((any), \
+ __xe_any_to_self_assoc(struct drm_device, (any)), \
+ default : &xe_any_to_xe(any)->drm)

-:123: WARNING:TABSTOP: Statements should start on a tabstop #123: FILE: drivers/gpu/drm/xe/xe_any.h:95:
+ default : &xe_any_to_xe(any)->drm)

-:123: ERROR:TRAILING_STATEMENTS: trailing statements should be on next line #123: FILE: drivers/gpu/drm/xe/xe_any.h:95:
+ default : &xe_any_to_xe(any)->drm)

-:131: CHECK:MACRO_ARG_REUSE: Macro argument reuse 'any' - possible side-effects? #131: FILE: drivers/gpu/drm/xe/xe_any.h:103:
+#define xe_any_to_dev(any) \
+ _Generic((any), \
+ __xe_any_to_self_assoc(struct device, (any)), \
+ __xe_any_to_other_assoc(, pci_dev, device, (any)), \
+ default : xe_any_to_drm(any)->dev)

-:135: WARNING:TABSTOP: Statements should start on a tabstop #135: FILE: drivers/gpu/drm/xe/xe_any.h:107:
+ default : xe_any_to_drm(any)->dev)

-:135: ERROR:TRAILING_STATEMENTS: trailing statements should be on next line #135: FILE: drivers/gpu/drm/xe/xe_any.h:107:
+ default : xe_any_to_drm(any)->dev)

-:143: CHECK:MACRO_ARG_REUSE: Macro argument reuse 'any' - possible side-effects? #143: FILE: drivers/gpu/drm/xe/xe_any.h:115:
+#define xe_any_to_pdev(any) \
+ _Generic((any), \
+ __xe_any_to_self_assoc(struct pci_dev, (any)), \
+ default : to_pci_dev(xe_any_to_dev(any)))

-:146: WARNING:TABSTOP: Statements should start on a tabstop #146: FILE: drivers/gpu/drm/xe/xe_any.h:118:
+ default : to_pci_dev(xe_any_to_dev(any)))

-:146: ERROR:TRAILING_STATEMENTS: trailing statements should be on next line #146: FILE: drivers/gpu/drm/xe/xe_any.h:118:
+ default : to_pci_dev(xe_any_to_dev(any)))

-:157: CHECK:MACRO_ARG_REUSE: Macro argument reuse 'any' - possible side-effects? #157: FILE: drivers/gpu/drm/xe/xe_any.h:129:
+#define xe_any_id(any) \
+ _Generic((any), \
+ __xe_any_to_other_assoc(/* */, xe_tile, id, (any)), \
+ __xe_any_to_other_assoc(const, xe_tile, id, (any)), \
+ __xe_any_to_other_assoc(/* */, xe_gt, id, (any)), \
+ __xe_any_to_other_assoc(const, xe_gt, id, (any)), \
+ default : 0)

-:163: WARNING:TABSTOP: Statements should start on a tabstop #163: FILE: drivers/gpu/drm/xe/xe_any.h:135:
+ default : 0)

-:163: ERROR:TRAILING_STATEMENTS: trailing statements should be on next line #163: FILE: drivers/gpu/drm/xe/xe_any.h:135:
+ default : 0)

total: 6 errors, 6 warnings, 10 checks, 137 lines checked
e4feac4d1fa3 drm/xe/log: Add structured SIGID error logging infrastructure
-:37: WARNING:FILE_PATH_CHANGES: added, moved or deleted file(s), does MAINTAINERS need updating? #37:
new file mode 100644

total: 0 errors, 1 warnings, 0 checks, 342 lines checked
70d69beed1d4 drm/xe/log: Introduce structured component/location identifiers -:18: WARNING:FILE_PATH_CHANGES: added, moved or deleted file(s), does MAINTAINERS need updating? #18:
new file mode 100644

-:154: ERROR:COMPLEX_MACRO: Macros with complex values should be enclosed in parentheses #154: FILE: drivers/gpu/drm/xe/abi/xe_log_abi.h:132:
+#define DEFINE_XE_LOG_COMPONENTS(define) \
+ /* */ \
+ define(SYSTEM, 1, PCI, SW, "Linux PCI Subsystem") \
+ define(SYSTEM, 2, DRM, SW, "DRM") \
+ /* */ \
+ define(DRIVER, 1, XE, SW, "Xe Driver") \
+ define(DRIVER, 2, PROBE, PROBE, "Driver Initialization") \
+ define(DRIVER, 3, WEDGED, WEDGED, "Device Malfunction") \
+ define(DRIVER, 4, RTP, SW, "Register Table Processing") \
+ define(DRIVER, 5, WA, SW, "Workarounds") \
+ define(DRIVER, 6, PAGEFAULT, MEM_FAULT, "Page Fault") \
+ /* */ \
+ define(DRIVER_HARDWARE, 1, REGS, IO_BUS, "Registers") \
+ define(DRIVER_HARDWARE, 2, GGTT, IO_BUS, "Global GTT") \
+ define(DRIVER_HARDWARE, 3, GT, GT_TDR, "Graphics Technology") \
+ define(DRIVER_HARDWARE, 4, LMTT, IO_BUS, "LMEM Translation Table") \
+ define(DRIVER_HARDWARE, 5, MEMIRQ, IO_BUS, "Memory Based IRQ") \
+ /* */ \
+ define(DRIVER_FEATURE, 1, PF, SW, "SR-IOV Physical Function") \
+ define(DRIVER_FEATURE, 2, VF, SW, "SR-IOV Virtual Function") \
+ define(DRIVER_FEATURE, 3, SURVIVABILITY, SURVIVABILITY, "Survivability") \
+ define(DRIVER_FEATURE, 4, RAS, SW, "Reliability, Accessibility, Serviceability") \
+ /* */ \
+ define(DRIVER_FIRMWARE, 1, GUC, RUNTIME_FW, "GuC") \
+ define(DRIVER_FIRMWARE, 2, HUC, RUNTIME_FW, "HuC") \
+ define(DRIVER_FIRMWARE, 3, GSC, RUNTIME_FW, "GSC") \
+ define(DRIVER_FIRMWARE, 16, PCODE, DEVICE_FW, "PCode") \
+ define(DRIVER_FIRMWARE, 17, SYSCTRL, DEVICE_FW, "System Controller") \
+ /* eod */

BUT SEE:

do {} while (0) advice is over-stated in a few situations:

The more obvious case is macros, like MODULE_PARM_DESC, invoked at file-scope, where C disallows code (it must be in functions). See $exceptions if you have one to add by name.

More troublesome is declarative macros used at top of new scope, like DECLARE_PER_CPU. These might just compile with a do-while-0 wrapper, but would be incorrect. Most of these are handled by detecting struct,union,etc declaration primitives in $exceptions.

Theres also macros called inside an if (block), which "return" an expression. These cannot do-while, and need a ({}) wrapper.

Enjoy this qualification while we work to improve our heuristics.

-:154: CHECK:MACRO_ARG_REUSE: Macro argument reuse 'define' - possible side-effects? #154: FILE: drivers/gpu/drm/xe/abi/xe_log_abi.h:132:
+#define DEFINE_XE_LOG_COMPONENTS(define) \
+ /* */ \
+ define(SYSTEM, 1, PCI, SW, "Linux PCI Subsystem") \
+ define(SYSTEM, 2, DRM, SW, "DRM") \
+ /* */ \
+ define(DRIVER, 1, XE, SW, "Xe Driver") \
+ define(DRIVER, 2, PROBE, PROBE, "Driver Initialization") \
+ define(DRIVER, 3, WEDGED, WEDGED, "Device Malfunction") \
+ define(DRIVER, 4, RTP, SW, "Register Table Processing") \
+ define(DRIVER, 5, WA, SW, "Workarounds") \
+ define(DRIVER, 6, PAGEFAULT, MEM_FAULT, "Page Fault") \
+ /* */ \
+ define(DRIVER_HARDWARE, 1, REGS, IO_BUS, "Registers") \
+ define(DRIVER_HARDWARE, 2, GGTT, IO_BUS, "Global GTT") \
+ define(DRIVER_HARDWARE, 3, GT, GT_TDR, "Graphics Technology") \
+ define(DRIVER_HARDWARE, 4, LMTT, IO_BUS, "LMEM Translation Table") \
+ define(DRIVER_HARDWARE, 5, MEMIRQ, IO_BUS, "Memory Based IRQ") \
+ /* */ \
+ define(DRIVER_FEATURE, 1, PF, SW, "SR-IOV Physical Function") \
+ define(DRIVER_FEATURE, 2, VF, SW, "SR-IOV Virtual Function") \
+ define(DRIVER_FEATURE, 3, SURVIVABILITY, SURVIVABILITY, "Survivability") \
+ define(DRIVER_FEATURE, 4, RAS, SW, "Reliability, Accessibility, Serviceability") \
+ /* */ \
+ define(DRIVER_FIRMWARE, 1, GUC, RUNTIME_FW, "GuC") \
+ define(DRIVER_FIRMWARE, 2, HUC, RUNTIME_FW, "HuC") \
+ define(DRIVER_FIRMWARE, 3, GSC, RUNTIME_FW, "GSC") \
+ define(DRIVER_FIRMWARE, 16, PCODE, DEVICE_FW, "PCode") \
+ define(DRIVER_FIRMWARE, 17, SYSCTRL, DEVICE_FW, "System Controller") \
+ /* eod */

-:189: ERROR:COMPLEX_MACRO: Macros with complex values should be enclosed in parentheses #189: FILE: drivers/gpu/drm/xe/abi/xe_log_abi.h:167:
+#define MAKE_XE_LOG_COMPONENT_ENUM(_CLASS, _ID, _TAG, _SIG, _NAME) \
+ XE_LOG_COMPONENT_##_TAG = MAKE_XE_LOG_COMPONENT(_CLASS, (_ID)), \
+ XE_LOG_COMPONENT_##_CLASS##_##_ID = XE_LOG_COMPONENT_##_TAG, \
+ /* eod */

BUT SEE:

do {} while (0) advice is over-stated in a few situations:

The more obvious case is macros, like MODULE_PARM_DESC, invoked at file-scope, where C disallows code (it must be in functions). See $exceptions if you have one to add by name.

More troublesome is declarative macros used at top of new scope, like DECLARE_PER_CPU. These might just compile with a do-while-0 wrapper, but would be incorrect. Most of these are handled by detecting struct,union,etc declaration primitives in $exceptions.

Theres also macros called inside an if (block), which "return" an expression. These cannot do-while, and need a ({}) wrapper.

Enjoy this qualification while we work to improve our heuristics.

-:189: WARNING:MACRO_ARG_UNUSED: Argument '_SIG' is not used in function-like macro #189: FILE: drivers/gpu/drm/xe/abi/xe_log_abi.h:167:
+#define MAKE_XE_LOG_COMPONENT_ENUM(_CLASS, _ID, _TAG, _SIG, _NAME) \
+ XE_LOG_COMPONENT_##_TAG = MAKE_XE_LOG_COMPONENT(_CLASS, (_ID)), \
+ XE_LOG_COMPONENT_##_CLASS##_##_ID = XE_LOG_COMPONENT_##_TAG, \
+ /* eod */

-:189: WARNING:MACRO_ARG_UNUSED: Argument '_NAME' is not used in function-like macro #189: FILE: drivers/gpu/drm/xe/abi/xe_log_abi.h:167:
+#define MAKE_XE_LOG_COMPONENT_ENUM(_CLASS, _ID, _TAG, _SIG, _NAME) \
+ XE_LOG_COMPONENT_##_TAG = MAKE_XE_LOG_COMPONENT(_CLASS, (_ID)), \
+ XE_LOG_COMPONENT_##_CLASS##_##_ID = XE_LOG_COMPONENT_##_TAG, \
+ /* eod */

-:202: ERROR:COMPLEX_MACRO: Macros with complex values should be enclosed in parentheses #202: FILE: drivers/gpu/drm/xe/abi/xe_log_abi.h:180:
+#define MAKE_XE_LOG_COMPONENT_SIGID(_CLASS, _ID, _TAG, _SIG, _NAME) \
+ XE_LOG_COMPONENT_##_TAG##_SIGID = XE_SIGID_##_SIG, \
+ /* eod */

BUT SEE:

do {} while (0) advice is over-stated in a few situations:

The more obvious case is macros, like MODULE_PARM_DESC, invoked at file-scope, where C disallows code (it must be in functions). See $exceptions if you have one to add by name.

More troublesome is declarative macros used at top of new scope, like DECLARE_PER_CPU. These might just compile with a do-while-0 wrapper, but would be incorrect. Most of these are handled by detecting struct,union,etc declaration primitives in $exceptions.

Theres also macros called inside an if (block), which "return" an expression. These cannot do-while, and need a ({}) wrapper.

Enjoy this qualification while we work to improve our heuristics.

-:202: WARNING:MACRO_ARG_UNUSED: Argument '_CLASS' is not used in function-like macro #202: FILE: drivers/gpu/drm/xe/abi/xe_log_abi.h:180:
+#define MAKE_XE_LOG_COMPONENT_SIGID(_CLASS, _ID, _TAG, _SIG, _NAME) \
+ XE_LOG_COMPONENT_##_TAG##_SIGID = XE_SIGID_##_SIG, \
+ /* eod */

-:202: WARNING:MACRO_ARG_UNUSED: Argument '_ID' is not used in function-like macro #202: FILE: drivers/gpu/drm/xe/abi/xe_log_abi.h:180:
+#define MAKE_XE_LOG_COMPONENT_SIGID(_CLASS, _ID, _TAG, _SIG, _NAME) \
+ XE_LOG_COMPONENT_##_TAG##_SIGID = XE_SIGID_##_SIG, \
+ /* eod */

-:202: WARNING:MACRO_ARG_UNUSED: Argument '_NAME' is not used in function-like macro #202: FILE: drivers/gpu/drm/xe/abi/xe_log_abi.h:180:
+#define MAKE_XE_LOG_COMPONENT_SIGID(_CLASS, _ID, _TAG, _SIG, _NAME) \
+ XE_LOG_COMPONENT_##_TAG##_SIGID = XE_SIGID_##_SIG, \
+ /* eod */

total: 3 errors, 6 warnings, 1 checks, 187 lines checked f3feb2a7198b drm/xe/log: Add component/location decorations to dmesg -:40: WARNING:TRAILING_SEMICOLON: macros should not use a trailing semicolon #40: FILE: drivers/gpu/drm/xe/xe_log.c:26:
+#define MAKE_XE_LOG_COMPONENT_CLASS_PREFIX(_CLASS) \
+ case XE_LOG_COMPONENT_CLASS_##_CLASS: return #_CLASS "? ";

-:55: WARNING:MACRO_ARG_UNUSED: Argument '_CLASS' is not used in function-like macro #55: FILE: drivers/gpu/drm/xe/xe_log.c:41:
+#define MAKE_XE_LOG_COMPONENT_CASE_PREFIX(_CLASS, _ID, _TAG, _SIG, _NAME) \
+ case XE_LOG_COMPONENT_##_TAG: return #_TAG ": ";

-:55: WARNING:MACRO_ARG_UNUSED: Argument '_ID' is not used in function-like macro #55: FILE: drivers/gpu/drm/xe/xe_log.c:41:
+#define MAKE_XE_LOG_COMPONENT_CASE_PREFIX(_CLASS, _ID, _TAG, _SIG, _NAME) \
+ case XE_LOG_COMPONENT_##_TAG: return #_TAG ": ";

-:55: WARNING:MACRO_ARG_UNUSED: Argument '_SIG' is not used in function-like macro #55: FILE: drivers/gpu/drm/xe/xe_log.c:41:
+#define MAKE_XE_LOG_COMPONENT_CASE_PREFIX(_CLASS, _ID, _TAG, _SIG, _NAME) \
+ case XE_LOG_COMPONENT_##_TAG: return #_TAG ": ";

-:55: WARNING:MACRO_ARG_UNUSED: Argument '_NAME' is not used in function-like macro #55: FILE: drivers/gpu/drm/xe/xe_log.c:41:
+#define MAKE_XE_LOG_COMPONENT_CASE_PREFIX(_CLASS, _ID, _TAG, _SIG, _NAME) \
+ case XE_LOG_COMPONENT_##_TAG: return #_TAG ": ";

-:55: WARNING:TRAILING_SEMICOLON: macros should not use a trailing semicolon #55: FILE: drivers/gpu/drm/xe/xe_log.c:41:
+#define MAKE_XE_LOG_COMPONENT_CASE_PREFIX(_CLASS, _ID, _TAG, _SIG, _NAME) \
+ case XE_LOG_COMPONENT_##_TAG: return #_TAG ": ";

total: 0 errors, 6 warnings, 0 checks, 126 lines checked 0a8ebef72139 drm/xe/log: Add SIGID log helpers for severity 5506af2cffb2 drm/xe/log: Add SIGID log helpers for location
-:45: CHECK:MACRO_ARG_REUSE: Macro argument reuse 'any' - possible side-effects? #45: FILE: drivers/gpu/drm/xe/xe_log.h:49:
+#define xe_log_location(any) \
+ PREP_XE_LOG_LOCATION(xe_log_location_type(any), xe_any_id(any))

total: 0 errors, 0 warnings, 1 checks, 47 lines checked
21f7f0662e9c drm/xe/log: Add SIGID log helpers for location & severity
f8c4ed0492d0 drm/xe/log: Add SIGID log helpers for components
8002a547f86a drm/xe/log: Add SIGID log helpers for component & severity
e3ba2be7f884 drm/xe/log: Add SIGID log helpers for errno-only
03b62a1d302f drm/xe/log: Index all SIGID printk messages
-:13: WARNING:COMMIT_LOG_LONG_LINE: Prefer a maximum 75 chars per line (possible unwrapped commit description?) #13:
<3> drivers/gpu/drm/xe/xe_log.c:142 log_dmesg_vprintk "%s %s: [drm] *ERROR* %pV"

-:65: WARNING:TRAILING_SEMICOLON: macros should not use a trailing semicolon #65: FILE: drivers/gpu/drm/xe/xe_log.h:23:
+#define __xe_log_emit_printk_index(fmt) \
+ dev_printk_index_emit(NULL, "[drm]%s SIGID=%u %s(%s)%s%s%s: " fmt);

-:68: CHECK:MACRO_ARG_REUSE: Macro argument reuse 'fmt' - possible side-effects? #68: FILE: drivers/gpu/drm/xe/xe_log.h:26:
+#define xe_log_emit(pdev, sev, sig, comp, loc, data, len, fmt, args...) ({ \
+ __xe_log_emit_printk_index(fmt); \
+ __xe_log_emit((pdev), (sev), (sig), (comp), (loc), (data), (len), fmt, ##args); \
+})

total: 0 errors, 2 warnings, 1 checks, 40 lines checked
eec656f53be3 drm/xe/log: Add hardware error signatures
dc9453a92f4f drm/xe/log: Extend components list with hardware items
-:25: ERROR:COMPLEX_MACRO: Macros with complex values should be enclosed in parentheses #25: FILE: drivers/gpu/drm/xe/abi/xe_log_abi.h:136:
+#define DEFINE_XE_LOG_SOFTWARE_COMPONENTS(define) \
/* */ \
define(SYSTEM, 1, PCI, SW, "Linux PCI Subsystem") \
define(SYSTEM, 2, DRM, SW, "DRM") \

BUT SEE:

do {} while (0) advice is over-stated in a few situations:

The more obvious case is macros, like MODULE_PARM_DESC, invoked at file-scope, where C disallows code (it must be in functions). See $exceptions if you have one to add by name.

More troublesome is declarative macros used at top of new scope, like DECLARE_PER_CPU. These might just compile with a do-while-0 wrapper, but would be incorrect. Most of these are handled by detecting struct,union,etc declaration primitives in $exceptions.

Theres also macros called inside an if (block), which "return" an expression. These cannot do-while, and need a ({}) wrapper.

Enjoy this qualification while we work to improve our heuristics.

-:25: CHECK:MACRO_ARG_REUSE: Macro argument reuse 'define' - possible side-effects? #25: FILE: drivers/gpu/drm/xe/abi/xe_log_abi.h:136:
+#define DEFINE_XE_LOG_SOFTWARE_COMPONENTS(define) \
/* */ \
define(SYSTEM, 1, PCI, SW, "Linux PCI Subsystem") \
define(SYSTEM, 2, DRM, SW, "DRM") \

-:34: ERROR:COMPLEX_MACRO: Macros with complex values should be enclosed in parentheses #34: FILE: drivers/gpu/drm/xe/abi/xe_log_abi.h:165:
+#define DEFINE_XE_LOG_HARDWARE_COMPONENTS(define) \
+ define(HARDWARE, 1, DEVICE_MEMORY, DEVICE_MEMORY, "Device Memory") \
+ define(HARDWARE, 2, CORE_COMPUTE, CORE_COMPUTE, "Core Compute") \
+ /* HARDWARE, 3, RESERVED */ \
+ define(HARDWARE, 4, PCIE, PCIE, "PCIe Interface") \
+ define(HARDWARE, 5, FABRIC, FABRIC, "Fabric") \
+ define(HARDWARE, 6, SOC_INTERNAL, SOC_INTERNAL, "SoC Internal") \
/* eod */

BUT SEE:

do {} while (0) advice is over-stated in a few situations:

The more obvious case is macros, like MODULE_PARM_DESC, invoked at file-scope, where C disallows code (it must be in functions). See $exceptions if you have one to add by name.

More troublesome is declarative macros used at top of new scope, like DECLARE_PER_CPU. These might just compile with a do-while-0 wrapper, but would be incorrect. Most of these are handled by detecting struct,union,etc declaration primitives in $exceptions.

Theres also macros called inside an if (block), which "return" an expression. These cannot do-while, and need a ({}) wrapper.

Enjoy this qualification while we work to improve our heuristics.

-:34: CHECK:MACRO_ARG_REUSE: Macro argument reuse 'define' - possible side-effects? #34: FILE: drivers/gpu/drm/xe/abi/xe_log_abi.h:165:
+#define DEFINE_XE_LOG_HARDWARE_COMPONENTS(define) \
+ define(HARDWARE, 1, DEVICE_MEMORY, DEVICE_MEMORY, "Device Memory") \
+ define(HARDWARE, 2, CORE_COMPUTE, CORE_COMPUTE, "Core Compute") \
+ /* HARDWARE, 3, RESERVED */ \
+ define(HARDWARE, 4, PCIE, PCIE, "PCIe Interface") \
+ define(HARDWARE, 5, FABRIC, FABRIC, "Fabric") \
+ define(HARDWARE, 6, SOC_INTERNAL, SOC_INTERNAL, "SoC Internal") \
/* eod */

total: 2 errors, 0 warnings, 2 checks, 24 lines checked
da1d6bdfd18d drm/xe/ras: Check RAS and LOG component definitions
ccbcce25c8fd drm/xe/kunit: Setup driver data in the test device
8c4626206f98 drm/xe/tests: Add Kunit tests for xe_log
-:16: WARNING:FILE_PATH_CHANGES: added, moved or deleted file(s), does MAINTAINERS need updating? #16:
new file mode 100644

-:48: WARNING:MACRO_ARG_UNUSED: Argument '_CLASS' is not used in function-like macro #48: FILE: drivers/gpu/drm/xe/tests/xe_log_kunit.c:28:
+#define make_component_tag_case(_CLASS, _ID, _TAG, _SIG, _NAME) \
+ case XE_LOG_COMPONENT_##_TAG: return _NAME;

-:48: WARNING:MACRO_ARG_UNUSED: Argument '_ID' is not used in function-like macro #48: FILE: drivers/gpu/drm/xe/tests/xe_log_kunit.c:28:
+#define make_component_tag_case(_CLASS, _ID, _TAG, _SIG, _NAME) \
+ case XE_LOG_COMPONENT_##_TAG: return _NAME;

-:48: WARNING:MACRO_ARG_UNUSED: Argument '_SIG' is not used in function-like macro #48: FILE: drivers/gpu/drm/xe/tests/xe_log_kunit.c:28:
+#define make_component_tag_case(_CLASS, _ID, _TAG, _SIG, _NAME) \
+ case XE_LOG_COMPONENT_##_TAG: return _NAME;

-:48: WARNING:TRAILING_SEMICOLON: macros should not use a trailing semicolon #48: FILE: drivers/gpu/drm/xe/tests/xe_log_kunit.c:28:
+#define make_component_tag_case(_CLASS, _ID, _TAG, _SIG, _NAME) \
+ case XE_LOG_COMPONENT_##_TAG: return _NAME;

total: 0 errors, 5 warnings, 0 checks, 575 lines checked
11ca6a01a930 drm/xe/tests: Add kunit tests for xe_any
-:25: WARNING:FILE_PATH_CHANGES: added, moved or deleted file(s), does MAINTAINERS need updating? #25:
new file mode 100644

total: 0 errors, 1 warnings, 0 checks, 220 lines checked
dfaafa58c78f drm/xe: Report 'probe blocked' error using SIGID 9ca9593a8fd5 drm/xe: Report all probe errors using SIGID
ab7260857768 drm/xe/survivability: Report 'boot status' using SIGID a1ae329226c7 drm/xe/survivability: Report 'sysfs failure' error using SIGID acb7a9ddca31 drm/xe/survivability: Report 'Boot Mode enabled' status using SIGID 9555113f1179 drm/xe/survivability: Report 'Runtime Mode enabled' status using SIGID 1460c28e63a1 drm/xe: Report 'device wedged' errors using SIGID 227ad65d2228 drm/xe/pcode: Report 'Mailbox failed' error using SIGID ed915805975b drm/xe/pcode: Report 'timeout, retrying' error using SIGID 19b535f69317 drm/xe/pcode: Report 'initialization timedout' error using SIGID 6ec7ae86f36b drm/xe/guc: Report 'GuC mmio' errors using SIGID 5cf4606f7590 drm/xe/gt: Report 'reset failed' errors using SIGID 9811f3d47640 drm/xe/gt: Report 'Fault response' pagefault error using SIGID 5e1412781ea6 drm/xe/gt: Report 'Queue full' pagefault error using SIGID 08c65472290d drm/xe/pci: Report 'cannot re-enable' error using SIGID