* [PATCH net 1/2] net/mlx5: make enable_mpesw idempotent
2025-12-01 15:13 [PATCH net 0/2] mlx5 misc fixes 2025-12-01 Tariq Toukan
@ 2025-12-01 15:13 ` Tariq Toukan
2025-12-02 15:23 ` Simon Horman
2025-12-01 15:13 ` [PATCH net 2/2] net/mlx5e: Avoid unregistering PSP twice Tariq Toukan
2025-12-04 11:00 ` [PATCH net 0/2] mlx5 misc fixes 2025-12-01 patchwork-bot+netdevbpf
2 siblings, 1 reply; 6+ messages in thread
From: Tariq Toukan @ 2025-12-01 15:13 UTC (permalink / raw)
To: Eric Dumazet, Jakub Kicinski, Paolo Abeni, Andrew Lunn,
David S. Miller
Cc: Saeed Mahameed, Tariq Toukan, Mark Bloch, Leon Romanovsky, netdev,
linux-rdma, linux-kernel, Gal Pressman, Moshe Shemesh
From: Moshe Shemesh <moshe@nvidia.com>
The enable_mpesw() function returns -EINVAL if ldev->mode is not
MLX5_LAG_MODE_NONE. This means attempting to enable MPESW mode when it's
already enabled will fail. In contrast, disable_mpesw() properly checks
if the mode is MLX5_LAG_MODE_MPESW before proceeding, making it
naturally idempotent and safe to call multiple times.
Fix enable_mpesw() to return success if mpesw is already enabled.
Fixes: a32327a3a02c ("net/mlx5: Lag, Control MultiPort E-Switch single FDB mode")
Signed-off-by: Moshe Shemesh <moshe@nvidia.com>
Reviewed-by: Shay Drori <shayd@nvidia.com>
Signed-off-by: Tariq Toukan <tariqt@nvidia.com>
---
drivers/net/ethernet/mellanox/mlx5/core/lag/mpesw.c | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/lag/mpesw.c b/drivers/net/ethernet/mellanox/mlx5/core/lag/mpesw.c
index aad52d3a90e6..2d86af8f0d9b 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/lag/mpesw.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/lag/mpesw.c
@@ -67,12 +67,19 @@ static int mlx5_mpesw_metadata_set(struct mlx5_lag *ldev)
static int enable_mpesw(struct mlx5_lag *ldev)
{
- int idx = mlx5_lag_get_dev_index_by_seq(ldev, MLX5_LAG_P1);
struct mlx5_core_dev *dev0;
int err;
+ int idx;
int i;
- if (idx < 0 || ldev->mode != MLX5_LAG_MODE_NONE)
+ if (ldev->mode == MLX5_LAG_MODE_MPESW)
+ return 0;
+
+ if (ldev->mode != MLX5_LAG_MODE_NONE)
+ return -EINVAL;
+
+ idx = mlx5_lag_get_dev_index_by_seq(ldev, MLX5_LAG_P1);
+ if (idx < 0)
return -EINVAL;
dev0 = ldev->pf[idx].dev;
--
2.31.1
^ permalink raw reply related [flat|nested] 6+ messages in thread* Re: [PATCH net 1/2] net/mlx5: make enable_mpesw idempotent
2025-12-01 15:13 ` [PATCH net 1/2] net/mlx5: make enable_mpesw idempotent Tariq Toukan
@ 2025-12-02 15:23 ` Simon Horman
0 siblings, 0 replies; 6+ messages in thread
From: Simon Horman @ 2025-12-02 15:23 UTC (permalink / raw)
To: Tariq Toukan
Cc: Eric Dumazet, Jakub Kicinski, Paolo Abeni, Andrew Lunn,
David S. Miller, Saeed Mahameed, Mark Bloch, Leon Romanovsky,
netdev, linux-rdma, linux-kernel, Gal Pressman, Moshe Shemesh
On Mon, Dec 01, 2025 at 05:13:27PM +0200, Tariq Toukan wrote:
> From: Moshe Shemesh <moshe@nvidia.com>
>
> The enable_mpesw() function returns -EINVAL if ldev->mode is not
> MLX5_LAG_MODE_NONE. This means attempting to enable MPESW mode when it's
> already enabled will fail. In contrast, disable_mpesw() properly checks
> if the mode is MLX5_LAG_MODE_MPESW before proceeding, making it
> naturally idempotent and safe to call multiple times.
>
> Fix enable_mpesw() to return success if mpesw is already enabled.
>
> Fixes: a32327a3a02c ("net/mlx5: Lag, Control MultiPort E-Switch single FDB mode")
> Signed-off-by: Moshe Shemesh <moshe@nvidia.com>
> Reviewed-by: Shay Drori <shayd@nvidia.com>
> Signed-off-by: Tariq Toukan <tariqt@nvidia.com>
Reviewed-by: Simon Horman <horms@kernel.org>
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH net 2/2] net/mlx5e: Avoid unregistering PSP twice
2025-12-01 15:13 [PATCH net 0/2] mlx5 misc fixes 2025-12-01 Tariq Toukan
2025-12-01 15:13 ` [PATCH net 1/2] net/mlx5: make enable_mpesw idempotent Tariq Toukan
@ 2025-12-01 15:13 ` Tariq Toukan
2025-12-02 15:24 ` Simon Horman
2025-12-04 11:00 ` [PATCH net 0/2] mlx5 misc fixes 2025-12-01 patchwork-bot+netdevbpf
2 siblings, 1 reply; 6+ messages in thread
From: Tariq Toukan @ 2025-12-01 15:13 UTC (permalink / raw)
To: Eric Dumazet, Jakub Kicinski, Paolo Abeni, Andrew Lunn,
David S. Miller
Cc: Saeed Mahameed, Tariq Toukan, Mark Bloch, Leon Romanovsky, netdev,
linux-rdma, linux-kernel, Gal Pressman, Moshe Shemesh,
Cosmin Ratiu
From: Cosmin Ratiu <cratiu@nvidia.com>
PSP is unregistered twice in:
_mlx5e_remove -> mlx5e_psp_unregister
mlx5e_nic_cleanup -> mlx5e_psp_unregister
This leads to a refcount underflow in some conditions:
------------[ cut here ]------------
refcount_t: underflow; use-after-free.
WARNING: CPU: 2 PID: 1694 at lib/refcount.c:28 refcount_warn_saturate+0xd8/0xe0
[...]
mlx5e_psp_unregister+0x26/0x50 [mlx5_core]
mlx5e_nic_cleanup+0x26/0x90 [mlx5_core]
mlx5e_remove+0xe6/0x1f0 [mlx5_core]
auxiliary_bus_remove+0x18/0x30
device_release_driver_internal+0x194/0x1f0
bus_remove_device+0xc6/0x130
device_del+0x159/0x3c0
mlx5_rescan_drivers_locked+0xbc/0x2a0 [mlx5_core]
[...]
Do not directly remove psp from the _mlx5e_remove path, the PSP cleanup
happens as part of profile cleanup.
Fixes: 89ee2d92f66c ("net/mlx5e: Support PSP offload functionality")
Signed-off-by: Cosmin Ratiu <cratiu@nvidia.com>
Reviewed-by: Dragos Tatulea <dtatulea@nvidia.com>
Signed-off-by: Tariq Toukan <tariqt@nvidia.com>
---
drivers/net/ethernet/mellanox/mlx5/core/en_main.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
index 5e17eae81f4b..1545f9c008f4 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
@@ -6805,7 +6805,6 @@ static void _mlx5e_remove(struct auxiliary_device *adev)
* is already unregistered before changing to NIC profile.
*/
if (priv->netdev->reg_state == NETREG_REGISTERED) {
- mlx5e_psp_unregister(priv);
unregister_netdev(priv->netdev);
_mlx5e_suspend(adev, false);
} else {
--
2.31.1
^ permalink raw reply related [flat|nested] 6+ messages in thread* Re: [PATCH net 2/2] net/mlx5e: Avoid unregistering PSP twice
2025-12-01 15:13 ` [PATCH net 2/2] net/mlx5e: Avoid unregistering PSP twice Tariq Toukan
@ 2025-12-02 15:24 ` Simon Horman
0 siblings, 0 replies; 6+ messages in thread
From: Simon Horman @ 2025-12-02 15:24 UTC (permalink / raw)
To: Tariq Toukan
Cc: Eric Dumazet, Jakub Kicinski, Paolo Abeni, Andrew Lunn,
David S. Miller, Saeed Mahameed, Mark Bloch, Leon Romanovsky,
netdev, linux-rdma, linux-kernel, Gal Pressman, Moshe Shemesh,
Cosmin Ratiu
On Mon, Dec 01, 2025 at 05:13:28PM +0200, Tariq Toukan wrote:
> From: Cosmin Ratiu <cratiu@nvidia.com>
>
> PSP is unregistered twice in:
> _mlx5e_remove -> mlx5e_psp_unregister
> mlx5e_nic_cleanup -> mlx5e_psp_unregister
>
> This leads to a refcount underflow in some conditions:
> ------------[ cut here ]------------
> refcount_t: underflow; use-after-free.
> WARNING: CPU: 2 PID: 1694 at lib/refcount.c:28 refcount_warn_saturate+0xd8/0xe0
> [...]
> mlx5e_psp_unregister+0x26/0x50 [mlx5_core]
> mlx5e_nic_cleanup+0x26/0x90 [mlx5_core]
> mlx5e_remove+0xe6/0x1f0 [mlx5_core]
> auxiliary_bus_remove+0x18/0x30
> device_release_driver_internal+0x194/0x1f0
> bus_remove_device+0xc6/0x130
> device_del+0x159/0x3c0
> mlx5_rescan_drivers_locked+0xbc/0x2a0 [mlx5_core]
> [...]
>
> Do not directly remove psp from the _mlx5e_remove path, the PSP cleanup
> happens as part of profile cleanup.
>
> Fixes: 89ee2d92f66c ("net/mlx5e: Support PSP offload functionality")
> Signed-off-by: Cosmin Ratiu <cratiu@nvidia.com>
> Reviewed-by: Dragos Tatulea <dtatulea@nvidia.com>
> Signed-off-by: Tariq Toukan <tariqt@nvidia.com>
Reviewed-by: Simon Horman <horms@kernel.org>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH net 0/2] mlx5 misc fixes 2025-12-01
2025-12-01 15:13 [PATCH net 0/2] mlx5 misc fixes 2025-12-01 Tariq Toukan
2025-12-01 15:13 ` [PATCH net 1/2] net/mlx5: make enable_mpesw idempotent Tariq Toukan
2025-12-01 15:13 ` [PATCH net 2/2] net/mlx5e: Avoid unregistering PSP twice Tariq Toukan
@ 2025-12-04 11:00 ` patchwork-bot+netdevbpf
2 siblings, 0 replies; 6+ messages in thread
From: patchwork-bot+netdevbpf @ 2025-12-04 11:00 UTC (permalink / raw)
To: Tariq Toukan
Cc: edumazet, kuba, pabeni, andrew+netdev, davem, saeedm, mbloch,
leon, netdev, linux-rdma, linux-kernel, gal, moshe
Hello:
This series was applied to netdev/net.git (main)
by Paolo Abeni <pabeni@redhat.com>:
On Mon, 1 Dec 2025 17:13:26 +0200 you wrote:
> Hi,
>
> This small patchset provides misc bug fixes from the team to the mlx5
> core and Eth drivers.
>
> Thanks,
> Tariq.
>
> [...]
Here is the summary with links:
- [net,1/2] net/mlx5: make enable_mpesw idempotent
https://git.kernel.org/netdev/net/c/cd7671ef4cf2
- [net,2/2] net/mlx5e: Avoid unregistering PSP twice
https://git.kernel.org/netdev/net/c/35e93736f699
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 6+ messages in thread