diff options
author | Dave Airlie <airlied@redhat.com> | 2016-04-26 21:27:39 -0400 |
---|---|---|
committer | Dave Airlie <airlied@redhat.com> | 2016-05-04 22:52:05 -0400 |
commit | d2307dea14a4f14a4b5db01b6d40a30fa6117e6c (patch) | |
tree | e9aa6cf0376a35ab1f19fd4c0e31aa4491433cd5 | |
parent | 0955c1250e9699b3bdc633d778710d219c61df66 (diff) |
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 <daniels@collabora.com>
Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Dave Airlie <airlied@redhat.com>
-rw-r--r-- | drivers/gpu/drm/drm_atomic.c | 14 | ||||
-rw-r--r-- | drivers/gpu/drm/drm_atomic_helper.c | 4 |
2 files changed, 9 insertions, 9 deletions
diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c index e4879d34c280..86e89db02ed7 100644 --- a/drivers/gpu/drm/drm_atomic.c +++ b/drivers/gpu/drm/drm_atomic.c | |||
@@ -144,15 +144,7 @@ void drm_atomic_state_default_clear(struct drm_atomic_state *state) | |||
144 | if (!connector) | 144 | if (!connector) |
145 | continue; | 145 | continue; |
146 | 146 | ||
147 | /* | 147 | connector->funcs->atomic_destroy_state(connector, |
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, | ||
156 | state->connector_states[i]); | 148 | state->connector_states[i]); |
157 | state->connectors[i] = NULL; | 149 | state->connectors[i] = NULL; |
158 | state->connector_states[i] = NULL; | 150 | state->connector_states[i] = NULL; |
@@ -1168,6 +1160,8 @@ drm_atomic_set_crtc_for_connector(struct drm_connector_state *conn_state, | |||
1168 | { | 1160 | { |
1169 | struct drm_crtc_state *crtc_state; | 1161 | struct drm_crtc_state *crtc_state; |
1170 | 1162 | ||
1163 | if (crtc) | ||
1164 | drm_connector_reference(conn_state->connector); | ||
1171 | if (conn_state->crtc && conn_state->crtc != crtc) { | 1165 | if (conn_state->crtc && conn_state->crtc != crtc) { |
1172 | crtc_state = drm_atomic_get_existing_crtc_state(conn_state->state, | 1166 | crtc_state = drm_atomic_get_existing_crtc_state(conn_state->state, |
1173 | conn_state->crtc); | 1167 | conn_state->crtc); |
@@ -1185,6 +1179,8 @@ drm_atomic_set_crtc_for_connector(struct drm_connector_state *conn_state, | |||
1185 | 1 << drm_connector_index(conn_state->connector); | 1179 | 1 << drm_connector_index(conn_state->connector); |
1186 | } | 1180 | } |
1187 | 1181 | ||
1182 | if (conn_state->crtc) | ||
1183 | drm_connector_unreference(conn_state->connector); | ||
1188 | conn_state->crtc = crtc; | 1184 | conn_state->crtc = crtc; |
1189 | 1185 | ||
1190 | if (crtc) | 1186 | if (crtc) |
diff --git a/drivers/gpu/drm/drm_atomic_helper.c b/drivers/gpu/drm/drm_atomic_helper.c index 92e11a2b83c8..997fd21e5388 100644 --- a/drivers/gpu/drm/drm_atomic_helper.c +++ b/drivers/gpu/drm/drm_atomic_helper.c | |||
@@ -2762,6 +2762,8 @@ __drm_atomic_helper_connector_duplicate_state(struct drm_connector *connector, | |||
2762 | struct drm_connector_state *state) | 2762 | struct drm_connector_state *state) |
2763 | { | 2763 | { |
2764 | memcpy(state, connector->state, sizeof(*state)); | 2764 | memcpy(state, connector->state, sizeof(*state)); |
2765 | if (state->crtc) | ||
2766 | drm_connector_reference(connector); | ||
2765 | } | 2767 | } |
2766 | EXPORT_SYMBOL(__drm_atomic_helper_connector_duplicate_state); | 2768 | EXPORT_SYMBOL(__drm_atomic_helper_connector_duplicate_state); |
2767 | 2769 | ||
@@ -2889,6 +2891,8 @@ __drm_atomic_helper_connector_destroy_state(struct drm_connector *connector, | |||
2889 | * state will automatically do the right thing if code is ever added | 2891 | * state will automatically do the right thing if code is ever added |
2890 | * to this function. | 2892 | * to this function. |
2891 | */ | 2893 | */ |
2894 | if (state->crtc) | ||
2895 | drm_connector_unreference(state->connector); | ||
2892 | } | 2896 | } |
2893 | EXPORT_SYMBOL(__drm_atomic_helper_connector_destroy_state); | 2897 | EXPORT_SYMBOL(__drm_atomic_helper_connector_destroy_state); |
2894 | 2898 | ||