Commit f8d2d39e authored by Lyude Paul's avatar Lyude Paul Committed by Alex Deucher

drm/amdgpu: Iterate through DRM connectors correctly

Currently, every single piece of code in amdgpu that loops through
connectors does it incorrectly and doesn't use the proper list iteration
helpers, drm_connector_list_iter_begin() and
drm_connector_list_iter_end(). Yeesh.

So, do that.

Cc: Juston Li <juston.li@intel.com>
Cc: Imre Deak <imre.deak@intel.com>
Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Cc: Harry Wentland <hwentlan@amd.com>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Reviewed-by: default avatarAlex Deucher <alexander.deucher@amd.com>
Signed-off-by: default avatarLyude Paul <lyude@redhat.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent 684cd480
...@@ -1022,8 +1022,12 @@ amdgpu_connector_dvi_detect(struct drm_connector *connector, bool force) ...@@ -1022,8 +1022,12 @@ amdgpu_connector_dvi_detect(struct drm_connector *connector, bool force)
*/ */
if (amdgpu_connector->shared_ddc && (ret == connector_status_connected)) { if (amdgpu_connector->shared_ddc && (ret == connector_status_connected)) {
struct drm_connector *list_connector; struct drm_connector *list_connector;
struct drm_connector_list_iter iter;
struct amdgpu_connector *list_amdgpu_connector; struct amdgpu_connector *list_amdgpu_connector;
list_for_each_entry(list_connector, &dev->mode_config.connector_list, head) {
drm_connector_list_iter_begin(dev, &iter);
drm_for_each_connector_iter(list_connector,
&iter) {
if (connector == list_connector) if (connector == list_connector)
continue; continue;
list_amdgpu_connector = to_amdgpu_connector(list_connector); list_amdgpu_connector = to_amdgpu_connector(list_connector);
...@@ -1040,6 +1044,7 @@ amdgpu_connector_dvi_detect(struct drm_connector *connector, bool force) ...@@ -1040,6 +1044,7 @@ amdgpu_connector_dvi_detect(struct drm_connector *connector, bool force)
} }
} }
} }
drm_connector_list_iter_end(&iter);
} }
} }
} }
...@@ -1501,6 +1506,7 @@ amdgpu_connector_add(struct amdgpu_device *adev, ...@@ -1501,6 +1506,7 @@ amdgpu_connector_add(struct amdgpu_device *adev,
{ {
struct drm_device *dev = adev->ddev; struct drm_device *dev = adev->ddev;
struct drm_connector *connector; struct drm_connector *connector;
struct drm_connector_list_iter iter;
struct amdgpu_connector *amdgpu_connector; struct amdgpu_connector *amdgpu_connector;
struct amdgpu_connector_atom_dig *amdgpu_dig_connector; struct amdgpu_connector_atom_dig *amdgpu_dig_connector;
struct drm_encoder *encoder; struct drm_encoder *encoder;
...@@ -1515,10 +1521,12 @@ amdgpu_connector_add(struct amdgpu_device *adev, ...@@ -1515,10 +1521,12 @@ amdgpu_connector_add(struct amdgpu_device *adev,
return; return;
/* see if we already added it */ /* see if we already added it */
list_for_each_entry(connector, &dev->mode_config.connector_list, head) { drm_connector_list_iter_begin(dev, &iter);
drm_for_each_connector_iter(connector, &iter) {
amdgpu_connector = to_amdgpu_connector(connector); amdgpu_connector = to_amdgpu_connector(connector);
if (amdgpu_connector->connector_id == connector_id) { if (amdgpu_connector->connector_id == connector_id) {
amdgpu_connector->devices |= supported_device; amdgpu_connector->devices |= supported_device;
drm_connector_list_iter_end(&iter);
return; return;
} }
if (amdgpu_connector->ddc_bus && i2c_bus->valid) { if (amdgpu_connector->ddc_bus && i2c_bus->valid) {
...@@ -1533,6 +1541,7 @@ amdgpu_connector_add(struct amdgpu_device *adev, ...@@ -1533,6 +1541,7 @@ amdgpu_connector_add(struct amdgpu_device *adev,
} }
} }
} }
drm_connector_list_iter_end(&iter);
/* check if it's a dp bridge */ /* check if it's a dp bridge */
list_for_each_entry(encoder, &dev->mode_config.encoder_list, head) { list_for_each_entry(encoder, &dev->mode_config.encoder_list, head) {
......
...@@ -3026,6 +3026,7 @@ int amdgpu_device_suspend(struct drm_device *dev, bool suspend, bool fbcon) ...@@ -3026,6 +3026,7 @@ int amdgpu_device_suspend(struct drm_device *dev, bool suspend, bool fbcon)
struct amdgpu_device *adev; struct amdgpu_device *adev;
struct drm_crtc *crtc; struct drm_crtc *crtc;
struct drm_connector *connector; struct drm_connector *connector;
struct drm_connector_list_iter iter;
int r; int r;
if (dev == NULL || dev->dev_private == NULL) { if (dev == NULL || dev->dev_private == NULL) {
...@@ -3048,9 +3049,11 @@ int amdgpu_device_suspend(struct drm_device *dev, bool suspend, bool fbcon) ...@@ -3048,9 +3049,11 @@ int amdgpu_device_suspend(struct drm_device *dev, bool suspend, bool fbcon)
if (!amdgpu_device_has_dc_support(adev)) { if (!amdgpu_device_has_dc_support(adev)) {
/* turn off display hw */ /* turn off display hw */
drm_modeset_lock_all(dev); drm_modeset_lock_all(dev);
list_for_each_entry(connector, &dev->mode_config.connector_list, head) { drm_connector_list_iter_begin(dev, &iter);
drm_helper_connector_dpms(connector, DRM_MODE_DPMS_OFF); drm_for_each_connector_iter(connector, &iter)
} drm_helper_connector_dpms(connector,
DRM_MODE_DPMS_OFF);
drm_connector_list_iter_end(&iter);
drm_modeset_unlock_all(dev); drm_modeset_unlock_all(dev);
/* unpin the front buffers and cursors */ /* unpin the front buffers and cursors */
list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) { list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) {
...@@ -3129,6 +3132,7 @@ int amdgpu_device_suspend(struct drm_device *dev, bool suspend, bool fbcon) ...@@ -3129,6 +3132,7 @@ int amdgpu_device_suspend(struct drm_device *dev, bool suspend, bool fbcon)
int amdgpu_device_resume(struct drm_device *dev, bool resume, bool fbcon) int amdgpu_device_resume(struct drm_device *dev, bool resume, bool fbcon)
{ {
struct drm_connector *connector; struct drm_connector *connector;
struct drm_connector_list_iter iter;
struct amdgpu_device *adev = dev->dev_private; struct amdgpu_device *adev = dev->dev_private;
struct drm_crtc *crtc; struct drm_crtc *crtc;
int r = 0; int r = 0;
...@@ -3199,9 +3203,13 @@ int amdgpu_device_resume(struct drm_device *dev, bool resume, bool fbcon) ...@@ -3199,9 +3203,13 @@ int amdgpu_device_resume(struct drm_device *dev, bool resume, bool fbcon)
/* turn on display hw */ /* turn on display hw */
drm_modeset_lock_all(dev); drm_modeset_lock_all(dev);
list_for_each_entry(connector, &dev->mode_config.connector_list, head) {
drm_helper_connector_dpms(connector, DRM_MODE_DPMS_ON); drm_connector_list_iter_begin(dev, &iter);
} drm_for_each_connector_iter(connector, &iter)
drm_helper_connector_dpms(connector,
DRM_MODE_DPMS_ON);
drm_connector_list_iter_end(&iter);
drm_modeset_unlock_all(dev); drm_modeset_unlock_all(dev);
} }
amdgpu_fbdev_set_suspend(adev, 0); amdgpu_fbdev_set_suspend(adev, 0);
......
...@@ -370,11 +370,13 @@ void amdgpu_display_print_display_setup(struct drm_device *dev) ...@@ -370,11 +370,13 @@ void amdgpu_display_print_display_setup(struct drm_device *dev)
struct amdgpu_connector *amdgpu_connector; struct amdgpu_connector *amdgpu_connector;
struct drm_encoder *encoder; struct drm_encoder *encoder;
struct amdgpu_encoder *amdgpu_encoder; struct amdgpu_encoder *amdgpu_encoder;
struct drm_connector_list_iter iter;
uint32_t devices; uint32_t devices;
int i = 0; int i = 0;
drm_connector_list_iter_begin(dev, &iter);
DRM_INFO("AMDGPU Display Connectors\n"); DRM_INFO("AMDGPU Display Connectors\n");
list_for_each_entry(connector, &dev->mode_config.connector_list, head) { drm_for_each_connector_iter(connector, &iter) {
amdgpu_connector = to_amdgpu_connector(connector); amdgpu_connector = to_amdgpu_connector(connector);
DRM_INFO("Connector %d:\n", i); DRM_INFO("Connector %d:\n", i);
DRM_INFO(" %s\n", connector->name); DRM_INFO(" %s\n", connector->name);
...@@ -438,6 +440,7 @@ void amdgpu_display_print_display_setup(struct drm_device *dev) ...@@ -438,6 +440,7 @@ void amdgpu_display_print_display_setup(struct drm_device *dev)
} }
i++; i++;
} }
drm_connector_list_iter_end(&iter);
} }
/** /**
......
...@@ -37,12 +37,14 @@ amdgpu_link_encoder_connector(struct drm_device *dev) ...@@ -37,12 +37,14 @@ amdgpu_link_encoder_connector(struct drm_device *dev)
{ {
struct amdgpu_device *adev = dev->dev_private; struct amdgpu_device *adev = dev->dev_private;
struct drm_connector *connector; struct drm_connector *connector;
struct drm_connector_list_iter iter;
struct amdgpu_connector *amdgpu_connector; struct amdgpu_connector *amdgpu_connector;
struct drm_encoder *encoder; struct drm_encoder *encoder;
struct amdgpu_encoder *amdgpu_encoder; struct amdgpu_encoder *amdgpu_encoder;
drm_connector_list_iter_begin(dev, &iter);
/* walk the list and link encoders to connectors */ /* walk the list and link encoders to connectors */
list_for_each_entry(connector, &dev->mode_config.connector_list, head) { drm_for_each_connector_iter(connector, &iter) {
amdgpu_connector = to_amdgpu_connector(connector); amdgpu_connector = to_amdgpu_connector(connector);
list_for_each_entry(encoder, &dev->mode_config.encoder_list, head) { list_for_each_entry(encoder, &dev->mode_config.encoder_list, head) {
amdgpu_encoder = to_amdgpu_encoder(encoder); amdgpu_encoder = to_amdgpu_encoder(encoder);
...@@ -55,6 +57,7 @@ amdgpu_link_encoder_connector(struct drm_device *dev) ...@@ -55,6 +57,7 @@ amdgpu_link_encoder_connector(struct drm_device *dev)
} }
} }
} }
drm_connector_list_iter_end(&iter);
} }
void amdgpu_encoder_set_active_device(struct drm_encoder *encoder) void amdgpu_encoder_set_active_device(struct drm_encoder *encoder)
...@@ -62,8 +65,10 @@ void amdgpu_encoder_set_active_device(struct drm_encoder *encoder) ...@@ -62,8 +65,10 @@ void amdgpu_encoder_set_active_device(struct drm_encoder *encoder)
struct drm_device *dev = encoder->dev; struct drm_device *dev = encoder->dev;
struct amdgpu_encoder *amdgpu_encoder = to_amdgpu_encoder(encoder); struct amdgpu_encoder *amdgpu_encoder = to_amdgpu_encoder(encoder);
struct drm_connector *connector; struct drm_connector *connector;
struct drm_connector_list_iter iter;
list_for_each_entry(connector, &dev->mode_config.connector_list, head) { drm_connector_list_iter_begin(dev, &iter);
drm_for_each_connector_iter(connector, &iter) {
if (connector->encoder == encoder) { if (connector->encoder == encoder) {
struct amdgpu_connector *amdgpu_connector = to_amdgpu_connector(connector); struct amdgpu_connector *amdgpu_connector = to_amdgpu_connector(connector);
amdgpu_encoder->active_device = amdgpu_encoder->devices & amdgpu_connector->devices; amdgpu_encoder->active_device = amdgpu_encoder->devices & amdgpu_connector->devices;
...@@ -72,6 +77,7 @@ void amdgpu_encoder_set_active_device(struct drm_encoder *encoder) ...@@ -72,6 +77,7 @@ void amdgpu_encoder_set_active_device(struct drm_encoder *encoder)
amdgpu_connector->devices, encoder->encoder_type); amdgpu_connector->devices, encoder->encoder_type);
} }
} }
drm_connector_list_iter_end(&iter);
} }
struct drm_connector * struct drm_connector *
...@@ -79,15 +85,20 @@ amdgpu_get_connector_for_encoder(struct drm_encoder *encoder) ...@@ -79,15 +85,20 @@ amdgpu_get_connector_for_encoder(struct drm_encoder *encoder)
{ {
struct drm_device *dev = encoder->dev; struct drm_device *dev = encoder->dev;
struct amdgpu_encoder *amdgpu_encoder = to_amdgpu_encoder(encoder); struct amdgpu_encoder *amdgpu_encoder = to_amdgpu_encoder(encoder);
struct drm_connector *connector; struct drm_connector *connector, *found = NULL;
struct drm_connector_list_iter iter;
struct amdgpu_connector *amdgpu_connector; struct amdgpu_connector *amdgpu_connector;
list_for_each_entry(connector, &dev->mode_config.connector_list, head) { drm_connector_list_iter_begin(dev, &iter);
drm_for_each_connector_iter(connector, &iter) {
amdgpu_connector = to_amdgpu_connector(connector); amdgpu_connector = to_amdgpu_connector(connector);
if (amdgpu_encoder->active_device & amdgpu_connector->devices) if (amdgpu_encoder->active_device & amdgpu_connector->devices) {
return connector; found = connector;
break;
}
} }
return NULL; drm_connector_list_iter_end(&iter);
return found;
} }
struct drm_connector * struct drm_connector *
...@@ -95,15 +106,20 @@ amdgpu_get_connector_for_encoder_init(struct drm_encoder *encoder) ...@@ -95,15 +106,20 @@ amdgpu_get_connector_for_encoder_init(struct drm_encoder *encoder)
{ {
struct drm_device *dev = encoder->dev; struct drm_device *dev = encoder->dev;
struct amdgpu_encoder *amdgpu_encoder = to_amdgpu_encoder(encoder); struct amdgpu_encoder *amdgpu_encoder = to_amdgpu_encoder(encoder);
struct drm_connector *connector; struct drm_connector *connector, *found = NULL;
struct drm_connector_list_iter iter;
struct amdgpu_connector *amdgpu_connector; struct amdgpu_connector *amdgpu_connector;
list_for_each_entry(connector, &dev->mode_config.connector_list, head) { drm_connector_list_iter_begin(dev, &iter);
drm_for_each_connector_iter(connector, &iter) {
amdgpu_connector = to_amdgpu_connector(connector); amdgpu_connector = to_amdgpu_connector(connector);
if (amdgpu_encoder->devices & amdgpu_connector->devices) if (amdgpu_encoder->devices & amdgpu_connector->devices) {
return connector; found = connector;
break;
}
} }
return NULL; drm_connector_list_iter_end(&iter);
return found;
} }
struct drm_encoder *amdgpu_get_external_encoder(struct drm_encoder *encoder) struct drm_encoder *amdgpu_get_external_encoder(struct drm_encoder *encoder)
......
...@@ -87,10 +87,13 @@ static void amdgpu_hotplug_work_func(struct work_struct *work) ...@@ -87,10 +87,13 @@ static void amdgpu_hotplug_work_func(struct work_struct *work)
struct drm_device *dev = adev->ddev; struct drm_device *dev = adev->ddev;
struct drm_mode_config *mode_config = &dev->mode_config; struct drm_mode_config *mode_config = &dev->mode_config;
struct drm_connector *connector; struct drm_connector *connector;
struct drm_connector_list_iter iter;
mutex_lock(&mode_config->mutex); mutex_lock(&mode_config->mutex);
list_for_each_entry(connector, &mode_config->connector_list, head) drm_connector_list_iter_begin(dev, &iter);
drm_for_each_connector_iter(connector, &iter)
amdgpu_connector_hotplug(connector); amdgpu_connector_hotplug(connector);
drm_connector_list_iter_end(&iter);
mutex_unlock(&mode_config->mutex); mutex_unlock(&mode_config->mutex);
/* Just fire off a uevent and let userspace tell us what to do */ /* Just fire off a uevent and let userspace tell us what to do */
drm_helper_hpd_irq_event(dev); drm_helper_hpd_irq_event(dev);
......
...@@ -330,9 +330,11 @@ static void dce_v10_0_hpd_init(struct amdgpu_device *adev) ...@@ -330,9 +330,11 @@ static void dce_v10_0_hpd_init(struct amdgpu_device *adev)
{ {
struct drm_device *dev = adev->ddev; struct drm_device *dev = adev->ddev;
struct drm_connector *connector; struct drm_connector *connector;
struct drm_connector_list_iter iter;
u32 tmp; u32 tmp;
list_for_each_entry(connector, &dev->mode_config.connector_list, head) { drm_connector_list_iter_begin(dev, &iter);
drm_for_each_connector_iter(connector, &iter) {
struct amdgpu_connector *amdgpu_connector = to_amdgpu_connector(connector); struct amdgpu_connector *amdgpu_connector = to_amdgpu_connector(connector);
if (amdgpu_connector->hpd.hpd >= adev->mode_info.num_hpd) if (amdgpu_connector->hpd.hpd >= adev->mode_info.num_hpd)
...@@ -368,6 +370,7 @@ static void dce_v10_0_hpd_init(struct amdgpu_device *adev) ...@@ -368,6 +370,7 @@ static void dce_v10_0_hpd_init(struct amdgpu_device *adev)
amdgpu_irq_get(adev, &adev->hpd_irq, amdgpu_irq_get(adev, &adev->hpd_irq,
amdgpu_connector->hpd.hpd); amdgpu_connector->hpd.hpd);
} }
drm_connector_list_iter_end(&iter);
} }
/** /**
...@@ -382,9 +385,11 @@ static void dce_v10_0_hpd_fini(struct amdgpu_device *adev) ...@@ -382,9 +385,11 @@ static void dce_v10_0_hpd_fini(struct amdgpu_device *adev)
{ {
struct drm_device *dev = adev->ddev; struct drm_device *dev = adev->ddev;
struct drm_connector *connector; struct drm_connector *connector;
struct drm_connector_list_iter iter;
u32 tmp; u32 tmp;
list_for_each_entry(connector, &dev->mode_config.connector_list, head) { drm_connector_list_iter_begin(dev, &iter);
drm_for_each_connector_iter(connector, &iter) {
struct amdgpu_connector *amdgpu_connector = to_amdgpu_connector(connector); struct amdgpu_connector *amdgpu_connector = to_amdgpu_connector(connector);
if (amdgpu_connector->hpd.hpd >= adev->mode_info.num_hpd) if (amdgpu_connector->hpd.hpd >= adev->mode_info.num_hpd)
...@@ -397,6 +402,7 @@ static void dce_v10_0_hpd_fini(struct amdgpu_device *adev) ...@@ -397,6 +402,7 @@ static void dce_v10_0_hpd_fini(struct amdgpu_device *adev)
amdgpu_irq_put(adev, &adev->hpd_irq, amdgpu_irq_put(adev, &adev->hpd_irq,
amdgpu_connector->hpd.hpd); amdgpu_connector->hpd.hpd);
} }
drm_connector_list_iter_end(&iter);
} }
static u32 dce_v10_0_hpd_get_gpio_reg(struct amdgpu_device *adev) static u32 dce_v10_0_hpd_get_gpio_reg(struct amdgpu_device *adev)
...@@ -1219,10 +1225,12 @@ static void dce_v10_0_afmt_audio_select_pin(struct drm_encoder *encoder) ...@@ -1219,10 +1225,12 @@ static void dce_v10_0_afmt_audio_select_pin(struct drm_encoder *encoder)
static void dce_v10_0_audio_write_latency_fields(struct drm_encoder *encoder, static void dce_v10_0_audio_write_latency_fields(struct drm_encoder *encoder,
struct drm_display_mode *mode) struct drm_display_mode *mode)
{ {
struct amdgpu_device *adev = encoder->dev->dev_private; struct drm_device *dev = encoder->dev;
struct amdgpu_device *adev = dev->dev_private;
struct amdgpu_encoder *amdgpu_encoder = to_amdgpu_encoder(encoder); struct amdgpu_encoder *amdgpu_encoder = to_amdgpu_encoder(encoder);
struct amdgpu_encoder_atom_dig *dig = amdgpu_encoder->enc_priv; struct amdgpu_encoder_atom_dig *dig = amdgpu_encoder->enc_priv;
struct drm_connector *connector; struct drm_connector *connector;
struct drm_connector_list_iter iter;
struct amdgpu_connector *amdgpu_connector = NULL; struct amdgpu_connector *amdgpu_connector = NULL;
u32 tmp; u32 tmp;
int interlace = 0; int interlace = 0;
...@@ -1230,12 +1238,14 @@ static void dce_v10_0_audio_write_latency_fields(struct drm_encoder *encoder, ...@@ -1230,12 +1238,14 @@ static void dce_v10_0_audio_write_latency_fields(struct drm_encoder *encoder,
if (!dig || !dig->afmt || !dig->afmt->pin) if (!dig || !dig->afmt || !dig->afmt->pin)
return; return;
list_for_each_entry(connector, &encoder->dev->mode_config.connector_list, head) { drm_connector_list_iter_begin(dev, &iter);
drm_for_each_connector_iter(connector, &iter) {
if (connector->encoder == encoder) { if (connector->encoder == encoder) {
amdgpu_connector = to_amdgpu_connector(connector); amdgpu_connector = to_amdgpu_connector(connector);
break; break;
} }
} }
drm_connector_list_iter_end(&iter);
if (!amdgpu_connector) { if (!amdgpu_connector) {
DRM_ERROR("Couldn't find encoder's connector\n"); DRM_ERROR("Couldn't find encoder's connector\n");
...@@ -1261,10 +1271,12 @@ static void dce_v10_0_audio_write_latency_fields(struct drm_encoder *encoder, ...@@ -1261,10 +1271,12 @@ static void dce_v10_0_audio_write_latency_fields(struct drm_encoder *encoder,
static void dce_v10_0_audio_write_speaker_allocation(struct drm_encoder *encoder) static void dce_v10_0_audio_write_speaker_allocation(struct drm_encoder *encoder)
{ {
struct amdgpu_device *adev = encoder->dev->dev_private; struct drm_device *dev = encoder->dev;
struct amdgpu_device *adev = dev->dev_private;
struct amdgpu_encoder *amdgpu_encoder = to_amdgpu_encoder(encoder); struct amdgpu_encoder *amdgpu_encoder = to_amdgpu_encoder(encoder);
struct amdgpu_encoder_atom_dig *dig = amdgpu_encoder->enc_priv; struct amdgpu_encoder_atom_dig *dig = amdgpu_encoder->enc_priv;
struct drm_connector *connector; struct drm_connector *connector;
struct drm_connector_list_iter iter;
struct amdgpu_connector *amdgpu_connector = NULL; struct amdgpu_connector *amdgpu_connector = NULL;
u32 tmp; u32 tmp;
u8 *sadb = NULL; u8 *sadb = NULL;
...@@ -1273,12 +1285,14 @@ static void dce_v10_0_audio_write_speaker_allocation(struct drm_encoder *encoder ...@@ -1273,12 +1285,14 @@ static void dce_v10_0_audio_write_speaker_allocation(struct drm_encoder *encoder
if (!dig || !dig->afmt || !dig->afmt->pin) if (!dig || !dig->afmt || !dig->afmt->pin)
return; return;
list_for_each_entry(connector, &encoder->dev->mode_config.connector_list, head) { drm_connector_list_iter_begin(dev, &iter);
drm_for_each_connector_iter(connector, &iter) {
if (connector->encoder == encoder) { if (connector->encoder == encoder) {
amdgpu_connector = to_amdgpu_connector(connector); amdgpu_connector = to_amdgpu_connector(connector);
break; break;
} }
} }
drm_connector_list_iter_end(&iter);
if (!amdgpu_connector) { if (!amdgpu_connector) {
DRM_ERROR("Couldn't find encoder's connector\n"); DRM_ERROR("Couldn't find encoder's connector\n");
...@@ -1313,10 +1327,12 @@ static void dce_v10_0_audio_write_speaker_allocation(struct drm_encoder *encoder ...@@ -1313,10 +1327,12 @@ static void dce_v10_0_audio_write_speaker_allocation(struct drm_encoder *encoder
static void dce_v10_0_audio_write_sad_regs(struct drm_encoder *encoder) static void dce_v10_0_audio_write_sad_regs(struct drm_encoder *encoder)
{ {
struct amdgpu_device *adev = encoder->dev->dev_private; struct drm_device *dev = encoder->dev;
struct amdgpu_device *adev = dev->dev_private;
struct amdgpu_encoder *amdgpu_encoder = to_amdgpu_encoder(encoder); struct amdgpu_encoder *amdgpu_encoder = to_amdgpu_encoder(encoder);
struct amdgpu_encoder_atom_dig *dig = amdgpu_encoder->enc_priv; struct amdgpu_encoder_atom_dig *dig = amdgpu_encoder->enc_priv;
struct drm_connector *connector; struct drm_connector *connector;
struct drm_connector_list_iter iter;
struct amdgpu_connector *amdgpu_connector = NULL; struct amdgpu_connector *amdgpu_connector = NULL;
struct cea_sad *sads; struct cea_sad *sads;
int i, sad_count; int i, sad_count;
...@@ -1339,12 +1355,14 @@ static void dce_v10_0_audio_write_sad_regs(struct drm_encoder *encoder) ...@@ -1339,12 +1355,14 @@ static void dce_v10_0_audio_write_sad_regs(struct drm_encoder *encoder)
if (!dig || !dig->afmt || !dig->afmt->pin) if (!dig || !dig->afmt || !dig->afmt->pin)
return; return;
list_for_each_entry(connector, &encoder->dev->mode_config.connector_list, head) { drm_connector_list_iter_begin(dev, &iter);
drm_for_each_connector_iter(connector, &iter) {
if (connector->encoder == encoder) { if (connector->encoder == encoder) {
amdgpu_connector = to_amdgpu_connector(connector); amdgpu_connector = to_amdgpu_connector(connector);
break; break;
} }
} }
drm_connector_list_iter_end(&iter);
if (!amdgpu_connector) { if (!amdgpu_connector) {
DRM_ERROR("Couldn't find encoder's connector\n"); DRM_ERROR("Couldn't find encoder's connector\n");
......
...@@ -348,9 +348,11 @@ static void dce_v11_0_hpd_init(struct amdgpu_device *adev) ...@@ -348,9 +348,11 @@ static void dce_v11_0_hpd_init(struct amdgpu_device *adev)
{ {
struct drm_device *dev = adev->ddev; struct drm_device *dev = adev->ddev;
struct drm_connector *connector; struct drm_connector *connector;
struct drm_connector_list_iter iter;
u32 tmp; u32 tmp;
list_for_each_entry(connector, &dev->mode_config.connector_list, head) { drm_connector_list_iter_begin(dev, &iter);
drm_for_each_connector_iter(connector, &iter) {
struct amdgpu_connector *amdgpu_connector = to_amdgpu_connector(connector); struct amdgpu_connector *amdgpu_connector = to_amdgpu_connector(connector);
if (amdgpu_connector->hpd.hpd >= adev->mode_info.num_hpd) if (amdgpu_connector->hpd.hpd >= adev->mode_info.num_hpd)
...@@ -385,6 +387,7 @@ static void dce_v11_0_hpd_init(struct amdgpu_device *adev) ...@@ -385,6 +387,7 @@ static void dce_v11_0_hpd_init(struct amdgpu_device *adev)
dce_v11_0_hpd_set_polarity(adev, amdgpu_connector->hpd.hpd); dce_v11_0_hpd_set_polarity(adev, amdgpu_connector->hpd.hpd);
amdgpu_irq_get(adev, &adev->hpd_irq, amdgpu_connector->hpd.hpd); amdgpu_irq_get(adev, &adev->hpd_irq, amdgpu_connector->hpd.hpd);
} }
drm_connector_list_iter_end(&iter);
} }
/** /**
...@@ -399,9 +402,11 @@ static void dce_v11_0_hpd_fini(struct amdgpu_device *adev) ...@@ -399,9 +402,11 @@ static void dce_v11_0_hpd_fini(struct amdgpu_device *adev)
{ {
struct drm_device *dev = adev->ddev; struct drm_device *dev = adev->ddev;
struct drm_connector *connector; struct drm_connector *connector;
struct drm_connector_list_iter iter;
u32 tmp; u32 tmp;
list_for_each_entry(connector, &dev->mode_config.connector_list, head) { drm_connector_list_iter_begin(dev, &iter);
drm_for_each_connector_iter(connector, &iter) {
struct amdgpu_connector *amdgpu_connector = to_amdgpu_connector(connector); struct amdgpu_connector *amdgpu_connector = to_amdgpu_connector(connector);
if (amdgpu_connector->hpd.hpd >= adev->mode_info.num_hpd) if (amdgpu_connector->hpd.hpd >= adev->mode_info.num_hpd)
...@@ -413,6 +418,7 @@ static void dce_v11_0_hpd_fini(struct amdgpu_device *adev) ...@@ -413,6 +418,7 @@ static void dce_v11_0_hpd_fini(struct amdgpu_device *adev)
amdgpu_irq_put(adev, &adev->hpd_irq, amdgpu_connector->hpd.hpd); amdgpu_irq_put(adev, &adev->hpd_irq, amdgpu_connector->hpd.hpd);
} }
drm_connector_list_iter_end(&iter);
} }
static u32 dce_v11_0_hpd_get_gpio_reg(struct amdgpu_device *adev) static u32 dce_v11_0_hpd_get_gpio_reg(struct amdgpu_device *adev)
...@@ -1245,10 +1251,12 @@ static void dce_v11_0_afmt_audio_select_pin(struct drm_encoder *encoder) ...@@ -1245,10 +1251,12 @@ static void dce_v11_0_afmt_audio_select_pin(struct drm_encoder *encoder)
static void dce_v11_0_audio_write_latency_fields(struct drm_encoder *encoder, static void dce_v11_0_audio_write_latency_fields(struct drm_encoder *encoder,
struct drm_display_mode *mode) struct drm_display_mode *mode)
{ {
struct amdgpu_device *adev = encoder->dev->dev_private; struct drm_device *dev = encoder->dev;
struct amdgpu_device *adev = dev->dev_private;
struct amdgpu_encoder *amdgpu_encoder = to_amdgpu_encoder(encoder); struct amdgpu_encoder *amdgpu_encoder = to_amdgpu_encoder(encoder);
struct amdgpu_encoder_atom_dig *dig = amdgpu_encoder->enc_priv; struct amdgpu_encoder_atom_dig *dig = amdgpu_encoder->enc_priv;
struct drm_connector *connector; struct drm_connector *connector;
struct drm_connector_list_iter iter;
struct amdgpu_connector *amdgpu_connector = NULL; struct amdgpu_connector *amdgpu_connector = NULL;
u32 tmp; u32 tmp;
int interlace = 0; int interlace = 0;
...@@ -1256,12 +1264,14 @@ static void dce_v11_0_audio_write_latency_fields(struct drm_encoder *encoder, ...@@ -1256,12 +1264,14 @@ static void dce_v11_0_audio_write_latency_fields(struct drm_encoder *encoder,
if (!dig || !dig->afmt || !dig->afmt->pin) if (!dig || !dig->afmt || !dig->afmt->pin)
return; return;
list_for_each_entry(connector, &encoder->dev->mode_config.connector_list, head) { drm_connector_list_iter_begin(dev, &iter);
drm_for_each_connector_iter(connector, &iter) {
if (connector->encoder == encoder) { if (connector->encoder == encoder) {
amdgpu_connector = to_amdgpu_connector(connector); amdgpu_connector = to_amdgpu_connector(connector);
break; break;
} }
} }
drm_connector_list_iter_end(&iter);
if (!amdgpu_connector) { if (!amdgpu_connector) {
DRM_ERROR("Couldn't find encoder's connector\n"); DRM_ERROR("Couldn't find encoder's connector\n");
...@@ -1287,10 +1297,12 @@ static void dce_v11_0_audio_write_latency_fields(struct drm_encoder *encoder, ...@@ -1287,10 +1297,12 @@ static void dce_v11_0_audio_write_latency_fields(struct drm_encoder *encoder,
static void dce_v11_0_audio_write_speaker_allocation(struct drm_encoder *encoder) static void dce_v11_0_audio_write_speaker_allocation(struct drm_encoder *encoder)
{ {
struct amdgpu_device *adev = encoder->dev->dev_private; struct drm_device *dev = encoder->dev;
struct amdgpu_device *adev = dev->dev_private;
struct amdgpu_encoder *amdgpu_encoder = to_amdgpu_encoder(encoder); struct amdgpu_encoder *amdgpu_encoder = to_amdgpu_encoder(encoder);
struct amdgpu_encoder_atom_dig *dig = amdgpu_encoder->enc_priv; struct amdgpu_encoder_atom_dig *dig = amdgpu_encoder->enc_priv;
struct drm_connector *connector; struct drm_connector *connector;
struct drm_connector_list_iter iter;
struct amdgpu_connector *amdgpu_connector = NULL; struct amdgpu_connector *amdgpu_connector = NULL;
u32 tmp; u32 tmp;
u8 *sadb = NULL; u8 *sadb = NULL;
...@@ -1299,12 +1311,14 @@ static void dce_v11_0_audio_write_speaker_allocation(struct drm_encoder *encoder ...@@ -1299,12 +1311,14 @@ static void dce_v11_0_audio_write_speaker_allocation(struct drm_encoder *encoder
if (!dig || !dig->afmt || !dig->afmt->pin) if (!dig || !dig->afmt || !dig->afmt->pin)
return; return;
list_for_each_entry(connector, &encoder->dev->mode_config.connector_list, head) { drm_connector_list_iter_begin(dev, &iter);
drm_for_each_connector_iter(connector, &iter) {
if (connector->encoder == encoder) { if (connector->encoder == encoder) {
amdgpu_connector = to_amdgpu_connector(connector); amdgpu_connector = to_amdgpu_connector(connector);
break; break;
} }
} }
drm_connector_list_iter_end(&iter);
if (!amdgpu_connector) { if (!amdgpu_connector) {
DRM_ERROR("Couldn't find encoder's connector\n"); DRM_ERROR("Couldn't find encoder's connector\n");
...@@ -1339,10 +1353,12 @@ static void dce_v11_0_audio_write_speaker_allocation(struct drm_encoder *encoder ...@@ -1339,10 +1353,12 @@ static void dce_v11_0_audio_write_speaker_allocation(struct drm_encoder *encoder
static void dce_v11_0_audio_write_sad_regs(struct drm_encoder *encoder) static void dce_v11_0_audio_write_sad_regs(struct drm_encoder *encoder)
{ {
struct amdgpu_device *adev = encoder->dev->dev_private; struct drm_device *dev = encoder->dev;
struct amdgpu_device *adev = dev->dev_private;
struct amdgpu_encoder *amdgpu_encoder = to_amdgpu_encoder(encoder); struct amdgpu_encoder *amdgpu_encoder = to_amdgpu_encoder(encoder);
struct amdgpu_encoder_atom_dig *dig = amdgpu_encoder->enc_priv; struct amdgpu_encoder_atom_dig *dig = amdgpu_encoder->enc_priv;
struct drm_connector *connector; struct drm_connector *connector;
struct drm_connector_list_iter iter;
struct amdgpu_connector *amdgpu_connector = NULL; struct amdgpu_connector *amdgpu_connector = NULL;
struct cea_sad *sads; struct cea_sad *sads;
int i, sad_count; int i, sad_count;
...@@ -1365,12 +1381,14 @@ static void dce_v11_0_audio_write_sad_regs(struct drm_encoder *encoder) ...@@ -1365,12 +1381,14 @@ static void dce_v11_0_audio_write_sad_regs(struct drm_encoder *encoder)
if (!dig || !dig->afmt || !dig->afmt->pin) if (!dig || !dig->afmt || !dig->afmt->pin)
return; return;
list_for_each_entry(connector, &encoder->dev->mode_config.connector_list, head) { drm_connector_list_iter_begin(dev, &iter);
drm_for_each_connector_iter(connector, &iter) {
if (connector->encoder == encoder) { if (connector->encoder == encoder) {
amdgpu_connector = to_amdgpu_connector(connector); amdgpu_connector = to_amdgpu_connector(connector);
break; break;
} }
} }
drm_connector_list_iter_end(&iter);
if (!amdgpu_connector) { if (!amdgpu_connector) {
DRM_ERROR("Couldn't find encoder's connector\n"); DRM_ERROR("Couldn't find encoder's connector\n");
......
...@@ -281,9 +281,11 @@ static void dce_v6_0_hpd_init(struct amdgpu_device *adev) ...@@ -281,9 +281,11 @@ static void dce_v6_0_hpd_init(struct amdgpu_device *adev)
{ {
struct drm_device *dev = adev->ddev; struct drm_device *dev = adev->ddev;
struct drm_connector *connector; struct drm_connector *connector;
struct drm_connector_list_iter iter;
u32 tmp; u32 tmp;
list_for_each_entry(connector, &dev->mode_config.connector_list, head) { drm_connector_list_iter_begin(dev, &iter);
drm_for_each_connector_iter(connector, &iter) {
struct amdgpu_connector *amdgpu_connector = to_amdgpu_connector(connector); struct amdgpu_connector *amdgpu_connector = to_amdgpu_connector(connector);
if (amdgpu_connector->hpd.hpd >= adev->mode_info.num_hpd) if (amdgpu_connector->hpd.hpd >= adev->mode_info.num_hpd)
...@@ -309,7 +311,7 @@ static void dce_v6_0_hpd_init(struct amdgpu_device *adev) ...@@ -309,7 +311,7 @@ static void dce_v6_0_hpd_init(struct amdgpu_device *adev)
dce_v6_0_hpd_set_polarity(adev, amdgpu_connector->hpd.hpd); dce_v6_0_hpd_set_polarity(adev, amdgpu_connector->hpd.hpd);
amdgpu_irq_get(adev, &adev->hpd_irq, amdgpu_connector->hpd.hpd); amdgpu_irq_get(adev, &adev->hpd_irq, amdgpu_connector->hpd.hpd);
} }
drm_connector_list_iter_end(&iter);
} }
/** /**
...@@ -324,9 +326,11 @@ static void dce_v6_0_hpd_fini(struct amdgpu_device *adev) ...@@ -324,9 +326,11 @@ static void dce_v6_0_hpd_fini(struct amdgpu_device *adev)
{ {
struct drm_device *dev = adev->ddev; struct drm_device *dev = adev->ddev;
struct drm_connector *connector; struct drm_connector *connector;
struct drm_connector_list_iter iter;
u32 tmp; u32 tmp;
list_for_each_entry(connector, &dev->mode_config.connector_list, head) { drm_connector_list_iter_begin(dev, &iter);
drm_for_each_connector_iter(connector, &iter) {
struct amdgpu_connector *amdgpu_connector = to_amdgpu_connector(connector); struct amdgpu_connector *amdgpu_connector = to_amdgpu_connector(connector);
if (amdgpu_connector->hpd.hpd >= adev->mode_info.num_hpd) if (amdgpu_connector->hpd.hpd >= adev->mode_info.num_hpd)
...@@ -338,6 +342,7 @@ static void dce_v6_0_hpd_fini(struct amdgpu_device *adev) ...@@ -338,6 +342,7 @@ static void dce_v6_0_hpd_fini(struct amdgpu_device *adev)
amdgpu_irq_put(adev, &adev->hpd_irq, amdgpu_connector->hpd.hpd); amdgpu_irq_put(adev, &adev->hpd_irq, amdgpu_connector->hpd.hpd);
} }
drm_connector_list_iter_end(&iter);
} }
static u32 dce_v6_0_hpd_get_gpio_reg(struct amdgpu_device *adev) static u32 dce_v6_0_hpd_get_gpio_reg(struct amdgpu_device *adev)
...@@ -1124,20 +1129,24 @@ static void dce_v6_0_audio_select_pin(struct drm_encoder *encoder) ...@@ -1124,20 +1129,24 @@ static void dce_v6_0_audio_select_pin(struct drm_encoder *encoder)
static void dce_v6_0_audio_write_latency_fields(struct drm_encoder *encoder, static void dce_v6_0_audio_write_latency_fields(struct drm_encoder *encoder,
struct drm_display_mode *mode) struct drm_display_mode *mode)
{ {
struct amdgpu_device *adev = encoder->dev->dev_private; struct drm_device *dev = encoder->dev;
struct amdgpu_device *adev = dev->dev_private;
struct amdgpu_encoder *amdgpu_encoder = to_amdgpu_encoder(encoder); struct amdgpu_encoder *amdgpu_encoder = to_amdgpu_encoder(encoder);
struct amdgpu_encoder_atom_dig *dig = amdgpu_encoder->enc_priv; struct amdgpu_encoder_atom_dig *dig = amdgpu_encoder->enc_priv;
struct drm_connector *connector; struct drm_connector *connector;
struct drm_connector_list_iter iter;
struct amdgpu_connector *amdgpu_connector = NULL; struct amdgpu_connector *amdgpu_connector = NULL;
int interlace = 0; int interlace = 0;
u32 tmp; u32 tmp;
list_for_each_entry(connector, &encoder->dev->mode_config.connector_list, head) { drm_connector_list_iter_begin(dev, &iter);
drm_for_each_connector_iter(connector, &iter) {
if (connector->encoder == encoder) { if (connector->encoder == encoder) {
amdgpu_connector = to_amdgpu_connector(connector); amdgpu_connector = to_amdgpu_connector(connector);
break; break;
} }
} }
drm_connector_list_iter_end(&iter);
if (!amdgpu_connector) { if (!amdgpu_connector) {
DRM_ERROR("Couldn't find encoder's connector\n"); DRM_ERROR("Couldn't find encoder's connector\n");
...@@ -1164,21 +1173,25 @@ static void dce_v6_0_audio_write_latency_fields(struct drm_encoder *encoder, ...@@ -1164,21 +1173,25 @@ static void dce_v6_0_audio_write_latency_fields(struct drm_encoder *encoder,
static void dce_v6_0_audio_write_speaker_allocation(struct drm_encoder *encoder) static void dce_v6_0_audio_write_speaker_allocation(struct drm_encoder *encoder)
{ {
struct amdgpu_device *adev = encoder->dev->dev_private; struct drm_device *dev = encoder->dev;
struct amdgpu_device *adev = dev->dev_private;
struct amdgpu_encoder *amdgpu_encoder = to_amdgpu_encoder(encoder); struct amdgpu_encoder *amdgpu_encoder = to_amdgpu_encoder(encoder);
struct amdgpu_encoder_atom_dig *dig = amdgpu_encoder->enc_priv; struct amdgpu_encoder_atom_dig *dig = amdgpu_encoder->enc_priv;
struct drm_connector *connector; struct drm_connector *connector;
struct drm_connector_list_iter iter;
struct amdgpu_connector *amdgpu_connector = NULL; struct amdgpu_connector *amdgpu_connector = NULL;
u8 *sadb = NULL; u8 *sadb = NULL;
int sad_count; int sad_count;
u32 tmp; u32 tmp;
list_for_each_entry(connector, &encoder->dev->mode_config.connector_list, head) { drm_connector_list_iter_begin(dev, &iter);
drm_for_each_connector_iter(connector, &iter) {
if (connector->encoder == encoder) { if (connector->encoder == encoder) {
amdgpu_connector = to_amdgpu_connector(connector); amdgpu_connector = to_amdgpu_connector(connector);
break; break;
} }
} }
drm_connector_list_iter_end(&iter);
if (!amdgpu_connector) { if (!amdgpu_connector) {
DRM_ERROR("Couldn't find encoder's connector\n"); DRM_ERROR("Couldn't find encoder's connector\n");
...@@ -1221,10 +1234,12 @@ static void dce_v6_0_audio_write_speaker_allocation(struct drm_encoder *encoder) ...@@ -1221,10 +1234,12 @@ static void dce_v6_0_audio_write_speaker_allocation(struct drm_encoder *encoder)
static void dce_v6_0_audio_write_sad_regs(struct drm_encoder *encoder) static void dce_v6_0_audio_write_sad_regs(struct drm_encoder *encoder)
{ {
struct amdgpu_device *adev = encoder->dev->dev_private; struct drm_device *dev = encoder->dev;
struct amdgpu_device *adev = dev->dev_private;
struct amdgpu_encoder *amdgpu_encoder = to_amdgpu_encoder(encoder); struct amdgpu_encoder *amdgpu_encoder = to_amdgpu_encoder(encoder);
struct amdgpu_encoder_atom_dig *dig = amdgpu_encoder->enc_priv; struct amdgpu_encoder_atom_dig *dig = amdgpu_encoder->enc_priv;
struct drm_connector *connector; struct drm_connector *connector;
struct drm_connector_list_iter iter;
struct amdgpu_connector *amdgpu_connector = NULL; struct amdgpu_connector *amdgpu_connector = NULL;
struct cea_sad *sads; struct cea_sad *sads;
int i, sad_count; int i, sad_count;
...@@ -1244,12 +1259,14 @@ static void dce_v6_0_audio_write_sad_regs(struct drm_encoder *encoder) ...@@ -1244,12 +1259,14 @@ static void dce_v6_0_audio_write_sad_regs(struct drm_encoder *encoder)
{ ixAZALIA_F0_CODEC_PIN_CONTROL_AUDIO_DESCRIPTOR13, HDMI_AUDIO_CODING_TYPE_WMA_PRO }, { ixAZALIA_F0_CODEC_PIN_CONTROL_AUDIO_DESCRIPTOR13, HDMI_AUDIO_CODING_TYPE_WMA_PRO },
}; };
list_for_each_entry(connector, &encoder->dev->mode_config.connector_list, head) { drm_connector_list_iter_begin(dev, &iter);
drm_for_each_connector_iter(connector, &iter) {
if (connector->encoder == encoder) { if (connector->encoder == encoder) {
amdgpu_connector = to_amdgpu_connector(connector); amdgpu_connector = to_amdgpu_connector(connector);
break; break;
} }
} }
drm_connector_list_iter_end(&iter);
if (!amdgpu_connector) { if (!amdgpu_connector) {
DRM_ERROR("Couldn't find encoder's connector\n"); DRM_ERROR("Couldn't find encoder's connector\n");
...@@ -1632,6 +1649,7 @@ static void dce_v6_0_afmt_setmode(struct drm_encoder *encoder, ...@@ -1632,6 +1649,7 @@ static void dce_v6_0_afmt_setmode(struct drm_encoder *encoder,
struct amdgpu_encoder *amdgpu_encoder = to_amdgpu_encoder(encoder); struct amdgpu_encoder *amdgpu_encoder = to_amdgpu_encoder(encoder);
struct amdgpu_encoder_atom_dig *dig = amdgpu_encoder->enc_priv; struct amdgpu_encoder_atom_dig *dig = amdgpu_encoder->enc_priv;
struct drm_connector *connector; struct drm_connector *connector;
struct drm_connector_list_iter iter;
struct amdgpu_connector *amdgpu_connector = NULL; struct amdgpu_connector *amdgpu_connector = NULL;
int em = amdgpu_atombios_encoder_get_encoder_mode(encoder); int em = amdgpu_atombios_encoder_get_encoder_mode(encoder);
int bpc = 8; int bpc = 8;
...@@ -1639,12 +1657,14 @@ static void dce_v6_0_afmt_setmode(struct drm_encoder *encoder, ...@@ -1639,12 +1657,14 @@ static void dce_v6_0_afmt_setmode(struct drm_encoder *encoder,
if (!dig || !dig->afmt) if (!dig || !dig->afmt)
return; return;
list_for_each_entry(connector, &encoder->dev->mode_config.connector_list, head) { drm_connector_list_iter_begin(dev, &iter);
drm_for_each_connector_iter(connector, &iter) {
if (connector->encoder == encoder) { if (connector->encoder == encoder) {
amdgpu_connector = to_amdgpu_connector(connector); amdgpu_connector = to_amdgpu_connector(connector);
break; break;
} }
} }
drm_connector_list_iter_end(&iter);
if (!amdgpu_connector) { if (!amdgpu_connector) {
DRM_ERROR("Couldn't find encoder's connector\n"); DRM_ERROR("Couldn't find encoder's connector\n");
......
...@@ -275,9 +275,11 @@ static void dce_v8_0_hpd_init(struct amdgpu_device *adev) ...@@ -275,9 +275,11 @@ static void dce_v8_0_hpd_init(struct amdgpu_device *adev)
{ {
struct drm_device *dev = adev->ddev; struct drm_device *dev = adev->ddev;
struct drm_connector *connector; struct drm_connector *connector;
struct drm_connector_list_iter iter;
u32 tmp; u32 tmp;
list_for_each_entry(connector, &dev->mode_config.connector_list, head) { drm_connector_list_iter_begin(dev, &iter);
drm_for_each_connector_iter(connector, &iter) {
struct amdgpu_connector *amdgpu_connector = to_amdgpu_connector(connector); struct amdgpu_connector *amdgpu_connector = to_amdgpu_connector(connector);
if (amdgpu_connector->hpd.hpd >= adev->mode_info.num_hpd) if (amdgpu_connector->hpd.hpd >= adev->mode_info.num_hpd)
...@@ -303,6 +305,7 @@ static void dce_v8_0_hpd_init(struct amdgpu_device *adev) ...@@ -303,6 +305,7 @@ static void dce_v8_0_hpd_init(struct amdgpu_device *adev)
dce_v8_0_hpd_set_polarity(adev, amdgpu_connector->hpd.hpd); dce_v8_0_hpd_set_polarity(adev, amdgpu_connector->hpd.hpd);
amdgpu_irq_get(adev, &adev->hpd_irq, amdgpu_connector->hpd.hpd); amdgpu_irq_get(adev, &adev->hpd_irq, amdgpu_connector->hpd.hpd);
} }
drm_connector_list_iter_end(&iter);
} }
/** /**
...@@ -317,9 +320,11 @@ static void dce_v8_0_hpd_fini(struct amdgpu_device *adev) ...@@ -317,9 +320,11 @@ static void dce_v8_0_hpd_fini(struct amdgpu_device *adev)
{ {
struct drm_device *dev = adev->ddev; struct drm_device *dev = adev->ddev;
struct drm_connector *connector; struct drm_connector *connector;
struct drm_connector_list_iter iter;
u32 tmp; u32 tmp;
list_for_each_entry(connector, &dev->mode_config.connector_list, head) { drm_connector_list_iter_begin(dev, &iter);
drm_for_each_connector_iter(connector, &iter) {
struct amdgpu_connector *amdgpu_connector = to_amdgpu_connector(connector); struct amdgpu_connector *amdgpu_connector = to_amdgpu_connector(connector);
if (amdgpu_connector->hpd.hpd >= adev->mode_info.num_hpd) if (amdgpu_connector->hpd.hpd >= adev->mode_info.num_hpd)
...@@ -331,6 +336,7 @@ static void dce_v8_0_hpd_fini(struct amdgpu_device *adev) ...@@ -331,6 +336,7 @@ static void dce_v8_0_hpd_fini(struct amdgpu_device *adev)
amdgpu_irq_put(adev, &adev->hpd_irq, amdgpu_connector->hpd.hpd); amdgpu_irq_put(adev, &adev->hpd_irq, amdgpu_connector->hpd.hpd);
} }
drm_connector_list_iter_end(&iter);
} }
static u32 dce_v8_0_hpd_get_gpio_reg(struct amdgpu_device *adev) static u32 dce_v8_0_hpd_get_gpio_reg(struct amdgpu_device *adev)
...@@ -1157,10 +1163,12 @@ static void dce_v8_0_afmt_audio_select_pin(struct drm_encoder *encoder) ...@@ -1157,10 +1163,12 @@ static void dce_v8_0_afmt_audio_select_pin(struct drm_encoder *encoder)
static void dce_v8_0_audio_write_latency_fields(struct drm_encoder *encoder, static void dce_v8_0_audio_write_latency_fields(struct drm_encoder *encoder,
struct drm_display_mode *mode) struct drm_display_mode *mode)
{ {
struct amdgpu_device *adev = encoder->dev->dev_private; struct drm_device *dev = encoder->dev;
struct amdgpu_device *adev = dev->dev_private;
struct amdgpu_encoder *amdgpu_encoder = to_amdgpu_encoder(encoder); struct amdgpu_encoder *amdgpu_encoder = to_amdgpu_encoder(encoder);
struct amdgpu_encoder_atom_dig *dig = amdgpu_encoder->enc_priv; struct amdgpu_encoder_atom_dig *dig = amdgpu_encoder->enc_priv;
struct drm_connector *connector; struct drm_connector *connector;
struct drm_connector_list_iter iter;
struct amdgpu_connector *amdgpu_connector = NULL; struct amdgpu_connector *amdgpu_connector = NULL;
u32 tmp = 0, offset; u32 tmp = 0, offset;
...@@ -1169,12 +1177,14 @@ static void dce_v8_0_audio_write_latency_fields(struct drm_encoder *encoder, ...@@ -1169,12 +1177,14 @@ static void dce_v8_0_audio_write_latency_fields(struct drm_encoder *encoder,
offset = dig->afmt->pin->offset; offset = dig->afmt->pin->offset;
list_for_each_entry(connector, &encoder->dev->mode_config.connector_list, head) { drm_connector_list_iter_begin(dev, &iter);
drm_for_each_connector_iter(connector, &iter) {
if (connector->encoder == encoder) { if (connector->encoder == encoder) {
amdgpu_connector = to_amdgpu_connector(connector); amdgpu_connector = to_amdgpu_connector(connector);
break; break;
} }
} }
drm_connector_list_iter_end(&iter);
if (!amdgpu_connector) { if (!amdgpu_connector) {
DRM_ERROR("Couldn't find encoder's connector\n"); DRM_ERROR("Couldn't find encoder's connector\n");
...@@ -1214,10 +1224,12 @@ static void dce_v8_0_audio_write_latency_fields(struct drm_encoder *encoder, ...@@ -1214,10 +1224,12 @@ static void dce_v8_0_audio_write_latency_fields(struct drm_encoder *encoder,
static void dce_v8_0_audio_write_speaker_allocation(struct drm_encoder *encoder) static void dce_v8_0_audio_write_speaker_allocation(struct drm_encoder *encoder)
{ {
struct amdgpu_device *adev = encoder->dev->dev_private; struct drm_device *dev = encoder->dev;
struct amdgpu_device *adev = dev->dev_private;
struct amdgpu_encoder *amdgpu_encoder = to_amdgpu_encoder(encoder); struct amdgpu_encoder *amdgpu_encoder = to_amdgpu_encoder(encoder);
struct amdgpu_encoder_atom_dig *dig = amdgpu_encoder->enc_priv; struct amdgpu_encoder_atom_dig *dig = amdgpu_encoder->enc_priv;
struct drm_connector *connector; struct drm_connector *connector;
struct drm_connector_list_iter iter;
struct amdgpu_connector *amdgpu_connector = NULL; struct amdgpu_connector *amdgpu_connector = NULL;
u32 offset, tmp; u32 offset, tmp;
u8 *sadb = NULL; u8 *sadb = NULL;
...@@ -1228,12 +1240,14 @@ static void dce_v8_0_audio_write_speaker_allocation(struct drm_encoder *encoder) ...@@ -1228,12 +1240,14 @@ static void dce_v8_0_audio_write_speaker_allocation(struct drm_encoder *encoder)
offset = dig->afmt->pin->offset; offset = dig->afmt->pin->offset;
list_for_each_entry(connector, &encoder->dev->mode_config.connector_list, head) { drm_connector_list_iter_begin(dev, &iter);
drm_for_each_connector_iter(connector, &iter) {
if (connector->encoder == encoder) { if (connector->encoder == encoder) {
amdgpu_connector = to_amdgpu_connector(connector); amdgpu_connector = to_amdgpu_connector(connector);
break; break;
} }
} }
drm_connector_list_iter_end(&iter);
if (!amdgpu_connector) { if (!amdgpu_connector) {
DRM_ERROR("Couldn't find encoder's connector\n"); DRM_ERROR("Couldn't find encoder's connector\n");
...@@ -1263,11 +1277,13 @@ static void dce_v8_0_audio_write_speaker_allocation(struct drm_encoder *encoder) ...@@ -1263,11 +1277,13 @@ static void dce_v8_0_audio_write_speaker_allocation(struct drm_encoder *encoder)
static void dce_v8_0_audio_write_sad_regs(struct drm_encoder *encoder) static void dce_v8_0_audio_write_sad_regs(struct drm_encoder *encoder)
{ {
struct amdgpu_device *adev = encoder->dev->dev_private; struct drm_device *dev = encoder->dev;
struct amdgpu_device *adev = dev->dev_private;
struct amdgpu_encoder *amdgpu_encoder = to_amdgpu_encoder(encoder); struct amdgpu_encoder *amdgpu_encoder = to_amdgpu_encoder(encoder);
struct amdgpu_encoder_atom_dig *dig = amdgpu_encoder->enc_priv; struct amdgpu_encoder_atom_dig *dig = amdgpu_encoder->enc_priv;
u32 offset; u32 offset;
struct drm_connector *connector; struct drm_connector *connector;
struct drm_connector_list_iter iter;
struct amdgpu_connector *amdgpu_connector = NULL; struct amdgpu_connector *amdgpu_connector = NULL;
struct cea_sad *sads; struct cea_sad *sads;
int i, sad_count; int i, sad_count;
...@@ -1292,12 +1308,14 @@ static void dce_v8_0_audio_write_sad_regs(struct drm_encoder *encoder) ...@@ -1292,12 +1308,14 @@ static void dce_v8_0_audio_write_sad_regs(struct drm_encoder *encoder)
offset = dig->afmt->pin->offset; offset = dig->afmt->pin->offset;
list_for_each_entry(connector, &encoder->dev->mode_config.connector_list, head) { drm_connector_list_iter_begin(dev, &iter);
drm_for_each_connector_iter(connector, &iter) {
if (connector->encoder == encoder) { if (connector->encoder == encoder) {
amdgpu_connector = to_amdgpu_connector(connector); amdgpu_connector = to_amdgpu_connector(connector);
break; break;
} }
} }
drm_connector_list_iter_end(&iter);
if (!amdgpu_connector) { if (!amdgpu_connector) {
DRM_ERROR("Couldn't find encoder's connector\n"); DRM_ERROR("Couldn't find encoder's connector\n");
......
...@@ -946,27 +946,29 @@ static int detect_mst_link_for_all_connectors(struct drm_device *dev) ...@@ -946,27 +946,29 @@ static int detect_mst_link_for_all_connectors(struct drm_device *dev)
{ {
struct amdgpu_dm_connector *aconnector; struct amdgpu_dm_connector *aconnector;
struct drm_connector *connector; struct drm_connector *connector;
struct drm_connector_list_iter iter;
int ret = 0; int ret = 0;
drm_modeset_lock(&dev->mode_config.connection_mutex, NULL); drm_connector_list_iter_begin(dev, &iter);
drm_for_each_connector_iter(connector, &iter) {
list_for_each_entry(connector, &dev->mode_config.connector_list, head) {
aconnector = to_amdgpu_dm_connector(connector); aconnector = to_amdgpu_dm_connector(connector);
if (aconnector->dc_link->type == dc_connection_mst_branch && if (aconnector->dc_link->type == dc_connection_mst_branch &&
aconnector->mst_mgr.aux) { aconnector->mst_mgr.aux) {
DRM_DEBUG_DRIVER("DM_MST: starting TM on aconnector: %p [id: %d]\n", DRM_DEBUG_DRIVER("DM_MST: starting TM on aconnector: %p [id: %d]\n",
aconnector, aconnector->base.base.id); aconnector,
aconnector->base.base.id);
ret = drm_dp_mst_topology_mgr_set_mst(&aconnector->mst_mgr, true); ret = drm_dp_mst_topology_mgr_set_mst(&aconnector->mst_mgr, true);
if (ret < 0) { if (ret < 0) {
DRM_ERROR("DM_MST: Failed to start MST\n"); DRM_ERROR("DM_MST: Failed to start MST\n");
((struct dc_link *)aconnector->dc_link)->type = dc_connection_single; aconnector->dc_link->type =
return ret; dc_connection_single;
} break;
} }
}
} }
drm_connector_list_iter_end(&iter);
drm_modeset_unlock(&dev->mode_config.connection_mutex);
return ret; return ret;
} }
...@@ -1009,14 +1011,13 @@ static void s3_handle_mst(struct drm_device *dev, bool suspend) ...@@ -1009,14 +1011,13 @@ static void s3_handle_mst(struct drm_device *dev, bool suspend)
{ {
struct amdgpu_dm_connector *aconnector; struct amdgpu_dm_connector *aconnector;
struct drm_connector *connector; struct drm_connector *connector;
struct drm_connector_list_iter iter;
struct drm_dp_mst_topology_mgr *mgr; struct drm_dp_mst_topology_mgr *mgr;
int ret; int ret;
bool need_hotplug = false; bool need_hotplug = false;
drm_modeset_lock(&dev->mode_config.connection_mutex, NULL); drm_connector_list_iter_begin(dev, &iter);
drm_for_each_connector_iter(connector, &iter) {
list_for_each_entry(connector, &dev->mode_config.connector_list,
head) {
aconnector = to_amdgpu_dm_connector(connector); aconnector = to_amdgpu_dm_connector(connector);
if (aconnector->dc_link->type != dc_connection_mst_branch || if (aconnector->dc_link->type != dc_connection_mst_branch ||
aconnector->mst_port) aconnector->mst_port)
...@@ -1034,8 +1035,7 @@ static void s3_handle_mst(struct drm_device *dev, bool suspend) ...@@ -1034,8 +1035,7 @@ static void s3_handle_mst(struct drm_device *dev, bool suspend)
} }
} }
} }
drm_connector_list_iter_end(&iter);
drm_modeset_unlock(&dev->mode_config.connection_mutex);
if (need_hotplug) if (need_hotplug)
drm_kms_helper_hotplug_event(dev); drm_kms_helper_hotplug_event(dev);
...@@ -1217,6 +1217,7 @@ static int dm_resume(void *handle) ...@@ -1217,6 +1217,7 @@ static int dm_resume(void *handle)
struct amdgpu_display_manager *dm = &adev->dm; struct amdgpu_display_manager *dm = &adev->dm;
struct amdgpu_dm_connector *aconnector; struct amdgpu_dm_connector *aconnector;
struct drm_connector *connector; struct drm_connector *connector;
struct drm_connector_list_iter iter;
struct drm_crtc *crtc; struct drm_crtc *crtc;
struct drm_crtc_state *new_crtc_state; struct drm_crtc_state *new_crtc_state;
struct dm_crtc_state *dm_new_crtc_state; struct dm_crtc_state *dm_new_crtc_state;
...@@ -1249,7 +1250,8 @@ static int dm_resume(void *handle) ...@@ -1249,7 +1250,8 @@ static int dm_resume(void *handle)
s3_handle_mst(ddev, false); s3_handle_mst(ddev, false);
/* Do detection*/ /* Do detection*/
list_for_each_entry(connector, &ddev->mode_config.connector_list, head) { drm_connector_list_iter_begin(ddev, &iter);
drm_for_each_connector_iter(connector, &iter) {
aconnector = to_amdgpu_dm_connector(connector); aconnector = to_amdgpu_dm_connector(connector);
/* /*
...@@ -1277,6 +1279,7 @@ static int dm_resume(void *handle) ...@@ -1277,6 +1279,7 @@ static int dm_resume(void *handle)
amdgpu_dm_update_connector_after_detect(aconnector); amdgpu_dm_update_connector_after_detect(aconnector);
mutex_unlock(&aconnector->hpd_lock); mutex_unlock(&aconnector->hpd_lock);
} }
drm_connector_list_iter_end(&iter);
/* Force mode set in atomic commit */ /* Force mode set in atomic commit */
for_each_new_crtc_in_state(dm->cached_state, crtc, new_crtc_state, i) for_each_new_crtc_in_state(dm->cached_state, crtc, new_crtc_state, i)
......
...@@ -732,8 +732,10 @@ void amdgpu_dm_hpd_init(struct amdgpu_device *adev) ...@@ -732,8 +732,10 @@ void amdgpu_dm_hpd_init(struct amdgpu_device *adev)
{ {
struct drm_device *dev = adev->ddev; struct drm_device *dev = adev->ddev;
struct drm_connector *connector; struct drm_connector *connector;
struct drm_connector_list_iter iter;
list_for_each_entry(connector, &dev->mode_config.connector_list, head) { drm_connector_list_iter_begin(dev, &iter);
drm_for_each_connector_iter(connector, &iter) {
struct amdgpu_dm_connector *amdgpu_dm_connector = struct amdgpu_dm_connector *amdgpu_dm_connector =
to_amdgpu_dm_connector(connector); to_amdgpu_dm_connector(connector);
...@@ -751,6 +753,7 @@ void amdgpu_dm_hpd_init(struct amdgpu_device *adev) ...@@ -751,6 +753,7 @@ void amdgpu_dm_hpd_init(struct amdgpu_device *adev)
true); true);
} }
} }
drm_connector_list_iter_end(&iter);
} }
/** /**
...@@ -765,8 +768,10 @@ void amdgpu_dm_hpd_fini(struct amdgpu_device *adev) ...@@ -765,8 +768,10 @@ void amdgpu_dm_hpd_fini(struct amdgpu_device *adev)
{ {
struct drm_device *dev = adev->ddev; struct drm_device *dev = adev->ddev;
struct drm_connector *connector; struct drm_connector *connector;
struct drm_connector_list_iter iter;
list_for_each_entry(connector, &dev->mode_config.connector_list, head) { drm_connector_list_iter_begin(dev, &iter);
drm_for_each_connector_iter(connector, &iter) {
struct amdgpu_dm_connector *amdgpu_dm_connector = struct amdgpu_dm_connector *amdgpu_dm_connector =
to_amdgpu_dm_connector(connector); to_amdgpu_dm_connector(connector);
const struct dc_link *dc_link = amdgpu_dm_connector->dc_link; const struct dc_link *dc_link = amdgpu_dm_connector->dc_link;
...@@ -779,4 +784,5 @@ void amdgpu_dm_hpd_fini(struct amdgpu_device *adev) ...@@ -779,4 +784,5 @@ void amdgpu_dm_hpd_fini(struct amdgpu_device *adev)
false); false);
} }
} }
drm_connector_list_iter_end(&iter);
} }
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