Commit fa265275 authored by Michal Wajdeczko's avatar Michal Wajdeczko Committed by Chris Wilson

drm/i915/huc: Check HuC status in dedicated function

We try to keep all HuC related code in dedicated file.
There is no need to peek HuC register directly during
handling getparam ioctl.
Signed-off-by: default avatarMichal Wajdeczko <michal.wajdeczko@intel.com>
Cc: Michel Thierry <michel.thierry@intel.com>
Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
Cc: Anusha Srivatsa <anusha.srivatsa@intel.com>
Reviewed-by: default avatarMichel Thierry <michel.thierry@intel.com>
Signed-off-by: default avatarChris Wilson <chris@chris-wilson.co.uk>
Link: https://patchwork.freedesktop.org/patch/msgid/20180314200429.40132-1-michal.wajdeczko@intel.com
parent 8b5eb5e2
...@@ -377,9 +377,9 @@ static int i915_getparam_ioctl(struct drm_device *dev, void *data, ...@@ -377,9 +377,9 @@ static int i915_getparam_ioctl(struct drm_device *dev, void *data,
value = INTEL_INFO(dev_priv)->sseu.min_eu_in_pool; value = INTEL_INFO(dev_priv)->sseu.min_eu_in_pool;
break; break;
case I915_PARAM_HUC_STATUS: case I915_PARAM_HUC_STATUS:
intel_runtime_pm_get(dev_priv); value = intel_huc_check_status(&dev_priv->huc);
value = I915_READ(HUC_STATUS2) & HUC_FW_VERIFIED; if (value < 0)
intel_runtime_pm_put(dev_priv); return value;
break; break;
case I915_PARAM_MMAP_GTT_VERSION: case I915_PARAM_MMAP_GTT_VERSION:
/* Though we've started our numbering from 1, and so class all /* Though we've started our numbering from 1, and so class all
......
...@@ -92,3 +92,28 @@ int intel_huc_auth(struct intel_huc *huc) ...@@ -92,3 +92,28 @@ int intel_huc_auth(struct intel_huc *huc)
DRM_ERROR("HuC: Authentication failed %d\n", ret); DRM_ERROR("HuC: Authentication failed %d\n", ret);
return ret; return ret;
} }
/**
* 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 positive value if HuC firmware is loaded and verified
* and -ENODEV if HuC is not present.
*/
int intel_huc_check_status(struct intel_huc *huc)
{
struct drm_i915_private *dev_priv = huc_to_i915(huc);
u32 status;
if (!HAS_HUC(dev_priv))
return -ENODEV;
intel_runtime_pm_get(dev_priv);
status = I915_READ(HUC_STATUS2) & HUC_FW_VERIFIED;
intel_runtime_pm_put(dev_priv);
return status;
}
...@@ -37,6 +37,7 @@ struct intel_huc { ...@@ -37,6 +37,7 @@ struct intel_huc {
void intel_huc_init_early(struct intel_huc *huc); void intel_huc_init_early(struct intel_huc *huc);
int intel_huc_auth(struct intel_huc *huc); int intel_huc_auth(struct intel_huc *huc);
int intel_huc_check_status(struct intel_huc *huc);
static inline int intel_huc_sanitize(struct intel_huc *huc) static inline int intel_huc_sanitize(struct intel_huc *huc)
{ {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment