drm/i915/uc: Don't enable communication twice on resume
authorDaniele Ceraolo Spurio <daniele.ceraolospurio@intel.com>
Tue, 30 Jul 2019 23:07:39 +0000 (16:07 -0700)
committerChris Wilson <chris@chris-wilson.co.uk>
Wed, 31 Jul 2019 09:01:32 +0000 (10:01 +0100)
When coming out of S3/S4 we sanitize and re-init the HW, which includes
enabling communication during uc_init_hw. We therefore don't want to do
that again in uc_resume and can just tell GuC to reload its state.

v2: split uc_resume and uc_runtime_resume to match the suspend
    functions and to better differentiate the expected state in the 2
    scenarios (Chris)

Signed-off-by: Daniele Ceraolo Spurio <daniele.ceraolospurio@intel.com>
Cc: Michal Wajdeczko <michal.wajdeczko@intel.com>
Cc: Chris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: Michal Wajdeczko <michal.wajdeczko@intel.com>
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Link: https://patchwork.freedesktop.org/patch/msgid/20190730230743.19542-1-daniele.ceraolospurio@intel.com
drivers/gpu/drm/i915/gt/uc/intel_uc.c
drivers/gpu/drm/i915/gt/uc/intel_uc.h
drivers/gpu/drm/i915/i915_drv.c

index 6eb8bb3fa2522d356a4d37f1aa7a458f030efc99..26671f1daaf7484cb7d2762bf0ddb833e54ca45a 100644 (file)
@@ -233,11 +233,18 @@ static void guc_disable_interrupts(struct intel_guc *guc)
        guc->interrupts.disable(guc);
 }
 
+static inline bool guc_communication_enabled(struct intel_guc *guc)
+{
+       return guc->send != intel_guc_send_nop;
+}
+
 static int guc_enable_communication(struct intel_guc *guc)
 {
        struct drm_i915_private *i915 = guc_to_gt(guc)->i915;
        int ret;
 
+       GEM_BUG_ON(guc_communication_enabled(guc));
+
        ret = intel_guc_ct_enable(&guc->ct);
        if (ret)
                return ret;
@@ -550,7 +557,7 @@ void intel_uc_suspend(struct intel_uc *uc)
                intel_uc_runtime_suspend(uc);
 }
 
-int intel_uc_resume(struct intel_uc *uc)
+static int __uc_resume(struct intel_uc *uc, bool enable_communication)
 {
        struct intel_guc *guc = &uc->guc;
        int err;
@@ -558,7 +565,11 @@ int intel_uc_resume(struct intel_uc *uc)
        if (!intel_guc_is_running(guc))
                return 0;
 
-       guc_enable_communication(guc);
+       /* Make sure we enable communication if and only if it's disabled */
+       GEM_BUG_ON(enable_communication == guc_communication_enabled(guc));
+
+       if (enable_communication)
+               guc_enable_communication(guc);
 
        err = intel_guc_resume(guc);
        if (err) {
@@ -568,3 +579,21 @@ int intel_uc_resume(struct intel_uc *uc)
 
        return 0;
 }
+
+int intel_uc_resume(struct intel_uc *uc)
+{
+       /*
+        * When coming out of S3/S4 we sanitize and re-init the HW, so
+        * communication is already re-enabled at this point.
+        */
+       return __uc_resume(uc, false);
+}
+
+int intel_uc_runtime_resume(struct intel_uc *uc)
+{
+       /*
+        * During runtime resume we don't sanitize, so we need to re-init
+        * communication as well.
+        */
+       return __uc_resume(uc, true);
+}
index fe3362fd770634272fe912d67ded5f1b2541d7c2..25da51e95417bb9e2d08756be98b3ac073366bb3 100644 (file)
@@ -47,6 +47,7 @@ void intel_uc_reset_prepare(struct intel_uc *uc);
 void intel_uc_suspend(struct intel_uc *uc);
 void intel_uc_runtime_suspend(struct intel_uc *uc);
 int intel_uc_resume(struct intel_uc *uc);
+int intel_uc_runtime_resume(struct intel_uc *uc);
 
 static inline bool intel_uc_is_using_guc(struct intel_uc *uc)
 {
index 7d081315014655ac93ac2594c45829038b6950ca..08c5504e040c6fdb407b2fae23890e9ba647cf98 100644 (file)
@@ -2950,7 +2950,7 @@ static int intel_runtime_suspend(struct device *kdev)
 
                intel_runtime_pm_enable_interrupts(dev_priv);
 
-               intel_uc_resume(&dev_priv->gt.uc);
+               intel_uc_runtime_resume(&dev_priv->gt.uc);
 
                intel_gt_init_swizzling(&dev_priv->gt);
                i915_gem_restore_fences(dev_priv);
@@ -3047,7 +3047,7 @@ static int intel_runtime_resume(struct device *kdev)
 
        intel_runtime_pm_enable_interrupts(dev_priv);
 
-       intel_uc_resume(&dev_priv->gt.uc);
+       intel_uc_runtime_resume(&dev_priv->gt.uc);
 
        /*
         * No point of rolling back things in case of an error, as the best