On Tue, 16 Aug 2016, Tvrtko Ursulin wrote:
On 16/08/16 12:18, Peter Antoine wrote:
This patch will allow for getparams to return the status of the HuC.
As the HuC has to be validated by the GuC this patch uses the validated
status to show when the HuC is loaded and ready for use. You cannot use
the loaded status as with the GuC as the HuC is verified after it is
loaded and is not usable until it is verified.
Signed-off-by: Peter Antoine <peter.antoine@xxxxxxxxx>
---
drivers/gpu/drm/i915/i915_drv.c | 4 ++++
drivers/gpu/drm/i915/intel_huc.h | 2 +-
drivers/gpu/drm/i915/intel_huc_loader.c | 21 +++++++++++++++++++++
include/uapi/drm/i915_drm.h | 1 +
4 files changed, 27 insertions(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/i915/i915_drv.c
b/drivers/gpu/drm/i915/i915_drv.c
index c8fc3d0..909297e 100644
--- a/drivers/gpu/drm/i915/i915_drv.c
+++ b/drivers/gpu/drm/i915/i915_drv.c
@@ -49,6 +49,7 @@
#include "i915_trace.h"
#include "i915_vgpu.h"
#include "intel_drv.h"
+#include "intel_huc.h"
#include "intel_guc.h"
static struct drm_driver driver;
@@ -355,6 +356,9 @@ static int i915_getparam(struct drm_device *dev, void
*data,
case I915_PARAM_MIN_EU_IN_POOL:
value = INTEL_INFO(dev)->min_eu_in_pool;
break;
+ case I915_PARAM_HAS_HUC:
+ value = intel_is_huc_valid(dev);
+ break;
case I915_PARAM_HAS_GUC:
value = intel_is_guc_valid(dev);
break;
diff --git a/drivers/gpu/drm/i915/intel_huc.h
b/drivers/gpu/drm/i915/intel_huc.h
index 946caa7..8c1847a 100644
--- a/drivers/gpu/drm/i915/intel_huc.h
+++ b/drivers/gpu/drm/i915/intel_huc.h
@@ -40,5 +40,5 @@ extern void intel_huc_init(struct drm_device *dev);
extern int intel_huc_load(struct drm_device *dev);
extern void intel_huc_auth(struct drm_device *dev);
extern void intel_huc_fini(struct drm_device *dev);
-
+extern int intel_is_huc_valid(struct drm_device *dev);
#endif
diff --git a/drivers/gpu/drm/i915/intel_huc_loader.c
b/drivers/gpu/drm/i915/intel_huc_loader.c
index 87a6948..ee42d5e 100644
--- a/drivers/gpu/drm/i915/intel_huc_loader.c
+++ b/drivers/gpu/drm/i915/intel_huc_loader.c
@@ -273,3 +273,24 @@ void intel_huc_fini(struct drm_device *dev)
huc_fw->fetch_status = UC_FIRMWARE_NONE;
}
+
+/**
+ * intel_is_huc_valid() - Check to see if the HuC is fully loaded.
+ * @dev: drm dedvice to check.
+ *
+ * This function will return true if the guc has been loaded and
+ * has valid firmware. The simplest way of doing this is to check
+ * if the HuC has been validated, if so it must have been loaded.
+ */
+int intel_is_huc_valid(struct drm_device *dev)
+{
+ int result;
+ struct drm_i915_private *dev_priv = to_i915(dev);
+
+ intel_uncore_forcewake_get(dev_priv, FORCEWAKE_ALL);
+ result = ((I915_READ(HUC_STATUS2) & HUC_FW_VERIFIED) != 0);
+ intel_uncore_forcewake_put(dev_priv, FORCEWAKE_ALL);
Is there a special reason why it is required to grab all forcewakes?
HUC_STATUS2 is 0xd3b0 which appears to be in the media forcewake range
already defined for gen9. So I915_READ will already grab that one.
No, was just coping the code from the GuC loader. Will remove the
forcewakes.
Thanks,
Peter.
Regards,
Tvrtko
--
Peter Antoine (Android Graphics Driver Software Engineer)
---------------------------------------------------------------------
Intel Corporation (UK) Limited
Registered No. 1134945 (England)
Registered Office: Pipers Way, Swindon SN3 1RJ
VAT No: 860 2173 47
_______________________________________________
Intel-gfx mailing list
Intel-gfx@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/intel-gfx