Skip to contentSkip to conversation

drm/xe: Structured RAS error logging infrastructure

RFC PATCH Superseded Mallesh Koujalagi 5 participants 18 messages Jun 17 – Jul 3

Subsystems (2)

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

v3 cover drm/xe: Structured RAS error logging infrastructure

Today XE logs GPU errors with ad-hoc drm_err()/drm_warn() calls that have no standard format, making it hard to identify what failed, where on the GPU it happened, and how to correlate events.

This series adds a lightweight structured logging layer:

- Introduces xe_sig_ids.h (Signature IDs that name each error class) and xe_ras_log.c (__xe_ras_log()), which emits every error in a fixed format:

    [xe-err] SIG_ID=<id> Severity=<sev> Location=<loc> Errno=<n>
    Message="<msg>"

- Converts the first call site: the open-coded drm_err() in xe_device_declare_wedged() is replaced with XE_RAS_WEDGED(), routing wedge events through the new common path.

v2:
- Rebase.

v3:
- Add HW SIG IDS details. (Riana)
- Refer "Tile%u" and "GT%u" strings. (Michal Wajdeczko)
- Remov xe_cper_severity_str(). (Michal Wajdeczko/Riana)
- Move __xe_ras_log() function to xe_ras_log.h. (Michal Wajdeczko)
- Make macro function properly.
- Remove *_FIRST and *_LAST macro. (Michal Wajdeczko/Riana)
- Add sig id documents. (Riana)
- Change macro function same prefix as the file.
- Handle __xe_ras_log() function with variable format.
- Update message in xe_ras_log_wedged().

Mallesh Koujalagi (3):
drm/xe: Add error Signature IDs for RAS logging drm/xe: Add RAS logging helpers
drm/xe: use XE_RAS_WEDGED macro in xe_device_declare_wedged

 drivers/gpu/drm/xe/Makefile     |   1 +
 drivers/gpu/drm/xe/xe_device.c  |  13 ++--
 drivers/gpu/drm/xe/xe_ras_log.c |  63 +++++++++++++++++++
 drivers/gpu/drm/xe/xe_ras_log.h | 108 ++++++++++++++++++++++++++++++++
 drivers/gpu/drm/xe/xe_sig_ids.h |  29 +++++++++
 5 files changed, 208 insertions(+), 6 deletions(-)
 create mode 100644 drivers/gpu/drm/xe/xe_ras_log.c
 create mode 100644 drivers/gpu/drm/xe/xe_ras_log.h
 create mode 100644 drivers/gpu/drm/xe/xe_sig_ids.h
Signature · 1 line
2.34.1
#1 lore raw

RFC PATCH v3 1/3 drm/xe: Add error Signature IDs for RAS logging

Every GPU fault needs a stable numeric label so monitoring tools can identify what went wrong without parsing log text. Add xe_sig_ids.h which defines those labels, called SIG_IDs.

---
v3:
- Add HW SIG IDS details. (Riana)

---
 drivers/gpu/drm/xe/xe_sig_ids.h | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)
 create mode 100644 drivers/gpu/drm/xe/xe_sig_ids.h
drivers/gpu/drm/xe/xe_sig_ids.h new file +29 -0
new file mode 100644
index 000000000000..7badd0d7ad72
@@ -0,0 +1,29 @@
+/* SPDX-License-Identifier: MIT */
+/*
+ * Copyright © 2026 Intel Corporation
+ */
+
+#ifndef _XE_SIG_IDS_H_
+#define _XE_SIG_IDS_H_
+
+/*
+ * Driver SIG_IDs
+ */
+#define XE_SIG_PROBE			1  /* FATAL: probe failed */
+#define XE_SIG_WEDGED			2  /* FATAL: device wedged */
+#define XE_SIG_SURVIVABILITY		3  /* FATAL: survivability mode */
+#define XE_SIG_FW			4  /* RECOVERABLE: GuC/HuC/UC/GSC/CSC/PCODE */
+#define XE_SIG_GT_TDR			5  /* RECOVERABLE: engine hang / reset */
+#define XE_SIG_MEM_FAULT		6  /* RECOVERABLE: VM bind, page fault, GTT */
+#define XE_SIG_IO_BUS			7  /* RECOVERABLE: runtime PCIe/IOMMU/MMIO */
+
+/*
+ * HW SIG_IDs
+ */
+#define XE_SIG_HW_DEVICE_MEMORY		8  /* Device memory errors (e.g. ECC) */
+#define XE_SIG_HW_CORE_COMPUTE		9  /* Compute/shader core errors */
+#define XE_SIG_HW_PCIE			10 /* PCIe interface errors */
+#define XE_SIG_HW_FABRIC		11 /* On-package fabric errors */
+#define XE_SIG_HW_SOC_INTERNAL		12 /* SoC-internal errors */
+
+#endif /* _XE_SIG_IDS_H_ */
Signature · 1 line
2.34.1
#2 lore raw

Re: [RFC PATCH v3 1/3] drm/xe: Add error Signature IDs for RAS logging

Quoted 1 line · Mallesh Koujalagi

Every GPU fault needs a stable numeric label so monitoring tools can

GPU fault does not need a label. This patch introduces so it's easy for tools /script to monitor.

Quoted 18 lines

identify what went wrong without parsing log text. Add xe_sig_ids.h which defines those labels, called SIG_IDs.

---
v3:
- Add HW SIG IDS details. (Riana)

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

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

drivers/gpu/drm/xe/xe_sig_ids.h new file +0 -0
new file mode 100644
index 000000000000..7badd0d7ad72

drivers/gpu/drm/xe/xe_sig_ids.h line 7

Quoted 7 lines
drivers/gpu/drm/xe/xe_sig_ids.h new file +7 -0
@@ -0,0 +1,29 @@
+/* SPDX-License-Identifier: MIT */
+/*
+ * Copyright © 2026 Intel Corporation
+ */
+
+#ifndef _XE_SIG_IDS_H_
+#define _XE_SIG_IDS_H_

Document would be more relevant here

Quoted 4 lines
drivers/gpu/drm/xe/xe_sig_ids.h new file +4 -0
+
+/*
+ * Driver SIG_IDs
+ */

drivers/gpu/drm/xe/xe_sig_ids.h line 21

Quoted 10 lines
drivers/gpu/drm/xe/xe_sig_ids.h new file +10 -0
+#define XE_SIG_PROBE			1  /* FATAL: probe failed */
+#define XE_SIG_WEDGED			2  /* FATAL: device wedged */
+#define XE_SIG_SURVIVABILITY		3  /* FATAL: survivability mode */
+#define XE_SIG_FW			4  /* RECOVERABLE: GuC/HuC/UC/GSC/CSC/PCODE */
+#define XE_SIG_GT_TDR			5  /* RECOVERABLE: engine hang / reset */
+#define XE_SIG_MEM_FAULT		6  /* RECOVERABLE: VM bind, page fault, GTT */
+#define XE_SIG_IO_BUS			7  /* RECOVERABLE: runtime PCIe/IOMMU/MMIO */
+
+/*
+ * HW SIG_IDs

Acronym needed? Mention Hardware error

drivers/gpu/drm/xe/xe_sig_ids.h line 23

Quoted 2 lines
drivers/gpu/drm/xe/xe_sig_ids.h new file +2 -0
+ */
+#define XE_SIG_HW_DEVICE_MEMORY		8  /* Device memory errors (e.g. ECC) */

example not needed. If required please define

drivers/gpu/drm/xe/xe_sig_ids.h line 26

Quoted 3 lines
drivers/gpu/drm/xe/xe_sig_ids.h new file +3 -0
+#define XE_SIG_HW_CORE_COMPUTE		9  /* Compute/shader core errors */
+#define XE_SIG_HW_PCIE			10 /* PCIe interface errors */
+#define XE_SIG_HW_FABRIC		11 /* On-package fabric errors */

on-package?

Thanks
Riana

Quoted 3 lines
drivers/gpu/drm/xe/xe_sig_ids.h new file +3 -0
+#define XE_SIG_HW_SOC_INTERNAL		12 /* SoC-internal errors */
+
+#endif /* _XE_SIG_IDS_H_ */
#3 lore raw

Re: [RFC PATCH v3 1/3] drm/xe: Add error Signature IDs for RAS logging

Quoted 6 lines · Riana
Quoted 1 line · Mallesh Koujalagi

Every GPU fault needs a stable numeric label so monitoring tools can

GPU fault does not need a label. This patch introduces so it's easy for tools /script to monitor.

You are right. I will update this in the next revision.

Quoted 12 lines
Quoted 12 lines

identify what went wrong without parsing log text. Add xe_sig_ids.h which defines those labels, called SIG_IDs.

---
v3:
- Add HW SIG IDS details. (Riana)
---
  drivers/gpu/drm/xe/xe_sig_ids.h | 29 +++++++++++++++++++++++++++++

  1 file changed, 29 insertions(+)

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

Quoted 16 lines

drivers/gpu/drm/xe/xe_sig_ids.h line 7

Quoted 13 lines
drivers/gpu/drm/xe/xe_sig_ids.h new file +7 -0
new file mode 100644
index 000000000000..7badd0d7ad72
@@ -0,0 +1,29 @@
+/* SPDX-License-Identifier: MIT */
+/*
+ * Copyright © 2026 Intel Corporation
+ */
+
+#ifndef _XE_SIG_IDS_H_
+#define _XE_SIG_IDS_H_

Document would be more relevant here

Ack, I'll move here.

Quoted 12 lines
Quoted 12 lines
drivers/gpu/drm/xe/xe_sig_ids.h new file +8 -0
+
+/*
+ * Driver SIG_IDs
+ */
+#define XE_SIG_PROBE            1  /* FATAL: probe failed */
+#define XE_SIG_WEDGED            2  /* FATAL: device wedged */
+#define XE_SIG_SURVIVABILITY        3  /* FATAL: survivability mode */
+#define XE_SIG_FW            4  /* RECOVERABLE: 

GuC/HuC/UC/GSC/CSC/PCODE */
+#define XE_SIG_GT_TDR            5  /* RECOVERABLE: engine hang / reset */
+#define XE_SIG_MEM_FAULT        6  /* RECOVERABLE: VM bind, page

Quoted 9 lines

drivers/gpu/drm/xe/xe_sig_ids.h line 21

Quoted 6 lines

fault, GTT */
+#define XE_SIG_IO_BUS            7  /* RECOVERABLE: runtime PCIe/IOMMU/MMIO */

drivers/gpu/drm/xe/xe_sig_ids.h new file +3 -0
+
+/*
+ * HW SIG_IDs

Acronym needed? Mention Hardware error

Good point. I will update the comment to explicitly mention “Hardware errors” in the next revision.

Quoted 6 lines
Quoted 3 lines

+ */
+#define XE_SIG_HW_DEVICE_MEMORY        8  /* Device memory errors (e.g. ECC) */

example not needed. If required please define

Agreed. I will drop the example and keep the comment concise

Quoted 5 lines

drivers/gpu/drm/xe/xe_sig_ids.h line 26

Quoted 4 lines

+#define XE_SIG_HW_CORE_COMPUTE        9 /* Compute/shader core errors */

drivers/gpu/drm/xe/xe_sig_ids.h new file +2 -0
+#define XE_SIG_HW_PCIE            10 /* PCIe interface errors */
+#define XE_SIG_HW_FABRIC        11 /* On-package fabric errors */

on-package?

It refers to the high speed interconnect between dies/tiles within the same GPU.

I'll make the comment clearer in next revision.

Thanks,

-/Mallesh

Quoted 8 lines

Thanks
Riana

Quoted 3 lines
drivers/gpu/drm/xe/xe_sig_ids.h new file +3 -0
+#define XE_SIG_HW_SOC_INTERNAL        12 /* SoC-internal errors */
+
+#endif /* _XE_SIG_IDS_H_ */
#4 lore raw

Re: [RFC PATCH v3 1/3] drm/xe: Add error Signature IDs for RAS logging

In reply to Mallesh Koujalagi
Quoted 1 line · Mallesh Koujalagi

Every GPU fault needs a stable numeric label so monitoring tools can

so the goal is to assign unique number to each GPU error that we report?

can't we teach the monitoring tools to use the message pattern instead?

or maybe it's not about unique signature but rather class of Xe GPU errors? like HW_ERR defined in [1] for generic hardware errors?

[1] https://elixir.bootlin.com/linux/v7.1/source/include/linux/printk.h#L118

Quoted 1 line

identify what went wrong without parsing log text.

hmm, but they will have to parse this text already to find that ID

Quoted 2 lines

Add xe_sig_ids.h
which defines those labels, called SIG_IDs.

SIG_ID looks like an acronym already - can we know the full real name?

the 'signature' suggests uniqueness, but below definitions are more like a 'class' of errors/faults

Quoted 16 lines

---
v3:
- Add HW SIG IDS details. (Riana)

---
 drivers/gpu/drm/xe/xe_sig_ids.h | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)
 create mode 100644 drivers/gpu/drm/xe/xe_sig_ids.h
drivers/gpu/drm/xe/xe_sig_ids.h new file +0 -0
new file mode 100644
index 000000000000..7badd0d7ad72

drivers/gpu/drm/xe/xe_sig_ids.h line 10

Quoted 10 lines
drivers/gpu/drm/xe/xe_sig_ids.h new file +10 -0
@@ -0,0 +1,29 @@
+/* SPDX-License-Identifier: MIT */
+/*
+ * Copyright © 2026 Intel Corporation
+ */
+
+#ifndef _XE_SIG_IDS_H_
+#define _XE_SIG_IDS_H_
+
+/*
+ * Driver SIG_IDs

please add kernel-doc for SIG_IDs itself
maybe then it will be clear what is it

based on the "Every GPU fault needs a stable numeric label" maybe the more appropriate name would be names like:

XE_ERROR_
XE_FAULT_

drivers/gpu/drm/xe/xe_sig_ids.h line 18

Quoted 8 lines
drivers/gpu/drm/xe/xe_sig_ids.h new file +8 -0
+ */
+#define XE_SIG_PROBE			1  /* FATAL: probe failed */
+#define XE_SIG_WEDGED			2  /* FATAL: device wedged */
+#define XE_SIG_SURVIVABILITY		3  /* FATAL: survivability mode */
+#define XE_SIG_FW			4  /* RECOVERABLE: GuC/HuC/UC/GSC/CSC/PCODE */
+#define XE_SIG_GT_TDR			5  /* RECOVERABLE: engine hang / reset */
+#define XE_SIG_MEM_FAULT		6  /* RECOVERABLE: VM bind, page fault, GTT */
+#define XE_SIG_IO_BUS			7  /* RECOVERABLE: runtime PCIe/IOMMU/MMIO */

at this patch, there is no description what FATAL or RECOVERABLE (severity?) really means here also, if there is a strict relation between SIG and its severity, then maybe those definitions should look like:

#define XE_SIG_PROBE XE_SIG(1, FATAL)
#define XE_SIG_WEDGED XE_SIG(2, FATAL)
...

but

drivers/gpu/drm/xe/xe_sig_ids.h line 22

Quoted 4 lines
drivers/gpu/drm/xe/xe_sig_ids.h new file +4 -0
+
+/*
+ * HW SIG_IDs
+ */

below SIGs do not have associated severity why the same family of IDs is defined so differently?

drivers/gpu/drm/xe/xe_sig_ids.h line 27

Quoted 5 lines
drivers/gpu/drm/xe/xe_sig_ids.h new file +5 -0
+#define XE_SIG_HW_DEVICE_MEMORY		8  /* Device memory errors (e.g. ECC) */
+#define XE_SIG_HW_CORE_COMPUTE		9  /* Compute/shader core errors */
+#define XE_SIG_HW_PCIE			10 /* PCIe interface errors */
+#define XE_SIG_HW_FABRIC		11 /* On-package fabric errors */
+#define XE_SIG_HW_SOC_INTERNAL		12 /* SoC-internal errors */

what's the plan for extending SW or HW SIG_IDs in the future?
as now it looks that will not be able to have new SW IDs together with old ones

and I guess the goal is to not change the IDs assignments

Quoted 2 lines
drivers/gpu/drm/xe/xe_sig_ids.h new file +2 -0
+
+#endif /* _XE_SIG_IDS_H_ */
#5 lore raw

Re: [RFC PATCH v3 1/3] drm/xe: Add error Signature IDs for RAS logging

Quoted 4 lines · Michal Wajdeczko
Quoted 1 line · Mallesh Koujalagi

Every GPU fault needs a stable numeric label so monitoring tools can

so the goal is to assign unique number to each GPU error that we report?

Thanks for questions, happy to clarify.

Not exactly. SIG_IDs represent types of errors,

not individual events. For example, XE_SIG_WEDGED = 2 just mean a "device wedged" error happened.

Multiple log message can share the same SIG_ID because they belongs to same category.

Quoted 2 lines

can't we teach the monitoring tools to use the message pattern instead?

We can and that is basically what HW_ERR "[Hardware Error]" does today. But that approach is

fragile. If the message tech changes (Wording etc) the pattern can break. So that is reason a

numeric ID like SIG_ID is more stable and acts like a reliable interface, even if the message text changes.

Quoted 5 lines

or maybe it's not about unique signature but rather class of Xe GPU errors? like HW_ERR defined in [1] for generic hardware errors?

[1] https://elixir.bootlin.com/linux/v7.1/source/include/linux/printk.h#L118

Yes, that is the closest comparison. The difference is that SIG_IDs are numeric, specific to Xe

and designed to work with CPER.

Quoted 2 lines
Quoted 1 line

identify what went wrong without parsing log text.

hmm, but they will have to parse this text already to find that ID

Fair point, I'll fix the commit message. Tool can identify what went wrong by matching the stable SIG_ID field,

without relying on message text.

Quoted 3 lines
Quoted 2 lines

Add xe_sig_ids.h
which defines those labels, called SIG_IDs.

SIG_ID looks like an acronym already - can we know the full real name?

SIG_ID expands to “Signature ID.” which is mentioned in the Spec.

Quoted 2 lines

the 'signature' suggests uniqueness, but below definitions are more like a 'class' of errors/faults

It designed function as a stable component/category identifier for a class of errors, with the specific cause carried separately

errno, message text etc.

Quoted 19 lines
Quoted 19 lines

---
v3:
- Add HW SIG IDS details. (Riana)

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

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

drivers/gpu/drm/xe/xe_sig_ids.h new file +4 -0
new file mode 100644
index 000000000000..7badd0d7ad72
@@ -0,0 +1,29 @@
+/* SPDX-License-Identifier: MIT */
+/*
+ * Copyright © 2026 Intel Corporation
+ */
Quoted 8 lines

drivers/gpu/drm/xe/xe_sig_ids.h line 10

Quoted 6 lines
drivers/gpu/drm/xe/xe_sig_ids.h new file +6 -0
+
+#ifndef _XE_SIG_IDS_H_
+#define _XE_SIG_IDS_H_
+
+/*
+ * Driver SIG_IDs

please add kernel-doc for SIG_IDs itself
maybe then it will be clear what is it

Sure, will add in next revision.

Quoted 7 lines

based on the "Every GPU fault needs a stable numeric label" maybe the more appropriate name would be names like:

XE_ERROR_
XE_FAULT_

Agreed, need to check with Arch team.

Quoted 11 lines

drivers/gpu/drm/xe/xe_sig_ids.h line 18

Quoted 8 lines
drivers/gpu/drm/xe/xe_sig_ids.h new file +8 -0
+ */
+#define XE_SIG_PROBE			1  /* FATAL: probe failed */
+#define XE_SIG_WEDGED			2  /* FATAL: device wedged */
+#define XE_SIG_SURVIVABILITY		3  /* FATAL: survivability mode */
+#define XE_SIG_FW			4  /* RECOVERABLE: GuC/HuC/UC/GSC/CSC/PCODE */
+#define XE_SIG_GT_TDR			5  /* RECOVERABLE: engine hang / reset */
+#define XE_SIG_MEM_FAULT		6  /* RECOVERABLE: VM bind, page fault, GTT */
+#define XE_SIG_IO_BUS			7  /* RECOVERABLE: runtime PCIe/IOMMU/MMIO */

at this patch, there is no description what FATAL or RECOVERABLE (severity?) really means here also, if there is a strict relation between SIG and its severity, then maybe those definitions should look like:

Quoted 5 lines

#define XE_SIG_PROBE XE_SIG(1, FATAL)
#define XE_SIG_WEDGED XE_SIG(2, FATAL)
...

but

Agreed. For driver SIG_IDs, severity is part of the contract, not just an incidental comment.

Sure, I can add the severity details in the header.

Quoted 6 lines

drivers/gpu/drm/xe/xe_sig_ids.h line 22

Quoted 4 lines
drivers/gpu/drm/xe/xe_sig_ids.h new file +4 -0
+
+/*
+ * HW SIG_IDs
+ */

below SIGs do not have associated severity why the same family of IDs is defined so differently?

This is intentional. Driver SIG_IDs are paired with fixed severities via the driver logging macros,

while Hardware SIG_IDs identify only the hardware component. Hardware severity is not fixed per SIG_ID,

it is carried by the incoming CPER record and may vary per event.

Quoted 6 lines

drivers/gpu/drm/xe/xe_sig_ids.h line 27

Quoted 5 lines
drivers/gpu/drm/xe/xe_sig_ids.h new file +5 -0
+#define XE_SIG_HW_DEVICE_MEMORY		8  /* Device memory errors (e.g. ECC) */
+#define XE_SIG_HW_CORE_COMPUTE		9  /* Compute/shader core errors */
+#define XE_SIG_HW_PCIE			10 /* PCIe interface errors */
+#define XE_SIG_HW_FABRIC		11 /* On-package fabric errors */
+#define XE_SIG_HW_SOC_INTERNAL		12 /* SoC-internal errors */

what's the plan for extending SW or HW SIG_IDs in the future?

The current scheme assumes driver IDs are a fixed low range and HW IDs occupy the next contiguous range,

with range alone distinguishing Driver vs Hardware.

Quoted 3 lines

as now it looks that will not be able to have new SW IDs together with old ones

and I guess the goal is to not change the IDs assignments

Yes, the stated goal is stable IDs.

Thanks,

-/Mallesh

Quoted 3 lines
Quoted 3 lines
drivers/gpu/drm/xe/xe_sig_ids.h new file +2 -0
+
+#endif /* _XE_SIG_IDS_H_ */
#6 lore raw

RFC PATCH v3 2/3 drm/xe: Add RAS logging helpers

In reply to Mallesh Koujalagi

Add xe_ras_log.c and xe_ras_log.h so the driver can report faults in a structured, machine-readable way.

The core is __xe_ras_log(), which emits a single log line with:
SIG_ID, severity, location (device or tile/GT), errno, and message. Fatal faults go to drm_err(); recoverable ones to drm_warn().

---
v3:
- Refer "Tile%u" and "GT%u" strings. (Michal Wajdeczko)
- Remov xe_cper_severity_str(). (Michal Wajdeczko/Riana)
- Move __xe_ras_log() function to xe_ras_log.h. (Michal Wajdeczko)
- Make macro function properly.
- Remove *_FIRST and *_LAST macro. (Michal Wajdeczko/Riana)
- Add sig id documents. (Riana)
- Change macro function same prefix as the file.
- Handle __xe_ras_log() function with variable format.

---
 drivers/gpu/drm/xe/Makefile     |   1 +
 drivers/gpu/drm/xe/xe_ras_log.c |  63 +++++++++++++++++++
 drivers/gpu/drm/xe/xe_ras_log.h | 108 ++++++++++++++++++++++++++++++++
 3 files changed, 172 insertions(+)
 create mode 100644 drivers/gpu/drm/xe/xe_ras_log.c
 create mode 100644 drivers/gpu/drm/xe/xe_ras_log.h
drivers/gpu/drm/xe/Makefile +1 -0
index 8e7b146880f4..607c9b099d03 100644
@@ -114,6 +114,7 @@ xe-y += xe_bb.o \
 	xe_query.o \
 	xe_range_fence.o \
 	xe_ras.o \
+	xe_ras_log.o \
 	xe_reg_sr.o \
 	xe_reg_whitelist.o \
 	xe_ring_ops.o \
drivers/gpu/drm/xe/xe_ras_log.c new file +63 -0

63 lines not on this page · raw message

drivers/gpu/drm/xe/xe_ras_log.h new file +108 -0

108 lines not on this page · raw message

Signature · 1 line
2.34.1
#7 lore raw

Re: [RFC PATCH v3 2/3] drm/xe: Add RAS logging helpers

Quoted 47 lines · Mallesh Koujalagi

Add xe_ras_log.c and xe_ras_log.h so the driver can report faults in a structured, machine-readable way.

The core is __xe_ras_log(), which emits a single log line with:
SIG_ID, severity, location (device or tile/GT), errno, and message. Fatal faults go to drm_err(); recoverable ones to drm_warn().

---
v3:
- Refer "Tile%u" and "GT%u" strings. (Michal Wajdeczko)
- Remov xe_cper_severity_str(). (Michal Wajdeczko/Riana)
- Move __xe_ras_log() function to xe_ras_log.h. (Michal Wajdeczko)
- Make macro function properly.
- Remove *_FIRST and *_LAST macro. (Michal Wajdeczko/Riana)
- Add sig id documents. (Riana)
- Change macro function same prefix as the file.
- Handle __xe_ras_log() function with variable format.

---
  drivers/gpu/drm/xe/Makefile     |   1 +
  drivers/gpu/drm/xe/xe_ras_log.c |  63 +++++++++++++++++++
  drivers/gpu/drm/xe/xe_ras_log.h | 108 ++++++++++++++++++++++++++++++++
  3 files changed, 172 insertions(+)

create mode 100644 drivers/gpu/drm/xe/xe_ras_log.c create mode 100644 drivers/gpu/drm/xe/xe_ras_log.h

drivers/gpu/drm/xe/Makefile +1 -0
index 8e7b146880f4..607c9b099d03 100644
@@ -114,6 +114,7 @@ xe-y += xe_bb.o \
  	xe_query.o \
  	xe_range_fence.o \
  	xe_ras.o \
+	xe_ras_log.o \
  	xe_reg_sr.o \
  	xe_reg_whitelist.o \
  	xe_ring_ops.o \
drivers/gpu/drm/xe/xe_ras_log.c new file +3 -0
new file mode 100644
index 000000000000..0e836ef5dcf6
@@ -0,0 +1,63 @@
+// SPDX-License-Identifier: MIT
+/*
+ * Copyright © 2026 Intel Corporation

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

Quoted 10 lines
drivers/gpu/drm/xe/xe_ras_log.c new file +10 -0
+ */
+
+#include <drm/drm_print.h>
+
+#include "xe_device.h"
+#include "xe_gt.h"
+#include "xe_ras_log.h"
+
+/**
+ * __xe_ras_log - Emit a structured RAS log entry

Why __?

drivers/gpu/drm/xe/xe_ras_log.c line 17

Quoted 4 lines
drivers/gpu/drm/xe/xe_ras_log.c new file +4 -0
+ * @xe: xe device instance
+ * @gt: GT instance where the error occurred, or NULL if device-wide
+ * @sig_id: signature ID from xe_sig_ids.h identifying the error class
+ * @cper_sev: CPER severity (one of CPER_SEV_FATAL, CPER_SEV_RECOVERABLE, etc.)

Add enum  name instead

drivers/gpu/drm/xe/xe_ras_log.c line 18

Quoted 1 line
drivers/gpu/drm/xe/xe_ras_log.c new file +1 -0
+ * @errno_val: negative errno describing the error condition

Why do we need error no?

drivers/gpu/drm/xe/xe_ras_log.c line 27

Quoted 9 lines
drivers/gpu/drm/xe/xe_ras_log.c new file +9 -0
+ * @fmt: printf-style format string
+ * @...: format arguments
+ *
+ * Formats the message and emits a kernel log line via drm_err() for fatal
+ * events or drm_warn() for all others. CPER record generation and hex dump
+ * are planned as follow-ups.
+ *
+ * Format:
+ *   [xe-err] SIG_ID = <id> Severity = <sev> Location = <loc> Errno = <n> Message = "<msg>"

You are using both error and warn but here it's only xe-err. Isn't this misleading?

Quoted 49 lines
drivers/gpu/drm/xe/xe_ras_log.c new file +36 -0
+ */
+__printf(6, 7)
+void __xe_ras_log(struct xe_device *xe, struct xe_gt *gt,
+		  u16 sig_id, u32 cper_sev, int errno_val,
+		  const char *fmt, ...)
+{
+	char loc[32];
+	struct va_format vaf;
+	va_list ap;
+
+	if (gt)
+		snprintf(loc, sizeof(loc), "tile%u/gt%u",
+			 gt->tile->id, gt->info.id);
+	else
+		snprintf(loc, sizeof(loc), "device");
+
+	va_start(ap, fmt);
+	vaf.fmt = fmt;
+	vaf.va = &ap;
+
+	if (cper_sev == CPER_SEV_FATAL)
+		drm_err(&xe->drm,
+			"[xe-err] SIG_ID = %u Severity = %s Location = %s Errno = %d Message = \"%pV\"",
+			sig_id, cper_severity_str(cper_sev), loc,
+			errno_val, &vaf);
+	else
+		drm_warn(&xe->drm,
+			 "[xe-err] SIG_ID = %u Severity = %s Location = %s Errno = %d Message = \"%pV\"",
+			 sig_id, cper_severity_str(cper_sev), loc,
+			 errno_val, &vaf);
+
+	va_end(ap);
+
+	/* TODO: Add CPER record driver handler */
+	/* TODO: Add RAS dump cper hex handler */
+}
drivers/gpu/drm/xe/xe_ras_log.h new file +7 -0
new file mode 100644
index 000000000000..08318dea75a9
@@ -0,0 +1,108 @@
+/* SPDX-License-Identifier: MIT */
+/*
+ * Copyright © 2026 Intel Corporation
+ */
+
+#ifndef _XE_RAS_LOG_H_
+#define _XE_RAS_LOG_H_

drivers/gpu/drm/xe/xe_ras_log.h line 17

Quoted 10 lines
drivers/gpu/drm/xe/xe_ras_log.h new file +10 -0
+
+#include <linux/cper.h>
+
+#include "xe_sig_ids.h"
+
+struct xe_device;
+struct xe_gt;
+
+/**
+ * DOC: RAS structured logging and SIG_IDs

Link this document.  Add a  brief heading

drivers/gpu/drm/xe/xe_ras_log.h line 20

Quoted 3 lines
drivers/gpu/drm/xe/xe_ras_log.h new file +3 -0
+ *
+ * What this file is for
+ * ---------------------

Once  this document is generated.
"this file" does not indicate what you are referring to. Use general doc headings

drivers/gpu/drm/xe/xe_ras_log.h line 26

Quoted 6 lines
drivers/gpu/drm/xe/xe_ras_log.h new file +6 -0
+ * Use the xe_ras_log_*() macros to report faults in a
+ * machine-readable way.
+ *
+ * What is a SIG_ID?
+ * -----------------
+ * A SIG_ID (defined in xe_sig_ids.h) is a stable numeric error class.

Add full form. Define what is SIG ID

drivers/gpu/drm/xe/xe_ras_log.h line 31

Quoted 5 lines
drivers/gpu/drm/xe/xe_ras_log.h new file +5 -0
+ * It tells tooling what kind of fault happened, independent of message text.
+ *
+ * Driver SIG_ID classes:
+ *   XE_SIG_PROBE         - probe/init failure
+ *   XE_SIG_WEDGED        - device unrecoverable

wedged does not mean device is not recoverable

drivers/gpu/drm/xe/xe_ras_log.h line 32

Quoted 2 lines
drivers/gpu/drm/xe/xe_ras_log.h new file +1 -0
+ *   XE_SIG_SURVIVABILITY - degraded/safe mode

not really safe mode. Please use actual definition

drivers/gpu/drm/xe/xe_ras_log.h line 44

Quoted 12 lines
drivers/gpu/drm/xe/xe_ras_log.h new file +12 -0
+ *   XE_SIG_FW            - firmware fault (GuC/HuC/GSC/CSC/PCODE)
+ *   XE_SIG_GT_TDR        - engine hang or GT reset (TDR)
+ *   XE_SIG_MEM_FAULT     - VM/page-fault/GTT error
+ *   XE_SIG_IO_BUS        - PCIe/IOMMU/MMIO bus error
+ *
+ * HW SIG_ID classes are hardware-defined categories, reported by firmware via
+ * CPER records (for example XE_SIG_HW_DEVICE_MEMORY). Driver code does not
+ * emit HW SIG_IDs directly.
+ *   XE_SIG_HW_DEVICE_MEMORY  - device memory errors (e.g. ECC)
+ *   XE_SIG_HW_CORE_COMPUTE   - compute/shader core errors
+ *   XE_SIG_HW_PCIE           - PCIe interface errors
+ *   XE_SIG_HW_FABRIC         - on-package fabric errors

on-package?

drivers/gpu/drm/xe/xe_ras_log.h line 50

Quoted 6 lines
drivers/gpu/drm/xe/xe_ras_log.h new file +6 -0
+ *   XE_SIG_HW_SOC_INTERNAL   - SoC-internal errors
+ *
+ * Why this exists
+ * ---------------
+ * SIG_IDs let RAS tools parse logs reliably, correlate CPER events, and apply
+ * policy/thresholding without depending on fragile string matching.

What do you mean?

drivers/gpu/drm/xe/xe_ras_log.h line 56

Quoted 6 lines
drivers/gpu/drm/xe/xe_ras_log.h new file +6 -0
+ *
+ * When to use xe_ras_log_*()
+ * --------------------------
+ * Use these macros when the event is:
+ *   1) a real hardware/firmware fault,
+ *   2) relevant to production monitoring, and

How does one decide if it's relevant?

Quoted 29 lines
drivers/gpu/drm/xe/xe_ras_log.h new file +29 -0
+ *   3) clearly mapped to one SIG_ID class.
+ *
+ * Do not use for all logs
+ * -----------------------
+ * Keep regular debug/info/driver-state messages on standard logging helpers
+ * (xe_gt_dbg(), xe_gt_info(), xe_gt_warn(), xe_gt_err(), drm_dbg(), drm_info()).
+ * RAS macros are for structured fault reporting only.
+ */
+
+/*
+ * Common backend helper
+ */
+__printf(6, 7)
+void __xe_ras_log(struct xe_device *xe, struct xe_gt *gt,
+		  u16 sig_id, u32 cper_sev, int errno_val,
+		  const char *fmt, ...);
+
+/*
+ * Driver-facing reporting macros
+ */
+
+/* FATAL */
+#define xe_ras_log_probe(xe, errno, fmt, ...) \
+	__xe_ras_log((xe), NULL, XE_SIG_PROBE, CPER_SEV_FATAL, \
+		     (errno), fmt, ##__VA_ARGS__)
+
+#define xe_ras_log_wedged(xe, errno, fmt, ...) \
+	__xe_ras_log((xe), NULL, XE_SIG_WEDGED, CPER_SEV_FATAL, \
+		     (errno), fmt, ##__VA_ARGS__)

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

Quoted 10 lines
drivers/gpu/drm/xe/xe_ras_log.h new file +10 -0
+
+#define xe_ras_log_survivability(xe, errno, fmt, ...) \
+	__xe_ras_log((xe), NULL, XE_SIG_SURVIVABILITY, CPER_SEV_FATAL, \
+		     (errno), fmt, ##__VA_ARGS__)
+
+/* RECOVERABLE */
+#define xe_ras_log_fw(xe, gt, errno, fmt, ...) \
+	__xe_ras_log((xe), (gt), XE_SIG_FW, CPER_SEV_RECOVERABLE, \
+		     (errno), fmt, ##__VA_ARGS__)
+

Why force a type of severity here?

Thanks
Riana

Quoted 13 lines
drivers/gpu/drm/xe/xe_ras_log.h new file +13 -0
+#define xe_ras_log_gt_tdr(xe, gt, errno, fmt, ...) \
+	__xe_ras_log((xe), (gt), XE_SIG_GT_TDR, CPER_SEV_RECOVERABLE, \
+		     (errno), fmt, ##__VA_ARGS__)
+
+#define xe_ras_log_mem_fault(xe, gt, errno, fmt, ...) \
+	__xe_ras_log((xe), (gt), XE_SIG_MEM_FAULT, CPER_SEV_RECOVERABLE, \
+		     (errno), fmt, ##__VA_ARGS__)
+
+#define xe_ras_log_io_bus(xe, errno, fmt, ...) \
+	__xe_ras_log((xe), NULL, XE_SIG_IO_BUS, CPER_SEV_RECOVERABLE, \
+		     (errno), fmt, ##__VA_ARGS__)
+
+#endif /* _XE_RAS_LOG_H_ */
#8 lore raw

Re: [RFC PATCH v3 2/3] drm/xe: Add RAS logging helpers

Quoted 53 lines · Riana
Quoted 51 lines · Mallesh Koujalagi

Add xe_ras_log.c and xe_ras_log.h so the driver can report faults in a structured, machine-readable way.

The core is __xe_ras_log(), which emits a single log line with:
SIG_ID, severity, location (device or tile/GT), errno, and message. Fatal faults go to drm_err(); recoverable ones to drm_warn().

---
v3:
- Refer "Tile%u" and "GT%u" strings. (Michal Wajdeczko)
- Remov xe_cper_severity_str(). (Michal Wajdeczko/Riana)
- Move __xe_ras_log() function to xe_ras_log.h. (Michal Wajdeczko)
- Make macro function properly.
- Remove *_FIRST and *_LAST macro. (Michal Wajdeczko/Riana)
- Add sig id documents. (Riana)
- Change macro function same prefix as the file.
- Handle __xe_ras_log() function with variable format.
---
  drivers/gpu/drm/xe/Makefile     |   1 + drivers/gpu/drm/xe/xe_ras_log.c |  63 +++++++++++++++++++ drivers/gpu/drm/xe/xe_ras_log.h | 108 ++++++++++++++++++++++++++++++++

  3 files changed, 172 insertions(+)

  create mode 100644 drivers/gpu/drm/xe/xe_ras_log.c create mode 100644 drivers/gpu/drm/xe/xe_ras_log.h

drivers/gpu/drm/xe/Makefile +1 -0
index 8e7b146880f4..607c9b099d03 100644
@@ -114,6 +114,7 @@ xe-y += xe_bb.o \
       xe_query.o \
       xe_range_fence.o \
       xe_ras.o \
+    xe_ras_log.o \
       xe_reg_sr.o \
       xe_reg_whitelist.o \
       xe_ring_ops.o \
drivers/gpu/drm/xe/xe_ras_log.c new file +7 -0
new file mode 100644
index 000000000000..0e836ef5dcf6
@@ -0,0 +1,63 @@
+// SPDX-License-Identifier: MIT
+/*
+ * Copyright © 2026 Intel Corporation
+ */
+
+#include <drm/drm_print.h>
+
Quoted 9 lines

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

Quoted 6 lines
drivers/gpu/drm/xe/xe_ras_log.c new file +6 -0
+#include "xe_device.h"
+#include "xe_gt.h"
+#include "xe_ras_log.h"
+
+/**
+ * __xe_ras_log - Emit a structured RAS log entry

Why __?

The __ prefix follows the kernel convention for the function that are not meant

to be called directly. In this case __xe_ras_log() is the backend implementation, callers

are expected to use the type-safe macros like xe_ras_log_wedged() etc.

Same pattern used elewhere in the kernel e.g. __dev_err()/dev_err().

Quoted 7 lines
Quoted 5 lines
drivers/gpu/drm/xe/xe_ras_log.c new file +4 -0
+ * @xe: xe device instance
+ * @gt: GT instance where the error occurred, or NULL if device-wide
+ * @sig_id: signature ID from xe_sig_ids.h identifying the error class
+ * @cper_sev: CPER severity (one of CPER_SEV_FATAL, 

CPER_SEV_RECOVERABLE, etc.)

Add enum  name instead

The CPER_SEV_* values are defined as macros in <linux/cper.h>, not as an enum,

so there isn't an enum type name to reference here.

Quoted 4 lines
Quoted 2 lines

+ * @errno_val: negative errno describing the error condition

Why do we need error no?

The errno provides a stable, machine-readable error code along with the log message.

This helps monitoring tools and scripts interpret the issue correctly—for example,

-EIO on a wedge event indicates the device is no longer responding to I/O.

Quoted 13 lines
Quoted 4 lines

+ * @fmt: printf-style format string
+ * @...: format arguments
+ *
+ * Formats the message and emits a kernel log line via drm_err() for

Quoted 8 lines

fatal
+ * events or drm_warn() for all others. CPER record generation and hex dump
+ * are planned as follow-ups.
+ *
+ * Format:
+ *   [xe-err] SIG_ID = <id> Severity = <sev> Location = <loc> Errno = <n> Message = "<msg>"

Quoted 3 lines

You are using both error and warn but here it's only xe-err. Isn't this misleading?

Good catch, I’ll update this in the next revision to reflect both xe-err and xe-warn appropriately.

Quoted 55 lines
Quoted 55 lines

+ */

drivers/gpu/drm/xe/xe_ras_log.c new file +22 -0
+__printf(6, 7)
+void __xe_ras_log(struct xe_device *xe, struct xe_gt *gt,
+          u16 sig_id, u32 cper_sev, int errno_val,
+          const char *fmt, ...)
+{
+    char loc[32];
+    struct va_format vaf;
+    va_list ap;
+
+    if (gt)
+        snprintf(loc, sizeof(loc), "tile%u/gt%u",
+             gt->tile->id, gt->info.id);
+    else
+        snprintf(loc, sizeof(loc), "device");
+
+    va_start(ap, fmt);
+    vaf.fmt = fmt;
+    vaf.va = &ap;
+
+    if (cper_sev == CPER_SEV_FATAL)
+        drm_err(&xe->drm,
+            "[xe-err] SIG_ID = %u Severity = %s Location = %s Errno 

= %d Message = \"%pV\"",
+            sig_id, cper_severity_str(cper_sev), loc,
+            errno_val, &vaf);
+    else
+        drm_warn(&xe->drm,
+             "[xe-err] SIG_ID = %u Severity = %s Location = %s Errno = %d Message = \"%pV\"",
+             sig_id, cper_severity_str(cper_sev), loc,
+             errno_val, &vaf);

drivers/gpu/drm/xe/xe_ras_log.c new file +6 -0
+
+    va_end(ap);
+
+    /* TODO: Add CPER record driver handler */
+    /* TODO: Add RAS dump cper hex handler */
+}
drivers/gpu/drm/xe/xe_ras_log.h new file +11 -0
new file mode 100644
index 000000000000..08318dea75a9
@@ -0,0 +1,108 @@
+/* SPDX-License-Identifier: MIT */
+/*
+ * Copyright © 2026 Intel Corporation
+ */
+
+#ifndef _XE_RAS_LOG_H_
+#define _XE_RAS_LOG_H_
+
+#include <linux/cper.h>
+
+#include "xe_sig_ids.h"
Quoted 9 lines

drivers/gpu/drm/xe/xe_ras_log.h line 17

Quoted 6 lines
drivers/gpu/drm/xe/xe_ras_log.h new file +6 -0
+
+struct xe_device;
+struct xe_gt;
+
+/**
+ * DOC: RAS structured logging and SIG_IDs

Link this document.  Add a  brief heading

I’ll update this with a proper heading and link to the documentation.

Quoted 8 lines

drivers/gpu/drm/xe/xe_ras_log.h line 20

Quoted 3 lines
drivers/gpu/drm/xe/xe_ras_log.h new file +3 -0
+ *
+ * What this file is for
+ * ---------------------

Once  this document is generated.
"this file" does not indicate what you are referring to. Use general doc headings

Agreed, I’ll rework the wording to use proper documentation-style headings.

Quoted 9 lines

drivers/gpu/drm/xe/xe_ras_log.h line 26

Quoted 6 lines
drivers/gpu/drm/xe/xe_ras_log.h new file +6 -0
+ * Use the xe_ras_log_*() macros to report faults in a
+ * machine-readable way.
+ *
+ * What is a SIG_ID?
+ * -----------------
+ * A SIG_ID (defined in xe_sig_ids.h) is a stable numeric error class.

Add full form. Define what is SIG ID

Good point, I’ll expand and define SIG_ID clearly in the next revision.

Quoted 8 lines
Quoted 6 lines
drivers/gpu/drm/xe/xe_ras_log.h new file +1 -0
+ * It tells tooling what kind of fault happened, independent of 

message text.
+ *
+ * Driver SIG_ID classes:
+ *   XE_SIG_PROBE         - probe/init failure
+ *   XE_SIG_WEDGED        - device unrecoverable

wedged does not mean device is not recoverable

You’re right, I’ll fix the wording to avoid implying it’s always unrecoverable.

Quoted 5 lines
Quoted 3 lines

+ *   XE_SIG_SURVIVABILITY - degraded/safe mode

not really safe mode. Please use actual definition

Agreed, “safe mode” is not accurate. I’ll update it with a more precise description

Quoted 16 lines
Quoted 15 lines

+ *   XE_SIG_FW            - firmware fault (GuC/HuC/GSC/CSC/PCODE)
+ *   XE_SIG_GT_TDR        - engine hang or GT reset (TDR)
+ *   XE_SIG_MEM_FAULT     - VM/page-fault/GTT error
+ *   XE_SIG_IO_BUS        - PCIe/IOMMU/MMIO bus error
+ *
+ * HW SIG_ID classes are hardware-defined categories, reported by firmware via
+ * CPER records (for example XE_SIG_HW_DEVICE_MEMORY). Driver code does not
+ * emit HW SIG_IDs directly.
+ *   XE_SIG_HW_DEVICE_MEMORY  - device memory errors (e.g. ECC)
+ *   XE_SIG_HW_CORE_COMPUTE   - compute/shader core errors
+ *   XE_SIG_HW_PCIE           - PCIe interface errors
+ *   XE_SIG_HW_FABRIC         - on-package fabric errors

Quoted 2 lines

on-package?

It refers to the high speed interconnect between dies/tiles within the same GPU.

I'll make the comment clearer in next revision.

Quoted 10 lines
Quoted 7 lines

+ *   XE_SIG_HW_SOC_INTERNAL   - SoC-internal errors
+ *
+ * Why this exists
+ * ---------------
+ * SIG_IDs let RAS tools parse logs reliably, correlate CPER events, and apply
+ * policy/thresholding without depending on fragile string matching.

What do you mean?

I’ll rewrite this section to make it more concrete and easier to understand.

Quoted 9 lines
Quoted 6 lines

+ *
+ * When to use xe_ras_log_*()
+ * --------------------------
+ * Use these macros when the event is:
+ *   1) a real hardware/firmware fault,
+ *   2) relevant to production monitoring, and

How does one decide if it's relevant?

That’s a fair point. I’ll replace this with clearer, more concrete guidance.

Quoted 35 lines
Quoted 35 lines

+ *   3) clearly mapped to one SIG_ID class.
+ *
+ * Do not use for all logs
+ * -----------------------
+ * Keep regular debug/info/driver-state messages on standard logging helpers
+ * (xe_gt_dbg(), xe_gt_info(), xe_gt_warn(), xe_gt_err(), drm_dbg(), drm_info()).
+ * RAS macros are for structured fault reporting only.
+ */

drivers/gpu/drm/xe/xe_ras_log.h new file +25 -0
+
+/*
+ * Common backend helper
+ */
+__printf(6, 7)
+void __xe_ras_log(struct xe_device *xe, struct xe_gt *gt,
+          u16 sig_id, u32 cper_sev, int errno_val,
+          const char *fmt, ...);
+
+/*
+ * Driver-facing reporting macros
+ */
+
+/* FATAL */
+#define xe_ras_log_probe(xe, errno, fmt, ...) \
+    __xe_ras_log((xe), NULL, XE_SIG_PROBE, CPER_SEV_FATAL, \
+             (errno), fmt, ##__VA_ARGS__)
+
+#define xe_ras_log_wedged(xe, errno, fmt, ...) \
+    __xe_ras_log((xe), NULL, XE_SIG_WEDGED, CPER_SEV_FATAL, \
+             (errno), fmt, ##__VA_ARGS__)
+
+#define xe_ras_log_survivability(xe, errno, fmt, ...) \
+    __xe_ras_log((xe), NULL, XE_SIG_SURVIVABILITY, CPER_SEV_FATAL, \
+             (errno), fmt, ##__VA_ARGS__)
Quoted 8 lines

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

Quoted 6 lines
drivers/gpu/drm/xe/xe_ras_log.h new file +6 -0
+
+/* RECOVERABLE */
+#define xe_ras_log_fw(xe, gt, errno, fmt, ...) \
+    __xe_ras_log((xe), (gt), XE_SIG_FW, CPER_SEV_RECOVERABLE, \
+             (errno), fmt, ##__VA_ARGS__)
+

Why force a type of severity here?

Good point, I’ll check with the architecture team and update accordingly.

Thanks,

-/Mallesh

Quoted 17 lines

Thanks
Riana

Quoted 13 lines
drivers/gpu/drm/xe/xe_ras_log.h new file +13 -0
+#define xe_ras_log_gt_tdr(xe, gt, errno, fmt, ...) \
+    __xe_ras_log((xe), (gt), XE_SIG_GT_TDR, CPER_SEV_RECOVERABLE, \
+             (errno), fmt, ##__VA_ARGS__)
+
+#define xe_ras_log_mem_fault(xe, gt, errno, fmt, ...) \
+    __xe_ras_log((xe), (gt), XE_SIG_MEM_FAULT, CPER_SEV_RECOVERABLE, \
+             (errno), fmt, ##__VA_ARGS__)
+
+#define xe_ras_log_io_bus(xe, errno, fmt, ...) \
+    __xe_ras_log((xe), NULL, XE_SIG_IO_BUS, CPER_SEV_RECOVERABLE, \
+             (errno), fmt, ##__VA_ARGS__)
+
+#endif /* _XE_RAS_LOG_H_ */
#9 lore raw

Re: [RFC PATCH v3 2/3] drm/xe: Add RAS logging helpers

In reply to Mallesh Koujalagi
Quoted 2 lines · Mallesh Koujalagi

Add xe_ras_log.c and xe_ras_log.h so the driver can report faults in a structured, machine-readable way.

hmm, but the dmesg logs are mostly for the human admins, no?

Quoted 3 lines

The core is __xe_ras_log(), which emits a single log line with:
SIG_ID, severity, location (device or tile/GT), errno, and message.

our dmesg logs are already to some extend structured as they contain:

severity: <3>
driver name: xe
device name: 0000:00:02.0
subsystem name: [drm]
error tag: *ERROR*
location: Tile0:
Tile0: GT0:
message: GuC mmio request ...

Quoted 1 line

Fatal faults go to drm_err(); recoverable ones to drm_warn().

note that we already have xe_err() and xe_warn() wrappers

Quoted 85 lines

---
v3:
- Refer "Tile%u" and "GT%u" strings. (Michal Wajdeczko)
- Remov xe_cper_severity_str(). (Michal Wajdeczko/Riana)
- Move __xe_ras_log() function to xe_ras_log.h. (Michal Wajdeczko)
- Make macro function properly.
- Remove *_FIRST and *_LAST macro. (Michal Wajdeczko/Riana)
- Add sig id documents. (Riana)
- Change macro function same prefix as the file.
- Handle __xe_ras_log() function with variable format.

---
 drivers/gpu/drm/xe/Makefile     |   1 +
 drivers/gpu/drm/xe/xe_ras_log.c |  63 +++++++++++++++++++
 drivers/gpu/drm/xe/xe_ras_log.h | 108 ++++++++++++++++++++++++++++++++
 3 files changed, 172 insertions(+)
 create mode 100644 drivers/gpu/drm/xe/xe_ras_log.c
 create mode 100644 drivers/gpu/drm/xe/xe_ras_log.h
drivers/gpu/drm/xe/Makefile +1 -0
index 8e7b146880f4..607c9b099d03 100644
@@ -114,6 +114,7 @@ xe-y += xe_bb.o \
 	xe_query.o \
 	xe_range_fence.o \
 	xe_ras.o \
+	xe_ras_log.o \
 	xe_reg_sr.o \
 	xe_reg_whitelist.o \
 	xe_ring_ops.o \
drivers/gpu/drm/xe/xe_ras_log.c new file +47 -0
new file mode 100644
index 000000000000..0e836ef5dcf6
@@ -0,0 +1,63 @@
+// SPDX-License-Identifier: MIT
+/*
+ * Copyright © 2026 Intel Corporation
+ */
+
+#include <drm/drm_print.h>
+
+#include "xe_device.h"
+#include "xe_gt.h"
+#include "xe_ras_log.h"
+
+/**
+ * __xe_ras_log - Emit a structured RAS log entry
+ * @xe: xe device instance
+ * @gt: GT instance where the error occurred, or NULL if device-wide
+ * @sig_id: signature ID from xe_sig_ids.h identifying the error class
+ * @cper_sev: CPER severity (one of CPER_SEV_FATAL, CPER_SEV_RECOVERABLE, etc.)
+ * @errno_val: negative errno describing the error condition
+ * @fmt: printf-style format string
+ * @...: format arguments
+ *
+ * Formats the message and emits a kernel log line via drm_err() for fatal
+ * events or drm_warn() for all others. CPER record generation and hex dump
+ * are planned as follow-ups.
+ *
+ * Format:
+ *   [xe-err] SIG_ID = <id> Severity = <sev> Location = <loc> Errno = <n> Message = "<msg>"
+ */
+__printf(6, 7)
+void __xe_ras_log(struct xe_device *xe, struct xe_gt *gt,
+		  u16 sig_id, u32 cper_sev, int errno_val,
+		  const char *fmt, ...)
+{
+	char loc[32];
+	struct va_format vaf;
+	va_list ap;
+
+	if (gt)
+		snprintf(loc, sizeof(loc), "tile%u/gt%u",
+			 gt->tile->id, gt->info.id);
+	else
+		snprintf(loc, sizeof(loc), "device");
+
+	va_start(ap, fmt);
+	vaf.fmt = fmt;
+	vaf.va = &ap;
+

drivers/gpu/drm/xe/xe_ras_log.c line 57

Quoted 10 lines
drivers/gpu/drm/xe/xe_ras_log.c new file +10 -0
+	if (cper_sev == CPER_SEV_FATAL)
+		drm_err(&xe->drm,
+			"[xe-err] SIG_ID = %u Severity = %s Location = %s Errno = %d Message = \"%pV\"",
+			sig_id, cper_severity_str(cper_sev), loc,
+			errno_val, &vaf);
+	else
+		drm_warn(&xe->drm,
+			 "[xe-err] SIG_ID = %u Severity = %s Location = %s Errno = %d Message = \"%pV\"",
+			 sig_id, cper_severity_str(cper_sev), loc,
+			 errno_val, &vaf);

again, this is not a very friendly message for the human admin

can't we just add severity/id pair to our updated xe_printk macros, like

	xe_err_fatal(xe, id, fmt, ...)
	xe_err_recoverable(xe, id, fmt, ...)

	xe_gt_err_fatal(gt, id, fmt, ...)
	xe_gt_err_recoverable(gt, id, fmt, ...)

and print sev/id pair within single tag:

	0000:02.0 xe [drm] *ERROR* [ID=123456] *FATAL* format ...
Quoted 28 lines
drivers/gpu/drm/xe/xe_ras_log.c new file +6 -0
+
+	va_end(ap);
+
+	/* TODO: Add CPER record driver handler */
+	/* TODO: Add RAS dump cper hex handler */
+}
drivers/gpu/drm/xe/xe_ras_log.h new file +16 -0
new file mode 100644
index 000000000000..08318dea75a9
@@ -0,0 +1,108 @@
+/* SPDX-License-Identifier: MIT */
+/*
+ * Copyright © 2026 Intel Corporation
+ */
+
+#ifndef _XE_RAS_LOG_H_
+#define _XE_RAS_LOG_H_
+
+#include <linux/cper.h>
+
+#include "xe_sig_ids.h"
+
+struct xe_device;
+struct xe_gt;
+
+/**

drivers/gpu/drm/xe/xe_ras_log.h line 26

Quoted 10 lines
drivers/gpu/drm/xe/xe_ras_log.h new file +10 -0
+ * DOC: RAS structured logging and SIG_IDs
+ *
+ * What this file is for
+ * ---------------------
+ * Use the xe_ras_log_*() macros to report faults in a
+ * machine-readable way.
+ *
+ * What is a SIG_ID?
+ * -----------------
+ * A SIG_ID (defined in xe_sig_ids.h) is a stable numeric error class.

hmm, so a SIG is now a CLASS ?
in the prev patch it was described as 'GPU fault signature'

and this kernel-doc for SIG_IDs should be in .h file where we define those IDs

drivers/gpu/drm/xe/xe_ras_log.h line 31

Quoted 5 lines
drivers/gpu/drm/xe/xe_ras_log.h new file +5 -0
+ * It tells tooling what kind of fault happened, independent of message text.
+ *
+ * Driver SIG_ID classes:
+ *   XE_SIG_PROBE         - probe/init failure
+ *   XE_SIG_WEDGED        - device unrecoverable

hmm, in drm_dev_wedged_event() we can specify recovery method so what unrecoverable means here?

drivers/gpu/drm/xe/xe_ras_log.h line 40

Quoted 9 lines
drivers/gpu/drm/xe/xe_ras_log.h new file +9 -0
+ *   XE_SIG_SURVIVABILITY - degraded/safe mode
+ *   XE_SIG_FW            - firmware fault (GuC/HuC/GSC/CSC/PCODE)
+ *   XE_SIG_GT_TDR        - engine hang or GT reset (TDR)
+ *   XE_SIG_MEM_FAULT     - VM/page-fault/GTT error
+ *   XE_SIG_IO_BUS        - PCIe/IOMMU/MMIO bus error
+ *
+ * HW SIG_ID classes are hardware-defined categories, reported by firmware via
+ * CPER records (for example XE_SIG_HW_DEVICE_MEMORY). Driver code does not
+ * emit HW SIG_IDs directly.

if HW SIGs are HW defined, are below IDs also defined by the HW or HW just defines different components, and we define IDs for them?

drivers/gpu/drm/xe/xe_ras_log.h line 49

Quoted 9 lines
drivers/gpu/drm/xe/xe_ras_log.h new file +9 -0
+ *   XE_SIG_HW_DEVICE_MEMORY  - device memory errors (e.g. ECC)
+ *   XE_SIG_HW_CORE_COMPUTE   - compute/shader core errors
+ *   XE_SIG_HW_PCIE           - PCIe interface errors
+ *   XE_SIG_HW_FABRIC         - on-package fabric errors
+ *   XE_SIG_HW_SOC_INTERNAL   - SoC-internal errors
+ *
+ * Why this exists
+ * ---------------
+ * SIG_IDs let RAS tools parse logs reliably, correlate CPER events, and apply

dmesg is not reliable

drivers/gpu/drm/xe/xe_ras_log.h line 50

Quoted 1 line
drivers/gpu/drm/xe/xe_ras_log.h new file +1 -0
+ * policy/thresholding without depending on fragile string matching.

if the whole idea is to group our errors per fault class, then maybe our macros should be used like:

	xe_err_fatal(xe, CLASS, fmt, ...)
	xe_err_recoverable(xe, CLASS, fmt, ...)

and output should be:

	0000:02.0 xe [drm] *ERROR* [PROBE] *FATAL* format ...
	0000:02.0 xe [drm] *ERROR* [TDR] *RECOVERABLE* format ...

as printing magic ID numbers is not very friendly

and any 'machine structured output' should be exposed elsewhere? maybe as sysfs file on the xe module level (to catch probe errors)

and maybe start with that alternate method first,
and use dmesg logging only as a best-effort informational step?

Quoted 46 lines
drivers/gpu/drm/xe/xe_ras_log.h new file +46 -0
+ *
+ * When to use xe_ras_log_*()
+ * --------------------------
+ * Use these macros when the event is:
+ *   1) a real hardware/firmware fault,
+ *   2) relevant to production monitoring, and
+ *   3) clearly mapped to one SIG_ID class.
+ *
+ * Do not use for all logs
+ * -----------------------
+ * Keep regular debug/info/driver-state messages on standard logging helpers
+ * (xe_gt_dbg(), xe_gt_info(), xe_gt_warn(), xe_gt_err(), drm_dbg(), drm_info()).
+ * RAS macros are for structured fault reporting only.
+ */
+
+/*
+ * Common backend helper
+ */
+__printf(6, 7)
+void __xe_ras_log(struct xe_device *xe, struct xe_gt *gt,
+		  u16 sig_id, u32 cper_sev, int errno_val,
+		  const char *fmt, ...);
+
+/*
+ * Driver-facing reporting macros
+ */
+
+/* FATAL */
+#define xe_ras_log_probe(xe, errno, fmt, ...) \
+	__xe_ras_log((xe), NULL, XE_SIG_PROBE, CPER_SEV_FATAL, \
+		     (errno), fmt, ##__VA_ARGS__)
+
+#define xe_ras_log_wedged(xe, errno, fmt, ...) \
+	__xe_ras_log((xe), NULL, XE_SIG_WEDGED, CPER_SEV_FATAL, \
+		     (errno), fmt, ##__VA_ARGS__)
+
+#define xe_ras_log_survivability(xe, errno, fmt, ...) \
+	__xe_ras_log((xe), NULL, XE_SIG_SURVIVABILITY, CPER_SEV_FATAL, \
+		     (errno), fmt, ##__VA_ARGS__)
+
+/* RECOVERABLE */
+#define xe_ras_log_fw(xe, gt, errno, fmt, ...) \
+	__xe_ras_log((xe), (gt), XE_SIG_FW, CPER_SEV_RECOVERABLE, \
+		     (errno), fmt, ##__VA_ARGS__)
+
+#define xe_ras_log_gt_tdr(xe, gt, errno, fmt, ...) \

drivers/gpu/drm/xe/xe_ras_log.h line 106

Quoted 10 lines
drivers/gpu/drm/xe/xe_ras_log.h new file +10 -0
+	__xe_ras_log((xe), (gt), XE_SIG_GT_TDR, CPER_SEV_RECOVERABLE, \
+		     (errno), fmt, ##__VA_ARGS__)
+
+#define xe_ras_log_mem_fault(xe, gt, errno, fmt, ...) \
+	__xe_ras_log((xe), (gt), XE_SIG_MEM_FAULT, CPER_SEV_RECOVERABLE, \
+		     (errno), fmt, ##__VA_ARGS__)
+
+#define xe_ras_log_io_bus(xe, errno, fmt, ...) \
+	__xe_ras_log((xe), NULL, XE_SIG_IO_BUS, CPER_SEV_RECOVERABLE, \
+		     (errno), fmt, ##__VA_ARGS__)

IMO those RAS customized macros, should be per severity and take a CLASS as a param since there is much less severity levels than your new SIG_IDs fault classes, so it scales better

	xe_err_fatal(xe, PROBE, fmt, ...)
	xe_err_recoverable(xe, IO_BUS, fmt, ...)

and I'm not sure that there is 1:1 relation between CLASS and severity

Quoted 2 lines
drivers/gpu/drm/xe/xe_ras_log.h new file +2 -0
+
+#endif /* _XE_RAS_LOG_H_ */
#10 lore raw

Re: [RFC PATCH v3 2/3] drm/xe: Add RAS logging helpers

Quoted 5 lines · Michal Wajdeczko
Quoted 2 lines · Mallesh Koujalagi

Add xe_ras_log.c and xe_ras_log.h so the driver can report faults in a structured, machine-readable way.

hmm, but the dmesg logs are mostly for the human admins, no?

You are right, dmesg is mostly for humans. The machine-readable interface appears to be the CPER

payload exposed  through xe_error_cper/tracefs, while dmesg is a human friendly rendering of the

same event.

Quoted 4 lines
Quoted 2 lines

The core is __xe_ras_log(), which emits a single log line with:
SIG_ID, severity, location (device or tile/GT), errno, and message.

our dmesg logs are already to some extend structured as they contain:

Quoted 8 lines

severity: <3>
driver name: xe
device name: 0000:00:02.0
subsystem name: [drm]
error tag: *ERROR*
location: Tile0:
Tile0: GT0:
message: GuC mmio request ...

This patch add is a more uniform fault-event format plus the CPER/tracepoint path for machine consumption.

Quoted 2 lines
Quoted 1 line

Fatal faults go to drm_err(); recoverable ones to drm_warn().

note that we already have xe_err() and xe_warn() wrappers

Good catch.

Quoted 104 lines
Quoted 84 lines

---
v3:
- Refer "Tile%u" and "GT%u" strings. (Michal Wajdeczko)
- Remov xe_cper_severity_str(). (Michal Wajdeczko/Riana)
- Move __xe_ras_log() function to xe_ras_log.h. (Michal Wajdeczko)
- Make macro function properly.
- Remove *_FIRST and *_LAST macro. (Michal Wajdeczko/Riana)
- Add sig id documents. (Riana)
- Change macro function same prefix as the file.
- Handle __xe_ras_log() function with variable format.

---
  drivers/gpu/drm/xe/Makefile     |   1 +
  drivers/gpu/drm/xe/xe_ras_log.c |  63 +++++++++++++++++++
  drivers/gpu/drm/xe/xe_ras_log.h | 108 ++++++++++++++++++++++++++++++++
  3 files changed, 172 insertions(+)

create mode 100644 drivers/gpu/drm/xe/xe_ras_log.c create mode 100644 drivers/gpu/drm/xe/xe_ras_log.h

drivers/gpu/drm/xe/Makefile +1 -0
index 8e7b146880f4..607c9b099d03 100644
@@ -114,6 +114,7 @@ xe-y += xe_bb.o \
  	xe_query.o \
  	xe_range_fence.o \
  	xe_ras.o \
+	xe_ras_log.o \
  	xe_reg_sr.o \
  	xe_reg_whitelist.o \
  	xe_ring_ops.o \
drivers/gpu/drm/xe/xe_ras_log.c new file +47 -0
new file mode 100644
index 000000000000..0e836ef5dcf6
@@ -0,0 +1,63 @@
+// SPDX-License-Identifier: MIT
+/*
+ * Copyright © 2026 Intel Corporation
+ */
+
+#include <drm/drm_print.h>
+
+#include "xe_device.h"
+#include "xe_gt.h"
+#include "xe_ras_log.h"
+
+/**
+ * __xe_ras_log - Emit a structured RAS log entry
+ * @xe: xe device instance
+ * @gt: GT instance where the error occurred, or NULL if device-wide
+ * @sig_id: signature ID from xe_sig_ids.h identifying the error class
+ * @cper_sev: CPER severity (one of CPER_SEV_FATAL, CPER_SEV_RECOVERABLE, etc.)
+ * @errno_val: negative errno describing the error condition
+ * @fmt: printf-style format string
+ * @...: format arguments
+ *
+ * Formats the message and emits a kernel log line via drm_err() for fatal
+ * events or drm_warn() for all others. CPER record generation and hex dump
+ * are planned as follow-ups.
+ *
+ * Format:
+ *   [xe-err] SIG_ID = <id> Severity = <sev> Location = <loc> Errno = <n> Message = "<msg>"
+ */
+__printf(6, 7)
+void __xe_ras_log(struct xe_device *xe, struct xe_gt *gt,
+		  u16 sig_id, u32 cper_sev, int errno_val,
+		  const char *fmt, ...)
+{
+	char loc[32];
+	struct va_format vaf;
+	va_list ap;
+
+	if (gt)
+		snprintf(loc, sizeof(loc), "tile%u/gt%u",
+			 gt->tile->id, gt->info.id);
+	else
+		snprintf(loc, sizeof(loc), "device");
+
+	va_start(ap, fmt);
+	vaf.fmt = fmt;
+	vaf.va = &ap;
+

drivers/gpu/drm/xe/xe_ras_log.c line 57

Quoted 10 lines
drivers/gpu/drm/xe/xe_ras_log.c new file +10 -0
+	if (cper_sev == CPER_SEV_FATAL)
+		drm_err(&xe->drm,
+			"[xe-err] SIG_ID = %u Severity = %s Location = %s Errno = %d Message = \"%pV\"",
+			sig_id, cper_severity_str(cper_sev), loc,
+			errno_val, &vaf);
+	else
+		drm_warn(&xe->drm,
+			 "[xe-err] SIG_ID = %u Severity = %s Location = %s Errno = %d Message = \"%pV\"",
+			 sig_id, cper_severity_str(cper_sev), loc,
+			 errno_val, &vaf);

again, this is not a very friendly message for the human admin

can't we just add severity/id pair to our updated xe_printk macros, like

	xe_err_fatal(xe, id, fmt, ...)
	xe_err_recoverable(xe, id, fmt, ...)

	xe_gt_err_fatal(gt, id, fmt, ...)
	xe_gt_err_recoverable(gt, id, fmt, ...)
Quoted 3 lines

and print sev/id pair within single tag:

	0000:02.0 xe [drm] *ERROR* [ID=123456] *FATAL* format ...

Agreed, however we've per file macro reference.

Quoted 32 lines
Quoted 32 lines
drivers/gpu/drm/xe/xe_ras_log.c new file +6 -0
+
+	va_end(ap);
+
+	/* TODO: Add CPER record driver handler */
+	/* TODO: Add RAS dump cper hex handler */
+}
drivers/gpu/drm/xe/xe_ras_log.h new file +20 -0
new file mode 100644
index 000000000000..08318dea75a9
@@ -0,0 +1,108 @@
+/* SPDX-License-Identifier: MIT */
+/*
+ * Copyright © 2026 Intel Corporation
+ */
+
+#ifndef _XE_RAS_LOG_H_
+#define _XE_RAS_LOG_H_
+
+#include <linux/cper.h>
+
+#include "xe_sig_ids.h"
+
+struct xe_device;
+struct xe_gt;
+
+/**
+ * DOC: RAS structured logging and SIG_IDs
+ *
+ * What this file is for
+ * ---------------------
Quoted 8 lines

drivers/gpu/drm/xe/xe_ras_log.h line 26

Quoted 6 lines
drivers/gpu/drm/xe/xe_ras_log.h new file +6 -0
+ * Use the xe_ras_log_*() macros to report faults in a
+ * machine-readable way.
+ *
+ * What is a SIG_ID?
+ * -----------------
+ * A SIG_ID (defined in xe_sig_ids.h) is a stable numeric error class.

hmm, so a SIG is now a CLASS ?
in the prev patch it was described as 'GPU fault signature'

Sure, i'll make it consistence.

Quoted 1 line

and this kernel-doc for SIG_IDs should be in .h file where we define those IDs

Sure, I'll move to header.

Quoted 7 lines

drivers/gpu/drm/xe/xe_ras_log.h line 31

Quoted 5 lines
drivers/gpu/drm/xe/xe_ras_log.h new file +5 -0
+ * It tells tooling what kind of fault happened, independent of message text.
+ *
+ * Driver SIG_ID classes:
+ *   XE_SIG_PROBE         - probe/init failure
+ *   XE_SIG_WEDGED        - device unrecoverable

hmm, in drm_dev_wedged_event() we can specify recovery method so what unrecoverable means here?

Good point, I'll fix the comment.

Quoted 11 lines

drivers/gpu/drm/xe/xe_ras_log.h line 40

Quoted 9 lines
drivers/gpu/drm/xe/xe_ras_log.h new file +9 -0
+ *   XE_SIG_SURVIVABILITY - degraded/safe mode
+ *   XE_SIG_FW            - firmware fault (GuC/HuC/GSC/CSC/PCODE)
+ *   XE_SIG_GT_TDR        - engine hang or GT reset (TDR)
+ *   XE_SIG_MEM_FAULT     - VM/page-fault/GTT error
+ *   XE_SIG_IO_BUS        - PCIe/IOMMU/MMIO bus error
+ *
+ * HW SIG_ID classes are hardware-defined categories, reported by firmware via
+ * CPER records (for example XE_SIG_HW_DEVICE_MEMORY). Driver code does not
+ * emit HW SIG_IDs directly.

if HW SIGs are HW defined, are below IDs also defined by the HW or HW just defines different components, and we define IDs for them?

No, the numeric values are not defined by the HW. HW defines the categories; we define the IDs for them.

Quoted 10 lines

drivers/gpu/drm/xe/xe_ras_log.h line 49

Quoted 9 lines
drivers/gpu/drm/xe/xe_ras_log.h new file +9 -0
+ *   XE_SIG_HW_DEVICE_MEMORY  - device memory errors (e.g. ECC)
+ *   XE_SIG_HW_CORE_COMPUTE   - compute/shader core errors
+ *   XE_SIG_HW_PCIE           - PCIe interface errors
+ *   XE_SIG_HW_FABRIC         - on-package fabric errors
+ *   XE_SIG_HW_SOC_INTERNAL   - SoC-internal errors
+ *
+ * Why this exists
+ * ---------------
+ * SIG_IDs let RAS tools parse logs reliably, correlate CPER events, and apply

dmesg is not reliable

dmesg is explicitly not a stable API, it is emitted “for logging purpose,”

while the machine-consumable path is the CPER record

via the existing xe_error_cper tracepoint.

Quoted 12 lines

drivers/gpu/drm/xe/xe_ras_log.h line 50

Quoted 1 line
drivers/gpu/drm/xe/xe_ras_log.h new file +1 -0
+ * policy/thresholding without depending on fragile string matching.

if the whole idea is to group our errors per fault class, then maybe our macros should be used like:

	xe_err_fatal(xe, CLASS, fmt, ...)
	xe_err_recoverable(xe, CLASS, fmt, ...)

and output should be:

	0000:02.0 xe [drm] *ERROR* [PROBE] *FATAL* format ...
	0000:02.0 xe [drm] *ERROR* [TDR] *RECOVERABLE* format ...
Quoted 7 lines

as printing magic ID numbers is not very friendly

and any 'machine structured output' should be exposed elsewhere? maybe as sysfs file on the xe module level (to catch probe errors)

and maybe start with that alternate method first,
and use dmesg logging only as a best-effort informational step?

We need component based helper, not based on severity.

Quoted 60 lines
Quoted 46 lines
drivers/gpu/drm/xe/xe_ras_log.h new file +46 -0
+ *
+ * When to use xe_ras_log_*()
+ * --------------------------
+ * Use these macros when the event is:
+ *   1) a real hardware/firmware fault,
+ *   2) relevant to production monitoring, and
+ *   3) clearly mapped to one SIG_ID class.
+ *
+ * Do not use for all logs
+ * -----------------------
+ * Keep regular debug/info/driver-state messages on standard logging helpers
+ * (xe_gt_dbg(), xe_gt_info(), xe_gt_warn(), xe_gt_err(), drm_dbg(), drm_info()).
+ * RAS macros are for structured fault reporting only.
+ */
+
+/*
+ * Common backend helper
+ */
+__printf(6, 7)
+void __xe_ras_log(struct xe_device *xe, struct xe_gt *gt,
+		  u16 sig_id, u32 cper_sev, int errno_val,
+		  const char *fmt, ...);
+
+/*
+ * Driver-facing reporting macros
+ */
+
+/* FATAL */
+#define xe_ras_log_probe(xe, errno, fmt, ...) \
+	__xe_ras_log((xe), NULL, XE_SIG_PROBE, CPER_SEV_FATAL, \
+		     (errno), fmt, ##__VA_ARGS__)
+
+#define xe_ras_log_wedged(xe, errno, fmt, ...) \
+	__xe_ras_log((xe), NULL, XE_SIG_WEDGED, CPER_SEV_FATAL, \
+		     (errno), fmt, ##__VA_ARGS__)
+
+#define xe_ras_log_survivability(xe, errno, fmt, ...) \
+	__xe_ras_log((xe), NULL, XE_SIG_SURVIVABILITY, CPER_SEV_FATAL, \
+		     (errno), fmt, ##__VA_ARGS__)
+
+/* RECOVERABLE */
+#define xe_ras_log_fw(xe, gt, errno, fmt, ...) \
+	__xe_ras_log((xe), (gt), XE_SIG_FW, CPER_SEV_RECOVERABLE, \
+		     (errno), fmt, ##__VA_ARGS__)
+
+#define xe_ras_log_gt_tdr(xe, gt, errno, fmt, ...) \

drivers/gpu/drm/xe/xe_ras_log.h line 106

Quoted 10 lines
drivers/gpu/drm/xe/xe_ras_log.h new file +10 -0
+	__xe_ras_log((xe), (gt), XE_SIG_GT_TDR, CPER_SEV_RECOVERABLE, \
+		     (errno), fmt, ##__VA_ARGS__)
+
+#define xe_ras_log_mem_fault(xe, gt, errno, fmt, ...) \
+	__xe_ras_log((xe), (gt), XE_SIG_MEM_FAULT, CPER_SEV_RECOVERABLE, \
+		     (errno), fmt, ##__VA_ARGS__)
+
+#define xe_ras_log_io_bus(xe, errno, fmt, ...) \
+	__xe_ras_log((xe), NULL, XE_SIG_IO_BUS, CPER_SEV_RECOVERABLE, \
+		     (errno), fmt, ##__VA_ARGS__)

IMO those RAS customized macros, should be per severity and take a CLASS as a param since there is much less severity levels than your new SIG_IDs fault classes, so it scales better

Quoted 4 lines
	xe_err_fatal(xe, PROBE, fmt, ...)
	xe_err_recoverable(xe, IO_BUS, fmt, ...)

and I'm not sure that there is 1:1 relation between CLASS and severity

ditto

Thanks,

-/Mallesh

Quoted 2 lines
Quoted 2 lines
drivers/gpu/drm/xe/xe_ras_log.h new file +2 -0
+
+#endif /* _XE_RAS_LOG_H_ */
#11 lore raw

Re: [RFC PATCH v3 2/3] drm/xe: Add RAS logging helpers

Quoted 243 lines · Koujalagi
Quoted 5 lines · Michal Wajdeczko
Quoted 2 lines · Mallesh Koujalagi

Add xe_ras_log.c and xe_ras_log.h so the driver can report faults in a structured, machine-readable way.

hmm, but the dmesg logs are mostly for the human admins, no?

You are right, dmesg is mostly for humans. The machine-readable interface appears to be the CPER

payload exposed  through xe_error_cper/tracefs, while dmesg is a human friendly rendering of the

same event.

Quoted 4 lines
Quoted 2 lines

The core is __xe_ras_log(), which emits a single log line with:
SIG_ID, severity, location (device or tile/GT), errno, and message.

our dmesg logs are already to some extend structured as they contain:

Quoted 8 lines

    severity:    <3>
    driver name:     xe
    device name:    0000:00:02.0
    subsystem name:    [drm]
    error tag:    *ERROR*
    location:    Tile0:
            Tile0: GT0:
    message:    GuC mmio request ...

This patch add is a more uniform fault-event format plus the CPER/tracepoint path for machine consumption.

Quoted 2 lines
Quoted 1 line

Fatal faults go to drm_err(); recoverable ones to drm_warn().

note that we already have xe_err() and xe_warn() wrappers

Good catch.

Quoted 108 lines
Quoted 93 lines

---
v3:
- Refer "Tile%u" and "GT%u" strings. (Michal Wajdeczko)
- Remov xe_cper_severity_str(). (Michal Wajdeczko/Riana)
- Move __xe_ras_log() function to xe_ras_log.h. (Michal Wajdeczko)
- Make macro function properly.
- Remove *_FIRST and *_LAST macro. (Michal Wajdeczko/Riana)
- Add sig id documents. (Riana)
- Change macro function same prefix as the file.
- Handle __xe_ras_log() function with variable format.
---
  drivers/gpu/drm/xe/Makefile     |   1 + drivers/gpu/drm/xe/xe_ras_log.c |  63 +++++++++++++++++++ drivers/gpu/drm/xe/xe_ras_log.h | 108
++++++++++++++++++++++++++++++++

  3 files changed, 172 insertions(+)

  create mode 100644 drivers/gpu/drm/xe/xe_ras_log.c create mode 100644 drivers/gpu/drm/xe/xe_ras_log.h

drivers/gpu/drm/xe/Makefile +1 -0
index 8e7b146880f4..607c9b099d03 100644
@@ -114,6 +114,7 @@ xe-y += xe_bb.o \
       xe_query.o \
       xe_range_fence.o \
       xe_ras.o \
+    xe_ras_log.o \
       xe_reg_sr.o \
       xe_reg_whitelist.o \
       xe_ring_ops.o \
drivers/gpu/drm/xe/xe_ras_log.c new file +17 -0
new file mode 100644
index 000000000000..0e836ef5dcf6
@@ -0,0 +1,63 @@
+// SPDX-License-Identifier: MIT
+/*
+ * Copyright © 2026 Intel Corporation
+ */
+
+#include <drm/drm_print.h>
+
+#include "xe_device.h"
+#include "xe_gt.h"
+#include "xe_ras_log.h"
+
+/**
+ * __xe_ras_log - Emit a structured RAS log entry
+ * @xe: xe device instance
+ * @gt: GT instance where the error occurred, or NULL if device-wide
+ * @sig_id: signature ID from xe_sig_ids.h identifying the error class
+ * @cper_sev: CPER severity (one of CPER_SEV_FATAL, 

CPER_SEV_RECOVERABLE, etc.)
+ * @errno_val: negative errno describing the error condition
+ * @fmt: printf-style format string
+ * @...: format arguments
+ *
+ * Formats the message and emits a kernel log line via drm_err() for fatal
+ * events or drm_warn() for all others. CPER record generation and hex dump
+ * are planned as follow-ups.
+ *
+ * Format:
+ *   [xe-err] SIG_ID = <id> Severity = <sev> Location = <loc> Errno = <n> Message = "<msg>"
+ */

drivers/gpu/drm/xe/xe_ras_log.c new file +22 -0
+__printf(6, 7)
+void __xe_ras_log(struct xe_device *xe, struct xe_gt *gt,
+          u16 sig_id, u32 cper_sev, int errno_val,
+          const char *fmt, ...)
+{
+    char loc[32];
+    struct va_format vaf;
+    va_list ap;
+
+    if (gt)
+        snprintf(loc, sizeof(loc), "tile%u/gt%u",
+             gt->tile->id, gt->info.id);
+    else
+        snprintf(loc, sizeof(loc), "device");
+
+    va_start(ap, fmt);
+    vaf.fmt = fmt;
+    vaf.va = &ap;
+
+    if (cper_sev == CPER_SEV_FATAL)
+        drm_err(&xe->drm,
+            "[xe-err] SIG_ID = %u Severity = %s Location = %s Errno 

= %d Message = \"%pV\"",

Quoted 8 lines

+            sig_id, cper_severity_str(cper_sev), loc, +            errno_val, &vaf);
+    else
+        drm_warn(&xe->drm,
+             "[xe-err] SIG_ID = %u Severity = %s Location = %s Errno = %d Message = \"%pV\"",
+             sig_id, cper_severity_str(cper_sev), loc, +             errno_val, &vaf);

again, this is not a very friendly message for the human admin

can't we just add severity/id pair to our updated xe_printk macros, like

    xe_err_fatal(xe, id, fmt, ...)
    xe_err_recoverable(xe, id, fmt, ...)

Quoted 6 lines

    xe_gt_err_fatal(gt, id, fmt, ...)
    xe_gt_err_recoverable(gt, id, fmt, ...)

and print sev/id pair within single tag:

    0000:02.0 xe [drm] *ERROR* [ID=123456] *FATAL* format ...

Agreed, however we've per file macro reference.

Quoted 32 lines
Quoted 32 lines
drivers/gpu/drm/xe/xe_ras_log.c new file +6 -0
+
+    va_end(ap);
+
+    /* TODO: Add CPER record driver handler */
+    /* TODO: Add RAS dump cper hex handler */
+}
drivers/gpu/drm/xe/xe_ras_log.h new file +20 -0
new file mode 100644
index 000000000000..08318dea75a9
@@ -0,0 +1,108 @@
+/* SPDX-License-Identifier: MIT */
+/*
+ * Copyright © 2026 Intel Corporation
+ */
+
+#ifndef _XE_RAS_LOG_H_
+#define _XE_RAS_LOG_H_
+
+#include <linux/cper.h>
+
+#include "xe_sig_ids.h"
+
+struct xe_device;
+struct xe_gt;
+
+/**
+ * DOC: RAS structured logging and SIG_IDs
+ *
+ * What this file is for
+ * ---------------------
Quoted 8 lines

drivers/gpu/drm/xe/xe_ras_log.h line 26

Quoted 6 lines
drivers/gpu/drm/xe/xe_ras_log.h new file +6 -0
+ * Use the xe_ras_log_*() macros to report faults in a
+ * machine-readable way.
+ *
+ * What is a SIG_ID?
+ * -----------------
+ * A SIG_ID (defined in xe_sig_ids.h) is a stable numeric error class.

hmm, so a SIG is now a CLASS ?
in the prev patch it was described as 'GPU fault signature'

Sure, i'll make it consistence.

Quoted 1 line

and this kernel-doc for SIG_IDs should be in .h file where we define those IDs

Sure, I'll move to header.

Quoted 8 lines
Quoted 6 lines
drivers/gpu/drm/xe/xe_ras_log.h new file +1 -0
+ * It tells tooling what kind of fault happened, independent of 

message text.
+ *
+ * Driver SIG_ID classes:
+ *   XE_SIG_PROBE         - probe/init failure
+ *   XE_SIG_WEDGED        - device unrecoverable

hmm, in drm_dev_wedged_event() we can specify recovery method so what unrecoverable means here?

Good point, I'll fix the comment.

Quoted 11 lines
Quoted 11 lines

+ *   XE_SIG_SURVIVABILITY - degraded/safe mode
+ *   XE_SIG_FW            - firmware fault (GuC/HuC/GSC/CSC/PCODE)
+ *   XE_SIG_GT_TDR        - engine hang or GT reset (TDR)
+ *   XE_SIG_MEM_FAULT     - VM/page-fault/GTT error
+ *   XE_SIG_IO_BUS        - PCIe/IOMMU/MMIO bus error
+ *
+ * HW SIG_ID classes are hardware-defined categories, reported by firmware via
+ * CPER records (for example XE_SIG_HW_DEVICE_MEMORY). Driver code does not
+ * emit HW SIG_IDs directly.

Quoted 2 lines

if HW SIGs are HW defined, are below IDs also defined by the HW or HW just defines different components, and we define IDs for them?

No, the numeric values are not defined by the HW. HW defines the categories; we define the IDs for them.

Quoted 11 lines
Quoted 10 lines

+ *   XE_SIG_HW_DEVICE_MEMORY  - device memory errors (e.g. ECC)
+ *   XE_SIG_HW_CORE_COMPUTE   - compute/shader core errors
+ *   XE_SIG_HW_PCIE           - PCIe interface errors
+ *   XE_SIG_HW_FABRIC         - on-package fabric errors
+ *   XE_SIG_HW_SOC_INTERNAL   - SoC-internal errors
+ *
+ * Why this exists
+ * ---------------
+ * SIG_IDs let RAS tools parse logs reliably, correlate CPER events, and apply

dmesg is not reliable

dmesg is explicitly not a stable API, it is emitted “for logging purpose,”

while the machine-consumable path is the CPER record

via the existing xe_error_cper tracepoint.

Quoted 14 lines
Quoted 1 line

+ * policy/thresholding without depending on fragile string matching.

if the whole idea is to group our errors per fault class, then maybe our macros should be used like:

    xe_err_fatal(xe, CLASS, fmt, ...)
    xe_err_recoverable(xe, CLASS, fmt, ...)

and output should be:

    0000:02.0 xe [drm] *ERROR* [PROBE] *FATAL* format ... 0000:02.0 xe [drm] *ERROR* [TDR] *RECOVERABLE* format ...

as printing magic ID numbers is not very friendly

Quoted 75 lines
Quoted 5 lines

and any 'machine structured output' should be exposed elsewhere? maybe as sysfs file on the xe module level (to catch probe errors)

and maybe start with that alternate method first,
and use dmesg logging only as a best-effort informational step?

We need component based helper, not based on severity.

Quoted 66 lines
Quoted 48 lines

+ *
+ * When to use xe_ras_log_*()
+ * --------------------------
+ * Use these macros when the event is:
+ *   1) a real hardware/firmware fault,
+ *   2) relevant to production monitoring, and
+ *   3) clearly mapped to one SIG_ID class.
+ *
+ * Do not use for all logs
+ * -----------------------
+ * Keep regular debug/info/driver-state messages on standard logging helpers
+ * (xe_gt_dbg(), xe_gt_info(), xe_gt_warn(), xe_gt_err(), drm_dbg(), drm_info()).
+ * RAS macros are for structured fault reporting only.
+ */

drivers/gpu/drm/xe/xe_ras_log.h new file +32 -0
+
+/*
+ * Common backend helper
+ */
+__printf(6, 7)
+void __xe_ras_log(struct xe_device *xe, struct xe_gt *gt,
+          u16 sig_id, u32 cper_sev, int errno_val,
+          const char *fmt, ...);
+
+/*
+ * Driver-facing reporting macros
+ */
+
+/* FATAL */
+#define xe_ras_log_probe(xe, errno, fmt, ...) \
+    __xe_ras_log((xe), NULL, XE_SIG_PROBE, CPER_SEV_FATAL, \
+             (errno), fmt, ##__VA_ARGS__)
+
+#define xe_ras_log_wedged(xe, errno, fmt, ...) \
+    __xe_ras_log((xe), NULL, XE_SIG_WEDGED, CPER_SEV_FATAL, \
+             (errno), fmt, ##__VA_ARGS__)
+
+#define xe_ras_log_survivability(xe, errno, fmt, ...) \
+    __xe_ras_log((xe), NULL, XE_SIG_SURVIVABILITY, CPER_SEV_FATAL, \
+             (errno), fmt, ##__VA_ARGS__)
+
+/* RECOVERABLE */
+#define xe_ras_log_fw(xe, gt, errno, fmt, ...) \
+    __xe_ras_log((xe), (gt), XE_SIG_FW, CPER_SEV_RECOVERABLE, \
+             (errno), fmt, ##__VA_ARGS__)
+
+#define xe_ras_log_gt_tdr(xe, gt, errno, fmt, ...) \

drivers/gpu/drm/xe/xe_ras_log.h line 106

Quoted 10 lines
drivers/gpu/drm/xe/xe_ras_log.h new file +10 -0
+    __xe_ras_log((xe), (gt), XE_SIG_GT_TDR, CPER_SEV_RECOVERABLE, \
+             (errno), fmt, ##__VA_ARGS__)
+
+#define xe_ras_log_mem_fault(xe, gt, errno, fmt, ...) \
+    __xe_ras_log((xe), (gt), XE_SIG_MEM_FAULT, CPER_SEV_RECOVERABLE, \
+             (errno), fmt, ##__VA_ARGS__)
+
+#define xe_ras_log_io_bus(xe, errno, fmt, ...) \
+    __xe_ras_log((xe), NULL, XE_SIG_IO_BUS, CPER_SEV_RECOVERABLE, \
+             (errno), fmt, ##__VA_ARGS__)

IMO those RAS customized macros, should be per severity and take a CLASS as a param since there is much less severity levels than your new SIG_IDs fault classes, so it scales better

    xe_err_fatal(xe, PROBE, fmt, ...)
    xe_err_recoverable(xe, IO_BUS, fmt, ...)

and I'm not sure that there is 1:1 relation between CLASS and severity

Agree with Michal here. Let's not force severity per class.

Developers should be allowed to set severity irrespective of sig id. Having severity based helpers would also be useful for HW error logs.

Thanks
Riana

Quoted 8 lines

ditto

Thanks,

-/Mallesh

Quoted 2 lines
Quoted 2 lines
drivers/gpu/drm/xe/xe_ras_log.h new file +2 -0
+
+#endif /* _XE_RAS_LOG_H_ */
#12 lore raw

RFC PATCH v3 3/3 drm/xe: use XE_RAS_WEDGED macro in xe_device_declare_wedged

In reply to Mallesh Koujalagi

Replace the open-coded drm_err() call with XE_RAS_WEDGED() macro so that wedge events are reported through the unified RAS/SIG logging path with a consistent format, CPER severity, and errno.

---
v2:
- Rebase.

v3:
- Update message in xe_ras_log_wedged().

---
 drivers/gpu/drm/xe/xe_device.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)
drivers/gpu/drm/xe/xe_device.c +7 -6
index 089872507bdd..8284578b9156 100644
@@ -61,6 +61,7 @@
 #include "xe_psmi.h"
 #include "xe_pxp.h"
 #include "xe_query.h"
+#include "xe_ras_log.h"
 #include "xe_shrinker.h"
 #include "xe_soc_remapper.h"
 #include "xe_survivability_mode.h"
@@ -1424,12 +1425,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_ras_log_wedged(xe, -EIO,
+				  "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));
 	}
 
 	for_each_gt(gt, xe, id)
Signature · 1 line
2.34.1
#13 lore raw

RE: [RFC PATCH v3 3/3] drm/xe: use XE_RAS_WEDGED macro in xe_device_declare_wedged

Quoted 19 lines

-----Original Message-----
From: Intel-xe <[email protected]> On Behalf Of Mallesh Koujalagi
Sent: Wednesday, June 17, 2026 4:17 PM
To: [email protected]; Vivi, Rodrigo <[email protected]>; Brost, Matthew <[email protected]>; [email protected]
Cc: Gupta, Anshuman <[email protected]>; Nilawar, Badal <[email protected]>; Belgaumkar, Vinay <[email protected]>; Iddamsetty, Aravind <[email protected]>; Tauro, Riana <[email protected]>; Poosa, Karthik <[email protected]>; Anirban, Sk <[email protected]>; Jadav, Raag <[email protected]>; Koujalagi, Mallesh <[email protected]>
Subject: [RFC PATCH v3 3/3] drm/xe: use XE_RAS_WEDGED macro in xe_device_declare_wedged

Hello,
nitpick. Please update patch subject the /s/XE_RAS_WEDGED /xe_ras_log_wedged in next rev.

Quoted 1 line

Replace the open-coded drm_err() call with XE_RAS_WEDGED() macro so that

^/s/XE_RAS_WEDGED /xe_ras_log_wedged

Dnyaneshwar

Quoted 53 lines

wedge events are reported through the unified RAS/SIG logging path with a consistent format, CPER severity, and errno.

---
v2:
- Rebase.

v3:
- Update message in xe_ras_log_wedged().

---
 drivers/gpu/drm/xe/xe_device.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)
drivers/gpu/drm/xe/xe_device.c +1 -4
index 089872507bdd..8284578b9156 100644
@@ -61,6 +61,7 @@
 #include "xe_psmi.h"
 #include "xe_pxp.h"
 #include "xe_query.h"
+#include "xe_ras_log.h"
 #include "xe_shrinker.h"
 #include "xe_soc_remapper.h"
 #include "xe_survivability_mode.h"
@@ -1424,12 +1425,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"

drivers/gpu/drm/xe/xe_device.c +0 -1
-			"Please file a _new_ bug report at

https://gitlab.freedesktop.org/drm/xe/kernel/issues/new\n",

drivers/gpu/drm/xe/xe_device.c +2 -1
-			dev_name(xe->drm.dev));
+		xe_ras_log_wedged(xe, -EIO,
+				  "CRITICAL: Xe has declared device %s as

wedged.\n"

drivers/gpu/drm/xe/xe_device.c +2 -0
+				  "IOCTLs and executions are blocked.\n"
+				  "For recovery procedure, refer to

https://docs.kernel.org/gpu/drm-uapi.html#device-wedging\n"

drivers/gpu/drm/xe/xe_device.c +1 -0
+				  "Please file a _new_ bug report at

https://gitlab.freedesktop.org/drm/xe/kernel/issues/new\n",

drivers/gpu/drm/xe/xe_device.c +1 -1
+				  dev_name(xe->drm.dev));
 	}
 
 	for_each_gt(gt, xe, id)
--

2.34.1

#14 lore raw

Re: [RFC PATCH v3 3/3] drm/xe: use XE_RAS_WEDGED macro in xe_device_declare_wedged

In reply to Mallesh Koujalagi
Quoted 29 lines · Mallesh Koujalagi

Replace the open-coded drm_err() call with XE_RAS_WEDGED() macro so that wedge events are reported through the unified RAS/SIG logging path with a consistent format, CPER severity, and errno.

---
v2:
- Rebase.

v3:
- Update message in xe_ras_log_wedged().

---
 drivers/gpu/drm/xe/xe_device.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)
drivers/gpu/drm/xe/xe_device.c +1 -0
index 089872507bdd..8284578b9156 100644
@@ -61,6 +61,7 @@
 #include "xe_psmi.h"
 #include "xe_pxp.h"
 #include "xe_query.h"
+#include "xe_ras_log.h"
 #include "xe_shrinker.h"
 #include "xe_soc_remapper.h"
 #include "xe_survivability_mode.h"

drivers/gpu/drm/xe/xe_device.c void xe_device_declare_wedged(struct xe_device *xe) · line 1428

Quoted 10 lines
drivers/gpu/drm/xe/xe_device.c +1 -6
@@ -1424,12 +1425,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_ras_log_wedged(xe, -EIO,

who really cares about the errno if machine will only look at class and severity?

if relevant for deep-dive analysis, it should be printed as part of the regular message

drivers/gpu/drm/xe/xe_device.c void xe_device_declare_wedged(struct xe_device *xe) · line 1429

Quoted 1 line
drivers/gpu/drm/xe/xe_device.c +1 -0
+				  "CRITICAL: Xe has declared device %s as wedged.\n"

hmm, so now we will have all this in one log line:

	*ERROR*
	[xe-err]
	Severity = FATAL
	CRITICAL:

and full message like:

	<3> [0.028976] xe 0000:03:00.0: [drm] *ERROR* [xe-err] SIG_ID = 2 Severity = FATAL Location = device Errno = -5  Xe driver declared device 0000:03:00.0 as wedged. ...

drivers/gpu/drm/xe/xe_device.c void xe_device_declare_wedged(struct xe_device *xe) · line 1433

Quoted 4 lines
drivers/gpu/drm/xe/xe_device.c +4 -0
+				  "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));

compare with:

xe_err_fatal(xe, WEDGED, "Xe driver declared device as wedged. ...")
and

	<3> [0.028976] xe 0000:03:00.0: [drm] *ERROR* [WEDGED] *FATAL* Xe driver declared device as wedged.
Quoted 3 lines
drivers/gpu/drm/xe/xe_device.c +0 -0
 	}
 
 	for_each_gt(gt, xe, id)
#15 lore raw

Re: [RFC PATCH v3 3/3] drm/xe: use XE_RAS_WEDGED macro in xe_device_declare_wedged

Quoted 34 lines · Michal Wajdeczko
Quoted 32 lines · Mallesh Koujalagi

Replace the open-coded drm_err() call with XE_RAS_WEDGED() macro so that wedge events are reported through the unified RAS/SIG logging path with a consistent format, CPER severity, and errno.

---
v2:
- Rebase.

v3:
- Update message in xe_ras_log_wedged().

---
  drivers/gpu/drm/xe/xe_device.c | 13 +++++++------
  1 file changed, 7 insertions(+), 6 deletions(-)
drivers/gpu/drm/xe/xe_device.c +1 -0
index 089872507bdd..8284578b9156 100644
@@ -61,6 +61,7 @@
  #include "xe_psmi.h"
  #include "xe_pxp.h"
  #include "xe_query.h"
+#include "xe_ras_log.h"
  #include "xe_shrinker.h"
  #include "xe_soc_remapper.h"
  #include "xe_survivability_mode.h"
@@ -1424,12 +1425,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);
Quoted 8 lines

drivers/gpu/drm/xe/xe_device.c void xe_device_declare_wedged(struct xe_device *xe) · line 1428

Quoted 7 lines
drivers/gpu/drm/xe/xe_device.c +1 -6
-		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_ras_log_wedged(xe, -EIO,

who really cares about the errno if machine will only look at class and severity?

We need errno to encode the driver-side failure and same stuff need to update in cper/tracefs.

Quoted 2 lines

if relevant for deep-dive analysis, it should be printed as part of the regular message

Yes, we need to print details since device is declared as wedged.

Quoted 4 lines

drivers/gpu/drm/xe/xe_device.c void xe_device_declare_wedged(struct xe_device *xe) · line 1429

Quoted 2 lines
drivers/gpu/drm/xe/xe_device.c +1 -0
+				  "CRITICAL: Xe has declared device %s as wedged.\n"

hmm, so now we will have all this in one log line:

Quoted 8 lines
	*ERROR*
	[xe-err]
	Severity = FATAL
	CRITICAL:

and full message like:

	<3> [0.028976] xe 0000:03:00.0: [drm] *ERROR* [xe-err] SIG_ID = 2 Severity = FATAL Location = device Errno = -5  Xe driver declared device 0000:03:00.0 as wedged. ...

Yes, Arch team is inline with that format.

Quoted 11 lines

drivers/gpu/drm/xe/xe_device.c void xe_device_declare_wedged(struct xe_device *xe) · line 1433

Quoted 5 lines
drivers/gpu/drm/xe/xe_device.c +4 -0
+				  "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));

compare with:

xe_err_fatal(xe, WEDGED, "Xe driver declared device as wedged. ...")
and

	<3> [0.028976] xe 0000:03:00.0: [drm] *ERROR* [WEDGED] *FATAL* Xe driver declared device as wedged.

Since macro is based on severity what happen when we have PROBE has different severity? so we defined macro based on component.

Thanks,

-/Mallesh

Quoted 3 lines
Quoted 3 lines
drivers/gpu/drm/xe/xe_device.c +0 -0
  	}
 
  	for_each_gt(gt, xe, id)
#16 lore raw

✗ CI.checkpatch: warning for drm/xe: Structured RAS error logging infrastructure (rev3)

In reply to Mallesh Koujalagi
== Series Details ==

== Series Details ==

Series: drm/xe: Structured RAS error logging infrastructure (rev3)
URL : https://patchwork.freedesktop.org/series/168333/
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 6df66520c1d16299c9345600a09b22c984143055

Author: Mallesh Koujalagi <[email protected]>
Date:   Wed Jun 17 16:17:15 2026 +0530

drm/xe: use XE_RAS_WEDGED macro in xe_device_declare_wedged

Replace the open-coded drm_err() call with XE_RAS_WEDGED() macro so that wedge events are reported through the unified RAS/SIG logging path with a consistent format, CPER severity, and errno.

+ /mt/dim checkpatch 1f1e03ee0c160129c336e9301aeed557f406153b drm-intel f4f11020d39d drm/xe: Add error Signature IDs for RAS logging
-:13: WARNING:FILE_PATH_CHANGES: added, moved or deleted file(s), does MAINTAINERS need updating? #13:
new file mode 100644

total: 0 errors, 1 warnings, 0 checks, 29 lines checked
c994e6fd52f4 drm/xe: Add RAS logging helpers
-:28: WARNING:FILE_PATH_CHANGES: added, moved or deleted file(s), does MAINTAINERS need updating? #28:
new file mode 100644

total: 0 errors, 1 warnings, 0 checks, 178 lines checked 6df66520c1d1 drm/xe: use XE_RAS_WEDGED macro in xe_device_declare_wedged

#17 lore raw

✗ CI.KUnit: failure for drm/xe: Structured RAS error logging infrastructure (rev3)

In reply to Mallesh Koujalagi
== Series Details ==

== Series Details ==

Series: drm/xe: Structured RAS error logging infrastructure (rev3)
URL : https://patchwork.freedesktop.org/series/168333/
State : failure

== Summary ==

+ trap cleanup EXIT
+ /kernel/tools/testing/kunit/kunit.py run --kunitconfig /kernel/drivers/gpu/drm/xe/.kunitconfig [11:11:18] Configuring KUnit Kernel ...
Generating .config ...
Populating config with:

$ make ARCH=um O=.kunit olddefconfig
[11:11:23] Building KUnit Kernel ...
Populating config with:
$ make ARCH=um O=.kunit olddefconfig
Building with:
$ make all compile_commands.json scripts_gdb ARCH=um O=.kunit --jobs=48
ERROR:root:/usr/bin/ld: drivers/gpu/drm/xe/xe_ras_log.o: in function `__xe_ras_log':
xe_ras_log.c:(.text+0xe0): undefined reference to `cper_severity_str'
/usr/bin/ld: xe_ras_log.c:(.text+0x102): undefined reference to `cper_severity_str'
collect2: error: ld returned 1 exit status
make[3]: *** [../scripts/Makefile.vmlinux:72: vmlinux.unstripped] Error 1
make[2]: *** [/kernel/Makefile:1338: vmlinux] Error 2
make[1]: *** [/kernel/Makefile:248: __sub-make] Error 2
make: *** [Makefile:248: __sub-make] Error 2

+ cleanup
++ stat -c %u:%g /kernel
+ chown -R 1003:1003 /kernel