[PATCH] drm/i915/huc: Check HuC firmware status only once

Michal Wajdeczko michal.wajdeczko at intel.com
Tue May 21 18:21:31 UTC 2019


During driver load we checked that HuC firmware was verified, and once
verified it stays verified, so there is no need to check that again.

Signed-off-by: Michal Wajdeczko <michal.wajdeczko at intel.com>
Cc: Chris Wilson <chris at chris-wilson.co.uk>
Cc: Tony Ye <tony.ye at intel.com>
---
 drivers/gpu/drm/i915/intel_huc.c | 17 ++++++-----------
 drivers/gpu/drm/i915/intel_huc.h |  2 ++
 2 files changed, 8 insertions(+), 11 deletions(-)

diff --git a/drivers/gpu/drm/i915/intel_huc.c b/drivers/gpu/drm/i915/intel_huc.c
index 1ff1fb015e58..aac17916e130 100644
--- a/drivers/gpu/drm/i915/intel_huc.c
+++ b/drivers/gpu/drm/i915/intel_huc.c
@@ -113,6 +113,8 @@ int intel_huc_auth(struct intel_huc *huc)
 	u32 status;
 	int ret;
 
+	GEM_BUG_ON(huc->verified);
+
 	if (huc->fw.load_status != INTEL_UC_FIRMWARE_SUCCESS)
 		return -ENOEXEC;
 
@@ -134,6 +136,7 @@ int intel_huc_auth(struct intel_huc *huc)
 		goto fail;
 	}
 
+	huc->verified = true;
 	return 0;
 
 fail:
@@ -147,24 +150,16 @@ int intel_huc_auth(struct intel_huc *huc)
  * intel_huc_check_status() - check HuC status
  * @huc: intel_huc structure
  *
- * This function reads status register to verify if HuC
- * firmware was successfully loaded.
- *
  * Returns: 1 if HuC firmware is loaded and verified,
  * 0 if HuC firmware is not loaded and -ENODEV if HuC
  * is not present on this platform.
  */
 int intel_huc_check_status(struct intel_huc *huc)
 {
-	struct drm_i915_private *dev_priv = huc_to_i915(huc);
-	intel_wakeref_t wakeref;
-	bool status = false;
+	struct drm_i915_private *i915 = huc_to_i915(huc);
 
-	if (!HAS_HUC(dev_priv))
+	if (!HAS_HUC(i915))
 		return -ENODEV;
 
-	with_intel_runtime_pm(dev_priv, wakeref)
-		status = I915_READ(HUC_STATUS2) & HUC_FW_VERIFIED;
-
-	return status;
+	return huc->verified;
 }
diff --git a/drivers/gpu/drm/i915/intel_huc.h b/drivers/gpu/drm/i915/intel_huc.h
index a0c21ae02a99..8c2b6c8f179c 100644
--- a/drivers/gpu/drm/i915/intel_huc.h
+++ b/drivers/gpu/drm/i915/intel_huc.h
@@ -31,6 +31,7 @@
 struct intel_huc {
 	/* Generic uC firmware management */
 	struct intel_uc_fw fw;
+	bool verified;
 
 	/* HuC-specific additions */
 	struct i915_vma *rsa_data;
@@ -52,6 +53,7 @@ static inline void intel_huc_fini_misc(struct intel_huc *huc)
 static inline int intel_huc_sanitize(struct intel_huc *huc)
 {
 	intel_uc_fw_sanitize(&huc->fw);
+	huc->verified = false;
 	return 0;
 }
 
-- 
2.19.2



More information about the Intel-gfx-trybot mailing list