mlx5 misc fixes 2025-12-01
Subsystems (5)
Tariq Toukan
maintainercover mlx5 misc fixes 2025-12-01
Hi,
This small patchset provides misc bug fixes from the team to the mlx5 core and Eth drivers.
Thanks,
Tariq.
Cosmin Ratiu (1):
net/mlx5e: Avoid unregistering PSP twice
Moshe Shemesh (1):
net/mlx5: make enable_mpesw idempotent
drivers/net/ethernet/mellanox/mlx5/core/en_main.c | 1 - drivers/net/ethernet/mellanox/mlx5/core/lag/mpesw.c | 11 +++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-)
base-commit: e5235eb6cfe02a51256013a78f7b28779a7740d5
Signature · 1 line
2.31.1
Tariq Toukan
maintainerPATCH 1/2 net/mlx5: make enable_mpesw idempotent
From: Moshe Shemesh <[email protected]>
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.
--- drivers/net/ethernet/mellanox/mlx5/core/lag/mpesw.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/lag/mpesw.c +9 -2
@@ -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;
Signature · 1 line
2.31.1
Re: [PATCH net 1/2] net/mlx5: make enable_mpesw idempotent
Quoted 8 lines · Tariq Toukan
From: Moshe Shemesh <[email protected]>
The
enable_mpesw()function returns-EINVALifldev->modeis notMLX5_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 isMLX5_LAG_MODE_MPESWbefore proceeding, making it naturally idempotent and safe to call multiple times.
Quoted 6 lines
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 <[email protected]>Reviewed-by Shay Drori <[email protected]>Signed-off-by Tariq Toukan <[email protected]>
Tariq Toukan
maintainerPATCH 2/2 net/mlx5e: Avoid unregistering PSP twice
In reply to Tariq ToukanFrom: Cosmin Ratiu <[email protected]>
PSP is unregistered twice in:_mlx5e_remove -> mlx5e_psp_unregistermlx5e_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.
--- drivers/net/ethernet/mellanox/mlx5/core/en_main.c | 1 - 1 file changed, 1 deletion(-)
drivers/net/ethernet/mellanox/mlx5/core/en_main.c +0 -1
@@ -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 {
Signature · 1 line
2.31.1
Re: [PATCH net 2/2] net/mlx5e: Avoid unregistering PSP twice
Quoted 21 lines · Tariq Toukan
From: Cosmin Ratiu <[email protected]>
PSP is unregistered twice in:
_mlx5e_remove->mlx5e_psp_unregistermlx5e_nic_cleanup->mlx5e_psp_unregisterThis 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][...]
Quoted 7 lines
Do not directly remove psp from the
_mlx5e_removepath, the PSP cleanup happens as part of profile cleanup.Fixes 89ee2d92f66c ("net/mlx5e: Support PSP offload functionality")Signed-off-by Cosmin Ratiu <[email protected]>Reviewed-by Dragos Tatulea <[email protected]>Signed-off-by Tariq Toukan <[email protected]>
This series was applied to netdev/net.git (main) by Paolo Abeni <[email protected]>:
Hello:
This series was applied to netdev/net.git (main)
by Paolo Abeni <[email protected]>:
Quoted 9 lines · 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!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html