drm/xe/guc: Report submission version of GuC firmware
authorMatthew Brost <matthew.brost@intel.com>
Thu, 12 Jan 2023 22:25:31 +0000 (17:25 -0500)
committerRodrigo Vivi <rodrigo.vivi@intel.com>
Tue, 12 Dec 2023 19:06:00 +0000 (14:06 -0500)
Starting in 70.6.* GuC firmware the CSS header includes the submission
version, pull this from the CSS header. Prior 70.* versions accidentally
omitted this informatio so hard code to the correct values. This
information will be used by VFs when communicating with the PF.

Signed-off-by: Matthew Brost <matthew.brost@intel.com>
Reviewed-by: Philippe Lecluse <philippe.lecluse1@gmail.com>
Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
drivers/gpu/drm/xe/xe_guc_types.h
drivers/gpu/drm/xe/xe_uc_fw.c
drivers/gpu/drm/xe/xe_uc_fw_abi.h

index ca177853cc12c3a1222240aa5b2cb54c45d675ef..c2a484282ef2ce47e00cf1a40a6df49c1706e102 100644 (file)
@@ -51,6 +51,15 @@ struct xe_guc {
                        /** @seqno: suspend fences seqno */
                        u32 seqno;
                } suspend;
+               /** @version: submission version */
+               struct {
+                       /** @major: major version of GuC submission */
+                       u32 major;
+                       /** @minor: minor version of GuC submission */
+                       u32 minor;
+                       /** @patch: patch version of GuC submission */
+                       u32 patch;
+               } version;
        } submission_state;
        /** @hwconfig: Hardware config state */
        struct {
index cd264cf50d30542dec93d856758fa77d62f44656..bd89ac27828e5bbcab6ae4d36297af654a3e2be3 100644 (file)
@@ -184,6 +184,40 @@ static void uc_fw_fini(struct drm_device *drm, void *arg)
        xe_uc_fw_change_status(uc_fw, XE_UC_FIRMWARE_SELECTED);
 }
 
+static void guc_read_css_info(struct xe_uc_fw *uc_fw, struct uc_css_header *css)
+{
+       struct xe_gt *gt = uc_fw_to_gt(uc_fw);
+       struct xe_guc *guc = &gt->uc.guc;
+
+       XE_BUG_ON(uc_fw->type != XE_UC_FW_TYPE_GUC);
+       XE_WARN_ON(uc_fw->major_ver_found < 70);
+
+       if (uc_fw->major_ver_found > 70 || uc_fw->minor_ver_found >= 6) {
+               /* v70.6.0 adds CSS header support */
+               guc->submission_state.version.major =
+                       FIELD_GET(CSS_SW_VERSION_UC_MAJOR,
+                                 css->submission_version);
+               guc->submission_state.version.minor =
+                       FIELD_GET(CSS_SW_VERSION_UC_MINOR,
+                                 css->submission_version);
+               guc->submission_state.version.patch =
+                       FIELD_GET(CSS_SW_VERSION_UC_PATCH,
+                                 css->submission_version);
+       } else if (uc_fw->minor_ver_found >= 3) {
+               /* v70.3.0 introduced v1.1.0 */
+               guc->submission_state.version.major = 1;
+               guc->submission_state.version.minor = 1;
+               guc->submission_state.version.patch = 0;
+       } else {
+               /* v70.0.0 introduced v1.0.0 */
+               guc->submission_state.version.major = 1;
+               guc->submission_state.version.minor = 0;
+               guc->submission_state.version.patch = 0;
+       }
+
+       uc_fw->private_data_size = css->private_data_size;
+}
+
 int xe_uc_fw_init(struct xe_uc_fw *uc_fw)
 {
        struct xe_device *xe = uc_fw_to_xe(uc_fw);
@@ -278,7 +312,7 @@ int xe_uc_fw_init(struct xe_uc_fw *uc_fw)
        }
 
        if (uc_fw->type == XE_UC_FW_TYPE_GUC)
-               uc_fw->private_data_size = css->private_data_size;
+               guc_read_css_info(uc_fw, css);
 
        obj = xe_bo_create_from_data(xe, gt, fw->data, fw->size,
                                     ttm_bo_type_kernel,
@@ -403,4 +437,14 @@ void xe_uc_fw_print(struct xe_uc_fw *uc_fw, struct drm_printer *p)
                   uc_fw->major_ver_found, uc_fw->minor_ver_found);
        drm_printf(p, "\tuCode: %u bytes\n", uc_fw->ucode_size);
        drm_printf(p, "\tRSA: %u bytes\n", uc_fw->rsa_size);
+
+       if (uc_fw->type == XE_UC_FW_TYPE_GUC) {
+               struct xe_gt *gt = uc_fw_to_gt(uc_fw);
+               struct xe_guc *guc = &gt->uc.guc;
+
+               drm_printf(p, "\tSubmit version: %u.%u.%u\n",
+                          guc->submission_state.version.major,
+                          guc->submission_state.version.minor,
+                          guc->submission_state.version.patch);
+       }
 }
index dafd26cb0c413cfbdd2c2097a79b3f2e1a6bdd9d..fc7b1855ee90f247c7a8ad973ad356c580c95f70 100644 (file)
@@ -69,7 +69,11 @@ struct uc_css_header {
 #define CSS_SW_VERSION_UC_MAJOR                (0xFF << 16)
 #define CSS_SW_VERSION_UC_MINOR                (0xFF << 8)
 #define CSS_SW_VERSION_UC_PATCH                (0xFF << 0)
-       u32 reserved0[13];
+       union {
+               u32 submission_version; /* only applies to GuC */
+               u32 reserved2;
+       };
+       u32 reserved0[12];
        union {
                u32 private_data_size; /* only applies to GuC */
                u32 reserved1;