Received: by 2002:a89:d88:0:b0:1fa:5c73:8e2d with SMTP id eb8csp2586735lqb; Tue, 28 May 2024 04:53:24 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXxM6z08FKHUyxHqrHsfawgD1Zo4NQniCG9I32hCF+KRNXbIr7aWjenCE0g0zGbrY2v8V7jUyonzj+1Ujol0CjGnfd7lJzisveERljRHw== X-Google-Smtp-Source: AGHT+IE2eLglai/8nAtif3XNtET1OetBUn3+hi76YsAaasCGku5tS5GYKVUcTvoFX7ci2Sfxm0Wx X-Received: by 2002:a05:6122:31a9:b0:4db:bba:acaa with SMTP id 71dfb90a1353d-4e4f021d31bmr12556281e0c.3.1716897204289; Tue, 28 May 2024 04:53:24 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716897204; cv=pass; d=google.com; s=arc-20160816; b=g8UxF5tzkC0QM8TN4cXbj0deL5YU3HqmawxYARuKaV/wMRVaW4KrdlImzU36Hmuj4J AJH9x0anq84md6pLt+NKOfhwTK+JQ2U3JmdX52v2wvyi1/Mo3qlFy9w0Q7d6tYJUz4ju y/WrVlJLIlU9NFW/dZ9FcBaVNDywnkvgqE4KklQB6HPn/lurz0Ct4vWicMkjQK3a/FGG kdVP5martrW/nTGvK70eoOlpfADJ0iN8bUyfUPjxvqaSdVTr0G5GBk6IcwM+JtKPL/wU 2ty4dt/N5CHgKX5sv0LkIUhMApohMJ0h4IYKcWXM/x6yg9KPzLL0R14LyMhEe7EhFrs0 VbmA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=NUJIw4bDszNpHkwVm+3PJxObaYkubtf4e9VhKtKptJM=; fh=XXiJyaFKL6xEDU3BzXSueVmtovVOF+nNT2FEgLv7+tE=; b=ECscIEfS2NHLWKl4NzzTNoPL+1R0gtNAGVA4eVA0F8UCCRHcaKYe7D7H5umNbVpu8L DxRVizDz4mfmCFgHHDPY+RP2Kg+uAnP2ssOztFTtecFbzlrZ2cdpSvlumY+BAq2rrgcR 0QPdMWDj3Rx3mxZkCNZwVVgH1GGuEQhWWQVflwpwTeafqQaXb9F7aGC8A6rHtcDmcqrd R2tR1OKMIsUAfBdP2vpwTKp2qlNHZmVnJrYEIEeHA1LnobUiFY2pli7jOdhPxY6gqsDi 6uJXkPBDQjBCoqi12LnRSzoIvsbvf3RI2/frRNn8iPAFPqzjfmYCQGuNsEPdoIyw1fBx 7uFg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=D03AwHuD; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-192226-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-192226-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id af79cd13be357-794abd3d269si1082662185a.468.2024.05.28.04.53.24 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 May 2024 04:53:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-192226-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=D03AwHuD; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-192226-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-192226-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 576181C23E26 for ; Tue, 28 May 2024 11:52:58 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1878D16C87B; Tue, 28 May 2024 11:52:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="D03AwHuD" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3319816C87C for ; Tue, 28 May 2024 11:52:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716897160; cv=none; b=sP0ANyzs7S0GJ8qCKpigETNaapE8d2b9Zw/UKTHahvs4OInohjTjIjPNuSOa1xHUVTllv4KB8VfpKp4wbApmBvUDQZ/j84ssXhhyx9K+mcxqzPTLUpbv3Ch6n0ToWZvJ2nSmse4hqkC6mODalYdLqYuo6+Cv472RTP2XMYooZFE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716897160; c=relaxed/simple; bh=c6HLmHQgr+K+/opF/OiiYVpCKahYXfgVPr1CgHqBTgk=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=ZYDOtdHwFc6/0l+90f1k9P5YdCrmFp8jold7KlFfDKjpodlSGobS6Totu2xIA4aZnqFdCbw+196F82To2HxKUyT6jrrflxSC1D+889QqKQxOKS5BuBY+dYah+4u8NPKwqoWQtOdvryctVYsxRbuqVe1l+CtAq2A9YmFKvR5hW9c= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=D03AwHuD; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 80F68C32782; Tue, 28 May 2024 11:52:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1716897159; bh=c6HLmHQgr+K+/opF/OiiYVpCKahYXfgVPr1CgHqBTgk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=D03AwHuDsKvcUkDlecqDtEPZZhMjTaMFd/0vPhG4U2wi15wGBBRYxi+a50oIIBAD3 kKAzYiBT1/iSoy4fgo1HuQYlVrjGJRadJCOGeXHrEpHjmtG5x2+kEt/49Zn++EPv+4 yeyFdAE0FhAbD49JWO4q62bg33zoI0vP/C8pwYSFZ30Fh2GsOjzJTbRobGkohqR5rr +m1pqpaXPIfHzUI95y9nwRik70fTPhQk/0KhuQAFuk92y8DNShIWo2NiRIKgACLAsd nq64oSyxXi+S9t5Pd+97UwuemMAMEJYbXLnE1eMhYtqw+0vuS/pjB9/noBCtL5TtS4 XbAPM52H58fyQ== From: Arnd Bergmann To: Harry Wentland , Leo Li , Rodrigo Siqueira Cc: Arnd Bergmann , Alex Deucher , =?UTF-8?q?Christian=20K=C3=B6nig?= , "Pan, Xinhui" , David Airlie , Daniel Vetter , Dillon Varone , Alex Hung , Chaitanya Dhere , Alvin Lee , Joshua Aberback , Charlene Liu , Mario Limonciello , Wenjing Liu , Aurabindo Pillai , amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Subject: [PATCH 3/4] drm/amd/display: avoid large on-stack structures Date: Tue, 28 May 2024 13:51:20 +0200 Message-Id: <20240528115146.2870032-3-arnd@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240528115146.2870032-1-arnd@kernel.org> References: <20240528115146.2870032-1-arnd@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Arnd Bergmann Putting excessively large objects on a function stack causes a warning about possibly overflowing the 8KiB of kernel stack: drivers/gpu/drm/amd/amdgpu/../display/dc/resource/dcn401/dcn401_resource.c: In function 'dcn401_update_bw_bounding_box': drivers/gpu/drm/amd/amdgpu/../display/dc/resource/dcn401/dcn401_resource.c:1599:1: error: the frame size of 1196 bytes is larger than 1024 bytes [-Werror=frame-larger-than=] 1599 | } | ^ 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:221:1: error: the frame size of 1196 bytes is larger than 1024 bytes [-Werror=frame-larger-than=] 221 | } | ^ Use dynamic allocation instead. Fixes: e779f4587f61 ("drm/amd/display: Add handling for DC power mode") Signed-off-by: Arnd Bergmann --- drivers/gpu/drm/amd/display/dc/core/dc_state.c | 16 +++++++++++----- .../display/dc/resource/dcn401/dcn401_resource.c | 16 +++++++++++----- 2 files changed, 22 insertions(+), 10 deletions(-) diff --git a/drivers/gpu/drm/amd/display/dc/core/dc_state.c b/drivers/gpu/drm/amd/display/dc/core/dc_state.c index 70928223b642..8ea9391c60b7 100644 --- a/drivers/gpu/drm/amd/display/dc/core/dc_state.c +++ b/drivers/gpu/drm/amd/display/dc/core/dc_state.c @@ -193,7 +193,11 @@ static void init_state(struct dc *dc, struct dc_state *state) struct dc_state *dc_state_create(struct dc *dc, struct dc_state_create_params *params) { #ifdef CONFIG_DRM_AMD_DC_FP - struct dml2_configuration_options dml2_opt = dc->dml2_options; + struct dml2_configuration_options *dml2_opt; + + dml2_opt = kmemdup(&dc->dml2_options, sizeof(*dml2_opt), GFP_KERNEL); + if (!dml2_opt) + return NULL; #endif struct dc_state *state = kvzalloc(sizeof(struct dc_state), GFP_KERNEL); @@ -207,12 +211,14 @@ struct dc_state *dc_state_create(struct dc *dc, struct dc_state_create_params *p #ifdef CONFIG_DRM_AMD_DC_FP if (dc->debug.using_dml2) { - dml2_opt.use_clock_dc_limits = false; - dml2_create(dc, &dml2_opt, &state->bw_ctx.dml2); + dml2_opt->use_clock_dc_limits = false; + dml2_create(dc, dml2_opt, &state->bw_ctx.dml2); - dml2_opt.use_clock_dc_limits = true; - dml2_create(dc, &dml2_opt, &state->bw_ctx.dml2_dc_power_source); + dml2_opt->use_clock_dc_limits = true; + dml2_create(dc, dml2_opt, &state->bw_ctx.dml2_dc_power_source); } + + kfree(dml2_opt); #endif kref_init(&state->refcount); diff --git a/drivers/gpu/drm/amd/display/dc/resource/dcn401/dcn401_resource.c b/drivers/gpu/drm/amd/display/dc/resource/dcn401/dcn401_resource.c index 247bac177d1b..8dfb0a3d21cb 100644 --- a/drivers/gpu/drm/amd/display/dc/resource/dcn401/dcn401_resource.c +++ b/drivers/gpu/drm/amd/display/dc/resource/dcn401/dcn401_resource.c @@ -1581,21 +1581,27 @@ static struct dc_cap_funcs cap_funcs = { static void dcn401_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(*dml2_opt), GFP_KERNEL); + if (!dml2_opt) + return; DC_FP_START(); dcn401_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); } enum dc_status dcn401_patch_unknown_plane_state(struct dc_plane_state *plane_state) -- 2.39.2