From patchwork Thu Apr 18 08:34:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 13634349 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 798CDC4345F for ; Thu, 18 Apr 2024 08:34:36 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 80E0410FE89; Thu, 18 Apr 2024 08:34:35 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.b="gpk2Fa2W"; dkim-atps=neutral Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by gabe.freedesktop.org (Postfix) with ESMTPS id 3E71810FE89; Thu, 18 Apr 2024 08:34:34 +0000 (UTC) Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id 1965DCE16A8; Thu, 18 Apr 2024 08:34:31 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 198FBC113CC; Thu, 18 Apr 2024 08:34:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1713429269; bh=foTuupios4Tf2RFReAr+18DI+jVKcX1qxJXzRW7VmzA=; h=From:To:Cc:Subject:Date:From; b=gpk2Fa2WhrJS/XHTk0xJX4e/AB2edk0Rev0P8fLFaA07EOUUxNIIjgW5mw4ucF0kA 2mA7wog3Kwh07RqwUso84ur5Gv48FRy/bF0IjyeAXRExODqVr3R3mRynqaIPdDLWNZ 0BsgEl751JT5/QTDC8to6OoPMP824P57Cwq4dX6dygrmTSpaeeOxZ0oSQ2pmph3So+ heG2eWv6stEPXU0R/FCmgazYyiYBVWqjH9VS7jravHSHk5vn2Otf2r5reUshF/DyQc 9FyNMhjP/NbVg1uck/EMbRbAkPo4ZDLJ5CPg8+OvhmZe9wAmGcs08lRnSfSI7uiVwr ftAlhjyLpR8hg== From: Arnd Bergmann To: Harry Wentland , Leo Li , Rodrigo Siqueira Cc: Arnd Bergmann , Alex Deucher , =?utf-8?q?Christian_K=C3=B6nig?= , "Pan, Xinhui" , David Airlie , Daniel Vetter , Wenjing Liu , Alvin Lee , Jun Lei , Dillon Varone , Aurabindo Pillai , Samson Tam , Qingqing Zhuo , Roman Li , Aric Cyr , Joshua Aberback , amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/2] drm/amd/display: dynamically allocate dml2_configuration_options structures Date: Thu, 18 Apr 2024 10:34:02 +0200 Message-Id: <20240418083421.3956461-1-arnd@kernel.org> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Arnd Bergmann 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 --- .../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_resource.c b/drivers/gpu/drm/amd/display/dc/resource/dcn32/dcn32_resource.c index c16e915686fc..b2b95f5abb09 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 @@ -2001,21 +2001,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 3816678b044f..ea5768f57138 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 @@ -1579,21 +1579,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 = { From patchwork Thu Apr 18 08:34:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 13634350 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 00B18C4345F for ; Thu, 18 Apr 2024 08:34:46 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 19F7F113AC0; Thu, 18 Apr 2024 08:34:46 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.b="N52Lm3VK"; dkim-atps=neutral Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by gabe.freedesktop.org (Postfix) with ESMTPS id 230C4113AC0; Thu, 18 Apr 2024 08:34:44 +0000 (UTC) Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id 3F74ECE16A8; Thu, 18 Apr 2024 08:34:42 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AB27BC113CC; Thu, 18 Apr 2024 08:34:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1713429280; bh=mm128Q0AdH9Dvjnv7b4cIuV9GNgaiwIadPzWSTcvOcM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=N52Lm3VKCcPqN8tpR+YRwXPxacUTwpSH7L5eIq8LmosIjo2h9ddpVSOEiTM5T2f2A 3FgFn49pZ3SLKFYM7D8duH70vvbHUp6ZSRImwhow7yAWN3FEeemiMuqwF36fC2WemO Lnm8Cb/KJ7ZW+hqqMP2eLIwLT3e3MEQrCPTC4d+8x0uxn5LcVjT3RASL2y0wD83yia tPD+VrkBAUPN/Pc3cMnhqspqWNlt0OwOpUYtlfFhJnIZgpuRlY5LlnGhtee6WKeXSI NC62QK2VIBu9tOT6sRywsZDV7GvnO2dGN394AiOT1F3Se4UmDRiq+UhYQA6qSEx4NL 68X2MQ7ogYl7g== From: Arnd Bergmann To: Harry Wentland , Leo Li , Rodrigo Siqueira Cc: Arnd Bergmann , Alex Deucher , =?utf-8?q?Christian_K=C3=B6nig?= , "Pan, Xinhui" , David Airlie , Daniel Vetter , Martin Leung , Mounika Adhuri , Roman Li , amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/2] drm/amd/display: fix graphics_object_id size Date: Thu, 18 Apr 2024 10:34:03 +0200 Message-Id: <20240418083421.3956461-2-arnd@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240418083421.3956461-1-arnd@kernel.org> References: <20240418083421.3956461-1-arnd@kernel.org> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Arnd Bergmann The graphics_object_id structure is meant to fit into 32 bits, as it's passed by value in and out of functions. A recent change increased the size to 128 bits, so it's now always passed by reference, which is clearly not intended and ends up producing a compile-time warning: drivers/gpu/drm/amd/amdgpu/../display/dc/link/link_factory.c: In function 'construct_phy': drivers/gpu/drm/amd/amdgpu/../display/dc/link/link_factory.c:743:1: error: the frame size of 1040 bytes is larger than 1024 bytes [-Werror=frame-larger-than=] Add back the bitfields to revert to the original size, while keeping the 'enum' type change. fec85f995a4b ("drm/amd/display: Fix compiler redefinition warnings for certain configs") Signed-off-by: Arnd Bergmann --- drivers/gpu/drm/amd/display/include/grph_object_id.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/amd/display/include/grph_object_id.h b/drivers/gpu/drm/amd/display/include/grph_object_id.h index 08ee0350b31f..54e33062b3c0 100644 --- a/drivers/gpu/drm/amd/display/include/grph_object_id.h +++ b/drivers/gpu/drm/amd/display/include/grph_object_id.h @@ -226,8 +226,8 @@ enum dp_alt_mode { struct graphics_object_id { uint32_t id:8; - enum object_enum_id enum_id; - enum object_type type; + enum object_enum_id enum_id :4; + enum object_type type :4; uint32_t reserved:16; /* for padding. total size should be u32 */ };