From: George Shen <[email protected]> [Why] Current implementation of DP retrain link test function contains an issue where ODM combine is cleared and not reconfigured when we toggle off/on OTG.
The function is also rigid and difficult to maintain when all the HW programming logic is done directly within it. [How] Move HW programming calls to a hwss function and call it from the DP retrain link function. Additionaly, add a call to reprogram the ODM combine register that is cleared when disabling OTG in the hwss function call. Cc: Michael Strauss <[email protected]> Signed-off-by: George Shen <[email protected]> Signed-off-by: James Lin <[email protected]> --- .../drm/amd/display/dc/core/dc_hw_sequencer.c | 84 +++++++++++++++++++ .../drm/amd/display/dc/hwss/hw_sequencer.h | 8 ++ .../display/dc/link/accessories/link_dp_cts.c | 39 ++------- 3 files changed, 98 insertions(+), 33 deletions(-) diff --git a/drivers/gpu/drm/amd/display/dc/core/dc_hw_sequencer.c b/drivers/gpu/drm/amd/display/dc/core/dc_hw_sequencer.c index ecf90e3a770c..061ea11cef0e 100644 --- a/drivers/gpu/drm/amd/display/dc/core/dc_hw_sequencer.c +++ b/drivers/gpu/drm/amd/display/dc/core/dc_hw_sequencer.c @@ -3195,6 +3195,90 @@ void hwss_wait_for_odm_update_pending_complete(struct dc *dc, struct dc_state *c hwss_wait_for_all_blank_complete(dc, context); } +/** + * hwss_restart_otg_for_dp_test_link_retrain - restart the OTGs of a link retrained + * by a DP test request, with the stream's planes left attached + * + * Disables the OTGs, programs the pixel clock and audio if requested, restores + * the ODM combine configuration cleared by disable_crtc, then re-enables the + * OTGs. The caller must have already turned DPMS off and updated the stream and + * link resources in @context for the new link settings. + * + * @dc: [in] dc reference + * @context: [in] hardware context in use + * @otg_masters: [in] OTG master pipes of the streams being retrained + * @otg_master_count: [in] number of entries in @otg_masters + * @program_pix_clk: [in] program pixel clock and audio, needed when the link encoding changes + * @audio_output: [in] audio output per OTG master, used if @program_pix_clk + */ +void hwss_restart_otg_for_dp_test_link_retrain(struct dc *dc, + struct dc_state *context, + struct pipe_ctx **otg_masters, + uint8_t otg_master_count, + bool program_pix_clk, + struct audio_output *audio_output) +{ + int i; + + // TODO: Confirm with HW docs if disable/re-enable is actually required here + for (i = 0; i < otg_master_count; i++) + otg_masters[i]->stream_res.tg->funcs->disable_crtc(otg_masters[i]->stream_res.tg); + + if (program_pix_clk) { + for (i = 0; i < otg_master_count; i++) { + struct pipe_ctx *pipe = otg_masters[i]; + struct audio *audio = pipe->stream_res.audio; + + if (pipe->stream_res.pix_clk_params.controller_id != CONTROLLER_ID_UNDEFINED) + pipe->clock_source->funcs->program_pix_clk( + pipe->clock_source, + &pipe->stream_res.pix_clk_params, + dc->link_srv->dp_get_encoding_format(&pipe->link_config.dp_link_settings), + &pipe->pll_settings); + + if (audio != NULL) { + const struct link_hwss *link_hwss = get_link_hwss( + pipe->stream->link, &pipe->link_res); + + link_hwss->setup_audio_output(pipe, &audio_output[i], audio->inst); + + audio->funcs->az_configure( + audio, + pipe->stream->signal, + &audio_output[i].crtc_info, + &pipe->stream->audio_info, + &audio_output[i].dp_link_info); + + if (dc->config.disable_hbr_audio_dp2 && + audio->funcs->az_disable_hbr_audio && + dc->link_srv->dp_is_128b_132b_signal(pipe)) + audio->funcs->az_disable_hbr_audio(audio); + } + } + } + + for (i = 0; i < otg_master_count; i++) { + struct pipe_ctx *pipe = otg_masters[i]; + + /* disable_crtc cleared the ODM segment config */ + if (pipe->next_odm_pipe) { + struct pipe_ctx *opp_heads[MAX_PIPES]; + int opp_inst[MAX_PIPES] = {0}; + int opp_head_count = resource_get_opp_heads_for_otg_master(pipe, &context->res_ctx, opp_heads); + int j; + + for (j = 0; j < opp_head_count; j++) + opp_inst[j] = opp_heads[j]->stream_res.opp->inst; + + pipe->stream_res.tg->funcs->set_odm_combine(pipe->stream_res.tg, opp_inst, opp_head_count, + resource_get_odm_slice_dst_width(pipe, false), + resource_get_odm_slice_dst_width(pipe, true)); + } + + pipe->stream_res.tg->funcs->enable_crtc(pipe->stream_res.tg); + } +} + void hwss_reset_unused_det(struct dc *dc, struct dc_state *context) { struct hubbub *hubbub = dc->res_pool->hubbub; diff --git a/drivers/gpu/drm/amd/display/dc/hwss/hw_sequencer.h b/drivers/gpu/drm/amd/display/dc/hwss/hw_sequencer.h index bfe9afb434af..c2e256a40128 100644 --- a/drivers/gpu/drm/amd/display/dc/hwss/hw_sequencer.h +++ b/drivers/gpu/drm/amd/display/dc/hwss/hw_sequencer.h @@ -66,6 +66,7 @@ struct link_training_settings; struct dc_link; struct dc_crtc_timing; struct dmub_srv_hw_params; +struct audio_output; struct tg_lock_params { struct dc *dc; @@ -2316,6 +2317,13 @@ void hwss_wait_for_all_blank_complete(struct dc *dc, void hwss_wait_for_odm_update_pending_complete(struct dc *dc, struct dc_state *context); +void hwss_restart_otg_for_dp_test_link_retrain(struct dc *dc, + struct dc_state *context, + struct pipe_ctx **otg_masters, + uint8_t otg_master_count, + bool program_pix_clk, + struct audio_output *audio_output); + void hwss_wait_for_no_pipes_pending(struct dc *dc, struct dc_state *context); diff --git a/drivers/gpu/drm/amd/display/dc/link/accessories/link_dp_cts.c b/drivers/gpu/drm/amd/display/dc/link/accessories/link_dp_cts.c index f316337cee1b..2fe7ceff1f50 100644 --- a/drivers/gpu/drm/amd/display/dc/link/accessories/link_dp_cts.c +++ b/drivers/gpu/drm/amd/display/dc/link/accessories/link_dp_cts.c @@ -72,6 +72,7 @@ static void dp_retrain_link_dp_test(struct dc_link *link, struct dc_stream_update stream_update = { 0 }; bool dpms_off = false; bool needs_divider_update = false; + bool program_pix_clk = false; bool was_hpo_acquired = resource_is_hpo_acquired(link->dc->current_state); bool is_hpo_acquired; uint8_t count; @@ -97,52 +98,24 @@ static void dp_retrain_link_dp_test(struct dc_link *link, link->dc, state, pipes[i]); - - // Disable OTG and re-enable after updating clocks - pipes[i]->stream_res.tg->funcs->disable_crtc(pipes[i]->stream_res.tg); } if (needs_divider_update && link->dc->res_pool->funcs->update_dc_state_for_encoder_switch) { link->dc->res_pool->funcs->update_dc_state_for_encoder_switch(link, link_setting, count, *pipes, &audio_output[0]); - for (i = 0; i < count; i++) { - pipes[i]->clock_source->funcs->program_pix_clk( - pipes[i]->clock_source, - &pipes[i]->stream_res.pix_clk_params, - link->dc->link_srv->dp_get_encoding_format(&pipes[i]->link_config.dp_link_settings), - &pipes[i]->pll_settings); - - if (pipes[i]->stream_res.audio != NULL) { - const struct link_hwss *link_hwss = get_link_hwss( - link, &pipes[i]->link_res); - - link_hwss->setup_audio_output(pipes[i], &audio_output[i], - pipes[i]->stream_res.audio->inst); - - pipes[i]->stream_res.audio->funcs->az_configure( - pipes[i]->stream_res.audio, - pipes[i]->stream->signal, - &audio_output[i].crtc_info, - &pipes[i]->stream->audio_info, - &audio_output[i].dp_link_info); - - if (link->dc->config.disable_hbr_audio_dp2 && - pipes[i]->stream_res.audio->funcs->az_disable_hbr_audio && - link->dc->link_srv->dp_is_128b_132b_signal(pipes[i])) - pipes[i]->stream_res.audio->funcs->az_disable_hbr_audio(pipes[i]->stream_res.audio); - } - } + program_pix_clk = true; } + // Disable OTG, update clocks and re-enable OTG with its ODM configuration restored + hwss_restart_otg_for_dp_test_link_retrain(dc, state, pipes, count, + program_pix_clk, audio_output); + // Toggle on HPO I/O if necessary is_hpo_acquired = resource_is_hpo_acquired(state); if (was_hpo_acquired != is_hpo_acquired && link->dc->hwss.setup_hpo_hw_control) link->dc->hwss.setup_hpo_hw_control(link->dc->hwseq, is_hpo_acquired); - for (i = 0; i < count; i++) - pipes[i]->stream_res.tg->funcs->enable_crtc(pipes[i]->stream_res.tg); - // Set DPMS on with stream update // Cache all streams on current link since dc_update_planes_and_stream might kill current_state for (i = 0; i < MAX_PIPES; i++) { -- 2.43.0
