From patchwork Mon Mar 8 15:32:57 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 395442 Delivered-To: patch@linaro.org Received: by 2002:a02:8562:0:0:0:0:0 with SMTP id g89csp1809031jai; Mon, 8 Mar 2021 07:34:06 -0800 (PST) X-Google-Smtp-Source: ABdhPJz0UeJtPoMK0sq/YP+/TcSNjRvZHkTS+oPct54IvgmRj6g+OUG1I3QHDOhOMYuVT9fUIKqt X-Received: by 2002:a17:906:ecfb:: with SMTP id qt27mr15176299ejb.245.1615217645952; Mon, 08 Mar 2021 07:34:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1615217645; cv=none; d=google.com; s=arc-20160816; b=Mdth44qzo2pv+97MVB7ZGnVkYnn0DX7K8Ymyzr3kCyw/SmzIz9wmKNZcPBNTKmpD82 RQQZHaHNS/rcAg2IdzGZv0O5A3O3lsHY4QZLKEyMi9PpIZbHjgemWZBwzUfeiAtXDgNn EA0wq0BcDw6KYzVxMFeuv5aN+N8jXhxp/nX0jLDD7i6rBa7HJ8MbS6OpOsVkJhT6pdUQ JvQzqc2xVzng/t3ruIXzeBQYDNviK2wPO75/n363tfx8UZzY5K/ASBdXYedH1d4MPXq4 VDtdYiMOHad1neqa4OASP4MUY2mYJBOJTJt2fttUJyJYcK2Gs2l1jUIVV3p97Ze7jaPr vf3g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=SePTOUIaft+zg1MNYoy4Xc//qwPIW8fEP7yX5DwQZLU=; b=HlgiISY8++M3MkF/g6FG44E9Gsh22GWYLZy5XwIB7UgxodcY0Qkh15vN8eyipeHEEw IbUgrrkzMW604UCDY8H2+DtM/jKgtsmi8X8AMpIdlMvRsIxQ5kyM4GZcDec63b4dcpiE pfysXrH47LjVIjL2yvtxibCF6Z3XhnSX2Xo+nf7MObjk270xrFExK5cOPNaRmp2SENan kl1Uks6keVxzu/OwrofpyDs1n/jwdhw+neEhCVhadW7m9cmG+yT5HrWAXDhiwIaPMNBT qc7LlL+Zo4z/idypKTAIKEAB77Qe48lBwANDgpy5YMS05BSs2Wy8UC3R4RWu7y1MZY4M 5IYA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=q7OA0wqv; spf=pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id de4si6680610ejc.539.2021.03.08.07.34.05; Mon, 08 Mar 2021 07:34:05 -0800 (PST) Received-SPF: pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=q7OA0wqv; spf=pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230425AbhCHPde (ORCPT + 9 others); Mon, 8 Mar 2021 10:33:34 -0500 Received: from mail.kernel.org ([198.145.29.99]:60680 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230150AbhCHPdZ (ORCPT ); Mon, 8 Mar 2021 10:33:25 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id F28D56526A; Mon, 8 Mar 2021 15:33:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1615217604; bh=UdgGpH5wigD4IDua1jI0Goj5nN066h+PRHihFx2waQY=; h=From:To:Cc:Subject:Date:From; b=q7OA0wqvAqQ/DPTVQ5yPBYKh3QOKEgYVJc/zfgupO+rvPAuhdHTnzdGOnmt73HJQ3 gS2efyZ2zIvJ3j+fpB+2AHpFYtAQbntLL3hOh+h3RhjsuJEtycG5+8YqTOJ4SOVzZZ OfMJIOVDHXR38lFFE2hYCizVE53huLTBgO2KEkrkWnbad/CWlcXxifwSXwijz4xI/d J3b6Htz08n43ghbK3pmUnnAMwX0g3MoXSEbryI7Ex3BffKRY6Sb0oYKXzpjaxEB1G8 1CVf/xYxuG8bDYhFcOJhKsEdXho9ka58QwILGAwT+EBRVMUUDmDofr/P0nh+UCy6kt ix8JOz166XrxA== From: Arnd Bergmann To: Saeed Mahameed , Leon Romanovsky , "David S. Miller" , Jakub Kicinski , Tariq Toukan , Noam Stolero , Tal Gilboa Cc: Arnd Bergmann , Nathan Chancellor , Nick Desaulniers , Roi Dayan , Vlad Buslov , Paul Blakey , Oz Shlomo , Eli Cohen , Ariel Levkovich , Maor Dickman , Tariq Toukan , netdev@vger.kernel.org, linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org, clang-built-linux@googlegroups.com Subject: [PATCH] net/mlx5e: allocate 'indirection_rqt' buffer dynamically Date: Mon, 8 Mar 2021 16:32:57 +0100 Message-Id: <20210308153318.2486939-1-arnd@kernel.org> X-Mailer: git-send-email 2.29.2 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Arnd Bergmann Increasing the size of the indirection_rqt array from 128 to 256 bytes pushed the stack usage of the mlx5e_hairpin_fill_rqt_rqns() function over the warning limit when building with clang and CONFIG_KASAN: drivers/net/ethernet/mellanox/mlx5/core/en_tc.c:970:1: error: stack frame size of 1180 bytes in function 'mlx5e_tc_add_nic_flow' [-Werror,-Wframe-larger-than=] Using dynamic allocation here is safe because the caller does the same, and it reduces the stack usage of the function to just a few bytes. Fixes: 1dd55ba2fb70 ("net/mlx5e: Increase indirection RQ table size to 256") Signed-off-by: Arnd Bergmann --- drivers/net/ethernet/mellanox/mlx5/core/en_tc.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) -- 2.29.2 Reviewed-by: Tariq Toukan diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c index 0da69b98f38f..66f98618dc13 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c @@ -445,12 +445,16 @@ static void mlx5e_hairpin_destroy_transport(struct mlx5e_hairpin *hp) mlx5_core_dealloc_transport_domain(hp->func_mdev, hp->tdn); } -static void mlx5e_hairpin_fill_rqt_rqns(struct mlx5e_hairpin *hp, void *rqtc) +static int mlx5e_hairpin_fill_rqt_rqns(struct mlx5e_hairpin *hp, void *rqtc) { - u32 indirection_rqt[MLX5E_INDIR_RQT_SIZE], rqn; + u32 *indirection_rqt, rqn; struct mlx5e_priv *priv = hp->func_priv; int i, ix, sz = MLX5E_INDIR_RQT_SIZE; + indirection_rqt = kzalloc(sz, GFP_KERNEL); + if (!indirection_rqt) + return -ENOMEM; + mlx5e_build_default_indir_rqt(indirection_rqt, sz, hp->num_channels); @@ -462,6 +466,9 @@ static void mlx5e_hairpin_fill_rqt_rqns(struct mlx5e_hairpin *hp, void *rqtc) rqn = hp->pair->rqn[ix]; MLX5_SET(rqtc, rqtc, rq_num[i], rqn); } + + kfree(indirection_rqt); + return 0; } static int mlx5e_hairpin_create_indirect_rqt(struct mlx5e_hairpin *hp) @@ -482,12 +489,15 @@ static int mlx5e_hairpin_create_indirect_rqt(struct mlx5e_hairpin *hp) MLX5_SET(rqtc, rqtc, rqt_actual_size, sz); MLX5_SET(rqtc, rqtc, rqt_max_size, sz); - mlx5e_hairpin_fill_rqt_rqns(hp, rqtc); + err = mlx5e_hairpin_fill_rqt_rqns(hp, rqtc); + if (err) + goto out; err = mlx5_core_create_rqt(mdev, in, inlen, &hp->indir_rqt.rqtn); if (!err) hp->indir_rqt.enabled = true; +out: kvfree(in); return err; }