[PATCH v4 10/13] drm/xe/xe_ras: Add support to offline/decline a page

Riana Tauro
2026-04-17T08:26:13Z

Add a helper function that sends commands to system controller
to offline/decline a page based on user policy.

Cc: Tejas Upadhyay <tejas.upadhyay@intel.com>
Cc: Himal Prasad Ghimiray <himal.prasad.ghimiray@intel.com>
Signed-off-by: Riana Tauro <riana.tauro@intel.com>
---
drivers/gpu/drm/xe/xe_ras.c | 51 +++++++++++++++++++
drivers/gpu/drm/xe/xe_ras.h | 2 +
drivers/gpu/drm/xe/xe_ras_types.h | 37 ++++++++++++++
drivers/gpu/drm/xe/xe_sysctrl_mailbox_types.h | 4 +-
4 files changed, 93 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/xe/xe_ras.c b/drivers/gpu/drm/xe/xe_ras.c
index 347844b3d2bf..cd1ac6441b92 100644
--- a/drivers/gpu/drm/xe/xe_ras.c
+++ b/drivers/gpu/drm/xe/xe_ras.c
@@ -268,6 +268,57 @@ enum xe_ras_recovery_action xe_ras_process_errors(struct xe_device *xe)
return XE_RAS_RECOVERY_ACTION_RESET;
}

+/**
+ * xe_ras_page_offline() - Send page offline/decline request to system controller
+ * @xe: xe device instance
+ * @action: Action to be performed (offline/decline)
+ * @page_address: address of the page
+ *
+ * Returns: 0 on success, negative error code on failure
+ */
+int xe_ras_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;
+
+ prepare_sysctrl_command(&command, 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, "[RAS]: sysctrl: error ret %d\n", ret);
+ return ret;
+ }
+
+ if (rlen != sizeof(response)) {
+ xe_err(xe, "[RAS]: sysctrl: response size mismatch. Expected %zu, got %zu\n",
+ sizeof(response), rlen);
+ return -EINVAL;
+ }
+
+ if (response.status) {
+ xe_err(xe, "[RAS]: sysctrl: Page offline command failed with status %u\n",
+ response.status);
+ return -EIO;
+ }
+
+ return 0;
+}
+
#ifdef CONFIG_PCIEAER
static void aer_unmask_and_downgrade_internal_error(struct xe_device *xe)
{
diff --git a/drivers/gpu/drm/xe/xe_ras.h b/drivers/gpu/drm/xe/xe_ras.h
index e191ab80080c..ec59258eb3df 100644
--- a/drivers/gpu/drm/xe/xe_ras.h
+++ b/drivers/gpu/drm/xe/xe_ras.h
@@ -12,5 +12,7 @@ struct xe_device;

void xe_ras_init(struct xe_device *xe);
enum xe_ras_recovery_action xe_ras_process_errors(struct xe_device *xe);
+int xe_ras_page_offline(struct xe_device *xe, enum xe_ras_page_action action,
+ u64 page_address);

#endif
diff --git a/drivers/gpu/drm/xe/xe_ras_types.h b/drivers/gpu/drm/xe/xe_ras_types.h
index 020e3f92a057..d76310866da5 100644
--- a/drivers/gpu/drm/xe/xe_ras_types.h
+++ b/drivers/gpu/drm/xe/xe_ras_types.h
@@ -30,6 +30,19 @@ enum xe_ras_recovery_action {
XE_RAS_RECOVERY_ACTION_MAX
};

+/**
+ * enum xe_ras_page_action - Page offline actions for page offline request
+ *
+ * @XE_RAS_PAGE_ACTION_OFFLINE: Instruct firmware to remove page from queue
+ * @XE_RAS_PAGE_ACTION_DECLINE: Instruct firmware to mark page as not offline
+ * @XE_RAS_PAGE_ACTION_MAX: Max value for validation
+ */
+enum xe_ras_page_action {
+ XE_RAS_PAGE_ACTION_OFFLINE,
+ XE_RAS_PAGE_ACTION_DECLINE,
+ XE_RAS_PAGE_ACTION_MAX
+};
+
/**
* struct xe_ras_error_common - Common RAS error class
*
@@ -260,4 +273,28 @@ struct xe_ras_memory_error {
/** @reserved2: Reserved for future use */
u32 reserved2[2];
} __packed;
+
+/**
+ * struct xe_ras_page_offline_request - Request for page offline command
+ *
+ * This structure provides the request format to offline/decline a page
+ */
+struct xe_ras_page_offline_request {
+ /** @page_address: Page address (4KB aligned) */
+ u64 page_address;
+ /** @action: Action to be performed (enum xe_ras_page_action) */
+ u32 action;
+ /** @reserved: Reserved for future use */
+ u32 reserved;
+} __packed;
+
+/**
+ * struct xe_ras_page_offline_response - Response from page offline command
+ */
+struct xe_ras_page_offline_response {
+ /** @status: Status of the page offline request */
+ u32 status;
+ /** @reserved: Reserved for future use */
+ u32 reserved;
+} __packed;
#endif
diff --git a/drivers/gpu/drm/xe/xe_sysctrl_mailbox_types.h b/drivers/gpu/drm/xe/xe_sysctrl_mailbox_types.h
index 00a0f05aab32..2cafa8a14cc3 100644
--- a/drivers/gpu/drm/xe/xe_sysctrl_mailbox_types.h
+++ b/drivers/gpu/drm/xe/xe_sysctrl_mailbox_types.h
@@ -14,9 +14,11 @@
* enum xe_sysctrl_mailbox_command_id - Command ID's for GFSP group
*
* @XE_SYSCTRL_CMD_GET_SOC_ERROR: Get basic error information
+ * @XE_SYSCTRL_CMD_PAGE_OFFLINE: Instruct firmware to offline/decline a page
*/
enum xe_sysctrl_mailbox_command_id {
- XE_SYSCTRL_CMD_GET_SOC_ERROR = 0x01
+ XE_SYSCTRL_CMD_GET_SOC_ERROR = 0x01,
+ XE_SYSCTRL_CMD_PAGE_OFFLINE = 0x08
};

enum xe_sysctrl_group {
--
2.47.1