drm/xe: Extend uAPI to query HuC micro-controler firmware version
authorFrancois Dugast <francois.dugast@intel.com>
Thu, 8 Feb 2024 18:35:39 +0000 (10:35 -0800)
committerJosé Roberto de Souza <jose.souza@intel.com>
Mon, 26 Feb 2024 14:17:07 +0000 (06:17 -0800)
The infrastructure to query GuC firmware version is already in place. It
is extended with a new micro-controller type to query the HuC firmware
version. It can be used from user space to know if HuC is running.

Cc: John Harrison <John.C.Harrison@Intel.com>
Cc: Francois Dugast <francois.dugast@intel.com>
Cc: Lucas De Marchi <lucas.demarchi@intel.com>
Signed-off-by: Francois Dugast <francois.dugast@intel.com>
Signed-off-by: José Roberto de Souza <jose.souza@intel.com>
Reviewed-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
Reviewed-by: John Harrison <John.C.Harrison@Intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20240208183539.185095-2-jose.souza@intel.com
drivers/gpu/drm/xe/xe_query.c
include/uapi/drm/xe_drm.h

index f1876b5..a6a20a6 100644 (file)
@@ -540,14 +540,44 @@ query_uc_fw_version(struct xe_device *xe, struct drm_xe_device_query *query)
                version = &guc->fw.versions.found[XE_UC_FW_VER_COMPATIBILITY];
                break;
        }
+       case XE_QUERY_UC_TYPE_HUC: {
+               struct xe_gt *media_gt = NULL;
+               struct xe_huc *huc;
+
+               if (MEDIA_VER(xe) >= 13) {
+                       struct xe_tile *tile;
+                       u8 gt_id;
+
+                       for_each_tile(tile, xe, gt_id) {
+                               if (tile->media_gt) {
+                                       media_gt = tile->media_gt;
+                                       break;
+                               }
+                       }
+               } else {
+                       media_gt = xe->tiles[0].primary_gt;
+               }
+
+               if (!media_gt)
+                       break;
+
+               huc = &media_gt->uc.huc;
+               if (huc->fw.status == XE_UC_FIRMWARE_RUNNING)
+                       version = &huc->fw.versions.found[XE_UC_FW_VER_RELEASE];
+               break;
+       }
        default:
                return -EINVAL;
        }
 
-       resp.branch_ver = 0;
-       resp.major_ver = version->major;
-       resp.minor_ver = version->minor;
-       resp.patch_ver = version->patch;
+       if (version) {
+               resp.branch_ver = 0;
+               resp.major_ver = version->major;
+               resp.minor_ver = version->minor;
+               resp.patch_ver = version->patch;
+       } else {
+               return -ENODEV;
+       }
 
        if (copy_to_user(query_ptr, &resp, size))
                return -EFAULT;
index 538a3ac..2fc1917 100644 (file)
@@ -583,6 +583,7 @@ struct drm_xe_query_engine_cycles {
 struct drm_xe_query_uc_fw_version {
        /** @uc_type: The micro-controller type to query firmware version */
 #define XE_QUERY_UC_TYPE_GUC_SUBMISSION 0
+#define XE_QUERY_UC_TYPE_HUC 1
        __u16 uc_type;
 
        /** @pad: MBZ */