Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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: e779f4587f61 ("drm/amd/display: Add handling for DC power mode")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>

authored by

Arnd Bergmann and committed by
Alex Deucher
88c61827 3027ce13

+22 -10
+11 -5
drivers/gpu/drm/amd/display/dc/resource/dcn32/dcn32_resource.c
··· 2007 2007 2008 2008 static void dcn32_update_bw_bounding_box(struct dc *dc, struct clk_bw_params *bw_params) 2009 2009 { 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; 2011 2015 2012 2016 DC_FP_START(); 2013 2017 2014 2018 dcn32_update_bw_bounding_box_fpu(dc, bw_params); 2015 2019 2016 - dml2_opt.use_clock_dc_limits = false; 2020 + dml2_opt->use_clock_dc_limits = false; 2017 2021 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); 2019 2023 2020 - dml2_opt.use_clock_dc_limits = true; 2024 + dml2_opt->use_clock_dc_limits = true; 2021 2025 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); 2023 2027 2024 2028 DC_FP_END(); 2029 + 2030 + kfree(dml2_opt); 2025 2031 } 2026 2032 2027 2033 static struct resource_funcs dcn32_res_pool_funcs = {
+11 -5
drivers/gpu/drm/amd/display/dc/resource/dcn321/dcn321_resource.c
··· 1581 1581 1582 1582 static void dcn321_update_bw_bounding_box(struct dc *dc, struct clk_bw_params *bw_params) 1583 1583 { 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; 1585 1589 1586 1590 DC_FP_START(); 1587 1591 1588 1592 dcn321_update_bw_bounding_box_fpu(dc, bw_params); 1589 1593 1590 - dml2_opt.use_clock_dc_limits = false; 1594 + dml2_opt->use_clock_dc_limits = false; 1591 1595 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); 1593 1597 1594 - dml2_opt.use_clock_dc_limits = true; 1598 + dml2_opt->use_clock_dc_limits = true; 1595 1599 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); 1597 1601 1598 1602 DC_FP_END(); 1603 + 1604 + kfree(dml2_opt); 1599 1605 } 1600 1606 1601 1607 static struct resource_funcs dcn321_res_pool_funcs = {