drm/amd/display: properly configure DCFCLK when enable/disable Freesync
authorVladimir Stempen <vladimir.stempen@amd.com>
Thu, 22 Sep 2022 19:03:05 +0000 (15:03 -0400)
committerAlex Deucher <alexander.deucher@amd.com>
Mon, 10 Oct 2022 21:14:46 +0000 (17:14 -0400)
[Why]
Bandwidth validation is using Freesync parameters
from previous Freesync state.
Bandwidth validation ignores DCFCLK calculated
after Freesync parameters are configured

[How]
Set Freesync bandwidth parameters to its default
state before running bandwidth validation.
Take DCFCLK calculated after Freesync bandwidth
parameters are assigned and bandwidth is
recalculated.

Tested-by: Daniel Wheeler <daniel.wheeler@amd.com>
Reviewed-by: Martin Leung <Martin.Leung@amd.com>
Reviewed-by: Nevenko Stupar <Nevenko.Stupar@amd.com>
Reviewed-by: Jun Lei <Jun.Lei@amd.com>
Acked-by: Qingqing Zhuo <qingqing.zhuo@amd.com>
Signed-off-by: Vladimir Stempen <vladimir.stempen@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/display/dc/dcn32/dcn32_resource.c
drivers/gpu/drm/amd/display/dc/dml/dcn32/dcn32_fpu.c

index 9585b25f10e52e047e23a77f2977305f19f0e650..a88dd7b3d1c10e01774301b74076ecc413634881 100644 (file)
@@ -1805,6 +1805,13 @@ bool dcn32_validate_bandwidth(struct dc *dc,
        int pipe_cnt = 0;
        display_e2e_pipe_params_st *pipes = kzalloc(dc->res_pool->pipe_count * sizeof(display_e2e_pipe_params_st), GFP_KERNEL);
        struct mall_temp_config mall_temp_config;
+
+       /* To handle Freesync properly, setting FreeSync DML parameters
+        * to its default state for the first stage of validation
+        */
+       context->bw_ctx.bw.dcn.clk.fw_based_mclk_switching = false;
+       context->bw_ctx.dml.soc.dram_clock_change_requirement_final = true;
+
        DC_LOGGER_INIT(dc->ctx->logger);
 
        /* For fast validation, there are situations where a shallow copy of
index 6bdd509d292a60b0642a74d0839a8faf02ef55b6..819de0f110126eed5059298b5bd50d78e57a0539 100644 (file)
@@ -1769,6 +1769,7 @@ void dcn32_calculate_wm_and_dlg_fpu(struct dc *dc, struct dc_state *context,
        int i, pipe_idx, vlevel_temp = 0;
        double dcfclk = dcn3_2_soc.clock_limits[0].dcfclk_mhz;
        double dcfclk_from_validation = context->bw_ctx.dml.vba.DCFCLKState[vlevel][context->bw_ctx.dml.vba.maxMpcComb];
+       double dcfclk_from_fw_based_mclk_switching = dcfclk_from_validation;
        bool pstate_en = context->bw_ctx.dml.vba.DRAMClockChangeSupport[vlevel][context->bw_ctx.dml.vba.maxMpcComb] !=
                        dm_dram_clock_change_unsupported;
        unsigned int dummy_latency_index = 0;
@@ -1804,7 +1805,7 @@ void dcn32_calculate_wm_and_dlg_fpu(struct dc *dc, struct dc_state *context,
                                        dc->clk_mgr->bw_params->wm_table.nv_entries[WM_A].dml_input.pstate_latency_us;
                        dcn32_internal_validate_bw(dc, context, pipes, &pipe_cnt, &vlevel, false);
                        maxMpcComb = context->bw_ctx.dml.vba.maxMpcComb;
-                       dcfclk = context->bw_ctx.dml.vba.DCFCLKState[vlevel][context->bw_ctx.dml.vba.maxMpcComb];
+                       dcfclk_from_fw_based_mclk_switching = context->bw_ctx.dml.vba.DCFCLKState[vlevel][context->bw_ctx.dml.vba.maxMpcComb];
                        pstate_en = context->bw_ctx.dml.vba.DRAMClockChangeSupport[vlevel][maxMpcComb] !=
                                        dm_dram_clock_change_unsupported;
                }
@@ -1890,6 +1891,10 @@ void dcn32_calculate_wm_and_dlg_fpu(struct dc *dc, struct dc_state *context,
        pipes[0].clks_cfg.dcfclk_mhz = dcfclk_from_validation;
        pipes[0].clks_cfg.socclk_mhz = context->bw_ctx.dml.soc.clock_limits[vlevel].socclk_mhz;
 
+       if (context->bw_ctx.bw.dcn.clk.fw_based_mclk_switching) {
+               pipes[0].clks_cfg.dcfclk_mhz = dcfclk_from_fw_based_mclk_switching;
+       }
+
        if (dc->clk_mgr->bw_params->wm_table.nv_entries[WM_C].valid) {
                min_dram_speed_mts = context->bw_ctx.dml.vba.DRAMSpeed;
                min_dram_speed_mts_margin = 160;