From 07acd42b825ae77bcd0d41c0179b9eada8db54dd Mon Sep 17 00:00:00 2001 From: Mykola Lysenko Date: Mon, 14 Dec 2015 19:04:17 +0800 Subject: [PATCH 0614/1110] drm/amd/dal: check stream on payload table update There is a situation when drm crtc moved from one connector to another, and MST connector can lack DC target for one commit. It should be guarded both in DM and DC Signed-off-by: Mykola Lysenko Signed-off-by: Harry Wentland Acked-by: Harry Wentland --- .../gpu/drm/amd/dal/amdgpu_dm/amdgpu_dc_helpers.c | 8 ++++ .../drm/amd/dal/dc/dce110/dce110_link_encoder.c | 47 ++++++++++++++-------- 2 files changed, 38 insertions(+), 17 deletions(-) diff --git a/drivers/gpu/drm/amd/dal/amdgpu_dm/amdgpu_dc_helpers.c b/drivers/gpu/drm/amd/dal/amdgpu_dm/amdgpu_dc_helpers.c index f2d1dc8..0230ee9 100644 --- a/drivers/gpu/drm/amd/dal/amdgpu_dm/amdgpu_dc_helpers.c +++ b/drivers/gpu/drm/amd/dal/amdgpu_dm/amdgpu_dc_helpers.c @@ -311,6 +311,14 @@ bool dc_helpers_dp_mst_write_payload_allocation_table( * crtc -> target -> stream -> sink */ crtc = aconnector->base.state->crtc; + + /* + * this situation can happen when crtc moved from one + * connector to another for any reason + */ + if (!crtc) + continue; + amdgpu_crtc = to_amdgpu_crtc(crtc); dc_target = amdgpu_crtc->target; diff --git a/drivers/gpu/drm/amd/dal/dc/dce110/dce110_link_encoder.c b/drivers/gpu/drm/amd/dal/dc/dce110/dce110_link_encoder.c index 8ddccdf..d71efa9 100644 --- a/drivers/gpu/drm/amd/dal/dc/dce110/dce110_link_encoder.c +++ b/drivers/gpu/drm/amd/dal/dc/dce110/dce110_link_encoder.c @@ -1630,6 +1630,24 @@ void dce110_link_encoder_set_dp_phy_pattern( } } +static void fill_stream_allocation_row_info( + const struct dp_mst_stream_allocation *stream_allocation, + uint32_t *src, + uint32_t *slots) +{ + const struct dc_stream *dc_stream = stream_allocation->stream; + struct core_stream *core_stream; + + if (dc_stream) { + core_stream = DC_STREAM_TO_CORE(dc_stream); + *src = core_stream->stream_enc->id; + *slots = stream_allocation->slot_count; + } else { + *src = 0; + *slots = 0; + } +} + /* programs DP MST VC payload allocation */ void dce110_link_encoder_update_mst_stream_allocation_table( struct link_encoder *enc, @@ -1642,8 +1660,6 @@ void dce110_link_encoder_update_mst_stream_allocation_table( uint32_t slots = 0; uint32_t src = 0; uint32_t retries = 0; - struct core_stream *core_stream = NULL; - /* For CZ, there are only 3 pipes. So Virtual channel is up 3.*/ @@ -1657,11 +1673,10 @@ void dce110_link_encoder_update_mst_stream_allocation_table( value1 = dal_read_reg(ctx, DP_REG(mmDP_MSE_SAT1)); if (table->stream_count >= 1) { - core_stream = - DC_STREAM_TO_CORE(table->stream_allocations[0].stream); - - src = core_stream->stream_enc->id; - slots = table->stream_allocations[0].slot_count; + fill_stream_allocation_row_info( + &table->stream_allocations[0], + &src, + &slots); } else { src = 0; slots = 0; @@ -1680,11 +1695,10 @@ void dce110_link_encoder_update_mst_stream_allocation_table( DP_MSE_SAT_SLOT_COUNT0); if (table->stream_count >= 2) { - core_stream = - DC_STREAM_TO_CORE(table->stream_allocations[1].stream); - - src = core_stream->stream_enc->id; - slots = table->stream_allocations[1].slot_count; + fill_stream_allocation_row_info( + &table->stream_allocations[1], + &src, + &slots); } else { src = 0; slots = 0; @@ -1703,11 +1717,10 @@ void dce110_link_encoder_update_mst_stream_allocation_table( DP_MSE_SAT_SLOT_COUNT1); if (table->stream_count >= 3) { - core_stream = - DC_STREAM_TO_CORE(table->stream_allocations[2].stream); - - src = core_stream->stream_enc->id; - slots = table->stream_allocations[2].slot_count; + fill_stream_allocation_row_info( + &table->stream_allocations[2], + &src, + &slots); } else { src = 0; slots = 0; -- 2.7.4