Skip to content

Commit 88c6182

Browse files
arndbalexdeucher
authored andcommitted
drm/amd/display: dynamically allocate dml2_configuration_options structures
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]>
1 parent 3027ce1 commit 88c6182

File tree

2 files changed

+22
-10
lines changed

2 files changed

+22
-10
lines changed

drivers/gpu/drm/amd/display/dc/resource/dcn32/dcn32_resource.c

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2007,21 +2007,27 @@ void dcn32_calculate_wm_and_dlg(struct dc *dc, struct dc_state *context,
20072007

20082008
static void dcn32_update_bw_bounding_box(struct dc *dc, struct clk_bw_params *bw_params)
20092009
{
2010-
struct dml2_configuration_options dml2_opt = dc->dml2_options;
2010+
struct dml2_configuration_options *dml2_opt;
2011+
2012+
dml2_opt = kmemdup(&dc->dml2_options, sizeof(dc->dml2_options), GFP_KERNEL);
2013+
if (!dml2_opt)
2014+
return;
20112015

20122016
DC_FP_START();
20132017

20142018
dcn32_update_bw_bounding_box_fpu(dc, bw_params);
20152019

2016-
dml2_opt.use_clock_dc_limits = false;
2020+
dml2_opt->use_clock_dc_limits = false;
20172021
if (dc->debug.using_dml2 && dc->current_state && dc->current_state->bw_ctx.dml2)
2018-
dml2_reinit(dc, &dml2_opt, &dc->current_state->bw_ctx.dml2);
2022+
dml2_reinit(dc, dml2_opt, &dc->current_state->bw_ctx.dml2);
20192023

2020-
dml2_opt.use_clock_dc_limits = true;
2024+
dml2_opt->use_clock_dc_limits = true;
20212025
if (dc->debug.using_dml2 && dc->current_state && dc->current_state->bw_ctx.dml2_dc_power_source)
2022-
dml2_reinit(dc, &dml2_opt, &dc->current_state->bw_ctx.dml2_dc_power_source);
2026+
dml2_reinit(dc, dml2_opt, &dc->current_state->bw_ctx.dml2_dc_power_source);
20232027

20242028
DC_FP_END();
2029+
2030+
kfree(dml2_opt);
20252031
}
20262032

20272033
static struct resource_funcs dcn32_res_pool_funcs = {

drivers/gpu/drm/amd/display/dc/resource/dcn321/dcn321_resource.c

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1581,21 +1581,27 @@ static struct dc_cap_funcs cap_funcs = {
15811581

15821582
static void dcn321_update_bw_bounding_box(struct dc *dc, struct clk_bw_params *bw_params)
15831583
{
1584-
struct dml2_configuration_options dml2_opt = dc->dml2_options;
1584+
struct dml2_configuration_options *dml2_opt;
1585+
1586+
dml2_opt = kmemdup(&dc->dml2_options, sizeof(dc->dml2_options), GFP_KERNEL);
1587+
if (!dml2_opt)
1588+
return;
15851589

15861590
DC_FP_START();
15871591

15881592
dcn321_update_bw_bounding_box_fpu(dc, bw_params);
15891593

1590-
dml2_opt.use_clock_dc_limits = false;
1594+
dml2_opt->use_clock_dc_limits = false;
15911595
if (dc->debug.using_dml2 && dc->current_state && dc->current_state->bw_ctx.dml2)
1592-
dml2_reinit(dc, &dml2_opt, &dc->current_state->bw_ctx.dml2);
1596+
dml2_reinit(dc, dml2_opt, &dc->current_state->bw_ctx.dml2);
15931597

1594-
dml2_opt.use_clock_dc_limits = true;
1598+
dml2_opt->use_clock_dc_limits = true;
15951599
if (dc->debug.using_dml2 && dc->current_state && dc->current_state->bw_ctx.dml2_dc_power_source)
1596-
dml2_reinit(dc, &dml2_opt, &dc->current_state->bw_ctx.dml2_dc_power_source);
1600+
dml2_reinit(dc, dml2_opt, &dc->current_state->bw_ctx.dml2_dc_power_source);
15971601

15981602
DC_FP_END();
1603+
1604+
kfree(dml2_opt);
15991605
}
16001606

16011607
static struct resource_funcs dcn321_res_pool_funcs = {

0 commit comments

Comments
 (0)