Skip to content

Commit

Permalink
drm/atomic: Add WARN_ON when state->acquire_ctx is not set.
Browse files Browse the repository at this point in the history
When I was writing an atomic wrapper for rmfb, I ran into the
following backtrace from lockdep:

=============================================
[ INFO: possible recursive locking detected ]
4.5.0-patser+ #4696 Tainted: G     U
---------------------------------------------
kworker/2:2/2608 is trying to acquire lock:
 (crtc_ww_class_mutex){+.+.+.}, at: [<ffffffffc00c9ddc>] drm_modeset_lock+0x7c/0x120 [drm]

but task is already holding lock:
 (crtc_ww_class_mutex){+.+.+.}, at: [<ffffffffc00c98cd>] modeset_backoff+0x8d/0x220 [drm]

other info that might help us debug this:
 Possible unsafe locking scenario:

       CPU0
       ----
  lock(crtc_ww_class_mutex);
  lock(crtc_ww_class_mutex);

 *** DEADLOCK ***

 May be due to missing lock nesting notation

4 locks held by kworker/2:2/2608:
 #0:  ("events"){.+.+.+}, at: [<ffffffff810a5eea>] process_one_work+0x15a/0x6c0
 #1:  ((&arg.work)){+.+.+.}, at: [<ffffffff810a5eea>] process_one_work+0x15a/0x6c0
 #2:  (crtc_ww_class_acquire){+.+.+.}, at: [<ffffffffc004532a>] drm_atomic_helper_remove_fb+0x4a/0x1d0 [drm_kms_helper]
 #3:  (crtc_ww_class_mutex){+.+.+.}, at: [<ffffffffc00c98cd>] modeset_backoff+0x8d/0x220 [drm]

While lockdep probably catches this bug when it happens, it's better
to explicitly warn when state->acquire_ctx is not set.

Signed-off-by: Maarten Lankhorst <[email protected]>
Signed-off-by: Daniel Vetter <[email protected]>
Link: http://patchwork.freedesktop.org/patch/msgid/1462266751-29123-1-git-send-email-maarten.lankhorst@linux.intel.com
  • Loading branch information
mlankhorst authored and Matt Macy committed Aug 12, 2016
1 parent bfb57fe commit 6071e44
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions drivers/gpu/drm/drm_atomic.c
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,8 @@ drm_atomic_get_crtc_state(struct drm_atomic_state *state,
int ret, index = drm_crtc_index(crtc);
struct drm_crtc_state *crtc_state;

WARN_ON(!state->acquire_ctx);

crtc_state = drm_atomic_get_existing_crtc_state(state, crtc);
if (crtc_state)
return crtc_state;
Expand Down Expand Up @@ -623,6 +625,8 @@ drm_atomic_get_plane_state(struct drm_atomic_state *state,
int ret, index = drm_plane_index(plane);
struct drm_plane_state *plane_state;

WARN_ON(!state->acquire_ctx);

plane_state = drm_atomic_get_existing_plane_state(state, plane);
if (plane_state)
return plane_state;
Expand Down Expand Up @@ -891,6 +895,8 @@ drm_atomic_get_connector_state(struct drm_atomic_state *state,
struct drm_mode_config *config = &connector->dev->mode_config;
struct drm_connector_state *connector_state;

WARN_ON(!state->acquire_ctx);

ret = drm_modeset_lock(&config->connection_mutex, state->acquire_ctx);
if (ret)
return ERR_PTR(ret);
Expand Down

0 comments on commit 6071e44

Please sign in to comment.