[PATCH v2 4/4] drm/atomic: Add checks to ensure get_state is not called after swapping.
Maarten Lankhorst
maarten.lankhorst at linux.intel.com
Wed Nov 16 13:58:08 UTC 2016
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 at 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
More information about the dri-devel
mailing list