@@ -682,7 +682,7 @@ static int i915_load_modeset_init(struct drm_device *dev)
return 0;
cleanup_gem:
- if (i915_gem_suspend(dev_priv))
+ if (i915_gem_unload(dev_priv))
DRM_ERROR("failed to idle hardware; continuing to unload!\n");
i915_gem_fini(dev_priv);
cleanup_uc:
@@ -1375,7 +1375,7 @@ void i915_driver_unload(struct drm_device *dev)
i915_driver_unregister(dev_priv);
- if (i915_gem_suspend(dev_priv))
+ if (i915_gem_unload(dev_priv))
DRM_ERROR("failed to idle hardware; continuing to unload!\n");
intel_display_power_get(dev_priv, POWER_DOMAIN_INIT);
@@ -3669,6 +3669,7 @@ void i915_gem_reset_engine(struct intel_engine_cs *engine,
int i915_gem_wait_for_idle(struct drm_i915_private *dev_priv,
unsigned int flags);
int __must_check i915_gem_suspend(struct drm_i915_private *dev_priv);
+int __must_check i915_gem_unload(struct drm_i915_private *dev_priv);
void i915_gem_resume(struct drm_i915_private *dev_priv);
int i915_gem_fault(struct vm_fault *vmf);
int i915_gem_object_wait(struct drm_i915_gem_object *obj,
@@ -4545,12 +4545,11 @@ void i915_gem_sanitize(struct drm_i915_private *i915)
}
}
-int i915_gem_suspend(struct drm_i915_private *dev_priv)
+static int i915_gem_contexts_suspend(struct drm_i915_private *dev_priv)
{
struct drm_device *dev = &dev_priv->drm;
int ret;
- intel_runtime_pm_get(dev_priv);
intel_suspend_gt_powersave(dev_priv);
mutex_lock(&dev->struct_mutex);
@@ -4577,8 +4576,15 @@ int i915_gem_suspend(struct drm_i915_private *dev_priv)
i915_gem_contexts_lost(dev_priv);
mutex_unlock(&dev->struct_mutex);
- intel_guc_system_suspend(&dev_priv->guc);
+ return 0;
+
+err_unlock:
+ mutex_unlock(&dev->struct_mutex);
+ return ret;
+}
+static void i915_gem_suspend_complete(struct drm_i915_private *dev_priv)
+{
cancel_delayed_work_sync(&dev_priv->gpu_error.hangcheck_work);
cancel_delayed_work_sync(&dev_priv->gt.retire_work);
@@ -4615,12 +4621,48 @@ int i915_gem_suspend(struct drm_i915_private *dev_priv)
* machine in an unusable condition.
*/
i915_gem_sanitize(dev_priv);
+}
+
+int i915_gem_suspend(struct drm_i915_private *dev_priv)
+{
+ int ret;
+
+ intel_runtime_pm_get(dev_priv);
+
+ ret = i915_gem_contexts_suspend(dev_priv);
+ if (ret && ret != -EIO)
+ goto err_suspend;
+
+ intel_guc_system_suspend(&dev_priv->guc);
+
+ i915_gem_suspend_complete(dev_priv);
intel_runtime_pm_put(dev_priv);
return 0;
-err_unlock:
- mutex_unlock(&dev->struct_mutex);
+err_suspend:
+ intel_runtime_pm_put(dev_priv);
+ return ret;
+}
+
+int i915_gem_unload(struct drm_i915_private *dev_priv)
+{
+ int ret;
+
+ intel_runtime_pm_get(dev_priv);
+
+ ret = i915_gem_contexts_suspend(dev_priv);
+ if (ret && ret != -EIO)
+ goto err_suspend;
+
+ intel_uc_unload(dev_priv);
+
+ i915_gem_suspend_complete(dev_priv);
+
+ intel_runtime_pm_put(dev_priv);
+ return 0;
+
+err_suspend:
intel_runtime_pm_put(dev_priv);
return ret;
}
@@ -333,3 +333,16 @@ int intel_guc_system_resume(struct intel_guc *guc)
*/
return ret;
}
+
+void intel_guc_unload(struct intel_guc *guc)
+{
+ struct drm_i915_private *dev_priv = guc_to_i915(guc);
+ struct drm_device *dev = &dev_priv->drm;
+
+ if (i915.enable_guc_submission) {
+ mutex_lock(&dev->struct_mutex);
+ i915_guc_submission_disable(dev_priv);
+ mutex_unlock(&dev->struct_mutex);
+ intel_guc_reset_prepare(guc);
+ }
+}
@@ -155,6 +155,7 @@ static inline u32 guc_ggtt_offset(struct i915_vma *vma)
int intel_guc_runtime_resume(struct intel_guc *guc);
int intel_guc_system_suspend(struct intel_guc *guc);
int intel_guc_system_resume(struct intel_guc *guc);
+void intel_guc_unload(struct intel_guc *guc);
/* intel_guc_loader.c */
int intel_guc_select_fw(struct intel_guc *guc);
@@ -379,22 +379,18 @@ int intel_uc_init_hw(struct drm_i915_private *dev_priv)
return ret;
}
-void intel_uc_fini_hw(struct drm_i915_private *dev_priv)
+void intel_uc_unload(struct drm_i915_private *dev_priv)
{
- guc_free_load_err_log(&dev_priv->guc);
+ intel_guc_unload(&dev_priv->guc);
+}
+void intel_uc_fini_hw(struct drm_i915_private *dev_priv)
+{
if (!i915.enable_guc_loading)
return;
- if (i915.enable_guc_submission)
- i915_guc_submission_disable(dev_priv);
-
- intel_guc_disable_communication(&dev_priv->guc);
+ guc_free_load_err_log(&dev_priv->guc);
- if (i915.enable_guc_submission) {
- gen9_disable_guc_interrupts(dev_priv);
+ if (i915.enable_guc_submission)
i915_guc_submission_fini(dev_priv);
- }
-
- i915_ggtt_disable_guc(dev_priv);
}
@@ -104,6 +104,7 @@ struct intel_uc_fw {
void intel_uc_init_fw(struct drm_i915_private *dev_priv);
void intel_uc_fini_fw(struct drm_i915_private *dev_priv);
int intel_uc_init_hw(struct drm_i915_private *dev_priv);
+void intel_uc_unload(struct drm_i915_private *dev_priv);
void intel_uc_fini_hw(struct drm_i915_private *dev_priv);
#endif