[PATCH 04/18] drm/amd/display: Skip writeback connector when we get amdgpu_dm_connector
Alex Hung
alex.hung at amd.com
Tue Sep 5 18:47:36 UTC 2023
Reviewed-by: Alex Hung <alex.hung at amd.com>
On 2023-08-16 15:26, Alex Hung wrote:
> From: Harry Wentland <harry.wentland at amd.com>
>
> [WHY]
> Writeback connectors are based on a different object:
> drm_writeback_connector, and are therefore different from
> amdgpu_dm_connector. We need to be careful to ensure code
> designed for amdgpu_dm_connector doesn't inadvertently try
> to operate on a drm_writeback_connector.
>
> [HOW]
> Skip them when connector type is DRM_MODE_CONNECTOR_WRITEBACK.
>
> Signed-off-by: Harry Wentland <harry.wentland at amd.com>
> Signed-off-by: Alex Hung <alex.hung at amd.com>
> ---
> .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 62 +++++++++++++++++--
> .../drm/amd/display/amdgpu_dm/amdgpu_dm_crc.c | 3 +
> .../drm/amd/display/amdgpu_dm/amdgpu_dm_irq.c | 22 +++++--
> 3 files changed, 76 insertions(+), 11 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> index 445369afcead..363d91d49a3a 100644
> --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> @@ -721,6 +721,10 @@ static void dmub_hpd_callback(struct amdgpu_device *adev,
>
> drm_connector_list_iter_begin(dev, &iter);
> drm_for_each_connector_iter(connector, &iter) {
> +
> + if (connector->connector_type == DRM_MODE_CONNECTOR_WRITEBACK)
> + continue;
> +
> aconnector = to_amdgpu_dm_connector(connector);
> if (link && aconnector->dc_link == link) {
> if (notify->type == DMUB_NOTIFICATION_HPD)
> @@ -945,6 +949,10 @@ static int amdgpu_dm_audio_component_get_eld(struct device *kdev, int port,
>
> drm_connector_list_iter_begin(dev, &conn_iter);
> drm_for_each_connector_iter(connector, &conn_iter) {
> +
> + if (connector->connector_type == DRM_MODE_CONNECTOR_WRITEBACK)
> + continue;
> +
> aconnector = to_amdgpu_dm_connector(connector);
> if (aconnector->audio_inst != port)
> continue;
> @@ -2270,6 +2278,10 @@ static int detect_mst_link_for_all_connectors(struct drm_device *dev)
>
> drm_connector_list_iter_begin(dev, &iter);
> drm_for_each_connector_iter(connector, &iter) {
> +
> + if (connector->connector_type == DRM_MODE_CONNECTOR_WRITEBACK)
> + continue;
> +
> aconnector = to_amdgpu_dm_connector(connector);
> if (aconnector->dc_link->type == dc_connection_mst_branch &&
> aconnector->mst_mgr.aux) {
> @@ -2350,6 +2362,10 @@ static void s3_handle_mst(struct drm_device *dev, bool suspend)
>
> drm_connector_list_iter_begin(dev, &iter);
> drm_for_each_connector_iter(connector, &iter) {
> +
> + if (connector->connector_type == DRM_MODE_CONNECTOR_WRITEBACK)
> + continue;
> +
> aconnector = to_amdgpu_dm_connector(connector);
> if (aconnector->dc_link->type != dc_connection_mst_branch ||
> aconnector->mst_root)
> @@ -2865,6 +2881,10 @@ static int dm_resume(void *handle)
> /* Do detection*/
> drm_connector_list_iter_begin(ddev, &iter);
> drm_for_each_connector_iter(connector, &iter) {
> +
> + if (connector->connector_type == DRM_MODE_CONNECTOR_WRITEBACK)
> + continue;
> +
> aconnector = to_amdgpu_dm_connector(connector);
>
> if (!aconnector->dc_link)
> @@ -3416,6 +3436,9 @@ static void register_hpd_handlers(struct amdgpu_device *adev)
> list_for_each_entry(connector,
> &dev->mode_config.connector_list, head) {
>
> + if (connector->connector_type == DRM_MODE_CONNECTOR_WRITEBACK)
> + continue;
> +
> aconnector = to_amdgpu_dm_connector(connector);
> dc_link = aconnector->dc_link;
>
> @@ -5413,10 +5436,13 @@ static void fill_stream_properties_from_drm_display_mode(
> {
> struct dc_crtc_timing *timing_out = &stream->timing;
> const struct drm_display_info *info = &connector->display_info;
> - struct amdgpu_dm_connector *aconnector = to_amdgpu_dm_connector(connector);
> + struct amdgpu_dm_connector *aconnector = NULL;
> struct hdmi_vendor_infoframe hv_frame;
> struct hdmi_avi_infoframe avi_frame;
>
> + if (connector->connector_type != DRM_MODE_CONNECTOR_WRITEBACK)
> + aconnector = to_amdgpu_dm_connector(connector);
> +
> memset(&hv_frame, 0, sizeof(hv_frame));
> memset(&avi_frame, 0, sizeof(avi_frame));
>
> @@ -6843,6 +6869,9 @@ static int dm_update_mst_vcpi_slots_for_dsc(struct drm_atomic_state *state,
>
> for_each_new_connector_in_state(state, connector, new_con_state, i) {
>
> + if (connector->connector_type == DRM_MODE_CONNECTOR_WRITEBACK)
> + continue;
> +
> aconnector = to_amdgpu_dm_connector(connector);
>
> if (!aconnector->mst_output_port)
> @@ -8392,6 +8421,9 @@ static void amdgpu_dm_commit_audio(struct drm_device *dev,
> if (!drm_atomic_crtc_needs_modeset(new_crtc_state))
> continue;
>
> + if (connector->connector_type == DRM_MODE_CONNECTOR_WRITEBACK)
> + continue;
> +
> notify:
> aconnector = to_amdgpu_dm_connector(connector);
>
> @@ -8425,6 +8457,9 @@ static void amdgpu_dm_commit_audio(struct drm_device *dev,
> if (!status)
> continue;
>
> + if (connector->connector_type == DRM_MODE_CONNECTOR_WRITEBACK)
> + continue;
> +
> aconnector = to_amdgpu_dm_connector(connector);
>
> mutex_lock(&adev->dm.audio_lock);
> @@ -8686,7 +8721,12 @@ static void amdgpu_dm_atomic_commit_tail(struct drm_atomic_state *state)
> for_each_oldnew_connector_in_state(state, connector, old_con_state, new_con_state, i) {
> struct dm_connector_state *dm_new_con_state = to_dm_connector_state(new_con_state);
> struct amdgpu_crtc *acrtc = to_amdgpu_crtc(dm_new_con_state->base.crtc);
> - struct amdgpu_dm_connector *aconnector = to_amdgpu_dm_connector(connector);
> + struct amdgpu_dm_connector *aconnector;
> +
> + if (connector->connector_type == DRM_MODE_CONNECTOR_WRITEBACK)
> + continue;
> +
> + aconnector = to_amdgpu_dm_connector(connector);
>
> if (!adev->dm.hdcp_workqueue)
> continue;
> @@ -9029,10 +9069,15 @@ static int dm_force_atomic_commit(struct drm_connector *connector)
> void dm_restore_drm_connector_state(struct drm_device *dev,
> struct drm_connector *connector)
> {
> - struct amdgpu_dm_connector *aconnector = to_amdgpu_dm_connector(connector);
> + struct amdgpu_dm_connector *aconnector;
> struct amdgpu_crtc *disconnected_acrtc;
> struct dm_crtc_state *acrtc_state;
>
> + if (connector->connector_type == DRM_MODE_CONNECTOR_WRITEBACK)
> + return;
> +
> + aconnector = to_amdgpu_dm_connector(connector);
> +
> if (!aconnector->dc_sink || !connector->state || !connector->encoder)
> return;
>
> @@ -9109,12 +9154,16 @@ static void get_freesync_config_for_crtc(
> struct dm_connector_state *new_con_state)
> {
> struct mod_freesync_config config = {0};
> - struct amdgpu_dm_connector *aconnector =
> - to_amdgpu_dm_connector(new_con_state->base.connector);
> + struct amdgpu_dm_connector *aconnector;
> struct drm_display_mode *mode = &new_crtc_state->base.mode;
> int vrefresh = drm_mode_vrefresh(mode);
> bool fs_vid_mode = false;
>
> + if (new_con_state->base.connector->connector_type == DRM_MODE_CONNECTOR_WRITEBACK)
> + return;
> +
> + aconnector = to_amdgpu_dm_connector(new_con_state->base.connector);
> +
> new_crtc_state->vrr_supported = new_con_state->freesync_capable &&
> vrefresh >= aconnector->min_vfreq &&
> vrefresh <= aconnector->max_vfreq;
> @@ -9898,6 +9947,9 @@ static int add_affected_mst_dsc_crtcs(struct drm_atomic_state *state, struct drm
> if (conn_state->crtc != crtc)
> continue;
>
> + if (connector->connector_type == DRM_MODE_CONNECTOR_WRITEBACK)
> + continue;
> +
> aconnector = to_amdgpu_dm_connector(connector);
> if (!aconnector->mst_output_port || !aconnector->mst_root)
> aconnector = NULL;
> diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_crc.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_crc.c
> index 52ecfa746b54..f936a35fa9eb 100644
> --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_crc.c
> +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_crc.c
> @@ -326,6 +326,9 @@ int amdgpu_dm_crtc_set_crc_source(struct drm_crtc *crtc, const char *src_name)
> if (!connector->state || connector->state->crtc != crtc)
> continue;
>
> + if (connector->connector_type == DRM_MODE_CONNECTOR_WRITEBACK)
> + continue;
> +
> aconn = to_amdgpu_dm_connector(connector);
> break;
> }
> diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_irq.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_irq.c
> index 51467f132c26..58b880acb087 100644
> --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_irq.c
> +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_irq.c
> @@ -894,10 +894,15 @@ void amdgpu_dm_hpd_init(struct amdgpu_device *adev)
>
> drm_connector_list_iter_begin(dev, &iter);
> drm_for_each_connector_iter(connector, &iter) {
> - struct amdgpu_dm_connector *amdgpu_dm_connector =
> - to_amdgpu_dm_connector(connector);
> + struct amdgpu_dm_connector *amdgpu_dm_connector;
> + const struct dc_link *dc_link;
>
> - const struct dc_link *dc_link = amdgpu_dm_connector->dc_link;
> + if (connector->connector_type == DRM_MODE_CONNECTOR_WRITEBACK)
> + continue;
> +
> + amdgpu_dm_connector = to_amdgpu_dm_connector(connector);
> +
> + dc_link = amdgpu_dm_connector->dc_link;
>
> if (dc_link->irq_source_hpd != DC_IRQ_SOURCE_INVALID) {
> dc_interrupt_set(adev->dm.dc,
> @@ -930,9 +935,14 @@ void amdgpu_dm_hpd_fini(struct amdgpu_device *adev)
>
> drm_connector_list_iter_begin(dev, &iter);
> drm_for_each_connector_iter(connector, &iter) {
> - struct amdgpu_dm_connector *amdgpu_dm_connector =
> - to_amdgpu_dm_connector(connector);
> - const struct dc_link *dc_link = amdgpu_dm_connector->dc_link;
> + struct amdgpu_dm_connector *amdgpu_dm_connector;
> + const struct dc_link *dc_link;
> +
> + if (connector->connector_type == DRM_MODE_CONNECTOR_WRITEBACK)
> + continue;
> +
> + amdgpu_dm_connector = to_amdgpu_dm_connector(connector);
> + dc_link = amdgpu_dm_connector->dc_link;
>
> if (dc_link->irq_source_hpd != DC_IRQ_SOURCE_INVALID) {
> dc_interrupt_set(adev->dm.dc,
More information about the amd-gfx
mailing list