[PATCH v14 23/25] drm/i915/uc: Update GEM runtime resume w/ and w/o GuC/HuC load

Sagar Arun Kamble sagar.a.kamble at intel.com
Tue Oct 17 10:37:12 UTC 2017


On resume from drm sleep/suspend, we have GEM Init path to load the
GuC/HuC firmware. However, on resume from runtime suspend we need
to add support to load the GuC/HuC firmware and resume. We can leverage
uC Init for this during runtime resume.

v2: Added comments about forced GuC/HuC load during runtime uC resume.
(Michal Wajdeczko). Disabled GuC submission on GuC resume failure during
runtime uC resume.

Signed-off-by: Sagar Arun Kamble <sagar.a.kamble at intel.com>
Cc: Chris Wilson <chris at chris-wilson.co.uk>
Cc: Michal Wajdeczko <michal.wajdeczko at intel.com>
Cc: MichaƂ Winiarski <michal.winiarski at intel.com>
Cc: Joonas Lahtinen <joonas.lahtinen at linux.intel.com>
---
 drivers/gpu/drm/i915/intel_uc.c | 44 +++++++++++++++++++++++++++++------------
 1 file changed, 31 insertions(+), 13 deletions(-)

diff --git a/drivers/gpu/drm/i915/intel_uc.c b/drivers/gpu/drm/i915/intel_uc.c
index 4b6894f..2b59117 100644
--- a/drivers/gpu/drm/i915/intel_uc.c
+++ b/drivers/gpu/drm/i915/intel_uc.c
@@ -444,8 +444,6 @@ int intel_uc_runtime_suspend(struct drm_i915_private *dev_priv)
  *
  * This function does similar resume tasks as uc_resume except
  * GuC load handling in case it gets unloaded during suspend.
- * TODO: Along drm resume path GuC gets loaded through uc_init_hw and
- * we need to add support to load GuC here.
  */
 void intel_uc_runtime_resume(struct drm_i915_private *dev_priv)
 {
@@ -455,23 +453,43 @@ void intel_uc_runtime_resume(struct drm_i915_private *dev_priv)
 	if (!i915_modparams.enable_guc_loading)
 		return;
 
-	/* TODO: Need to handle case when GuC is not loaded. */
-
-	if (guc->fw.load_status != INTEL_UC_FIRMWARE_SUCCESS) {
-		DRM_ERROR("GuC not loaded. Resume skipped\n");
+	if (!guc->suspended) {
+		DRM_ERROR("GuC not suspended. Resume skipped\n");
 		return;
 	}
 
-	intel_restore_guc_interrupts(guc);
+	/*
+	 * Function uc_resume_prepare would have determined GuC/HuC load status.
+	 * If loaded, we need to enable communication with GuC, GuC interrupts,
+	 * invoke GuC action to resume from sleep.
+	 * If not loaded, it is similar to fresh boot and we need load the
+	 * GuC/HuC firmwares and enable other GuC related mechanisms. Post
+	 * loading GuC, we need to send action to resume from sleep for GuC to
+	 * restore its state prior to suspend.
+	 */
+	if (guc->fw.load_status == INTEL_UC_FIRMWARE_SUCCESS) {
+		intel_restore_guc_interrupts(guc);
+
+		ret = intel_guc_resume(guc);
+		if (ret) {
+			DRM_ERROR("GuC resume failed (%d)\n", ret);
 
-	ret = intel_guc_resume(guc);
-	if (ret) {
-		DRM_ERROR("GuC resume failed (%d)\n", ret);
+			intel_suspend_guc_interrupts(guc);
+		}
 
-		intel_suspend_guc_interrupts(guc);
-	}
+		/* TODO: Need to restore doorbells for all GuC clients. */
 
-	/* TODO: Need to restore doorbells for all GuC clients. */
+		guc->suspended = false;
+	}  else {
+		/*
+		 * During runtime resume we don't do full GEM reinitialisation
+		 * hence we will have to load GuC/Huc here through uc_init_hw
+		 * That will internally resume GuC state.
+		 */
+		DRM_DEBUG_DRIVER("GuC not available. Loading GuC firmware. "
+				 "Resume will be done during load\n");
+		intel_uc_init_hw(dev_priv);
+	}
 }
 
 /**
-- 
1.9.1



More information about the Intel-gfx-trybot mailing list