Blame SOURCES/0008-netdrv-net-mlx5e-xsk-dynamically-allocate-mlx5e_chan.patch

d8f823
From bd1ba9688ed45fe25f151e33657b2c50c0b4f424 Mon Sep 17 00:00:00 2001
d8f823
From: Alaa Hleihel <ahleihel@redhat.com>
d8f823
Date: Sun, 10 May 2020 14:51:25 -0400
d8f823
Subject: [PATCH 008/312] [netdrv] net/mlx5e: xsk: dynamically allocate
d8f823
 mlx5e_channel_param
d8f823
d8f823
Message-id: <20200510145245.10054-3-ahleihel@redhat.com>
d8f823
Patchwork-id: 306542
d8f823
Patchwork-instance: patchwork
d8f823
O-Subject: [RHEL8.3 BZ 1789378 v2 02/82] net/mlx5e: xsk: dynamically allocate mlx5e_channel_param
d8f823
Bugzilla: 1789378
d8f823
RH-Acked-by: Kamal Heib <kheib@redhat.com>
d8f823
RH-Acked-by: Jarod Wilson <jarod@redhat.com>
d8f823
RH-Acked-by: Tony Camuso <tcamuso@redhat.com>
d8f823
RH-Acked-by: Jonathan Toppins <jtoppins@redhat.com>
d8f823
d8f823
Bugzilla: http://bugzilla.redhat.com/1789378
d8f823
Upstream: v5.4-rc1
d8f823
d8f823
commit 658688ce6c936254c34ea1f31549ec62439574aa
d8f823
Author: Arnd Bergmann <arnd@arndb.de>
d8f823
Date:   Tue Jul 23 12:02:26 2019 +0000
d8f823
d8f823
    net/mlx5e: xsk: dynamically allocate mlx5e_channel_param
d8f823
d8f823
    The structure is too large to put on the stack, resulting in a
d8f823
    warning on 32-bit ARM:
d8f823
d8f823
    drivers/net/ethernet/mellanox/mlx5/core/en/xsk/setup.c:59:5: error: stack frame size of 1344 bytes in function
d8f823
          'mlx5e_open_xsk' [-Werror,-Wframe-larger-than=]
d8f823
d8f823
    Use kvzalloc() instead.
d8f823
d8f823
    Fixes: a038e9794541 ("net/mlx5e: Add XSK zero-copy support")
d8f823
    Signed-off-by: Arnd Bergmann <arnd@arndb.de>
d8f823
    Signed-off-by: Maxim Mikityanskiy <maximmi@mellanox.com>
d8f823
    Signed-off-by: David S. Miller <davem@davemloft.net>
d8f823
d8f823
Signed-off-by: Alaa Hleihel <ahleihel@redhat.com>
d8f823
Signed-off-by: Frantisek Hrbata <fhrbata@redhat.com>
d8f823
---
d8f823
 .../net/ethernet/mellanox/mlx5/core/en/xsk/setup.c | 27 ++++++++++++++--------
d8f823
 1 file changed, 18 insertions(+), 9 deletions(-)
d8f823
d8f823
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/xsk/setup.c b/drivers/net/ethernet/mellanox/mlx5/core/en/xsk/setup.c
d8f823
index 81efd2fbc75d..79060ee60c98 100644
d8f823
--- a/drivers/net/ethernet/mellanox/mlx5/core/en/xsk/setup.c
d8f823
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en/xsk/setup.c
d8f823
@@ -65,24 +65,28 @@ int mlx5e_open_xsk(struct mlx5e_priv *priv, struct mlx5e_params *params,
d8f823
 		   struct mlx5e_xsk_param *xsk, struct xdp_umem *umem,
d8f823
 		   struct mlx5e_channel *c)
d8f823
 {
d8f823
-	struct mlx5e_channel_param cparam = {};
d8f823
+	struct mlx5e_channel_param *cparam;
d8f823
 	struct dim_cq_moder icocq_moder = {};
d8f823
 	int err;
d8f823
 
d8f823
 	if (!mlx5e_validate_xsk_param(params, xsk, priv->mdev))
d8f823
 		return -EINVAL;
d8f823
 
d8f823
-	mlx5e_build_xsk_cparam(priv, params, xsk, &cparam);
d8f823
+	cparam = kvzalloc(sizeof(*cparam), GFP_KERNEL);
d8f823
+	if (!cparam)
d8f823
+		return -ENOMEM;
d8f823
 
d8f823
-	err = mlx5e_open_cq(c, params->rx_cq_moderation, &cparam.rx_cq, &c->xskrq.cq);
d8f823
+	mlx5e_build_xsk_cparam(priv, params, xsk, cparam);
d8f823
+
d8f823
+	err = mlx5e_open_cq(c, params->rx_cq_moderation, &cparam->rx_cq, &c->xskrq.cq);
d8f823
 	if (unlikely(err))
d8f823
-		return err;
d8f823
+		goto err_free_cparam;
d8f823
 
d8f823
-	err = mlx5e_open_rq(c, params, &cparam.rq, xsk, umem, &c->xskrq);
d8f823
+	err = mlx5e_open_rq(c, params, &cparam->rq, xsk, umem, &c->xskrq);
d8f823
 	if (unlikely(err))
d8f823
 		goto err_close_rx_cq;
d8f823
 
d8f823
-	err = mlx5e_open_cq(c, params->tx_cq_moderation, &cparam.tx_cq, &c->xsksq.cq);
d8f823
+	err = mlx5e_open_cq(c, params->tx_cq_moderation, &cparam->tx_cq, &c->xsksq.cq);
d8f823
 	if (unlikely(err))
d8f823
 		goto err_close_rq;
d8f823
 
d8f823
@@ -92,21 +96,23 @@ int mlx5e_open_xsk(struct mlx5e_priv *priv, struct mlx5e_params *params,
d8f823
 	 * is disabled and then reenabled, but the SQ continues receiving CQEs
d8f823
 	 * from the old UMEM.
d8f823
 	 */
d8f823
-	err = mlx5e_open_xdpsq(c, params, &cparam.xdp_sq, umem, &c->xsksq, true);
d8f823
+	err = mlx5e_open_xdpsq(c, params, &cparam->xdp_sq, umem, &c->xsksq, true);
d8f823
 	if (unlikely(err))
d8f823
 		goto err_close_tx_cq;
d8f823
 
d8f823
-	err = mlx5e_open_cq(c, icocq_moder, &cparam.icosq_cq, &c->xskicosq.cq);
d8f823
+	err = mlx5e_open_cq(c, icocq_moder, &cparam->icosq_cq, &c->xskicosq.cq);
d8f823
 	if (unlikely(err))
d8f823
 		goto err_close_sq;
d8f823
 
d8f823
 	/* Create a dedicated SQ for posting NOPs whenever we need an IRQ to be
d8f823
 	 * triggered and NAPI to be called on the correct CPU.
d8f823
 	 */
d8f823
-	err = mlx5e_open_icosq(c, params, &cparam.icosq, &c->xskicosq);
d8f823
+	err = mlx5e_open_icosq(c, params, &cparam->icosq, &c->xskicosq);
d8f823
 	if (unlikely(err))
d8f823
 		goto err_close_icocq;
d8f823
 
d8f823
+	kvfree(cparam);
d8f823
+
d8f823
 	spin_lock_init(&c->xskicosq_lock);
d8f823
 
d8f823
 	set_bit(MLX5E_CHANNEL_STATE_XSK, c->state);
d8f823
@@ -128,6 +134,9 @@ int mlx5e_open_xsk(struct mlx5e_priv *priv, struct mlx5e_params *params,
d8f823
 err_close_rx_cq:
d8f823
 	mlx5e_close_cq(&c->xskrq.cq);
d8f823
 
d8f823
+err_free_cparam:
d8f823
+	kvfree(cparam);
d8f823
+
d8f823
 	return err;
d8f823
 }
d8f823
 
d8f823
-- 
d8f823
2.13.6
d8f823