Skip to content

Commit d2307de

Browse files
committed
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: Daniel Stone <[email protected]> Reviewed-by: Daniel Vetter <[email protected]> Signed-off-by: Dave Airlie <[email protected]>
1 parent 0955c12 commit d2307de

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

drivers/gpu/drm/drm_atomic.c

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -144,15 +144,7 @@ void drm_atomic_state_default_clear(struct drm_atomic_state *state)
144144
if (!connector)
145145
continue;
146146

147-
/*
148-
* FIXME: Nonblocking commits can race with connector unplugging and
149-
* there's currently nothing that prevents cleanup up state for
150-
* deleted connectors. As long as the callback doesn't look at
151-
* the connector we'll be fine though, so make sure that's the
152-
* case by setting all connector pointers to NULL.
153-
*/
154-
state->connector_states[i]->connector = NULL;
155-
connector->funcs->atomic_destroy_state(NULL,
147+
connector->funcs->atomic_destroy_state(connector,
156148
state->connector_states[i]);
157149
state->connectors[i] = NULL;
158150
state->connector_states[i] = NULL;
@@ -1168,6 +1160,8 @@ drm_atomic_set_crtc_for_connector(struct drm_connector_state *conn_state,
11681160
{
11691161
struct drm_crtc_state *crtc_state;
11701162

1163+
if (crtc)
1164+
drm_connector_reference(conn_state->connector);
11711165
if (conn_state->crtc && conn_state->crtc != crtc) {
11721166
crtc_state = drm_atomic_get_existing_crtc_state(conn_state->state,
11731167
conn_state->crtc);
@@ -1185,6 +1179,8 @@ drm_atomic_set_crtc_for_connector(struct drm_connector_state *conn_state,
11851179
1 << drm_connector_index(conn_state->connector);
11861180
}
11871181

1182+
if (conn_state->crtc)
1183+
drm_connector_unreference(conn_state->connector);
11881184
conn_state->crtc = crtc;
11891185

11901186
if (crtc)

drivers/gpu/drm/drm_atomic_helper.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2762,6 +2762,8 @@ __drm_atomic_helper_connector_duplicate_state(struct drm_connector *connector,
27622762
struct drm_connector_state *state)
27632763
{
27642764
memcpy(state, connector->state, sizeof(*state));
2765+
if (state->crtc)
2766+
drm_connector_reference(connector);
27652767
}
27662768
EXPORT_SYMBOL(__drm_atomic_helper_connector_duplicate_state);
27672769

@@ -2889,6 +2891,8 @@ __drm_atomic_helper_connector_destroy_state(struct drm_connector *connector,
28892891
* state will automatically do the right thing if code is ever added
28902892
* to this function.
28912893
*/
2894+
if (state->crtc)
2895+
drm_connector_unreference(state->connector);
28922896
}
28932897
EXPORT_SYMBOL(__drm_atomic_helper_connector_destroy_state);
28942898

0 commit comments

Comments
 (0)