All of lore.kernel.org
 help / color / mirror / Atom feed
From: Daniel Vetter <daniel.vetter@ffwll.ch>
To: DRI Development <dri-devel@lists.freedesktop.org>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>,
	Intel Graphics Development <intel-gfx@lists.freedesktop.org>,
	Daniel Vetter <daniel.vetter@intel.com>
Subject: [PATCH 3/3] drm/atomic: refuse changing CRTC for planes while active
Date: Wed, 29 Jul 2015 14:01:10 +0200	[thread overview]
Message-ID: <1438171270-11471-3-git-send-email-daniel.vetter@ffwll.ch> (raw)
In-Reply-To: <1438171270-11471-1-git-send-email-daniel.vetter@ffwll.ch>

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 <thierry.reding@gmail.com>
Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
---
 drivers/gpu/drm/drm_atomic.c        | 38 +++++++++++++++++++++++++++++++++++++
 drivers/gpu/drm/drm_atomic_helper.c |  1 +
 2 files changed, 39 insertions(+)

diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c
index 434915448ea0..422183e7ee7d 100644
--- a/drivers/gpu/drm/drm_atomic.c
+++ b/drivers/gpu/drm/drm_atomic.c
@@ -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;
 }
 
diff --git a/drivers/gpu/drm/drm_atomic_helper.c b/drivers/gpu/drm/drm_atomic_helper.c
index 6be0adb5a0e9..54c59ddc59a5 100644
--- a/drivers/gpu/drm/drm_atomic_helper.c
+++ b/drivers/gpu/drm/drm_atomic_helper.c
@@ -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) {
-- 
2.5.0

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel

  parent reply	other threads:[~2015-07-29 12:01 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-29 12:01 [PATCH 1/3] drm/atomic-helper: Add option to update planes only on active crtc Daniel Vetter
2015-07-29 12:01 ` [PATCH 2/3] drm/rcar: Only update planes " Daniel Vetter
2015-07-29 12:01 ` Daniel Vetter [this message]
2015-07-30 10:37   ` [PATCH 3/3] drm/atomic: refuse changing CRTC for planes while active shuang.he
2015-08-26 15:41   ` [PATCH] drm/atomic: refuse changing CRTC for planes directly Daniel Vetter
2015-08-26 15:53     ` [Intel-gfx] " Ville Syrjälä
2015-08-26 16:33       ` Daniel Stone
2015-08-26 16:03     ` Rob Clark
2015-08-26 16:07       ` Rob Clark
2015-08-26 16:30         ` Ville Syrjälä
2015-08-26 17:38           ` Rob Clark
2015-08-26 17:53             ` Ville Syrjälä
2015-08-26 17:58               ` Rob Clark
2015-08-26 19:49     ` Daniel Vetter
2015-08-26 21:51       ` [Intel-gfx] " Rob Clark
2015-08-27  7:45         ` Daniel Vetter
2015-08-27  6:08       ` Maarten Lankhorst
2015-08-31  2:12       ` shuang.he
2015-08-30 21:46     ` shuang.he
2015-07-30 16:28 ` [PATCH 1/3] drm/atomic-helper: Add option to update planes only on active crtc Maarten Lankhorst
2015-08-26 14:02 ` [PATCH] " Daniel Vetter
2015-09-08 10:02   ` Daniel Vetter
2015-09-08 11:10     ` Thierry Reding
2015-09-08 11:50       ` Daniel Vetter
2015-09-08 11:27     ` Laurent Pinchart

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1438171270-11471-3-git-send-email-daniel.vetter@ffwll.ch \
    --to=daniel.vetter@ffwll.ch \
    --cc=daniel.vetter@intel.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=intel-gfx@lists.freedesktop.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.