On Tue, 13 Feb 2018 00:45:51 +0100, Jackie Li <yaodong.li@xxxxxxxxx> wrote:
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.
v6:
- Extended HuC FW size check against GuC WOPCM size to all
Gen9 and CNL A0 platforms
v7:
- Fixed patch format issues
v8:
- Renamed variables and functions to avoid ambiguity (Joonas)
- Updated commit message and comments to be more comprehensive (Sagar)
v9:
- 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)
v10:
- Shorten function names and reorganized size_check code to have clear
isolation (Joonas)
- Removed unnecessary comments (Joonas)
Cc: Michal Wajdeczko <michal.wajdeczko@xxxxxxxxx>
Cc: Sagar Arun Kamble <sagar.a.kamble@xxxxxxxxx>
Cc: John Spotswood <john.a.spotswood@xxxxxxxxx>
Cc: Jeff McGee <jeff.mcgee@xxxxxxxxx>
Cc: Chris Wilson <chris@xxxxxxxxxxxxxxxxxx>
Cc: Joonas Lahtinen <joonas.lahtinen@xxxxxxxxxxxxxxx>
Reviewed-by: Sagar Arun Kamble <sagar.a.kamble@xxxxxxxxx> (v8)
Signed-off-by: Jackie Li <yaodong.li@xxxxxxxxx>
---
drivers/gpu/drm/i915/intel_guc_wopcm.c | 26 ++++++++++++++++++++++----
1 file changed, 22 insertions(+), 4 deletions(-)
diff --git a/drivers/gpu/drm/i915/intel_guc_wopcm.c
b/drivers/gpu/drm/i915/intel_guc_wopcm.c
index 9a276fe..0194266 100644
--- a/drivers/gpu/drm/i915/intel_guc_wopcm.c
+++ b/drivers/gpu/drm/i915/intel_guc_wopcm.c
@@ -19,6 +19,20 @@ static inline u32 context_reserved_size(struct
intel_guc *guc)
return 0;
}
+static inline int check_huc_fw_fits(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 (guc_wopcm->size - GUC_WOPCM_RESERVED < huc_fw_size)
What if guc_wopcm->size < GUC_WOPCM_RESERVED ?
+ return -E2BIG;
+
+ return 0;
+}
+
static inline int gen9_check_dword_gap(struct intel_guc_wopcm
*guc_wopcm)
{
u32 guc_wopcm_start;
@@ -40,15 +54,19 @@ static inline int gen9_check_dword_gap(struct
intel_guc_wopcm *guc_wopcm)
return 0;
}
-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;
+ int err = 0;
if (IS_GEN9(i915))
- return gen9_check_dword_gap(guc_wopcm);
+ err = gen9_check_dword_gap(guc_wopcm);
- return 0;
+ if (IS_GEN9(i915) || IS_CNL_REVID(i915, CNL_REVID_A0, CNL_REVID_A0))
+ err = check_huc_fw_fits(guc_wopcm, huc_fw_size);
Hmm, what if gen9_check_dword_gap() fails but check_huc_fw_fits() passes ?
+
+ return err;
}
/**
@@ -121,7 +139,7 @@ int intel_guc_wopcm_init(struct intel_guc_wopcm
*guc_wopcm, u32 guc_fw_size,
guc->wopcm.size = size;
guc->wopcm.top = top;
- err = guc_wopcm_size_check(guc);
+ err = guc_wopcm_size_check(guc, huc_fw_size);
if (err) {
DRM_DEBUG_DRIVER("GuC WOPCM size check failed.\n");
return err;
I'm more and more convinced that we should use "intel_wopcm" to make
partition and all these checks
Michal
_______________________________________________
Intel-gfx mailing list
Intel-gfx@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/intel-gfx