mlx5 misc fixes 2026-02-24
Subsystems (5)
Tariq Toukan
maintainercover mlx5 misc fixes 2026-02-24
Hi,
This patchset provides misc bug fixes from the team to the mlx5 core and Eth drivers.
Thanks,
Tariq.
Jianbo Liu (1):
net/mlx5e: Fix "scheduling while atomic" in IPsec MAC address query
Shay Drory (4):
net/mlx5: DR, Fix circular locking dependency in dump net/mlx5: LAG, disable MPESW in lag_disable_change() net/mlx5: E-switch, Clear legacy flag when moving to switchdev net/mlx5: Fix missing devlink lock in SRIOV enable error path
drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec.c | 3 +-- .../net/ethernet/mellanox/mlx5/core/eswitch_offloads.c | 2 ++ drivers/net/ethernet/mellanox/mlx5/core/lag/lag.c | 8 ++++++-- drivers/net/ethernet/mellanox/mlx5/core/lag/mpesw.c | 8 ++++---- drivers/net/ethernet/mellanox/mlx5/core/lag/mpesw.h | 5 +++++ drivers/net/ethernet/mellanox/mlx5/core/sriov.c | 2 ++ .../net/ethernet/mellanox/mlx5/core/steering/sws/dr_dbg.c | 4 ++-- 7 files changed, 22 insertions(+), 10 deletions(-)
base-commit: 82aec772fca2223bc5774bd9af486fd95766e578
Signature · 1 line
2.44.0
Tariq Toukan
maintainerPATCH 1/5 net/mlx5: DR, Fix circular locking dependency in dump
From: Shay Drory <[email protected]>
Fix a circular locking dependency between dbg_mutex and the domain rx/tx mutexes that could lead to a deadlock.
The dump path in dr_dump_domain_all() was acquiring locks in the order:
dbg_mutex -> rx.mutex -> tx.mutex
While the table/matcher creation paths acquire locks in the order:
rx.mutex -> tx.mutex -> dbg_mutex
This inverted lock ordering creates a circular dependency. Fix this by changing dr_dump_domain_all() to acquire the domain lock before dbg_mutex, matching the order used in mlx5dr_table_create() and mlx5dr_matcher_create().
Lockdep splat:
======================================================
WARNING: possible circular locking dependency detected 6.19.0-rc6net_next_e817c4e #1 Not tainted
------------------------------------------------------
sos/30721 is trying to acquire lock:
ffff888102df5900 (&dmn->info.rx.mutex){+.+.}-{4:4}, at:dr_dump_start+0x131/0x450 [mlx5_core]
but task is already holding lock:
ffff888102df5bc0 (&dmn->dump_info.dbg_mutex){+.+.}-{4:4}, at:dr_dump_start+0x10b/0x450 [mlx5_core]
which lock already depends on the new lock.
the existing dependency chain (in reverse order) is:
-> #2 (&dmn->dump_info.dbg_mutex){+.+.}-{4:4}:
__mutex_lock+0x91/0x1060
mlx5dr_matcher_create+0x377/0x5e0 [mlx5_core]
mlx5_cmd_dr_create_flow_group+0x62/0xd0 [mlx5_core]
mlx5_create_flow_group+0x113/0x1c0 [mlx5_core]
mlx5_chains_create_prio+0x453/0x2290 [mlx5_core]
mlx5_chains_get_table+0x2e2/0x980 [mlx5_core]
esw_chains_create+0x1e6/0x3b0 [mlx5_core]
esw_create_offloads_fdb_tables.cold+0x62/0x63f [mlx5_core]
esw_offloads_enable+0x76f/0xd20 [mlx5_core]
mlx5_eswitch_enable_locked+0x35a/0x500 [mlx5_core]
mlx5_devlink_eswitch_mode_set+0x561/0x950 [mlx5_core]
devlink_nl_eswitch_set_doit+0x67/0xe0
genl_family_rcv_msg_doit+0xe0/0x130
genl_rcv_msg+0x188/0x290
netlink_rcv_skb+0x4b/0xf0
genl_rcv+0x24/0x40
netlink_unicast+0x1ed/0x2c0
netlink_sendmsg+0x210/0x450
__sock_sendmsg+0x38/0x60
__sys_sendto+0x119/0x180
__x64_sys_sendto+0x20/0x30
do_syscall_64+0x70/0xd00
entry_SYSCALL_64_after_hwframe+0x4b/0x53-> #1 (&dmn->info.tx.mutex){+.+.}-{4:4}:
__mutex_lock+0x91/0x1060
mlx5dr_table_create+0x11d/0x530 [mlx5_core]
mlx5_cmd_dr_create_flow_table+0x62/0x140 [mlx5_core]
__mlx5_create_flow_table+0x46f/0x960 [mlx5_core]
mlx5_create_flow_table+0x16/0x20 [mlx5_core]
esw_create_offloads_fdb_tables+0x136/0x240 [mlx5_core]
esw_offloads_enable+0x76f/0xd20 [mlx5_core]
mlx5_eswitch_enable_locked+0x35a/0x500 [mlx5_core]
mlx5_devlink_eswitch_mode_set+0x561/0x950 [mlx5_core]
devlink_nl_eswitch_set_doit+0x67/0xe0
genl_family_rcv_msg_doit+0xe0/0x130
genl_rcv_msg+0x188/0x290
netlink_rcv_skb+0x4b/0xf0
genl_rcv+0x24/0x40
netlink_unicast+0x1ed/0x2c0
netlink_sendmsg+0x210/0x450
__sock_sendmsg+0x38/0x60
__sys_sendto+0x119/0x180
__x64_sys_sendto+0x20/0x30
do_syscall_64+0x70/0xd00
entry_SYSCALL_64_after_hwframe+0x4b/0x53-> #0 (&dmn->info.rx.mutex){+.+.}-{4:4}:
__lock_acquire+0x18b6/0x2eb0
lock_acquire+0xd3/0x2c0
__mutex_lock+0x91/0x1060
dr_dump_start+0x131/0x450 [mlx5_core]
seq_read_iter+0xe3/0x410
seq_read+0xfb/0x130
full_proxy_read+0x53/0x80
vfs_read+0xba/0x330
ksys_read+0x65/0xe0
do_syscall_64+0x70/0xd00
entry_SYSCALL_64_after_hwframe+0x4b/0x53
Possible unsafe locking scenario: CPU0 CPU1
---- ----
lock(&dmn->dump_info.dbg_mutex);
lock(&dmn->info.tx.mutex);
lock(&dmn->dump_info.dbg_mutex); lock(&dmn->info.rx.mutex);
*** DEADLOCK ***
--- drivers/net/ethernet/mellanox/mlx5/core/steering/sws/dr_dbg.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/steering/sws/dr_dbg.c +2 -2
@@ -1051,8 +1051,8 @@ static int dr_dump_domain_all(struct seq_file *file, struct mlx5dr_domain *dmn)struct mlx5dr_table *tbl;int ret; -mutex_lock (&dmn->dump_info.dbg_mutex);mlx5dr_domain_lock (dmn); +mutex_lock (&dmn->dump_info.dbg_mutex); ret =dr_dump_domain (file, dmn);if (ret <0 )
@@ -1065,8 +1065,8 @@ static int dr_dump_domain_all(struct seq_file *file, struct mlx5dr_domain *dmn) } unlock_mutex: -mlx5dr_domain_unlock (dmn);mutex_unlock (&dmn->dump_info.dbg_mutex); +mlx5dr_domain_unlock (dmn);return ret; }
Signature · 1 line
2.44.0
Tariq Toukan
maintainerPATCH 2/5 net/mlx5: LAG, disable MPESW in lag_disable_change()
In reply to Tariq ToukanFrom: Shay Drory <[email protected]>
mlx5_lag_disable_change() unconditionally called mlx5_disable_lag() when LAG was active, which is incorrect for MLX5_LAG_MODE_MPESW. Hnece, call mlx5_disable_mpesw() when running in MPESW mode.
--- drivers/net/ethernet/mellanox/mlx5/core/lag/lag.c | 8 ++++++-- drivers/net/ethernet/mellanox/mlx5/core/lag/mpesw.c | 8 ++++---- drivers/net/ethernet/mellanox/mlx5/core/lag/mpesw.h | 5 +++++ 3 files changed, 15 insertions(+), 6 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/lag/lag.c +6 -2
@@ -1869,8 +1869,12 @@ void mlx5_lag_disable_change(struct mlx5_core_dev *dev)mutex_lock (&ldev->lock); ldev->mode_changes_in_progress++; -if (__mlx5_lag_is_active (ldev)) -mlx5_disable_lag (ldev); +if (__mlx5_lag_is_active (ldev)) { +if (ldev->mode ==MLX5_LAG_MODE_MPESW ) +mlx5_lag_disable_mpesw (ldev); +else +mlx5_disable_lag (ldev); + }mutex_unlock (&ldev->lock);mlx5_devcom_comp_unlock (dev->priv.hca_devcom_comp);
drivers/net/ethernet/mellanox/mlx5/core/lag/mpesw.c +4 -4
@@ -65,7 +65,7 @@ static int mlx5_mpesw_metadata_set(struct mlx5_lag *ldev)return err; } -static int enable_mpesw (struct mlx5_lag *ldev) +static int mlx5_lag_enable_mpesw (struct mlx5_lag *ldev) {struct mlx5_core_dev *dev0;int err;
@@ -126,7 +126,7 @@ static int enable_mpesw(struct mlx5_lag *ldev)return err; } -static void disable_mpesw (struct mlx5_lag *ldev) +void mlx5_lag_disable_mpesw (struct mlx5_lag *ldev) {if (ldev->mode ==MLX5_LAG_MODE_MPESW ) {mlx5_mpesw_metadata_cleanup (ldev);
@@ -152,9 +152,9 @@ static void mlx5_mpesw_work(struct work_struct *work) }if (mpesww->op ==MLX5_MPESW_OP_ENABLE ) - mpesww->result =enable_mpesw (ldev); + mpesww->result =mlx5_lag_enable_mpesw (ldev);else if (mpesww->op ==MLX5_MPESW_OP_DISABLE ) -disable_mpesw (ldev); +mlx5_lag_disable_mpesw (ldev); unlock:mutex_unlock (&ldev->lock);mlx5_devcom_comp_unlock (devcom);
drivers/net/ethernet/mellanox/mlx5/core/lag/mpesw.h +5 -0
@@ -31,6 +31,11 @@ int mlx5_lag_mpesw_do_mirred(struct mlx5_core_dev *mdev,bool mlx5_lag_is_mpesw (struct mlx5_core_dev *dev);void mlx5_lag_mpesw_disable (struct mlx5_core_dev *dev);int mlx5_lag_mpesw_enable (struct mlx5_core_dev *dev); +#ifdef CONFIG_MLX5_ESWITCH +void mlx5_lag_disable_mpesw (struct mlx5_lag *ldev); +#else +static inline void mlx5_lag_disable_mpesw (struct mlx5_lag *ldev) {} +#endif /* CONFIG_MLX5_ESWITCH */ #ifdef CONFIG_MLX5_ESWITCH void mlx5_mpesw_speed_update_work (struct work_struct *work);
Signature · 1 line
2.44.0
Tariq Toukan
maintainerPATCH 3/5 net/mlx5: E-switch, Clear legacy flag when moving to switchdev
In reply to Tariq ToukanFrom: Shay Drory <[email protected]>
The cited commit introduced MLX5_PRIV_FLAGS_SWITCH_LEGACY to identify when a transition to legacy mode is requested via devlink. However, the logic failed to clear this flag if the mode was subsequently changed back to MLX5_ESWITCH_OFFLOADS (switchdev). Consequently, if a user toggled from legacy to switchdev, the flag remained set, leaving the driver with wrong state indicating
Fix this by explicitly clearing the MLX5_PRIV_FLAGS_SWITCH_LEGACY bit when the requested mode is MLX5_ESWITCH_OFFLOADS.
--- drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c +2 -0
@@ -4068,6 +4068,8 @@ int mlx5_devlink_eswitch_mode_set(struct devlink *devlink, u16 mode,if (mlx5_mode ==MLX5_ESWITCH_LEGACY ) esw->dev->priv.flags |=MLX5_PRIV_FLAGS_SWITCH_LEGACY ; +if (mlx5_mode ==MLX5_ESWITCH_OFFLOADS ) + esw->dev->priv.flags &= ~MLX5_PRIV_FLAGS_SWITCH_LEGACY ;mlx5_eswitch_disable_locked (esw);if (mlx5_mode ==MLX5_ESWITCH_OFFLOADS ) {if (mlx5_devlink_trap_get_num_active (esw->dev)) {
Signature · 1 line
2.44.0
Tariq Toukan
maintainerPATCH 4/5 net/mlx5: Fix missing devlink lock in SRIOV enable error path
In reply to Tariq ToukanFrom: Shay Drory <[email protected]>
The cited commit miss to add locking in the error path of mlx5_sriov_enable(). When pci_enable_sriov() fails, mlx5_device_disable_sriov() is called to clean up. This cleanup function now expects to be called with the devlink instance lock held.
Add the missing devl_lock(devlink) and devl_unlock(devlink)
--- drivers/net/ethernet/mellanox/mlx5/core/sriov.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/net/ethernet/mellanox/mlx5/core/sriov.c +2 -0
@@ -193,7 +193,9 @@ static int mlx5_sriov_enable(struct pci_dev *pdev, int num_vfs) err =pci_enable_sriov (pdev, num_vfs);if (err) {mlx5_core_warn (dev,"pci_enable_sriov failed : %d\n" , err); +devl_lock (devlink);mlx5_device_disable_sriov (dev, num_vfs, true, true); +devl_unlock (devlink); }return err; }
Signature · 1 line
2.44.0
Tariq Toukan
maintainerPATCH 5/5 net/mlx5e: Fix "scheduling while atomic" in IPsec MAC address query
In reply to Tariq ToukanFrom: Jianbo Liu <[email protected]>
Fix a "scheduling while atomic" bug in mlx5e_ipsec_init_macs() by replacing mlx5_query_mac_address() with ether_addr_copy() to get the local MAC address directly from netdev->dev_addr.
The issue occurs because mlx5_query_mac_address() queries the hardware which involves mlx5_cmd_exec() that can sleep, but it is called from the mlx5e_ipsec_handle_event workqueue which runs in atomic context.
The MAC address is already available in netdev->dev_addr, so no need to query hardware. This avoids the sleeping call and resolves the bug.
Call trace: BUG: scheduling while atomic: kworker/u112:2/69344/0x00000200 __schedule+0x7ab/0xa20 schedule+0x1c/0xb0 schedule_timeout+0x6e/0xf0 __wait_for_common+0x91/0x1b0 cmd_exec+0xa85/0xff0 [mlx5_core] mlx5_cmd_exec+0x1f/0x50 [mlx5_core] mlx5_query_nic_vport_mac_address+0x7b/0xd0 [mlx5_core] mlx5_query_mac_address+0x19/0x30 [mlx5_core] mlx5e_ipsec_init_macs+0xc1/0x720 [mlx5_core] mlx5e_ipsec_build_accel_xfrm_attrs+0x422/0x670 [mlx5_core] mlx5e_ipsec_handle_event+0x2b9/0x460 [mlx5_core] process_one_work+0x178/0x2e0 worker_thread+0x2ea/0x430
--- drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec.c +1 -2
@@ -259,7 +259,6 @@ static void mlx5e_ipsec_init_limits(struct mlx5e_ipsec_sa_entry *sa_entry,static void mlx5e_ipsec_init_macs (struct mlx5e_ipsec_sa_entry *sa_entry,struct mlx5_accel_esp_xfrm_attrs *attrs) { -struct mlx5_core_dev *mdev =mlx5e_ipsec_sa2dev (sa_entry);struct mlx5e_ipsec_addr *addrs = &attrs->addrs;struct net_device *netdev = sa_entry->dev;struct xfrm_state *x = sa_entry->x;
@@ -276,7 +275,7 @@ static void mlx5e_ipsec_init_macs(struct mlx5e_ipsec_sa_entry *sa_entry, attrs->type != XFRM_DEV_OFFLOAD_PACKET)return ; -mlx5_query_mac_address (mdev, addr); +ether_addr_copy (addr, netdev->dev_addr);switch (attrs->dir) {case XFRM_DEV_OFFLOAD_IN : src = attrs->dmac;
Signature · 1 line
2.44.0
Quoted 8 lines · Tariq Toukan
Hi,
This patchset provides misc bug fixes from the team to the mlx5 core and Eth drivers.
Thanks,
Tariq.
Quoted 8 lines
Jianbo Liu (1):
net/mlx5e: Fix "scheduling while atomic" in IPsec MAC address queryShay Drory (4):
net/mlx5: DR, Fix circular locking dependency in dump net/mlx5: LAG, disable MPESW inlag_disable_change()net/mlx5: E-switch, Clear legacy flag when moving to switchdev net/mlx5: Fix missing devlink lock in SRIOV enable error path
Thanks Tariq, all.
For the series,
This series was applied to netdev/net.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This series was applied to netdev/net.git (main)
by Jakub Kicinski <[email protected]>:
Quoted 9 lines · On Tue, 24 Feb 2026 13:46:47 +0200 you wrote:
Hi,
This 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/5] net/mlx5: DR, Fix circular locking dependency in dump
https://git.kernel.org/netdev/net/c/2700b7e603af - [net,2/5] net/mlx5: LAG, disable MPESW in lag_disable_change() https://git.kernel.org/netdev/net/c/bd7b9f83fb9f - [net,3/5] net/mlx5: E-switch, Clear legacy flag when moving to switchdev https://git.kernel.org/netdev/net/c/d7073e8b978a - [net,4/5] net/mlx5: Fix missing devlink lock in SRIOV enable error path https://git.kernel.org/netdev/net/c/60253042c0b8 - [net,5/5] net/mlx5e: Fix "scheduling while atomic" in IPsec MAC address query https://git.kernel.org/netdev/net/c/859380694f43
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html