]> www.infradead.org Git - users/hch/misc.git/commitdiff
drm/xe/guc: Update CSS header structures
authorJohn Harrison <John.C.Harrison@Intel.com>
Wed, 10 Sep 2025 21:02:32 +0000 (14:02 -0700)
committerJohn Harrison <John.C.Harrison@Intel.com>
Mon, 15 Sep 2025 16:53:21 +0000 (09:53 -0700)
Rework the CSS header structure according to recent updates to the GuC
API spec. Also include more field definitions.

v2: Also pass the new GuC specific structure to a GuC specific
function instead of the higher level, generic structure (review
feedback from Daniele).
Also correct naming of CSS_TIME_* fields.

Signed-off-by: John Harrison <John.C.Harrison@Intel.com>
Reviewed-by: Daniele Ceraolo Spurio <daniele.ceraolospurio@intel.com>
Link: https://lore.kernel.org/r/20250910210237.603576-2-John.C.Harrison@Intel.com
drivers/gpu/drm/xe/xe_uc_fw.c
drivers/gpu/drm/xe/xe_uc_fw_abi.h

index 4faf8b0fbcfe96bca4472265dbfbc083e92df2fd..57b8230cec584dc6f8986b36bd67d24bd9b81396 100644 (file)
@@ -328,7 +328,7 @@ static void uc_fw_fini(struct drm_device *drm, void *arg)
        xe_uc_fw_change_status(uc_fw, XE_UC_FIRMWARE_SELECTED);
 }
 
-static int guc_read_css_info(struct xe_uc_fw *uc_fw, struct uc_css_header *css)
+static int guc_read_css_info(struct xe_uc_fw *uc_fw, struct uc_css_guc_info *guc_info)
 {
        struct xe_gt *gt = uc_fw_to_gt(uc_fw);
        struct xe_uc_fw_version *release = &uc_fw->versions.found[XE_UC_FW_VER_RELEASE];
@@ -343,11 +343,11 @@ static int guc_read_css_info(struct xe_uc_fw *uc_fw, struct uc_css_header *css)
                return -EINVAL;
        }
 
-       compatibility->major = FIELD_GET(CSS_SW_VERSION_UC_MAJOR, css->submission_version);
-       compatibility->minor = FIELD_GET(CSS_SW_VERSION_UC_MINOR, css->submission_version);
-       compatibility->patch = FIELD_GET(CSS_SW_VERSION_UC_PATCH, css->submission_version);
+       compatibility->major = FIELD_GET(CSS_SW_VERSION_UC_MAJOR, guc_info->submission_version);
+       compatibility->minor = FIELD_GET(CSS_SW_VERSION_UC_MINOR, guc_info->submission_version);
+       compatibility->patch = FIELD_GET(CSS_SW_VERSION_UC_PATCH, guc_info->submission_version);
 
-       uc_fw->private_data_size = css->private_data_size;
+       uc_fw->private_data_size = guc_info->private_data_size;
 
        return 0;
 }
@@ -416,8 +416,8 @@ static int parse_css_header(struct xe_uc_fw *uc_fw, const void *fw_data, size_t
        css = (struct uc_css_header *)fw_data;
 
        /* Check integrity of size values inside CSS header */
-       size = (css->header_size_dw - css->key_size_dw - css->modulus_size_dw -
-               css->exponent_size_dw) * sizeof(u32);
+       size = (css->header_size_dw - css->rsa_info.key_size_dw - css->rsa_info.modulus_size_dw -
+               css->rsa_info.exponent_size_dw) * sizeof(u32);
        if (unlikely(size != sizeof(struct uc_css_header))) {
                drm_warn(&xe->drm,
                         "%s firmware %s: unexpected header size: %zu != %zu\n",
@@ -430,7 +430,7 @@ static int parse_css_header(struct xe_uc_fw *uc_fw, const void *fw_data, size_t
        uc_fw->ucode_size = (css->size_dw - css->header_size_dw) * sizeof(u32);
 
        /* now RSA */
-       uc_fw->rsa_size = css->key_size_dw * sizeof(u32);
+       uc_fw->rsa_size = css->rsa_info.key_size_dw * sizeof(u32);
 
        /* At least, it should have header, uCode and RSA. Size of all three. */
        size = sizeof(struct uc_css_header) + uc_fw->ucode_size +
@@ -443,12 +443,12 @@ static int parse_css_header(struct xe_uc_fw *uc_fw, const void *fw_data, size_t
        }
 
        /* Get version numbers from the CSS header */
-       release->major = FIELD_GET(CSS_SW_VERSION_UC_MAJOR, css->sw_version);
-       release->minor = FIELD_GET(CSS_SW_VERSION_UC_MINOR, css->sw_version);
-       release->patch = FIELD_GET(CSS_SW_VERSION_UC_PATCH, css->sw_version);
+       release->major = FIELD_GET(CSS_SW_VERSION_UC_MAJOR, css->guc_info.sw_version);
+       release->minor = FIELD_GET(CSS_SW_VERSION_UC_MINOR, css->guc_info.sw_version);
+       release->patch = FIELD_GET(CSS_SW_VERSION_UC_PATCH, css->guc_info.sw_version);
 
        if (uc_fw->type == XE_UC_FW_TYPE_GUC)
-               return guc_read_css_info(uc_fw, css);
+               return guc_read_css_info(uc_fw, &css->guc_info);
 
        return 0;
 }
index 87ade41209d0d6f10bd74e52b329a931d1903082..faceb437fd2f7555b2c7163078d5f62f1f0ddaa1 100644 (file)
  *    in fw. So driver will load a truncated firmware in this case.
  */
 
+struct uc_css_rsa_info {
+       u32 key_size_dw;
+       u32 modulus_size_dw;
+       u32 exponent_size_dw;
+} __packed;
+
+struct uc_css_guc_info {
+       u32 time;
+#define CSS_TIME_HOUR                          (0xFF << 0)
+#define CSS_TIME_MIN                           (0xFF << 8)
+#define CSS_TIME_SEC                           (0xFFFF << 16)
+       u32 reserved0[5];
+       u32 sw_version;
+#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 submission_version;
+       u32 reserved1[11];
+       u32 header_info;
+#define CSS_HEADER_INFO_SVN                    (0xFF)
+#define CSS_HEADER_INFO_COPY_VALID             (0x1 << 31)
+       u32 private_data_size;
+       u32 ukernel_info;
+#define CSS_UKERNEL_INFO_DEVICEID              (0xFFFF << 16)
+#define CSS_UKERNEL_INFO_PRODKEY               (0xFF << 8)
+#define CSS_UKERNEL_INFO_BUILDTYPE             (0x3 << 2)
+#define CSS_UKERNEL_INFO_BUILDTYPE_PROD                0
+#define CSS_UKERNEL_INFO_BUILDTYPE_PREPROD     1
+#define CSS_UKERNEL_INFO_BUILDTYPE_DEBUG       2
+#define CSS_UKERNEL_INFO_ENCSTATUS             (0x1 << 1)
+#define CSS_UKERNEL_INFO_COPY_VALID            (0x1 << 0)
+} __packed;
+
 struct uc_css_header {
        u32 module_type;
        /*
@@ -52,36 +85,21 @@ struct uc_css_header {
         */
        u32 header_size_dw;
        u32 header_version;
-       u32 module_id;
+       u32 reserved0;
        u32 module_vendor;
        u32 date;
-#define CSS_DATE_DAY                   (0xFF << 0)
-#define CSS_DATE_MONTH                 (0xFF << 8)
-#define CSS_DATE_YEAR                  (0xFFFF << 16)
+#define CSS_DATE_DAY                           (0xFF << 0)
+#define CSS_DATE_MONTH                         (0xFF << 8)
+#define CSS_DATE_YEAR                          (0xFFFF << 16)
        u32 size_dw; /* uCode plus header_size_dw */
-       u32 key_size_dw;
-       u32 modulus_size_dw;
-       u32 exponent_size_dw;
-       u32 time;
-#define CSS_TIME_HOUR                  (0xFF << 0)
-#define CSS_DATE_MIN                   (0xFF << 8)
-#define CSS_DATE_SEC                   (0xFFFF << 16)
-       char username[8];
-       char buildnumber[12];
-       u32 sw_version;
-#define CSS_SW_VERSION_UC_MAJOR                (0xFF << 16)
-#define CSS_SW_VERSION_UC_MINOR                (0xFF << 8)
-#define CSS_SW_VERSION_UC_PATCH                (0xFF << 0)
        union {
-               u32 submission_version; /* only applies to GuC */
-               u32 reserved2;
+               u32 reserved1[3];
+               struct uc_css_rsa_info rsa_info;
        };
-       u32 reserved0[12];
        union {
-               u32 private_data_size; /* only applies to GuC */
-               u32 reserved1;
+               u32 reserved2[22];
+               struct uc_css_guc_info guc_info;
        };
-       u32 header_info;
 } __packed;
 static_assert(sizeof(struct uc_css_header) == 128);