[PATCH 3/7] trim-mutex-lock

Chris Wilson chris at chris-wilson.co.uk
Wed Jun 7 19:28:31 UTC 2017


---
 drivers/gpu/drm/i915/intel_display.c | 24 +++++++++++++-----------
 1 file changed, 13 insertions(+), 11 deletions(-)

diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
index 9398c1dec473..f76cc83d678e 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -12785,14 +12785,7 @@ static int intel_atomic_prepare_commit(struct drm_device *dev,
 			flush_workqueue(dev_priv->wq);
 	}
 
-	ret = mutex_lock_interruptible(&dev->struct_mutex);
-	if (ret)
-		return ret;
-
-	ret = drm_atomic_helper_prepare_planes(dev, &state->base);
-	mutex_unlock(&dev->struct_mutex);
-
-	return ret;
+	return drm_atomic_helper_prepare_planes(dev, &state->base);
 }
 
 u32 intel_crtc_get_vblank_counter(struct intel_crtc *crtc)
@@ -13190,9 +13183,7 @@ static void intel_atomic_commit_tail(struct drm_atomic_state *state)
 	if (intel_state->modeset)
 		intel_display_power_put(dev_priv, POWER_DOMAIN_MODESET);
 
-	mutex_lock(&dev->struct_mutex);
 	drm_atomic_helper_cleanup_planes(dev, state);
-	mutex_unlock(&dev->struct_mutex);
 
 	drm_atomic_helper_commit_cleanup_done(state);
 
@@ -13346,7 +13337,13 @@ intel_prepare_plane_fb(struct drm_plane *plane,
 		} else {
 			struct i915_vma *vma;
 
+			ret = mutex_lock_interruptible(&dev_priv->drm.struct_mutex);
+			if (ret)
+				return ret;
+
 			vma = intel_pin_and_fence_fb_obj(fb, new_state->rotation);
+			mutex_unlock(&dev_priv->drm.struct_mutex);
+
 			if (IS_ERR(vma)) {
 				DRM_DEBUG_KMS("failed to pin object\n");
 				return PTR_ERR(vma);
@@ -13405,7 +13402,9 @@ intel_prepare_plane_fb(struct drm_plane *plane,
 		if (ret < 0)
 			return ret;
 
+		mutex_lock(&dev_priv->drm.struct_mutex);
 		i915_gem_object_wait_priority(obj, 0, I915_PRIORITY_DISPLAY);
+		mutex_unlock(&dev_priv->drm.struct_mutex);
 	}
 
 	return 0;
@@ -13428,8 +13427,11 @@ intel_cleanup_plane_fb(struct drm_plane *plane,
 
 	/* Should only be called after a successful intel_prepare_plane_fb()! */
 	vma = fetch_and_zero(&to_intel_plane_state(old_state)->vma);
-	if (vma)
+	if (vma) {
+		mutex_lock(&plane->dev->struct_mutex);
 		intel_unpin_fb_vma(vma);
+		mutex_unlock(&plane->dev->struct_mutex);
+	}
 }
 
 int
-- 
2.11.0



More information about the Intel-gfx-trybot mailing list