Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp1550797rwb; Thu, 15 Dec 2022 11:27:48 -0800 (PST) X-Google-Smtp-Source: AA0mqf6sL239KqtLxDY67moEbJkrs3RGPYfSpudtH3P8TFxwtZZEZpYdeMbBy9Tkw8ytULLUfHaB X-Received: by 2002:a17:907:9018:b0:7c0:e988:4157 with SMTP id ay24-20020a170907901800b007c0e9884157mr20406682ejc.40.1671132467853; Thu, 15 Dec 2022 11:27:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671132467; cv=none; d=google.com; s=arc-20160816; b=i5E0aE9mHX+uHWTVi4vnoEYT2qIJYNyQUMSgEFMFGf280pcirFtwm26jkeDs/qexI/ 6TocMJn7OA0YImbxz/kpGpC51vgyF2k0IJI6tdSJtgUuZ+4TkmFqX7zlewvjBwqcSH4c zpN6ZN/6XPxdASPVSE/Uoj/pNLSKf/ldPRA6keMsFc3caGGPKEyd6ge8gphpAr2bnzt5 ESu/b+OZ26KADe4yuNqcjpilv+pkRyriNeK2CQfWLHFIR6PEWm75E5vsPZrAYxY9HCsn l7O2hUanP6Z1H1MuSwQaUrApImKZ03cYptrOJUrll+ZciLsaExo74Q8yQslLSDxZI/Sk r0XQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=WEfPevdP7TJjnOIQtPsy+AcNppPJSiCKzyrt/O+WxJM=; b=Lfs5yH5ZgXUW2OJQn5YVi/Ir/7/EP9HFyOSdKpeU7zzjQKZUUT9etLtYyOcp7+O+WD HoYUrm7Eq262AUHJzlHTDmLtuOnF03gCmlR9HFnvX2KQKfl65wz+unpNLk+qrFGm6d42 kt1c9zaLDc/8RMTU+IzHkYpXaKVleeX7mqqNC+HYWz/jNPqlRF+pRQr29dmVUAeCeApf Wdn13lFgx1g8G3HCka1bxsMyGnNWJQvmCFlAzGAP5+NR47/NbR0jWlg1+QI3wCQiKopL mQMmi4LToXEr6j1mR8P1u0YSmkzNwt16M1riaYb6LzLt8iUQBEzeOboFfSwen78C5cEH kTXQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=j6kGh3yk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id gw9-20020a170906f14900b007c0ea5a7ca4si12147537ejb.858.2022.12.15.11.27.30; Thu, 15 Dec 2022 11:27:47 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=j6kGh3yk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229789AbiLOSp5 (ORCPT + 68 others); Thu, 15 Dec 2022 13:45:57 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40972 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230227AbiLOSpa (ORCPT ); Thu, 15 Dec 2022 13:45:30 -0500 Received: from mail-oa1-x33.google.com (mail-oa1-x33.google.com [IPv6:2001:4860:4864:20::33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 36F1527CD0 for ; Thu, 15 Dec 2022 10:45:29 -0800 (PST) Received: by mail-oa1-x33.google.com with SMTP id 586e51a60fabf-1433ef3b61fso369069fac.10 for ; Thu, 15 Dec 2022 10:45:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=WEfPevdP7TJjnOIQtPsy+AcNppPJSiCKzyrt/O+WxJM=; b=j6kGh3ykV4NImJgI7b18PBsKNjvgGeK3aR+cZp5W/GhzrtxBO4uxn9oFBS+5IJn7hC wDNGjiaLz1b7Rb9LOEtYldzbpWAwEENBtSkknMRlSYdwkgZ547nKZtuDweUyNOMNtYAx TFfkpCycfKp9sikmP2gSadcGfBzp4dsBms2+HZ/AM1FiG7hrZLZt4olXVuDyM8uFh2Z5 h7jkjX7L52UMfE2UCBQjC7vZfi66ulCitQ2yl1EoFvWj4xJe/06p1QRLzMXpbtfUUY2R psSQf5Kw5OQcgvWLswPDD+wUZNb4Oia5qqHjFN97IZuH2BOjDKQdtAXynDfNmD8oxxry Usww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=WEfPevdP7TJjnOIQtPsy+AcNppPJSiCKzyrt/O+WxJM=; b=1JJaHcbDj3Ca05v8ZAey2YIwUMhbCtJB1WMQyhea+sd9tojKH+c0tqztiuIucSlN/Y MUH8VBtqOlgancwvJAMMaV33wnLVRmeZWuoRfyyh762VMsEnnNpCS88EJUFxmt4tV7bO GFeeVxKjEM/259aIT25msGTEajyqgtZAOIQzrFGGBsYqU7f/2ehwJMeqEBMBoRwz3mlh KC7WSN3Ht31tfNJczoglFXhZr4aE9Z6DpM7/2x3NXoUaPDL7xW8T0NBIRcC4nri0XedI m6UZCNIThdCdrQeAPuQz8ZtaoJNnG00UJ0obwCqTY6+E8oT+k2VG8ErR4BT/fZD1JvTO mXNg== X-Gm-Message-State: AFqh2kpRjflcFMH/UjAHx9I1kT6C4dXFqUNd2lF8QXz+I1V/H7SIHtby uRApYynW8RMj7G6qdIFze1vDOEuuWh4XTEH3Dc0= X-Received: by 2002:a05:6870:8091:b0:148:3c8f:15ab with SMTP id q17-20020a056870809100b001483c8f15abmr360847oab.46.1671129928331; Thu, 15 Dec 2022 10:45:28 -0800 (PST) MIME-Version: 1.0 References: <20221215163649.386750-1-arnd@kernel.org> In-Reply-To: <20221215163649.386750-1-arnd@kernel.org> From: Alex Deucher Date: Thu, 15 Dec 2022 13:45:16 -0500 Message-ID: Subject: Re: [PATCH] drm/amd/pm: avoid large variable on kernel stack To: Arnd Bergmann Cc: Evan Quan , Alex Deucher , =?UTF-8?Q?Christian_K=C3=B6nig?= , "Pan, Xinhui" , Kenneth Feng , Yang Wang , Arnd Bergmann , Chengming Gui , Tom Rix , llvm@lists.linux.dev, Nick Desaulniers , linux-kernel@vger.kernel.org, amd-gfx@lists.freedesktop.org, Nathan Chancellor , dri-devel@lists.freedesktop.org, Hawking Zhang Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Applied. Thanks! Alex On Thu, Dec 15, 2022 at 11:37 AM Arnd Bergmann wrote: > > From: Arnd Bergmann > > The activity_monitor_external[] array is too big to fit on the > kernel stack, resulting in this warning with clang: > > drivers/gpu/drm/amd/amdgpu/../pm/swsmu/smu13/smu_v13_0_7_ppt.c:1438:12: error: stack frame size (1040) exceeds limit (1024) in 'smu_v13_0_7_get_power_profile_mode' [-Werror,-Wframe-larger-than] > > Use dynamic allocation instead. It should also be possible to > have single element here instead of the array, but this seems > easier. > > Fixes: 334682ae8151 ("drm/amd/pm: enable workload type change on smu_v13_0_7") > Signed-off-by: Arnd Bergmann > --- > .../drm/amd/pm/swsmu/smu13/smu_v13_0_7_ppt.c | 21 ++++++++++++++----- > 1 file changed, 16 insertions(+), 5 deletions(-) > > diff --git a/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_7_ppt.c b/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_7_ppt.c > index c270f94a1b86..7eba854e09ec 100644 > --- a/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_7_ppt.c > +++ b/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_7_ppt.c > @@ -1439,7 +1439,7 @@ static int smu_v13_0_7_get_power_limit(struct smu_context *smu, > > static int smu_v13_0_7_get_power_profile_mode(struct smu_context *smu, char *buf) > { > - DpmActivityMonitorCoeffIntExternal_t activity_monitor_external[PP_SMC_POWER_PROFILE_COUNT]; > + DpmActivityMonitorCoeffIntExternal_t *activity_monitor_external; > uint32_t i, j, size = 0; > int16_t workload_type = 0; > int result = 0; > @@ -1447,6 +1447,12 @@ static int smu_v13_0_7_get_power_profile_mode(struct smu_context *smu, char *buf > if (!buf) > return -EINVAL; > > + activity_monitor_external = kcalloc(sizeof(activity_monitor_external), > + PP_SMC_POWER_PROFILE_COUNT, > + GFP_KERNEL); > + if (!activity_monitor_external) > + return -ENOMEM; > + > size += sysfs_emit_at(buf, size, " "); > for (i = 0; i <= PP_SMC_POWER_PROFILE_WINDOW3D; i++) > size += sysfs_emit_at(buf, size, "%-14s%s", amdgpu_pp_profile_name[i], > @@ -1459,15 +1465,17 @@ static int smu_v13_0_7_get_power_profile_mode(struct smu_context *smu, char *buf > workload_type = smu_cmn_to_asic_specific_index(smu, > CMN2ASIC_MAPPING_WORKLOAD, > i); > - if (workload_type < 0) > - return -EINVAL; > + if (workload_type < 0) { > + result = -EINVAL; > + goto out; > + } > > result = smu_cmn_update_table(smu, > SMU_TABLE_ACTIVITY_MONITOR_COEFF, workload_type, > (void *)(&activity_monitor_external[i]), false); > if (result) { > dev_err(smu->adev->dev, "[%s] Failed to get activity monitor!", __func__); > - return result; > + goto out; > } > } > > @@ -1495,7 +1503,10 @@ do { \ > PRINT_DPM_MONITOR(Fclk_BoosterFreq); > #undef PRINT_DPM_MONITOR > > - return size; > + result = size; > +out: > + kfree(activity_monitor_external); > + return result; > } > > static int smu_v13_0_7_set_power_profile_mode(struct smu_context *smu, long *input, uint32_t size) > -- > 2.35.1 >