drm/amd/display: Modify DHCUB waterwark structures and functions
authorDillon Varone <dillon.varone@amd.com>
Fri, 15 Mar 2024 20:50:47 +0000 (16:50 -0400)
committerAlex Deucher <alexander.deucher@amd.com>
Wed, 27 Mar 2024 05:43:28 +0000 (01:43 -0400)
[WHY&HOW]
Converting the watermark set structure to a union and modifying some interfaces
to accommodate future usage.

Reviewed-by: Chaitanya Dhere <chaitanya.dhere@amd.com>
Acked-by: Tom Chung <chiahsuan.chung@amd.com>
Signed-off-by: Dillon Varone <dillon.varone@amd.com>
Tested-by: Daniel Wheeler <daniel.wheeler@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
17 files changed:
drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hubbub.c
drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hubbub.h
drivers/gpu/drm/amd/display/dc/dcn20/dcn20_hubbub.c
drivers/gpu/drm/amd/display/dc/dcn20/dcn20_hubbub.h
drivers/gpu/drm/amd/display/dc/dcn201/dcn201_hubbub.c
drivers/gpu/drm/amd/display/dc/dcn21/dcn21_hubbub.c
drivers/gpu/drm/amd/display/dc/dcn21/dcn21_hubbub.h
drivers/gpu/drm/amd/display/dc/dcn30/dcn30_hubbub.c
drivers/gpu/drm/amd/display/dc/dcn30/dcn30_hubbub.h
drivers/gpu/drm/amd/display/dc/dcn31/dcn31_hubbub.c
drivers/gpu/drm/amd/display/dc/dcn32/dcn32_hubbub.c
drivers/gpu/drm/amd/display/dc/dcn32/dcn32_hubbub.h
drivers/gpu/drm/amd/display/dc/dcn35/dcn35_hubbub.c
drivers/gpu/drm/amd/display/dc/hwss/dcn20/dcn20_hwseq.c
drivers/gpu/drm/amd/display/dc/inc/core_types.h
drivers/gpu/drm/amd/display/dc/inc/hw/dchubbub.h
drivers/gpu/drm/amd/display/dc/inc/hw/mem_input.h

index d51f1ce..d9ade9e 100644 (file)
@@ -242,7 +242,7 @@ void hubbub1_wm_change_req_wa(struct hubbub *hubbub)
 
 bool hubbub1_program_urgent_watermarks(
                struct hubbub *hubbub,
-               struct dcn_watermark_set *watermarks,
+               union dcn_watermark_set *watermarks,
                unsigned int refclk_mhz,
                bool safe_to_lower)
 {
@@ -356,7 +356,7 @@ bool hubbub1_program_urgent_watermarks(
 
 bool hubbub1_program_stutter_watermarks(
                struct hubbub *hubbub,
-               struct dcn_watermark_set *watermarks,
+               union dcn_watermark_set *watermarks,
                unsigned int refclk_mhz,
                bool safe_to_lower)
 {
@@ -501,7 +501,7 @@ bool hubbub1_program_stutter_watermarks(
 
 bool hubbub1_program_pstate_watermarks(
                struct hubbub *hubbub,
-               struct dcn_watermark_set *watermarks,
+               union dcn_watermark_set *watermarks,
                unsigned int refclk_mhz,
                bool safe_to_lower)
 {
@@ -582,7 +582,7 @@ bool hubbub1_program_pstate_watermarks(
 
 bool hubbub1_program_watermarks(
                struct hubbub *hubbub,
-               struct dcn_watermark_set *watermarks,
+               union dcn_watermark_set *watermarks,
                unsigned int refclk_mhz,
                bool safe_to_lower)
 {
index 4201b76..d1f9e63 100644 (file)
@@ -409,7 +409,7 @@ struct dcn10_hubbub {
        const struct dcn_hubbub_shift *shifts;
        const struct dcn_hubbub_mask *masks;
        unsigned int debug_test_index_pstate;
-       struct dcn_watermark_set watermarks;
+       union dcn_watermark_set watermarks;
 };
 
 void hubbub1_update_dchub(
@@ -423,7 +423,7 @@ void hubbub1_wm_change_req_wa(struct hubbub *hubbub);
 
 bool hubbub1_program_watermarks(
                struct hubbub *hubbub,
-               struct dcn_watermark_set *watermarks,
+               union dcn_watermark_set *watermarks,
                unsigned int refclk_mhz,
                bool safe_to_lower);
 
@@ -446,17 +446,17 @@ void hubbub1_construct(struct hubbub *hubbub,
 
 bool hubbub1_program_urgent_watermarks(
                struct hubbub *hubbub,
-               struct dcn_watermark_set *watermarks,
+               union dcn_watermark_set *watermarks,
                unsigned int refclk_mhz,
                bool safe_to_lower);
 bool hubbub1_program_stutter_watermarks(
                struct hubbub *hubbub,
-               struct dcn_watermark_set *watermarks,
+               union dcn_watermark_set *watermarks,
                unsigned int refclk_mhz,
                bool safe_to_lower);
 bool hubbub1_program_pstate_watermarks(
                struct hubbub *hubbub,
-               struct dcn_watermark_set *watermarks,
+               union dcn_watermark_set *watermarks,
                unsigned int refclk_mhz,
                bool safe_to_lower);
 
index 6eebcb2..c6f8598 100644 (file)
@@ -570,7 +570,7 @@ void hubbub2_get_dchub_ref_freq(struct hubbub *hubbub,
 
 static bool hubbub2_program_watermarks(
                struct hubbub *hubbub,
-               struct dcn_watermark_set *watermarks,
+               union dcn_watermark_set *watermarks,
                unsigned int refclk_mhz,
                bool safe_to_lower)
 {
index 2f6146b..24a9c45 100644 (file)
@@ -85,7 +85,7 @@ struct dcn20_hubbub {
        const struct dcn_hubbub_shift *shifts;
        const struct dcn_hubbub_mask *masks;
        unsigned int debug_test_index_pstate;
-       struct dcn_watermark_set watermarks;
+       union dcn_watermark_set watermarks;
        int num_vmid;
        struct dcn20_vmid vmid[16];
        unsigned int detile_buf_size;
index 037d265..09ea65a 100644 (file)
@@ -52,7 +52,7 @@
 
 static bool hubbub201_program_watermarks(
                struct hubbub *hubbub,
-               struct dcn_watermark_set *watermarks,
+               union dcn_watermark_set *watermarks,
                unsigned int refclk_mhz,
                bool safe_to_lower)
 {
index aeb0e0d..2546224 100644 (file)
@@ -140,7 +140,7 @@ int hubbub21_init_dchub(struct hubbub *hubbub,
 
 bool hubbub21_program_urgent_watermarks(
                struct hubbub *hubbub,
-               struct dcn_watermark_set *watermarks,
+               union dcn_watermark_set *watermarks,
                unsigned int refclk_mhz,
                bool safe_to_lower)
 {
@@ -334,7 +334,7 @@ bool hubbub21_program_urgent_watermarks(
 
 bool hubbub21_program_stutter_watermarks(
                struct hubbub *hubbub,
-               struct dcn_watermark_set *watermarks,
+               union dcn_watermark_set *watermarks,
                unsigned int refclk_mhz,
                bool safe_to_lower)
 {
@@ -487,7 +487,7 @@ bool hubbub21_program_stutter_watermarks(
 
 bool hubbub21_program_pstate_watermarks(
                struct hubbub *hubbub,
-               struct dcn_watermark_set *watermarks,
+               union dcn_watermark_set *watermarks,
                unsigned int refclk_mhz,
                bool safe_to_lower)
 {
@@ -573,7 +573,7 @@ bool hubbub21_program_pstate_watermarks(
 
 bool hubbub21_program_watermarks(
                struct hubbub *hubbub,
-               struct dcn_watermark_set *watermarks,
+               union dcn_watermark_set *watermarks,
                unsigned int refclk_mhz,
                bool safe_to_lower)
 {
index d8eb2bb..ab2ce03 100644 (file)
@@ -127,22 +127,22 @@ int hubbub21_init_dchub(struct hubbub *hubbub,
                struct dcn_hubbub_phys_addr_config *pa_config);
 bool hubbub21_program_watermarks(
                struct hubbub *hubbub,
-               struct dcn_watermark_set *watermarks,
+               union dcn_watermark_set *watermarks,
                unsigned int refclk_mhz,
                bool safe_to_lower);
 bool hubbub21_program_urgent_watermarks(
                struct hubbub *hubbub,
-               struct dcn_watermark_set *watermarks,
+               union dcn_watermark_set *watermarks,
                unsigned int refclk_mhz,
                bool safe_to_lower);
 bool hubbub21_program_stutter_watermarks(
                struct hubbub *hubbub,
-               struct dcn_watermark_set *watermarks,
+               union dcn_watermark_set *watermarks,
                unsigned int refclk_mhz,
                bool safe_to_lower);
 bool hubbub21_program_pstate_watermarks(
                struct hubbub *hubbub,
-               struct dcn_watermark_set *watermarks,
+               union dcn_watermark_set *watermarks,
                unsigned int refclk_mhz,
                bool safe_to_lower);
 
index 152c9c5..6a5af3d 100644 (file)
@@ -95,7 +95,7 @@ int hubbub3_init_dchub_sys_ctx(struct hubbub *hubbub,
 
 bool hubbub3_program_watermarks(
                struct hubbub *hubbub,
-               struct dcn_watermark_set *watermarks,
+               union dcn_watermark_set *watermarks,
                unsigned int refclk_mhz,
                bool safe_to_lower)
 {
index 7b59790..ca6233e 100644 (file)
@@ -124,7 +124,7 @@ bool hubbub3_get_dcc_compression_cap(struct hubbub *hubbub,
 
 bool hubbub3_program_watermarks(
                struct hubbub *hubbub,
-               struct dcn_watermark_set *watermarks,
+               union dcn_watermark_set *watermarks,
                unsigned int refclk_mhz,
                bool safe_to_lower);
 
index 5b5b5e0..b906db6 100644 (file)
@@ -172,7 +172,7 @@ static uint32_t convert_and_clamp(
 
 static bool hubbub31_program_urgent_watermarks(
                struct hubbub *hubbub,
-               struct dcn_watermark_set *watermarks,
+               union dcn_watermark_set *watermarks,
                unsigned int refclk_mhz,
                bool safe_to_lower)
 {
@@ -362,7 +362,7 @@ static bool hubbub31_program_urgent_watermarks(
 
 static bool hubbub31_program_stutter_watermarks(
                struct hubbub *hubbub,
-               struct dcn_watermark_set *watermarks,
+               union dcn_watermark_set *watermarks,
                unsigned int refclk_mhz,
                bool safe_to_lower)
 {
@@ -635,7 +635,7 @@ static bool hubbub31_program_stutter_watermarks(
 
 static bool hubbub31_program_pstate_watermarks(
                struct hubbub *hubbub,
-               struct dcn_watermark_set *watermarks,
+               union dcn_watermark_set *watermarks,
                unsigned int refclk_mhz,
                bool safe_to_lower)
 {
@@ -717,7 +717,7 @@ static bool hubbub31_program_pstate_watermarks(
 
 static bool hubbub31_program_watermarks(
                struct hubbub *hubbub,
-               struct dcn_watermark_set *watermarks,
+               union dcn_watermark_set *watermarks,
                unsigned int refclk_mhz,
                bool safe_to_lower)
 {
index 88dfc90..515c4c2 100644 (file)
@@ -167,7 +167,7 @@ static uint32_t convert_and_clamp(
 
 bool hubbub32_program_urgent_watermarks(
                struct hubbub *hubbub,
-               struct dcn_watermark_set *watermarks,
+               union dcn_watermark_set *watermarks,
                unsigned int refclk_mhz,
                bool safe_to_lower)
 {
@@ -357,7 +357,7 @@ bool hubbub32_program_urgent_watermarks(
 
 bool hubbub32_program_stutter_watermarks(
                struct hubbub *hubbub,
-               struct dcn_watermark_set *watermarks,
+               union dcn_watermark_set *watermarks,
                unsigned int refclk_mhz,
                bool safe_to_lower)
 {
@@ -503,7 +503,7 @@ bool hubbub32_program_stutter_watermarks(
 
 bool hubbub32_program_pstate_watermarks(
                struct hubbub *hubbub,
-               struct dcn_watermark_set *watermarks,
+               union dcn_watermark_set *watermarks,
                unsigned int refclk_mhz,
                bool safe_to_lower)
 {
@@ -656,7 +656,7 @@ bool hubbub32_program_pstate_watermarks(
 
 bool hubbub32_program_usr_watermarks(
                struct hubbub *hubbub,
-               struct dcn_watermark_set *watermarks,
+               union dcn_watermark_set *watermarks,
                unsigned int refclk_mhz,
                bool safe_to_lower)
 {
@@ -750,7 +750,7 @@ void hubbub32_force_usr_retraining_allow(struct hubbub *hubbub, bool allow)
 
 static bool hubbub32_program_watermarks(
                struct hubbub *hubbub,
-               struct dcn_watermark_set *watermarks,
+               union dcn_watermark_set *watermarks,
                unsigned int refclk_mhz,
                bool safe_to_lower)
 {
index f073839..e439ba0 100644 (file)
 
 bool hubbub32_program_urgent_watermarks(
                struct hubbub *hubbub,
-               struct dcn_watermark_set *watermarks,
+               union dcn_watermark_set *watermarks,
                unsigned int refclk_mhz,
                bool safe_to_lower);
 
 bool hubbub32_program_stutter_watermarks(
                struct hubbub *hubbub,
-               struct dcn_watermark_set *watermarks,
+               union dcn_watermark_set *watermarks,
                unsigned int refclk_mhz,
                bool safe_to_lower);
 
 bool hubbub32_program_pstate_watermarks(
                struct hubbub *hubbub,
-               struct dcn_watermark_set *watermarks,
+               union dcn_watermark_set *watermarks,
                unsigned int refclk_mhz,
                bool safe_to_lower);
 
 bool hubbub32_program_usr_watermarks(
                struct hubbub *hubbub,
-               struct dcn_watermark_set *watermarks,
+               union dcn_watermark_set *watermarks,
                unsigned int refclk_mhz,
                bool safe_to_lower);
 
index 339bf0c..6293173 100644 (file)
@@ -111,7 +111,7 @@ static uint32_t convert_and_clamp(
 
 static bool hubbub35_program_stutter_z8_watermarks(
                struct hubbub *hubbub,
-               struct dcn_watermark_set *watermarks,
+               union dcn_watermark_set *watermarks,
                unsigned int refclk_mhz,
                bool safe_to_lower)
 {
@@ -297,7 +297,7 @@ static void hubbub35_get_dchub_ref_freq(struct hubbub *hubbub,
 
 static bool hubbub35_program_watermarks(
                struct hubbub *hubbub,
-               struct dcn_watermark_set *watermarks,
+               union dcn_watermark_set *watermarks,
                unsigned int refclk_mhz,
                bool safe_to_lower)
 {
index 1530b1f..f983041 100644 (file)
@@ -1910,9 +1910,11 @@ static void dcn20_program_pipe(
                        dc->res_pool->hubbub->funcs->force_wm_propagate_to_pipes(dc->res_pool->hubbub);
        }
 
-       if (dc->res_pool->hubbub->funcs->program_det_size && pipe_ctx->update_flags.bits.det_size)
-               dc->res_pool->hubbub->funcs->program_det_size(
-                       dc->res_pool->hubbub, pipe_ctx->plane_res.hubp->inst, pipe_ctx->det_buffer_size_kb);
+       if (pipe_ctx->update_flags.bits.det_size) {
+               if (dc->res_pool->hubbub->funcs->program_det_size)
+                       dc->res_pool->hubbub->funcs->program_det_size(
+                               dc->res_pool->hubbub, pipe_ctx->plane_res.hubp->inst, pipe_ctx->det_buffer_size_kb);
+       }
 
        if (pipe_ctx->update_flags.raw || pipe_ctx->plane_state->update_flags.raw || pipe_ctx->stream->update_flags.raw)
                dcn20_update_dchubp_dpp(dc, pipe_ctx, context);
@@ -2073,9 +2075,11 @@ void dcn20_program_front_end_for_ctx(
                         * turned on (i.e. in an MCLK switch) which can come in too late and cause issues with
                         * DET allocation.
                         */
-                       if (hubbub->funcs->program_det_size && (context->res_ctx.pipe_ctx[i].update_flags.bits.disable ||
-                                       (context->res_ctx.pipe_ctx[i].plane_state && dc_state_get_pipe_subvp_type(context, &context->res_ctx.pipe_ctx[i]) == SUBVP_PHANTOM)))
-                               hubbub->funcs->program_det_size(hubbub, dc->current_state->res_ctx.pipe_ctx[i].plane_res.hubp->inst, 0);
+                       if ((context->res_ctx.pipe_ctx[i].update_flags.bits.disable ||
+                                       (context->res_ctx.pipe_ctx[i].plane_state && dc_state_get_pipe_subvp_type(context, &context->res_ctx.pipe_ctx[i]) == SUBVP_PHANTOM))) {
+                               if (hubbub->funcs->program_det_size)
+                                       hubbub->funcs->program_det_size(hubbub, dc->current_state->res_ctx.pipe_ctx[i].plane_res.hubp->inst, 0);
+                       }
                        hws->funcs.plane_atomic_disconnect(dc, dc->current_state, &dc->current_state->res_ctx.pipe_ctx[i]);
                        DC_LOG_DC("Reset mpcc for pipe %d\n", dc->current_state->res_ctx.pipe_ctx[i].pipe_idx);
                }
index a66676c..3f6876a 100644 (file)
@@ -499,7 +499,7 @@ struct dcn_bw_writeback {
 
 struct dcn_bw_output {
        struct dc_clocks clk;
-       struct dcn_watermark_set watermarks;
+       union dcn_watermark_set watermarks;
        struct dcn_bw_writeback bw_writeback;
        int compbuf_size_kb;
        unsigned int mall_ss_size_bytes;
index 2ae7484..305fdc1 100644 (file)
@@ -160,7 +160,7 @@ struct hubbub_funcs {
 
        bool (*program_watermarks)(
                        struct hubbub *hubbub,
-                       struct dcn_watermark_set *watermarks,
+                       union dcn_watermark_set *watermarks,
                        unsigned int refclk_mhz,
                        bool safe_to_lower);
 
index b72fb31..86c12cd 100644 (file)
@@ -50,11 +50,13 @@ struct dcn_watermarks {
        uint32_t usr_retraining_ns;
 };
 
-struct dcn_watermark_set {
-       struct dcn_watermarks a;
-       struct dcn_watermarks b;
-       struct dcn_watermarks c;
-       struct dcn_watermarks d;
+union dcn_watermark_set {
+       struct {
+               struct dcn_watermarks a;
+               struct dcn_watermarks b;
+               struct dcn_watermarks c;
+               struct dcn_watermarks d;
+       }; // legacy
 };
 
 struct dce_watermarks {