[AMD Official Use Only - AMD Internal Distribution Only] Reviewed-by: Wenjing Liu <wenjing....@amd.com>
________________________________ From: SHANMUGAM, SRINIVASAN <srinivasan.shanmu...@amd.com> Sent: Friday, August 01, 2025 8:12 AM To: Hung, Alex <alex.h...@amd.com>; Pillai, Aurabindo <aurabindo.pil...@amd.com>; Lei, Jun <jun....@amd.com>; Liu, Wenjing <wenjing....@amd.com> Cc: amd-gfx@lists.freedesktop.org <amd-gfx@lists.freedesktop.org>; SHANMUGAM, SRINIVASAN <srinivasan.shanmu...@amd.com>; Strauss, Michael <michael.stra...@amd.com>; Lee, Alvin <alvin.l...@amd.com>; LIPSKI, IVAN <ivan.lip...@amd.com> Subject: [PATCH] drm/amd/display: Move 'audio descriptor' storage from 'stream resource' to 'dc scratch' The `stream_resource` structure holds hardware parts and resources that stay active as long as the display stream or pipe is running. It represents the hardware state. The `audio_output` structure is temporary. It is built and used only during operations like dc validation and link retraining. It does not represent permanent hardware resources. This patch moves the audio_output descriptor from stream_res to dc_scratch_space. This keeps temporary data separate from permanent hardware state 'Fixes: 571662266db3 ("drm/amd/display: Reduce Stack Usage by moving 'audio_output' into 'stream_res' v4")' Cc: Michael Strauss <michael.stra...@amd.com> Cc: Alvin Lee <alvin.l...@amd.com> Cc: Jun Lei <jun....@amd.com> Cc: Wenjing Liu <wenjing....@amd.com> Cc: Alex Hung <alex.h...@amd.com> Cc: Ivan Lipski <ivan.lip...@amd.com> Cc: Aurabindo Pillai <aurabindo.pil...@amd.com> Suggested-by: Jun Lei <jun....@amd.com> Signed-off-by: Srinivasan Shanmugam <srinivasan.shanmu...@amd.com> --- drivers/gpu/drm/amd/display/dc/dc.h | 3 ++ .../amd/display/dc/hwss/dce110/dce110_hwseq.c | 30 +++++++++++-------- .../gpu/drm/amd/display/dc/inc/core_types.h | 5 ++-- .../display/dc/link/accessories/link_dp_cts.c | 13 +++++--- .../dc/resource/dcn31/dcn31_resource.c | 5 ++-- .../dc/resource/dcn31/dcn31_resource.h | 3 +- 6 files changed, 36 insertions(+), 23 deletions(-) diff --git a/drivers/gpu/drm/amd/display/dc/dc.h b/drivers/gpu/drm/amd/display/dc/dc.h index 5653c1673aec..c6bfde9d3e98 100644 --- a/drivers/gpu/drm/amd/display/dc/dc.h +++ b/drivers/gpu/drm/amd/display/dc/dc.h @@ -47,6 +47,7 @@ #include "dmub/inc/dmub_cmd.h" #include "sspl/dc_spl_types.h" +#include "audio_types.h" struct abm_save_restore; @@ -1734,6 +1735,8 @@ struct dc { struct dc_stream_state temp_stream; // Used so we don't need to allocate stream on the stack struct dc_link temp_link; bool pipes_to_unlock_first[MAX_PIPES]; /* Any of the pipes indicated here should be unlocked first */ + /* Pre-allocated buffer for audio_output used in dp_retrain_link_dp_test() */ + struct audio_output audio_output[MAX_PIPES]; } scratch; struct dml2_configuration_options dml2_options; diff --git a/drivers/gpu/drm/amd/display/dc/hwss/dce110/dce110_hwseq.c b/drivers/gpu/drm/amd/display/dc/hwss/dce110/dce110_hwseq.c index 153d68375fa3..49ad34734cef 100644 --- a/drivers/gpu/drm/amd/display/dc/hwss/dce110/dce110_hwseq.c +++ b/drivers/gpu/drm/amd/display/dc/hwss/dce110/dce110_hwseq.c @@ -1586,6 +1586,7 @@ enum dc_status dce110_apply_single_controller_ctx_to_hw( struct dc_state *context, struct dc *dc) { + struct audio_output *audio_output; struct dc_stream_state *stream = pipe_ctx->stream; struct dc_link *link = stream->link; struct drr_params params = {0}; @@ -1595,23 +1596,23 @@ enum dc_status dce110_apply_single_controller_ctx_to_hw( const struct link_hwss *link_hwss = get_link_hwss( link, &pipe_ctx->link_res); - if (hws->funcs.disable_stream_gating) { hws->funcs.disable_stream_gating(dc, pipe_ctx); } if (pipe_ctx->stream_res.audio != NULL) { - build_audio_output(context, pipe_ctx, &pipe_ctx->stream_res.audio_output); + audio_output = &dc->scratch.audio_output[pipe_ctx->pipe_idx]; + build_audio_output(context, pipe_ctx, audio_output); - link_hwss->setup_audio_output(pipe_ctx, &pipe_ctx->stream_res.audio_output, + link_hwss->setup_audio_output(pipe_ctx, 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, - &pipe_ctx->stream_res.audio_output.crtc_info, + &audio_output->crtc_info, &pipe_ctx->stream->audio_info, - &pipe_ctx->stream_res.audio_output.dp_link_info); + &audio_output->dp_link_info); if (dc->config.disable_hbr_audio_dp2) if (pipe_ctx->stream_res.audio->funcs->az_disable_hbr_audio && @@ -2354,6 +2355,7 @@ static void dce110_setup_audio_dto( struct dc_state *context) { unsigned int i; + struct audio_output *audio_output; /* program audio wall clock. use HDMI as clock source if HDMI * audio active. Otherwise, use DP as clock source @@ -2385,7 +2387,8 @@ static void dce110_setup_audio_dto( if (pipe_ctx->stream->signal != SIGNAL_TYPE_HDMI_TYPE_A) continue; if (pipe_ctx->stream_res.audio != NULL) { - build_audio_output(context, pipe_ctx, &pipe_ctx->stream_res.audio_output); + audio_output = &dc->scratch.audio_output[i]; + build_audio_output(context, pipe_ctx, audio_output); if (dc->res_pool->dccg && dc->res_pool->dccg->funcs->set_audio_dtbclk_dto) { struct dtbclk_dto_params dto_params = {0}; @@ -2396,14 +2399,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, - &pipe_ctx->stream_res.audio_output.crtc_info, - &pipe_ctx->stream_res.audio_output.pll_info); + &audio_output->crtc_info, + &audio_output->pll_info); } else pipe_ctx->stream_res.audio->funcs->wall_dto_setup( pipe_ctx->stream_res.audio, pipe_ctx->stream->signal, - &pipe_ctx->stream_res.audio_output.crtc_info, - &pipe_ctx->stream_res.audio_output.pll_info); + &audio_output->crtc_info, + &audio_output->pll_info); break; } } @@ -2423,15 +2426,16 @@ static void dce110_setup_audio_dto( continue; if (pipe_ctx->stream_res.audio != NULL) { + audio_output = &dc->scratch.audio_output[i]; build_audio_output(context, pipe_ctx, - &pipe_ctx->stream_res.audio_output); + audio_output); pipe_ctx->stream_res.audio->funcs->wall_dto_setup( pipe_ctx->stream_res.audio, pipe_ctx->stream->signal, - &pipe_ctx->stream_res.audio_output.crtc_info, - &pipe_ctx->stream_res.audio_output.pll_info); + &audio_output->crtc_info, + &audio_output->pll_info); break; } } diff --git a/drivers/gpu/drm/amd/display/dc/inc/core_types.h b/drivers/gpu/drm/amd/display/dc/inc/core_types.h index 4387de044469..df0d72b2c1b0 100644 --- a/drivers/gpu/drm/amd/display/dc/inc/core_types.h +++ b/drivers/gpu/drm/amd/display/dc/inc/core_types.h @@ -228,7 +228,8 @@ 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 pipe_ctx *pipes, + struct audio_output *audio_output); }; struct audio_support{ @@ -360,8 +361,6 @@ struct stream_resource { uint8_t gsl_group; struct test_pattern_params test_pattern_params; - - struct audio_output audio_output; }; struct plane_resource { 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 23f41c99fa38..4af5fde2e392 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 @@ -35,6 +35,7 @@ #include "dc_dmub_srv.h" #include "dce/dmub_hw_lock_mgr.h" #include "clk_mgr.h" +#include "dc.h" #define DC_LOGGER \ link->ctx->logger @@ -66,6 +67,7 @@ static void dp_retrain_link_dp_test(struct dc_link *link, struct dc_link_settings *link_setting, bool skip_video_pattern) { + struct dc *dc = (struct dc *)(unsigned long)link->dc; struct pipe_ctx *pipes[MAX_PIPES]; struct dc_state *state = link->dc->current_state; struct dc_stream_update stream_update = { 0 }; @@ -79,6 +81,9 @@ static void dp_retrain_link_dp_test(struct dc_link *link, struct dc_stream_state *streams_on_link[MAX_PIPES]; int num_streams_on_link = 0; + /* Zero out the scratch audio output array */ + memset((void *)dc->scratch.audio_output, 0, sizeof(dc->scratch.audio_output)); + 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)); @@ -101,7 +106,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); + *pipes, dc->scratch.audio_output); for (i = 0; i < count; i++) { pipes[i]->clock_source->funcs->program_pix_clk( pipes[i]->clock_source, @@ -114,15 +119,15 @@ static void dp_retrain_link_dp_test(struct dc_link *link, link, &pipes[i]->link_res); link_hwss->setup_audio_output(pipes[i], - &pipes[i]->stream_res.audio_output, + &dc->scratch.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, - &pipes[i]->stream_res.audio_output.crtc_info, + &dc->scratch.audio_output[i].crtc_info, &pipes[i]->stream->audio_info, - &pipes[i]->stream_res.audio_output.dp_link_info); + &dc->scratch.audio_output[i].dp_link_info); if (link->dc->config.disable_hbr_audio_dp2 && pipes[i]->stream_res.audio->funcs->az_disable_hbr_audio && diff --git a/drivers/gpu/drm/amd/display/dc/resource/dcn31/dcn31_resource.c b/drivers/gpu/drm/amd/display/dc/resource/dcn31/dcn31_resource.c index ca17e5d8fdc2..3ed7f50554e2 100644 --- a/drivers/gpu/drm/amd/display/dc/resource/dcn31/dcn31_resource.c +++ b/drivers/gpu/drm/amd/display/dc/resource/dcn31/dcn31_resource.c @@ -2239,7 +2239,8 @@ 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 pipe_ctx *pipes, + struct audio_output *audio_output) { struct dc_state *state = link->dc->current_state; int i; @@ -2254,7 +2255,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], &pipes[i].stream_res.audio_output); + build_audio_output(state, &pipes[i], &audio_output[i]); } #else /* This DCN requires rate divider updates and audio reprogramming to allow DP1<-->DP2 link rate switching, diff --git a/drivers/gpu/drm/amd/display/dc/resource/dcn31/dcn31_resource.h b/drivers/gpu/drm/amd/display/dc/resource/dcn31/dcn31_resource.h index 7e8fde65528f..c32c85ef0ba4 100644 --- a/drivers/gpu/drm/amd/display/dc/resource/dcn31/dcn31_resource.h +++ b/drivers/gpu/drm/amd/display/dc/resource/dcn31/dcn31_resource.h @@ -69,7 +69,8 @@ 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 pipe_ctx *pipes, + struct audio_output *audio_output); /*temp: B0 specific before switch to dcn313 headers*/ #ifndef regPHYPLLF_PIXCLK_RESYNC_CNTL -- 2.34.1