[Intel-gfx] [PATCH 4/5] drm/i915: Quick spring clean of intel_prepare_plane_fb()

Chris Wilson chris at chris-wilson.co.uk
Sat Oct 29 12:04:46 UTC 2016


Just a quick tidy now to make the next patch neater.

Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
---
 drivers/gpu/drm/i915/intel_display.c | 38 ++++++++++++++++++++----------------
 1 file changed, 21 insertions(+), 17 deletions(-)

diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
index 9391c1dcd57f..97bd5698003f 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -14119,6 +14119,17 @@ static int intel_atomic_check(struct drm_device *dev,
 	return calc_watermark_data(state);
 }
 
+static bool old_plane_needs_modeset(struct drm_plane *plane,
+				    struct drm_plane_state *new_state)
+{
+	struct drm_crtc_state *crtc_state;
+
+	crtc_state = drm_atomic_get_existing_crtc_state(new_state->state,
+							plane->state->crtc);
+
+	return needs_modeset(crtc_state);
+}
+
 /**
  * intel_prepare_plane_fb - Prepare fb for usage on plane
  * @plane: drm plane to prepare for
@@ -14143,16 +14154,11 @@ intel_prepare_plane_fb(struct drm_plane *plane,
 	struct drm_i915_private *dev_priv = to_i915(dev);
 	struct drm_framebuffer *fb = new_state->fb;
 	struct drm_i915_gem_object *obj = intel_fb_obj(fb);
-	struct drm_i915_gem_object *old_obj = intel_fb_obj(plane->state->fb);
 	int ret;
 
-	if (!obj && !old_obj)
-		return 0;
-
-	if (old_obj) {
-		struct drm_crtc_state *crtc_state =
-			drm_atomic_get_existing_crtc_state(new_state->state,
-							   plane->state->crtc);
+	if (plane->state->fb && old_plane_needs_modeset(plane, new_state)) {
+		struct drm_i915_gem_object *old_obj =
+			intel_fb_obj(plane->state->fb);
 
 		/* Big Hammer, we also need to ensure that any pending
 		 * MI_WAIT_FOR_EVENT inside a user batch buffer on the
@@ -14165,14 +14171,12 @@ intel_prepare_plane_fb(struct drm_plane *plane,
 		 * This should only fail upon a hung GPU, in which case we
 		 * can safely continue.
 		 */
-		if (needs_modeset(crtc_state)) {
-			ret = i915_sw_fence_await_reservation(&intel_state->commit_ready,
-							      old_obj->resv, NULL,
-							      false, 0,
-							      GFP_KERNEL);
-			if (ret < 0)
-				return ret;
-		}
+		ret = i915_sw_fence_await_reservation(&intel_state->commit_ready,
+						      old_obj->resv, NULL,
+						      false, 0,
+						      GFP_KERNEL);
+		if (ret < 0)
+			return ret;
 	}
 
 	if (new_state->fence) { /* explicit fencing */
@@ -14211,7 +14215,7 @@ intel_prepare_plane_fb(struct drm_plane *plane,
 
 		vma = intel_pin_and_fence_fb_obj(fb, new_state->rotation);
 		if (IS_ERR(vma))
-			ret = PTR_ERR(vma);
+			return PTR_ERR(vma);
 
 		to_intel_plane_state(new_state)->vma = vma;
 	}
-- 
2.10.1



More information about the Intel-gfx mailing list