diff mbox series

drm/i915/huc: Don't try to check HuC status if it's not loaded

Message ID 20190517214028.14388-1-michal.wajdeczko@intel.com (mailing list archive)
State New, archived
Headers show
Series drm/i915/huc: Don't try to check HuC status if it's not loaded | expand

Commit Message

Michal Wajdeczko May 17, 2019, 9:40 p.m. UTC
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.

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 | 3 +++
 drivers/gpu/drm/i915/intel_huc.h | 5 +++++
 2 files changed, 8 insertions(+)

Comments

Chris Wilson May 17, 2019, 9:52 p.m. UTC | #1
Quoting Michal Wajdeczko (2019-05-17 22:40:28)
> 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.
> 
> 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 | 3 +++
>  drivers/gpu/drm/i915/intel_huc.h | 5 +++++
>  2 files changed, 8 insertions(+)
> 
> diff --git a/drivers/gpu/drm/i915/intel_huc.c b/drivers/gpu/drm/i915/intel_huc.c
> index 1ff1fb015e58..9d91089e2cd1 100644
> --- a/drivers/gpu/drm/i915/intel_huc.c
> +++ b/drivers/gpu/drm/i915/intel_huc.c
> @@ -163,6 +163,9 @@ int intel_huc_check_status(struct intel_huc *huc)
>         if (!HAS_HUC(dev_priv))
>                 return -ENODEV;
>  
> +       if (!intel_huc_is_loaded(huc))
> +               return 0;

Just to throw out an idea, -ENXIO?

A subtle change in ABI that should go unnoticed by the media driver, but
helps differentiate cause without having to dig deeper.
-Chris
Michal Wajdeczko May 17, 2019, 10:07 p.m. UTC | #2
On Fri, 17 May 2019 23:52:37 +0200, Chris Wilson  
<chris@chris-wilson.co.uk> wrote:

> Quoting Michal Wajdeczko (2019-05-17 22:40:28)
>> 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.
>>
>> 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 | 3 +++
>>  drivers/gpu/drm/i915/intel_huc.h | 5 +++++
>>  2 files changed, 8 insertions(+)
>>
>> diff --git a/drivers/gpu/drm/i915/intel_huc.c  
>> b/drivers/gpu/drm/i915/intel_huc.c
>> index 1ff1fb015e58..9d91089e2cd1 100644
>> --- a/drivers/gpu/drm/i915/intel_huc.c
>> +++ b/drivers/gpu/drm/i915/intel_huc.c
>> @@ -163,6 +163,9 @@ int intel_huc_check_status(struct intel_huc *huc)
>>         if (!HAS_HUC(dev_priv))
>>                 return -ENODEV;
>>
>> +       if (!intel_huc_is_loaded(huc))
>> +               return 0;
>
> Just to throw out an idea, -ENXIO?
>
> A subtle change in ABI that should go unnoticed by the media driver, but
> helps differentiate cause without having to dig deeper.

or maybe:

	if (!USES_HUC(dev_priv))
		return 0;

	if (!intel_huc_is_loaded(huc))
		return -ENXIO;

	...
diff mbox series

Patch

diff --git a/drivers/gpu/drm/i915/intel_huc.c b/drivers/gpu/drm/i915/intel_huc.c
index 1ff1fb015e58..9d91089e2cd1 100644
--- a/drivers/gpu/drm/i915/intel_huc.c
+++ b/drivers/gpu/drm/i915/intel_huc.c
@@ -163,6 +163,9 @@  int intel_huc_check_status(struct intel_huc *huc)
 	if (!HAS_HUC(dev_priv))
 		return -ENODEV;
 
+	if (!intel_huc_is_loaded(huc))
+		return 0;
+
 	with_intel_runtime_pm(dev_priv, wakeref)
 		status = I915_READ(HUC_STATUS2) & HUC_FW_VERIFIED;
 
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);