Skip to contentSkip to conversation

drm/atomic-helper: Add option to update planes only on active crtc

PATCH In review Daniel Vetter 9 participants 25 messages Jul 29, 2015 – Sep 8, 2015

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

PATCH 1/3 drm/atomic-helper: Add option to update planes only on active crtc

With drivers supporting runtime pm it's generally not a good idea to touch the hardware when it's off. Add an option to the commit_planes helper to support this case.

Note that the helpers already add all planes on a crtc when a modeset happens, hence plane updates will not be lost if drivers set this to true.

v2: Check for NULL state->crtc before chasing the pointer. Also check both old and new crtc if there's a switch. Finally just outright disallow switching crtcs for a plane if the plane is in active use, on most hardware that doesn't make sense.

v3: Since commit_planes(active_only = true) is for enabling things only after all the crtc are on we should only look at the new crtc to decide whether to call the plane hooks - if the current CRTC isn't on then skip. If the old crtc (when moving a plane) went down then the plane should have been disabled as part of the pipe shutdown work already. For which there's currently no helper really unfortunately. Also move the check for wether a plane gets a new CRTC assigned while still in active use out of this patch.

Cc Maarten Lankhorst <[email protected]>
Cc Thierry Reding <[email protected]>
Cc Laurent Pinchart <[email protected]>
---
 drivers/gpu/drm/drm_atomic_helper.c    | 20 ++++++++++++++++++--
 drivers/gpu/drm/exynos/exynos_drm_fb.c |  2 +-
 drivers/gpu/drm/msm/msm_atomic.c       |  2 +-
 drivers/gpu/drm/omapdrm/omap_drv.c     |  2 +-
 drivers/gpu/drm/rcar-du/rcar_du_kms.c  |  2 +-
 drivers/gpu/drm/sti/sti_drm_drv.c      |  2 +-
 drivers/gpu/drm/tegra/drm.c            |  2 +-
 include/drm/drm_atomic_helper.h        |  3 ++-
 8 files changed, 26 insertions(+), 9 deletions(-)
drivers/gpu/drm/drm_atomic_helper.c +18 -2
index 0b475fae067d..6be0adb5a0e9 100644
@@ -1029,7 +1029,7 @@ int drm_atomic_helper_commit(struct drm_device *dev,
 
 	drm_atomic_helper_commit_modeset_disables(dev, state);
 
-	drm_atomic_helper_commit_planes(dev, state);
+	drm_atomic_helper_commit_planes(dev, state, false);
 
 	drm_atomic_helper_commit_modeset_enables(dev, state);
 
@@ -1144,10 +1144,16 @@ fail:
 }
 EXPORT_SYMBOL(drm_atomic_helper_prepare_planes);
 
+bool plane_crtc_active(struct drm_plane_state *state)
+{
+	return state->crtc && state->crtc->state->active;
+}
+
 /**
  * drm_atomic_helper_commit_planes - commit plane state
  * @dev: DRM device
  * @old_state: atomic state object with old state structures
+ * @active_only: Only commit on active CRTC if set
  *
  * This function commits the new plane state using the plane and atomic helper
  * functions for planes and crtcs. It assumes that the atomic state has already
@@ -1162,7 +1168,8 @@ EXPORT_SYMBOL(drm_atomic_helper_prepare_planes);
  * drm_atomic_helper_commit_planes_on_crtc() instead.
  */
 void drm_atomic_helper_commit_planes(struct drm_device *dev,
-				     struct drm_atomic_state *old_state)
+				     struct drm_atomic_state *old_state,
+				     bool active_only)
 {
 	struct drm_crtc *crtc;
 	struct drm_crtc_state *old_crtc_state;
@@ -1178,6 +1185,9 @@ void drm_atomic_helper_commit_planes(struct drm_device *dev,
 		if (!funcs || !funcs->atomic_begin)
 			continue;
 
+		if (active_only && !crtc->state->active)
+			continue;
+
 		funcs->atomic_begin(crtc, old_crtc_state);
 	}
 
@@ -1189,6 +1199,9 @@ void drm_atomic_helper_commit_planes(struct drm_device *dev,
 		if (!funcs)
 			continue;
 
+		if (active_only && !plane_crtc_active(plane->state))
+			continue;
+
 		/*
 		 * Special-case disabling the plane if drivers support it.
 		 */
@@ -1208,6 +1221,9 @@ void drm_atomic_helper_commit_planes(struct drm_device *dev,
 		if (!funcs || !funcs->atomic_flush)
 			continue;
 
+		if (active_only && !crtc->state->active)
+			continue;
+
 		funcs->atomic_flush(crtc, old_crtc_state);
 	}
 }
drivers/gpu/drm/exynos/exynos_drm_fb.c +1 -1
index 2b6320e6eae2..7b383acbb5af 100644
@@ -293,7 +293,7 @@ static int exynos_atomic_commit(struct drm_device *dev,
 	 * have the relevant clocks enabled to perform the update.
 	 */
 
-	drm_atomic_helper_commit_planes(dev, state);
+	drm_atomic_helper_commit_planes(dev, state, false);
 
 	drm_atomic_helper_cleanup_planes(dev, state);
 
drivers/gpu/drm/msm/msm_atomic.c +1 -1
index 1b22d8bfe142..0709b97251bf 100644
@@ -125,7 +125,7 @@ static void complete_commit(struct msm_commit *c)
 
 	drm_atomic_helper_commit_modeset_disables(dev, state);
 
-	drm_atomic_helper_commit_planes(dev, state);
+	drm_atomic_helper_commit_planes(dev, state, false);
 
 	drm_atomic_helper_commit_modeset_enables(dev, state);
 
drivers/gpu/drm/omapdrm/omap_drv.c +1 -1
index e888a831dd3c..0ecce79fc782 100644
@@ -96,7 +96,7 @@ static void omap_atomic_complete(struct omap_atomic_state_commit *commit)
 	dispc_runtime_get();
 
 	drm_atomic_helper_commit_modeset_disables(dev, old_state);
-	drm_atomic_helper_commit_planes(dev, old_state);
+	drm_atomic_helper_commit_planes(dev, old_state, false);
 	drm_atomic_helper_commit_modeset_enables(dev, old_state);
 
 	omap_atomic_wait_for_completion(dev, old_state);
drivers/gpu/drm/rcar-du/rcar_du_kms.c +1 -1
index 56518eb1269a..ca12e8ca5552 100644
@@ -456,7 +456,7 @@ static void rcar_du_atomic_complete(struct rcar_du_commit *commit)
 	/* Apply the atomic update. */
 	drm_atomic_helper_commit_modeset_disables(dev, old_state);
 	drm_atomic_helper_commit_modeset_enables(dev, old_state);
-	drm_atomic_helper_commit_planes(dev, old_state);
+	drm_atomic_helper_commit_planes(dev, old_state, false);
 
 	drm_atomic_helper_wait_for_vblanks(dev, old_state);
 
drivers/gpu/drm/sti/sti_drm_drv.c +1 -1
index 59d558b400b3..123f1408d508 100644
@@ -59,7 +59,7 @@ static void sti_drm_atomic_complete(struct sti_drm_private *private,
 	 */
 
 	drm_atomic_helper_commit_modeset_disables(drm, state);
-	drm_atomic_helper_commit_planes(drm, state);
+	drm_atomic_helper_commit_planes(drm, state, false);
 	drm_atomic_helper_commit_modeset_enables(drm, state);
 
 	drm_atomic_helper_wait_for_vblanks(drm, state);
drivers/gpu/drm/tegra/drm.c +1 -1
index c6276aebfec3..783edc242648 100644
@@ -56,7 +56,7 @@ static void tegra_atomic_complete(struct tegra_drm *tegra,
 	 */
 
 	drm_atomic_helper_commit_modeset_disables(drm, state);
-	drm_atomic_helper_commit_planes(drm, state);
+	drm_atomic_helper_commit_planes(drm, state, false);
 	drm_atomic_helper_commit_modeset_enables(drm, state);
 
 	drm_atomic_helper_wait_for_vblanks(drm, state);
include/drm/drm_atomic_helper.h +2 -1
index 11266d147a29..4ffe9dca07c4 100644
@@ -55,7 +55,8 @@ void drm_atomic_helper_commit_modeset_enables(struct drm_device *dev,
 int drm_atomic_helper_prepare_planes(struct drm_device *dev,
 				     struct drm_atomic_state *state);
 void drm_atomic_helper_commit_planes(struct drm_device *dev,
-				     struct drm_atomic_state *state);
+				     struct drm_atomic_state *state,
+				     bool active_only);
 void drm_atomic_helper_cleanup_planes(struct drm_device *dev,
 				      struct drm_atomic_state *old_state);
 void drm_atomic_helper_commit_planes_on_crtc(struct drm_crtc_state *old_crtc_state);
Signature · 6 lines
2.5.0

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

PATCH 2/3 drm/rcar: Only update planes on active crtc

R-car does runtime pm (that's why it's committing plane state only at the end). Therefore better to only update planes on active crtc. Note that since the helpers always add all enabled planes when doing a modeset change on a crtc we are guaranteed to update plane hw state to the latest requested state each time the crtc is enabled.

Cc Laurent Pinchart <[email protected]>
---
 drivers/gpu/drm/rcar-du/rcar_du_kms.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/rcar-du/rcar_du_kms.c +1 -1
index ca12e8ca5552..20813582fbf1 100644
@@ -456,7 +456,7 @@ static void rcar_du_atomic_complete(struct rcar_du_commit *commit)
 	/* Apply the atomic update. */
 	drm_atomic_helper_commit_modeset_disables(dev, old_state);
 	drm_atomic_helper_commit_modeset_enables(dev, old_state);
-	drm_atomic_helper_commit_planes(dev, old_state, false);
+	drm_atomic_helper_commit_planes(dev, old_state, true);
 
 	drm_atomic_helper_wait_for_vblanks(dev, old_state);
 
Signature · 6 lines
2.5.0

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

PATCH 3/3 drm/atomic: refuse changing CRTC for planes while active

In reply to Daniel Vetter

Very strictly speaking this is possible if you have special hw and genlocked CRTCs. In general switching a plane between two active CRTC just won't work so well and is probably not tested at all. Just forbid it.

The exception is when both CRTC do a full modeset, then it should be no problem at all to move the planes around (presuming a correct implementation) so allow that case.

I've put this into the core since I really couldn't come up with a case where we don't want to enforce that. But if that ever happens it would be easy to move this check into helpers.

Cc Thierry Reding <[email protected]>
Cc Maarten Lankhorst <[email protected]>
---
 drivers/gpu/drm/drm_atomic.c        | 38 +++++++++++++++++++++++++++++++++++++
 drivers/gpu/drm/drm_atomic_helper.c |  1 +
 2 files changed, 39 insertions(+)
drivers/gpu/drm/drm_atomic.c +38 -0
index 434915448ea0..422183e7ee7d 100644
@@ -663,6 +663,38 @@ drm_atomic_plane_get_property(struct drm_plane *plane,
 	return 0;
 }
 
+/* checks whether a plane has its CRTC switched while being in active use. */
+static bool
+active_plane_switching(struct drm_atomic_state *state,
+		       struct drm_plane *plane,
+		       struct drm_plane_state *plane_state)
+{
+	struct drm_crtc_state *crtc_state, *curr_crtc_state;
+
+	if (!plane->state->crtc || !plane_state->crtc)
+		return false;
+
+	if (plane->state->crtc == plane_state->crtc)
+		return false;
+
+	curr_crtc_state = plane->state->crtc->state;
+	if (!curr_crtc_state->active)
+		return false;
+
+	crtc_state = drm_atomic_get_existing_crtc_state(state,
+							plane_state->crtc);
+	if (!crtc_state->active)
+		return false;
+
+	/* plane switching CRTC and both CRTC are active. This is only ok if
+	 * both CRTC do a full modeset. */
+	if (drm_atomic_crtc_needs_modeset(curr_crtc_state) &&
+	    drm_atomic_crtc_needs_modeset(crtc_state))
+		return false;
+
+	return true;
+}
+
 /**
  * drm_atomic_plane_check - check plane state
  * @plane: plane to check
@@ -734,6 +766,12 @@ static int drm_atomic_plane_check(struct drm_plane *plane,
 		return -ENOSPC;
 	}
 
+	if (active_plane_switching(state->state, plane, state)) {
+		DRM_DEBUG_ATOMIC("[PLANE:%d] switching active CRTC without modeset\n",
+				 plane->base.id);
+		return -EINVAL;
+	}
+
 	return 0;
 }
 
drivers/gpu/drm/drm_atomic_helper.c +1 -0
index 6be0adb5a0e9..54c59ddc59a5 100644
@@ -497,6 +497,7 @@ drm_atomic_helper_check_planes(struct drm_device *dev,
 					 plane->base.id);
 			return ret;
 		}
+
 	}
 
 	for_each_crtc_in_state(state, crtc, crtc_state, i) {
Signature · 6 lines
2.5.0

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
Tested-by on v1 3/3
#3 lore raw

Re: [PATCH 3/3] drm/atomic: refuse changing CRTC for planes while active

Task id: 6889 -------------------------------------Summary-------------------------------------
Platform Delta drm-intel-nightly Series Applied

ILK                                  297/297              297/297
SNB                                  315/315              315/315
IVB                                  342/342              342/342
BYT                                  282/282              282/282
HSW                                  378/378              378/378

-------------------------------------Detailed-------------------------------------
Platform Test drm-intel-nightly Series Applied
Note: You need to pay more attention to line start with '*'
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

#4 lore raw

PATCH 1/1 drm/atomic: refuse changing CRTC for planes directly

In reply to Daniel Vetter

Very strictly speaking this is possible if you have special hw and genlocked CRTCs. In general switching a plane between two active CRTC just won't work so well and is probably not tested at all. Just forbid it.

I've put this into the core since I really couldn't come up with a case where we don't want to enforce that. But if that ever happens it would be easy to move this check into helpers.

v2: don't bother with complexity and just outright disallow plane switching without the intermediate OFF state. Simplifies drivers, we don't have any hw that could do it anyway and current atomic userspace (weston) works like this already anyway.

Cc Thierry Reding <[email protected]>
Cc Maarten Lankhorst <[email protected]>
Cc Daniel Stone <[email protected]>
---
 drivers/gpu/drm/drm_atomic.c | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)
drivers/gpu/drm/drm_atomic.c +22 -0
index 434915448ea0..f27aae3fa765 100644
@@ -663,6 +663,22 @@ drm_atomic_plane_get_property(struct drm_plane *plane,
 	return 0;
 }
 
+static bool
+plane_switching(struct drm_atomic_state *state,
+		struct drm_plane *plane,
+		struct drm_plane_state *plane_state)
+{
+	struct drm_crtc_state *crtc_state, *curr_crtc_state;
+
+	if (!plane->state->crtc || !plane_state->crtc)
+		return false;
+
+	if (plane->state->crtc == plane_state->crtc)
+		return false;
+
+	return true;
+}
+
 /**
  * drm_atomic_plane_check - check plane state
  * @plane: plane to check
@@ -734,6 +750,12 @@ static int drm_atomic_plane_check(struct drm_plane *plane,
 		return -ENOSPC;
 	}
 
+	if (plane_switching(state->state, plane, state)) {
+		DRM_DEBUG_ATOMIC("[PLANE:%d] switching CRTC directly\n",
+				 plane->base.id);
+		return -EINVAL;
+	}
+
 	return 0;
 }
 
Signature · 6 lines
2.5.0

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

Re: [Intel-gfx] [PATCH] drm/atomic: refuse changing CRTC for planes directly

Quoted 27 lines · Daniel Vetter

Very strictly speaking this is possible if you have special hw and genlocked CRTCs. In general switching a plane between two active CRTC just won't work so well and is probably not tested at all. Just forbid it.

I've put this into the core since I really couldn't come up with a case where we don't want to enforce that. But if that ever happens it would be easy to move this check into helpers.

v2: don't bother with complexity and just outright disallow plane switching without the intermediate OFF state. Simplifies drivers, we don't have any hw that could do it anyway and current atomic userspace (weston) works like this already anyway.

Cc Thierry Reding <[email protected]>
Cc Maarten Lankhorst <[email protected]>
Cc Daniel Stone <[email protected]>
---
 drivers/gpu/drm/drm_atomic.c | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)
drivers/gpu/drm/drm_atomic.c +0 -0
index 434915448ea0..f27aae3fa765 100644

drivers/gpu/drm/drm_atomic.c drm_atomic_plane_get_property(struct drm_plane *plane, · line 669

Quoted 7 lines
drivers/gpu/drm/drm_atomic.c +4 -0
@@ -663,6 +663,22 @@ drm_atomic_plane_get_property(struct drm_plane *plane,
 	return 0;
 }
 
+static bool
+plane_switching(struct drm_atomic_state *state,
+		struct drm_plane *plane,
+		struct drm_plane_state *plane_state)

plane_switching_crtc()?

Quoted 35 lines
drivers/gpu/drm/drm_atomic.c +18 -0
+{
+	struct drm_crtc_state *crtc_state, *curr_crtc_state;
+
+	if (!plane->state->crtc || !plane_state->crtc)
+		return false;
+
+	if (plane->state->crtc == plane_state->crtc)
+		return false;
+
+	return true;
+}
+
 /**
  * drm_atomic_plane_check - check plane state
  * @plane: plane to check
@@ -734,6 +750,12 @@ static int drm_atomic_plane_check(struct drm_plane *plane,
 		return -ENOSPC;
 	}
 
+	if (plane_switching(state->state, plane, state)) {
+		DRM_DEBUG_ATOMIC("[PLANE:%d] switching CRTC directly\n",
+				 plane->base.id);
+		return -EINVAL;
+	}
+
 	return 0;
 }
 
Signature · 6 lines
2.5.0

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

Re: [Intel-gfx] [PATCH] drm/atomic: refuse changing CRTC for planes directly

Quoted 38 lines · Ville Syrjälä
Quoted 37 lines · Daniel Vetter

Very strictly speaking this is possible if you have special hw and genlocked CRTCs. In general switching a plane between two active CRTC
just won't work so well and is probably not tested at all. Just forbid
it.

I've put this into the core since I really couldn't come up with a case where we don't want to enforce that. But if that ever happens it
would be easy to move this check into helpers.

v2: don't bother with complexity and just outright disallow plane switching without the intermediate OFF state. Simplifies drivers, we
don't have any hw that could do it anyway and current atomic userspace
(weston) works like this already anyway.

Cc Thierry Reding <[email protected]>
Cc Maarten Lankhorst <[email protected]>
Cc Daniel Stone <[email protected]>
---
 drivers/gpu/drm/drm_atomic.c | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)
drivers/gpu/drm/drm_atomic.c +0 -0
index 434915448ea0..f27aae3fa765 100644
@@ -663,6 +663,22 @@ drm_atomic_plane_get_property(struct
 drm_plane *plane,
 	return 0;
 }
 
Quoted 6 lines

drivers/gpu/drm/drm_atomic.c drm_atomic_plane_get_property(struct drm_plane *plane, · line 669

Quoted 4 lines
drivers/gpu/drm/drm_atomic.c +4 -0
+static bool
+plane_switching(struct drm_atomic_state *state,
+		struct drm_plane *plane,
+		struct drm_plane_state *plane_state)

plane_switching_crtc()?

With Ville's shed colour:

As this won't work in the general case, I'd prefer to see a hint to userspace that two CRTCs are genlocked before we enable it and people start to rely on it.

Cheers,
Daniel
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

#7 lore raw

Re: [PATCH] drm/atomic: refuse changing CRTC for planes directly

In reply to Daniel Vetter
Quoted 4 lines · Daniel Vetter

Very strictly speaking this is possible if you have special hw and genlocked CRTCs. In general switching a plane between two active CRTC just won't work so well and is probably not tested at all. Just forbid it.

So, I expect msm should actually be able to do this w/ dual-dsi (where we are using two CRTC's, w/ synchronized flushes)..

Probably someone who has a dual-dsi panel should actually test that to confirm. But it seems like it should work. Maybe we need something in 'struct drm_crtc' so core can realize that two CRTC's are locked together..

BR,
-R

Quoted 60 lines

I've put this into the core since I really couldn't come up with a case where we don't want to enforce that. But if that ever happens it would be easy to move this check into helpers.

v2: don't bother with complexity and just outright disallow plane switching without the intermediate OFF state. Simplifies drivers, we don't have any hw that could do it anyway and current atomic userspace (weston) works like this already anyway.

Cc Thierry Reding <[email protected]>
Cc Maarten Lankhorst <[email protected]>
Cc Daniel Stone <[email protected]>
---
 drivers/gpu/drm/drm_atomic.c | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)
drivers/gpu/drm/drm_atomic.c +22 -1
index 434915448ea0..f27aae3fa765 100644
@@ -663,6 +663,22 @@ drm_atomic_plane_get_property(struct drm_plane *plane,
        return 0;
 }
 
+static bool
+plane_switching(struct drm_atomic_state *state,
+               struct drm_plane *plane,
+               struct drm_plane_state *plane_state)
+{
+       struct drm_crtc_state *crtc_state, *curr_crtc_state;
+
+       if (!plane->state->crtc || !plane_state->crtc)
+               return false;
+
+       if (plane->state->crtc == plane_state->crtc)
+               return false;
+
+       return true;
+}
+
 /**
  * drm_atomic_plane_check - check plane state
  * @plane: plane to check
@@ -734,6 +750,12 @@ static int drm_atomic_plane_check(struct drm_plane *plane,
                return -ENOSPC;
        }
 
+       if (plane_switching(state->state, plane, state)) {
+               DRM_DEBUG_ATOMIC("[PLANE:%d] switching CRTC directly\n",
+                                plane->base.id);
+               return -EINVAL;
+       }
+
        return 0;
 }
 
--

2.5.0

Quoted 4 lines

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

#8 lore raw

Re: [PATCH] drm/atomic: refuse changing CRTC for planes directly

Quoted 6 lines · Rob Clark
Quoted 4 lines · Daniel Vetter

Very strictly speaking this is possible if you have special hw and genlocked CRTCs. In general switching a plane between two active CRTC just won't work so well and is probably not tested at all. Just forbid it.

Quoted 7 lines

So, I expect msm should actually be able to do this w/ dual-dsi (where we are using two CRTC's, w/ synchronized flushes)..

Probably someone who has a dual-dsi panel should actually test that to confirm. But it seems like it should work. Maybe we need something in 'struct drm_crtc' so core can realize that two CRTC's are locked together..

oh, and for most drivers, switching plane between CRTCs without an off-cycle would probably also work for DSI cmd mode..

BR,
-R

Quoted 58 lines
Quoted 58 lines

I've put this into the core since I really couldn't come up with a case where we don't want to enforce that. But if that ever happens it would be easy to move this check into helpers.

v2: don't bother with complexity and just outright disallow plane switching without the intermediate OFF state. Simplifies drivers, we don't have any hw that could do it anyway and current atomic userspace (weston) works like this already anyway.

Cc Thierry Reding <[email protected]>
Cc Maarten Lankhorst <[email protected]>
Cc Daniel Stone <[email protected]>
---
 drivers/gpu/drm/drm_atomic.c | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)
drivers/gpu/drm/drm_atomic.c +22 -0
index 434915448ea0..f27aae3fa765 100644
@@ -663,6 +663,22 @@ drm_atomic_plane_get_property(struct drm_plane *plane,
        return 0;
 }
 
+static bool
+plane_switching(struct drm_atomic_state *state,
+               struct drm_plane *plane,
+               struct drm_plane_state *plane_state)
+{
+       struct drm_crtc_state *crtc_state, *curr_crtc_state;
+
+       if (!plane->state->crtc || !plane_state->crtc)
+               return false;
+
+       if (plane->state->crtc == plane_state->crtc)
+               return false;
+
+       return true;
+}
+
 /**
  * drm_atomic_plane_check - check plane state
  * @plane: plane to check
@@ -734,6 +750,12 @@ static int drm_atomic_plane_check(struct drm_plane *plane,
                return -ENOSPC;
        }
 
+       if (plane_switching(state->state, plane, state)) {
+               DRM_DEBUG_ATOMIC("[PLANE:%d] switching CRTC directly\n",
+                                plane->base.id);
+               return -EINVAL;
+       }
+
        return 0;
 }
 
Quoted 7 lines
Quoted 7 lines

--
2.5.0

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

#9 lore raw

Re: [PATCH] drm/atomic: refuse changing CRTC for planes directly

Quoted 10 lines · Rob Clark
Quoted 9 lines · Rob Clark
Quoted 4 lines · Daniel Vetter

Very strictly speaking this is possible if you have special hw and genlocked CRTCs. In general switching a plane between two active CRTC just won't work so well and is probably not tested at all. Just forbid it.

So, I expect msm should actually be able to do this w/ dual-dsi (where we are using two CRTC's, w/ synchronized flushes)..

Quoted 7 lines
Quoted 4 lines

Probably someone who has a dual-dsi panel should actually test that to confirm. But it seems like it should work. Maybe we need something in 'struct drm_crtc' so core can realize that two CRTC's are locked together..

oh, and for most drivers, switching plane between CRTCs without an off-cycle would probably also work for DSI cmd mode..

You'd need to wait for any ongoing transfer on the old crtc to finish before moving the plane. So that's not really any different than the driver doing the dance with a vblank wait on a video mode display.

Quoted 73 lines

BR,
-R

Quoted 58 lines
Quoted 58 lines

I've put this into the core since I really couldn't come up with a case where we don't want to enforce that. But if that ever happens it would be easy to move this check into helpers.

v2: don't bother with complexity and just outright disallow plane switching without the intermediate OFF state. Simplifies drivers, we don't have any hw that could do it anyway and current atomic userspace (weston) works like this already anyway.

Cc Thierry Reding <[email protected]>
Cc Maarten Lankhorst <[email protected]>
Cc Daniel Stone <[email protected]>
---
 drivers/gpu/drm/drm_atomic.c | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)
drivers/gpu/drm/drm_atomic.c +22 -0
index 434915448ea0..f27aae3fa765 100644
@@ -663,6 +663,22 @@ drm_atomic_plane_get_property(struct drm_plane *plane,
        return 0;
 }
 
+static bool
+plane_switching(struct drm_atomic_state *state,
+               struct drm_plane *plane,
+               struct drm_plane_state *plane_state)
+{
+       struct drm_crtc_state *crtc_state, *curr_crtc_state;
+
+       if (!plane->state->crtc || !plane_state->crtc)
+               return false;
+
+       if (plane->state->crtc == plane_state->crtc)
+               return false;
+
+       return true;
+}
+
 /**
  * drm_atomic_plane_check - check plane state
  * @plane: plane to check
@@ -734,6 +750,12 @@ static int drm_atomic_plane_check(struct drm_plane *plane,
                return -ENOSPC;
        }
 
+       if (plane_switching(state->state, plane, state)) {
+               DRM_DEBUG_ATOMIC("[PLANE:%d] switching CRTC directly\n",
+                                plane->base.id);
+               return -EINVAL;
+       }
+
        return 0;
 }
 
Quoted 7 lines
Quoted 7 lines

--
2.5.0

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

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

Re: [PATCH] drm/atomic: refuse changing CRTC for planes directly

Quoted 16 lines · Ville Syrjälä
Quoted 15 lines · Rob Clark
Quoted 13 lines · Rob Clark
Quoted 4 lines · Daniel Vetter

Very strictly speaking this is possible if you have special hw and genlocked CRTCs. In general switching a plane between two active CRTC just won't work so well and is probably not tested at all. Just forbid it.

So, I expect msm should actually be able to do this w/ dual-dsi (where we are using two CRTC's, w/ synchronized flushes)..

Probably someone who has a dual-dsi panel should actually test that to confirm. But it seems like it should work. Maybe we need something in 'struct drm_crtc' so core can realize that two CRTC's are locked together..

Quoted 6 lines
Quoted 2 lines

oh, and for most drivers, switching plane between CRTCs without an off-cycle would probably also work for DSI cmd mode..

You'd need to wait for any ongoing transfer on the old crtc to finish before moving the plane. So that's not really any different than the driver doing the dance with a vblank wait on a video mode display.

except that update would need to block from previous xfer anyways, so there isn't really a race w/ frame n+1 like there would be with video mode..

I do think that *somehow* we need to expose whether or not the display is cmd-mode to userspace, since that factors into decisions about whether it can immediately re-use a plane on another CRTC, and I think it factors into discussion about some differences between ADF fencing and upstream fencing as we add explicit fencing support to atomic.. but that is probably a different topic..

BR,
-R

Quoted 74 lines
Quoted 65 lines

BR,
-R

Quoted 61 lines
Quoted 61 lines

I've put this into the core since I really couldn't come up with a case where we don't want to enforce that. But if that ever happens it would be easy to move this check into helpers.

v2: don't bother with complexity and just outright disallow plane switching without the intermediate OFF state. Simplifies drivers, we don't have any hw that could do it anyway and current atomic userspace (weston) works like this already anyway.

Cc Thierry Reding <[email protected]>
Cc Maarten Lankhorst <[email protected]>
Cc Daniel Stone <[email protected]>
---
 drivers/gpu/drm/drm_atomic.c | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)
drivers/gpu/drm/drm_atomic.c +22 -1
index 434915448ea0..f27aae3fa765 100644
@@ -663,6 +663,22 @@ drm_atomic_plane_get_property(struct drm_plane *plane,
        return 0;
 }
 
+static bool
+plane_switching(struct drm_atomic_state *state,
+               struct drm_plane *plane,
+               struct drm_plane_state *plane_state)
+{
+       struct drm_crtc_state *crtc_state, *curr_crtc_state;
+
+       if (!plane->state->crtc || !plane_state->crtc)
+               return false;
+
+       if (plane->state->crtc == plane_state->crtc)
+               return false;
+
+       return true;
+}
+
 /**
  * drm_atomic_plane_check - check plane state
  * @plane: plane to check
@@ -734,6 +750,12 @@ static int drm_atomic_plane_check(struct drm_plane *plane,
                return -ENOSPC;
        }
 
+       if (plane_switching(state->state, plane, state)) {
+               DRM_DEBUG_ATOMIC("[PLANE:%d] switching CRTC directly\n",
+                                plane->base.id);
+               return -EINVAL;
+       }
+
        return 0;
 }
 
--

2.5.0

Quoted 8 lines
Quoted 4 lines
Quoted 4 lines

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

Quoted 3 lines

--
Ville Syrjälä
Intel OTC

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

#11 lore raw

Re: [PATCH] drm/atomic: refuse changing CRTC for planes directly

Quoted 21 lines · Rob Clark
Quoted 19 lines · Ville Syrjälä
Quoted 17 lines · Rob Clark
Quoted 6 lines · Rob Clark
Quoted 4 lines · Daniel Vetter

Very strictly speaking this is possible if you have special hw and genlocked CRTCs. In general switching a plane between two active CRTC just won't work so well and is probably not tested at all. Just forbid it.

Quoted 7 lines

So, I expect msm should actually be able to do this w/ dual-dsi (where we are using two CRTC's, w/ synchronized flushes)..

Probably someone who has a dual-dsi panel should actually test that to confirm. But it seems like it should work. Maybe we need something in 'struct drm_crtc' so core can realize that two CRTC's are locked together..

oh, and for most drivers, switching plane between CRTCs without an off-cycle would probably also work for DSI cmd mode..

Quoted 7 lines
Quoted 3 lines

You'd need to wait for any ongoing transfer on the old crtc to finish before moving the plane. So that's not really any different than the driver doing the dance with a vblank wait on a video mode display.

except that update would need to block from previous xfer anyways, so there isn't really a race w/ frame n+1 like there would be with video mode..

Why would it block if it's on a separate crtc?

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

Re: [PATCH] drm/atomic: refuse changing CRTC for planes directly

Quoted 26 lines · Ville Syrjälä
Quoted 25 lines · Rob Clark
Quoted 22 lines · Ville Syrjälä
Quoted 10 lines · Rob Clark
Quoted 9 lines · Rob Clark
Quoted 4 lines · Daniel Vetter

Very strictly speaking this is possible if you have special hw and genlocked CRTCs. In general switching a plane between two active CRTC just won't work so well and is probably not tested at all. Just forbid it.

So, I expect msm should actually be able to do this w/ dual-dsi (where we are using two CRTC's, w/ synchronized flushes)..

Quoted 7 lines
Quoted 4 lines

Probably someone who has a dual-dsi panel should actually test that to confirm. But it seems like it should work. Maybe we need something in 'struct drm_crtc' so core can realize that two CRTC's are locked together..

oh, and for most drivers, switching plane between CRTCs without an off-cycle would probably also work for DSI cmd mode..

You'd need to wait for any ongoing transfer on the old crtc to finish before moving the plane. So that's not really any different than the driver doing the dance with a vblank wait on a video mode display.

Quoted 5 lines
Quoted 3 lines

except that update would need to block from previous xfer anyways, so there isn't really a race w/ frame n+1 like there would be with video mode..

Why would it block if it's on a separate crtc?

or, well, could block.. but anyways, the more realistic scenario for 2x dsi is dual-dsi to single panel w/ the two CRTC's locked in sync..

BR,
-R

Quoted 3 lines

--
Ville Syrjälä
Intel OTC

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

#13 lore raw

PATCH 1/1 drm/atomic: refuse changing CRTC for planes directly

In reply to Daniel Vetter

Very strictly speaking this is possible if you have special hw and genlocked CRTCs. In general switching a plane between two active CRTC just won't work so well and is probably not tested at all. Just forbid it.

I've put this into the core since right now no helper or driver copes with it, no userspace has code for it and no one asks for it. Yes there's piles of corner-cases where this would be possible to do this like:
- switch from inactive crtc to active crtc
- swithc from active crtc to inactive crtc
- genlocked display
- invisible plane (to do whatever)
- idle plane hw due to dsi cmd mode/psr
- whatever
but looking at details it's not that easy to implement this correctly. Hence just put it into the core and add a comment, since the only userspace we have right now for atomic (weston) doesn't want to use direct plane switching either.

v2: don't bother with complexity and just outright disallow plane switching without the intermediate OFF state. Simplifies drivers, we don't have any hw that could do it anyway and current atomic userspace (weston) works like this already anyway.

v3: Bikeshed function name (Ville) and add comment (Rob).

v4: Also bikeshed commit message (Rob).

Cc Thierry Reding <[email protected]>
Cc Maarten Lankhorst <[email protected]>
Cc Daniel Stone <[email protected]>

---

Imo this is bikeshedded enough, so either someone takes this or someone else can mangle this patch more.
-Daniel

---
 drivers/gpu/drm/drm_atomic.c | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)
drivers/gpu/drm/drm_atomic.c +27 -0
index 1066e4b658cf..40ddd6aa100f 100644
@@ -663,6 +663,27 @@ drm_atomic_plane_get_property(struct drm_plane *plane,
 	return 0;
 }
 
+static bool
+plane_switching_crtc(struct drm_atomic_state *state,
+		     struct drm_plane *plane,
+		     struct drm_plane_state *plane_state)
+{
+	struct drm_crtc_state *crtc_state, *curr_crtc_state;
+
+	if (!plane->state->crtc || !plane_state->crtc)
+		return false;
+
+	if (plane->state->crtc == plane_state->crtc)
+		return false;
+
+	/* This could be refined, but currently there's no helper or driver code
+	 * to implement direct switching of active planes nor userspace to take
+	 * advantage of more direct plane switching without the intermediate
+	 * full OFF state.
+	 */
+	return true;
+}
+
 /**
  * drm_atomic_plane_check - check plane state
  * @plane: plane to check
@@ -734,6 +755,12 @@ static int drm_atomic_plane_check(struct drm_plane *plane,
 		return -ENOSPC;
 	}
 
+	if (plane_switching_crtc(state->state, plane, state)) {
+		DRM_DEBUG_ATOMIC("[PLANE:%d] switching CRTC directly\n",
+				 plane->base.id);
+		return -EINVAL;
+	}
+
 	return 0;
 }
 
Signature · 6 lines
2.5.0

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
Reviewed-by on v1 1/1
#14 lore raw

Re: [Intel-gfx] [PATCH] drm/atomic: refuse changing CRTC for planes directly

Quoted 5 lines · Daniel Vetter

Very strictly speaking this is possible if you have special hw and genlocked CRTCs. In general switching a plane between two active CRTC just won't work so well and is probably not tested at all. Just forbid it.

Quoted 14 lines

I've put this into the core since right now no helper or driver copes with it, no userspace has code for it and no one asks for it. Yes there's piles of corner-cases where this would be possible to do this like:
- switch from inactive crtc to active crtc
- swithc from active crtc to inactive crtc
- genlocked display
- invisible plane (to do whatever)
- idle plane hw due to dsi cmd mode/psr
- whatever
but looking at details it's not that easy to implement this correctly. Hence just put it into the core and add a comment, since the only userspace we have right now for atomic (weston) doesn't want to use direct plane switching either.

I suspect that eventually we'll want to make this a helper exposed to drivers and push this check down into the drivers.. perhaps that is not until weston (and/or atomic based hwc) grows driver specific userspace plugin type API to make smarter hw specific decisions.. until then, this is probably the most reasonable thing to do.. so

(w/ s/swihc/switch/ fix smashed in above)

Quoted 72 lines

v2: don't bother with complexity and just outright disallow plane switching without the intermediate OFF state. Simplifies drivers, we don't have any hw that could do it anyway and current atomic userspace (weston) works like this already anyway.

v3: Bikeshed function name (Ville) and add comment (Rob).

v4: Also bikeshed commit message (Rob).

Cc Thierry Reding <[email protected]>
Cc Maarten Lankhorst <[email protected]>
Cc Daniel Stone <[email protected]>

---

Imo this is bikeshedded enough, so either someone takes this or someone else can mangle this patch more.

(quoted diff) +0 -2
-Daniel
---
 drivers/gpu/drm/drm_atomic.c | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)
drivers/gpu/drm/drm_atomic.c +27 -1
index 1066e4b658cf..40ddd6aa100f 100644
@@ -663,6 +663,27 @@ drm_atomic_plane_get_property(struct drm_plane *plane,
        return 0;
 }
 
+static bool
+plane_switching_crtc(struct drm_atomic_state *state,
+                    struct drm_plane *plane,
+                    struct drm_plane_state *plane_state)
+{
+       struct drm_crtc_state *crtc_state, *curr_crtc_state;
+
+       if (!plane->state->crtc || !plane_state->crtc)
+               return false;
+
+       if (plane->state->crtc == plane_state->crtc)
+               return false;
+
+       /* This could be refined, but currently there's no helper or driver code
+        * to implement direct switching of active planes nor userspace to take
+        * advantage of more direct plane switching without the intermediate
+        * full OFF state.
+        */
+       return true;
+}
+
 /**
  * drm_atomic_plane_check - check plane state
  * @plane: plane to check
@@ -734,6 +755,12 @@ static int drm_atomic_plane_check(struct drm_plane *plane,
                return -ENOSPC;
        }
 
+       if (plane_switching_crtc(state->state, plane, state)) {
+               DRM_DEBUG_ATOMIC("[PLANE:%d] switching CRTC directly\n",
+                                plane->base.id);
+               return -EINVAL;
+       }
+
        return 0;
 }
 
--

2.5.0

Quoted 4 lines

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

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

#15 lore raw

Re: [PATCH] drm/atomic: refuse changing CRTC for planes directly

Quoted 21 lines · Rob Clark
Quoted 5 lines · Daniel Vetter

Very strictly speaking this is possible if you have special hw and genlocked CRTCs. In general switching a plane between two active CRTC just won't work so well and is probably not tested at all. Just forbid it.

Quoted 14 lines

I've put this into the core since right now no helper or driver copes with it, no userspace has code for it and no one asks for it. Yes there's piles of corner-cases where this would be possible to do this like:
- switch from inactive crtc to active crtc
- swithc from active crtc to inactive crtc
- genlocked display
- invisible plane (to do whatever)
- idle plane hw due to dsi cmd mode/psr
- whatever
but looking at details it's not that easy to implement this correctly. Hence just put it into the core and add a comment, since the only userspace we have right now for atomic (weston) doesn't want to use direct plane switching either.

Quoted 5 lines

I suspect that eventually we'll want to make this a helper exposed to drivers and push this check down into the drivers.. perhaps that is not until weston (and/or atomic based hwc) grows driver specific userspace plugin type API to make smarter hw specific decisions.. until then, this is probably the most reasonable thing to do.. so

Yeah this really is just to plug a "undefined behaviour" gap in the abi until we know what exactly we want and have some userspace needing this.

Quoted 3 lines

(w/ s/swihc/switch/ fix smashed in above)

Fixed&merged to drm-misc, thanks for the review.
-Daniel

Quoted 78 lines
Quoted 78 lines

v2: don't bother with complexity and just outright disallow plane switching without the intermediate OFF state. Simplifies drivers, we don't have any hw that could do it anyway and current atomic userspace (weston) works like this already anyway.

v3: Bikeshed function name (Ville) and add comment (Rob).

v4: Also bikeshed commit message (Rob).

Cc Thierry Reding <[email protected]>
Cc Maarten Lankhorst <[email protected]>
Cc Daniel Stone <[email protected]>

---

Imo this is bikeshedded enough, so either someone takes this or someone else can mangle this patch more.

(quoted diff) +0 -2
-Daniel
---
 drivers/gpu/drm/drm_atomic.c | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)
drivers/gpu/drm/drm_atomic.c +27 -1
index 1066e4b658cf..40ddd6aa100f 100644
@@ -663,6 +663,27 @@ drm_atomic_plane_get_property(struct drm_plane *plane,
        return 0;
 }
 
+static bool
+plane_switching_crtc(struct drm_atomic_state *state,
+                    struct drm_plane *plane,
+                    struct drm_plane_state *plane_state)
+{
+       struct drm_crtc_state *crtc_state, *curr_crtc_state;
+
+       if (!plane->state->crtc || !plane_state->crtc)
+               return false;
+
+       if (plane->state->crtc == plane_state->crtc)
+               return false;
+
+       /* This could be refined, but currently there's no helper or driver code
+        * to implement direct switching of active planes nor userspace to take
+        * advantage of more direct plane switching without the intermediate
+        * full OFF state.
+        */
+       return true;
+}
+
 /**
  * drm_atomic_plane_check - check plane state
  * @plane: plane to check
@@ -734,6 +755,12 @@ static int drm_atomic_plane_check(struct drm_plane *plane,
                return -ENOSPC;
        }
 
+       if (plane_switching_crtc(state->state, plane, state)) {
+               DRM_DEBUG_ATOMIC("[PLANE:%d] switching CRTC directly\n",
+                                plane->base.id);
+               return -EINVAL;
+       }
+
        return 0;
 }
 
--

2.5.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
maintainer Acked-by on v1 1/1
#16 lore raw

Re: [PATCH] drm/atomic: refuse changing CRTC for planes directly

In reply to Daniel Vetter

Op 26-08-15 om 21:49 schreef Daniel Vetter:

Quoted 25 lines

Very strictly speaking this is possible if you have special hw and genlocked CRTCs. In general switching a plane between two active CRTC just won't work so well and is probably not tested at all. Just forbid it.

I've put this into the core since right now no helper or driver copes with it, no userspace has code for it and no one asks for it. Yes there's piles of corner-cases where this would be possible to do this like:
- switch from inactive crtc to active crtc
- swithc from active crtc to inactive crtc
- genlocked display
- invisible plane (to do whatever)
- idle plane hw due to dsi cmd mode/psr
- whatever
but looking at details it's not that easy to implement this correctly. Hence just put it into the core and add a comment, since the only userspace we have right now for atomic (weston) doesn't want to use direct plane switching either.

v2: don't bother with complexity and just outright disallow plane switching without the intermediate OFF state. Simplifies drivers, we don't have any hw that could do it anyway and current atomic userspace (weston) works like this already anyway.

Quoted 6 lines

v3: Bikeshed function name (Ville) and add comment (Rob).

v4: Also bikeshed commit message (Rob).

Cc Thierry Reding <[email protected]>
Cc Maarten Lankhorst <[email protected]>
Quoted 48 lines

---

Imo this is bikeshedded enough, so either someone takes this or someone else can mangle this patch more.

(quoted diff) +0 -2
-Daniel
---
 drivers/gpu/drm/drm_atomic.c | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)
drivers/gpu/drm/drm_atomic.c +21 -0
index 1066e4b658cf..40ddd6aa100f 100644
@@ -663,6 +663,27 @@ drm_atomic_plane_get_property(struct drm_plane *plane,
 	return 0;
 }
 
+static bool
+plane_switching_crtc(struct drm_atomic_state *state,
+		     struct drm_plane *plane,
+		     struct drm_plane_state *plane_state)
+{
+	struct drm_crtc_state *crtc_state, *curr_crtc_state;
+
+	if (!plane->state->crtc || !plane_state->crtc)
+		return false;
+
+	if (plane->state->crtc == plane_state->crtc)
+		return false;
+
+	/* This could be refined, but currently there's no helper or driver code
+	 * to implement direct switching of active planes nor userspace to take
+	 * advantage of more direct plane switching without the intermediate
+	 * full OFF state.
+	 */
+	return true;
+}
+
 /**
  * drm_atomic_plane_check - check plane state
  * @plane: plane to check
@@ -734,6 +755,12 @@ static int drm_atomic_plane_check(struct drm_plane *plane,
 		return -ENOSPC;
 	}

drivers/gpu/drm/drm_atomic.c static int drm_atomic_plane_check(struct drm_plane *plane, · line 766

Quoted 10 lines
drivers/gpu/drm/drm_atomic.c +6 -0
 
+	if (plane_switching_crtc(state->state, plane, state)) {
+		DRM_DEBUG_ATOMIC("[PLANE:%d] switching CRTC directly\n",
+				 plane->base.id);
+		return -EINVAL;
+	}
+
 	return 0;
 }
 

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

Tested-by on v1 1/1
#17 lore raw

Re: [PATCH] drm/atomic: refuse changing CRTC for planes directly

In reply to Daniel Vetter

Task id: 7266 -------------------------------------Summary-------------------------------------
Platform Delta drm-intel-nightly Series Applied
ILK -1 302/302 301/302

SNB                                  315/315              315/315
IVB                                  336/336              336/336

BYT -1 283/283 282/283
HSW 378/378 378/378
-------------------------------------Detailed-------------------------------------
Platform Test drm-intel-nightly Series Applied
*ILK igt@kms_flip@wf_vblank-vs-modeset-interruptible PASS(1) DMESG_WARN(1)
*BYT igt@gem_persistent_relocs@interruptible PASS(1) FAIL(1)
Note: You need to pay more attention to line start with '*'
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

Tested-by on v1 1/1
#18 lore raw

Re: [PATCH] drm/atomic: refuse changing CRTC for planes directly

In reply to Daniel Vetter

Task id: 7264 -------------------------------------Summary-------------------------------------
Platform Delta drm-intel-nightly Series Applied
ILK -2 302/302 300/302

SNB                                  315/315              315/315
IVB                                  336/336              336/336

BYT -1 283/283 282/283
HSW 378/378 378/378
-------------------------------------Detailed-------------------------------------
Platform Test drm-intel-nightly Series Applied

*ILK  igt@kms_flip@flip-vs-dpms-interruptible      PASS(1)      DMESG_WARN(1)
*ILK  igt@kms_flip@wf_vblank-vs-modeset-interruptible      PASS(1)      DMESG_WARN(1)
*BYT  igt@gem_tiled_partial_pwrite_pread@reads      PASS(1)      FAIL(1)

Note: You need to pay more attention to line start with '*'
_______________________________________________
Intel-gfx mailing list [email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

#19 lore raw
In reply to Daniel Vetter

Op 29-07-15 om 14:01 schreef Daniel Vetter:

Quoted 89 lines

With drivers supporting runtime pm it's generally not a good idea to touch the hardware when it's off. Add an option to the commit_planes helper to support this case.

Note that the helpers already add all planes on a crtc when a modeset happens, hence plane updates will not be lost if drivers set this to true.

v2: Check for NULL state->crtc before chasing the pointer. Also check both old and new crtc if there's a switch. Finally just outright disallow switching crtcs for a plane if the plane is in active use, on most hardware that doesn't make sense.

v3: Since commit_planes(active_only = true) is for enabling things only after all the crtc are on we should only look at the new crtc to decide whether to call the plane hooks - if the current CRTC isn't on then skip. If the old crtc (when moving a plane) went down then the plane should have been disabled as part of the pipe shutdown work already. For which there's currently no helper really unfortunately. Also move the check for wether a plane gets a new CRTC assigned while still in active use out of this patch.

Cc Maarten Lankhorst <[email protected]>
Cc Thierry Reding <[email protected]>
Cc Laurent Pinchart <[email protected]>
---
 drivers/gpu/drm/drm_atomic_helper.c    | 20 ++++++++++++++++++--
 drivers/gpu/drm/exynos/exynos_drm_fb.c |  2 +-
 drivers/gpu/drm/msm/msm_atomic.c       |  2 +-
 drivers/gpu/drm/omapdrm/omap_drv.c     |  2 +-
 drivers/gpu/drm/rcar-du/rcar_du_kms.c  |  2 +-
 drivers/gpu/drm/sti/sti_drm_drv.c      |  2 +-
 drivers/gpu/drm/tegra/drm.c            |  2 +-
 include/drm/drm_atomic_helper.h        |  3 ++-
 8 files changed, 26 insertions(+), 9 deletions(-)
drivers/gpu/drm/drm_atomic_helper.c +12 -2
index 0b475fae067d..6be0adb5a0e9 100644
@@ -1029,7 +1029,7 @@ int drm_atomic_helper_commit(struct drm_device *dev,
 
 	drm_atomic_helper_commit_modeset_disables(dev, state);
 
-	drm_atomic_helper_commit_planes(dev, state);
+	drm_atomic_helper_commit_planes(dev, state, false);
 
 	drm_atomic_helper_commit_modeset_enables(dev, state);
 
@@ -1144,10 +1144,16 @@ fail:
 }
 EXPORT_SYMBOL(drm_atomic_helper_prepare_planes);
 
+bool plane_crtc_active(struct drm_plane_state *state)
+{
+	return state->crtc && state->crtc->state->active;
+}
+
 /**
  * drm_atomic_helper_commit_planes - commit plane state
  * @dev: DRM device
  * @old_state: atomic state object with old state structures
+ * @active_only: Only commit on active CRTC if set
  *
  * This function commits the new plane state using the plane and atomic helper
  * functions for planes and crtcs. It assumes that the atomic state has already
@@ -1162,7 +1168,8 @@ EXPORT_SYMBOL(drm_atomic_helper_prepare_planes);
  * drm_atomic_helper_commit_planes_on_crtc() instead.
  */
 void drm_atomic_helper_commit_planes(struct drm_device *dev,
-				     struct drm_atomic_state *old_state)
+				     struct drm_atomic_state *old_state,
+				     bool active_only)
 {
 	struct drm_crtc *crtc;
 	struct drm_crtc_state *old_crtc_state;
@@ -1178,6 +1185,9 @@ void drm_atomic_helper_commit_planes(struct drm_device *dev,
 		if (!funcs || !funcs->atomic_begin)
 			continue;
 
+		if (active_only && !crtc->state->active)
+			continue;
+
 		funcs->atomic_begin(crtc, old_crtc_state);
 	}
 

drivers/gpu/drm/drm_atomic_helper.c void drm_atomic_helper_commit_planes(struct drm_device *dev, · line 1207

Quoted 9 lines
drivers/gpu/drm/drm_atomic_helper.c +3 -0
@@ -1189,6 +1199,9 @@ void drm_atomic_helper_commit_planes(struct drm_device *dev,
 		if (!funcs)
 			continue;
 
+		if (active_only && !plane_crtc_active(plane->state))
+			continue;
+
 		/*
 		 * Special-case disabling the plane if drivers support it.
 		 */

This would leave a plane active if it was moved from a active crtc to a inactive crtc, you would still need to call the atomic_disable(plane) callback for that one. ;-)

~Maarten

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

#20 lore raw

PATCH 1/1 drm/atomic-helper: Add option to update planes only on active crtc

In reply to Daniel Vetter

With drivers supporting runtime pm it's generally not a good idea to touch the hardware when it's off. Add an option to the commit_planes helper to support this case.

Note that the helpers already add all planes on a crtc when a modeset happens, hence plane updates will not be lost if drivers set this to true.

v2: Check for NULL state->crtc before chasing the pointer. Also check both old and new crtc if there's a switch. Finally just outright disallow switching crtcs for a plane if the plane is in active use, on most hardware that doesn't make sense.

v3: Since commit_planes(active_only = true) is for enabling things only after all the crtc are on we should only look at the new crtc to decide whether to call the plane hooks - if the current CRTC isn't on then skip. If the old crtc (when moving a plane) went down then the plane should have been disabled as part of the pipe shutdown work already. For which there's currently no helper really unfortunately. Also move the check for wether a plane gets a new CRTC assigned while still in active use out of this patch.

Cc Maarten Lankhorst <[email protected]>
Cc Thierry Reding <[email protected]>
Cc Laurent Pinchart <[email protected]>
---
 drivers/gpu/drm/drm_atomic_helper.c    | 20 ++++++++++++++++++--
 drivers/gpu/drm/exynos/exynos_drm_fb.c |  2 +-
 drivers/gpu/drm/msm/msm_atomic.c       |  2 +-
 drivers/gpu/drm/omapdrm/omap_drv.c     |  2 +-
 drivers/gpu/drm/rcar-du/rcar_du_kms.c  |  2 +-
 drivers/gpu/drm/sti/sti_drv.c          |  2 +-
 drivers/gpu/drm/tegra/drm.c            |  2 +-
 include/drm/drm_atomic_helper.h        |  3 ++-
 8 files changed, 26 insertions(+), 9 deletions(-)
drivers/gpu/drm/drm_atomic_helper.c +18 -2
index e0b99302c667..8bfd64f71bc4 100644
@@ -1037,7 +1037,7 @@ int drm_atomic_helper_commit(struct drm_device *dev,
 
 	drm_atomic_helper_commit_modeset_disables(dev, state);
 
-	drm_atomic_helper_commit_planes(dev, state);
+	drm_atomic_helper_commit_planes(dev, state, false);
 
 	drm_atomic_helper_commit_modeset_enables(dev, state);
 
@@ -1152,10 +1152,16 @@ fail:
 }
 EXPORT_SYMBOL(drm_atomic_helper_prepare_planes);
 
+bool plane_crtc_active(struct drm_plane_state *state)
+{
+	return state->crtc && state->crtc->state->active;
+}
+
 /**
  * drm_atomic_helper_commit_planes - commit plane state
  * @dev: DRM device
  * @old_state: atomic state object with old state structures
+ * @active_only: Only commit on active CRTC if set
  *
  * This function commits the new plane state using the plane and atomic helper
  * functions for planes and crtcs. It assumes that the atomic state has already
@@ -1170,7 +1176,8 @@ EXPORT_SYMBOL(drm_atomic_helper_prepare_planes);
  * drm_atomic_helper_commit_planes_on_crtc() instead.
  */
 void drm_atomic_helper_commit_planes(struct drm_device *dev,
-				     struct drm_atomic_state *old_state)
+				     struct drm_atomic_state *old_state,
+				     bool active_only)
 {
 	struct drm_crtc *crtc;
 	struct drm_crtc_state *old_crtc_state;
@@ -1186,6 +1193,9 @@ void drm_atomic_helper_commit_planes(struct drm_device *dev,
 		if (!funcs || !funcs->atomic_begin)
 			continue;
 
+		if (active_only && !crtc->state->active)
+			continue;
+
 		funcs->atomic_begin(crtc, old_crtc_state);
 	}
 
@@ -1197,6 +1207,9 @@ void drm_atomic_helper_commit_planes(struct drm_device *dev,
 		if (!funcs)
 			continue;
 
+		if (active_only && !plane_crtc_active(plane->state))
+			continue;
+
 		/*
 		 * Special-case disabling the plane if drivers support it.
 		 */
@@ -1216,6 +1229,9 @@ void drm_atomic_helper_commit_planes(struct drm_device *dev,
 		if (!funcs || !funcs->atomic_flush)
 			continue;
 
+		if (active_only && !crtc->state->active)
+			continue;
+
 		funcs->atomic_flush(crtc, old_crtc_state);
 	}
 }
drivers/gpu/drm/exynos/exynos_drm_fb.c +1 -1
index 9738f4e0c6eb..2e1f7143174c 100644
@@ -293,7 +293,7 @@ static int exynos_atomic_commit(struct drm_device *dev,
 	 * have the relevant clocks enabled to perform the update.
 	 */
 
-	drm_atomic_helper_commit_planes(dev, state);
+	drm_atomic_helper_commit_planes(dev, state, false);
 
 	drm_atomic_helper_cleanup_planes(dev, state);
 
drivers/gpu/drm/msm/msm_atomic.c +1 -1
index 1ceb4f22dd89..7eb253bc24df 100644
@@ -125,7 +125,7 @@ static void complete_commit(struct msm_commit *c)
 
 	drm_atomic_helper_commit_modeset_disables(dev, state);
 
-	drm_atomic_helper_commit_planes(dev, state);
+	drm_atomic_helper_commit_planes(dev, state, false);
 
 	drm_atomic_helper_commit_modeset_enables(dev, state);
 
drivers/gpu/drm/omapdrm/omap_drv.c +1 -1
index e888a831dd3c..0ecce79fc782 100644
@@ -96,7 +96,7 @@ static void omap_atomic_complete(struct omap_atomic_state_commit *commit)
 	dispc_runtime_get();
 
 	drm_atomic_helper_commit_modeset_disables(dev, old_state);
-	drm_atomic_helper_commit_planes(dev, old_state);
+	drm_atomic_helper_commit_planes(dev, old_state, false);
 	drm_atomic_helper_commit_modeset_enables(dev, old_state);
 
 	omap_atomic_wait_for_completion(dev, old_state);
drivers/gpu/drm/rcar-du/rcar_du_kms.c +1 -1
index 56518eb1269a..ca12e8ca5552 100644
@@ -456,7 +456,7 @@ static void rcar_du_atomic_complete(struct rcar_du_commit *commit)
 	/* Apply the atomic update. */
 	drm_atomic_helper_commit_modeset_disables(dev, old_state);
 	drm_atomic_helper_commit_modeset_enables(dev, old_state);
-	drm_atomic_helper_commit_planes(dev, old_state);
+	drm_atomic_helper_commit_planes(dev, old_state, false);
 
 	drm_atomic_helper_wait_for_vblanks(dev, old_state);
 
drivers/gpu/drm/sti/sti_drv.c +1 -1
index 6f4af6a8ba1b..9f85988a43ce 100644
@@ -59,7 +59,7 @@ static void sti_atomic_complete(struct sti_private *private,
 	 */
 
 	drm_atomic_helper_commit_modeset_disables(drm, state);
-	drm_atomic_helper_commit_planes(drm, state);
+	drm_atomic_helper_commit_planes(drm, state, false);
 	drm_atomic_helper_commit_modeset_enables(drm, state);
 
 	drm_atomic_helper_wait_for_vblanks(drm, state);
drivers/gpu/drm/tegra/drm.c +1 -1
index e7759a7b9f2d..9ba8a988a030 100644
@@ -56,7 +56,7 @@ static void tegra_atomic_complete(struct tegra_drm *tegra,
 	 */
 
 	drm_atomic_helper_commit_modeset_disables(drm, state);
-	drm_atomic_helper_commit_planes(drm, state);
+	drm_atomic_helper_commit_planes(drm, state, false);
 	drm_atomic_helper_commit_modeset_enables(drm, state);
 
 	drm_atomic_helper_wait_for_vblanks(drm, state);
include/drm/drm_atomic_helper.h +2 -1
index 11266d147a29..4ffe9dca07c4 100644
@@ -55,7 +55,8 @@ void drm_atomic_helper_commit_modeset_enables(struct drm_device *dev,
 int drm_atomic_helper_prepare_planes(struct drm_device *dev,
 				     struct drm_atomic_state *state);
 void drm_atomic_helper_commit_planes(struct drm_device *dev,
-				     struct drm_atomic_state *state);
+				     struct drm_atomic_state *state,
+				     bool active_only);
 void drm_atomic_helper_cleanup_planes(struct drm_device *dev,
 				      struct drm_atomic_state *old_state);
 void drm_atomic_helper_commit_planes_on_crtc(struct drm_crtc_state *old_crtc_state);
Signature · 6 lines
2.5.0

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

PATCH 1/1 drm/atomic-helper: Add option to update planes only on active crtc

With drivers supporting runtime pm it's generally not a good idea to touch the hardware when it's off. Add an option to the commit_planes helper to support this case.

Note that the helpers already add all planes on a crtc when a modeset happens, hence plane updates will not be lost if drivers set this to true.

v2: Check for NULL state->crtc before chasing the pointer. Also check both old and new crtc if there's a switch. Finally just outright disallow switching crtcs for a plane if the plane is in active use, on most hardware that doesn't make sense.

v3: Since commit_planes(active_only = true) is for enabling things only after all the crtc are on we should only look at the new crtc to decide whether to call the plane hooks - if the current CRTC isn't on then skip. If the old crtc (when moving a plane) went down then the plane should have been disabled as part of the pipe shutdown work already. For which there's currently no helper really unfortunately. Also move the check for wether a plane gets a new CRTC assigned while still in active use out of this patch.

v4: Rebase over exynos changes.

Cc Maarten Lankhorst <[email protected]>
Cc Thierry Reding <[email protected]>
Cc Laurent Pinchart <[email protected]>
---
 drivers/gpu/drm/drm_atomic_helper.c     | 20 ++++++++++++++++++--
 drivers/gpu/drm/exynos/exynos_drm_drv.c |  2 +-
 drivers/gpu/drm/msm/msm_atomic.c        |  2 +-
 drivers/gpu/drm/omapdrm/omap_drv.c      |  2 +-
 drivers/gpu/drm/rcar-du/rcar_du_kms.c   |  2 +-
 drivers/gpu/drm/sti/sti_drv.c           |  2 +-
 drivers/gpu/drm/tegra/drm.c             |  2 +-
 include/drm/drm_atomic_helper.h         |  3 ++-
 8 files changed, 26 insertions(+), 9 deletions(-)
drivers/gpu/drm/drm_atomic_helper.c +18 -2
index 9b0c47690ae8..12c25c54309f 100644
@@ -1037,7 +1037,7 @@ int drm_atomic_helper_commit(struct drm_device *dev,
 
 	drm_atomic_helper_commit_modeset_disables(dev, state);
 
-	drm_atomic_helper_commit_planes(dev, state);
+	drm_atomic_helper_commit_planes(dev, state, false);
 
 	drm_atomic_helper_commit_modeset_enables(dev, state);
 
@@ -1146,10 +1146,16 @@ fail:
 }
 EXPORT_SYMBOL(drm_atomic_helper_prepare_planes);
 
+bool plane_crtc_active(struct drm_plane_state *state)
+{
+	return state->crtc && state->crtc->state->active;
+}
+
 /**
  * drm_atomic_helper_commit_planes - commit plane state
  * @dev: DRM device
  * @old_state: atomic state object with old state structures
+ * @active_only: Only commit on active CRTC if set
  *
  * This function commits the new plane state using the plane and atomic helper
  * functions for planes and crtcs. It assumes that the atomic state has already
@@ -1164,7 +1170,8 @@ EXPORT_SYMBOL(drm_atomic_helper_prepare_planes);
  * drm_atomic_helper_commit_planes_on_crtc() instead.
  */
 void drm_atomic_helper_commit_planes(struct drm_device *dev,
-				     struct drm_atomic_state *old_state)
+				     struct drm_atomic_state *old_state,
+				     bool active_only)
 {
 	struct drm_crtc *crtc;
 	struct drm_crtc_state *old_crtc_state;
@@ -1180,6 +1187,9 @@ void drm_atomic_helper_commit_planes(struct drm_device *dev,
 		if (!funcs || !funcs->atomic_begin)
 			continue;
 
+		if (active_only && !crtc->state->active)
+			continue;
+
 		funcs->atomic_begin(crtc, old_crtc_state);
 	}
 
@@ -1191,6 +1201,9 @@ void drm_atomic_helper_commit_planes(struct drm_device *dev,
 		if (!funcs)
 			continue;
 
+		if (active_only && !plane_crtc_active(plane->state))
+			continue;
+
 		/*
 		 * Special-case disabling the plane if drivers support it.
 		 */
@@ -1210,6 +1223,9 @@ void drm_atomic_helper_commit_planes(struct drm_device *dev,
 		if (!funcs || !funcs->atomic_flush)
 			continue;
 
+		if (active_only && !crtc->state->active)
+			continue;
+
 		funcs->atomic_flush(crtc, old_crtc_state);
 	}
 }
drivers/gpu/drm/exynos/exynos_drm_drv.c +1 -1
index c1ed308496a2..632e21e0d1be 100644
@@ -105,7 +105,7 @@ static void exynos_atomic_commit_complete(struct exynos_atomic_commit *commit)
 		atomic_inc(&exynos_crtc->pending_update);
 	}
 
-	drm_atomic_helper_commit_planes(dev, state);
+	drm_atomic_helper_commit_planes(dev, state, false);
 
 	exynos_atomic_wait_for_commit(state);
 
drivers/gpu/drm/msm/msm_atomic.c +1 -1
index 1ceb4f22dd89..7eb253bc24df 100644
@@ -125,7 +125,7 @@ static void complete_commit(struct msm_commit *c)
 
 	drm_atomic_helper_commit_modeset_disables(dev, state);
 
-	drm_atomic_helper_commit_planes(dev, state);
+	drm_atomic_helper_commit_planes(dev, state, false);
 
 	drm_atomic_helper_commit_modeset_enables(dev, state);
 
drivers/gpu/drm/omapdrm/omap_drv.c +1 -1
index e888a831dd3c..0ecce79fc782 100644
@@ -96,7 +96,7 @@ static void omap_atomic_complete(struct omap_atomic_state_commit *commit)
 	dispc_runtime_get();
 
 	drm_atomic_helper_commit_modeset_disables(dev, old_state);
-	drm_atomic_helper_commit_planes(dev, old_state);
+	drm_atomic_helper_commit_planes(dev, old_state, false);
 	drm_atomic_helper_commit_modeset_enables(dev, old_state);
 
 	omap_atomic_wait_for_completion(dev, old_state);
drivers/gpu/drm/rcar-du/rcar_du_kms.c +1 -1
index 56518eb1269a..ca12e8ca5552 100644
@@ -456,7 +456,7 @@ static void rcar_du_atomic_complete(struct rcar_du_commit *commit)
 	/* Apply the atomic update. */
 	drm_atomic_helper_commit_modeset_disables(dev, old_state);
 	drm_atomic_helper_commit_modeset_enables(dev, old_state);
-	drm_atomic_helper_commit_planes(dev, old_state);
+	drm_atomic_helper_commit_planes(dev, old_state, false);
 
 	drm_atomic_helper_wait_for_vblanks(dev, old_state);
 
drivers/gpu/drm/sti/sti_drv.c +1 -1
index 6f4af6a8ba1b..9f85988a43ce 100644
@@ -59,7 +59,7 @@ static void sti_atomic_complete(struct sti_private *private,
 	 */
 
 	drm_atomic_helper_commit_modeset_disables(drm, state);
-	drm_atomic_helper_commit_planes(drm, state);
+	drm_atomic_helper_commit_planes(drm, state, false);
 	drm_atomic_helper_commit_modeset_enables(drm, state);
 
 	drm_atomic_helper_wait_for_vblanks(drm, state);
drivers/gpu/drm/tegra/drm.c +1 -1
index e7759a7b9f2d..9ba8a988a030 100644
@@ -56,7 +56,7 @@ static void tegra_atomic_complete(struct tegra_drm *tegra,
 	 */
 
 	drm_atomic_helper_commit_modeset_disables(drm, state);
-	drm_atomic_helper_commit_planes(drm, state);
+	drm_atomic_helper_commit_planes(drm, state, false);
 	drm_atomic_helper_commit_modeset_enables(drm, state);
 
 	drm_atomic_helper_wait_for_vblanks(drm, state);
include/drm/drm_atomic_helper.h +2 -1
index 11266d147a29..4ffe9dca07c4 100644
@@ -55,7 +55,8 @@ void drm_atomic_helper_commit_modeset_enables(struct drm_device *dev,
 int drm_atomic_helper_prepare_planes(struct drm_device *dev,
 				     struct drm_atomic_state *state);
 void drm_atomic_helper_commit_planes(struct drm_device *dev,
-				     struct drm_atomic_state *state);
+				     struct drm_atomic_state *state,
+				     bool active_only);
 void drm_atomic_helper_cleanup_planes(struct drm_device *dev,
 				      struct drm_atomic_state *old_state);
 void drm_atomic_helper_commit_planes_on_crtc(struct drm_crtc_state *old_crtc_state);
Signature · 6 lines
2.5.1

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
Reviewed-by Tested-by on v1 1/1
#22 lore raw
Quoted 28 lines · Daniel Vetter

With drivers supporting runtime pm it's generally not a good idea to touch the hardware when it's off. Add an option to the commit_planes helper to support this case.

Note that the helpers already add all planes on a crtc when a modeset happens, hence plane updates will not be lost if drivers set this to true.

v2: Check for NULL state->crtc before chasing the pointer. Also check both old and new crtc if there's a switch. Finally just outright disallow switching crtcs for a plane if the plane is in active use, on most hardware that doesn't make sense.

v3: Since commit_planes(active_only = true) is for enabling things only after all the crtc are on we should only look at the new crtc to decide whether to call the plane hooks - if the current CRTC isn't on then skip. If the old crtc (when moving a plane) went down then the plane should have been disabled as part of the pipe shutdown work already. For which there's currently no helper really unfortunately. Also move the check for wether a plane gets a new CRTC assigned while still in active use out of this patch.

v4: Rebase over exynos changes.

Cc Maarten Lankhorst <[email protected]>
Cc Thierry Reding <[email protected]>
Cc Laurent Pinchart <[email protected]>
Quoted 10 lines
---
 drivers/gpu/drm/drm_atomic_helper.c     | 20 ++++++++++++++++++--
 drivers/gpu/drm/exynos/exynos_drm_drv.c |  2 +-
 drivers/gpu/drm/msm/msm_atomic.c        |  2 +-
 drivers/gpu/drm/omapdrm/omap_drv.c      |  2 +-
 drivers/gpu/drm/rcar-du/rcar_du_kms.c   |  2 +-
 drivers/gpu/drm/sti/sti_drv.c           |  2 +-
 drivers/gpu/drm/tegra/drm.c             |  2 +-
 include/drm/drm_atomic_helper.h         |  3 ++-
 8 files changed, 26 insertions(+), 9 deletions(-)

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

#23 lore raw
Quoted 40 lines · Thierry Reding
Quoted 28 lines · Daniel Vetter

With drivers supporting runtime pm it's generally not a good idea to touch the hardware when it's off. Add an option to the commit_planes helper to support this case.

Note that the helpers already add all planes on a crtc when a modeset happens, hence plane updates will not be lost if drivers set this to true.

v2: Check for NULL state->crtc before chasing the pointer. Also check both old and new crtc if there's a switch. Finally just outright disallow switching crtcs for a plane if the plane is in active use, on most hardware that doesn't make sense.

v3: Since commit_planes(active_only = true) is for enabling things only after all the crtc are on we should only look at the new crtc to decide whether to call the plane hooks - if the current CRTC isn't on then skip. If the old crtc (when moving a plane) went down then the plane should have been disabled as part of the pipe shutdown work already. For which there's currently no helper really unfortunately. Also move the check for wether a plane gets a new CRTC assigned while still in active use out of this patch.

v4: Rebase over exynos changes.

Cc Maarten Lankhorst <[email protected]>
Cc Thierry Reding <[email protected]>
Cc Laurent Pinchart <[email protected]>
Quoted 10 lines
---
 drivers/gpu/drm/drm_atomic_helper.c     | 20 ++++++++++++++++++--
 drivers/gpu/drm/exynos/exynos_drm_drv.c |  2 +-
 drivers/gpu/drm/msm/msm_atomic.c        |  2 +-
 drivers/gpu/drm/omapdrm/omap_drv.c      |  2 +-
 drivers/gpu/drm/rcar-du/rcar_du_kms.c   |  2 +-
 drivers/gpu/drm/sti/sti_drv.c           |  2 +-
 drivers/gpu/drm/tegra/drm.c             |  2 +-
 include/drm/drm_atomic_helper.h         |  3 ++-
 8 files changed, 26 insertions(+), 9 deletions(-)
Quoted 2 lines

Applied to drm-misc, thanks for the review.
-Daniel

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

Hi Daniel,

Thank you for the patch.

Quoted 69 lines · On Tuesday 08 September 2015 12:02:07 Daniel Vetter wrote:

With drivers supporting runtime pm it's generally not a good idea to touch the hardware when it's off. Add an option to the commit_planes helper to support this case.

Note that the helpers already add all planes on a crtc when a modeset happens, hence plane updates will not be lost if drivers set this to true.

v2: Check for NULL state->crtc before chasing the pointer. Also check both old and new crtc if there's a switch. Finally just outright disallow switching crtcs for a plane if the plane is in active use, on most hardware that doesn't make sense.

v3: Since commit_planes(active_only = true) is for enabling things only after all the crtc are on we should only look at the new crtc to decide whether to call the plane hooks - if the current CRTC isn't on then skip. If the old crtc (when moving a plane) went down then the plane should have been disabled as part of the pipe shutdown work already. For which there's currently no helper really unfortunately. Also move the check for wether a plane gets a new CRTC assigned while still in active use out of this patch.

v4: Rebase over exynos changes.

Cc Maarten Lankhorst <[email protected]>
Cc Thierry Reding <[email protected]>
Cc Laurent Pinchart <[email protected]>
---
 drivers/gpu/drm/drm_atomic_helper.c     | 20 ++++++++++++++++++--
 drivers/gpu/drm/exynos/exynos_drm_drv.c |  2 +-
 drivers/gpu/drm/msm/msm_atomic.c        |  2 +-
 drivers/gpu/drm/omapdrm/omap_drv.c      |  2 +-
 drivers/gpu/drm/rcar-du/rcar_du_kms.c   |  2 +-
 drivers/gpu/drm/sti/sti_drv.c           |  2 +-
 drivers/gpu/drm/tegra/drm.c             |  2 +-
 include/drm/drm_atomic_helper.h         |  3 ++-
 8 files changed, 26 insertions(+), 9 deletions(-)
(quoted diff) +0 -0

b/drivers/gpu/drm/drm_atomic_helper.c index 9b0c47690ae8..12c25c54309f 100644

drivers/gpu/drm/drm_atomic_helper.c +7 -1
@@ -1037,7 +1037,7 @@ int drm_atomic_helper_commit(struct drm_device *dev,
 
 	drm_atomic_helper_commit_modeset_disables(dev, state);
 
-	drm_atomic_helper_commit_planes(dev, state);
+	drm_atomic_helper_commit_planes(dev, state, false);
 
 	drm_atomic_helper_commit_modeset_enables(dev, state);
 
@@ -1146,10 +1146,16 @@ fail:
 }
 EXPORT_SYMBOL(drm_atomic_helper_prepare_planes);
 
+bool plane_crtc_active(struct drm_plane_state *state)
+{
+	return state->crtc && state->crtc->state->active;
+}
+
 /**
  * drm_atomic_helper_commit_planes - commit plane state
  * @dev: DRM device
  * @old_state: atomic state object with old state structures
+ * @active_only: Only commit on active CRTC if set
  *
  * This function commits the new plane state using the plane and atomic
Quoted 3 lines

helper
* functions for planes and crtcs. It assumes that the atomic state has
already

Following our recent discussion on the subject, I believe some more documentation would be helpful in the form of guidelines for driver developers. Most drivers using the atomic helpers shouldn't need to be notified of plane state update for disabled CRTC, as the DRM core will record the plane state and apply it when the CRTC gets enabled.

Quoted 138 lines
drivers/gpu/drm/drm_atomic_helper.c +0 -0
@@ -1164,7 +1170,8 @@

EXPORT_SYMBOL(drm_atomic_helper_prepare_planes); * drm_atomic_helper_commit_planes_on_crtc() instead.
*/
void drm_atomic_helper_commit_planes(struct drm_device *dev,

drivers/gpu/drm/drm_atomic_helper.c +11 -1
-				     struct drm_atomic_state *old_state)
+				     struct drm_atomic_state *old_state,
+				     bool active_only)
 {
 	struct drm_crtc *crtc;
 	struct drm_crtc_state *old_crtc_state;
@@ -1180,6 +1187,9 @@ void drm_atomic_helper_commit_planes(struct drm_device
 *dev, if (!funcs || !funcs->atomic_begin)
 			continue;
 
+		if (active_only && !crtc->state->active)
+			continue;
+
 		funcs->atomic_begin(crtc, old_crtc_state);
 	}
 
@@ -1191,6 +1201,9 @@ void drm_atomic_helper_commit_planes(struct drm_device
 *dev, if (!funcs)
 			continue;
 
+		if (active_only && !plane_crtc_active(plane->state))
+			continue;
+
 		/*
 		 * Special-case disabling the plane if drivers support it.
 		 */
@@ -1210,6 +1223,9 @@ void drm_atomic_helper_commit_planes(struct drm_device
 *dev, if (!funcs || !funcs->atomic_flush)
 			continue;
 
+		if (active_only && !crtc->state->active)
+			continue;
+
 		funcs->atomic_flush(crtc, old_crtc_state);
 	}
 }
(quoted diff) +0 -0

b/drivers/gpu/drm/exynos/exynos_drm_drv.c index c1ed308496a2..632e21e0d1be 100644

drivers/gpu/drm/exynos/exynos_drm_drv.c +1 -1
@@ -105,7 +105,7 @@ static void exynos_atomic_commit_complete(struct
 exynos_atomic_commit *commit) atomic_inc(&exynos_crtc->pending_update);
 	}
 
-	drm_atomic_helper_commit_planes(dev, state);
+	drm_atomic_helper_commit_planes(dev, state, false);
 
 	exynos_atomic_wait_for_commit(state);
 
(quoted diff) +0 -0

b/drivers/gpu/drm/msm/msm_atomic.c index 1ceb4f22dd89..7eb253bc24df 100644

drivers/gpu/drm/msm/msm_atomic.c +1 -1
@@ -125,7 +125,7 @@ static void complete_commit(struct msm_commit *c)
 
 	drm_atomic_helper_commit_modeset_disables(dev, state);
 
-	drm_atomic_helper_commit_planes(dev, state);
+	drm_atomic_helper_commit_planes(dev, state, false);
 
 	drm_atomic_helper_commit_modeset_enables(dev, state);
 
(quoted diff) +0 -0

b/drivers/gpu/drm/omapdrm/omap_drv.c index e888a831dd3c..0ecce79fc782 100644

drivers/gpu/drm/omapdrm/omap_drv.c +1 -1
@@ -96,7 +96,7 @@ static void omap_atomic_complete(struct
 omap_atomic_state_commit *commit) dispc_runtime_get();
 
 	drm_atomic_helper_commit_modeset_disables(dev, old_state);
-	drm_atomic_helper_commit_planes(dev, old_state);
+	drm_atomic_helper_commit_planes(dev, old_state, false);
 	drm_atomic_helper_commit_modeset_enables(dev, old_state);
 
 	omap_atomic_wait_for_completion(dev, old_state);
(quoted diff) +0 -0

b/drivers/gpu/drm/rcar-du/rcar_du_kms.c index 56518eb1269a..ca12e8ca5552 100644

drivers/gpu/drm/rcar-du/rcar_du_kms.c +0 -0
@@ -456,7 +456,7 @@ static void rcar_du_atomic_complete(struct

rcar_du_commit *commit) /* Apply the atomic update. */

drivers/gpu/drm/rcar-du/rcar_du_kms.c +1 -1
 	drm_atomic_helper_commit_modeset_disables(dev, old_state);
 	drm_atomic_helper_commit_modeset_enables(dev, old_state);
-	drm_atomic_helper_commit_planes(dev, old_state);
+	drm_atomic_helper_commit_planes(dev, old_state, false);
 
 	drm_atomic_helper_wait_for_vblanks(dev, old_state);
drivers/gpu/drm/sti/sti_drv.c +1 -1
index 6f4af6a8ba1b..9f85988a43ce 100644
@@ -59,7 +59,7 @@ static void sti_atomic_complete(struct sti_private
 *private, */
 
 	drm_atomic_helper_commit_modeset_disables(drm, state);
-	drm_atomic_helper_commit_planes(drm, state);
+	drm_atomic_helper_commit_planes(drm, state, false);
 	drm_atomic_helper_commit_modeset_enables(drm, state);
 
 	drm_atomic_helper_wait_for_vblanks(drm, state);
drivers/gpu/drm/tegra/drm.c +1 -1
index e7759a7b9f2d..9ba8a988a030 100644
@@ -56,7 +56,7 @@ static void tegra_atomic_complete(struct tegra_drm *tegra,
 */
 
 	drm_atomic_helper_commit_modeset_disables(drm, state);
-	drm_atomic_helper_commit_planes(drm, state);
+	drm_atomic_helper_commit_planes(drm, state, false);
 	drm_atomic_helper_commit_modeset_enables(drm, state);
 
 	drm_atomic_helper_wait_for_vblanks(drm, state);
(quoted diff) +0 -0

b/include/drm/drm_atomic_helper.h index 11266d147a29..4ffe9dca07c4 100644

include/drm/drm_atomic_helper.h +0 -0
@@ -55,7 +55,8 @@ void drm_atomic_helper_commit_modeset_enables(struct

drm_device *dev, int drm_atomic_helper_prepare_planes(struct drm_device *dev,

include/drm/drm_atomic_helper.h +2 -1
 				     struct drm_atomic_state *state);
 void drm_atomic_helper_commit_planes(struct drm_device *dev,
-				     struct drm_atomic_state *state);
+				     struct drm_atomic_state *state,
+				     bool active_only);
 void drm_atomic_helper_cleanup_planes(struct drm_device *dev,
 				      struct drm_atomic_state *old_state);
 void drm_atomic_helper_commit_planes_on_crtc(struct drm_crtc_state

*old_crtc_state);

Signature · 8 lines
Regards,

Laurent Pinchart

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel