]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
drm/amd/display: Reduce Stack Usage by moving 'audio_output' into 'stream_res' v4
authorSrinivasan Shanmugam <srinivasan.shanmugam@amd.com>
Thu, 24 Jul 2025 07:32:18 +0000 (13:02 +0530)
committerAlex Deucher <alexander.deucher@amd.com>
Mon, 28 Jul 2025 20:40:07 +0000 (16:40 -0400)
The function `dp_retrain_link_dp_test` currently allocates a large
audio_output array on the stack, causing the stack frame size to exceed
the compiler limit (1080 bytes > 1024 bytes).

This change prevents stack overflow issues:
amdgpu/../display/dc/link/accessories/link_dp_cts.c:65:13: warning: stack frame size (1080) exceeds limit (1024) in 'dp_retrain_link_dp_test' [-Wframe-larger-than]
static void dp_retrain_link_dp_test(struct dc_link *link,

v2: Move audio-related data like `audio_output` is kept "per pipe" to
    manage the audio for that specific display pipeline/display output path
    (stream). (Wenjing)

v3: Update in all the places where `build_audio_output` is currently
    called with a separate audio_output variable on the stack & wherever
    `audio_output` is passed to other functions
    `dce110_apply_single_controller_ctx_to_hw()` &
    `dce110_setup_audio_dto()` (like `az_configure`, `wall_dto_setup`)
    replace with usage of `pipe_ctx->stream_res.audio_output`
    to centralize audio data per pipe.

v4: Remove empty lines before `build_audio_output`. (Alex)

Fixes: 9c6669c2e21a ("drm/amd/display: Fix Link Override Sequencing When Switching Between DIO/HPO")
Cc: Wayne Lin <wayne.lin@amd.com>
Cc: George Shen <george.shen@amd.com>
Cc: Michael Strauss <michael.strauss@amd.com>
Cc: Alvin Lee <Alvin.Lee2@amd.com>
Cc: Ray Wu <ray.wu@amd.com>
Cc: Wenjing Liu <wenjing.liu@amd.com>
Cc: Harry Wentland <harry.wentland@amd.com>
Cc: Tom Chung <chiahsuan.chung@amd.com>
Cc: Roman Li <roman.li@amd.com>
Cc: Alex Hung <alex.hung@amd.com>
Cc: Aurabindo Pillai <aurabindo.pillai@amd.com>
Signed-off-by: Srinivasan Shanmugam <srinivasan.shanmugam@amd.com>
Reviewed-by: Wenjing Liu <wenjing.liu@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/display/dc/hwss/dce110/dce110_hwseq.c
drivers/gpu/drm/amd/display/dc/inc/core_types.h
drivers/gpu/drm/amd/display/dc/link/accessories/link_dp_cts.c
drivers/gpu/drm/amd/display/dc/resource/dcn31/dcn31_resource.c
drivers/gpu/drm/amd/display/dc/resource/dcn31/dcn31_resource.h

index 4ea13d0bf815e251c6551c53fdc8d5fbb3eeb702..c69194e04ff93e61008525862ac225459c4a4121 100644 (file)
@@ -1600,19 +1600,17 @@ enum dc_status dce110_apply_single_controller_ctx_to_hw(
        }
 
        if (pipe_ctx->stream_res.audio != NULL) {
-               struct audio_output audio_output = {0};
+               build_audio_output(context, pipe_ctx, &pipe_ctx->stream_res.audio_output);
 
-               build_audio_output(context, pipe_ctx, &audio_output);
-
-               link_hwss->setup_audio_output(pipe_ctx, &audio_output,
+               link_hwss->setup_audio_output(pipe_ctx, &pipe_ctx->stream_res.audio_output,
                                pipe_ctx->stream_res.audio->inst);
 
                pipe_ctx->stream_res.audio->funcs->az_configure(
                                pipe_ctx->stream_res.audio,
                                pipe_ctx->stream->signal,
-                               &audio_output.crtc_info,
+                               &pipe_ctx->stream_res.audio_output.crtc_info,
                                &pipe_ctx->stream->audio_info,
-                               &audio_output.dp_link_info);
+                               &pipe_ctx->stream_res.audio_output.dp_link_info);
 
                if (dc->config.disable_hbr_audio_dp2)
                        if (pipe_ctx->stream_res.audio->funcs->az_disable_hbr_audio &&
@@ -2386,9 +2384,7 @@ static void dce110_setup_audio_dto(
                if (pipe_ctx->stream->signal != SIGNAL_TYPE_HDMI_TYPE_A)
                        continue;
                if (pipe_ctx->stream_res.audio != NULL) {
-                       struct audio_output audio_output;
-
-                       build_audio_output(context, pipe_ctx, &audio_output);
+                       build_audio_output(context, pipe_ctx, &pipe_ctx->stream_res.audio_output);
 
                        if (dc->res_pool->dccg && dc->res_pool->dccg->funcs->set_audio_dtbclk_dto) {
                                struct dtbclk_dto_params dto_params = {0};
@@ -2399,14 +2395,14 @@ static void dce110_setup_audio_dto(
                                pipe_ctx->stream_res.audio->funcs->wall_dto_setup(
                                                pipe_ctx->stream_res.audio,
                                                pipe_ctx->stream->signal,
-                                               &audio_output.crtc_info,
-                                               &audio_output.pll_info);
+                                               &pipe_ctx->stream_res.audio_output.crtc_info,
+                                               &pipe_ctx->stream_res.audio_output.pll_info);
                        } else
                                pipe_ctx->stream_res.audio->funcs->wall_dto_setup(
                                        pipe_ctx->stream_res.audio,
                                        pipe_ctx->stream->signal,
-                                       &audio_output.crtc_info,
-                                       &audio_output.pll_info);
+                                       &pipe_ctx->stream_res.audio_output.crtc_info,
+                                       &pipe_ctx->stream_res.audio_output.pll_info);
                        break;
                }
        }
@@ -2426,15 +2422,15 @@ static void dce110_setup_audio_dto(
                                continue;
 
                        if (pipe_ctx->stream_res.audio != NULL) {
-                               struct audio_output audio_output = {0};
-
-                               build_audio_output(context, pipe_ctx, &audio_output);
+                               build_audio_output(context,
+                                                  pipe_ctx,
+                                                  &pipe_ctx->stream_res.audio_output);
 
                                pipe_ctx->stream_res.audio->funcs->wall_dto_setup(
                                        pipe_ctx->stream_res.audio,
                                        pipe_ctx->stream->signal,
-                                       &audio_output.crtc_info,
-                                       &audio_output.pll_info);
+                                       &pipe_ctx->stream_res.audio_output.crtc_info,
+                                       &pipe_ctx->stream_res.audio_output.pll_info);
                                break;
                        }
                }
index f0d7185153b2aeffb2841f063cd3c46f26449a06..f896cce87b8d454a162fffedbe91ef998dcd6817 100644 (file)
@@ -228,8 +228,7 @@ struct resource_funcs {
        enum dc_status (*update_dc_state_for_encoder_switch)(struct dc_link *link,
                struct dc_link_settings *link_setting,
                uint8_t pipe_count,
-               struct pipe_ctx *pipes,
-               struct audio_output *audio_output);
+               struct pipe_ctx *pipes);
 };
 
 struct audio_support{
@@ -361,6 +360,8 @@ struct stream_resource {
        uint8_t gsl_group;
 
        struct test_pattern_params test_pattern_params;
+
+       struct audio_output audio_output;
 };
 
 struct plane_resource {
index 2956c2b3ad1aad79f5142617a1529268bf6ab06a..b12d61701d4d9f6df8648cecacccb0ab0a9aa837 100644 (file)
@@ -75,7 +75,6 @@ static void dp_retrain_link_dp_test(struct dc_link *link,
        bool is_hpo_acquired;
        uint8_t count;
        int i;
-       struct audio_output audio_output[MAX_PIPES];
 
        needs_divider_update = (link->dc->link_srv->dp_get_encoding_format(link_setting) !=
        link->dc->link_srv->dp_get_encoding_format((const struct dc_link_settings *) &link->cur_link_settings));
@@ -99,7 +98,7 @@ static void dp_retrain_link_dp_test(struct dc_link *link,
        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]);
+                               *pipes);
                for (i = 0; i < count; i++) {
                        pipes[i]->clock_source->funcs->program_pix_clk(
                                        pipes[i]->clock_source,
@@ -111,15 +110,16 @@ static void dp_retrain_link_dp_test(struct dc_link *link,
                                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);
+                               link_hwss->setup_audio_output(pipes[i],
+                                                             &pipes[i]->stream_res.audio_output,
+                                                             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_res.audio_output.crtc_info,
                                                &pipes[i]->stream->audio_info,
-                                               &audio_output[i].dp_link_info);
+                                               &pipes[i]->stream_res.audio_output.dp_link_info);
 
                                if (link->dc->config.disable_hbr_audio_dp2 &&
                                                pipes[i]->stream_res.audio->funcs->az_disable_hbr_audio &&
index 3ed7f50554e21e0556d6e06e20ab4f569dac6f84..ca17e5d8fdc2a4ef9eba392a268b8a198e5f4cc7 100644 (file)
@@ -2239,8 +2239,7 @@ struct resource_pool *dcn31_create_resource_pool(
 enum dc_status dcn31_update_dc_state_for_encoder_switch(struct dc_link *link,
        struct dc_link_settings *link_setting,
        uint8_t pipe_count,
-       struct pipe_ctx *pipes,
-       struct audio_output *audio_output)
+       struct pipe_ctx *pipes)
 {
        struct dc_state *state = link->dc->current_state;
        int i;
@@ -2255,7 +2254,7 @@ enum dc_status dcn31_update_dc_state_for_encoder_switch(struct dc_link *link,
 
                // Setup audio
                if (pipes[i].stream_res.audio != NULL)
-                       build_audio_output(state, &pipes[i], &audio_output[i]);
+                       build_audio_output(state, &pipes[i], &pipes[i].stream_res.audio_output);
        }
 #else
        /* This DCN requires rate divider updates and audio reprogramming to allow DP1<-->DP2 link rate switching,
index c32c85ef0ba4774579cb2645c25ab0c3c0c544b4..7e8fde65528f148e207120e5ca6a02e396023fc5 100644 (file)
@@ -69,8 +69,7 @@ unsigned int dcn31_get_det_buffer_size(
 enum dc_status dcn31_update_dc_state_for_encoder_switch(struct dc_link *link,
        struct dc_link_settings *link_setting,
        uint8_t pipe_count,
-       struct pipe_ctx *pipes,
-       struct audio_output *audio_output);
+       struct pipe_ctx *pipes);
 
 /*temp: B0 specific before switch to dcn313 headers*/
 #ifndef regPHYPLLF_PIXCLK_RESYNC_CNTL