Skip to content

Commit

Permalink
drm/amd/display: dynamically allocate dml2_configuration_options stru…
Browse files Browse the repository at this point in the history
…ctures

This structure is too large to fit on a stack, as shown by the
newly introduced warnings from a recent code change:

drivers/gpu/drm/amd/amdgpu/../display/dc/resource/dcn32/dcn32_resource.c: In function 'dcn32_update_bw_bounding_box':
drivers/gpu/drm/amd/amdgpu/../display/dc/resource/dcn32/dcn32_resource.c:2019:1: error: the frame size of 1180 bytes is larger than 1024 bytes [-Werror=frame-larger-than=]
drivers/gpu/drm/amd/amdgpu/../display/dc/resource/dcn321/dcn321_resource.c: In function 'dcn321_update_bw_bounding_box':
drivers/gpu/drm/amd/amdgpu/../display/dc/resource/dcn321/dcn321_resource.c:1597:1: error: the frame size of 1180 bytes is larger than 1024 bytes [-Werror=frame-larger-than=]
drivers/gpu/drm/amd/amdgpu/../display/dc/core/dc_state.c: In function 'dc_state_create':
drivers/gpu/drm/amd/amdgpu/../display/dc/core/dc_state.c:219:1: error: the frame size of 1184 bytes is larger than 1024 bytes [-Werror=frame-larger-than=]

Instead of open-coding the assignment of a large structure to a stack
variable, use an explicit kmemdup() in each case to move it off the stack.

Fixes: e779f45 ("drm/amd/display: Add handling for DC power mode")
Signed-off-by: Arnd Bergmann <[email protected]>
Signed-off-by: Alex Deucher <[email protected]>
  • Loading branch information
arndb authored and alexdeucher committed May 29, 2024
1 parent 3027ce1 commit 88c6182
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 10 deletions.
16 changes: 11 additions & 5 deletions drivers/gpu/drm/amd/display/dc/resource/dcn32/dcn32_resource.c
Original file line number Diff line number Diff line change
Expand Up @@ -2007,21 +2007,27 @@ void dcn32_calculate_wm_and_dlg(struct dc *dc, struct dc_state *context,

static void dcn32_update_bw_bounding_box(struct dc *dc, struct clk_bw_params *bw_params)
{
struct dml2_configuration_options dml2_opt = dc->dml2_options;
struct dml2_configuration_options *dml2_opt;

dml2_opt = kmemdup(&dc->dml2_options, sizeof(dc->dml2_options), GFP_KERNEL);
if (!dml2_opt)
return;

DC_FP_START();

dcn32_update_bw_bounding_box_fpu(dc, bw_params);

dml2_opt.use_clock_dc_limits = false;
dml2_opt->use_clock_dc_limits = false;
if (dc->debug.using_dml2 && dc->current_state && dc->current_state->bw_ctx.dml2)
dml2_reinit(dc, &dml2_opt, &dc->current_state->bw_ctx.dml2);
dml2_reinit(dc, dml2_opt, &dc->current_state->bw_ctx.dml2);

dml2_opt.use_clock_dc_limits = true;
dml2_opt->use_clock_dc_limits = true;
if (dc->debug.using_dml2 && dc->current_state && dc->current_state->bw_ctx.dml2_dc_power_source)
dml2_reinit(dc, &dml2_opt, &dc->current_state->bw_ctx.dml2_dc_power_source);
dml2_reinit(dc, dml2_opt, &dc->current_state->bw_ctx.dml2_dc_power_source);

DC_FP_END();

kfree(dml2_opt);
}

static struct resource_funcs dcn32_res_pool_funcs = {
Expand Down
16 changes: 11 additions & 5 deletions drivers/gpu/drm/amd/display/dc/resource/dcn321/dcn321_resource.c
Original file line number Diff line number Diff line change
Expand Up @@ -1581,21 +1581,27 @@ static struct dc_cap_funcs cap_funcs = {

static void dcn321_update_bw_bounding_box(struct dc *dc, struct clk_bw_params *bw_params)
{
struct dml2_configuration_options dml2_opt = dc->dml2_options;
struct dml2_configuration_options *dml2_opt;

dml2_opt = kmemdup(&dc->dml2_options, sizeof(dc->dml2_options), GFP_KERNEL);
if (!dml2_opt)
return;

DC_FP_START();

dcn321_update_bw_bounding_box_fpu(dc, bw_params);

dml2_opt.use_clock_dc_limits = false;
dml2_opt->use_clock_dc_limits = false;
if (dc->debug.using_dml2 && dc->current_state && dc->current_state->bw_ctx.dml2)
dml2_reinit(dc, &dml2_opt, &dc->current_state->bw_ctx.dml2);
dml2_reinit(dc, dml2_opt, &dc->current_state->bw_ctx.dml2);

dml2_opt.use_clock_dc_limits = true;
dml2_opt->use_clock_dc_limits = true;
if (dc->debug.using_dml2 && dc->current_state && dc->current_state->bw_ctx.dml2_dc_power_source)
dml2_reinit(dc, &dml2_opt, &dc->current_state->bw_ctx.dml2_dc_power_source);
dml2_reinit(dc, dml2_opt, &dc->current_state->bw_ctx.dml2_dc_power_source);

DC_FP_END();

kfree(dml2_opt);
}

static struct resource_funcs dcn321_res_pool_funcs = {
Expand Down

0 comments on commit 88c6182

Please sign in to comment.