All of lore.kernel.org
 help / color / mirror / Atom feed
From: yu.dai@intel.com
To: intel-gfx@lists.freedesktop.org
Subject: [PATCH v2 05/18] drm/i915: Add firmware version check
Date: Fri,  3 Apr 2015 11:08:31 -0700	[thread overview]
Message-ID: <1428084524-28437-6-git-send-email-yu.dai@intel.com> (raw)
In-Reply-To: <1428084524-28437-1-git-send-email-yu.dai@intel.com>

From: Alex Dai <yu.dai@intel.com>

Set the firmware version that required by HW. Driver sets required
version according to platform. After firmware is loaded but before
send to HW, the major.minor version is read from CSS header field,
which is 17th DWORD currently. The major version must be same; the
minor version must be newer than required.

Currently the GuC fw version is 1.0.

Issue: VIZ-4884
Signed-off-by: Alex Dai <yu.dai@intel.com>
---
 drivers/gpu/drm/i915/intel_guc.h        |  2 ++
 drivers/gpu/drm/i915/intel_guc_loader.c | 47 +++++++++++++++++++++++++++++++--
 drivers/gpu/drm/i915/intel_uc_loader.c  |  3 +++
 drivers/gpu/drm/i915/intel_uc_loader.h  |  4 +++
 4 files changed, 54 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/i915/intel_guc.h b/drivers/gpu/drm/i915/intel_guc.h
index 64cfc20..4fafcec 100644
--- a/drivers/gpu/drm/i915/intel_guc.h
+++ b/drivers/gpu/drm/i915/intel_guc.h
@@ -50,6 +50,8 @@ struct intel_guc {
 
 #define UOS_CSS_HEADER_OFFSET	0
 #define UOS_CSS_HEADER_SIZE	0x80
+#define   UOS_VER_MINOR_OFFSET	0x44
+#define   UOS_VER_MAJOR_OFFSET	0x46
 #define UOS_RSA_SIG_OFFSET	0x80
 #define UOS_RSA_SIG_SIZE	0x100
 #define UOS_CSS_SIGNING_SIZE	0x204
diff --git a/drivers/gpu/drm/i915/intel_guc_loader.c b/drivers/gpu/drm/i915/intel_guc_loader.c
index 950170c..8d141ba 100644
--- a/drivers/gpu/drm/i915/intel_guc_loader.c
+++ b/drivers/gpu/drm/i915/intel_guc_loader.c
@@ -33,6 +33,13 @@
  * pool and doorbells. intel_guc owns a i915_guc_client to replace the legacy
  * ExecList submission.
  *
+ * Firmware versioning:
+ * The firmware build process will generate a version header file with major and
+ * minor version defined. The versions are built into CSS header of firmware.
+ * i915 kernel driver set the minimal firmware version required per platform.
+ * The firmware installation package will install (symbolic link) proper version
+ * of firmware.
+ *
  */
 
 #define I915_GUC_UCODE_GEN8 "i915/guc_gen8.bin"
@@ -269,6 +276,35 @@ fail:
 	return err;
 }
 
+/*
+ * Check the firmware that was found; return TRUE if acceptable.
+ *
+ * For the GuC, we just check the version number embedded at a well-known
+ * offset within the firmware blob; note that major / minor version are two
+ * bytes each - in *u16*
+ */
+static bool intel_guc_ucode_check(struct intel_uc_fw *guc_fw)
+{
+	uint32_t major, minor;
+	u8 *css_header = (u8 *)guc_fw->uc_fw_blob->data + UOS_CSS_HEADER_OFFSET;
+
+	major = *(u16 *)(css_header + UOS_VER_MAJOR_OFFSET);
+	minor = *(u16 *)(css_header + UOS_VER_MINOR_OFFSET);
+
+	if (major == guc_fw->uc_fw_ver_major &&
+	    minor >= guc_fw->uc_fw_ver_minor) {
+		DRM_DEBUG_DRIVER("firmware version %d.%d OK (minimum %d.%d)\n",
+			 major, minor,
+			 guc_fw->uc_fw_ver_major, guc_fw->uc_fw_ver_minor);
+		return true;
+	}
+
+	DRM_ERROR("GuC firmware version %d.%d, required %d.%d\n",
+		 major, minor,
+		 guc_fw->uc_fw_ver_major, guc_fw->uc_fw_ver_minor);
+	return false;
+}
+
 /**
  * intel_guc_ucode_init() - init a firmware loading request
  */
@@ -281,10 +317,17 @@ void intel_guc_ucode_init(struct drm_device *dev)
 	if (!HAS_GUC_UCODE(dev))
 		return;
 
-	if (IS_GEN8(dev))
+	if (IS_GEN8(dev)) {
 		path = I915_GUC_UCODE_GEN8;
-	else if (IS_GEN9(dev))
+		guc_fw->uc_fw_ver_major = 1;
+		guc_fw->uc_fw_ver_minor = 0;
+		guc_fw->uc_fw_check = intel_guc_ucode_check;
+	} else if (IS_GEN9(dev)) {
 		path = I915_GUC_UCODE_GEN9;
+		guc_fw->uc_fw_ver_major = 1;
+		guc_fw->uc_fw_ver_minor = 0;
+		guc_fw->uc_fw_check = intel_guc_ucode_check;
+	}
 
 	intel_uc_fw_init(dev, guc_fw, "GuC", path);
 }
diff --git a/drivers/gpu/drm/i915/intel_uc_loader.c b/drivers/gpu/drm/i915/intel_uc_loader.c
index bc499f4..65031ff 100644
--- a/drivers/gpu/drm/i915/intel_uc_loader.c
+++ b/drivers/gpu/drm/i915/intel_uc_loader.c
@@ -77,6 +77,9 @@ static void uc_fw_finish(struct drm_device *dev, struct intel_uc_fw *uc_fw)
 		uc_fw->uc_fw_blob = fw;
 	}
 
+	if (uc_fw->uc_fw_check && !uc_fw->uc_fw_check(uc_fw))
+		goto fail;
+
 	obj = i915_gem_alloc_object(dev, round_up(fw->size, PAGE_SIZE));
 	if (!obj)
 		goto fail;
diff --git a/drivers/gpu/drm/i915/intel_uc_loader.h b/drivers/gpu/drm/i915/intel_uc_loader.h
index 0994f98..4ed6e94 100644
--- a/drivers/gpu/drm/i915/intel_uc_loader.h
+++ b/drivers/gpu/drm/i915/intel_uc_loader.h
@@ -68,11 +68,15 @@ struct intel_uc_fw {
 	struct drm_i915_gem_object *	uc_fw_obj;
 	enum intel_uc_fw_status		uc_fw_fetch_status;
 	enum intel_uc_fw_status		uc_fw_load_status;
+	uint32_t			uc_fw_ver_major;
+	uint32_t			uc_fw_ver_minor;
+	bool				(*uc_fw_check)(struct intel_uc_fw *);
 };
 
 void intel_uc_fw_init(struct drm_device *dev, struct intel_uc_fw *uc_fw,
 	const char *uc_name, const char *fw_path);
 int intel_uc_fw_check(struct drm_device *dev, struct intel_uc_fw *uc_fw);
 void intel_uc_fw_fini(struct drm_device *dev, struct intel_uc_fw *uc_fw);
+bool intel_uc_fw_version_check(struct intel_uc_fw *fw, const char *data);
 
 #endif
-- 
1.9.1

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

  parent reply	other threads:[~2015-04-03 18:10 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-03 18:08 [PATCH v2 00/18] *** Command submission via GuC for SKL *** yu.dai
2015-04-03 18:08 ` [PATCH v2 01/18] drm/i915: Add guc firmware interface headers yu.dai
2015-04-03 18:08 ` [PATCH v2 02/18] drm/i915: Add i915_gem_object_write() to i915_gem.c yu.dai
2015-04-03 18:08 ` [PATCH v2 03/18] drm/i915: Unified firmware loading mechanism yu.dai
2015-04-03 18:08 ` [PATCH v2 04/18] drm/i915: GuC firmware loader yu.dai
2015-04-03 18:08 ` yu.dai [this message]
2015-04-03 18:08 ` [PATCH v2 06/18] drm/i915: Defer default hardware context initialisation until first open yu.dai
2015-04-03 18:08 ` [PATCH v2 07/18] drm/i915: Move execlists defines from .c to .h yu.dai
2015-04-03 18:08 ` [PATCH v2 08/18] drm/i915: Make several execlist helper functions external yu.dai
2015-04-03 18:08 ` [PATCH v2 09/18] drm/i915: Add functions to allocate / release gem obj for GuC yu.dai
2015-04-03 18:08 ` [PATCH v2 10/18] drm/i915: Functions to support command submission via GuC yu.dai
2015-04-03 18:08 ` [PATCH v2 11/18] drm/i915: Integration of GuC client yu.dai
2015-04-03 18:08 ` [PATCH v2 12/18] drm/i915: Interrupt routing for GuC scheduler yu.dai
2015-04-03 18:08 ` [PATCH v2 13/18] drm/i915: Enable commands submission via GuC yu.dai
2015-04-03 18:08 ` [PATCH v2 14/18] drm/i915: debugfs of GuC status yu.dai
2015-04-03 18:08 ` [PATCH v2 15/18] drm/i915: Enable GuC firmware log yu.dai
2015-04-03 18:08 ` [PATCH v2 16/18] drm/i915: Ring Context allocating for GuC yu.dai
2015-04-03 18:08 ` [PATCH v2 17/18] drm/i915: Taking forcewake during GuC load yu.dai
2015-04-03 18:08 ` [PATCH v2 18/18] Documentation/drm: kerneldoc for GuC yu.dai
2015-04-09 13:24   ` shuang.he
2015-04-09 13:28     ` Daniel Vetter

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1428084524-28437-6-git-send-email-yu.dai@intel.com \
    --to=yu.dai@intel.com \
    --cc=intel-gfx@lists.freedesktop.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.