Commit 9a9f5ce8 authored by Daniel Vetter's avatar Daniel Vetter

drm: Roll out drm_for_each_connector more

Now that we also grab the connection_mutex and so fixed the race with
atomic modeset we can use the iterator there too.

The other special case is drm_connector_unplug_all which would have a
locking inversion with the sysfs store/show functions if we'd grab the
mode_config.mutex around the unplug. We could just grab
connection_mutex instead, but that's a bit too much a dirty trick for
my taste. Also it's only used by udl, which doesn't do any other kind
of connector hotplugging, so should be race-free. Hence just stick
with a comment for now.
Reviewed-by: default avatarMaarten Lankhorst <maarten.lankhorst@linux.intel.com>
Signed-off-by: default avatarDaniel Vetter <daniel.vetter@intel.com>
parent cff20ba2
...@@ -1063,7 +1063,7 @@ drm_atomic_add_affected_connectors(struct drm_atomic_state *state, ...@@ -1063,7 +1063,7 @@ drm_atomic_add_affected_connectors(struct drm_atomic_state *state,
* Changed connectors are already in @state, so only need to look at the * Changed connectors are already in @state, so only need to look at the
* current configuration. * current configuration.
*/ */
list_for_each_entry(connector, &config->connector_list, head) { drm_for_each_connector(connector, state->dev) {
if (connector->state->crtc != crtc) if (connector->state->crtc != crtc)
continue; continue;
......
...@@ -89,7 +89,7 @@ get_current_crtc_for_encoder(struct drm_device *dev, ...@@ -89,7 +89,7 @@ get_current_crtc_for_encoder(struct drm_device *dev,
WARN_ON(!drm_modeset_is_locked(&config->connection_mutex)); WARN_ON(!drm_modeset_is_locked(&config->connection_mutex));
list_for_each_entry(connector, &config->connector_list, head) { drm_for_each_connector(connector, dev) {
if (connector->state->best_encoder != encoder) if (connector->state->best_encoder != encoder)
continue; continue;
...@@ -1986,7 +1986,7 @@ void drm_atomic_helper_connector_dpms(struct drm_connector *connector, ...@@ -1986,7 +1986,7 @@ void drm_atomic_helper_connector_dpms(struct drm_connector *connector,
WARN_ON(!drm_modeset_is_locked(&config->connection_mutex)); WARN_ON(!drm_modeset_is_locked(&config->connection_mutex));
list_for_each_entry(tmp_connector, &config->connector_list, head) { drm_for_each_connector(tmp_connector, connector->dev) {
if (tmp_connector->state->crtc != crtc) if (tmp_connector->state->crtc != crtc)
continue; continue;
......
...@@ -988,7 +988,7 @@ unsigned int drm_connector_index(struct drm_connector *connector) ...@@ -988,7 +988,7 @@ unsigned int drm_connector_index(struct drm_connector *connector)
WARN_ON(!drm_modeset_is_locked(&config->connection_mutex)); WARN_ON(!drm_modeset_is_locked(&config->connection_mutex));
list_for_each_entry(tmp, &connector->dev->mode_config.connector_list, head) { drm_for_each_connector(tmp, connector->dev) {
if (tmp == connector) if (tmp == connector)
return index; return index;
...@@ -1054,7 +1054,7 @@ void drm_connector_unplug_all(struct drm_device *dev) ...@@ -1054,7 +1054,7 @@ void drm_connector_unplug_all(struct drm_device *dev)
{ {
struct drm_connector *connector; struct drm_connector *connector;
/* taking the mode config mutex ends up in a clash with sysfs */ /* FIXME: taking the mode config mutex ends up in a clash with sysfs */
list_for_each_entry(connector, &dev->mode_config.connector_list, head) list_for_each_entry(connector, &dev->mode_config.connector_list, head)
drm_connector_unregister(connector); drm_connector_unregister(connector);
...@@ -1726,7 +1726,7 @@ int drm_mode_group_init_legacy_group(struct drm_device *dev, ...@@ -1726,7 +1726,7 @@ int drm_mode_group_init_legacy_group(struct drm_device *dev,
group->id_list[group->num_crtcs + group->num_encoders++] = group->id_list[group->num_crtcs + group->num_encoders++] =
encoder->base.id; encoder->base.id;
list_for_each_entry(connector, &dev->mode_config.connector_list, head) drm_for_each_connector(connector, dev)
group->id_list[group->num_crtcs + group->num_encoders + group->id_list[group->num_crtcs + group->num_encoders +
group->num_connectors++] = connector->base.id; group->num_connectors++] = connector->base.id;
...@@ -1810,12 +1810,13 @@ int drm_mode_getresources(struct drm_device *dev, void *data, ...@@ -1810,12 +1810,13 @@ int drm_mode_getresources(struct drm_device *dev, void *data,
* connector hot-adding. CRTC/Plane lists are invariant. */ * connector hot-adding. CRTC/Plane lists are invariant. */
mutex_lock(&dev->mode_config.mutex); mutex_lock(&dev->mode_config.mutex);
if (!drm_is_primary_client(file_priv)) { if (!drm_is_primary_client(file_priv)) {
struct drm_connector *connector;
mode_group = NULL; mode_group = NULL;
list_for_each(lh, &dev->mode_config.crtc_list) list_for_each(lh, &dev->mode_config.crtc_list)
crtc_count++; crtc_count++;
list_for_each(lh, &dev->mode_config.connector_list) drm_for_each_connector(connector, dev)
connector_count++; connector_count++;
list_for_each(lh, &dev->mode_config.encoder_list) list_for_each(lh, &dev->mode_config.encoder_list)
......
...@@ -121,7 +121,7 @@ bool drm_helper_encoder_in_use(struct drm_encoder *encoder) ...@@ -121,7 +121,7 @@ bool drm_helper_encoder_in_use(struct drm_encoder *encoder)
WARN_ON(!drm_modeset_is_locked(&dev->mode_config.connection_mutex)); WARN_ON(!drm_modeset_is_locked(&dev->mode_config.connection_mutex));
} }
list_for_each_entry(connector, &dev->mode_config.connector_list, head) drm_for_each_connector(connector, dev)
if (connector->encoder == encoder) if (connector->encoder == encoder)
return true; return true;
return false; return false;
...@@ -712,7 +712,7 @@ static int drm_helper_choose_encoder_dpms(struct drm_encoder *encoder) ...@@ -712,7 +712,7 @@ static int drm_helper_choose_encoder_dpms(struct drm_encoder *encoder)
struct drm_connector *connector; struct drm_connector *connector;
struct drm_device *dev = encoder->dev; struct drm_device *dev = encoder->dev;
list_for_each_entry(connector, &dev->mode_config.connector_list, head) drm_for_each_connector(connector, dev)
if (connector->encoder == encoder) if (connector->encoder == encoder)
if (connector->dpms < dpms) if (connector->dpms < dpms)
dpms = connector->dpms; dpms = connector->dpms;
...@@ -746,7 +746,7 @@ static int drm_helper_choose_crtc_dpms(struct drm_crtc *crtc) ...@@ -746,7 +746,7 @@ static int drm_helper_choose_crtc_dpms(struct drm_crtc *crtc)
struct drm_connector *connector; struct drm_connector *connector;
struct drm_device *dev = crtc->dev; struct drm_device *dev = crtc->dev;
list_for_each_entry(connector, &dev->mode_config.connector_list, head) drm_for_each_connector(connector, dev)
if (connector->encoder && connector->encoder->crtc == crtc) if (connector->encoder && connector->encoder->crtc == crtc)
if (connector->dpms < dpms) if (connector->dpms < dpms)
dpms = connector->dpms; dpms = connector->dpms;
......
...@@ -3413,7 +3413,7 @@ struct drm_connector *drm_select_eld(struct drm_encoder *encoder, ...@@ -3413,7 +3413,7 @@ struct drm_connector *drm_select_eld(struct drm_encoder *encoder,
WARN_ON(!mutex_is_locked(&dev->mode_config.mutex)); WARN_ON(!mutex_is_locked(&dev->mode_config.mutex));
WARN_ON(!drm_modeset_is_locked(&dev->mode_config.connection_mutex)); WARN_ON(!drm_modeset_is_locked(&dev->mode_config.connection_mutex));
list_for_each_entry(connector, &dev->mode_config.connector_list, head) drm_for_each_connector(connector, dev)
if (connector->encoder == encoder && connector->eld[0]) if (connector->encoder == encoder && connector->eld[0])
return connector; return connector;
......
...@@ -91,13 +91,14 @@ static int get_connectors_for_crtc(struct drm_crtc *crtc, ...@@ -91,13 +91,14 @@ static int get_connectors_for_crtc(struct drm_crtc *crtc,
*/ */
WARN_ON(!drm_modeset_is_locked(&dev->mode_config.connection_mutex)); WARN_ON(!drm_modeset_is_locked(&dev->mode_config.connection_mutex));
list_for_each_entry(connector, &dev->mode_config.connector_list, head) drm_for_each_connector(connector, dev) {
if (connector->encoder && connector->encoder->crtc == crtc) { if (connector->encoder && connector->encoder->crtc == crtc) {
if (connector_list != NULL && count < num_connectors) if (connector_list != NULL && count < num_connectors)
*(connector_list++) = connector; *(connector_list++) = connector;
count++; count++;
} }
}
return count; return count;
} }
......
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