aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/drm_atomic.c
diff options
context:
space:
mode:
authorRob Clark <robdclark@gmail.com>2014-11-21 15:28:31 -0500
committerDaniel Vetter <daniel.vetter@ffwll.ch>2014-11-27 09:38:15 -0500
commit6ddd388ab222b66b596342becc76d5031c0e2fc8 (patch)
treea13411bc126896dc7a4a61a442657beb02ef59eb /drivers/gpu/drm/drm_atomic.c
parent3009c0377f25c29852b218a6933a969d02cbdc5d (diff)
drm/atomic: track bitmask of planes attached to crtc
Chasing plane->state->crtc of planes that are *not* part of the same atomic update is racy, making it incredibly awkward (or impossible) to do something simple like iterate over all planes and figure out which ones are attached to a crtc. Solve this by adding a bitmask of currently attached planes in the crtc-state. Note that the transitional helpers do not maintain the plane_mask. But they only support the legacy ioctls, which have sufficient brute-force locking around plane updates that they can continue to loop over all planes to see what is attached to a crtc the old way. Signed-off-by: Rob Clark <robdclark@gmail.com> [danvet: - Drop comments about locking in set_crtc_for_plane since they're a bit misleading - we already should hold lock for the current crtc. - Also WARN_ON if get_state on the old crtc fails since that should have been done already. - Squash in fixup to check get_plane_state return value, reported by Dan Carpenter and acked by Rob Clark.] Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Diffstat (limited to 'drivers/gpu/drm/drm_atomic.c')
-rw-r--r--drivers/gpu/drm/drm_atomic.c26
1 files changed, 21 insertions, 5 deletions
diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c
index ba49b5ca822f..ff5f034cc405 100644
--- a/drivers/gpu/drm/drm_atomic.c
+++ b/drivers/gpu/drm/drm_atomic.c
@@ -344,7 +344,8 @@ EXPORT_SYMBOL(drm_atomic_get_connector_state);
344 344
345/** 345/**
346 * drm_atomic_set_crtc_for_plane - set crtc for plane 346 * drm_atomic_set_crtc_for_plane - set crtc for plane
347 * @plane_state: atomic state object for the plane 347 * @state: the incoming atomic state
348 * @plane: the plane whose incoming state to update
348 * @crtc: crtc to use for the plane 349 * @crtc: crtc to use for the plane
349 * 350 *
350 * Changing the assigned crtc for a plane requires us to grab the lock and state 351 * Changing the assigned crtc for a plane requires us to grab the lock and state
@@ -357,20 +358,35 @@ EXPORT_SYMBOL(drm_atomic_get_connector_state);
357 * sequence must be restarted. All other errors are fatal. 358 * sequence must be restarted. All other errors are fatal.
358 */ 359 */
359int 360int
360drm_atomic_set_crtc_for_plane(struct drm_plane_state *plane_state, 361drm_atomic_set_crtc_for_plane(struct drm_atomic_state *state,
361 struct drm_crtc *crtc) 362 struct drm_plane *plane, struct drm_crtc *crtc)
362{ 363{
364 struct drm_plane_state *plane_state =
365 drm_atomic_get_plane_state(state, plane);
363 struct drm_crtc_state *crtc_state; 366 struct drm_crtc_state *crtc_state;
364 367
368 if (WARN_ON(IS_ERR(plane_state)))
369 return PTR_ERR(plane_state);
370
371 if (plane_state->crtc) {
372 crtc_state = drm_atomic_get_crtc_state(plane_state->state,
373 plane_state->crtc);
374 if (WARN_ON(IS_ERR(crtc_state)))
375 return PTR_ERR(crtc_state);
376
377 crtc_state->plane_mask &= ~(1 << drm_plane_index(plane));
378 }
379
380 plane_state->crtc = crtc;
381
365 if (crtc) { 382 if (crtc) {
366 crtc_state = drm_atomic_get_crtc_state(plane_state->state, 383 crtc_state = drm_atomic_get_crtc_state(plane_state->state,
367 crtc); 384 crtc);
368 if (IS_ERR(crtc_state)) 385 if (IS_ERR(crtc_state))
369 return PTR_ERR(crtc_state); 386 return PTR_ERR(crtc_state);
387 crtc_state->plane_mask |= (1 << drm_plane_index(plane));
370 } 388 }
371 389
372 plane_state->crtc = crtc;
373
374 if (crtc) 390 if (crtc)
375 DRM_DEBUG_KMS("Link plane state %p to [CRTC:%d]\n", 391 DRM_DEBUG_KMS("Link plane state %p to [CRTC:%d]\n",
376 plane_state, crtc->base.id); 392 plane_state, crtc->base.id);