[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CADnq5_OtL0D+mE8bsoWmPz0e7USC=UrpFjcZZ2LTeaHePToBxQ@mail.gmail.com>
Date: Wed, 29 May 2024 10:46:27 -0400
From: Alex Deucher <alexdeucher@...il.com>
To: Arnd Bergmann <arnd@...nel.org>
Cc: Harry Wentland <harry.wentland@....com>, Leo Li <sunpeng.li@....com>,
Rodrigo Siqueira <Rodrigo.Siqueira@....com>, Arnd Bergmann <arnd@...db.de>,
Alex Deucher <alexander.deucher@....com>, Christian König <christian.koenig@....com>,
"Pan, Xinhui" <Xinhui.Pan@....com>, David Airlie <airlied@...il.com>, Daniel Vetter <daniel@...ll.ch>,
Wenjing Liu <wenjing.liu@....com>, Alvin Lee <alvin.lee2@....com>, Jun Lei <jun.lei@....com>,
Hamza Mahfooz <hamza.mahfooz@....com>, Aurabindo Pillai <aurabindo.pillai@....com>,
Dillon Varone <dillon.varone@....com>, Qingqing Zhuo <Qingqing.Zhuo@....com>,
Roman Li <roman.li@....com>, Aric Cyr <aric.cyr@....com>,
Joshua Aberback <joshua.aberback@....com>, amd-gfx@...ts.freedesktop.org,
dri-devel@...ts.freedesktop.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH 1/4] [RESEND] drm/amd/display: dynamically allocate
dml2_configuration_options structures
Applied the series. Thanks!
Alex
On Tue, May 28, 2024 at 7:52 AM Arnd Bergmann <arnd@...nel.org> wrote:
>
> From: Arnd Bergmann <arnd@...db.de>
>
> 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@...db.de>
> ---
> Originally sent as https://lore.kernel.org/all/20240418083421.3956461-1-arnd@kernel.org/
> ---
> .../display/dc/resource/dcn32/dcn32_resource.c | 16 +++++++++++-----
> .../display/dc/resource/dcn321/dcn321_resource.c | 16 +++++++++++-----
> 2 files changed, 22 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/display/dc/resource/dcn32/dcn32_resourcec b/drivers/gpu/drm/amd/display/dc/resource/dcn32/dcn32_resource.c
> index 022d320be1d5..0f11d7c8791c 100644
> --- a/drivers/gpu/drm/amd/display/dc/resource/dcn32/dcn32_resource.c
> +++ b/drivers/gpu/drm/amd/display/dc/resource/dcn32/dcn32_resource.c
> @@ -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 = {
> diff --git a/drivers/gpu/drm/amd/display/dc/resource/dcn321/dcn321_resource.c b/drivers/gpu/drm/amd/display/dc/resource/dcn321/dcn321_resource.c
> index e4b360d89b3b..07ca6f58447d 100644
> --- a/drivers/gpu/drm/amd/display/dc/resource/dcn321/dcn321_resource.c
> +++ b/drivers/gpu/drm/amd/display/dc/resource/dcn321/dcn321_resource.c
> @@ -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 = {
> --
> 2.39.2
>
Powered by blists - more mailing lists