Commit 78028862 authored by Arnd Bergmann's avatar Arnd Bergmann Committed by Saeed Mahameed

mlx5: reduce stack usage in mlx5_setup_tc

Clang warns about excessive stack usage on 32-bit targets:

drivers/net/ethernet/mellanox/mlx5/core/en_main.c:3597:12: error: stack frame size (1184) exceeds limit (1024) in 'mlx5e_setup_tc' [-Werror,-Wframe-larger-than]
static int mlx5e_setup_tc(struct net_device *dev, enum tc_setup_type type,

It turns out that both the mlx5e_setup_tc_mqprio_dcb() function and
the mlx5e_safe_switch_params() function it calls have a copy of
'struct mlx5e_params' on the stack, and this structure is fairly
large.

Use dynamic allocation for the inner one.
Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
Reviewed-by: default avatarJacob Keller <jacob.e.keller@intel.com>
Reviewed-by: default avatarTariq Toukan <tariqt@nvidia.com>
Signed-off-by: default avatarSaeed Mahameed <saeedm@nvidia.com>
parent 383d9f87
...@@ -3002,32 +3002,37 @@ int mlx5e_safe_switch_params(struct mlx5e_priv *priv, ...@@ -3002,32 +3002,37 @@ int mlx5e_safe_switch_params(struct mlx5e_priv *priv,
mlx5e_fp_preactivate preactivate, mlx5e_fp_preactivate preactivate,
void *context, bool reset) void *context, bool reset)
{ {
struct mlx5e_channels new_chs = {}; struct mlx5e_channels *new_chs;
int err; int err;
reset &= test_bit(MLX5E_STATE_OPENED, &priv->state); reset &= test_bit(MLX5E_STATE_OPENED, &priv->state);
if (!reset) if (!reset)
return mlx5e_switch_priv_params(priv, params, preactivate, context); return mlx5e_switch_priv_params(priv, params, preactivate, context);
new_chs.params = *params; new_chs = kzalloc(sizeof(*new_chs), GFP_KERNEL);
if (!new_chs)
return -ENOMEM;
new_chs->params = *params;
mlx5e_selq_prepare_params(&priv->selq, &new_chs.params); mlx5e_selq_prepare_params(&priv->selq, &new_chs->params);
err = mlx5e_open_channels(priv, &new_chs); err = mlx5e_open_channels(priv, new_chs);
if (err) if (err)
goto err_cancel_selq; goto err_cancel_selq;
err = mlx5e_switch_priv_channels(priv, &new_chs, preactivate, context); err = mlx5e_switch_priv_channels(priv, new_chs, preactivate, context);
if (err) if (err)
goto err_close; goto err_close;
kfree(new_chs);
return 0; return 0;
err_close: err_close:
mlx5e_close_channels(&new_chs); mlx5e_close_channels(new_chs);
err_cancel_selq: err_cancel_selq:
mlx5e_selq_cancel(&priv->selq); mlx5e_selq_cancel(&priv->selq);
kfree(new_chs);
return err; return err;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment