Commit d2307dea authored by Dave Airlie's avatar Dave Airlie

drm/atomic: use connector references (v3)

Take a reference when setting a crtc on a connecter,
also take one when duplicating if a crtc is set,
and drop one on destroy if a crtc is set.

v2: take Daniel Stone's advice and simplify the
ref/unref dances, also take care of NULL as connector
to state reset.

v3: remove need for connector NULL check.
Reviewed-by: default avatarDaniel Stone <daniels@collabora.com>
Reviewed-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: default avatarDave Airlie <airlied@redhat.com>
parent 0955c125
...@@ -144,15 +144,7 @@ void drm_atomic_state_default_clear(struct drm_atomic_state *state) ...@@ -144,15 +144,7 @@ void drm_atomic_state_default_clear(struct drm_atomic_state *state)
if (!connector) if (!connector)
continue; continue;
/* connector->funcs->atomic_destroy_state(connector,
* FIXME: Nonblocking commits can race with connector unplugging and
* there's currently nothing that prevents cleanup up state for
* deleted connectors. As long as the callback doesn't look at
* the connector we'll be fine though, so make sure that's the
* case by setting all connector pointers to NULL.
*/
state->connector_states[i]->connector = NULL;
connector->funcs->atomic_destroy_state(NULL,
state->connector_states[i]); state->connector_states[i]);
state->connectors[i] = NULL; state->connectors[i] = NULL;
state->connector_states[i] = NULL; state->connector_states[i] = NULL;
...@@ -1168,6 +1160,8 @@ drm_atomic_set_crtc_for_connector(struct drm_connector_state *conn_state, ...@@ -1168,6 +1160,8 @@ drm_atomic_set_crtc_for_connector(struct drm_connector_state *conn_state,
{ {
struct drm_crtc_state *crtc_state; struct drm_crtc_state *crtc_state;
if (crtc)
drm_connector_reference(conn_state->connector);
if (conn_state->crtc && conn_state->crtc != crtc) { if (conn_state->crtc && conn_state->crtc != crtc) {
crtc_state = drm_atomic_get_existing_crtc_state(conn_state->state, crtc_state = drm_atomic_get_existing_crtc_state(conn_state->state,
conn_state->crtc); conn_state->crtc);
...@@ -1185,6 +1179,8 @@ drm_atomic_set_crtc_for_connector(struct drm_connector_state *conn_state, ...@@ -1185,6 +1179,8 @@ drm_atomic_set_crtc_for_connector(struct drm_connector_state *conn_state,
1 << drm_connector_index(conn_state->connector); 1 << drm_connector_index(conn_state->connector);
} }
if (conn_state->crtc)
drm_connector_unreference(conn_state->connector);
conn_state->crtc = crtc; conn_state->crtc = crtc;
if (crtc) if (crtc)
......
...@@ -2762,6 +2762,8 @@ __drm_atomic_helper_connector_duplicate_state(struct drm_connector *connector, ...@@ -2762,6 +2762,8 @@ __drm_atomic_helper_connector_duplicate_state(struct drm_connector *connector,
struct drm_connector_state *state) struct drm_connector_state *state)
{ {
memcpy(state, connector->state, sizeof(*state)); memcpy(state, connector->state, sizeof(*state));
if (state->crtc)
drm_connector_reference(connector);
} }
EXPORT_SYMBOL(__drm_atomic_helper_connector_duplicate_state); EXPORT_SYMBOL(__drm_atomic_helper_connector_duplicate_state);
...@@ -2889,6 +2891,8 @@ __drm_atomic_helper_connector_destroy_state(struct drm_connector *connector, ...@@ -2889,6 +2891,8 @@ __drm_atomic_helper_connector_destroy_state(struct drm_connector *connector,
* state will automatically do the right thing if code is ever added * state will automatically do the right thing if code is ever added
* to this function. * to this function.
*/ */
if (state->crtc)
drm_connector_unreference(state->connector);
} }
EXPORT_SYMBOL(__drm_atomic_helper_connector_destroy_state); EXPORT_SYMBOL(__drm_atomic_helper_connector_destroy_state);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment