[Intel-gfx] [CI 5/8] resume

Chris Wilson chris at chris-wilson.co.uk
Wed May 18 09:50:44 UTC 2016


---
 drivers/gpu/drm/i915/i915_drv.c | 40 ++++++++++++++++++++++++++++++----------
 1 file changed, 30 insertions(+), 10 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_drv.c b/drivers/gpu/drm/i915/i915_drv.c
index 60ce7373ab45..46f1fd542d73 100644
--- a/drivers/gpu/drm/i915/i915_drv.c
+++ b/drivers/gpu/drm/i915/i915_drv.c
@@ -741,6 +741,7 @@ struct resume_context {
 	struct drm_i915_private *i915;
 
 	async_cookie_t cookie;
+	struct async_fence *irq_fence;
 };
 
 static struct resume_context *resume_context(struct drm_device *dev)
@@ -757,6 +758,8 @@ static struct resume_context *resume_context(struct drm_device *dev)
 		kref_init(&ctx->kref);
 		ctx->i915 = dev_priv;
 
+		ctx->irq_fence = async_fence_create(GFP_KERNEL);
+
 		dev_priv->async_context = ctx;
 	}
 
@@ -767,6 +770,7 @@ static void resume_context_free(struct kref *kref)
 {
 	struct resume_context *ctx = container_of(kref, typeof(*ctx), kref);
 
+	async_fence_put(ctx->irq_fence);
 	kfree(ctx);
 }
 
@@ -797,6 +801,27 @@ static void i915_drm_complete(struct drm_device *dev)
 	resume_context_put(ctx);
 }
 
+static void i915_gem_resume(void *data, async_cookie_t cookie)
+{
+	struct resume_context *ctx = data;
+	struct drm_device *dev = ctx->i915->dev;
+
+	mutex_lock(&dev->struct_mutex);
+
+	i915_gem_restore_gtt_mappings(dev);
+
+	async_fence_wait(ctx->irq_fence);
+
+	if (i915_gem_init_hw(dev)) {
+		DRM_ERROR("failed to re-initialize GPU, declaring wedged!\n");
+			atomic_or(I915_WEDGED, &ctx->i915->gpu_error.reset_counter);
+	}
+
+	mutex_unlock(&dev->struct_mutex);
+
+	resume_context_put(ctx);
+}
+
 static int i915_drm_resume(struct drm_device *dev)
 {
 	struct resume_context *ctx;
@@ -810,11 +835,11 @@ static int i915_drm_resume(struct drm_device *dev)
 	if(i915_ggtt_enable_hw(dev))
 		DRM_ERROR("failed to re-enable GGTT\n");
 
-	intel_csr_ucode_resume(ctx->i915);
+	ctx->cookie = async_schedule_domain(i915_gem_resume,
+					    resume_context_get(ctx),
+					    &ctx->i915->async_domain);
 
-	mutex_lock(&dev->struct_mutex);
-	i915_gem_restore_gtt_mappings(dev);
-	mutex_unlock(&dev->struct_mutex);
+	intel_csr_ucode_resume(ctx->i915);
 
 	i915_restore_state(dev);
 	intel_opregion_setup(dev);
@@ -832,12 +857,7 @@ static int i915_drm_resume(struct drm_device *dev)
 	 */
 	intel_runtime_pm_enable_interrupts(ctx->i915);
 
-	mutex_lock(&dev->struct_mutex);
-	if (i915_gem_init_hw(dev)) {
-		DRM_ERROR("failed to re-initialize GPU, declaring wedged!\n");
-			atomic_or(I915_WEDGED, &ctx->i915->gpu_error.reset_counter);
-	}
-	mutex_unlock(&dev->struct_mutex);
+	async_fence_signal(ctx->irq_fence);
 
 	intel_guc_resume(dev);
 
-- 
2.8.1



More information about the Intel-gfx mailing list