Skip to contentSkip to conversation

Nuke some legacy state.

PATCH In review Maarten Lankhorst 3 participants 37 messages Sep 10, 2015 – Sep 23, 2015

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

cover Nuke some legacy state.

This series reduces the dependency on legacy state, and replaces it with atomic state where possible.

Maarten Lankhorst (10):
drm/i915: Use atomic plane state in the primary plane update. drm/i915: Use the plane state in intel_crtc_info. drm/i915: Use the atomic state in intel_update_primary_planes. drm/i915: Use atomic state when changing cursor visibility. drm/i915: Remove legacy plane updates for cursor and sprite planes. drm/i915: Update legacy primary state outside the commit hook. drm/i915: Do not handle a null plane state.
drm/i915: Use crtc->state for duplication.
drm/i915: Kill off a user of update_state_fb.
drm/i915: Only run commit when crtc is active.

 drivers/gpu/drm/i915/i915_debugfs.c       |  8 +--
 drivers/gpu/drm/i915/intel_atomic.c       |  9 +---
 drivers/gpu/drm/i915/intel_atomic_plane.c |  6 +--
 drivers/gpu/drm/i915/intel_display.c      | 82 ++++++++++++++-----------------
 drivers/gpu/drm/i915/intel_sprite.c       |  5 --
 5 files changed, 45 insertions(+), 65 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/10 drm/i915: Use atomic plane state in the primary plane update.

---
 drivers/gpu/drm/i915/intel_display.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/intel_display.c +3 -1
index 80a98bffd5ba..33200403a5db 100644
@@ -13448,7 +13448,9 @@ intel_commit_primary_plane(struct drm_plane *plane,
 	if (!crtc->state->active)
 		return;
 
-	dev_priv->display.update_primary_plane(crtc, fb, crtc->x, crtc->y);
+	dev_priv->display.update_primary_plane(crtc, fb,
+					       state->src.x1 >> 16,
+					       state->src.y1 >> 16);
 }
 
 static void
Signature · 6 lines
2.1.0

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

Re: [PATCH 01/10] drm/i915: Use atomic plane state in the primary plane update.

Quoted 10 lines · Maarten Lankhorst
---
 drivers/gpu/drm/i915/intel_display.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/intel_display.c +0 -0
index 80a98bffd5ba..33200403a5db 100644

drivers/gpu/drm/i915/intel_display.c intel_commit_primary_plane(struct drm_plane *plane, · line 13454

Quoted 8 lines
drivers/gpu/drm/i915/intel_display.c +3 -1
@@ -13448,7 +13448,9 @@ intel_commit_primary_plane(struct drm_plane *plane,
 	if (!crtc->state->active)
 		return;
 
-	dev_priv->display.update_primary_plane(crtc, fb, crtc->x, crtc->y);
+	dev_priv->display.update_primary_plane(crtc, fb,
+					       state->src.x1 >> 16,
+					       state->src.y1 >> 16);
 }

You know I posted a pile of patches last spring to start cleaning up this mess. Maybe someone wants to rescue the patches and avoid some duplicate work?

http://lists.freedesktop.org/archives/intel-gfx/2015-March/061715.html

Signature · 6 lines
Ville Syrjälä
Intel OTC
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#3 lore raw

Re: [PATCH 01/10] drm/i915: Use atomic plane state in the primary plane update.

Op 14-09-15 om 15:27 schreef Ville Syrjälä:

Quoted 23 lines · Maarten Lankhorst
Quoted 10 lines
---
 drivers/gpu/drm/i915/intel_display.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/intel_display.c +0 -0
index 80a98bffd5ba..33200403a5db 100644

drivers/gpu/drm/i915/intel_display.c intel_commit_primary_plane(struct drm_plane *plane, · line 13454

Quoted 8 lines
drivers/gpu/drm/i915/intel_display.c +3 -1
@@ -13448,7 +13448,9 @@ intel_commit_primary_plane(struct drm_plane *plane,
 	if (!crtc->state->active)
 		return;
 
-	dev_priv->display.update_primary_plane(crtc, fb, crtc->x, crtc->y);
+	dev_priv->display.update_primary_plane(crtc, fb,
+					       state->src.x1 >> 16,
+					       state->src.y1 >> 16);
 }

You know I posted a pile of patches last spring to start cleaning up this mess. Maybe someone wants to rescue the patches and avoid some duplicate work?

Quoted 2 lines

http://lists.freedesktop.org/archives/intel-gfx/2015-March/061715.html

Yeah I've seen it, watermarks will have to be solved another way. I've been considering passing to the primary plane state instead. :-)
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

#4 lore raw

Re: [PATCH 01/10] drm/i915: Use atomic plane state in the primary plane update.

Quoted 24 lines · Maarten Lankhorst

Op 14-09-15 om 15:27 schreef Ville Syrjälä:

Quoted 23 lines · Maarten Lankhorst
Quoted 10 lines
---
 drivers/gpu/drm/i915/intel_display.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/intel_display.c +0 -0
index 80a98bffd5ba..33200403a5db 100644

drivers/gpu/drm/i915/intel_display.c intel_commit_primary_plane(struct drm_plane *plane, · line 13454

Quoted 8 lines
drivers/gpu/drm/i915/intel_display.c +3 -1
@@ -13448,7 +13448,9 @@ intel_commit_primary_plane(struct drm_plane *plane,
 	if (!crtc->state->active)
 		return;
 
-	dev_priv->display.update_primary_plane(crtc, fb, crtc->x, crtc->y);
+	dev_priv->display.update_primary_plane(crtc, fb,
+					       state->src.x1 >> 16,
+					       state->src.y1 >> 16);
 }

You know I posted a pile of patches last spring to start cleaning up this mess. Maybe someone wants to rescue the patches and avoid some duplicate work?

Quoted 4 lines
Quoted 2 lines

http://lists.freedesktop.org/archives/intel-gfx/2015-March/061715.html

Yeah I've seen it, watermarks will have to be solved another way. I've been considering passing to the primary plane state instead. :-)

I wasn't referring to watermarks. I meant the series started to make the primary plane code sane, but it got stuck in some crap limbo again even though the relevant patches were reviewed. Someone should take them, and thus make the primary plane code suck a bit less. And then it should be fairly easy to continue the effort to unify the primary plane code to look like the sprite plane code, and eventually unify it all. The current situation is just a weird mess.

Signature · 6 lines
Ville Syrjälä
Intel OTC
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#5 lore raw

Re: [PATCH 01/10] drm/i915: Use atomic plane state in the primary plane update.

In reply to Ville Syrjälä
Quoted 24 lines · Ville Syrjälä
Quoted 10 lines · Maarten Lankhorst
---
 drivers/gpu/drm/i915/intel_display.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/intel_display.c +0 -0
index 80a98bffd5ba..33200403a5db 100644

drivers/gpu/drm/i915/intel_display.c intel_commit_primary_plane(struct drm_plane *plane, · line 13454

Quoted 8 lines
drivers/gpu/drm/i915/intel_display.c +3 -1
@@ -13448,7 +13448,9 @@ intel_commit_primary_plane(struct drm_plane *plane,
 	if (!crtc->state->active)
 		return;
 
-	dev_priv->display.update_primary_plane(crtc, fb, crtc->x, crtc->y);
+	dev_priv->display.update_primary_plane(crtc, fb,
+					       state->src.x1 >> 16,
+					       state->src.y1 >> 16);
 }

You know I posted a pile of patches last spring to start cleaning up this mess. Maybe someone wants to rescue the patches and avoid some duplicate work?

Quoted 1 line

http://lists.freedesktop.org/archives/intel-gfx/2015-March/061715.html

I double-checked that series again and I pulled in the first 3 patches (which had an r-b), but for patches 4+ there's been some inconclusive discussion afaict from a quick look. Did I miss a resend somewhere?

Thanks, Daniel

Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#6 lore raw

Re: [PATCH 01/10] drm/i915: Use atomic plane state in the primary plane update.

Quoted 25 lines · Daniel Vetter
Quoted 24 lines · Ville Syrjälä
Quoted 10 lines · Maarten Lankhorst
---
 drivers/gpu/drm/i915/intel_display.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/intel_display.c +0 -0
index 80a98bffd5ba..33200403a5db 100644

drivers/gpu/drm/i915/intel_display.c intel_commit_primary_plane(struct drm_plane *plane, · line 13454

Quoted 8 lines
drivers/gpu/drm/i915/intel_display.c +3 -1
@@ -13448,7 +13448,9 @@ intel_commit_primary_plane(struct drm_plane *plane,
 	if (!crtc->state->active)
 		return;
 
-	dev_priv->display.update_primary_plane(crtc, fb, crtc->x, crtc->y);
+	dev_priv->display.update_primary_plane(crtc, fb,
+					       state->src.x1 >> 16,
+					       state->src.y1 >> 16);
 }

You know I posted a pile of patches last spring to start cleaning up this mess. Maybe someone wants to rescue the patches and avoid some duplicate work?

Quoted 5 lines
Quoted 1 line

http://lists.freedesktop.org/archives/intel-gfx/2015-March/061715.html

I double-checked that series again and I pulled in the first 3 patches (which had an r-b), but for patches 4+ there's been some inconclusive discussion afaict from a quick look. Did I miss a resend somewhere?

Nah. I think the patches cleaning up the primary plane junk had an r-b, but I guess those were patches 5-6. But given how bad atomic/plane state was at the time, I'm sure those couldn't have been applied safely w/o patch 4. One might hope things have gotten better since then, but I can't be sure.

Signature · 6 lines
Ville Syrjälä
Intel OTC
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#7 lore raw

PATCH 2/10 drm/i915: Use the plane state in intel_crtc_info.

In reply to Maarten Lankhorst

Legacy state might not be updated any more.

---
 drivers/gpu/drm/i915/i915_debugfs.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/gpu/drm/i915/i915_debugfs.c +5 -3
index 41629faaf939..72ae3472ddbe 100644
@@ -2817,11 +2817,13 @@ static void intel_crtc_info(struct seq_file *m, struct intel_crtc *intel_crtc)
 	struct drm_device *dev = node->minor->dev;
 	struct drm_crtc *crtc = &intel_crtc->base;
 	struct intel_encoder *intel_encoder;
+	struct drm_plane_state *plane_state = crtc->primary->state;
+	struct drm_framebuffer *fb = plane_state->fb;
 
-	if (crtc->primary->fb)
+	if (fb)
 		seq_printf(m, "\tfb: %d, pos: %dx%d, size: %dx%d\n",
-			   crtc->primary->fb->base.id, crtc->x, crtc->y,
-			   crtc->primary->fb->width, crtc->primary->fb->height);
+			   fb->base.id, plane_state->src_x >> 16,
+			   plane_state->src_y >> 16, fb->width, fb->height);
 	else
 		seq_puts(m, "\tprimary plane disabled\n");
 	for_each_encoder_on_crtc(dev, crtc, intel_encoder)
Signature · 6 lines
2.1.0

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

PATCH 3/10 drm/i915: Use the atomic state in intel_update_primary_planes.

In reply to Maarten Lankhorst

This function was still using the legacy state, convert it to atomic. While we're at it, fix the FIXME too and disable the primary plane.

---
 drivers/gpu/drm/i915/intel_display.c | 26 ++++++++++++--------------
 1 file changed, 12 insertions(+), 14 deletions(-)
drivers/gpu/drm/i915/intel_display.c +12 -14
index 33200403a5db..b68aa95c5460 100644
@@ -3138,24 +3138,22 @@ static void intel_complete_page_flips(struct drm_device *dev)
 
 static void intel_update_primary_planes(struct drm_device *dev)
 {
-	struct drm_i915_private *dev_priv = dev->dev_private;
 	struct drm_crtc *crtc;
 
 	for_each_crtc(dev, crtc) {
-		struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
+		struct intel_plane *plane = to_intel_plane(crtc->primary);
+		struct intel_plane_state *plane_state;
 
-		drm_modeset_lock(&crtc->mutex, NULL);
-		/*
-		 * FIXME: Once we have proper support for primary planes (and
-		 * disabling them without disabling the entire crtc) allow again
-		 * a NULL crtc->primary->fb.
-		 */
-		if (intel_crtc->active && crtc->primary->fb)
-			dev_priv->display.update_primary_plane(crtc,
-							       crtc->primary->fb,
-							       crtc->x,
-							       crtc->y);
-		drm_modeset_unlock(&crtc->mutex);
+		drm_modeset_lock_crtc(crtc, &plane->base);
+
+		plane_state = to_intel_plane_state(plane->base.state);
+
+		if (plane_state->base.fb)
+			plane->commit_plane(&plane->base, plane_state);
+		else if (crtc->state->active)
+			plane->disable_plane(&plane->base, crtc);
+
+		drm_modeset_unlock_crtc(crtc);
 	}
 }
 
Signature · 6 lines
2.1.0

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

Re: [PATCH 03/10] drm/i915: Use the atomic state in intel_update_primary_planes.

Quoted 20 lines · Maarten Lankhorst

This function was still using the legacy state, convert it to atomic. While we're at it, fix the FIXME too and disable the primary plane.

---
 drivers/gpu/drm/i915/intel_display.c | 26 ++++++++++++--------------
 1 file changed, 12 insertions(+), 14 deletions(-)
drivers/gpu/drm/i915/intel_display.c +0 -1
index 33200403a5db..b68aa95c5460 100644
@@ -3138,24 +3138,22 @@ static void intel_complete_page_flips(struct drm_device *dev)
 
 static void intel_update_primary_planes(struct drm_device *dev)
 {
-	struct drm_i915_private *dev_priv = dev->dev_private;
 	struct drm_crtc *crtc;
 
 	for_each_crtc(dev, crtc) {

drivers/gpu/drm/i915/intel_display.c static void intel_complete_page_flips(struct drm_device *dev) · line 3152

Quoted 10 lines
drivers/gpu/drm/i915/intel_display.c +2 -7
-		struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
+		struct intel_plane *plane = to_intel_plane(crtc->primary);
+		struct intel_plane_state *plane_state;
 
-		drm_modeset_lock(&crtc->mutex, NULL);
-		/*
-		 * FIXME: Once we have proper support for primary planes (and
-		 * disabling them without disabling the entire crtc) allow again
-		 * a NULL crtc->primary->fb.
-		 */

We probably should have a new FIXME here to ditch this all once we use atomic for legacy page_flips (since the only reason we have this is when CS flips are lost in the reset).
-Daniel

Quoted 26 lines
drivers/gpu/drm/i915/intel_display.c +10 -6
-		if (intel_crtc->active && crtc->primary->fb)
-			dev_priv->display.update_primary_plane(crtc,
-							       crtc->primary->fb,
-							       crtc->x,
-							       crtc->y);
-		drm_modeset_unlock(&crtc->mutex);
+		drm_modeset_lock_crtc(crtc, &plane->base);
+
+		plane_state = to_intel_plane_state(plane->base.state);
+
+		if (plane_state->base.fb)
+			plane->commit_plane(&plane->base, plane_state);
+		else if (crtc->state->active)
+			plane->disable_plane(&plane->base, crtc);
+
+		drm_modeset_unlock_crtc(crtc);
 	}
 }
 
Signature · 6 lines
2.1.0

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#10 lore raw

Re: [PATCH 03/10] drm/i915: Use the atomic state in intel_update_primary_planes.

In reply to Maarten Lankhorst
Quoted 34 lines · Maarten Lankhorst

This function was still using the legacy state, convert it to atomic. While we're at it, fix the FIXME too and disable the primary plane.

---
 drivers/gpu/drm/i915/intel_display.c | 26 ++++++++++++--------------
 1 file changed, 12 insertions(+), 14 deletions(-)
drivers/gpu/drm/i915/intel_display.c +2 -12
index 33200403a5db..b68aa95c5460 100644
@@ -3138,24 +3138,22 @@ static void intel_complete_page_flips(struct drm_device *dev)
 
 static void intel_update_primary_planes(struct drm_device *dev)
 {
-	struct drm_i915_private *dev_priv = dev->dev_private;
 	struct drm_crtc *crtc;
 
 	for_each_crtc(dev, crtc) {
-		struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
+		struct intel_plane *plane = to_intel_plane(crtc->primary);
+		struct intel_plane_state *plane_state;
 
-		drm_modeset_lock(&crtc->mutex, NULL);
-		/*
-		 * FIXME: Once we have proper support for primary planes (and
-		 * disabling them without disabling the entire crtc) allow again
-		 * a NULL crtc->primary->fb.
-		 */
-		if (intel_crtc->active && crtc->primary->fb)
-			dev_priv->display.update_primary_plane(crtc,
-							       crtc->primary->fb,
-							       crtc->x,

drivers/gpu/drm/i915/intel_display.c static void intel_complete_page_flips(struct drm_device *dev) · line 3154

Quoted 10 lines
drivers/gpu/drm/i915/intel_display.c +8 -2
-							       crtc->y);
-		drm_modeset_unlock(&crtc->mutex);
+		drm_modeset_lock_crtc(crtc, &plane->base);
+
+		plane_state = to_intel_plane_state(plane->base.state);
+
+		if (plane_state->base.fb)
+			plane->commit_plane(&plane->base, plane_state);
+		else if (crtc->state->active)
+			plane->disable_plane(&plane->base, crtc);

That doesn't make sense. There's no way to disable a plane with a page flip, so there's simply nothing to do here if the fb is NULL. If we can trust the plane state to be sane we should just check 'visible' here and commit the plane in that case.

Quoted 12 lines
drivers/gpu/drm/i915/intel_display.c +2 -0
+
+		drm_modeset_unlock_crtc(crtc);
 	}
 }
 
Signature · 6 lines
2.1.0

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 6 lines
Ville Syrjälä
Intel OTC
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#11 lore raw

Re: [PATCH 03/10] drm/i915: Use the atomic state in intel_update_primary_planes.

Quoted 42 lines · Ville Syrjälä
Quoted 41 lines · Maarten Lankhorst

This function was still using the legacy state, convert it to atomic. While we're at it, fix the FIXME too and disable the primary plane.

---
 drivers/gpu/drm/i915/intel_display.c | 26 ++++++++++++--------------
 1 file changed, 12 insertions(+), 14 deletions(-)
drivers/gpu/drm/i915/intel_display.c +7 -14
index 33200403a5db..b68aa95c5460 100644
@@ -3138,24 +3138,22 @@ static void intel_complete_page_flips(struct drm_device *dev)
 
 static void intel_update_primary_planes(struct drm_device *dev)
 {
-	struct drm_i915_private *dev_priv = dev->dev_private;
 	struct drm_crtc *crtc;
 
 	for_each_crtc(dev, crtc) {
-		struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
+		struct intel_plane *plane = to_intel_plane(crtc->primary);
+		struct intel_plane_state *plane_state;
 
-		drm_modeset_lock(&crtc->mutex, NULL);
-		/*
-		 * FIXME: Once we have proper support for primary planes (and
-		 * disabling them without disabling the entire crtc) allow again
-		 * a NULL crtc->primary->fb.
-		 */
-		if (intel_crtc->active && crtc->primary->fb)
-			dev_priv->display.update_primary_plane(crtc,
-							       crtc->primary->fb,
-							       crtc->x,
-							       crtc->y);
-		drm_modeset_unlock(&crtc->mutex);
+		drm_modeset_lock_crtc(crtc, &plane->base);
+
+		plane_state = to_intel_plane_state(plane->base.state);
+
+		if (plane_state->base.fb)
Quoted 8 lines

drivers/gpu/drm/i915/intel_display.c static void intel_complete_page_flips(struct drm_device *dev) · line 3154

Quoted 3 lines
drivers/gpu/drm/i915/intel_display.c +3 -0
+			plane->commit_plane(&plane->base, plane_state);
+		else if (crtc->state->active)
+			plane->disable_plane(&plane->base, crtc);

That doesn't make sense. There's no way to disable a plane with a page flip, so there's simply nothing to do here if the fb is NULL. If we can trust the plane state to be sane we should just check 'visible' here and commit the plane in that case.

Right missed that and squash up a fixup that Ville acked on irc. Also added the FIXME comment too.
-Daniel

Quoted 21 lines
Quoted 13 lines
drivers/gpu/drm/i915/intel_display.c +2 -0
+
+		drm_modeset_unlock_crtc(crtc);
 	}
 }
 
Signature · 6 lines
2.1.0

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 6 lines
Ville Syrjälä
Intel OTC
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#12 lore raw

Re: [PATCH 03/10] drm/i915: Use the atomic state in intel_update_primary_planes.

Quoted 52 lines · Daniel Vetter
Quoted 42 lines · Ville Syrjälä
Quoted 41 lines · Maarten Lankhorst

This function was still using the legacy state, convert it to atomic. While we're at it, fix the FIXME too and disable the primary plane.

---
 drivers/gpu/drm/i915/intel_display.c | 26 ++++++++++++--------------
 1 file changed, 12 insertions(+), 14 deletions(-)
drivers/gpu/drm/i915/intel_display.c +7 -14
index 33200403a5db..b68aa95c5460 100644
@@ -3138,24 +3138,22 @@ static void intel_complete_page_flips(struct drm_device *dev)
 
 static void intel_update_primary_planes(struct drm_device *dev)
 {
-	struct drm_i915_private *dev_priv = dev->dev_private;
 	struct drm_crtc *crtc;
 
 	for_each_crtc(dev, crtc) {
-		struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
+		struct intel_plane *plane = to_intel_plane(crtc->primary);
+		struct intel_plane_state *plane_state;
 
-		drm_modeset_lock(&crtc->mutex, NULL);
-		/*
-		 * FIXME: Once we have proper support for primary planes (and
-		 * disabling them without disabling the entire crtc) allow again
-		 * a NULL crtc->primary->fb.
-		 */
-		if (intel_crtc->active && crtc->primary->fb)
-			dev_priv->display.update_primary_plane(crtc,
-							       crtc->primary->fb,
-							       crtc->x,
-							       crtc->y);
-		drm_modeset_unlock(&crtc->mutex);
+		drm_modeset_lock_crtc(crtc, &plane->base);
+
+		plane_state = to_intel_plane_state(plane->base.state);
+
+		if (plane_state->base.fb)
Quoted 8 lines

drivers/gpu/drm/i915/intel_display.c static void intel_complete_page_flips(struct drm_device *dev) · line 3154

Quoted 3 lines
drivers/gpu/drm/i915/intel_display.c +3 -0
+			plane->commit_plane(&plane->base, plane_state);
+		else if (crtc->state->active)
+			plane->disable_plane(&plane->base, crtc);

That doesn't make sense. There's no way to disable a plane with a page flip, so there's simply nothing to do here if the fb is NULL. If we can trust the plane state to be sane we should just check 'visible' here and commit the plane in that case.

Quoted 2 lines

Right missed that and squash up a fixup that Ville acked on irc. Also added the FIXME comment too.

Actually I take it back. We just lost the ->active check entirely so now we're commiting a plane on a disabled pipe potentially.

Quoted 28 lines

-Daniel

Quoted 21 lines
Quoted 13 lines
drivers/gpu/drm/i915/intel_display.c +2 -0
+
+		drm_modeset_unlock_crtc(crtc);
 	}
 }
 
Signature · 6 lines
2.1.0

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 6 lines
Ville Syrjälä
Intel OTC
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 3 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
Signature · 6 lines
Ville Syrjälä
Intel OTC
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#13 lore raw

Re: [PATCH 03/10] drm/i915: Use the atomic state in intel_update_primary_planes.

Quoted 53 lines · Ville Syrjälä
Quoted 52 lines · Daniel Vetter
Quoted 50 lines · Ville Syrjälä
Quoted 34 lines · Maarten Lankhorst

This function was still using the legacy state, convert it to atomic. While we're at it, fix the FIXME too and disable the primary plane.

---
 drivers/gpu/drm/i915/intel_display.c | 26 ++++++++++++--------------
 1 file changed, 12 insertions(+), 14 deletions(-)
drivers/gpu/drm/i915/intel_display.c +2 -12
index 33200403a5db..b68aa95c5460 100644
@@ -3138,24 +3138,22 @@ static void intel_complete_page_flips(struct drm_device *dev)
 
 static void intel_update_primary_planes(struct drm_device *dev)
 {
-	struct drm_i915_private *dev_priv = dev->dev_private;
 	struct drm_crtc *crtc;
 
 	for_each_crtc(dev, crtc) {
-		struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
+		struct intel_plane *plane = to_intel_plane(crtc->primary);
+		struct intel_plane_state *plane_state;
 
-		drm_modeset_lock(&crtc->mutex, NULL);
-		/*
-		 * FIXME: Once we have proper support for primary planes (and
-		 * disabling them without disabling the entire crtc) allow again
-		 * a NULL crtc->primary->fb.
-		 */
-		if (intel_crtc->active && crtc->primary->fb)
-			dev_priv->display.update_primary_plane(crtc,
-							       crtc->primary->fb,
-							       crtc->x,

drivers/gpu/drm/i915/intel_display.c static void intel_complete_page_flips(struct drm_device *dev) · line 3154

Quoted 10 lines
drivers/gpu/drm/i915/intel_display.c +8 -2
-							       crtc->y);
-		drm_modeset_unlock(&crtc->mutex);
+		drm_modeset_lock_crtc(crtc, &plane->base);
+
+		plane_state = to_intel_plane_state(plane->base.state);
+
+		if (plane_state->base.fb)
+			plane->commit_plane(&plane->base, plane_state);
+		else if (crtc->state->active)
+			plane->disable_plane(&plane->base, crtc);

That doesn't make sense. There's no way to disable a plane with a page flip, so there's simply nothing to do here if the fb is NULL. If we can trust the plane state to be sane we should just check 'visible' here and commit the plane in that case.

Quoted 5 lines
Quoted 2 lines

Right missed that and squash up a fixup that Ville acked on irc. Also added the FIXME comment too.

Actually I take it back. We just lost the ->active check entirely so now we're commiting a plane on a disabled pipe potentially.

Blergh and I tagged the pile already :( Maarten, can you pls send out the fixup as a separate patch asap?

Thanks, Daniel

Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#14 lore raw

PATCH 1/1 drm/i915: Only commit active planes when updating planes during reset.

In a future commit commit_plane will no longer check if the crtc is active. To prevent issues with legacy page flips the check should be performed inside update_primary_planes.

----

Hey,

Op 14-09-15 om 11:02 schreef Daniel Vetter:

Quoted 52 lines · Ville Syrjälä
Quoted 51 lines · Daniel Vetter
Quoted 50 lines · Ville Syrjälä
Quoted 49 lines · Maarten Lankhorst
Quoted 34 lines

This function was still using the legacy state, convert it to atomic. While we're at it, fix the FIXME too and disable the primary plane.

---
 drivers/gpu/drm/i915/intel_display.c | 26 ++++++++++++--------------
 1 file changed, 12 insertions(+), 14 deletions(-)
drivers/gpu/drm/i915/intel_display.c +2 -12
index 33200403a5db..b68aa95c5460 100644
@@ -3138,24 +3138,22 @@ static void intel_complete_page_flips(struct drm_device *dev)
 
 static void intel_update_primary_planes(struct drm_device *dev)
 {
-	struct drm_i915_private *dev_priv = dev->dev_private;
 	struct drm_crtc *crtc;
 
 	for_each_crtc(dev, crtc) {
-		struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
+		struct intel_plane *plane = to_intel_plane(crtc->primary);
+		struct intel_plane_state *plane_state;
 
-		drm_modeset_lock(&crtc->mutex, NULL);
-		/*
-		 * FIXME: Once we have proper support for primary planes (and
-		 * disabling them without disabling the entire crtc) allow again
-		 * a NULL crtc->primary->fb.
-		 */
-		if (intel_crtc->active && crtc->primary->fb)
-			dev_priv->display.update_primary_plane(crtc,
-							       crtc->primary->fb,
-							       crtc->x,

drivers/gpu/drm/i915/intel_display.c static void intel_complete_page_flips(struct drm_device *dev) · line 3154

Quoted 10 lines
drivers/gpu/drm/i915/intel_display.c +8 -2
-							       crtc->y);
-		drm_modeset_unlock(&crtc->mutex);
+		drm_modeset_lock_crtc(crtc, &plane->base);
+
+		plane_state = to_intel_plane_state(plane->base.state);
+
+		if (plane_state->base.fb)
+			plane->commit_plane(&plane->base, plane_state);
+		else if (crtc->state->active)
+			plane->disable_plane(&plane->base, crtc);

That doesn't make sense. There's no way to disable a plane with a page flip, so there's simply nothing to do here if the fb is NULL. If we can trust the plane state to be sane we should just check 'visible' here and commit the plane in that case.

Quoted 7 lines
Quoted 4 lines
Quoted 2 lines

Right missed that and squash up a fixup that Ville acked on irc. Also added the FIXME comment too.

Actually I take it back. We just lost the ->active check entirely so now we're commiting a plane on a disabled pipe potentially.

Blergh and I tagged the pile already :( Maarten, can you pls send out the fixup as a separate patch asap?

This is not currently an issue because "drm/i915: Only run commit when crtc is active.' is not applied.

Thanks for catching though!
---

drivers/gpu/drm/i915/intel_display.c +1 -2
index 452e8f77151d..47d9c0f8b2fb 100644
@@ -3145,10 +3145,9 @@ static void intel_update_primary_planes(struct drm_device *dev)
 		struct intel_plane_state *plane_state;
 
 		drm_modeset_lock_crtc(crtc, &plane->base);
-
 		plane_state = to_intel_plane_state(plane->base.state);
 
-		if (plane_state->base.fb)
+		if (crtc->state->active && plane_state->base.fb)
 			plane->commit_plane(&plane->base, plane_state);
 
 		drm_modeset_unlock_crtc(crtc);

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

#15 lore raw

Re: [fixup PATCH] drm/i915: Only commit active planes when updating planes during reset.

Quoted 64 lines · Maarten Lankhorst

In a future commit commit_plane will no longer check if the crtc is active. To prevent issues with legacy page flips the check should be performed inside update_primary_planes.

----

Hey,

Op 14-09-15 om 11:02 schreef Daniel Vetter:

Quoted 54 lines · Ville Syrjälä
Quoted 53 lines · Daniel Vetter
Quoted 52 lines · Ville Syrjälä
Quoted 41 lines · Maarten Lankhorst
Quoted 40 lines

This function was still using the legacy state, convert it to atomic. While we're at it, fix the FIXME too and disable the primary plane.

---
 drivers/gpu/drm/i915/intel_display.c | 26 ++++++++++++--------------
 1 file changed, 12 insertions(+), 14 deletions(-)
drivers/gpu/drm/i915/intel_display.c +6 -14
index 33200403a5db..b68aa95c5460 100644
@@ -3138,24 +3138,22 @@ static void intel_complete_page_flips(struct drm_device *dev)
 
 static void intel_update_primary_planes(struct drm_device *dev)
 {
-	struct drm_i915_private *dev_priv = dev->dev_private;
 	struct drm_crtc *crtc;
 
 	for_each_crtc(dev, crtc) {
-		struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
+		struct intel_plane *plane = to_intel_plane(crtc->primary);
+		struct intel_plane_state *plane_state;
 
-		drm_modeset_lock(&crtc->mutex, NULL);
-		/*
-		 * FIXME: Once we have proper support for primary planes (and
-		 * disabling them without disabling the entire crtc) allow again
-		 * a NULL crtc->primary->fb.
-		 */
-		if (intel_crtc->active && crtc->primary->fb)
-			dev_priv->display.update_primary_plane(crtc,
-							       crtc->primary->fb,
-							       crtc->x,
-							       crtc->y);
-		drm_modeset_unlock(&crtc->mutex);
+		drm_modeset_lock_crtc(crtc, &plane->base);
+
+		plane_state = to_intel_plane_state(plane->base.state);
+
Quoted 8 lines

drivers/gpu/drm/i915/intel_display.c static void intel_complete_page_flips(struct drm_device *dev) · line 3154

Quoted 4 lines
drivers/gpu/drm/i915/intel_display.c +4 -0
+		if (plane_state->base.fb)
+			plane->commit_plane(&plane->base, plane_state);
+		else if (crtc->state->active)
+			plane->disable_plane(&plane->base, crtc);

That doesn't make sense. There's no way to disable a plane with a page flip, so there's simply nothing to do here if the fb is NULL. If we can trust the plane state to be sane we should just check 'visible' here and commit the plane in that case.

Right missed that and squash up a fixup that Ville acked on irc. Also added the FIXME comment too.

Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

Actually I take it back. We just lost the ->active check entirely so now we're commiting a plane on a disabled pipe potentially.

Blergh and I tagged the pile already :( Maarten, can you pls send out the fixup as a separate patch asap?

This is not currently an issue because "drm/i915: Only run commit when crtc is active.' is not applied.

Thanks for catching though!

I Meant a full patch (including commit citation and sob and all taht) since I already tagged it and can't squash in any more. -Daniel

Quoted 18 lines

---

drivers/gpu/drm/i915/intel_display.c +1 -2
index 452e8f77151d..47d9c0f8b2fb 100644
@@ -3145,10 +3145,9 @@ static void intel_update_primary_planes(struct drm_device *dev)
 		struct intel_plane_state *plane_state;
 
 		drm_modeset_lock_crtc(crtc, &plane->base);
-
 		plane_state = to_intel_plane_state(plane->base.state);
 
-		if (plane_state->base.fb)
+		if (crtc->state->active && plane_state->base.fb)
 			plane->commit_plane(&plane->base, plane_state);
 
 		drm_modeset_unlock_crtc(crtc);
Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#16 lore raw

PATCH 4/10 drm/i915: Use atomic state when changing cursor visibility.

In reply to Maarten Lankhorst
---
 drivers/gpu/drm/i915/intel_display.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)
drivers/gpu/drm/i915/intel_display.c +7 -6
index b68aa95c5460..bad22cb828c0 100644
@@ -9926,8 +9926,9 @@ static void intel_crtc_update_cursor(struct drm_crtc *crtc,
 	struct drm_i915_private *dev_priv = dev->dev_private;
 	struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
 	int pipe = intel_crtc->pipe;
-	int x = crtc->cursor_x;
-	int y = crtc->cursor_y;
+	struct drm_plane_state *cursor_state = crtc->cursor->state;
+	int x = cursor_state->crtc_x;
+	int y = cursor_state->crtc_y;
 	u32 base = 0, pos = 0;
 
 	if (on)
@@ -9940,7 +9941,7 @@ static void intel_crtc_update_cursor(struct drm_crtc *crtc,
 		base = 0;
 
 	if (x < 0) {
-		if (x + intel_crtc->base.cursor->state->crtc_w <= 0)
+		if (x + cursor_state->crtc_w <= 0)
 			base = 0;
 
 		pos |= CURSOR_POS_SIGN << CURSOR_X_SHIFT;
@@ -9949,7 +9950,7 @@ static void intel_crtc_update_cursor(struct drm_crtc *crtc,
 	pos |= x << CURSOR_X_SHIFT;
 
 	if (y < 0) {
-		if (y + intel_crtc->base.cursor->state->crtc_h <= 0)
+		if (y + cursor_state->crtc_h <= 0)
 			base = 0;
 
 		pos |= CURSOR_POS_SIGN << CURSOR_Y_SHIFT;
@@ -9965,8 +9966,8 @@ static void intel_crtc_update_cursor(struct drm_crtc *crtc,
 	/* ILK+ do this automagically */
 	if (HAS_GMCH_DISPLAY(dev) &&
 	    crtc->cursor->state->rotation == BIT(DRM_ROTATE_180)) {
-		base += (intel_crtc->base.cursor->state->crtc_h *
-			intel_crtc->base.cursor->state->crtc_w - 1) * 4;
+		base += (cursor_state->crtc_h *
+			 cursor_state->crtc_w - 1) * 4;
 	}
 
 	if (IS_845G(dev) || IS_I865G(dev))
Signature · 6 lines
2.1.0

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

Re: [PATCH 04/10] drm/i915: Use atomic state when changing cursor visibility.

Quoted 31 lines · Maarten Lankhorst
---
 drivers/gpu/drm/i915/intel_display.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)
drivers/gpu/drm/i915/intel_display.c +4 -3
index b68aa95c5460..bad22cb828c0 100644
@@ -9926,8 +9926,9 @@ static void intel_crtc_update_cursor(struct drm_crtc *crtc,
 	struct drm_i915_private *dev_priv = dev->dev_private;
 	struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
 	int pipe = intel_crtc->pipe;
-	int x = crtc->cursor_x;
-	int y = crtc->cursor_y;
+	struct drm_plane_state *cursor_state = crtc->cursor->state;
+	int x = cursor_state->crtc_x;
+	int y = cursor_state->crtc_y;
 	u32 base = 0, pos = 0;
 
 	if (on)
@@ -9940,7 +9941,7 @@ static void intel_crtc_update_cursor(struct drm_crtc *crtc,
 		base = 0;
 
 	if (x < 0) {
-		if (x + intel_crtc->base.cursor->state->crtc_w <= 0)
+		if (x + cursor_state->crtc_w <= 0)
 			base = 0;
 
 		pos |= CURSOR_POS_SIGN << CURSOR_X_SHIFT;

drivers/gpu/drm/i915/intel_display.c static void intel_crtc_update_cursor(struct drm_crtc *crtc, · line 9954

Quoted 6 lines
drivers/gpu/drm/i915/intel_display.c +1 -1
@@ -9949,7 +9950,7 @@ static void intel_crtc_update_cursor(struct drm_crtc *crtc,
 	pos |= x << CURSOR_X_SHIFT;
 
 	if (y < 0) {
-		if (y + intel_crtc->base.cursor->state->crtc_h <= 0)
+		if (y + cursor_state->crtc_h <= 0)
 			base = 0;

This whole stuff should be ripped out, and instead we should make sure the plane state is sane (ie. 'visible' is set when the cursor must be visible, and not set when the cursor must not be visible).

Quoted 20 lines
drivers/gpu/drm/i915/intel_display.c +2 -2
 		pos |= CURSOR_POS_SIGN << CURSOR_Y_SHIFT;
@@ -9965,8 +9966,8 @@ static void intel_crtc_update_cursor(struct drm_crtc *crtc,
 	/* ILK+ do this automagically */
 	if (HAS_GMCH_DISPLAY(dev) &&
 	    crtc->cursor->state->rotation == BIT(DRM_ROTATE_180)) {
-		base += (intel_crtc->base.cursor->state->crtc_h *
-			intel_crtc->base.cursor->state->crtc_w - 1) * 4;
+		base += (cursor_state->crtc_h *
+			 cursor_state->crtc_w - 1) * 4;
 	}
 
 	if (IS_845G(dev) || IS_I865G(dev))
Signature · 6 lines
2.1.0

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 6 lines
Ville Syrjälä
Intel OTC
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#18 lore raw

PATCH 5/10 drm/i915: Remove legacy plane updates for cursor and sprite planes.

In reply to Maarten Lankhorst

Unfortunately fbc still depends on legacy primary state, so it can't be killed off completely yet.

---
 drivers/gpu/drm/i915/intel_display.c | 4 ----
 drivers/gpu/drm/i915/intel_sprite.c  | 2 --
 2 files changed, 6 deletions(-)
drivers/gpu/drm/i915/intel_display.c +0 -4
index bad22cb828c0..87c5eba08454 100644
@@ -13662,10 +13662,6 @@ intel_commit_cursor_plane(struct drm_plane *plane,
 	crtc = crtc ? crtc : plane->crtc;
 	intel_crtc = to_intel_crtc(crtc);
 
-	plane->fb = state->base.fb;
-	crtc->cursor_x = state->base.crtc_x;
-	crtc->cursor_y = state->base.crtc_y;
-
 	if (intel_crtc->cursor_bo == obj)
 		goto update;
 
drivers/gpu/drm/i915/intel_sprite.c +0 -2
index ca7e26430e66..9553859ca151 100644
@@ -927,8 +927,6 @@ intel_commit_sprite_plane(struct drm_plane *plane,
 
 	crtc = crtc ? crtc : plane->crtc;
 
-	plane->fb = fb;
-
 	if (!crtc->state->active)
 		return;
 
Signature · 6 lines
2.1.0

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

Re: [PATCH 05/10] drm/i915: Remove legacy plane updates for cursor and sprite planes.

Quoted 4 lines · Maarten Lankhorst

Unfortunately fbc still depends on legacy primary state, so it can't be killed off completely yet.

Wont it be enough that the helpers will update these legacy states for us? And I didn't spot anything else really using them ...

What I did spot though is update_state_fb - the core should take care of that now too for us since

commit 3cb43cc0b408c4672ba94fe28406a90a94b1edfe

Author: Daniel Vetter <[email protected]>
Date:   Tue Jul 7 08:43:03 2015 +0200
    drm: Update plane->fb also for page_flip

Can you please have a testcase on top to remove this one too? -Daniel

Quoted 40 lines
---
 drivers/gpu/drm/i915/intel_display.c | 4 ----
 drivers/gpu/drm/i915/intel_sprite.c  | 2 --
 2 files changed, 6 deletions(-)
drivers/gpu/drm/i915/intel_display.c +0 -4
index bad22cb828c0..87c5eba08454 100644
@@ -13662,10 +13662,6 @@ intel_commit_cursor_plane(struct drm_plane *plane,
 	crtc = crtc ? crtc : plane->crtc;
 	intel_crtc = to_intel_crtc(crtc);
 
-	plane->fb = state->base.fb;
-	crtc->cursor_x = state->base.crtc_x;
-	crtc->cursor_y = state->base.crtc_y;
-
 	if (intel_crtc->cursor_bo == obj)
 		goto update;
 
drivers/gpu/drm/i915/intel_sprite.c +0 -2
index ca7e26430e66..9553859ca151 100644
@@ -927,8 +927,6 @@ intel_commit_sprite_plane(struct drm_plane *plane,
 
 	crtc = crtc ? crtc : plane->crtc;
 
-	plane->fb = fb;
-
 	if (!crtc->state->active)
 		return;
 
Signature · 6 lines
2.1.0

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#20 lore raw

PATCH 6/10 drm/i915: Update legacy primary state outside the commit hook.

In reply to Maarten Lankhorst

This should allow not running plane commit when the crtc is off. While the atomic helpers update those, crtc->x/y is only updated during modesets, and primary plane is updated after this function returns.

Unfortunately non-atomic watermarks and fbc still depend on this state inside i915, so it has to be kept in sync.

---
 drivers/gpu/drm/i915/intel_display.c | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)
drivers/gpu/drm/i915/intel_display.c +8 -7
index 87c5eba08454..b809ee2a8678 100644
@@ -12198,6 +12198,14 @@ intel_modeset_update_crtc_state(struct drm_atomic_state *state)
 			crtc->hwmode = crtc->state->adjusted_mode;
 		else
 			crtc->hwmode.crtc_clock = 0;
+
+		if (drm_atomic_get_existing_plane_state(state, crtc->primary)) {
+			struct drm_plane_state *plane_state = crtc->primary->state;
+
+			crtc->primary->fb = plane_state->fb;
+			crtc->x = plane_state->src_x >> 16;
+			crtc->y = plane_state->src_y >> 16;
+		}
 	}
 }
 
@@ -13434,15 +13442,8 @@ intel_commit_primary_plane(struct drm_plane *plane,
 	struct drm_framebuffer *fb = state->base.fb;
 	struct drm_device *dev = plane->dev;
 	struct drm_i915_private *dev_priv = dev->dev_private;
-	struct intel_crtc *intel_crtc;
-	struct drm_rect *src = &state->src;
 
 	crtc = crtc ? crtc : plane->crtc;
-	intel_crtc = to_intel_crtc(crtc);
-
-	plane->fb = fb;
-	crtc->x = src->x1 >> 16;
-	crtc->y = src->y1 >> 16;
 
 	if (!crtc->state->active)
 		return;
Signature · 6 lines
2.1.0

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

Re: [PATCH 06/10] drm/i915: Update legacy primary state outside the commit hook.

Quoted 19 lines · Maarten Lankhorst

This should allow not running plane commit when the crtc is off. While the atomic helpers update those, crtc->x/y is only updated during modesets, and primary plane is updated after this function returns.

Unfortunately non-atomic watermarks and fbc still depend on this state inside i915, so it has to be kept in sync.

---
 drivers/gpu/drm/i915/intel_display.c | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)
drivers/gpu/drm/i915/intel_display.c +0 -0
index 87c5eba08454..b809ee2a8678 100644
@@ -12198,6 +12198,14 @@ intel_modeset_update_crtc_state(struct drm_atomic_state *state)
 			crtc->hwmode = crtc->state->adjusted_mode;

drivers/gpu/drm/i915/intel_display.c intel_modeset_update_crtc_state(struct drm_atomic_state *state) · line 12208

Quoted 10 lines
drivers/gpu/drm/i915/intel_display.c +8 -0
 		else
 			crtc->hwmode.crtc_clock = 0;
+
+		if (drm_atomic_get_existing_plane_state(state, crtc->primary)) {
+			struct drm_plane_state *plane_state = crtc->primary->state;
+
+			crtc->primary->fb = plane_state->fb;
+			crtc->x = plane_state->src_x >> 16;
+			crtc->y = plane_state->src_y >> 16;
+		}

drm_atomic_helper_update_legacy_modeset_state should do that for us, not? Atm we have an if (any_ms) check for it, but that seems to just be a bug really.
-Daniel

Quoted 26 lines
drivers/gpu/drm/i915/intel_display.c +0 -7
 	}
 }
 
@@ -13434,15 +13442,8 @@ intel_commit_primary_plane(struct drm_plane *plane,
 	struct drm_framebuffer *fb = state->base.fb;
 	struct drm_device *dev = plane->dev;
 	struct drm_i915_private *dev_priv = dev->dev_private;
-	struct intel_crtc *intel_crtc;
-	struct drm_rect *src = &state->src;
 
 	crtc = crtc ? crtc : plane->crtc;
-	intel_crtc = to_intel_crtc(crtc);
-
-	plane->fb = fb;
-	crtc->x = src->x1 >> 16;
-	crtc->y = src->y1 >> 16;
 
 	if (!crtc->state->active)
 		return;
Signature · 6 lines
2.1.0

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#22 lore raw

Re: [PATCH 06/10] drm/i915: Update legacy primary state outside the commit hook.

Op 10-09-15 om 17:41 schreef Daniel Vetter:

Quoted 25 lines · Maarten Lankhorst
Quoted 24 lines

This should allow not running plane commit when the crtc is off. While the atomic helpers update those, crtc->x/y is only updated during modesets, and primary plane is updated after this function returns.

Unfortunately non-atomic watermarks and fbc still depend on this state inside i915, so it has to be kept in sync.

---
 drivers/gpu/drm/i915/intel_display.c | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)
drivers/gpu/drm/i915/intel_display.c +3 -0
index 87c5eba08454..b809ee2a8678 100644
@@ -12198,6 +12198,14 @@ intel_modeset_update_crtc_state(struct drm_atomic_state *state)
 			crtc->hwmode = crtc->state->adjusted_mode;
 		else
 			crtc->hwmode.crtc_clock = 0;
+
+		if (drm_atomic_get_existing_plane_state(state, crtc->primary)) {
+			struct drm_plane_state *plane_state = crtc->primary->state;
Quoted 8 lines

drivers/gpu/drm/i915/intel_display.c intel_modeset_update_crtc_state(struct drm_atomic_state *state) · line 12208

Quoted 5 lines
drivers/gpu/drm/i915/intel_display.c +5 -0
+
+			crtc->primary->fb = plane_state->fb;
+			crtc->x = plane_state->src_x >> 16;
+			crtc->y = plane_state->src_y >> 16;
+		}

drm_atomic_helper_update_legacy_modeset_state should do that for us, not? Atm we have an if (any_ms) check for it, but that seems to just be a bug really.

That function doesn't update primary->fb though. This is fixed up by the caller of drm_atomic_commit after the call succeeds. We need it sooner because update_fbc unfortunately still looks at the legacy state.

There are a few other users of the legacy state left in i915, but they should be more easy to convert than fbc.

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

#23 lore raw

Re: [PATCH 06/10] drm/i915: Update legacy primary state outside the commit hook.

Quoted 34 lines · Maarten Lankhorst

Op 10-09-15 om 17:41 schreef Daniel Vetter:

Quoted 25 lines · Maarten Lankhorst
Quoted 24 lines

This should allow not running plane commit when the crtc is off. While the atomic helpers update those, crtc->x/y is only updated during modesets, and primary plane is updated after this function returns.

Unfortunately non-atomic watermarks and fbc still depend on this state inside i915, so it has to be kept in sync.

---
 drivers/gpu/drm/i915/intel_display.c | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)
drivers/gpu/drm/i915/intel_display.c +3 -0
index 87c5eba08454..b809ee2a8678 100644
@@ -12198,6 +12198,14 @@ intel_modeset_update_crtc_state(struct drm_atomic_state *state)
 			crtc->hwmode = crtc->state->adjusted_mode;
 		else
 			crtc->hwmode.crtc_clock = 0;
+
+		if (drm_atomic_get_existing_plane_state(state, crtc->primary)) {
+			struct drm_plane_state *plane_state = crtc->primary->state;
Quoted 8 lines

drivers/gpu/drm/i915/intel_display.c intel_modeset_update_crtc_state(struct drm_atomic_state *state) · line 12208

Quoted 5 lines
drivers/gpu/drm/i915/intel_display.c +5 -0
+
+			crtc->primary->fb = plane_state->fb;
+			crtc->x = plane_state->src_x >> 16;
+			crtc->y = plane_state->src_y >> 16;
+		}

drm_atomic_helper_update_legacy_modeset_state should do that for us, not? Atm we have an if (any_ms) check for it, but that seems to just be a bug really.

Quoted 4 lines

That function doesn't update primary->fb though. This is fixed up by the caller of drm_atomic_commit after the call succeeds. We need it sooner because update_fbc unfortunately still looks at the legacy state.

There are a few other users of the legacy state left in i915, but they should be more easy to convert than fbc.

Hm, I tried looking really hard but didn't find anything that cared about plane->fb. Can you please point me at them?
-Daniel

Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#24 lore raw

Re: [PATCH 06/10] drm/i915: Update legacy primary state outside the commit hook.

Op 14-09-15 om 15:13 schreef Daniel Vetter:

Quoted 35 lines · Maarten Lankhorst
Quoted 34 lines

Op 10-09-15 om 17:41 schreef Daniel Vetter:

Quoted 33 lines · Maarten Lankhorst
Quoted 19 lines

This should allow not running plane commit when the crtc is off. While the atomic helpers update those, crtc->x/y is only updated during modesets, and primary plane is updated after this function returns.

Unfortunately non-atomic watermarks and fbc still depend on this state inside i915, so it has to be kept in sync.

---
 drivers/gpu/drm/i915/intel_display.c | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)
drivers/gpu/drm/i915/intel_display.c +0 -0
index 87c5eba08454..b809ee2a8678 100644
@@ -12198,6 +12198,14 @@ intel_modeset_update_crtc_state(struct drm_atomic_state *state)
 			crtc->hwmode = crtc->state->adjusted_mode;

drivers/gpu/drm/i915/intel_display.c intel_modeset_update_crtc_state(struct drm_atomic_state *state) · line 12208

Quoted 10 lines
drivers/gpu/drm/i915/intel_display.c +8 -0
 		else
 			crtc->hwmode.crtc_clock = 0;
+
+		if (drm_atomic_get_existing_plane_state(state, crtc->primary)) {
+			struct drm_plane_state *plane_state = crtc->primary->state;
+
+			crtc->primary->fb = plane_state->fb;
+			crtc->x = plane_state->src_x >> 16;
+			crtc->y = plane_state->src_y >> 16;
+		}

drm_atomic_helper_update_legacy_modeset_state should do that for us, not? Atm we have an if (any_ms) check for it, but that seems to just be a bug really.

Quoted 7 lines
Quoted 4 lines

That function doesn't update primary->fb though. This is fixed up by the caller of drm_atomic_commit after the call succeeds. We need it sooner because update_fbc unfortunately still looks at the legacy state.

There are a few other users of the legacy state left in i915, but they should be more easy to convert than fbc.

Hm, I tried looking really hard but didn't find anything that cared about plane->fb. Can you please point me at them?

Look for primary->fb. :-) Also crtc->y is used in __intel_fbc_update.

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

#25 lore raw

Re: [PATCH 06/10] drm/i915: Update legacy primary state outside the commit hook.

Quoted 36 lines · Maarten Lankhorst

Op 14-09-15 om 15:13 schreef Daniel Vetter:

Quoted 35 lines · Maarten Lankhorst
Quoted 34 lines

Op 10-09-15 om 17:41 schreef Daniel Vetter:

Quoted 33 lines · Maarten Lankhorst
Quoted 19 lines

This should allow not running plane commit when the crtc is off. While the atomic helpers update those, crtc->x/y is only updated during modesets, and primary plane is updated after this function returns.

Unfortunately non-atomic watermarks and fbc still depend on this state inside i915, so it has to be kept in sync.

---
 drivers/gpu/drm/i915/intel_display.c | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)
drivers/gpu/drm/i915/intel_display.c +0 -0
index 87c5eba08454..b809ee2a8678 100644
@@ -12198,6 +12198,14 @@ intel_modeset_update_crtc_state(struct drm_atomic_state *state)
 			crtc->hwmode = crtc->state->adjusted_mode;

drivers/gpu/drm/i915/intel_display.c intel_modeset_update_crtc_state(struct drm_atomic_state *state) · line 12208

Quoted 10 lines
drivers/gpu/drm/i915/intel_display.c +8 -0
 		else
 			crtc->hwmode.crtc_clock = 0;
+
+		if (drm_atomic_get_existing_plane_state(state, crtc->primary)) {
+			struct drm_plane_state *plane_state = crtc->primary->state;
+
+			crtc->primary->fb = plane_state->fb;
+			crtc->x = plane_state->src_x >> 16;
+			crtc->y = plane_state->src_y >> 16;
+		}

drm_atomic_helper_update_legacy_modeset_state should do that for us, not? Atm we have an if (any_ms) check for it, but that seems to just be a bug really.

Quoted 8 lines
Quoted 7 lines
Quoted 4 lines

That function doesn't update primary->fb though. This is fixed up by the caller of drm_atomic_commit after the call succeeds. We need it sooner because update_fbc unfortunately still looks at the legacy state.

There are a few other users of the legacy state left in i915, but they should be more easy to convert than fbc.

Hm, I tried looking really hard but didn't find anything that cared about plane->fb. Can you please point me at them?

Look for primary->fb. :-) Also crtc->y is used in __intel_fbc_update.

Well I did hunt for that but only found usage in crtc_disable functions (where we need the old value anyway) and flip code (which updates it itself). I did indeed somehow miss the fbc code. Oh well. Comment might be good for that.
-Daniel

Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#26 lore raw

Re: [PATCH 06/10] drm/i915: Update legacy primary state outside the commit hook.

Op 14-09-15 om 16:26 schreef Daniel Vetter:

Quoted 44 lines · Maarten Lankhorst
Quoted 43 lines

Op 14-09-15 om 15:13 schreef Daniel Vetter:

Quoted 42 lines · Maarten Lankhorst
Quoted 34 lines

Op 10-09-15 om 17:41 schreef Daniel Vetter:

Quoted 25 lines · Maarten Lankhorst
Quoted 24 lines

This should allow not running plane commit when the crtc is off. While the atomic helpers update those, crtc->x/y is only updated during modesets, and primary plane is updated after this function returns.

Unfortunately non-atomic watermarks and fbc still depend on this state inside i915, so it has to be kept in sync.

---
 drivers/gpu/drm/i915/intel_display.c | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)
drivers/gpu/drm/i915/intel_display.c +3 -0
index 87c5eba08454..b809ee2a8678 100644
@@ -12198,6 +12198,14 @@ intel_modeset_update_crtc_state(struct drm_atomic_state *state)
 			crtc->hwmode = crtc->state->adjusted_mode;
 		else
 			crtc->hwmode.crtc_clock = 0;
+
+		if (drm_atomic_get_existing_plane_state(state, crtc->primary)) {
+			struct drm_plane_state *plane_state = crtc->primary->state;
Quoted 8 lines

drivers/gpu/drm/i915/intel_display.c intel_modeset_update_crtc_state(struct drm_atomic_state *state) · line 12208

Quoted 5 lines
drivers/gpu/drm/i915/intel_display.c +5 -0
+
+			crtc->primary->fb = plane_state->fb;
+			crtc->x = plane_state->src_x >> 16;
+			crtc->y = plane_state->src_y >> 16;
+		}

drm_atomic_helper_update_legacy_modeset_state should do that for us, not? Atm we have an if (any_ms) check for it, but that seems to just be a bug really.

Quoted 4 lines

That function doesn't update primary->fb though. This is fixed up by the caller of drm_atomic_commit after the call succeeds. We need it sooner because update_fbc unfortunately still looks at the legacy state.

There are a few other users of the legacy state left in i915, but they should be more easy to convert than fbc.

Hm, I tried looking really hard but didn't find anything that cared about plane->fb. Can you please point me at them?

Quoted 6 lines
Quoted 1 line

Look for primary->fb. :-) Also crtc->y is used in __intel_fbc_update.

Well I did hunt for that but only found usage in crtc_disable functions (where we need the old value anyway) and flip code (which updates it itself). I did indeed somehow miss the fbc code. Oh well. Comment might be good for that.
-Daniel

Ok, I will resend the remaining patches from this series and this one with the comment added.
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

#27 lore raw

PATCH 7/10 drm/i915: Do not handle a null plane state.

In reply to Maarten Lankhorst

With the conversion to atomic this cannot happen any more.

---
 drivers/gpu/drm/i915/intel_atomic_plane.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)
drivers/gpu/drm/i915/intel_atomic_plane.c +1 -5
index f1ab8e4b9c11..a11980696595 100644
@@ -76,11 +76,7 @@ intel_plane_duplicate_state(struct drm_plane *plane)
 	struct drm_plane_state *state;
 	struct intel_plane_state *intel_state;
 
-	if (WARN_ON(!plane->state))
-		intel_state = intel_create_plane_state(plane);
-	else
-		intel_state = kmemdup(plane->state, sizeof(*intel_state),
-				      GFP_KERNEL);
+	intel_state = kmemdup(plane->state, sizeof(*intel_state), GFP_KERNEL);
 
 	if (!intel_state)
 		return NULL;
Signature · 6 lines
2.1.0

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

PATCH 8/10 drm/i915: Use crtc->state for duplication.

In reply to Maarten Lankhorst

In async mode crtc->config can be updated after the locks are released, resulting in the wrong state being duplicated.

---
 drivers/gpu/drm/i915/intel_atomic.c | 9 +--------
 1 file changed, 1 insertion(+), 8 deletions(-)
drivers/gpu/drm/i915/intel_atomic.c +1 -8
index 8287b81287a0..9d5cc89ebfcb 100644
@@ -85,20 +85,13 @@ intel_connector_atomic_get_property(struct drm_connector *connector,
 struct drm_crtc_state *
 intel_crtc_duplicate_state(struct drm_crtc *crtc)
 {
-	struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
 	struct intel_crtc_state *crtc_state;
 
-	if (WARN_ON(!intel_crtc->config))
-		crtc_state = kzalloc(sizeof(*crtc_state), GFP_KERNEL);
-	else
-		crtc_state = kmemdup(intel_crtc->config,
-				     sizeof(*intel_crtc->config), GFP_KERNEL);
-
+	crtc_state = kmemdup(crtc->state, sizeof(*crtc_state), GFP_KERNEL);
 	if (!crtc_state)
 		return NULL;
 
 	__drm_atomic_helper_crtc_duplicate_state(crtc, &crtc_state->base);
-	crtc_state->base.crtc = crtc;
 	crtc_state->update_pipe = false;
 
 	return &crtc_state->base;
Signature · 6 lines
2.1.0

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

Re: [PATCH 08/10] drm/i915: Use crtc->state for duplication.

Quoted 21 lines · Maarten Lankhorst

In async mode crtc->config can be updated after the locks are released, resulting in the wrong state being duplicated.

---
 drivers/gpu/drm/i915/intel_atomic.c | 9 +--------
 1 file changed, 1 insertion(+), 8 deletions(-)
drivers/gpu/drm/i915/intel_atomic.c +0 -3
index 8287b81287a0..9d5cc89ebfcb 100644
@@ -85,20 +85,13 @@ intel_connector_atomic_get_property(struct drm_connector *connector,
 struct drm_crtc_state *
 intel_crtc_duplicate_state(struct drm_crtc *crtc)
 {
-	struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
 	struct intel_crtc_state *crtc_state;
 
-	if (WARN_ON(!intel_crtc->config))
-		crtc_state = kzalloc(sizeof(*crtc_state), GFP_KERNEL);

drivers/gpu/drm/i915/intel_atomic.c intel_connector_atomic_get_property(struct drm_connector *connector, · line 101

Quoted 10 lines
drivers/gpu/drm/i915/intel_atomic.c +1 -5
-	else
-		crtc_state = kmemdup(intel_crtc->config,
-				     sizeof(*intel_crtc->config), GFP_KERNEL);
-
+	crtc_state = kmemdup(crtc->state, sizeof(*crtc_state), GFP_KERNEL);
 	if (!crtc_state)
 		return NULL;
 
 	__drm_atomic_helper_crtc_duplicate_state(crtc, &crtc_state->base);
-	crtc_state->base.crtc = crtc;

This is a bugfix for Ander's patch in 4.3. Please split it out and submit just that part to Jani. I've dropped this part from the patch I merged to dinq.
-Daniel

Quoted 10 lines
drivers/gpu/drm/i915/intel_atomic.c +0 -0
 	crtc_state->update_pipe = false;
 
 	return &crtc_state->base;
Signature · 6 lines
2.1.0

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#30 lore raw

Re: [PATCH 08/10] drm/i915: Use crtc->state for duplication.

Quoted 30 lines · Daniel Vetter
Quoted 29 lines · Maarten Lankhorst

In async mode crtc->config can be updated after the locks are released, resulting in the wrong state being duplicated.

---
 drivers/gpu/drm/i915/intel_atomic.c | 9 +--------
 1 file changed, 1 insertion(+), 8 deletions(-)
drivers/gpu/drm/i915/intel_atomic.c +1 -7
index 8287b81287a0..9d5cc89ebfcb 100644
@@ -85,20 +85,13 @@ intel_connector_atomic_get_property(struct drm_connector *connector,
 struct drm_crtc_state *
 intel_crtc_duplicate_state(struct drm_crtc *crtc)
 {
-	struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
 	struct intel_crtc_state *crtc_state;
 
-	if (WARN_ON(!intel_crtc->config))
-		crtc_state = kzalloc(sizeof(*crtc_state), GFP_KERNEL);
-	else
-		crtc_state = kmemdup(intel_crtc->config,
-				     sizeof(*intel_crtc->config), GFP_KERNEL);
-
+	crtc_state = kmemdup(crtc->state, sizeof(*crtc_state), GFP_KERNEL);
 	if (!crtc_state)
 		return NULL;
 
Quoted 6 lines

drivers/gpu/drm/i915/intel_atomic.c intel_connector_atomic_get_property(struct drm_connector *connector, · line 101

Quoted 2 lines
drivers/gpu/drm/i915/intel_atomic.c +0 -1
 	__drm_atomic_helper_crtc_duplicate_state(crtc, &crtc_state->base);
-	crtc_state->base.crtc = crtc;

This is a bugfix for Ander's patch in 4.3. Please split it out and submit just that part to Jani. I've dropped this part from the patch I merged to dinq.

Argh got confused, that line is in dinq too. I added a commit reference to your patch.
-Daniel

Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#31 lore raw

PATCH 9/10 drm/i915: Kill off a user of update_state_fb.

In reply to Maarten Lankhorst
---
 drivers/gpu/drm/i915/intel_display.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/i915/intel_display.c +2 -2
index b809ee2a8678..f41ca558ba3b 100644
@@ -15353,9 +15353,9 @@ void intel_modeset_gem_init(struct drm_device *dev)
 			DRM_ERROR("failed to pin boot fb on pipe %d\n",
 				  to_intel_crtc(c)->pipe);
 			drm_framebuffer_unreference(c->primary->fb);
-			c->primary->fb = NULL;
+			drm_framebuffer_unreference(c->primary->state->fb);
+			c->primary->fb = c->primary->state->fb = NULL;
 			c->primary->crtc = c->primary->state->crtc = NULL;
-			update_state_fb(c->primary);
 			c->state->plane_mask &= ~(1 << drm_plane_index(c->primary));
 		}
 	}
Signature · 6 lines
2.1.0

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

Re: [PATCH 09/10] drm/i915: Kill off a user of update_state_fb.

Quoted 1 line · Maarten Lankhorst

Not sure this is worth it ... I'll punt for now. But if you add a bit of justification that we could get rid of update_state_fb entirely it would look better ;-)
-Daniel

Quoted 27 lines
---
 drivers/gpu/drm/i915/intel_display.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/i915/intel_display.c +2 -2
index b809ee2a8678..f41ca558ba3b 100644
@@ -15353,9 +15353,9 @@ void intel_modeset_gem_init(struct drm_device *dev)
 			DRM_ERROR("failed to pin boot fb on pipe %d\n",
 				  to_intel_crtc(c)->pipe);
 			drm_framebuffer_unreference(c->primary->fb);
-			c->primary->fb = NULL;
+			drm_framebuffer_unreference(c->primary->state->fb);
+			c->primary->fb = c->primary->state->fb = NULL;
 			c->primary->crtc = c->primary->state->crtc = NULL;
-			update_state_fb(c->primary);
 			c->state->plane_mask &= ~(1 << drm_plane_index(c->primary));
 		}
 	}
Signature · 6 lines
2.1.0

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#33 lore raw

Re: [PATCH 09/10] drm/i915: Kill off a user of update_state_fb.

Op 10-09-15 om 17:50 schreef Daniel Vetter:

Quoted 6 lines · Maarten Lankhorst
Quoted 1 line

Not sure this is worth it ... I'll punt for now. But if you add a bit of justification that we could get rid of update_state_fb entirely it would look better ;-)

When the page flip handler is converted to atomic this function will finally have no more use. I'm a patient man and can hold off this patch a bit longer. ;-)
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

#34 lore raw

PATCH 10/10 drm/i915: Only run commit when crtc is active.

In reply to Maarten Lankhorst

The crtc->active guards are no longer needed now that all state updates are outside the commit.

---
 drivers/gpu/drm/i915/intel_display.c | 16 ++++++----------
 drivers/gpu/drm/i915/intel_sprite.c  |  3 ---
 2 files changed, 6 insertions(+), 13 deletions(-)
drivers/gpu/drm/i915/intel_display.c +6 -10
index f41ca558ba3b..dc696ec5f228 100644
@@ -13135,7 +13135,9 @@ static int intel_atomic_commit(struct drm_device *dev,
 		if (!modeset)
 			intel_pre_plane_update(intel_crtc);
 
-		drm_atomic_helper_commit_planes_on_crtc(crtc_state);
+		if (crtc->state->active && (crtc->state->planes_changed ||
+		    to_intel_crtc_state(crtc->state)->update_pipe))
+			drm_atomic_helper_commit_planes_on_crtc(crtc_state);
 
 		if (put_domains)
 			modeset_put_power_domains(dev_priv, put_domains);
@@ -13445,9 +13447,6 @@ intel_commit_primary_plane(struct drm_plane *plane,
 
 	crtc = crtc ? crtc : plane->crtc;
 
-	if (!crtc->state->active)
-		return;
-
 	dev_priv->display.update_primary_plane(crtc, fb,
 					       state->src.x1 >> 16,
 					       state->src.y1 >> 16);
@@ -13476,8 +13475,7 @@ static void intel_begin_crtc_commit(struct drm_crtc *crtc,
 		intel_update_watermarks(crtc);
 
 	/* Perform vblank evasion around commit operation */
-	if (crtc->state->active)
-		intel_pipe_update_start(intel_crtc);
+	intel_pipe_update_start(intel_crtc);
 
 	if (modeset)
 		return;
@@ -13493,8 +13491,7 @@ static void intel_finish_crtc_commit(struct drm_crtc *crtc,
 {
 	struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
 
-	if (crtc->state->active)
-		intel_pipe_update_end(intel_crtc);
+	intel_pipe_update_end(intel_crtc);
 }
 
 /**
@@ -13677,8 +13674,7 @@ intel_commit_cursor_plane(struct drm_plane *plane,
 	intel_crtc->cursor_bo = obj;
 
 update:
-	if (crtc->state->active)
-		intel_crtc_update_cursor(crtc, state->visible);
+	intel_crtc_update_cursor(crtc, state->visible);
 }
 
 static struct drm_plane *intel_cursor_plane_create(struct drm_device *dev,
drivers/gpu/drm/i915/intel_sprite.c +0 -3
index 9553859ca151..9c13d8156135 100644
@@ -927,9 +927,6 @@ intel_commit_sprite_plane(struct drm_plane *plane,
 
 	crtc = crtc ? crtc : plane->crtc;
 
-	if (!crtc->state->active)
-		return;
-
 	if (state->visible) {
 		intel_plane->update_plane(plane, crtc, fb,
 					  state->dst.x1, state->dst.y1,
Signature · 6 lines
2.1.0

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

Re: [PATCH 10/10] drm/i915: Only run commit when crtc is active.

Quoted 4 lines · Maarten Lankhorst

The crtc->active guards are no longer needed now that all state updates are outside the commit.

This looks actually complicated, so I'll punt. Merged most of the other patches from your series, thanks.
-Daniel

Quoted 81 lines
---
 drivers/gpu/drm/i915/intel_display.c | 16 ++++++----------
 drivers/gpu/drm/i915/intel_sprite.c  |  3 ---
 2 files changed, 6 insertions(+), 13 deletions(-)
drivers/gpu/drm/i915/intel_display.c +6 -10
index f41ca558ba3b..dc696ec5f228 100644
@@ -13135,7 +13135,9 @@ static int intel_atomic_commit(struct drm_device *dev,
 		if (!modeset)
 			intel_pre_plane_update(intel_crtc);
 
-		drm_atomic_helper_commit_planes_on_crtc(crtc_state);
+		if (crtc->state->active && (crtc->state->planes_changed ||
+		    to_intel_crtc_state(crtc->state)->update_pipe))
+			drm_atomic_helper_commit_planes_on_crtc(crtc_state);
 
 		if (put_domains)
 			modeset_put_power_domains(dev_priv, put_domains);
@@ -13445,9 +13447,6 @@ intel_commit_primary_plane(struct drm_plane *plane,
 
 	crtc = crtc ? crtc : plane->crtc;
 
-	if (!crtc->state->active)
-		return;
-
 	dev_priv->display.update_primary_plane(crtc, fb,
 					       state->src.x1 >> 16,
 					       state->src.y1 >> 16);
@@ -13476,8 +13475,7 @@ static void intel_begin_crtc_commit(struct drm_crtc *crtc,
 		intel_update_watermarks(crtc);
 
 	/* Perform vblank evasion around commit operation */
-	if (crtc->state->active)
-		intel_pipe_update_start(intel_crtc);
+	intel_pipe_update_start(intel_crtc);
 
 	if (modeset)
 		return;
@@ -13493,8 +13491,7 @@ static void intel_finish_crtc_commit(struct drm_crtc *crtc,
 {
 	struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
 
-	if (crtc->state->active)
-		intel_pipe_update_end(intel_crtc);
+	intel_pipe_update_end(intel_crtc);
 }
 
 /**
@@ -13677,8 +13674,7 @@ intel_commit_cursor_plane(struct drm_plane *plane,
 	intel_crtc->cursor_bo = obj;
 
 update:
-	if (crtc->state->active)
-		intel_crtc_update_cursor(crtc, state->visible);
+	intel_crtc_update_cursor(crtc, state->visible);
 }
 
 static struct drm_plane *intel_cursor_plane_create(struct drm_device *dev,
drivers/gpu/drm/i915/intel_sprite.c +0 -3
index 9553859ca151..9c13d8156135 100644
@@ -927,9 +927,6 @@ intel_commit_sprite_plane(struct drm_plane *plane,
 
 	crtc = crtc ? crtc : plane->crtc;
 
-	if (!crtc->state->active)
-		return;
-
 	if (state->visible) {
 		intel_plane->update_plane(plane, crtc, fb,
 					  state->dst.x1, state->dst.y1,
Signature · 6 lines
2.1.0

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#36 lore raw

Re: [PATCH 10/10] drm/i915: Only run commit when crtc is active.

Op 10-09-15 om 17:51 schreef Daniel Vetter:

Quoted 7 lines · Maarten Lankhorst
Quoted 4 lines

The crtc->active guards are no longer needed now that all state updates are outside the commit.

This looks actually complicated, so I'll punt. Merged most of the other patches from your series, thanks.

It's very easy, but needs previous patches to be applied, the fixup patch for intel_update_primaries and the update primary plane state outside commit_primary_plane patch.

With all state updates in commit gone, only hw state is still updated.
Each commit_plane has a line with if (!crtc->state->active) return; eg its a noop when crtc is inactive. Same for begin/finish crtc_commit.

Hence it could be changed to
if (crtc->state->active) drm_atomic_helper_commit_planes_on_crtc(crtc_state);

When planes_changed = false, there is no plane state for the current crtc. The other function of begin_crtc_commit is updating pipe config for a fastset.

If neither are required, there's no hw state to update, so commit_planes_on_crtc would do vblank evasion for no reason. It can be skipped.

Maybe it's easier to understand if I split this up in 2 patches. One to make the crtc->state->active changes, another to add the planes_changed || update_pipe changes.

Quoted 78 lines

-Daniel

Quoted 77 lines
---
 drivers/gpu/drm/i915/intel_display.c | 16 ++++++----------
 drivers/gpu/drm/i915/intel_sprite.c  |  3 ---
 2 files changed, 6 insertions(+), 13 deletions(-)
drivers/gpu/drm/i915/intel_display.c +6 -10
index f41ca558ba3b..dc696ec5f228 100644
@@ -13135,7 +13135,9 @@ static int intel_atomic_commit(struct drm_device *dev,
 		if (!modeset)
 			intel_pre_plane_update(intel_crtc);
 
-		drm_atomic_helper_commit_planes_on_crtc(crtc_state);
+		if (crtc->state->active && (crtc->state->planes_changed ||
+		    to_intel_crtc_state(crtc->state)->update_pipe))
+			drm_atomic_helper_commit_planes_on_crtc(crtc_state);
 
 		if (put_domains)
 			modeset_put_power_domains(dev_priv, put_domains);
@@ -13445,9 +13447,6 @@ intel_commit_primary_plane(struct drm_plane *plane,
 
 	crtc = crtc ? crtc : plane->crtc;
 
-	if (!crtc->state->active)
-		return;
-
 	dev_priv->display.update_primary_plane(crtc, fb,
 					       state->src.x1 >> 16,
 					       state->src.y1 >> 16);
@@ -13476,8 +13475,7 @@ static void intel_begin_crtc_commit(struct drm_crtc *crtc,
 		intel_update_watermarks(crtc);
 
 	/* Perform vblank evasion around commit operation */
-	if (crtc->state->active)
-		intel_pipe_update_start(intel_crtc);
+	intel_pipe_update_start(intel_crtc);
 
 	if (modeset)
 		return;
@@ -13493,8 +13491,7 @@ static void intel_finish_crtc_commit(struct drm_crtc *crtc,
 {
 	struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
 
-	if (crtc->state->active)
-		intel_pipe_update_end(intel_crtc);
+	intel_pipe_update_end(intel_crtc);
 }
 
 /**
@@ -13677,8 +13674,7 @@ intel_commit_cursor_plane(struct drm_plane *plane,
 	intel_crtc->cursor_bo = obj;
 
 update:
-	if (crtc->state->active)
-		intel_crtc_update_cursor(crtc, state->visible);
+	intel_crtc_update_cursor(crtc, state->visible);
 }
 
 static struct drm_plane *intel_cursor_plane_create(struct drm_device *dev,
drivers/gpu/drm/i915/intel_sprite.c +0 -3
index 9553859ca151..9c13d8156135 100644
@@ -927,9 +927,6 @@ intel_commit_sprite_plane(struct drm_plane *plane,
 
 	crtc = crtc ? crtc : plane->crtc;
 
-	if (!crtc->state->active)
-		return;
-
 	if (state->visible) {
 		intel_plane->update_plane(plane, crtc, fb,
 					  state->dst.x1, state->dst.y1,
Signature · 1 line
2.1.0
Quoted 4 lines
Quoted 4 lines

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

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