Skip to content

Commit

Permalink
drm/atomic: Only destroy connector states with connection mutex held
Browse files Browse the repository at this point in the history
Otherwise the connector might have been unplugged and destroyed while
we didn't look. Yet another fallout from DP MST hotplugging that I
didn't consider.

To make sure we get this right add an appropriate WARN_ON to
drm_atomic_state_clear (obviously only when we actually have a state
to clear up). And reorder all the state_clear and backoff calls to
make it work out properly.

Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Reviewed-by: Rob Clark <robdclark@gmail.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
  • Loading branch information
Daniel Vetter authored and Dave Airlie committed Nov 20, 2014
1 parent c7eb76f commit 6f75cea
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
9 changes: 6 additions & 3 deletions drivers/gpu/drm/drm_atomic.c
Original file line number Diff line number Diff line change
Expand Up @@ -112,21 +112,24 @@ EXPORT_SYMBOL(drm_atomic_state_alloc);
void drm_atomic_state_clear(struct drm_atomic_state *state)
{
struct drm_device *dev = state->dev;
struct drm_mode_config *config = &dev->mode_config;
int i;

DRM_DEBUG_KMS("Clearing atomic state %p\n", state);

for (i = 0; i < dev->mode_config.num_connector; i++) {
for (i = 0; i < config->num_connector; i++) {
struct drm_connector *connector = state->connectors[i];

if (!connector)
continue;

WARN_ON(!drm_modeset_is_locked(&config->connection_mutex));

connector->funcs->atomic_destroy_state(connector,
state->connector_states[i]);
}

for (i = 0; i < dev->mode_config.num_crtc; i++) {
for (i = 0; i < config->num_crtc; i++) {
struct drm_crtc *crtc = state->crtcs[i];

if (!crtc)
Expand All @@ -136,7 +139,7 @@ void drm_atomic_state_clear(struct drm_atomic_state *state)
state->crtc_states[i]);
}

for (i = 0; i < dev->mode_config.num_total_plane; i++) {
for (i = 0; i < config->num_total_plane; i++) {
struct drm_plane *plane = state->planes[i];

if (!plane)
Expand Down
14 changes: 7 additions & 7 deletions drivers/gpu/drm/drm_atomic_helper.c
Original file line number Diff line number Diff line change
Expand Up @@ -1217,8 +1217,8 @@ int drm_atomic_helper_update_plane(struct drm_plane *plane,

return ret;
backoff:
drm_atomic_legacy_backoff(state);
drm_atomic_state_clear(state);
drm_atomic_legacy_backoff(state);

/*
* Someone might have exchanged the framebuffer while we dropped locks
Expand Down Expand Up @@ -1285,8 +1285,8 @@ int drm_atomic_helper_disable_plane(struct drm_plane *plane)

return ret;
backoff:
drm_atomic_legacy_backoff(state);
drm_atomic_state_clear(state);
drm_atomic_legacy_backoff(state);

/*
* Someone might have exchanged the framebuffer while we dropped locks
Expand Down Expand Up @@ -1462,8 +1462,8 @@ int drm_atomic_helper_set_config(struct drm_mode_set *set)

return ret;
backoff:
drm_atomic_legacy_backoff(state);
drm_atomic_state_clear(state);
drm_atomic_legacy_backoff(state);

/*
* Someone might have exchanged the framebuffer while we dropped locks
Expand Down Expand Up @@ -1528,8 +1528,8 @@ drm_atomic_helper_crtc_set_property(struct drm_crtc *crtc,

return ret;
backoff:
drm_atomic_legacy_backoff(state);
drm_atomic_state_clear(state);
drm_atomic_legacy_backoff(state);

goto retry;
}
Expand Down Expand Up @@ -1587,8 +1587,8 @@ drm_atomic_helper_plane_set_property(struct drm_plane *plane,

return ret;
backoff:
drm_atomic_legacy_backoff(state);
drm_atomic_state_clear(state);
drm_atomic_legacy_backoff(state);

goto retry;
}
Expand Down Expand Up @@ -1646,8 +1646,8 @@ drm_atomic_helper_connector_set_property(struct drm_connector *connector,

return ret;
backoff:
drm_atomic_legacy_backoff(state);
drm_atomic_state_clear(state);
drm_atomic_legacy_backoff(state);

goto retry;
}
Expand Down Expand Up @@ -1725,8 +1725,8 @@ int drm_atomic_helper_page_flip(struct drm_crtc *crtc,

return ret;
backoff:
drm_atomic_legacy_backoff(state);
drm_atomic_state_clear(state);
drm_atomic_legacy_backoff(state);

/*
* Someone might have exchanged the framebuffer while we dropped locks
Expand Down

0 comments on commit 6f75cea

Please sign in to comment.