summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnoop Vijay <anoop.c.vijay@intel.com>2026-09-04 06:49:36 -0700
committerUmesh Nerlige Ramappa <umesh.nerlige.ramappa@intel.com>2026-09-09 12:44:20 -0700
commit0bae1d5438abecaf688b2df7ac30edf0482b8d90 (patch)
tree38690713a5ad8fc1022b311d5bbff2b9a4a2a4e6
parent73ae70cf843f93904bb02f8f213b50acfbb84ce7 (diff)
downloadlinux-next-0bae1d5438abecaf688b2df7ac30edf0482b8d90.tar.gz
linux-next-0bae1d5438abecaf688b2df7ac30edf0482b8d90.zip
drm/xe/sysctrl: Add helper to query application status
Add xe_sysctrl_check_app_status() to query the state of a System Controller application using get_app_status_by_id mailbox command. The helper maps xe_sysctrl_app_id values to firmware application IDs and returns the reported application state. Add a convenience wrapper to check diag firmware application readiness. Signed-off-by: Anoop Vijay <anoop.c.vijay@intel.com> Reviewed-by: Michael J. Ruhl <michael.j.ruhl@intel.com> Reviewed-by: Umesh Nerlige Ramappa <umesh.nerlige.ramappa@intel.com> Signed-off-by: Umesh Nerlige Ramappa <umesh.nerlige.ramappa@intel.com> Link: https://patch.msgid.link/20260904134935.674507-5-anoop.c.vijay@intel.com
-rw-r--r--drivers/gpu/drm/xe/xe_sysctrl.c73
-rw-r--r--drivers/gpu/drm/xe/xe_sysctrl.h1
-rw-r--r--drivers/gpu/drm/xe/xe_sysctrl_mailbox_types.h45
3 files changed, 119 insertions, 0 deletions
diff --git a/drivers/gpu/drm/xe/xe_sysctrl.c b/drivers/gpu/drm/xe/xe_sysctrl.c
index 62ccc9be71b4..3b7fa2c9c333 100644
--- a/drivers/gpu/drm/xe/xe_sysctrl.c
+++ b/drivers/gpu/drm/xe/xe_sysctrl.c
@@ -13,9 +13,11 @@
#include "xe_device.h"
#include "xe_mmio.h"
#include "xe_pm.h"
+#include "xe_printk.h"
#include "xe_soc_remapper.h"
#include "xe_sysctrl.h"
#include "xe_sysctrl_mailbox.h"
+#include "xe_sysctrl_mailbox_types.h"
#include "xe_sysctrl_types.h"
/**
@@ -29,6 +31,20 @@
* This module provides initialization and support code for interacting
* with System Controller through the mailbox interface.
*/
+
+/* Application status flags reported in xe_sysctrl_app_status_resp.flags */
+#define XE_SYSCTRL_APP_RESP_VALID BIT(0)
+#define XE_SYSCTRL_APP_RESP_BOOTED BIT(1)
+#define XE_SYSCTRL_APP_RESP_INITIALIZED BIT(2)
+
+/*
+ * Known System Controller application identifiers, keyed by firmware
+ * application ID.
+ */
+enum xe_sysctrl_app_id {
+ XE_SYSCTRL_APP_DIAG = 0x0D,
+};
+
static void sysctrl_fini(void *arg)
{
struct xe_device *xe = arg;
@@ -125,3 +141,60 @@ void xe_sysctrl_pm_resume(struct xe_device *xe)
xe->soc_remapper.set_sysctrl_region(xe, SYSCTRL_MAILBOX_INDEX);
}
+
+static enum xe_sysctrl_fw_status
+xe_sysctrl_check_app_status(struct xe_device *xe, enum xe_sysctrl_app_id app_id)
+{
+ struct xe_sysctrl_app_status_req req = {};
+ struct xe_sysctrl_app_status_resp resp = {};
+ struct xe_sysctrl_mailbox_command cmd = {};
+ size_t out_len = 0;
+ u32 flags;
+ int ret;
+
+ req.app_id = (u8)app_id;
+
+ xe_sysctrl_create_command(&cmd, XE_SYSCTRL_GROUP_CORE, XE_SYSCTRL_CMD_GET_APP_STATUS_BY_ID,
+ &req, sizeof(req), &resp, sizeof(resp));
+
+ ret = xe_sysctrl_send_command(&xe->sc, &cmd, &out_len);
+ if (ret)
+ return XE_SYSCTRL_FIRMWARE_COMM_FAILURE;
+
+ if (out_len != sizeof(resp)) {
+ xe_err(xe, "sysctrl: unexpected get app status response length %zu (expected %zu)\n",
+ out_len, sizeof(resp));
+ return XE_SYSCTRL_FIRMWARE_COMM_FAILURE;
+ }
+
+ flags = resp.flags;
+
+ if (!(flags & XE_SYSCTRL_APP_RESP_VALID))
+ return XE_SYSCTRL_FIRMWARE_APP_INVALID;
+
+ if (!(flags & XE_SYSCTRL_APP_RESP_BOOTED))
+ return XE_SYSCTRL_FIRMWARE_APP_NOT_LOADED;
+
+ if (!(flags & XE_SYSCTRL_APP_RESP_INITIALIZED))
+ return XE_SYSCTRL_FIRMWARE_APP_BOOTED;
+
+ return XE_SYSCTRL_FIRMWARE_APP_INITIALIZED;
+}
+
+/**
+ * xe_sysctrl_is_diag_fw_ready() - Check if diag firmware is fully initialized
+ * @xe: xe device instance
+ *
+ * Returns true if diag firmware has reached the initialized state, indicating
+ * it is ready to handle requests.
+ *
+ * Callers must only invoke this on platforms where System Controller is
+ * present (xe->info.has_sysctrl).
+ *
+ * Return: true if diag firmware is initialized, false otherwise
+ */
+bool xe_sysctrl_is_diag_fw_ready(struct xe_device *xe)
+{
+ return xe_sysctrl_check_app_status(xe, XE_SYSCTRL_APP_DIAG) ==
+ XE_SYSCTRL_FIRMWARE_APP_INITIALIZED;
+}
diff --git a/drivers/gpu/drm/xe/xe_sysctrl.h b/drivers/gpu/drm/xe/xe_sysctrl.h
index 090dffb6d55f..8dc576796890 100644
--- a/drivers/gpu/drm/xe/xe_sysctrl.h
+++ b/drivers/gpu/drm/xe/xe_sysctrl.h
@@ -20,5 +20,6 @@ void xe_sysctrl_event(struct xe_sysctrl *sc);
int xe_sysctrl_init(struct xe_device *xe);
void xe_sysctrl_irq_handler(struct xe_device *xe, u32 master_ctl);
void xe_sysctrl_pm_resume(struct xe_device *xe);
+bool xe_sysctrl_is_diag_fw_ready(struct xe_device *xe);
#endif
diff --git a/drivers/gpu/drm/xe/xe_sysctrl_mailbox_types.h b/drivers/gpu/drm/xe/xe_sysctrl_mailbox_types.h
index 66e7cbcc3f91..c236e5377f30 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_group - System Controller command groups
*
* @XE_SYSCTRL_GROUP_GFSP: GFSP group
+ * @XE_SYSCTRL_GROUP_CORE: Core group
*/
enum xe_sysctrl_group {
XE_SYSCTRL_GROUP_GFSP = 0x01,
+ XE_SYSCTRL_GROUP_CORE = 0xFF,
};
/**
@@ -43,6 +45,49 @@ enum xe_sysctrl_gfsp_cmd {
};
/**
+ * enum xe_sysctrl_core_cmd - Commands supported by Core group
+ *
+ * @XE_SYSCTRL_CMD_GET_APP_STATUS_BY_ID: Retrieve application status by ID
+ */
+enum xe_sysctrl_core_cmd {
+ XE_SYSCTRL_CMD_GET_APP_STATUS_BY_ID = 0x05,
+};
+
+/**
+ * struct xe_sysctrl_app_status_req - Get application status request
+ *
+ * @app_id: Application ID for which to retrieve status
+ */
+struct xe_sysctrl_app_status_req {
+ u8 app_id;
+} __packed;
+
+/**
+ * struct xe_sysctrl_app_status_resp - Get application status response
+ * @flags: Application status flags interpreted by xe_sysctrl_check_app_status()
+ */
+struct xe_sysctrl_app_status_resp {
+ u32 flags;
+} __packed;
+
+/**
+ * enum xe_sysctrl_fw_status - System Controller firmware application lifecycle states
+ *
+ * @XE_SYSCTRL_FIRMWARE_APP_INVALID: app_id is not recognized by firmware
+ * @XE_SYSCTRL_FIRMWARE_APP_NOT_LOADED: application is known but has not yet booted
+ * @XE_SYSCTRL_FIRMWARE_APP_BOOTED: boot sequence completed, post-boot init pending
+ * @XE_SYSCTRL_FIRMWARE_APP_INITIALIZED: application fully operational
+ * @XE_SYSCTRL_FIRMWARE_COMM_FAILURE: communication with System Controller firmware failed
+ */
+enum xe_sysctrl_fw_status {
+ XE_SYSCTRL_FIRMWARE_APP_INVALID,
+ XE_SYSCTRL_FIRMWARE_APP_NOT_LOADED,
+ XE_SYSCTRL_FIRMWARE_APP_BOOTED,
+ XE_SYSCTRL_FIRMWARE_APP_INITIALIZED,
+ XE_SYSCTRL_FIRMWARE_COMM_FAILURE,
+};
+
+/**
* struct xe_sysctrl_mailbox_command - System Controller mailbox command
*/
struct xe_sysctrl_mailbox_command {