Intel-XE Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm/xe/ras: Add RAS config command to downgrade AER uncorrectable internal error
@ 2026-11-17  9:57 Riana Tauro
  2026-11-17 10:06 ` ✓ CI.KUnit: success for " Patchwork
  2026-11-17 10:11 ` [PATCH] " sashiko-bot
  0 siblings, 2 replies; 3+ messages in thread
From: Riana Tauro @ 2026-11-17  9:57 UTC (permalink / raw)
  To: intel-xe
  Cc: riana.tauro, anshuman.gupta, aravind.iddamsetty, raag.jadav,
	badal.nilawar, ravi.kishore.koppuravuri, mallesh.koujalagi,
	soham.purkait

The driver downgrades the AER uncorrectable internal error severity of the
upstream switch port (USP) to non-fatal, so that errors can be handled
by the driver. This is done by writing the AER registers of the USP
directly, which is only allowed when the OS has native control of AER.

The OS does not have native control of AER when the platform uses firmware
first error handling or when native AER is disabled (pcie_ports=compat).
In these cases the driver cannot program the USP AER registers, so request
the firmware to downgrade the error instead.

The firmware provides a generic configuration command to get or set
firmware owned RAS configuration settings. Add support for this
configuration command and use it to request the firmware to downgrade the
severity when the OS does not have native control of AER.

Signed-off-by: Riana Tauro <riana.tauro@intel.com>
---

Note: This change to remove the cxl namespace from pcie_aer_is_native
function is discussed in the following mailing list thread:
https://lore.kernel.org/all/avs1MPhrZtf7u_uB@wunner.de/
The cxl import will be removed once this change is merged.
Sending this for initial review.

---
 drivers/gpu/drm/xe/xe_ras.c                   | 65 +++++++++++++++++++
 drivers/gpu/drm/xe/xe_ras_types.h             | 58 +++++++++++++++++
 drivers/gpu/drm/xe/xe_sysctrl_mailbox_types.h |  2 +
 3 files changed, 125 insertions(+)

diff --git a/drivers/gpu/drm/xe/xe_ras.c b/drivers/gpu/drm/xe/xe_ras.c
index 0fb891d00b36..8055340d0096 100644
--- a/drivers/gpu/drm/xe/xe_ras.c
+++ b/drivers/gpu/drm/xe/xe_ras.c
@@ -3,6 +3,7 @@
  * Copyright © 2026 Intel Corporation
  */
 
+#include <linux/aer.h>
 #include <linux/bitfield.h>
 
 #include <generated/xe_device_wa_oob.h>
@@ -508,17 +509,80 @@ static void get_offline_list(struct xe_device *xe)
 			      &response, sizeof(response), &response.common, false);
 }
 
+static inline const char *action_to_str(enum xe_ras_config_action action)
+{
+	return action == XE_RAS_CONFIG_ACTION_GET ? "get" : "set";
+}
+
+static int ras_config(struct xe_device *xe, enum xe_ras_config config,
+		      enum xe_ras_config_action action)
+{
+	struct xe_sysctrl_mailbox_command command = {0};
+	struct xe_ras_config_response response = {0};
+	struct xe_ras_config_request request = {0};
+	size_t len;
+	int ret;
+
+	request.config = config;
+	request.action = action;
+
+	xe_sysctrl_create_command(&command, XE_SYSCTRL_GROUP_GFSP, XE_SYSCTRL_CMD_RAS_CONFIG,
+				  &request, sizeof(request), &response, sizeof(response));
+
+	guard(xe_pm_runtime)(xe);
+	ret = xe_sysctrl_send_command(&xe->sc, &command, &len);
+	if (ret) {
+		xe_err(xe, "sysctrl: failed to %s config %u: %d\n", action_to_str(action), config,
+		       ret);
+		return ret;
+	}
+
+	if (len != sizeof(response)) {
+		xe_err(xe, "sysctrl: unexpected %s config response length %zu (expected %zu)\n",
+		       action_to_str(action), len, sizeof(response));
+		return -EIO;
+	}
+
+	ret = ras_status_to_errno(response.status);
+	if (ret) {
+		xe_err(xe, "sysctrl: %s config command failed with status %#x\n",
+		       action_to_str(action), response.status);
+		return ret;
+	}
+
+	if (response.size)
+		xe_dbg(xe, "[RAS]: %s config %u, data (%u bytes): %*ph\n",
+		       action_to_str(response.action), response.config, response.size,
+		       (int)min(response.size, sizeof(response.data)), response.data);
+
+	return 0;
+}
+
 static void ras_usp_aer_init(struct xe_device *xe)
 {
 	struct pci_dev *pdev = to_pci_dev(xe->drm.dev);
+	enum xe_ras_config config;
 	struct pci_dev *usp;
 	u16 aer_cap;
 	u32 status;
+	int ret;
 
 	usp = xe_pci_get_usp_dev(pdev);
 	if (!usp)
 		return;
 
+	if (!pcie_aer_is_native(usp)) {
+		config = XE_RAS_CONFIG_USP_AER_UNCOR_INTERNAL_NONFATAL;
+
+		ret = ras_config(xe, config, XE_RAS_CONFIG_ACTION_SET);
+		if (ret)
+			return;
+
+		/* Read the configuration */
+		ras_config(xe, config, XE_RAS_CONFIG_ACTION_GET);
+		return;
+	}
+
 	aer_cap = pci_find_ext_capability(usp, PCI_EXT_CAP_ID_ERR);
 	if (!aer_cap) {
 		dev_warn(&usp->dev, "AER capability unavailable\n");
@@ -553,6 +617,7 @@ static void ras_usp_aer_init(struct xe_device *xe)
 	pci_save_state(usp);
 	dev_dbg(&usp->dev, "Uncorrectable Internal Errors downgraded and unmasked\n");
 }
+MODULE_IMPORT_NS("CXL");
 
 static void ras_send_error_event(struct xe_device *xe, u8 severity, u8 component)
 {
diff --git a/drivers/gpu/drm/xe/xe_ras_types.h b/drivers/gpu/drm/xe/xe_ras_types.h
index 0ff5803d495b..b62a48446fb0 100644
--- a/drivers/gpu/drm/xe/xe_ras_types.h
+++ b/drivers/gpu/drm/xe/xe_ras_types.h
@@ -50,6 +50,30 @@ enum xe_ras_recovery_action {
 	XE_RAS_RECOVERY_ACTION_MAX
 };
 
+/**
+ * enum xe_ras_config_action - Action requested for a config
+ *
+ * @XE_RAS_CONFIG_ACTION_GET: Get the current state of the config
+ * @XE_RAS_CONFIG_ACTION_SET: Set the config
+ * @XE_RAS_CONFIG_ACTION_MAX: Max action value
+ */
+enum xe_ras_config_action {
+	XE_RAS_CONFIG_ACTION_GET = 0,
+	XE_RAS_CONFIG_ACTION_SET,
+	XE_RAS_CONFIG_ACTION_MAX
+};
+
+/**
+ * enum xe_ras_config - RAS configuration options
+ *
+ * @XE_RAS_CONFIG_USP_AER_UNCOR_INTERNAL_NONFATAL: Downgrade USP AER Uncorrectable Internal Error
+ * @XE_RAS_CONFIG_MAX: Max config value
+ */
+enum xe_ras_config {
+	XE_RAS_CONFIG_USP_AER_UNCOR_INTERNAL_NONFATAL = 0x01,
+	XE_RAS_CONFIG_MAX
+};
+
 /**
  * struct xe_ras_error_common - Error fields that are common across all products
  */
@@ -408,6 +432,40 @@ struct xe_ras_set_health_response {
 	u32 reserved1[2];
 } __packed;
 
+/**
+ * struct xe_ras_config_request - Request structure for RAS configuration
+ */
+struct xe_ras_config_request {
+	/** @config: Config id, see &enum xe_ras_config */
+	u16 config;
+	/** @action: Action to perform, see &enum xe_ras_config_action */
+	u8 action;
+	/** @reserved: Reserved for future use */
+	u8 reserved;
+	/** @size: Bytes valid in the payload */
+	u32 size;
+	/** @data: Payload */
+	u32 data[16];
+} __packed;
+
+/**
+ * struct xe_ras_config_response - Response structure for RAS configuration
+ */
+struct xe_ras_config_response {
+	/** @status: Status of config operation */
+	u32 status;
+	/** @config: Config id from request, see &enum xe_ras_config */
+	u16 config;
+	/** @action: Action that was performed, see &enum xe_ras_config_action */
+	u8 action;
+	/** @reserved: Reserved for future use */
+	u8 reserved;
+	/** @size: Bytes valid in the payload */
+	u32 size;
+	/** @data: Payload */
+	u32 data[16];
+} __packed;
+
 /* Device structures */
 
 /**
diff --git a/drivers/gpu/drm/xe/xe_sysctrl_mailbox_types.h b/drivers/gpu/drm/xe/xe_sysctrl_mailbox_types.h
index cdacceebca06..34ced248aa68 100644
--- a/drivers/gpu/drm/xe/xe_sysctrl_mailbox_types.h
+++ b/drivers/gpu/drm/xe/xe_sysctrl_mailbox_types.h
@@ -37,6 +37,7 @@ enum xe_sysctrl_group {
  * @XE_SYSCTRL_CMD_GET_OFFLINE_QUEUE: Retrieve list of offlined queued pages from firmware
  * @XE_SYSCTRL_CMD_GET_HEALTH: Retrieve gpu health
  * @XE_SYSCTRL_CMD_SET_HEALTH: Set gpu health
+ * @XE_SYSCTRL_CMD_RAS_CONFIG: Get or set FW RAS configuration
  */
 enum xe_sysctrl_gfsp_cmd {
 	XE_SYSCTRL_CMD_GET_SOC_ERROR		= 0x01,
@@ -50,6 +51,7 @@ enum xe_sysctrl_gfsp_cmd {
 	XE_SYSCTRL_CMD_GET_OFFLINE_QUEUE	= 0x0A,
 	XE_SYSCTRL_CMD_GET_HEALTH		= 0x0B,
 	XE_SYSCTRL_CMD_SET_HEALTH		= 0x0C,
+	XE_SYSCTRL_CMD_RAS_CONFIG		= 0x0E,
 };
 
 /**
-- 
2.47.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-11-17 10:11 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-17  9:57 [PATCH] drm/xe/ras: Add RAS config command to downgrade AER uncorrectable internal error Riana Tauro
2026-11-17 10:06 ` ✓ CI.KUnit: success for " Patchwork
2026-11-17 10:11 ` [PATCH] " sashiko-bot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox