Commit 7d0ca56e authored by John Harrison's avatar John Harrison
Browse files

drm/xe/guc: Update CSS header structures



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: default avatarJohn Harrison <John.C.Harrison@Intel.com>
Reviewed-by: default avatarDaniele Ceraolo Spurio <daniele.ceraolospurio@intel.com>
Link: https://lore.kernel.org/r/20250910210237.603576-2-John.C.Harrison@Intel.com
parent 84afb84b
Loading
Loading
Loading
Loading
+12 −12
Original line number Diff line number Diff line
@@ -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;
}
+41 −23
Original line number Diff line number Diff line
@@ -44,6 +44,39 @@
 *    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)
	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);