Commit 65332a5b authored by John Harrison's avatar John Harrison Committed by Daniele Ceraolo Spurio
Browse files

drm/i915/uc: Add patch level version number support



With the move to un-versioned filenames, it becomes more difficult to
know exactly what version of a given firmware is being used. So add
the patch level version number to the debugfs output.

Also, support matching by patch level when selecting code paths for
firmware compatibility. While a patch level change cannot be backwards
breaking, it is potentially possible that a new feature only works
from a given patch level onwards (even though it was theoretically
added in an earlier version that bumped the major or minor version).

Signed-off-by: default avatarJohn Harrison <John.C.Harrison@Intel.com>
Reviewed-by: default avatarDaniele Ceraolo Spurio <daniele.ceraolospurio@intel.com>
Signed-off-by: default avatarDaniele Ceraolo Spurio <daniele.ceraolospurio@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20220906230147.479945-2-daniele.ceraolospurio@intel.com
parent 665ae9c9
Loading
Loading
Loading
Loading
+5 −5
Original line number Diff line number Diff line
@@ -1868,7 +1868,7 @@ int intel_guc_submission_init(struct intel_guc *guc)
	if (guc->submission_initialized)
		return 0;

	if (guc->fw.file_selected.major_ver < 70) {
	if (GET_UC_VER(guc) < MAKE_UC_VER(70, 0, 0)) {
		ret = guc_lrc_desc_pool_create_v69(guc);
		if (ret)
			return ret;
@@ -2303,7 +2303,7 @@ static int register_context(struct intel_context *ce, bool loop)
	GEM_BUG_ON(intel_context_is_child(ce));
	trace_intel_context_register(ce);

	if (guc->fw.file_selected.major_ver >= 70)
	if (GET_UC_VER(guc) >= MAKE_UC_VER(70, 0, 0))
		ret = register_context_v70(guc, ce, loop);
	else
		ret = register_context_v69(guc, ce, loop);
@@ -2315,7 +2315,7 @@ static int register_context(struct intel_context *ce, bool loop)
		set_context_registered(ce);
		spin_unlock_irqrestore(&ce->guc_state.lock, flags);

		if (guc->fw.file_selected.major_ver >= 70)
		if (GET_UC_VER(guc) >= MAKE_UC_VER(70, 0, 0))
			guc_context_policy_init_v70(ce, loop);
	}

@@ -2921,7 +2921,7 @@ static void __guc_context_set_preemption_timeout(struct intel_guc *guc,
						 u16 guc_id,
						 u32 preemption_timeout)
{
	if (guc->fw.file_selected.major_ver >= 70) {
	if (GET_UC_VER(guc) >= MAKE_UC_VER(70, 0, 0)) {
		struct context_policy policy;

		__guc_context_policy_start_klv(&policy, guc_id);
@@ -3186,7 +3186,7 @@ static int guc_context_alloc(struct intel_context *ce)
static void __guc_context_set_prio(struct intel_guc *guc,
				   struct intel_context *ce)
{
	if (guc->fw.file_selected.major_ver >= 70) {
	if (GET_UC_VER(guc) >= MAKE_UC_VER(70, 0, 0)) {
		struct context_policy policy;

		__guc_context_policy_start_klv(&policy, ce->guc_id.id);
+4 −2
Original line number Diff line number Diff line
@@ -435,9 +435,11 @@ static void print_fw_ver(struct intel_uc *uc, struct intel_uc_fw *fw)
{
	struct drm_i915_private *i915 = uc_to_gt(uc)->i915;

	drm_info(&i915->drm, "%s firmware %s version %u.%u\n",
	drm_info(&i915->drm, "%s firmware %s version %u.%u.%u\n",
		 intel_uc_fw_type_repr(fw->type), fw->file_selected.path,
		 fw->file_selected.major_ver, fw->file_selected.minor_ver);
		 fw->file_selected.major_ver,
		 fw->file_selected.minor_ver,
		 fw->file_selected.patch_ver);
}

static int __uc_init_hw(struct intel_uc *uc)
+27 −9
Original line number Diff line number Diff line
@@ -447,10 +447,12 @@ static int check_gsc_manifest(const struct firmware *fw,
			      struct intel_uc_fw *uc_fw)
{
	u32 *dw = (u32 *)fw->data;
	u32 version = dw[HUC_GSC_VERSION_DW];
	u32 version_hi = dw[HUC_GSC_VERSION_HI_DW];
	u32 version_lo = dw[HUC_GSC_VERSION_LO_DW];

	uc_fw->file_selected.major_ver = FIELD_GET(HUC_GSC_MAJOR_VER_MASK, version);
	uc_fw->file_selected.minor_ver = FIELD_GET(HUC_GSC_MINOR_VER_MASK, version);
	uc_fw->file_selected.major_ver = FIELD_GET(HUC_GSC_MAJOR_VER_HI_MASK, version_hi);
	uc_fw->file_selected.minor_ver = FIELD_GET(HUC_GSC_MINOR_VER_HI_MASK, version_hi);
	uc_fw->file_selected.patch_ver = FIELD_GET(HUC_GSC_PATCH_VER_LO_MASK, version_lo);

	return 0;
}
@@ -512,6 +514,8 @@ static int check_ccs_header(struct drm_i915_private *i915,
						   css->sw_version);
	uc_fw->file_selected.minor_ver = FIELD_GET(CSS_SW_VERSION_UC_MINOR,
						   css->sw_version);
	uc_fw->file_selected.patch_ver = FIELD_GET(CSS_SW_VERSION_UC_PATCH,
						   css->sw_version);

	if (uc_fw->type == INTEL_UC_FW_TYPE_GUC)
		uc_fw->private_data_size = css->private_data_size;
@@ -1000,6 +1004,8 @@ size_t intel_uc_fw_copy_rsa(struct intel_uc_fw *uc_fw, void *dst, u32 max_len)
 */
void intel_uc_fw_dump(const struct intel_uc_fw *uc_fw, struct drm_printer *p)
{
	u32 ver_sel, ver_want;

	drm_printf(p, "%s firmware: %s\n",
		   intel_uc_fw_type_repr(uc_fw->type), uc_fw->file_selected.path);
	if (uc_fw->file_selected.path != uc_fw->file_wanted.path)
@@ -1007,13 +1013,25 @@ void intel_uc_fw_dump(const struct intel_uc_fw *uc_fw, struct drm_printer *p)
			   intel_uc_fw_type_repr(uc_fw->type), uc_fw->file_wanted.path);
	drm_printf(p, "\tstatus: %s\n",
		   intel_uc_fw_status_repr(uc_fw->status));
	if (uc_fw->file_wanted.major_ver)
		drm_printf(p, "\tversion: wanted %u.%u, found %u.%u\n",
			   uc_fw->file_wanted.major_ver, uc_fw->file_wanted.minor_ver,
			   uc_fw->file_selected.major_ver, uc_fw->file_selected.minor_ver);
	ver_sel = MAKE_UC_VER(uc_fw->file_selected.major_ver,
			      uc_fw->file_selected.minor_ver,
			      uc_fw->file_selected.patch_ver);
	ver_want = MAKE_UC_VER(uc_fw->file_wanted.major_ver,
			       uc_fw->file_wanted.minor_ver,
			       uc_fw->file_wanted.patch_ver);
	if (ver_sel < ver_want)
		drm_printf(p, "\tversion: wanted %u.%u.%u, found %u.%u.%u\n",
			   uc_fw->file_wanted.major_ver,
			   uc_fw->file_wanted.minor_ver,
			   uc_fw->file_wanted.patch_ver,
			   uc_fw->file_selected.major_ver,
			   uc_fw->file_selected.minor_ver,
			   uc_fw->file_selected.patch_ver);
	else
		drm_printf(p, "\tversion: found %u.%u\n",
			   uc_fw->file_selected.major_ver, uc_fw->file_selected.minor_ver);
		drm_printf(p, "\tversion: found %u.%u.%u\n",
			   uc_fw->file_selected.major_ver,
			   uc_fw->file_selected.minor_ver,
			   uc_fw->file_selected.patch_ver);
	drm_printf(p, "\tuCode: %u bytes\n", uc_fw->ucode_size);
	drm_printf(p, "\tRSA: %u bytes\n", uc_fw->rsa_size);
}
+6 −0
Original line number Diff line number Diff line
@@ -73,6 +73,7 @@ struct intel_uc_fw_file {
	const char *path;
	u16 major_ver;
	u16 minor_ver;
	u16 patch_ver;
};

/*
@@ -108,6 +109,11 @@ struct intel_uc_fw {
	bool loaded_via_gsc;
};

#define MAKE_UC_VER(maj, min, pat)	((pat) | ((min) << 8) | ((maj) << 16))
#define GET_UC_VER(uc)			(MAKE_UC_VER((uc)->fw.file_selected.major_ver, \
						     (uc)->fw.file_selected.minor_ver, \
						     (uc)->fw.file_selected.patch_ver))

#ifdef CONFIG_DRM_I915_DEBUG_GUC
void intel_uc_fw_change_status(struct intel_uc_fw *uc_fw,
			       enum intel_uc_fw_status status);
+5 −3
Original line number Diff line number Diff line
@@ -83,8 +83,10 @@ struct uc_css_header {
} __packed;
static_assert(sizeof(struct uc_css_header) == 128);

#define HUC_GSC_VERSION_DW		44
#define   HUC_GSC_MAJOR_VER_MASK	(0xFF << 0)
#define   HUC_GSC_MINOR_VER_MASK	(0xFF << 16)
#define HUC_GSC_VERSION_HI_DW		44
#define   HUC_GSC_MAJOR_VER_HI_MASK	(0xFF << 0)
#define   HUC_GSC_MINOR_VER_HI_MASK	(0xFF << 16)
#define HUC_GSC_VERSION_LO_DW		45
#define   HUC_GSC_PATCH_VER_LO_MASK	(0xFF << 0)

#endif /* _INTEL_UC_FW_ABI_H */