dri-devel.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
From: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
To: dri-devel@lists.freedesktop.org
Subject: [PATCH v2 4/4] drm/atomic: Add checks to ensure get_state is not called after swapping.
Date: Wed, 16 Nov 2016 14:58:08 +0100	[thread overview]
Message-ID: <1479304688-24010-5-git-send-email-maarten.lankhorst@linux.intel.com> (raw)
In-Reply-To: <1479304688-24010-1-git-send-email-maarten.lankhorst@linux.intel.com>

This isn't allowed, callers should use get_new_state or get_old_state,
but lets be paranoid..

Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
---
 drivers/gpu/drm/drm_atomic.c | 18 +++++++++++++++---
 1 file changed, 15 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c
index e80663154858..81080e37091d 100644
--- a/drivers/gpu/drm/drm_atomic.c
+++ b/drivers/gpu/drm/drm_atomic.c
@@ -267,8 +267,12 @@ drm_atomic_get_crtc_state(struct drm_atomic_state *state,
 	WARN_ON(!state->acquire_ctx);
 
 	crtc_state = drm_atomic_get_existing_crtc_state(state, crtc);
-	if (crtc_state)
+	if (crtc_state) {
+		WARN(state->crtcs[index].state == state->crtcs[index].old_state,
+		     "drm_atomic_get_crtc_state() used after swapping state!\n");
+
 		return crtc_state;
+	}
 
 	ret = drm_modeset_lock(&crtc->mutex, state->acquire_ctx);
 	if (ret)
@@ -655,8 +659,12 @@ drm_atomic_get_plane_state(struct drm_atomic_state *state,
 	WARN_ON(!state->acquire_ctx);
 
 	plane_state = drm_atomic_get_existing_plane_state(state, plane);
-	if (plane_state)
+	if (plane_state) {
+		WARN(state->planes[index].state == state->planes[index].old_state,
+		     "drm_atomic_get_plane_state() used after swapping state!\n");
+
 		return plane_state;
+	}
 
 	ret = drm_modeset_lock(&plane->mutex, state->acquire_ctx);
 	if (ret)
@@ -988,8 +996,12 @@ drm_atomic_get_connector_state(struct drm_atomic_state *state,
 		state->num_connector = alloc;
 	}
 
-	if (state->connectors[index].state)
+	if (state->connectors[index].state) {
+		WARN(state->connectors[index].state == state->connectors[index].old_state,
+		     "drm_atomic_get_connector_state() used after swapping state!\n");
+
 		return state->connectors[index].state;
+	}
 
 	connector_state = connector->funcs->atomic_duplicate_state(connector);
 	if (!connector_state)
-- 
2.7.4

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

  parent reply	other threads:[~2016-11-16 13:58 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-16 13:58 [PATCH v2 0/4] drm/atomic: Add accessor macros for all atomic state Maarten Lankhorst
2016-11-16 13:58 ` [PATCH v2 1/4] drm/atomic: Add new iterators over all state, v2 Maarten Lankhorst
2016-11-16 13:58 ` [PATCH v2 2/4] drm/atomic: Add accessor macros for the current state Maarten Lankhorst
2016-11-16 14:35   ` Ville Syrjälä
2016-11-16 15:04     ` Daniel Vetter
2016-11-16 16:11       ` Maarten Lankhorst
2016-11-16 16:26         ` Daniel Vetter
2016-11-16 16:32         ` Ville Syrjälä
2016-11-17 11:58           ` Maarten Lankhorst
2016-11-17 12:26             ` Ville Syrjälä
2016-11-17 12:42               ` Maarten Lankhorst
2016-11-17 12:50                 ` Ville Syrjälä
2016-11-17 13:20                   ` [PATCH v2.1 2/4] drm/atomic: Add accessor macros for the current state, v2 Maarten Lankhorst
2016-12-09 22:27                     ` Daniel Vetter
2016-12-14 13:15                     ` Daniel Vetter
2016-12-15 10:24                       ` [PATCH v2.2 2/4] drm/atomic: Add accessor macros for the current state, v3 Maarten Lankhorst
2016-11-16 13:58 ` [PATCH v2 3/4] drm/atomic: Add macros to access existing old/new state Maarten Lankhorst
2016-12-28 14:25   ` Daniel Vetter
2016-11-16 13:58 ` Maarten Lankhorst [this message]
2016-11-16 14:18 ` [PATCH v2 0/4] drm/atomic: Add accessor macros for all atomic state Daniel Vetter
2016-11-16 16:11   ` Maarten Lankhorst
2016-11-16 16:27     ` Daniel Vetter
2016-12-14 13:17 ` Daniel Vetter
2016-12-15  9:19   ` Maarten Lankhorst

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=1479304688-24010-5-git-send-email-maarten.lankhorst@linux.intel.com \
    --to=maarten.lankhorst@linux.intel.com \
    --cc=dri-devel@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).