[PATCH v9 5/7] drm/i915/guc: Add HuC firmware size related restriction for Gen9 and CNL A0

Jackie Li yaodong.li at intel.com
Thu Feb 8 22:12:23 UTC 2018

On CNL A0 and Gen9, there's a hardware restriction that requires the
available GuC WOPCM size to be larger than or equal to HuC firmware size.

This patch adds new verfication code to ensure the available GuC WOPCM size
to be larger than or equal to HuC firmware size on both Gen9 and CNL A0.

 - Extended HuC FW size check against GuC WOPCM size to all
   Gen9 and CNL A0 platforms

 - Fixed patch format issues

 - Renamed variables and functions to avoid ambiguity (Joonas)
 - Updated commit message and comments to be more comprehensive (Sagar)

 - Moved code that is not related to restriction check into a separate
   patch and updated the commit message accordingly (Sagar/Michal)
 - Avoided to call uc_get_fw_size for better layer isolation (Michal)

Cc: Michal Wajdeczko <michal.wajdeczko at intel.com>
Cc: Sagar Arun Kamble <sagar.a.kamble at intel.com>
Cc: John Spotswood <john.a.spotswood at intel.com>
Cc: Jeff McGee <jeff.mcgee at intel.com>
Cc: Chris Wilson <chris at chris-wilson.co.uk>
Cc: Joonas Lahtinen <joonas.lahtinen at linux.intel.com>
Reviewed-by: Sagar Arun Kamble <sagar.a.kamble at intel.com> (v8)
Signed-off-by: Jackie Li <yaodong.li at intel.com>
 drivers/gpu/drm/i915/intel_guc_wopcm.c | 28 +++++++++++++++++++++++-----
 1 file changed, 23 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/i915/intel_guc_wopcm.c b/drivers/gpu/drm/i915/intel_guc_wopcm.c
index d0185b0..2e8e9ec 100644
--- a/drivers/gpu/drm/i915/intel_guc_wopcm.c
+++ b/drivers/gpu/drm/i915/intel_guc_wopcm.c
@@ -40,7 +40,22 @@ static inline u32 guc_wopcm_context_reserved_size(struct intel_guc *guc)
 	return 0;
-static inline int gen9_guc_wopcm_size_check(struct intel_guc_wopcm *guc_wopcm)
+static inline int guc_wopcm_check_huc_fw_size(struct intel_guc_wopcm *guc_wopcm,
+					      u32 huc_fw_size)
+	/*
+	 * On Gen9 & CNL A0, hardware requires the total available GuC WOPCM
+	 * size to be larger than or equal to HuC firmware size. Otherwise,
+	 * firmware uploading would fail.
+	 */
+	if (unlikely(guc_wopcm->size - GUC_WOPCM_RESERVED < huc_fw_size))
+		return -E2BIG;
+	return 0;
+static inline int gen9_guc_wopcm_size_check(struct intel_guc_wopcm *guc_wopcm,
+					    u32 huc_fw_size)
 	u32 guc_wopcm_start;
 	u32 delta;
@@ -58,16 +73,19 @@ static inline int gen9_guc_wopcm_size_check(struct intel_guc_wopcm *guc_wopcm)
 	if (unlikely(delta < sizeof(u32)))
 		return -E2BIG;
-	return 0;
+	return guc_wopcm_check_huc_fw_size(guc_wopcm, huc_fw_size);
-static inline int guc_wopcm_size_check(struct intel_guc *guc)
+static inline int guc_wopcm_size_check(struct intel_guc *guc, u32 huc_fw_size)
 	struct drm_i915_private *i915 = guc_to_i915(guc);
 	struct intel_guc_wopcm *guc_wopcm = &guc->wopcm;
 	if (IS_GEN9(i915))
-		return gen9_guc_wopcm_size_check(guc_wopcm);
+		return gen9_guc_wopcm_size_check(guc_wopcm, huc_fw_size);
+		return guc_wopcm_check_huc_fw_size(guc_wopcm, huc_fw_size);
 	return 0;
@@ -131,7 +149,7 @@ int intel_guc_wopcm_init(struct intel_guc_wopcm *guc_wopcm, u32 guc_fw_size,
 	guc->wopcm.top = top;
 	/* Check platform specific restrictions */
-	err = guc_wopcm_size_check(guc);
+	err = guc_wopcm_size_check(guc, huc_fw_size);
 	if (err)
 		return err;

More information about the Intel-gfx-trybot mailing list