Introduce Xe Uncorrectable Error Handling
Subsystems (2)
v7 cover Introduce Xe Uncorrectable Error Handling
This series adds support for XE Uncorrectable Error Handling
The first four patches implement PCI error recovery callbacks for AER events. On fatal errors, the device is wedged in error_detected and a Secondary Bus reset (SBR) is requested from PCI core by returning PCI_ERS_RESULT_NEED_RESET.
On non-fatal errors, the mmio_enabled callback is invoked to query the error and attempt the required recovery.
This series adds support for handling Uncorrectable core compute, SoC internal and device memory errors.
Core Compute Errors: Uncorrectable Core-Compute errors are classified into Global and Local errors.
Global error is an error that affects the entire device requiring a reset to recover. When an AER is reported and error_detected is invoked return PCI_ERS_RESULT_NEED_RESET.
A Local error is confined to a specific component or context like a engine. These errors can be contained and recovered by resetting only the affected part without distrupting the rest of the device.
SoC Internal errors: Most of the uncorrectable SoC internal errors are recovered using a SBR apart from CSC firmware and Punit errors. CSC firmware errors requires a firmware flash to be recovered whereas Punit error requires cold-reset.
Device memory errors: Most of the uncorrectable memory errors are recovered using a SBR. However, double-bit ecc errors require page offlining in both s/w (done in a later patch) and firmware. Add helper to send offline/decline command to firmware. These pages are also saved by firmware in flash and need to be offlined by software on module load. Add helpers to retrieve the list and queue from firmware.
Rev2: Add support for SoC internal errors
fix review comments
Rev3: remove in_recovery flag for disconnect error
prevent sysctrl flooding
use minimal logging
simplify soc structures
add error_count to GT structures
Rev4: add device memory errors
add helpers for memory errors
fix cosmetic review comments
Rev5: simplify structures in all patches
disconnect on wedged or survivability mode rename in_recovery to in_reset
add minimal integration patch for device memory errors rename system controller flooding macro
fix comments
Rev6: rename function to prepare_reset.
call pci_prepare_reset() before requesting SBR fix cosmetic review comments
add patch to skip run_ticks while reading fdinfo when SBR is in flight
Rev7: rename sysctrl build command function
rename pci prepare reset function
use wedged state management
split function for usp dev
Raag Jadav (1):
drm/xe: Improve wedged state management
Riana Tauro (14):
drm/xe/xe_survivability: Decouple survivability info from boot
survivability
drm/xe/xe_sysctrl: Make sysctrl flood limit reusable drm/xe/xe_pci_error: Implement PCI error recovery callbacks drm/xe/xe_pci_error: Group all devres to release them on PCIe slot
reset
drm/xe: Skip device access during PCI error recovery drm/xe/xe_ras: Initialize Uncorrectable AER Registers drm/xe/xe_ras: Add support for uncorrectable core-compute errors drm/xe/xe_ras: Handle uncorrectable SoC Internal errors drm/xe/xe_ras: Add support to query device memory errors drm/xe/xe_ras: Query errors from system controller on probe drm/xe/xe_pci_error: Process errors in mmio_enabled drm/xe/xe_ras: Add support to query page offline queue and list drm/xe/xe_ras: Add support to offline/decline a page address drm/xe/xe_ras: Process pages from offlined list and queue
drivers/gpu/drm/xe/Makefile | 1 + drivers/gpu/drm/xe/xe_device.c | 24 +- drivers/gpu/drm/xe/xe_device.h | 27 +- drivers/gpu/drm/xe/xe_device_types.h | 12 +- drivers/gpu/drm/xe/xe_gt.c | 14 +- drivers/gpu/drm/xe/xe_guc_submit.c | 9 +- drivers/gpu/drm/xe/xe_pci.c | 9 + drivers/gpu/drm/xe/xe_pci_error.c | 135 +++++ drivers/gpu/drm/xe/xe_pci_error.h | 13 + drivers/gpu/drm/xe/xe_ras.c | 475 ++++++++++++++++++ drivers/gpu/drm/xe/xe_ras.h | 4 + drivers/gpu/drm/xe/xe_ras_types.h | 215 ++++++++ drivers/gpu/drm/xe/xe_survivability_mode.c | 13 +- drivers/gpu/drm/xe/xe_sysctrl_event.c | 2 +- drivers/gpu/drm/xe/xe_sysctrl_event_types.h | 3 - drivers/gpu/drm/xe/xe_sysctrl_mailbox.c | 28 ++ drivers/gpu/drm/xe/xe_sysctrl_mailbox.h | 4 +- drivers/gpu/drm/xe/xe_sysctrl_mailbox_types.h | 11 + 18 files changed, 971 insertions(+), 28 deletions(-) create mode 100644 drivers/gpu/drm/xe/xe_pci_error.c create mode 100644 drivers/gpu/drm/xe/xe_pci_error.h
Signature · 1 line
2.47.1
PATCH v7 1/15 drm/xe/xe_survivability: Decouple survivability info from boot survivability
On CSC runtime firmware errors that requires firmware flash through SPI, PCODE sets the FDO mode bit in the Capability register. Currently the survivability_info group is created only for boot survivability.
Create survivability_info group even for runtime survivability to allow userspace to check FDO mode sysfs.
---
v2: Fix typo (Mallesh)
v3: use tab (Mallesh)
--- drivers/gpu/drm/xe/xe_survivability_mode.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-)
drivers/gpu/drm/xe/xe_survivability_mode.c +11 -2
@@ -54,7 +54,6 @@* # cat /sys/bus/pci/devices/<device>/survivability_mode * Boot * -* * Any additional debug information if present will be visible under the directory * ``survivability_info``:: *
@@ -98,6 +97,15 @@* # cat /sys/bus/pci/devices/<device>/survivability_mode * Runtime * +* On some CSC firmware errors, PCODE sets FDO mode and the only recovery possible is through +* firmware flash using SPI driver. Userspace can check if FDO mode is set by checking the below +* sysfs entry. +* +* .. code-block:: shell +* +* # cat /sys/bus/pci/devices/<device>/survivability_info/fdo_mode +* enabled +* * When such errors occur, userspace is notified with the drm device wedged uevent and runtime * survivability mode. User can then initiate a firmware flash using userspace tools like fwupd * to restore device to normal operation.
@@ -296,7 +304,8 @@ static int create_survivability_sysfs(struct pci_dev *pdev)if (ret)return ret; -if (check_boot_failure (xe)) { +/* 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;
Signature · 1 line
2.47.1
PATCH v7 2/15 drm/xe/xe_sysctrl: Make sysctrl flood limit reusable
In reply to Riana TauroThe sysctrl command flood limit was defined in an event specific header, restricting its usage to event handling. Move it to the shared header with a generic name so it can be re-used across all files using system controller commands.
---
v2: remove duplicate (Raag, Mallesh)
v3: fix wrapping in commit message (Raag)
add limit postfix (Mallesh)
--- drivers/gpu/drm/xe/xe_sysctrl_event.c | 2 +- drivers/gpu/drm/xe/xe_sysctrl_event_types.h | 3 --- drivers/gpu/drm/xe/xe_sysctrl_mailbox_types.h | 3 +++ 3 files changed, 4 insertions(+), 4 deletions(-)
drivers/gpu/drm/xe/xe_sysctrl_event.c +1 -1
@@ -16,7 +16,7 @@ static void get_pending_event(struct xe_sysctrl *sc, struct xe_sysctrl_mailbox_c {struct xe_sysctrl_event_response *response = command->data_out;struct xe_device *xe =sc_to_xe (sc); -u32 count =XE_SYSCTRL_EVENT_FLOOD ; +u32 count =XE_SYSCTRL_FLOOD_LIMIT ;size_t len;int ret;
drivers/gpu/drm/xe/xe_sysctrl_event_types.h +0 -3
@@ -10,9 +10,6 @@#define XE_SYSCTRL_EVENT_DATA_LEN 59 -/* Modify as needed */ -#define XE_SYSCTRL_EVENT_FLOOD 16 -/** * enum xe_sysctrl_event - Events reported by System Controller *
drivers/gpu/drm/xe/xe_sysctrl_mailbox_types.h +3 -0
@@ -48,6 +48,9 @@ struct xe_sysctrl_mailbox_command {size_t data_out_len; }; +/* Modify as needed */ +#define XE_SYSCTRL_FLOOD_LIMIT 16 +#define XE_SYSCTRL_MB_FRAME_SIZE 16#define XE_SYSCTRL_MB_MAX_FRAMES 64#define XE_SYSCTRL_MB_MAX_MESSAGE_SIZE \
Signature · 1 line
2.47.1
PATCH v7 3/15 drm/xe: Improve wedged state management
In reply to Riana TauroFrom: Raag Jadav <[email protected]>
Currently, wedged state is serving a single usecase where the device is declared wedged, but this doesn't allow any wedged state management for runtime usecases. In preparation of usecases which requires to facilitate temporary device wedging, convert wedged.flag to wedged.ref which serves as a driver internal refcount and blocks critical path execution during device lifetime and while at it, introduce wedged.fini and use it as a cleanup indicator during driver unwind which operates independent of the refcount.
--- drivers/gpu/drm/xe/xe_device.c | 5 +++-- drivers/gpu/drm/xe/xe_device.h | 12 +++++++++++- drivers/gpu/drm/xe/xe_device_types.h | 6 ++++-- 3 files changed, 18 insertions(+), 5 deletions(-)
drivers/gpu/drm/xe/xe_device.c +3 -2
@@ -915,7 +915,7 @@ static void xe_device_wedged_fini(struct drm_device *drm, void *arg) {struct xe_device *xe = arg; -if (atomic_read (&xe->wedged.flag)) +if (atomic_read (&xe->wedged.fini))xe_pm_runtime_put (xe); }
@@ -1411,7 +1411,8 @@ void xe_device_declare_wedged(struct xe_device *xe)return ; } -if (!atomic_xchg (&xe->wedged.flag,1 )) { +if (!atomic_xchg (&xe->wedged.fini,1 )) { +xe_device_wedged_get (xe); xe->needs_flr_on_fini = true;xe_pm_runtime_get_noresume (xe); drm_err(&xe->drm,
drivers/gpu/drm/xe/xe_device.h +11 -1
@@ -192,9 +192,19 @@ bool xe_device_is_l2_flush_optimized(struct xe_device *xe);void xe_device_td_flush (struct xe_device *xe);void xe_device_l2_flush (struct xe_device *xe); +static inline void xe_device_wedged_get (struct xe_device *xe) +{ +atomic_inc (&xe->wedged.ref); +} + +static inline void xe_device_wedged_put (struct xe_device *xe) +{ +atomic_dec (&xe->wedged.ref); +} +static inline bool xe_device_wedged (struct xe_device *xe) { -return atomic_read (&xe->wedged.flag); +return atomic_read (&xe->wedged.ref); }void xe_device_set_wedged_method (struct xe_device *xe,unsigned long method);
drivers/gpu/drm/xe/xe_device_types.h +4 -2
@@ -485,8 +485,10 @@ struct xe_device {/** @wedged: Struct to control Wedged States and mode */ struct { -/** @wedged.flag: Xe device faced a critical error and is now blocked. */ -atomic_t flag; +/** @wedged.fini: Needs cleanup on fini */ +atomic_t fini; +/** @wedged.ref: Refcount for wedged device, blocks critical path execution */ +atomic_t ref;/** @wedged.mode: Mode controlled by kernel parameter and debugfs */ enum xe_wedged_mode mode;/** @wedged.method: Recovery method to be sent in the drm device wedged uevent */
Signature · 1 line
2.47.1
PATCH v7 4/15 drm/xe/xe_pci_error: Implement PCI error recovery callbacks
In reply to Riana TauroAdd error_detected, mmio_enabled, slot_reset and resume recovery callbacks to handle PCIe Advanced Error Reporting (AER) errors.
For fatal errors, the device is wedged and becomes inaccessible. Return PCI_ERS_RESULT_NEED_RESET from error_detected to request a Secondary Bus Reset (SBR).
For non-fatal errors, return PCI_ERS_RESULT_CAN_RECOVER from error_detected to trigger the mmio_enabled callback. In this callback, the device is queried to determine the error cause and attempt recovery based on the error type.
Once the secondary bus reset(SBR) is completed the slot_reset callback cleanly removes and reprobe the device to restore functionality.
---
Note: The re-probe in this patch will be replaced by minimal re-initalization once below patch is merged
https://lore.kernel.org/intel-xe/[email protected]/
v2: re-order linux headers
reword error messages
do not clear in_recovery after remove
return PCI_ERS_RESULT_DISCONNECT if probe fails (Michal) only wedge device do not send uevent (Raag) set recovery flag in error_detected and clear on resume add default switch case (Mallesh)
v3: do not set in_recovery for disconnect (Mallesh)
return if already wedged or in survivability mode
v4: Add comment (Matthew)
Fix tab (Mallesh)
v5: remove in_reset
disconnect if already in survivability mode or wedged block I/O operations in slot reset (Raag)
v6: acquire runtime pm wakeref while setting the
wedged flag(Matthew Brost)
rename function from xe_pci_error_handling() to pci_prepare_reset()
call pci_prepare_reset() before requesting SBR add blank line after copyright
v7: use wedged helpers
add header file
rename pci_prepare_reset function (Michal)
--- drivers/gpu/drm/xe/Makefile | 1 + drivers/gpu/drm/xe/xe_pci.c | 2 + drivers/gpu/drm/xe/xe_pci_error.c | 113 ++++++++++++++++++++++++++++++ drivers/gpu/drm/xe/xe_pci_error.h | 13 ++++ 4 files changed, 129 insertions(+) create mode 100644 drivers/gpu/drm/xe/xe_pci_error.c create mode 100644 drivers/gpu/drm/xe/xe_pci_error.h
drivers/gpu/drm/xe/Makefile +1 -0
@@ -101,6 +101,7 @@ xe-y += xe_bb.o \ xe_page_reclaim.o \ xe_pat.o \ xe_pci.o \ + xe_pci_error.o \ xe_pci_rebar.o \ xe_pcode.o \ xe_pm.o \
drivers/gpu/drm/xe/xe_pci.c +2 -0
@@ -26,6 +26,7 @@#include "xe_guc.h" #include "xe_mmio.h" #include "xe_module.h" +#include "xe_pci_error.h" #include "xe_pci_rebar.h" #include "xe_pci_sriov.h" #include "xe_pci_types.h"
@@ -1349,6 +1350,7 @@ static struct pci_driver xe_pci_driver = { .remove = xe_pci_remove, .shutdown = xe_pci_shutdown, .sriov_configure = xe_pci_sriov_configure, + .err_handler = &xe_pci_error_handlers,#ifdef CONFIG_PM_SLEEP .driver.pm = &xe_pm_ops,#endif
drivers/gpu/drm/xe/xe_pci_error.c new file +113 -0
113 lines not on this page · raw message
drivers/gpu/drm/xe/xe_pci_error.h new file +13 -0
@@ -0,0 +1,13 @@ +/* SPDX-License-Identifier: MIT */ +/* +* Copyright © 2026 Intel Corporation +*/ + +#ifndef _XE_PCI_ERROR_H_ +#define _XE_PCI_ERROR_H_ + +struct pci_error_handlers ; + +extern const struct pci_error_handlers xe_pci_error_handlers; + +#endif
Signature · 1 line
2.47.1
PATCH v7 5/15 drm/xe/xe_pci_error: Group all devres to release them on PCIe slot reset
In reply to Riana TauroAdd devres grouping to handle device resource cleanup during PCI error recovery.
Secondary Bus Reset (SBR) is triggered by PCI core when the error_detected/mmio_enabled callbacks return PCI_ERS_RESULT_NEED_RESET.
Once SBR is complete, the slot_reset callback is triggered. SBR wipes out all device memory requiring XE KMD to perform a device removal and reprobe.
Calling xe_pci_remove() alone does not free the devres allocated. Since there are no exported functions to release all devres, group the devres allocations and release the entire group during slot reset to ensure proper cleanup.
---
v2: move to xe pci layer
--- drivers/gpu/drm/xe/xe_device_types.h | 3 +++ drivers/gpu/drm/xe/xe_pci.c | 7 +++++++ drivers/gpu/drm/xe/xe_pci_error.c | 1 + 3 files changed, 11 insertions(+)
drivers/gpu/drm/xe/xe_device_types.h +3 -0
@@ -497,6 +497,9 @@ struct xe_device {bool inconsistent_reset; } wedged; +/** @devres_group_id: id for devres group */ +void *devres_group_id; +/** @bo_device: Struct to control async free of BOs */ struct xe_bo_dev {/** @bo_device.async_free: Free worker */
drivers/gpu/drm/xe/xe_pci.c +7 -0
@@ -1077,6 +1077,7 @@ static int xe_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)const struct xe_device_desc *desc = (const void *)ent->driver_data;const struct xe_subplatform_desc *subplatform_desc;struct xe_device *xe; +void *devres_id;int err; subplatform_desc =find_subplatform (desc, pdev->device);
@@ -1104,6 +1105,10 @@ 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 ; + devres_id =devres_open_group (&pdev->dev,NULL ,GFP_KERNEL ); +if (!devres_id) +return -ENOMEM ; + err =pcim_enable_device (pdev);if (err)return err;
@@ -1112,6 +1117,8 @@ static int xe_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)if (IS_ERR (xe))return PTR_ERR (xe); + xe->devres_group_id = devres_id; +pci_set_drvdata (pdev, &xe->drm);xe_pm_assert_unbounded_bridge (xe);
drivers/gpu/drm/xe/xe_pci_error.c +1 -0
@@ -83,6 +83,7 @@ static pci_ers_result_t xe_pci_error_slot_reset(struct pci_dev *pdev)* kernel BOs. */ pdev->driver->remove (pdev); +devres_release_group (&pdev->dev, xe->devres_group_id);if (pdev->driver->probe (pdev, ent))return PCI_ERS_RESULT_DISCONNECT ;
Signature · 1 line
2.47.1
PATCH v7 6/15 drm/xe: Skip device access during PCI error recovery
In reply to Riana TauroWhen a fatal error occurs and the error_detected callback is invoked the device is inaccessible. The error_detected callback wedges the device causing the jobs to timeout.
The timedout handler acquires forcewake to dump devcoredump and triggers a GT reset. Since the device is inaccessible this causes errors. Skip all mmio accesses and gt reset when the device is in reset.
---
v2: add check in worker (Mallesh)
v3: add in_reset calls (Raag)
rename in_recovery to in_reset
v4: fix typo
combine gt reset log (Mallesh)
--- drivers/gpu/drm/xe/xe_device.h | 15 +++++++++++++++ drivers/gpu/drm/xe/xe_device_types.h | 3 +++ drivers/gpu/drm/xe/xe_gt.c | 14 ++++++++++---- drivers/gpu/drm/xe/xe_guc_submit.c | 9 +++++---- drivers/gpu/drm/xe/xe_pci_error.c | 3 +++ 5 files changed, 36 insertions(+), 8 deletions(-)
drivers/gpu/drm/xe/xe_device.h +15 -0
@@ -181,6 +181,21 @@ static inline bool xe_device_has_mert(const struct xe_device *xe)return xe->info.has_mert; } +static inline bool xe_device_is_in_reset (struct xe_device *xe) +{ +return atomic_read (&xe->in_reset); +} + +static inline void xe_device_set_in_reset (struct xe_device *xe) +{ +atomic_set (&xe->in_reset,1 ); +} + +static inline void xe_device_clear_in_reset (struct xe_device *xe) +{ +atomic_set (&xe->in_reset,0 ); +} +u32 xe_device_ccs_bytes (struct xe_device *xe,u64 size);void xe_device_snapshot_print (struct xe_device *xe,struct drm_printer *p);
drivers/gpu/drm/xe/xe_device_types.h +3 -0
@@ -483,6 +483,9 @@ struct xe_device {/** @needs_flr_on_fini: requests function-reset on fini */ bool needs_flr_on_fini; +/** @in_reset: Indicates if device is in reset */ +atomic_t in_reset; +/** @wedged: Struct to control Wedged States and mode */ struct {/** @wedged.fini: Needs cleanup on fini */
drivers/gpu/drm/xe/xe_gt.c +10 -4
@@ -917,6 +917,9 @@ static void gt_reset_worker(struct work_struct *w)if (xe_device_wedged (gt_to_xe (gt))) goto err_pm_put; +if (xe_device_is_in_reset (gt_to_xe (gt))) + goto err_pm_put; +/* We only support GT resets with GuC submission */ if (!xe_device_uc_enabled (gt_to_xe (gt))) goto err_pm_put;
@@ -977,18 +980,21 @@ static void gt_reset_worker(struct work_struct *w)void xe_gt_reset_async (struct xe_gt *gt) { -xe_gt_info (gt,"trying reset from %ps\n" ,__builtin_return_address (0 )); +struct xe_device *xe =gt_to_xe (gt); + +if (xe_device_is_in_reset (xe)) +return ;/* Don't do a reset while one is already in flight */ if (!xe_fault_inject_gt_reset () &&xe_uc_reset_prepare (>->uc))return ; -xe_gt_info (gt,"reset queued\n" ); +xe_gt_info (gt,"reset queued from %ps\n" ,__builtin_return_address (0 ));/* Pair with put in gt_reset_worker() if work is enqueued */ -xe_pm_runtime_get_noresume (gt_to_xe (gt)); +xe_pm_runtime_get_noresume (xe);if (!queue_work (gt->ordered_wq, >->reset.worker)) -xe_pm_runtime_put (gt_to_xe (gt)); +xe_pm_runtime_put (xe); }void xe_gt_suspend_prepare (struct xe_gt *gt)
drivers/gpu/drm/xe/xe_guc_submit.c +5 -4
@@ -1511,7 +1511,7 @@ guc_exec_queue_timedout_job(struct drm_sched_job *drm_job)* If devcoredump not captured and GuC capture for the job is not ready * do manual capture first and decide later if we need to use it */ -if (!exec_queue_killed (q) && !xe->devcoredump.captured && +if (!xe_device_is_in_reset (xe) && !exec_queue_killed (q) && !xe->devcoredump.captured && !xe_guc_capture_get_matching_and_lock (q)) {/* take force wake before engine register manual capture */ CLASS (xe_force_wake, fw_ref)(gt_to_fw (q->gt),XE_FORCEWAKE_ALL );
@@ -1533,8 +1533,8 @@ guc_exec_queue_timedout_job(struct drm_sched_job *drm_job)set_exec_queue_banned (q);/* Kick job / queue off hardware */ -if (!wedged && (exec_queue_enabled (primary) || -exec_queue_pending_disable (primary))) { +if (!xe_device_is_in_reset (xe) && !wedged && + (exec_queue_enabled (primary) ||exec_queue_pending_disable (primary))) {int ret;if (exec_queue_reset (primary))
@@ -1602,7 +1602,8 @@ guc_exec_queue_timedout_job(struct drm_sched_job *drm_job)trace_xe_sched_job_timedout (job); -if (!exec_queue_killed (q)) +/* Do not access device if in reset */ +if (!xe_device_is_in_reset (xe) && !exec_queue_killed (q)) xe_devcoredump(q, job, "Timedout job - seqno=%u, lrc_seqno=%u, guc_id=%d, flags=0x%lx", xe_sched_job_seqno(job), xe_sched_job_lrc_seqno(job),
drivers/gpu/drm/xe/xe_pci_error.c +3 -0
@@ -17,6 +17,8 @@ static void prepare_device_for_reset(struct pci_dev *pdev)struct xe_gt *gt;u8 id; +xe_device_set_in_reset (xe); +/* Wedge the device to prevent userspace access during reset */ xe_device_wedged_get (xe);
@@ -82,6 +84,7 @@ static pci_ers_result_t xe_pci_error_slot_reset(struct pci_dev *pdev)* TODO: optimize by re-initializing only the hardware state and re-creating * kernel BOs. */ +xe_device_clear_in_reset (xe); pdev->driver->remove (pdev);devres_release_group (&pdev->dev, xe->devres_group_id);
Signature · 1 line
2.47.1
PATCH v7 7/15 drm/xe/xe_ras: Initialize Uncorrectable AER Registers
In reply to Riana TauroUncorrectable errors from different endpoints in the device are steered to the USP(Upstream Switch Port) which is a PCI Advanced Error Reporting (AER) Compliant device. Downgrade all the errors to non-fatal to prevent PCIe bus driver from triggering a Secondary Bus Reset (SBR). This allows error detection, containment and recovery in the driver.
The Uncorrectable Error Severity Register has the 'Uncorrectable Internal Error Severity' set to fatal by default. Set this to non-fatal and unmask the error.
---
v2: clear stale uncorrectable internal status in status register (Aravind)
v3: abbrevate TLA's (Raag)
add a info message if USP does not support AER
v4: add a success log (Raag)
v5: add extra newline
use IS_ENABLED check
remove VF check (Michal)
add function to get usp
--- drivers/gpu/drm/xe/xe_device.c | 3 ++ drivers/gpu/drm/xe/xe_ras.c | 81 ++++++++++++++++++++++++++++++++++ drivers/gpu/drm/xe/xe_ras.h | 1 + 3 files changed, 85 insertions(+)
drivers/gpu/drm/xe/xe_device.c +3 -0
@@ -61,6 +61,7 @@#include "xe_psmi.h" #include "xe_pxp.h" #include "xe_query.h" +#include "xe_ras.h" #include "xe_shrinker.h" #include "xe_soc_remapper.h" #include "xe_survivability_mode.h"
@@ -1074,6 +1075,8 @@ int xe_device_probe(struct xe_device *xe)if (err) goto err_unregister_display; +xe_ras_init (xe); + err =xe_device_sysfs_init (xe);if (err) goto err_unregister_display;
drivers/gpu/drm/xe/xe_ras.c +81 -0
84 lines not on this page · raw message
drivers/gpu/drm/xe/xe_ras.h +1 -0
@@ -11,5 +11,6 @@ struct xe_sysctrl_event_response;void xe_ras_counter_threshold_crossed (struct xe_device *xe,struct xe_sysctrl_event_response *response); +void xe_ras_init (struct xe_device *xe);#endif
Signature · 1 line
2.47.1
PATCH v7 8/15 drm/xe/xe_ras: Add support for uncorrectable core-compute errors
In reply to Riana TauroAdd structures and command for get soc error and process uncorrectable core-compute errors.
Uncorrectable core-compute errors are classified into global and local errors.
Global error is an error that affects the entire device requiring a reset. This type of error is not isolated. When an AER is reported and error_detected is invoked return PCI_ERS_RESULT_NEED_RESET.
Local error is confined to a specific component or context like a engine. These errors can be contained and recovered by resetting only the affected part without disrupting the rest of the device.
Upon detection of an uncorrectable local core-compute error, an AER is generated and GuC is notified of the error to trigger engine reset. Return recovered from PCI error callbacks for these errors as no action is needed.
---
v2: add newline and fix log
add bounds check (Mallesh)
add ras specific enum (Raag)
helper for sysctrl prepare command process all errors before deciding recovery action
v3: remove TODO from commit message
remove redundant rlen check
fix loop
add check for sysctrl flooding (Raag)
do not use xe_ras prefix for static functions (Soham)
v4: remove rlen initialization to 0
remove local variable
add error message for length mismatch (Raag)
reset on sysctrl flooding
fix sysctrl flood condition
v5: rebase
modify log and move it to process_errors
modify sysctrl flood check
remove whitespace
simplify structure (Raag)
fix typo in commit message
v6: remove xe parameter
remove error_class local variable (Mallesh) move prepare_sysctrl_command to sysctrl layer (Raag) shorten structure member names
rename count to remaining
fix sparse warnings
v7: rename sysctrl_build_command (Raag)
--- drivers/gpu/drm/xe/xe_ras.c | 110 ++++++++++++++++++ drivers/gpu/drm/xe/xe_ras.h | 3 + drivers/gpu/drm/xe/xe_ras_types.h | 55 +++++++++ drivers/gpu/drm/xe/xe_sysctrl_mailbox.c | 28 +++++ drivers/gpu/drm/xe/xe_sysctrl_mailbox.h | 4 +- drivers/gpu/drm/xe/xe_sysctrl_mailbox_types.h | 2 + 6 files changed, 201 insertions(+), 1 deletion(-)
drivers/gpu/drm/xe/xe_ras.c +110 -0
@@ -9,6 +9,11 @@#include "xe_ras_types.h" #include "xe_sysctrl.h" #include "xe_sysctrl_event_types.h" +#include "xe_sysctrl_mailbox.h" +#include "xe_sysctrl_mailbox_types.h" + +#define CORE_COMPUTE_UNCORR_TYPE GENMASK(26, 25) +#define GLOBAL_UNCORR_ERROR 2/* Severity of detected errors */ enum xe_ras_severity {
@@ -66,6 +71,24 @@ static inline const char *comp_to_str(u8 component)return xe_ras_components[component]; } +static enum xe_ras_recovery_action handle_core_compute_errors (struct xe_ras_error_array *arr) +{ +struct xe_ras_compute_error *error_info = (void *)arr->details; +u8 uncorr_type; + + uncorr_type =FIELD_GET (CORE_COMPUTE_UNCORR_TYPE , error_info->log_header); + +/* Request a reset if error is global */ +if (uncorr_type ==GLOBAL_UNCORR_ERROR ) +return XE_RAS_RECOVERY_ACTION_RESET ; + +/* +* No action needed for other errors. +* Local errors are recovered using an engine reset by GuC. +*/ +return XE_RAS_RECOVERY_ACTION_RECOVERED ; +} +void xe_ras_counter_threshold_crossed (struct xe_device *xe,struct xe_sysctrl_event_response *response) {
@@ -92,6 +115,93 @@ void xe_ras_counter_threshold_crossed(struct xe_device *xe, } } +/** +* xe_ras_process_errors() - Process and contain hardware errors +* @xe: xe device instance +* +* Get error details from system controller and return recovery +* method. Called only from PCI error handling. +* +* Returns: recovery action to be taken +*/ +enum xe_ras_recovery_action xe_ras_process_errors (struct xe_device *xe) +{ +struct xe_sysctrl_mailbox_command command = {0 }; +struct xe_ras_get_soc_error response; +enum xe_ras_recovery_action final_action; +u32 remaining =XE_SYSCTRL_FLOOD_LIMIT ; +size_t rlen; +int ret; + +if (!xe->info.has_sysctrl) +return XE_RAS_RECOVERY_ACTION_RESET ; + +/* Default action */ + final_action =XE_RAS_RECOVERY_ACTION_RECOVERED ; + +xe_sysctrl_create_command (&command,XE_SYSCTRL_GROUP_GFSP ,XE_SYSCTRL_CMD_GET_SOC_ERROR , +NULL ,0 , &response,sizeof (response)); + +do { +memset (&response,0 ,sizeof (response)); + + ret =xe_sysctrl_send_command (&xe->sc, &command, &rlen); +if (ret) { +xe_err (xe,"sysctrl: failed to get soc error %d\n" , ret); + goto err; + } + +if (rlen !=sizeof (response)) { +xe_err (xe,"sysctrl: unexpected get soc error response length %zu (expected %zu)\n" , + rlen,sizeof (response)); + goto err; + } + +/* Report if number of errors exceeds the maximum errors supported */ +if (response.num_errors >XE_RAS_NUM_ERROR_ARR ) +xe_err (xe,"sysctrl: number of errors received %d out of bound (%d)\n" , + response.num_errors,XE_RAS_NUM_ERROR_ARR ); + +for (int i =0 ; i < response.num_errors && i <XE_RAS_NUM_ERROR_ARR ; i++) { +struct xe_ras_error_array *arr = &response.arr[i]; +enum xe_ras_recovery_action action; +u8 component, severity; + + component = arr->counter.common.component; + severity = arr->counter.common.severity; + +xe_err (xe,"[RAS]: %s %s detected\n" ,comp_to_str (component), +sev_to_str (severity)); + +switch (component) { +case XE_RAS_COMP_CORE_COMPUTE : + action =handle_core_compute_errors (arr); +break ; +default : +/* For any other component, reset */ + action =XE_RAS_RECOVERY_ACTION_RESET ; +break ; + } + +/* Process and log all errors and then trigger highest recovery action */ +if (action > final_action) + final_action = action; + } + +/* Treat flooding as an system controller error */ +if (!--remaining) { +xe_err (xe,"[RAS]: sysctrl: get soc error response flooding\n" ); +return XE_RAS_RECOVERY_ACTION_RESET ; + } + + }while (response.additional_errors); + +return final_action; + +err: +return XE_RAS_RECOVERY_ACTION_RESET ; +} +static struct pci_dev *find_usp_dev (struct pci_dev *pdev) {struct pci_dev *vsp;
drivers/gpu/drm/xe/xe_ras.h +3 -0
@@ -6,11 +6,14 @@#ifndef _XE_RAS_H_#define _XE_RAS_H_ +#include "xe_ras_types.h" +struct xe_device ;struct xe_sysctrl_event_response ;void xe_ras_counter_threshold_crossed (struct xe_device *xe,struct xe_sysctrl_event_response *response);void xe_ras_init (struct xe_device *xe); +enum xe_ras_recovery_action xe_ras_process_errors (struct xe_device *xe);#endif
drivers/gpu/drm/xe/xe_ras_types.h +55 -0
67 lines not on this page · raw message
drivers/gpu/drm/xe/xe_sysctrl_mailbox.c +28 -0
@@ -307,6 +307,34 @@ void xe_sysctrl_mailbox_init(struct xe_sysctrl *sc) sc->phase_bit = (ctrl_reg &SYSCTRL_FRAME_PHASE ) ?1 :0 ; } +/** +* xe_sysctrl_create_command() - Create System controller command structure +* @command: Sysctrl command structure +* @group_id: Command group ID +* @cmd_id: Command ID +* @request: Pointer to request buffer (can be NULL) +* @request_len: Size of request buffer +* @response: Pointer to response buffer +* @response_len: Size of response buffer +* +* Helper function to create sysctrl command to be sent via xe_sysctrl_send_command() +*/ +void xe_sysctrl_create_command (struct xe_sysctrl_mailbox_command *command,u8 group_id,u8 cmd_id, +void *request,size_t request_len,void *response, +size_t response_len) +{ +struct xe_sysctrl_app_msg_hdr header = {0 }; + + header.data =FIELD_PREP (APP_HDR_GROUP_ID_MASK , group_id) | +FIELD_PREP (APP_HDR_COMMAND_MASK , cmd_id); + + command->header = header; + command->data_in = request; + command->data_in_len = request_len; + command->data_out = response; + command->data_out_len = response_len; +} +/** * xe_sysctrl_send_command() - Send mailbox command to System Controller * @sc: System Controller instance
drivers/gpu/drm/xe/xe_sysctrl_mailbox.h +3 -1
@@ -27,5 +27,7 @@ void xe_sysctrl_mailbox_init(struct xe_sysctrl *sc);int xe_sysctrl_send_command (struct xe_sysctrl *sc,struct xe_sysctrl_mailbox_command *cmd,size_t *rdata_len); - +void xe_sysctrl_create_command (struct xe_sysctrl_mailbox_command *command,u8 group_id,u8 cmd_id, +void *request,size_t request_len,void *response, +size_t response_len);#endif
drivers/gpu/drm/xe/xe_sysctrl_mailbox_types.h +2 -0
@@ -22,9 +22,11 @@ enum xe_sysctrl_group {/** * enum xe_sysctrl_gfsp_cmd - Commands supported by GFSP group * +* @XE_SYSCTRL_CMD_GET_SOC_ERROR: Retrieve basic error information * @XE_SYSCTRL_CMD_GET_PENDING_EVENT: Retrieve pending event */ enum xe_sysctrl_gfsp_cmd { +XE_SYSCTRL_CMD_GET_SOC_ERROR =0x01 ,XE_SYSCTRL_CMD_GET_PENDING_EVENT =0x07 , };
Signature · 1 line
2.47.1
PATCH v7 9/15 drm/xe/xe_ras: Handle uncorrectable SoC Internal errors
In reply to Riana TauroSome critical errors such as CSC firmware and Punit are reported under SoC internal errors and require special handling.
CSC errors are classified into hardware errors and firmware errors. Hardware errors can be recovered using a SBR (Secondary Bus Reset) whereas firmware errors are critical and require a firmware flash. On such errors, device is wedged and runtime survivability mode will be enabled to notify userspace that a firmware flash is required.
PUNIT uncorrectable errors can only be recovered through a cold reset.
---
v2: simplify soc structures
return error code for each SoC error (Mallesh)
v3: squash patches (Raag)
v4: re-use csc work
v5: do not use csc work (Mallesh)
simplify structure member names
fix sparse warnings
--- drivers/gpu/drm/xe/xe_ras.c | 45 ++++++++++++++++++++++++++++ drivers/gpu/drm/xe/xe_ras_types.h | 50 +++++++++++++++++++++++++++++++ 2 files changed, 95 insertions(+)
drivers/gpu/drm/xe/xe_ras.c +45 -0
@@ -7,6 +7,7 @@#include "xe_printk.h" #include "xe_ras.h" #include "xe_ras_types.h" +#include "xe_survivability_mode.h" #include "xe_sysctrl.h" #include "xe_sysctrl_event_types.h" #include "xe_sysctrl_mailbox.h"
@@ -89,6 +90,47 @@ static enum xe_ras_recovery_action handle_core_compute_errors(struct xe_ras_erroreturn XE_RAS_RECOVERY_ACTION_RECOVERED ; } +static enum xe_ras_recovery_action handle_soc_internal_errors (struct xe_device *xe, +struct xe_ras_error_array *arr) +{ +struct xe_ras_soc_error *info = (void *)arr->details; +struct xe_ras_soc_error_source *source = &info->source; +struct xe_ras_error_class *counter = &arr->counter; + +if (source->csc) { +struct xe_ras_csc_error *csc_error = (void *)info->details; + +/* +* CSC uncorrectable errors are classified as hardware errors and firmware errors. +* CSC firmware errors are critical errors that can be recovered only by firmware +* update via SPI driver. On a CSC firmware error, PCODE enables FDO mode and sets +* the bit in the capability register. On receiving this error, the driver enables +* runtime survivability mode which notifies userspace that a firmware update +* is required. +*/ +if (csc_error->hec_fw_error) { +xe_err (xe,"[RAS]: CSC %s detected: 0x%x\n" , +sev_to_str (counter->common.severity), + csc_error->hec_fw_error); +xe_survivability_mode_runtime_enable (xe); +return XE_RAS_RECOVERY_ACTION_DISCONNECT ; + } + }else if (source->ieh) { +struct xe_ras_ieh_error *ieh_error = (void *)info->details; + +if (ieh_error->global_error_status &XE_RAS_SOC_IEH_PUNIT ) { +xe_err (xe,"[RAS]: PUNIT %s detected: 0x%x\n" , +sev_to_str (counter->common.severity), + ieh_error->global_error_status); +/* TODO: Add PUNIT error handling */ +return XE_RAS_RECOVERY_ACTION_DISCONNECT ; + } + } + +/* For other SOC internal errors, request a reset as recovery mechanism */ +return XE_RAS_RECOVERY_ACTION_RESET ; +} +void xe_ras_counter_threshold_crossed (struct xe_device *xe,struct xe_sysctrl_event_response *response) {
@@ -177,6 +219,9 @@ enum xe_ras_recovery_action xe_ras_process_errors(struct xe_device *xe)case XE_RAS_COMP_CORE_COMPUTE : action =handle_core_compute_errors (arr);break ; +case XE_RAS_COMP_SOC_INTERNAL : + action =handle_soc_internal_errors (xe, arr); +break ;default :/* For any other component, reset */ action =XE_RAS_RECOVERY_ACTION_RESET ;
drivers/gpu/drm/xe/xe_ras_types.h +50 -0
60 lines not on this page · raw message
Signature · 1 line
2.47.1
PATCH v7 10/15 drm/xe/xe_ras: Add support to query device memory errors
In reply to Riana TauroAdd initial support to query uncorrectable device memory errors from system controller. Double bit ECC (Error Correcting Code) errors will be handled using Page offlining in a later patch. The other device memory error categories require a Secondary Bus Reset (SBR) to recover.
---
v2: simplify structures
v3: fix reserved member (Mallesh)
--- drivers/gpu/drm/xe/xe_ras.c | 18 ++++++++++++++++++ drivers/gpu/drm/xe/xe_ras_types.h | 17 +++++++++++++++++ 2 files changed, 35 insertions(+)
drivers/gpu/drm/xe/xe_ras.c +18 -0
@@ -131,6 +131,21 @@ static enum xe_ras_recovery_action handle_soc_internal_errors(struct xe_device *return XE_RAS_RECOVERY_ACTION_RESET ; } +static enum xe_ras_recovery_action handle_device_memory_errors (struct xe_device *xe, +struct xe_ras_error_array *arr) +{ +struct xe_ras_memory_error *info = (void *)arr->details; + +if (info->category &XE_RAS_MEMORY_ECC ) { +xe_err (xe,"[RAS]: double-bit ECC error detected at sw address 0x%llx\n" , + info->sw_address); +/* TODO: page offline handling for double-bit ECC errors and return accordingly */ + } + +/* Request a reset for other device memory error categories */ +return XE_RAS_RECOVERY_ACTION_RESET ; +} +void xe_ras_counter_threshold_crossed (struct xe_device *xe,struct xe_sysctrl_event_response *response) {
@@ -222,6 +237,9 @@ enum xe_ras_recovery_action xe_ras_process_errors(struct xe_device *xe)case XE_RAS_COMP_SOC_INTERNAL : action =handle_soc_internal_errors (xe, arr);break ; +case XE_RAS_COMP_DEVICE_MEMORY : + action =handle_device_memory_errors (xe, arr); +break ;default :/* For any other component, reset */ action =XE_RAS_RECOVERY_ACTION_RESET ;
drivers/gpu/drm/xe/xe_ras_types.h +17 -0
@@ -11,6 +11,7 @@#define XE_RAS_NUM_ERROR_ARR 3#define XE_RAS_NUM_COUNTERS 16#define XE_RAS_SOC_IEH_PUNIT BIT(1) +#define XE_RAS_MEMORY_ECC BIT(1)/** * enum xe_ras_recovery_action - RAS recovery actions
@@ -175,4 +176,20 @@ struct xe_ras_ieh_error {/** @info: Additional information */ u32 info[10]; } __packed; + +/** +* struct xe_ras_memory_error - Device memory error details +*/ +struct xe_ras_memory_error { +/** @category: Device memory error category */ +u8 category; +/** @reserved: Reserved for future use */ +u8 reserved[7 ]; +/** @hardware_address: Hardware physical address details */ +u64 hardware_address; +/** @sw_address: Software address where error occurred */ +u64 sw_address; +/** @reserved1: Reserved */ +u32 reserved1[10 ]; +} __packed;#endif
Signature · 1 line
2.47.1
PATCH v7 11/15 drm/xe/xe_ras: Query errors from system controller on probe
In reply to Riana TauroDuring probe, process and log any errors detected by firmware while the driver was not loaded. Critical errors such as Punit, CSC are reported through Pcode init failure, causing the driver to enter survivability mode on probe.
Move soc remapper and system controller initialization up in xe_device_probe to allow querying errors on module load
---
v2: fix comment (Raag)
v3: reword commit message (Umesh)
--- drivers/gpu/drm/xe/xe_device.c | 20 ++++++++++---------- drivers/gpu/drm/xe/xe_ras.c | 7 +++++++ 2 files changed, 17 insertions(+), 10 deletions(-)
drivers/gpu/drm/xe/xe_device.c +10 -10
@@ -989,6 +989,16 @@ int xe_device_probe(struct xe_device *xe)if (err)return err; + err =xe_soc_remapper_init (xe); +if (err) +return err; + + err =xe_sysctrl_init (xe); +if (err) +return err; + +xe_ras_init (xe); +/* * Now that GT is initialized (TTM in particular), * we can try to init display, and inherit the initial fb.
@@ -1029,10 +1039,6 @@ int xe_device_probe(struct xe_device *xe)xe_nvm_init (xe); - err =xe_soc_remapper_init (xe); -if (err) -return err; - err =xe_heci_gsc_init (xe);if (err)return err;
@@ -1071,12 +1077,6 @@ int xe_device_probe(struct xe_device *xe)if (err) goto err_unregister_display; - err =xe_sysctrl_init (xe); -if (err) - goto err_unregister_display; - -xe_ras_init (xe); - err =xe_device_sysfs_init (xe);if (err) goto err_unregister_display;
drivers/gpu/drm/xe/xe_ras.c +7 -0
@@ -344,4 +344,11 @@ void xe_ras_init(struct xe_device *xe)if (IS_ENABLED (CONFIG_PCIEAER ))aer_unmask_and_downgrade_internal_error (xe); + +/* +* During probe, process and log any errors detected by firmware while the driver was not +* loaded. Critical errors such as Punit and CSC are reported through Pcode init failure, +* causing the driver to enter survivability mode. +*/ +xe_ras_process_errors (xe); }
Signature · 1 line
2.47.1
PATCH v7 12/15 drm/xe/xe_pci_error: Process errors in mmio_enabled
In reply to Riana TauroQuery system controller when any non fatal error occurs to check the type of the error, contain and recover.
The system controller is queried in the mmio_enabled callback.
---
v2: use ras recovery enum (Raag)
v3: add comment for mapping
use const (Mallesh)
v4: use switch (Raag, Anshuman)
v5: call pci_prepare_reset() before requesting SBR
v6: rebase
--- drivers/gpu/drm/xe/xe_pci_error.c | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-)
drivers/gpu/drm/xe/xe_pci_error.c +20 -2
@@ -9,6 +9,7 @@#include "xe_gt.h" #include "xe_pci.h" #include "xe_printk.h" +#include "xe_ras.h" #include "xe_survivability_mode.h" static void prepare_device_for_reset (struct pci_dev *pdev)
@@ -28,6 +29,21 @@ static void prepare_device_for_reset(struct pci_dev *pdev)pci_disable_device (pdev); } +static pci_ers_result_t ras_action_to_pci_result (struct pci_dev *pdev,u32 action) +{ +switch (action) { +case XE_RAS_RECOVERY_ACTION_RECOVERED : +return PCI_ERS_RESULT_RECOVERED ; +case XE_RAS_RECOVERY_ACTION_RESET : +prepare_device_for_reset (pdev); +return PCI_ERS_RESULT_NEED_RESET ; +case XE_RAS_RECOVERY_ACTION_DISCONNECT : +return PCI_ERS_RESULT_DISCONNECT ; +default : +return PCI_ERS_RESULT_DISCONNECT ; + } +} +static pci_ers_result_t xe_pci_error_detected (struct pci_dev *pdev,pci_channel_state_t state) {struct xe_device *xe =pdev_to_xe_device (pdev);
@@ -56,11 +72,13 @@ static pci_ers_result_t xe_pci_error_detected(struct pci_dev *pdev, pci_channel_static pci_ers_result_t xe_pci_error_mmio_enabled (struct pci_dev *pdev) {struct xe_device *xe =pdev_to_xe_device (pdev); +enum xe_ras_recovery_action action;xe_err (xe,"PCI error: MMIO enabled\n" ); -/* TODO: Query system controller for the type of error and take appropriate action */ -return PCI_ERS_RESULT_RECOVERED ; + action =xe_ras_process_errors (xe); + +return ras_action_to_pci_result (pdev, action); }static pci_ers_result_t xe_pci_error_slot_reset (struct pci_dev *pdev)
Signature · 1 line
2.47.1
PATCH v7 13/15 drm/xe/xe_ras: Add support to query page offline queue and list
In reply to Riana TauroAdd support to query page offline list and queue from firmware during module load. The page offline list command retrieves pages that are already offlined by the firmware. The page offline queue command retrieves the pages pending to be offlined by the firmware. processing pages is done in a later patch.
---
v2: fix commit message
fix log (Tejas)
v3: move sysctrl prepare command to sysctrl layer (Raag)
v4: break if pages are 0 (Tejas)
--- drivers/gpu/drm/xe/xe_ras.c | 92 +++++++++++++++++++ drivers/gpu/drm/xe/xe_ras_types.h | 35 +++++++ drivers/gpu/drm/xe/xe_sysctrl_mailbox_types.h | 4 + 3 files changed, 131 insertions(+)
drivers/gpu/drm/xe/xe_ras.c +92 -0
@@ -146,6 +146,95 @@ static enum xe_ras_recovery_action handle_device_memory_errors(struct xe_devicereturn XE_RAS_RECOVERY_ACTION_RESET ; } +static void get_queued_pages (struct xe_device *xe) +{ +struct xe_sysctrl_mailbox_command command = {0 }; +struct xe_ras_page_offline_queue response = {0 }; +u32 count =0 ; +size_t rlen; +int ret; + +/* Supported only on platforms with system controller */ +if (!xe->info.has_sysctrl) +return ; + +xe_sysctrl_create_command (&command,XE_SYSCTRL_GROUP_GFSP , +XE_SYSCTRL_CMD_GET_OFFLINE_QUEUE ,NULL ,0 , &response, +sizeof (response)); + +do { +memset (&response,0 ,sizeof (response)); + + ret =xe_sysctrl_send_command (&xe->sc, &command, &rlen); +if (ret) { +xe_err (xe,"sysctrl: failed to get page offline queue %d\n" , ret); +return ; + } + +if (rlen !=sizeof (response)) { +xe_err (xe,"sysctrl: unexpected page offline queue response length %zu (expected %zu)\n" , + rlen,sizeof (response)); +return ; + } + +/* TODO: Process pages and offline them */ + + count += response.pages_returned; +if (!response.pages_returned) +break ; + +if (count > response.total_pages) { +xe_err (xe,"sysctrl: Pages returned from queue exceed total pages %u, returned %u\n" , + response.total_pages, count); +return ; + } + }while (response.additional_data); +} + +static void get_offlined_list (struct xe_device *xe) +{ +struct xe_sysctrl_mailbox_command command = {0 }; +struct xe_ras_page_offline_list response = {0 }; +u32 count =0 ; +size_t rlen; +int ret; + +/* Supported only on platforms with system controller */ +if (!xe->info.has_sysctrl) +return ; + +xe_sysctrl_create_command (&command,XE_SYSCTRL_GROUP_GFSP ,XE_SYSCTRL_CMD_GET_OFFLINE_LIST , +NULL ,0 , &response,sizeof (response)); + +do { +memset (&response,0 ,sizeof (response)); + + ret =xe_sysctrl_send_command (&xe->sc, &command, &rlen); +if (ret) { +xe_err (xe,"sysctrl: failed to get page offline list %d\n" , ret); +return ; + } + +if (rlen !=sizeof (response)) { +xe_err (xe,"sysctrl: unexpected page offline list response length %zu (expected %zu)\n" , + rlen,sizeof (response)); +return ; + } + +/* TODO: Process pages and offline them */ + + count += response.pages_returned; +if (!response.pages_returned) +break ; + +if (count > response.total_pages) { +xe_err (xe,"sysctrl: Pages returned from list exceed total pages %u, returned %u\n" , + response.total_pages, count); +return ; + } + }while (response.additional_data); +} +void xe_ras_counter_threshold_crossed (struct xe_device *xe,struct xe_sysctrl_event_response *response) {
@@ -345,6 +434,9 @@ void xe_ras_init(struct xe_device *xe)if (IS_ENABLED (CONFIG_PCIEAER ))aer_unmask_and_downgrade_internal_error (xe); +get_queued_pages (xe); +get_offlined_list (xe); +/* * During probe, process and log any errors detected by firmware while the driver was not * loaded. Critical errors such as Punit and CSC are reported through Pcode init failure,
drivers/gpu/drm/xe/xe_ras_types.h +35 -0
@@ -12,6 +12,7 @@#define XE_RAS_NUM_COUNTERS 16#define XE_RAS_SOC_IEH_PUNIT BIT(1)#define XE_RAS_MEMORY_ECC BIT(1) +#define XE_RAS_NUM_PAGES 25/** * enum xe_ras_recovery_action - RAS recovery actions
@@ -192,4 +193,38 @@ struct xe_ras_memory_error {/** @reserved1: Reserved */ u32 reserved1[10]; } __packed; + +/** +* struct xe_ras_page_offline_list - Response from get offline list command +*/ +struct xe_ras_page_offline_list { +/** @max_entries: Total no of pages that can be stored in flash */ +u32 max_entries; +/** @total_pages: Total number of permanently offlined pages */ +u32 total_pages; +/** @pages_returned: Number of pages returned in this response */ +u32 pages_returned; +/** @page_addresses: Array of permanently offlined page addresses (4KB aligned) */ +u64 page_addresses[XE_RAS_NUM_PAGES ]; +/** @additional_data: Indicates if more data is available */ +u8 additional_data; +/** @reserved: Reserved for future use */ +u8 reserved[3 ]; +} __packed; + +/** +* struct xe_ras_page_offline_queue - Response from get offline queue command +*/ +struct xe_ras_page_offline_queue { +/** @total_pages: Total number of queued pages */ +u32 total_pages; +/** @pages_returned: Number of pages returned in this response */ +u32 pages_returned; +/** @page_addresses: Array of page addresses (4KB aligned) */ +u64 page_addresses[XE_RAS_NUM_PAGES ]; +/** @additional_data: Indicates if more data is available */ +u8 additional_data; +/** @reserved: Reserved for future use */ +u8 reserved[3 ]; +} __packed;#endif
drivers/gpu/drm/xe/xe_sysctrl_mailbox_types.h +4 -0
@@ -24,10 +24,14 @@ enum xe_sysctrl_group {* * @XE_SYSCTRL_CMD_GET_SOC_ERROR: Retrieve basic error information * @XE_SYSCTRL_CMD_GET_PENDING_EVENT: Retrieve pending event +* @XE_SYSCTRL_CMD_GET_OFFLINE_LIST: Retrieve list of all offlined pages from flash +* @XE_SYSCTRL_CMD_GET_OFFLINE_QUEUE: Retrieve list of offlined queued pages from firmware */ enum xe_sysctrl_gfsp_cmd {XE_SYSCTRL_CMD_GET_SOC_ERROR =0x01 ,XE_SYSCTRL_CMD_GET_PENDING_EVENT =0x07 , +XE_SYSCTRL_CMD_GET_OFFLINE_LIST =0x09 , +XE_SYSCTRL_CMD_GET_OFFLINE_QUEUE =0x0A , };/**
Signature · 1 line
2.47.1
RFC PATCH v7 14/15 drm/xe/xe_ras: Add support to offline/decline a page address
In reply to Riana TauroThis will be integrated with the related address-fault handling flow once this patch is merged.
https://lore.kernel.org/intel-xe/[email protected]/
Sending for initial comments.
Add basic support for sending page offline/decline requests to system controller and use it for device memory ECC error handling.
Handle return values from xe_ttm_vram_handle_addr_fault() and take corresponding action. Pages that belong to critical BOs cannot be handled by offlining and require a SBR (Secondary Bus Reset). Pages that are configured for log-only handling are declined. Other eligible page addresses are offlined through firmware.
---
v2: set ret to 0 (Tejas)
use switch for status
--- drivers/gpu/drm/xe/xe_ras.c | 124 +++++++++++++++++- drivers/gpu/drm/xe/xe_ras_types.h | 58 ++++++++ drivers/gpu/drm/xe/xe_sysctrl_mailbox_types.h | 2 + 3 files changed, 182 insertions(+), 2 deletions(-)
drivers/gpu/drm/xe/xe_ras.c +122 -2
@@ -3,6 +3,7 @@* Copyright © 2026 Intel Corporation */ +#include "xe_bo.h" #include "xe_device.h" #include "xe_printk.h" #include "xe_ras.h"
@@ -72,6 +73,122 @@ static inline const char *comp_to_str(u8 component)return xe_ras_components[component]; } +static int ras_status_to_errno (u32 status) +{ +switch (status) { +case XE_RAS_STATUS_SUCCESS : +return 0 ; +case XE_RAS_STATUS_INVALID_PARAM : +return -EINVAL ; +case XE_RAS_STATUS_OP_NOT_SUPPORTED : +return -EOPNOTSUPP ; +case XE_RAS_STATUS_TIMEOUT : +return -ETIMEDOUT ; +case XE_RAS_STATUS_HARDWARE_FAILURE : +return -EIO ; +case XE_RAS_STATUS_INSUFFICIENT_RESOURCES : +return -ENOSPC ; +default : +return -EPROTO ; + } +} + +static int send_page_offline (struct xe_device *xe,enum xe_ras_page_action action,u64 page_address) +{ +struct xe_sysctrl_mailbox_command command = {0 }; +struct xe_ras_page_offline_request request = {0 }; +struct xe_ras_page_offline_response response = {0 }; +size_t rlen; +int ret; + +if (!xe->info.has_sysctrl) +return 0 ; + +if (action >=XE_RAS_PAGE_ACTION_MAX ) { +xe_err (xe,"[RAS]: Invalid page offline action %d\n" , action); +return -EINVAL ; + } + + request.page_address = page_address; + request.action = action; + +xe_sysctrl_create_command (&command,XE_SYSCTRL_GROUP_GFSP ,XE_SYSCTRL_CMD_PAGE_OFFLINE , + &request,sizeof (request), &response,sizeof (response)); + + ret =xe_sysctrl_send_command (&xe->sc, &command, &rlen); +if (ret) { +xe_err (xe,"sysctrl: failed to send page offline command %d\n" , ret); +return ret; + } + +if (rlen !=sizeof (response)) { +xe_err (xe,"sysctrl: unexpected page offline response length %zu (expected %zu)\n" , + rlen,sizeof (response)); +return -EINVAL ; + } + + ret =ras_status_to_errno (response.status); +if (ret) { +xe_err (xe,"sysctrl: page offline command failed with status %d\n" , + response.status); + } + +return ret; +} + +static int handle_page_offline (struct xe_device *xe,u64 page_address,bool send_offline_cmd) +{ +enum xe_ras_page_action action; +int ret =0 ; + +if (!IS_ALIGNED (page_address,XE_PAGE_SIZE )) { +xe_err (xe,"sysctrl: Unaligned page address: 0x%llx\n" , page_address); +return -EINVAL ; + } + +/* +* TODO: Call function to handle address fault +* ret = xe_ttm_vram_handle_addr_fault(xe, page_address); +*/ + +/* +* Handle return code from address fault handling function: +* 0: Address is valid and can be offlined +* -EIO: Address belongs to a critical BO that cannot be offlined +* -EOPNOTSUPP: Address is valid and can be offlined but user policy is not to offline +* +* For any other non-zero error code, skip offlining. +*/ + +switch (ret) { +case 0 : + action =XE_RAS_PAGE_ACTION_OFFLINE ; +break ; +/* User policy set to decline page offlining */ +case -EOPNOTSUPP : + action =XE_RAS_PAGE_ACTION_DECLINE ; +break ; +case -EIO : +xe_err (xe,"[RAS]: Page address belongs to critical BO: 0x%llx\n" , + page_address); +return ret; +default : +xe_err (xe,"[RAS]: Failed to handle address fault 0x%llx: %d\n" , + page_address, ret); +return 0 ; + } + +if (send_offline_cmd) { + ret =send_page_offline (xe, action, page_address); +if (ret) +xe_err (xe,"sysctrl: Failed to offline page for address 0x%llx: %d\n" , + page_address, ret); +return ret; + } + +return 0 ; +} +static enum xe_ras_recovery_action handle_core_compute_errors (struct xe_ras_error_array *arr) {struct xe_ras_compute_error *error_info = (void *)arr->details;
@@ -135,14 +252,17 @@ static enum xe_ras_recovery_action handle_device_memory_errors(struct xe_device struct xe_ras_error_array *arr) {struct xe_ras_memory_error *info = (void *)arr->details; +int ret;if (info->category &XE_RAS_MEMORY_ECC ) {xe_err (xe,"[RAS]: double-bit ECC error detected at sw address 0x%llx\n" , info->sw_address); -/* TODO: page offline handling for double-bit ECC errors and return accordingly */ + ret =handle_page_offline (xe, info->sw_address, true); +if (!ret) +return XE_RAS_RECOVERY_ACTION_RECOVERED ; } -/* Request a reset for other device memory error categories */ +/* Request a reset for other device memory errors and if page offlining failed */ return XE_RAS_RECOVERY_ACTION_RESET ; }
drivers/gpu/drm/xe/xe_ras_types.h +58 -0
68 lines not on this page · raw message
drivers/gpu/drm/xe/xe_sysctrl_mailbox_types.h +2 -0
@@ -24,12 +24,14 @@ enum xe_sysctrl_group {* * @XE_SYSCTRL_CMD_GET_SOC_ERROR: Retrieve basic error information * @XE_SYSCTRL_CMD_GET_PENDING_EVENT: Retrieve pending event +* @XE_SYSCTRL_CMD_PAGE_OFFLINE: Instruct firmware to offline/decline a page * @XE_SYSCTRL_CMD_GET_OFFLINE_LIST: Retrieve list of all offlined pages from flash * @XE_SYSCTRL_CMD_GET_OFFLINE_QUEUE: Retrieve list of offlined queued pages from firmware */ enum xe_sysctrl_gfsp_cmd {XE_SYSCTRL_CMD_GET_SOC_ERROR =0x01 ,XE_SYSCTRL_CMD_GET_PENDING_EVENT =0x07 , +XE_SYSCTRL_CMD_PAGE_OFFLINE =0x08 ,XE_SYSCTRL_CMD_GET_OFFLINE_LIST =0x09 ,XE_SYSCTRL_CMD_GET_OFFLINE_QUEUE =0x0A , };
Signature · 1 line
2.47.1
RFC PATCH v7 15/15 drm/xe/xe_ras: Process pages from offlined list and queue
In reply to Riana TauroThis will be integrated with the related address-fault handling flow once this patch is merged.
https://lore.kernel.org/intel-xe/[email protected]/
Sending for initial comments.
On module load, process pages queued by firmware for offlining by reserving and sending the offline/decline command to firmware. For already offlined pages in the firmware list, reserve the pages.
---
v2: remove newline (Tejas)
--- drivers/gpu/drm/xe/xe_ras.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
drivers/gpu/drm/xe/xe_ras.c +6 -4
@@ -272,7 +272,7 @@ static void get_queued_pages(struct xe_device *xe)struct xe_ras_page_offline_queue response = {0 };u32 count =0 ;size_t rlen; -int ret; +int ret, i;/* Supported only on platforms with system controller */ if (!xe->info.has_sysctrl)
@@ -297,7 +297,8 @@ static void get_queued_pages(struct xe_device *xe)return ; } -/* TODO: Process pages and offline them */ +for (i =0 ; i < response.pages_returned && i <XE_RAS_NUM_PAGES ; i++) +handle_page_offline (xe, response.page_addresses[i], true); count += response.pages_returned;if (!response.pages_returned)
@@ -317,7 +318,7 @@ static void get_offlined_list(struct xe_device *xe)struct xe_ras_page_offline_list response = {0 };u32 count =0 ;size_t rlen; -int ret; +int ret, i;/* Supported only on platforms with system controller */ if (!xe->info.has_sysctrl)
@@ -341,7 +342,8 @@ static void get_offlined_list(struct xe_device *xe)return ; } -/* TODO: Process pages and offline them */ +for (i =0 ; i < response.pages_returned && i <XE_RAS_NUM_PAGES ; i++) +handle_page_offline (xe, response.page_addresses[i], false); count += response.pages_returned;if (!response.pages_returned)
Signature · 1 line
2.47.1
Patchwork
CI✗ CI.checkpatch: warning for Introduce Xe Uncorrectable Error Handling (rev7)
In reply to Riana Tauro== Series Details ==
== Series Details ==
Series: Introduce Xe Uncorrectable Error Handling (rev7)
URL : https://patchwork.freedesktop.org/series/160482/
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 c986431059fe0130b6d273b728fdc0ad74c594f4
Author: Riana Tauro <[email protected]> Date: Fri Jun 5 15:05:01 2026 +0530
drm/xe/xe_ras: Process pages from offlined list and queue
This will be integrated with the related address-fault handling flow once this patch is merged.
https://lore.kernel.org/intel-xe/[email protected]/
Sending for initial comments.
On module load, process pages queued by firmware for offlining by reserving and sending the offline/decline command to firmware. For already offlined pages in the firmware list, reserve the pages.
+ /mt/dim checkpatch fe3f27ecb39e8357b0af59cfe9402fd5cc0c07b1 drm-intel 083c69bc290c drm/xe/xe_survivability: Decouple survivability info from boot survivability 83b126af89fa drm/xe/xe_sysctrl: Make sysctrl flood limit reusable58bdef6a5961 drm/xe: Improve wedged state managemente9124187f42c drm/xe/xe_pci_error: Implement PCI error recovery callbacks
-:60: WARNING:FILE_PATH_CHANGES: added, moved or deleted file(s), does MAINTAINERS need updating? #60:
new file mode 100644
total: 0 errors, 1 warnings, 0 checks, 147 lines checkedf054b3121006 drm/xe/xe_pci_error: Group all devres to release them on PCIe slot reset 60f1ada34dab drm/xe: Skip device access during PCI error recovery f3ee8a1dcb61 drm/xe/xe_ras: Initialize Uncorrectable AER Registers c7d524619153 drm/xe/xe_ras: Add support for uncorrectable core-compute errors 4ca18c29bb51 drm/xe/xe_ras: Handle uncorrectable SoC Internal errors bc818ccb2de9 drm/xe/xe_ras: Add support to query device memory errors b44b1b0ff548 drm/xe/xe_ras: Query errors from system controller on probe 4a1fe18d3855 drm/xe/xe_pci_error: Process errors in mmio_enabled 4d2cdc14ce96 drm/xe/xe_ras: Add support to query page offline queue and list 45ea4c1d21af drm/xe/xe_ras: Add support to offline/decline a page address c986431059fe drm/xe/xe_ras: Process pages from offlined list and queue
Patchwork
CI✗ CI.KUnit: failure for Introduce Xe Uncorrectable Error Handling (rev7)
In reply to Riana Tauro== Series Details ==
== Series Details ==
Series: Introduce Xe Uncorrectable Error Handling (rev7)
URL : https://patchwork.freedesktop.org/series/160482/
State : failure
== Summary ==
+ trap cleanup EXIT
+ /kernel/tools/testing/kunit/kunit.py run --kunitconfig /kernel/drivers/gpu/drm/xe/.kunitconfig ERROR:root:../drivers/gpu/drm/xe/xe_ras.c: In function ‘aer_unmask_and_downgrade_internal_error’:../drivers/gpu/drm/xe/xe_ras.c:506:24: error: ‘struct pci_dev’ has no member named ‘aer_cap’; did you mean ‘ats_cap’?
506 | aer_cap = usp->aer_cap;
| ^~~~~~~
| ats_capmake[7]: *** [../scripts/Makefile.build:289: drivers/gpu/drm/xe/xe_ras.o] Error 1 make[7]: *** Waiting for unfinished jobs....
make[6]: *** [../scripts/Makefile.build:548: drivers/gpu/drm/xe] Error 2 make[5]: *** [../scripts/Makefile.build:548: drivers/gpu/drm] Error 2 make[4]: *** [../scripts/Makefile.build:548: drivers/gpu] Error 2 make[3]: *** [../scripts/Makefile.build:548: drivers] Error 2 make[2]: *** [/kernel/Makefile:2143: .] Error 2
make[1]: *** [/kernel/Makefile:248: __sub-make] Error 2
make: *** [Makefile:248: __sub-make] Error 2
[11:28:50] Configuring KUnit Kernel ...
Generating .config ...
Populating config with:
$ make ARCH=um O=.kunit olddefconfig [11:28:54] 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 + cleanup ++ stat -c %u:%g /kernel + chown -R 1003:1003 /kernel