diff mbox series

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

Message ID 20190522190057.848-3-michal.wajdeczko@intel.com (mailing list archive)
State New, archived
Headers show
Series drm/i915: HuC updates | expand

Commit Message

Michal Wajdeczko May 22, 2019, 7 p.m. UTC
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@intel.com>
Cc: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Tony Ye <tony.ye@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(-)

Comments

Chris Wilson May 22, 2019, 8:13 p.m. UTC | #1
Quoting Michal Wajdeczko (2019-05-22 20:00:56)
> 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@intel.com>
> Cc: Chris Wilson <chris@chris-wilson.co.uk>
> Cc: Tony Ye <tony.ye@intel.com>

Makes sense to me as purely a code monkey.

Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>

I would like a second opinion from someone who knows the innards of the
HuC to confirm that indeed once verified, it remains verified. And if it
can change, we need to report the change in status to userspace (or they
just hang and the gpu + huc gets reset).
-Chris
Ye, Tony May 23, 2019, 11:58 a.m. UTC | #2
> 在 2019年5月23日,上午4:14,Chris Wilson <chris@chris-wilson.co.uk> 写道:
> 
> Quoting Michal Wajdeczko (2019-05-22 20:00:56)
>> 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@intel.com>
>> Cc: Chris Wilson <chris@chris-wilson.co.uk>
>> Cc: Tony Ye <tony.ye@intel.com>
> 
> Makes sense to me as purely a code monkey.
> 
> Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
> 
> I would like a second opinion from someone who knows the innards of the
> HuC to confirm that indeed once verified, it remains verified. And if it
> can change, we need to report the change in status to userspace (or they
> just hang and the gpu + huc gets reset).
> -Chris
UMD doesn’t authenticate HuC. It only reads the authentication status. So as long as KMD/GuC verified it, it keeps verified.
Regards, -Tony
diff mbox series

Patch

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;
 }