All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] drm/i915/huc: Don't try to check HuC status if it's not loaded
@ 2019-05-19 21:50 Michal Wajdeczko
  2019-05-19 22:26 ` ✓ Fi.CI.BAT: success for drm/i915/huc: Don't try to check HuC status if it's not loaded (rev2) Patchwork
                   ` (2 more replies)
  0 siblings, 3 replies; 13+ messages in thread
From: Michal Wajdeczko @ 2019-05-19 21:50 UTC (permalink / raw)
  To: intel-gfx

If we never attempted to load HuC firmware, or we already wedged
or reset GuC/HuC, then there is no reason to wake up the device
to check one bit in the register that will be for sure cleared.

v2: check if HuC was enabled; subtle change in ABI
    reuse hus_is_load helper

Suggested-by: Chris Wilson <chris@chris-wilson.co.uk>
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 | 20 ++++++++++++--------
 drivers/gpu/drm/i915/intel_huc.h |  5 +++++
 2 files changed, 17 insertions(+), 8 deletions(-)

diff --git a/drivers/gpu/drm/i915/intel_huc.c b/drivers/gpu/drm/i915/intel_huc.c
index 1ff1fb015e58..bfdebec1cfc8 100644
--- a/drivers/gpu/drm/i915/intel_huc.c
+++ b/drivers/gpu/drm/i915/intel_huc.c
@@ -113,7 +113,7 @@ int intel_huc_auth(struct intel_huc *huc)
 	u32 status;
 	int ret;
 
-	if (huc->fw.load_status != INTEL_UC_FIRMWARE_SUCCESS)
+	if (!intel_huc_is_loaded(huc))
 		return -ENOEXEC;
 
 	ret = intel_guc_auth_huc(guc,
@@ -150,21 +150,25 @@ int intel_huc_auth(struct intel_huc *huc)
  * 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.
+ * Returns: 1 if HuC firmware is loaded and verified, 0 if HuC firmware is not
+ * enabled, -ENOPKG 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;
+	bool verified = false;
 
 	if (!HAS_HUC(dev_priv))
 		return -ENODEV;
 
-	with_intel_runtime_pm(dev_priv, wakeref)
-		status = I915_READ(HUC_STATUS2) & HUC_FW_VERIFIED;
+	if (!USES_HUC(dev_priv))
+		return 0;
 
-	return status;
+	if (intel_huc_is_loaded(huc))
+		with_intel_runtime_pm(dev_priv, wakeref)
+			verified = I915_READ(HUC_STATUS2) & HUC_FW_VERIFIED;
+
+	return verified ? 1 : -ENOPKG;
 }
diff --git a/drivers/gpu/drm/i915/intel_huc.h b/drivers/gpu/drm/i915/intel_huc.h
index a0c21ae02a99..cde3d303718d 100644
--- a/drivers/gpu/drm/i915/intel_huc.h
+++ b/drivers/gpu/drm/i915/intel_huc.h
@@ -44,6 +44,11 @@ void intel_huc_fini(struct intel_huc *huc);
 int intel_huc_auth(struct intel_huc *huc);
 int intel_huc_check_status(struct intel_huc *huc);
 
+static inline bool intel_huc_is_loaded(struct intel_huc *huc)
+{
+	return intel_uc_fw_is_loaded(&huc->fw);
+}
+
 static inline void intel_huc_fini_misc(struct intel_huc *huc)
 {
 	intel_uc_fw_cleanup_fetch(&huc->fw);
-- 
2.19.2

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

^ permalink raw reply related	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2019-05-27 11:23 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-19 21:50 [PATCH v2] drm/i915/huc: Don't try to check HuC status if it's not loaded Michal Wajdeczko
2019-05-19 22:26 ` ✓ Fi.CI.BAT: success for drm/i915/huc: Don't try to check HuC status if it's not loaded (rev2) Patchwork
2019-05-19 23:54 ` ✓ Fi.CI.IGT: " Patchwork
2019-05-20  9:35 ` [PATCH v2] drm/i915/huc: Don't try to check HuC status if it's not loaded Chris Wilson
2019-05-20 10:24   ` Michal Wajdeczko
2019-05-20 10:44     ` Chris Wilson
2019-05-20 12:16       ` Michal Wajdeczko
2019-05-21 11:04         ` Ye, Tony
2019-05-21 11:08           ` Michal Wajdeczko
2019-05-22 11:32             ` Ye, Tony
2019-05-24 13:10               ` Joonas Lahtinen
2019-05-24 13:29                 ` Michal Wajdeczko
2019-05-27 11:23                   ` Michal Wajdeczko

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.