Use proper locking, connector_state and encoder masks. Signed-off-by: Maarten Lankhorst <maarten.lankhorst@xxxxxxxxxxxxxxx> --- drivers/gpu/drm/i915/i915_debugfs.c | 72 ++++++++++++++++++------------------- 1 file changed, 34 insertions(+), 38 deletions(-) diff --git a/drivers/gpu/drm/i915/i915_debugfs.c b/drivers/gpu/drm/i915/i915_debugfs.c index 9b740d8a3f5e..37b06ea9b112 100644 --- a/drivers/gpu/drm/i915/i915_debugfs.c +++ b/drivers/gpu/drm/i915/i915_debugfs.c @@ -2655,13 +2655,11 @@ static int i915_sink_crc(struct seq_file *m, void *data) drm_modeset_lock_all(dev); for_each_intel_connector(dev, connector) { - if (connector->base.dpms != DRM_MODE_DPMS_ON) + if (!connector->base.state->crtc || + !connector->base.state->crtc->state->active) continue; - if (!connector->base.encoder) - continue; - - encoder = to_intel_encoder(connector->base.encoder); + encoder = to_intel_encoder(connector->base.state->best_encoder); if (encoder->type != INTEL_OUTPUT_EDP) continue; @@ -2837,14 +2835,17 @@ static void intel_encoder_info(struct seq_file *m, struct drm_info_node *node = m->private; struct drm_device *dev = node->minor->dev; struct drm_crtc *crtc = &intel_crtc->base; - struct intel_connector *intel_connector; + struct drm_connector *connector; struct drm_encoder *encoder; encoder = &intel_encoder->base; seq_printf(m, "\tencoder %d: type: %s, connectors:\n", encoder->base.id, encoder->name); - for_each_connector_on_encoder(dev, encoder, intel_connector) { - struct drm_connector *connector = &intel_connector->base; + + drm_for_each_connector(connector, dev) { + if (connector->state->best_encoder != &intel_encoder->base) + continue; + seq_printf(m, "\t\tconnector %d: type: %s, status: %s", connector->base.id, connector->name, @@ -3695,30 +3696,24 @@ static int i8xx_pipe_crc_ctl_reg(enum intel_pipe_crc_source *source, static int i9xx_pipe_crc_auto_source(struct drm_device *dev, enum pipe pipe, enum intel_pipe_crc_source *source) { - struct intel_encoder *encoder; - struct intel_crtc *crtc; + struct drm_encoder *encoder; + struct drm_crtc *crtc; struct intel_digital_port *dig_port; int ret = 0; *source = INTEL_PIPE_CRC_SOURCE_PIPE; drm_modeset_lock_all(dev); - for_each_intel_encoder(dev, encoder) { - if (!encoder->base.crtc) - continue; + crtc = to_i915(dev)->pipe_to_crtc_mapping[pipe]; - crtc = to_intel_crtc(encoder->base.crtc); - - if (crtc->pipe != pipe) - continue; - - switch (encoder->type) { + drm_for_each_encoder_mask(encoder, dev, crtc->state->encoder_mask) { + switch (to_intel_encoder(encoder)->type) { case INTEL_OUTPUT_TVOUT: *source = INTEL_PIPE_CRC_SOURCE_TV; break; case INTEL_OUTPUT_DISPLAYPORT: case INTEL_OUTPUT_EDP: - dig_port = enc_to_dig_port(&encoder->base); + dig_port = enc_to_dig_port(encoder); switch (dig_port->port) { case PORT_B: *source = INTEL_PIPE_CRC_SOURCE_DP_B; @@ -4322,14 +4317,11 @@ static ssize_t i915_displayport_test_active_write(struct file *file, int status = 0; struct drm_device *dev; struct drm_connector *connector; - struct list_head *connector_list; struct intel_dp *intel_dp; int val = 0; dev = ((struct seq_file *)file->private_data)->private; - connector_list = &dev->mode_config.connector_list; - if (len == 0) return 0; @@ -4337,6 +4329,8 @@ static ssize_t i915_displayport_test_active_write(struct file *file, if (!input_buffer) return -ENOMEM; + drm_modeset_lock(&dev->mode_config.connection_mutex, NULL); + if (copy_from_user(input_buffer, ubuf, len)) { status = -EFAULT; goto out; @@ -4345,15 +4339,14 @@ static ssize_t i915_displayport_test_active_write(struct file *file, input_buffer[len] = '\0'; DRM_DEBUG_DRIVER("Copied %d bytes from user\n", (unsigned int)len); - list_for_each_entry(connector, connector_list, head) { - + drm_for_each_connector(connector, dev) { if (connector->connector_type != DRM_MODE_CONNECTOR_DisplayPort) continue; if (connector->status == connector_status_connected && - connector->encoder != NULL) { - intel_dp = enc_to_intel_dp(connector->encoder); + connector->state->best_encoder != NULL) { + intel_dp = enc_to_intel_dp(connector->state->best_encoder); status = kstrtoint(input_buffer, 10, &val); if (status < 0) goto out; @@ -4368,6 +4361,7 @@ static ssize_t i915_displayport_test_active_write(struct file *file, } } out: + drm_modeset_unlock(&dev->mode_config.connection_mutex); kfree(input_buffer); if (status < 0) return status; @@ -4380,18 +4374,18 @@ static int i915_displayport_test_active_show(struct seq_file *m, void *data) { struct drm_device *dev = m->private; struct drm_connector *connector; - struct list_head *connector_list = &dev->mode_config.connector_list; struct intel_dp *intel_dp; - list_for_each_entry(connector, connector_list, head) { + drm_modeset_lock(&dev->mode_config.connection_mutex, NULL); + drm_for_each_connector(connector, dev) { if (connector->connector_type != DRM_MODE_CONNECTOR_DisplayPort) continue; if (connector->status == connector_status_connected && - connector->encoder != NULL) { - intel_dp = enc_to_intel_dp(connector->encoder); + connector->state->best_encoder != NULL) { + intel_dp = enc_to_intel_dp(connector->state->best_encoder); if (intel_dp->compliance_test_active) seq_puts(m, "1"); else @@ -4399,6 +4393,7 @@ static int i915_displayport_test_active_show(struct seq_file *m, void *data) } else seq_puts(m, "0"); } + drm_modeset_unlock(&dev->mode_config.connection_mutex); return 0; } @@ -4424,10 +4419,10 @@ static int i915_displayport_test_data_show(struct seq_file *m, void *data) { struct drm_device *dev = m->private; struct drm_connector *connector; - struct list_head *connector_list = &dev->mode_config.connector_list; struct intel_dp *intel_dp; - list_for_each_entry(connector, connector_list, head) { + drm_modeset_lock(&dev->mode_config.connection_mutex, NULL); + drm_for_each_connector(connector, dev) { if (connector->connector_type != DRM_MODE_CONNECTOR_DisplayPort) @@ -4435,11 +4430,12 @@ static int i915_displayport_test_data_show(struct seq_file *m, void *data) if (connector->status == connector_status_connected && connector->encoder != NULL) { - intel_dp = enc_to_intel_dp(connector->encoder); + intel_dp = enc_to_intel_dp(connector->state->best_encoder); seq_printf(m, "%lx", intel_dp->compliance_test_data); } else seq_puts(m, "0"); } + drm_modeset_unlock(&dev->mode_config.connection_mutex); return 0; } @@ -4463,22 +4459,22 @@ static int i915_displayport_test_type_show(struct seq_file *m, void *data) { struct drm_device *dev = m->private; struct drm_connector *connector; - struct list_head *connector_list = &dev->mode_config.connector_list; struct intel_dp *intel_dp; - list_for_each_entry(connector, connector_list, head) { - + drm_modeset_lock(&dev->mode_config.connection_mutex, NULL); + drm_for_each_connector(connector, dev) { if (connector->connector_type != DRM_MODE_CONNECTOR_DisplayPort) continue; if (connector->status == connector_status_connected && connector->encoder != NULL) { - intel_dp = enc_to_intel_dp(connector->encoder); + intel_dp = enc_to_intel_dp(connector->state->best_encoder); seq_printf(m, "%02lx", intel_dp->compliance_test_type); } else seq_puts(m, "0"); } + drm_modeset_unlock(&dev->mode_config.connection_mutex); return 0; } -- 2.1.0 _______________________________________________ Intel-gfx mailing list Intel-gfx@xxxxxxxxxxxxxxxxxxxxx https://lists.freedesktop.org/mailman/listinfo/intel-gfx