Skip to content

Commit 31e59f3

Browse files
author
Jocelyn Falempe
committed
drm/i915/huc: better define HuC status getparam possible return values.
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2041690 Upstream Status: git://anongit.freedesktop.org/drm/drm commit b76c14c Author: Daniele Ceraolo Spurio <daniele.ceraolospurio@intel.com> AuthorDate: Tue Sep 27 17:41:43 2022 -0700 Commit: Daniele Ceraolo Spurio <daniele.ceraolospurio@intel.com> CommitDate: Mon Oct 3 11:29:20 2022 -0700 The current HuC status getparam return values are a bit confusing in regards to what happens in some scenarios. In particular, most of the error cases cause the ioctl to return an error, but a couple of them, INIT_FAIL and LOAD_FAIL, are not explicitly handled and neither is their expected return value documented; these 2 error cases therefore end up into the catch-all umbrella of the "HuC not loaded" case, with this case therefore including both some error scenarios and the load in progress one. The updates included in this patch change the handling so that all error cases behave the same way, i.e. return an errno code, and so that the HuC load in progress case is unambiguous. The patch also includes a small change to the FW init path to make sure we always transition to an error state if something goes wrong. Signed-off-by: Daniele Ceraolo Spurio <daniele.ceraolospurio@intel.com> Cc: Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com> Cc: Tony Ye <tony.ye@intel.com> Acked-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com> Acked-by: Tony Ye <tony.ye@intel.com> Reviewed-by: Alan Previn <alan.previn.teres.alexis@intel.com> Link: https://patchwork.freedesktop.org/patch/msgid/20220928004145.745803-14-daniele.ceraolospurio@intel.com Signed-off-by: Jocelyn Falempe <jfalempe@redhat.com>
1 parent a095846 commit 31e59f3

File tree

4 files changed

+24
-8
lines changed

4 files changed

+24
-8
lines changed

drivers/gpu/drm/i915/gt/uc/intel_guc.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -474,6 +474,7 @@ int intel_guc_init(struct intel_guc *guc)
474474
err_fw:
475475
intel_uc_fw_fini(&guc->fw);
476476
out:
477+
intel_uc_fw_change_status(&guc->fw, INTEL_UC_FIRMWARE_INIT_FAIL);
477478
i915_probe_error(gt->i915, "failed with %d\n", ret);
478479
return ret;
479480
}

drivers/gpu/drm/i915/gt/uc/intel_huc.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,7 @@ int intel_huc_init(struct intel_huc *huc)
285285
return 0;
286286

287287
out:
288+
intel_uc_fw_change_status(&huc->fw, INTEL_UC_FIRMWARE_INIT_FAIL);
288289
drm_info(&i915->drm, "HuC init failed with %d\n", err);
289290
return err;
290291
}
@@ -404,13 +405,8 @@ bool intel_huc_is_authenticated(struct intel_huc *huc)
404405
* This function reads status register to verify if HuC
405406
* firmware was successfully loaded.
406407
*
407-
* Returns:
408-
* * -ENODEV if HuC is not present on this platform,
409-
* * -EOPNOTSUPP if HuC firmware is disabled,
410-
* * -ENOPKG if HuC firmware was not installed,
411-
* * -ENOEXEC if HuC firmware is invalid or mismatched,
412-
* * 0 if HuC firmware is not running,
413-
* * 1 if HuC firmware is authenticated and running.
408+
* The return values match what is expected for the I915_PARAM_HUC_STATUS
409+
* getparam.
414410
*/
415411
int intel_huc_check_status(struct intel_huc *huc)
416412
{
@@ -423,6 +419,10 @@ int intel_huc_check_status(struct intel_huc *huc)
423419
return -ENOPKG;
424420
case INTEL_UC_FIRMWARE_ERROR:
425421
return -ENOEXEC;
422+
case INTEL_UC_FIRMWARE_INIT_FAIL:
423+
return -ENOMEM;
424+
case INTEL_UC_FIRMWARE_LOAD_FAIL:
425+
return -EIO;
426426
default:
427427
break;
428428
}

drivers/gpu/drm/i915/gt/uc/intel_uc_fw.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -894,7 +894,6 @@ int intel_uc_fw_init(struct intel_uc_fw *uc_fw)
894894
out_unpin:
895895
i915_gem_object_unpin_pages(uc_fw->obj);
896896
out:
897-
intel_uc_fw_change_status(uc_fw, INTEL_UC_FIRMWARE_INIT_FAIL);
898897
return err;
899898
}
900899

include/uapi/drm/i915_drm.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -645,6 +645,22 @@ typedef struct drm_i915_irq_wait {
645645
*/
646646
#define I915_SCHEDULER_CAP_STATIC_PRIORITY_MAP (1ul << 5)
647647

648+
/*
649+
* Query the status of HuC load.
650+
*
651+
* The query can fail in the following scenarios with the listed error codes:
652+
* -ENODEV if HuC is not present on this platform,
653+
* -EOPNOTSUPP if HuC firmware usage is disabled,
654+
* -ENOPKG if HuC firmware fetch failed,
655+
* -ENOEXEC if HuC firmware is invalid or mismatched,
656+
* -ENOMEM if i915 failed to prepare the FW objects for transfer to the uC,
657+
* -EIO if the FW transfer or the FW authentication failed.
658+
*
659+
* If the IOCTL is successful, the returned parameter will be set to one of the
660+
* following values:
661+
* * 0 if HuC firmware load is not complete,
662+
* * 1 if HuC firmware is authenticated and running.
663+
*/
648664
#define I915_PARAM_HUC_STATUS 42
649665

650666
/* Query whether DRM_I915_GEM_EXECBUFFER2 supports the ability to opt-out of

0 commit comments

Comments
 (0)