Skip to contentSkip to conversation

Make plane updates use the atomic state.

PATCH New Maarten Lankhorst 1 participant 9 messages Nov 17, 2015

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover Make plane updates use the atomic state.

This fixes the plane commit to use the passed atomic state instead of dereferencing plane->state and crtc->config. It also constifies the state structs passed to the callbacks, since they should be read-only.

"drm/i915: Only rotate cursor base when the cursor is visible." should be applied to -fixes.

Maarten Lankhorst (8):
drm/i915: Use passed plane state for sprite planes, v4. drm/i915: Do not use commit_plane for sprite planes. drm/i915: Remove some visibility checks from intel_crtc_update_cursor. drm/i915: Only rotate cursor base when the cursor is visible. drm/i915: Make disable_cursor_plane similar to commit_cursor_plane. drm/i915: Use the plane state for cursor updates. drm/i915: Use plane state for primary plane updates. drm/i915: Remove commit_plane function pointer.

 drivers/gpu/drm/i915/i915_drv.h           |   3 -
 drivers/gpu/drm/i915/intel_atomic_plane.c |  10 +-
 drivers/gpu/drm/i915/intel_display.c      | 334 +++++++++++++-----------------
 drivers/gpu/drm/i915/intel_drv.h          |  12 +-
 drivers/gpu/drm/i915/intel_sprite.c       | 129 ++++++------
 5 files changed, 212 insertions(+), 276 deletions(-)
Signature · 6 lines
2.1.0

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#1 lore raw

PATCH 1/8 drm/i915: Use passed plane state for sprite planes, v4.

Don't use plane->state directly, use the pointer from commit_plane.

Changes since v1:
- Fix uses of plane->state->rotation and color key to use the passed state too.
- Only pass crtc_state and plane_state to update_plane.
Changes since v2:
- Rebased.
Changes since v3:
- Small whitespace changes and only assign 1 variable per line.
- Constify plane_state and crtc_state.

---
 drivers/gpu/drm/i915/intel_drv.h    |  10 +--
 drivers/gpu/drm/i915/intel_sprite.c | 124 ++++++++++++++++++++----------------
 2 files changed, 71 insertions(+), 63 deletions(-)
drivers/gpu/drm/i915/intel_drv.h +3 -7
index 034b7a84c698..f053e4e888a1 100644
@@ -652,16 +652,12 @@ struct intel_plane {
 	/*
 	 * NOTE: Do not place new plane state fields here (e.g., when adding
 	 * new plane properties).  New runtime state should now be placed in
-	 * the intel_plane_state structure and accessed via drm_plane->state.
+	 * the intel_plane_state structure and accessed via plane_state.
 	 */
 
 	void (*update_plane)(struct drm_plane *plane,
-			     struct drm_crtc *crtc,
-			     struct drm_framebuffer *fb,
-			     int crtc_x, int crtc_y,
-			     unsigned int crtc_w, unsigned int crtc_h,
-			     uint32_t x, uint32_t y,
-			     uint32_t src_w, uint32_t src_h);
+			     const struct intel_crtc_state *crtc_state,
+			     const struct intel_plane_state *plane_state);
 	void (*disable_plane)(struct drm_plane *plane,
 			      struct drm_crtc *crtc);
 	int (*check_plane)(struct drm_plane *plane,
drivers/gpu/drm/i915/intel_sprite.c +68 -56

237 lines not on this page · raw message

Signature · 6 lines
2.1.0

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#2 lore raw

PATCH 2/8 drm/i915: Do not use commit_plane for sprite planes.

In reply to Maarten Lankhorst

Use update_plane and disable_plane directly.

---
 drivers/gpu/drm/i915/intel_atomic_plane.c | 12 +++++++++++-
 drivers/gpu/drm/i915/intel_sprite.c       | 19 -------------------
 2 files changed, 11 insertions(+), 20 deletions(-)
drivers/gpu/drm/i915/intel_atomic_plane.c +11 -1
index c6bb0fc1edfb..ef7157be7ef2 100644
@@ -194,8 +194,18 @@ static void intel_plane_atomic_update(struct drm_plane *plane,
 	struct intel_plane *intel_plane = to_intel_plane(plane);
 	struct intel_plane_state *intel_state =
 		to_intel_plane_state(plane->state);
+	struct drm_crtc *crtc = plane->state->crtc ?: old_state->crtc;
+	struct drm_crtc_state *crtc_state =
+		drm_atomic_get_existing_crtc_state(old_state->state, crtc);
 
-	intel_plane->commit_plane(plane, intel_state);
+	if (intel_plane->commit_plane)
+		intel_plane->commit_plane(plane, intel_state);
+	else if (intel_state->visible)
+		intel_plane->update_plane(plane,
+					  to_intel_crtc_state(crtc_state),
+					  intel_state);
+	else
+		intel_plane->disable_plane(plane, crtc);
 }
 
 const struct drm_plane_helper_funcs intel_plane_helper_funcs = {
drivers/gpu/drm/i915/intel_sprite.c +0 -19
index 706b4b2ee599..8c671e3e9da6 100644
@@ -931,24 +931,6 @@ intel_check_sprite_plane(struct drm_plane *plane,
 	return 0;
 }
 
-static void
-intel_commit_sprite_plane(struct drm_plane *plane,
-			  struct intel_plane_state *state)
-{
-	struct intel_plane *intel_plane = to_intel_plane(plane);
-
-	if (state->visible) {
-		struct intel_crtc_state *crtc_state =
-			to_intel_crtc(state->base.crtc)->config;
-
-		intel_plane->update_plane(plane, crtc_state, state);
-	} else {
-		struct drm_crtc *crtc = state->base.crtc;
-
-		intel_plane->disable_plane(plane, crtc ?: plane->crtc);
-	}
-}
-
 int intel_sprite_set_colorkey(struct drm_device *dev, void *data,
 			      struct drm_file *file_priv)
 {
@@ -1130,7 +1112,6 @@ intel_plane_init(struct drm_device *dev, enum pipe pipe, int plane)
 	intel_plane->plane = plane;
 	intel_plane->frontbuffer_bit = INTEL_FRONTBUFFER_SPRITE(pipe, plane);
 	intel_plane->check_plane = intel_check_sprite_plane;
-	intel_plane->commit_plane = intel_commit_sprite_plane;
 	possible_crtcs = (1 << pipe);
 	ret = drm_universal_plane_init(dev, &intel_plane->base, possible_crtcs,
 				       &intel_plane_funcs,
Signature · 6 lines
2.1.0

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#3 lore raw

PATCH 3/8 drm/i915: Remove some visibility checks from intel_crtc_update_cursor.

In reply to Maarten Lankhorst

This is duplicated with intel_check_cursor_plane, and with all non-atomic paths removed this should be dead code.

---
 drivers/gpu/drm/i915/intel_display.c | 17 -----------------
 1 file changed, 17 deletions(-)
drivers/gpu/drm/i915/intel_display.c +0 -17
index c9b969552592..c7ed478ddd49 100644
@@ -83,8 +83,6 @@ static const uint32_t intel_cursor_formats[] = {
 	DRM_FORMAT_ARGB8888,
 };
 
-static void intel_crtc_update_cursor(struct drm_crtc *crtc, bool on);
-
 static void i9xx_crtc_clock_get(struct intel_crtc *crtc,
 				struct intel_crtc_state *pipe_config);
 static void ironlake_pch_clock_get(struct intel_crtc *crtc,
@@ -10027,33 +10025,18 @@ static void intel_crtc_update_cursor(struct drm_crtc *crtc,
 	if (on)
 		base = intel_crtc->cursor_addr;
 
-	if (x >= intel_crtc->config->pipe_src_w)
-		base = 0;
-
-	if (y >= intel_crtc->config->pipe_src_h)
-		base = 0;
-
 	if (x < 0) {
-		if (x + cursor_state->crtc_w <= 0)
-			base = 0;
-
 		pos |= CURSOR_POS_SIGN << CURSOR_X_SHIFT;
 		x = -x;
 	}
 	pos |= x << CURSOR_X_SHIFT;
 
 	if (y < 0) {
-		if (y + cursor_state->crtc_h <= 0)
-			base = 0;
-
 		pos |= CURSOR_POS_SIGN << CURSOR_Y_SHIFT;
 		y = -y;
 	}
 	pos |= y << CURSOR_Y_SHIFT;
 
-	if (base == 0 && intel_crtc->cursor_base == 0)
-		return;
-
 	I915_WRITE(CURPOS(pipe), pos);
 
 	/* ILK+ do this automagically */
Signature · 6 lines
2.1.0

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#4 lore raw

PATCH 4/8 drm/i915: Only rotate cursor base when the cursor is visible.

In reply to Maarten Lankhorst

There is a if branch in i9xx_update_cursor that may get taken otherwise, resulting in cursor not being made invisible accidentally.

---
 drivers/gpu/drm/i915/intel_display.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/i915/intel_display.c +1 -1
index c7ed478ddd49..70e4589e6387 100644
@@ -10040,7 +10040,7 @@ static void intel_crtc_update_cursor(struct drm_crtc *crtc,
 	I915_WRITE(CURPOS(pipe), pos);
 
 	/* ILK+ do this automagically */
-	if (HAS_GMCH_DISPLAY(dev) &&
+	if (HAS_GMCH_DISPLAY(dev) && base &&
 	    crtc->cursor->state->rotation == BIT(DRM_ROTATE_180)) {
 		base += (cursor_state->crtc_h *
 			 cursor_state->crtc_w - 1) * 4;
Signature · 6 lines
2.1.0

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#5 lore raw

PATCH 5/8 drm/i915: Make disable_cursor_plane similar to commit_cursor_plane.

In reply to Maarten Lankhorst

Update cursor_bo and cursor_addr after being called. This is required to make commit_cursor_plane take a crtc_state and a plane_state.

---
 drivers/gpu/drm/i915/intel_display.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/gpu/drm/i915/intel_display.c +4 -0
index 70e4589e6387..cfc2d92f7ebd 100644
@@ -13942,6 +13942,10 @@ static void
 intel_disable_cursor_plane(struct drm_plane *plane,
 			   struct drm_crtc *crtc)
 {
+	struct intel_crtc *crtc = to_intel_crtc(crtc);
+
+	intel_crtc->cursor_addr = 0;
+	intel_crtc->cursor_bo = NULL;
 	intel_crtc_update_cursor(crtc, false);
 }
 
Signature · 6 lines
2.1.0

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#6 lore raw

PATCH 6/8 drm/i915: Use the plane state for cursor updates.

In reply to Maarten Lankhorst

Cursor planes grab the state from plane->state instead of the state that was passed. The only cursor updates dpme are atomic now, so use the plane_state that's passed in.

---
 drivers/gpu/drm/i915/intel_display.c | 70 ++++++++++++++++++------------------
 1 file changed, 36 insertions(+), 34 deletions(-)
drivers/gpu/drm/i915/intel_display.c +36 -34
index cfc2d92f7ebd..b383cbe3964c 100644
@@ -9900,7 +9900,8 @@ static bool haswell_get_pipe_config(struct intel_crtc *crtc,
 	return true;
 }
 
-static void i845_update_cursor(struct drm_crtc *crtc, u32 base)
+static void i845_update_cursor(struct drm_crtc *crtc, u32 base,
+			       const struct intel_plane_state *plane_state)
 {
 	struct drm_device *dev = crtc->dev;
 	struct drm_i915_private *dev_priv = dev->dev_private;
@@ -9908,8 +9909,8 @@ static void i845_update_cursor(struct drm_crtc *crtc, u32 base)
 	uint32_t cntl = 0, size = 0;
 
 	if (base) {
-		unsigned int width = intel_crtc->base.cursor->state->crtc_w;
-		unsigned int height = intel_crtc->base.cursor->state->crtc_h;
+		unsigned int width = plane_state->base.crtc_w;
+		unsigned int height = plane_state->base.crtc_h;
 		unsigned int stride = roundup_pow_of_two(width) * 4;
 
 		switch (stride) {
@@ -9962,7 +9963,8 @@ static void i845_update_cursor(struct drm_crtc *crtc, u32 base)
 	}
 }
 
-static void i9xx_update_cursor(struct drm_crtc *crtc, u32 base)
+static void i9xx_update_cursor(struct drm_crtc *crtc, u32 base,
+			       const struct intel_plane_state *plane_state)
 {
 	struct drm_device *dev = crtc->dev;
 	struct drm_i915_private *dev_priv = dev->dev_private;
@@ -9973,7 +9975,7 @@ static void i9xx_update_cursor(struct drm_crtc *crtc, u32 base)
 	cntl = 0;
 	if (base) {
 		cntl = MCURSOR_GAMMA_ENABLE;
-		switch (intel_crtc->base.cursor->state->crtc_w) {
+		switch (plane_state->base.crtc_w) {
 			case 64:
 				cntl |= CURSOR_MODE_64_ARGB_AX;
 				break;
@@ -9984,17 +9986,17 @@ static void i9xx_update_cursor(struct drm_crtc *crtc, u32 base)
 				cntl |= CURSOR_MODE_256_ARGB_AX;
 				break;
 			default:
-				MISSING_CASE(intel_crtc->base.cursor->state->crtc_w);
+				MISSING_CASE(plane_state->base.crtc_w);
 				return;
 		}
 		cntl |= pipe << 28; /* Connect to correct pipe */
 
 		if (HAS_DDI(dev))
 			cntl |= CURSOR_PIPE_CSC_ENABLE;
-	}
 
-	if (crtc->cursor->state->rotation == BIT(DRM_ROTATE_180))
-		cntl |= CURSOR_ROTATE_180;
+		if (plane_state->base.rotation == BIT(DRM_ROTATE_180))
+			cntl |= CURSOR_ROTATE_180;
+	}
 
 	if (intel_crtc->cursor_cntl != cntl) {
 		I915_WRITE(CURCNTR(pipe), cntl);
@@ -10011,20 +10013,29 @@ static void i9xx_update_cursor(struct drm_crtc *crtc, u32 base)
 
 /* If no-part of the cursor is visible on the framebuffer, then the GPU may hang... */
 static void intel_crtc_update_cursor(struct drm_crtc *crtc,
-				     bool on)
+				     const struct intel_plane_state *plane_state)
 {
 	struct drm_device *dev = crtc->dev;
 	struct drm_i915_private *dev_priv = dev->dev_private;
 	struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
 	int pipe = intel_crtc->pipe;
-	struct drm_plane_state *cursor_state = crtc->cursor->state;
-	int x = cursor_state->crtc_x;
-	int y = cursor_state->crtc_y;
+	int x = 0, y = 0;
 	u32 base = 0, pos = 0;
 
-	if (on)
+	if (plane_state && plane_state->visible) {
 		base = intel_crtc->cursor_addr;
 
+		x = plane_state->base.crtc_x;
+		y = plane_state->base.crtc_y;
+
+		/* ILK+ do this automagically */
+		if (HAS_GMCH_DISPLAY(dev) &&
+		    plane_state->base.rotation == BIT(DRM_ROTATE_180)) {
+			base += (plane_state->base.crtc_h *
+				 plane_state->base.crtc_w - 1) * 4;
+		}
+	}
+
 	if (x < 0) {
 		pos |= CURSOR_POS_SIGN << CURSOR_X_SHIFT;
 		x = -x;
@@ -10039,17 +10050,10 @@ static void intel_crtc_update_cursor(struct drm_crtc *crtc,
 
 	I915_WRITE(CURPOS(pipe), pos);
 
-	/* ILK+ do this automagically */
-	if (HAS_GMCH_DISPLAY(dev) && base &&
-	    crtc->cursor->state->rotation == BIT(DRM_ROTATE_180)) {
-		base += (cursor_state->crtc_h *
-			 cursor_state->crtc_w - 1) * 4;
-	}
-
 	if (IS_845G(dev) || IS_I865G(dev))
-		i845_update_cursor(crtc, base);
+		i845_update_cursor(crtc, base, plane_state);
 	else
-		i9xx_update_cursor(crtc, base);
+		i9xx_update_cursor(crtc, base, plane_state);
 }
 
 static bool cursor_size_ok(struct drm_device *dev,
@@ -13942,26 +13946,24 @@ static void
 intel_disable_cursor_plane(struct drm_plane *plane,
 			   struct drm_crtc *crtc)
 {
-	struct intel_crtc *crtc = to_intel_crtc(crtc);
+	struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
 
 	intel_crtc->cursor_addr = 0;
 	intel_crtc->cursor_bo = NULL;
-	intel_crtc_update_cursor(crtc, false);
+	intel_crtc_update_cursor(crtc, NULL);
 }
 
 static void
-intel_commit_cursor_plane(struct drm_plane *plane,
-			  struct intel_plane_state *state)
+intel_update_cursor_plane(struct drm_plane *plane,
+			  const struct intel_crtc_state *crtc_state,
+			  const struct intel_plane_state *state)
 {
-	struct drm_crtc *crtc = state->base.crtc;
+	struct drm_crtc *crtc = crtc_state->base.crtc;
+	struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
 	struct drm_device *dev = plane->dev;
-	struct intel_crtc *intel_crtc;
 	struct drm_i915_gem_object *obj = intel_fb_obj(state->base.fb);
 	uint32_t addr;
 
-	crtc = crtc ? crtc : plane->crtc;
-	intel_crtc = to_intel_crtc(crtc);
-
 	if (intel_crtc->cursor_bo == obj)
 		goto update;
 
@@ -13976,7 +13978,7 @@ intel_commit_cursor_plane(struct drm_plane *plane,
 	intel_crtc->cursor_bo = obj;
 
 update:
-	intel_crtc_update_cursor(crtc, state->visible);
+	intel_crtc_update_cursor(crtc, state);
 }
 
 static struct drm_plane *intel_cursor_plane_create(struct drm_device *dev,
@@ -14002,7 +14004,7 @@ static struct drm_plane *intel_cursor_plane_create(struct drm_device *dev,
 	cursor->plane = pipe;
 	cursor->frontbuffer_bit = INTEL_FRONTBUFFER_CURSOR(pipe);
 	cursor->check_plane = intel_check_cursor_plane;
-	cursor->commit_plane = intel_commit_cursor_plane;
+	cursor->update_plane = intel_update_cursor_plane;
 	cursor->disable_plane = intel_disable_cursor_plane;
 
 	drm_universal_plane_init(dev, &cursor->base, 0,
Signature · 6 lines
2.1.0

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#7 lore raw

PATCH 7/8 drm/i915: Use plane state for primary plane updates.

In reply to Maarten Lankhorst

Pass in the atomic states to allow for proper updates. This removes uses of intel_crtc->config and direct access to plane->state.

This breaks the last bit of kgdboc, but that appears to be dead code.

---
 drivers/gpu/drm/i915/i915_drv.h      |   3 -
 drivers/gpu/drm/i915/intel_display.c | 249 ++++++++++++++---------------------
 2 files changed, 102 insertions(+), 150 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +0 -3
index b6b62387cbe1..8c6b5eb2a8bb 100644
@@ -656,9 +656,6 @@ struct drm_i915_display_funcs {
 			  struct drm_i915_gem_object *obj,
 			  struct drm_i915_gem_request *req,
 			  uint32_t flags);
-	void (*update_primary_plane)(struct drm_crtc *crtc,
-				     struct drm_framebuffer *fb,
-				     int x, int y);
 	void (*hpd_irq_setup)(struct drm_device *dev);
 	/* clock updates for mode set */
 	/* cursor updates */
drivers/gpu/drm/i915/intel_display.c +102 -147

420 lines not on this page · raw message

Signature · 6 lines
2.1.0

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#8 lore raw

PATCH 8/8 drm/i915: Remove commit_plane function pointer.

In reply to Maarten Lankhorst

With sprites, cursors and primary planes taking the atomic state this is now unused. It's removed in a separate commit to allow a revert.

---
 drivers/gpu/drm/i915/intel_atomic_plane.c | 4 +---
 drivers/gpu/drm/i915/intel_drv.h          | 2 --
 2 files changed, 1 insertion(+), 5 deletions(-)
drivers/gpu/drm/i915/intel_atomic_plane.c +1 -3
index ef7157be7ef2..a5a336863109 100644
@@ -198,9 +198,7 @@ static void intel_plane_atomic_update(struct drm_plane *plane,
 	struct drm_crtc_state *crtc_state =
 		drm_atomic_get_existing_crtc_state(old_state->state, crtc);
 
-	if (intel_plane->commit_plane)
-		intel_plane->commit_plane(plane, intel_state);
-	else if (intel_state->visible)
+	if (intel_state->visible)
 		intel_plane->update_plane(plane,
 					  to_intel_crtc_state(crtc_state),
 					  intel_state);
drivers/gpu/drm/i915/intel_drv.h +0 -2
index f053e4e888a1..ae120d802775 100644
@@ -663,8 +663,6 @@ struct intel_plane {
 	int (*check_plane)(struct drm_plane *plane,
 			   struct intel_crtc_state *crtc_state,
 			   struct intel_plane_state *state);
-	void (*commit_plane)(struct drm_plane *plane,
-			     struct intel_plane_state *state);
 };
 
 struct intel_watermark_params {
Signature · 6 lines
2.1.0

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx