mirror of https://gitee.com/openkylin/linux.git
drm/i915: Use drm_connector_list_iter in debugfs
While at it also try to reduce the locking a bit to what's really just needed instead of everything that we could possibly lock. Added a new for_each_intel_connector_iter which includes the cast to intel_connector. Otherwise just plain transformation with nothing special going on. v2: Review from Maarten: - Stick with modeset_lock_all in sink_crc, it looks at crtc->state. - Fix up early loop exit in i915_displayport_test_active_write. v3: Rebase onto the iter_get/put->iter_begin/end rename. Cc: Thierry Reding <thierry.reding@gmail.com> Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com> Reviewed-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com> (v2) Signed-off-by: Daniel Vetter <daniel.vetter@intel.com> Link: http://patchwork.freedesktop.org/patch/msgid/20170301095226.30584-1-daniel.vetter@ffwll.ch
This commit is contained in:
parent
5b5554c51d
commit
3f6a5e1ea6
|
@ -2709,12 +2709,14 @@ static int i915_sink_crc(struct seq_file *m, void *data)
|
|||
struct drm_i915_private *dev_priv = node_to_i915(m->private);
|
||||
struct drm_device *dev = &dev_priv->drm;
|
||||
struct intel_connector *connector;
|
||||
struct drm_connector_list_iter conn_iter;
|
||||
struct intel_dp *intel_dp = NULL;
|
||||
int ret;
|
||||
u8 crc[6];
|
||||
|
||||
drm_modeset_lock_all(dev);
|
||||
for_each_intel_connector(dev, connector) {
|
||||
drm_connector_list_iter_begin(dev, &conn_iter);
|
||||
for_each_intel_connector_iter(connector, &conn_iter) {
|
||||
struct drm_crtc *crtc;
|
||||
|
||||
if (!connector->base.state->best_encoder)
|
||||
|
@ -2740,6 +2742,7 @@ static int i915_sink_crc(struct seq_file *m, void *data)
|
|||
}
|
||||
ret = -ENODEV;
|
||||
out:
|
||||
drm_connector_list_iter_end(&conn_iter);
|
||||
drm_modeset_unlock_all(dev);
|
||||
return ret;
|
||||
}
|
||||
|
@ -3176,9 +3179,9 @@ static int i915_display_info(struct seq_file *m, void *unused)
|
|||
struct drm_device *dev = &dev_priv->drm;
|
||||
struct intel_crtc *crtc;
|
||||
struct drm_connector *connector;
|
||||
struct drm_connector_list_iter conn_iter;
|
||||
|
||||
intel_runtime_pm_get(dev_priv);
|
||||
drm_modeset_lock_all(dev);
|
||||
seq_printf(m, "CRTC info\n");
|
||||
seq_printf(m, "---------\n");
|
||||
for_each_intel_crtc(dev, crtc) {
|
||||
|
@ -3186,6 +3189,7 @@ static int i915_display_info(struct seq_file *m, void *unused)
|
|||
struct intel_crtc_state *pipe_config;
|
||||
int x, y;
|
||||
|
||||
drm_modeset_lock(&crtc->base.mutex, NULL);
|
||||
pipe_config = to_intel_crtc_state(crtc->base.state);
|
||||
|
||||
seq_printf(m, "CRTC %d: pipe: %c, active=%s, (size=%dx%d), dither=%s, bpp=%d\n",
|
||||
|
@ -3210,15 +3214,19 @@ static int i915_display_info(struct seq_file *m, void *unused)
|
|||
seq_printf(m, "\tunderrun reporting: cpu=%s pch=%s \n",
|
||||
yesno(!crtc->cpu_fifo_underrun_disabled),
|
||||
yesno(!crtc->pch_fifo_underrun_disabled));
|
||||
drm_modeset_unlock(&crtc->base.mutex);
|
||||
}
|
||||
|
||||
seq_printf(m, "\n");
|
||||
seq_printf(m, "Connector info\n");
|
||||
seq_printf(m, "--------------\n");
|
||||
list_for_each_entry(connector, &dev->mode_config.connector_list, head) {
|
||||
mutex_lock(&dev->mode_config.mutex);
|
||||
drm_connector_list_iter_begin(dev, &conn_iter);
|
||||
drm_for_each_connector_iter(connector, &conn_iter)
|
||||
intel_connector_info(m, connector);
|
||||
}
|
||||
drm_modeset_unlock_all(dev);
|
||||
drm_connector_list_iter_end(&conn_iter);
|
||||
mutex_unlock(&dev->mode_config.mutex);
|
||||
|
||||
intel_runtime_pm_put(dev_priv);
|
||||
|
||||
return 0;
|
||||
|
@ -3551,13 +3559,16 @@ static void drrs_status_per_crtc(struct seq_file *m,
|
|||
struct i915_drrs *drrs = &dev_priv->drrs;
|
||||
int vrefresh = 0;
|
||||
struct drm_connector *connector;
|
||||
struct drm_connector_list_iter conn_iter;
|
||||
|
||||
drm_for_each_connector(connector, dev) {
|
||||
drm_connector_list_iter_begin(dev, &conn_iter);
|
||||
drm_for_each_connector_iter(connector, &conn_iter) {
|
||||
if (connector->state->crtc != &intel_crtc->base)
|
||||
continue;
|
||||
|
||||
seq_printf(m, "%s:\n", connector->name);
|
||||
}
|
||||
drm_connector_list_iter_end(&conn_iter);
|
||||
|
||||
if (dev_priv->vbt.drrs_type == STATIC_DRRS_SUPPORT)
|
||||
seq_puts(m, "\tVBT: DRRS_type: Static");
|
||||
|
@ -3643,9 +3654,10 @@ static int i915_dp_mst_info(struct seq_file *m, void *unused)
|
|||
struct intel_encoder *intel_encoder;
|
||||
struct intel_digital_port *intel_dig_port;
|
||||
struct drm_connector *connector;
|
||||
struct drm_connector_list_iter conn_iter;
|
||||
|
||||
drm_modeset_lock_all(dev);
|
||||
drm_for_each_connector(connector, dev) {
|
||||
drm_connector_list_iter_begin(dev, &conn_iter);
|
||||
drm_for_each_connector_iter(connector, &conn_iter) {
|
||||
if (connector->connector_type != DRM_MODE_CONNECTOR_DisplayPort)
|
||||
continue;
|
||||
|
||||
|
@ -3661,7 +3673,8 @@ static int i915_dp_mst_info(struct seq_file *m, void *unused)
|
|||
port_name(intel_dig_port->port));
|
||||
drm_dp_mst_dump_topology(m, &intel_dig_port->dp.mst_mgr);
|
||||
}
|
||||
drm_modeset_unlock_all(dev);
|
||||
drm_connector_list_iter_end(&conn_iter);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -3673,14 +3686,12 @@ 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 drm_connector_list_iter conn_iter;
|
||||
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;
|
||||
|
||||
|
@ -3696,7 +3707,8 @@ 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_connector_list_iter_begin(dev, &conn_iter);
|
||||
drm_for_each_connector_iter(connector, &conn_iter) {
|
||||
if (connector->connector_type !=
|
||||
DRM_MODE_CONNECTOR_DisplayPort)
|
||||
continue;
|
||||
|
@ -3706,7 +3718,7 @@ static ssize_t i915_displayport_test_active_write(struct file *file,
|
|||
intel_dp = enc_to_intel_dp(connector->encoder);
|
||||
status = kstrtoint(input_buffer, 10, &val);
|
||||
if (status < 0)
|
||||
goto out;
|
||||
break;
|
||||
DRM_DEBUG_DRIVER("Got %d for test active\n", val);
|
||||
/* To prevent erroneous activation of the compliance
|
||||
* testing code, only accept an actual value of 1 here
|
||||
|
@ -3717,6 +3729,7 @@ static ssize_t i915_displayport_test_active_write(struct file *file,
|
|||
intel_dp->compliance.test_active = 0;
|
||||
}
|
||||
}
|
||||
drm_connector_list_iter_end(&conn_iter);
|
||||
out:
|
||||
kfree(input_buffer);
|
||||
if (status < 0)
|
||||
|
@ -3730,10 +3743,11 @@ 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 drm_connector_list_iter conn_iter;
|
||||
struct intel_dp *intel_dp;
|
||||
|
||||
list_for_each_entry(connector, connector_list, head) {
|
||||
drm_connector_list_iter_begin(dev, &conn_iter);
|
||||
drm_for_each_connector_iter(connector, &conn_iter) {
|
||||
if (connector->connector_type !=
|
||||
DRM_MODE_CONNECTOR_DisplayPort)
|
||||
continue;
|
||||
|
@ -3748,6 +3762,7 @@ static int i915_displayport_test_active_show(struct seq_file *m, void *data)
|
|||
} else
|
||||
seq_puts(m, "0");
|
||||
}
|
||||
drm_connector_list_iter_end(&conn_iter);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -3774,10 +3789,11 @@ 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 drm_connector_list_iter conn_iter;
|
||||
struct intel_dp *intel_dp;
|
||||
|
||||
list_for_each_entry(connector, connector_list, head) {
|
||||
drm_connector_list_iter_begin(dev, &conn_iter);
|
||||
drm_for_each_connector_iter(connector, &conn_iter) {
|
||||
if (connector->connector_type !=
|
||||
DRM_MODE_CONNECTOR_DisplayPort)
|
||||
continue;
|
||||
|
@ -3801,6 +3817,7 @@ static int i915_displayport_test_data_show(struct seq_file *m, void *data)
|
|||
} else
|
||||
seq_puts(m, "0");
|
||||
}
|
||||
drm_connector_list_iter_end(&conn_iter);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -3825,10 +3842,11 @@ 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 drm_connector_list_iter conn_iter;
|
||||
struct intel_dp *intel_dp;
|
||||
|
||||
list_for_each_entry(connector, connector_list, head) {
|
||||
drm_connector_list_iter_begin(dev, &conn_iter);
|
||||
drm_for_each_connector_iter(connector, &conn_iter) {
|
||||
if (connector->connector_type !=
|
||||
DRM_MODE_CONNECTOR_DisplayPort)
|
||||
continue;
|
||||
|
@ -3840,6 +3858,7 @@ static int i915_displayport_test_type_show(struct seq_file *m, void *data)
|
|||
} else
|
||||
seq_puts(m, "0");
|
||||
}
|
||||
drm_connector_list_iter_end(&conn_iter);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -494,6 +494,9 @@ struct i915_hotplug {
|
|||
&(dev)->mode_config.connector_list, \
|
||||
base.head)
|
||||
|
||||
#define for_each_intel_connector_iter(intel_connector, iter) \
|
||||
while ((intel_connector = to_intel_connector(drm_connector_list_iter_next(iter))))
|
||||
|
||||
#define for_each_encoder_on_crtc(dev, __crtc, intel_encoder) \
|
||||
list_for_each_entry((intel_encoder), &(dev)->mode_config.encoder_list, base.head) \
|
||||
for_each_if ((intel_encoder)->base.crtc == (__crtc))
|
||||
|
|
Loading…
Reference in New Issue