mlx5 misc fixes 2026-01-20
Subsystems (5)
Tariq Toukan
maintainercover mlx5 misc fixes 2026-01-20
Hi,
This patchset provides misc bug fixes from the team to the mlx5 core and Eth drivers.
Thanks,
Tariq.
Cosmin Ratiu (1):
net/mlx5: Fix deadlock between devlink lock and esw->wq
Jianbo Liu (1):
net/mlx5e: Skip ESN replay window setup for IPsec crypto offload
Parav Pandit (1):
net/mlx5: Fix vhca_id access call trace use before alloc
Shay Drory (1):
net/mlx5: fs, Fix inverted cap check in tx flow table root disconnect
.../net/ethernet/mellanox/mlx5/core/debugfs.c | 16 ++++++++++++++++ .../ethernet/mellanox/mlx5/core/en_accel/ipsec.c | 3 ++- .../net/ethernet/mellanox/mlx5/core/eswitch.c | 6 +++++- .../net/ethernet/mellanox/mlx5/core/eswitch.h | 1 + .../mellanox/mlx5/core/eswitch_offloads.c | 12 +++++++++++- drivers/net/ethernet/mellanox/mlx5/core/fs_cmd.c | 3 ++- drivers/net/ethernet/mellanox/mlx5/core/main.c | 14 +++----------- .../net/ethernet/mellanox/mlx5/core/mlx5_core.h | 1 + .../ethernet/mellanox/mlx5/core/sf/dev/driver.c | 1 + 9 files changed, 42 insertions(+), 15 deletions(-)
base-commit: 58bae918d73e3b6cd57d1e39fcf7c75c7dd1a8fe
Signature · 1 line
2.44.0
Tariq Toukan
maintainerPATCH 1/4 net/mlx5: fs, Fix inverted cap check in tx flow table root disconnect
From: Shay Drory <[email protected]>
The capability check for reset_root_to_default was inverted, causing the function to return -EOPNOTSUPP when the capability IS supported, rather than when it is NOT supported.
Fix the capability check condition.
--- drivers/net/ethernet/mellanox/mlx5/core/fs_cmd.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/ethernet/mellanox/mlx5/core/fs_cmd.c +2 -1
@@ -1198,7 +1198,8 @@ int mlx5_fs_cmd_set_tx_flow_table_root(struct mlx5_core_dev *dev, u32 ft_id, boou32 out[MLX5_ST_SZ_DW (set_flow_table_root_out)] = {};u32 in[MLX5_ST_SZ_DW (set_flow_table_root_in)] = {}; -if (disconnect &&MLX5_CAP_FLOWTABLE_NIC_TX (dev, reset_root_to_default)) +if (disconnect && + !MLX5_CAP_FLOWTABLE_NIC_TX (dev, reset_root_to_default))return -EOPNOTSUPP ; MLX5_SET(set_flow_table_root_in, in, opcode,
Signature · 1 line
2.44.0
Tariq Toukan
maintainerPATCH 2/4 net/mlx5: Fix deadlock between devlink lock and esw->wq
In reply to Tariq ToukanFrom: Cosmin Ratiu <[email protected]>
esw_functions_changed_event_handler -> esw_vfs_changed_event_handler is called from the esw->work_queue and acquires the devlink lock.
Changing the esw mode is done via .eswitch_mode_set (acquires devlink lock in the devlink_nl_pre_doit call) -> mlx5_devlink_eswitch_mode_set -> mlx5_eswitch_disable_locked -> mlx5_eswitch_event_handler_unregister -> flush_workqueue.
This creates a circular lock dependency which could lead to a real deadlock, as the code flushing the workqueue is holding the devlink lock, and the work handler being flushed could try to acquire it.
Fix that by adding a new bool field 'notifier_enabled' next to the event handler scheduling the work, keeping it true while the notifier is active, and using it to repeatedly try to acquire the devlink lock from the work handler while true, with a slight delay to avoid busy looping.
This avoids the deadlock because the event handler will be removed first (turning 'notifier_enabled' false), and the work handler will eventually give up in acquiring the lock because the work is no longer necessary.
--- drivers/net/ethernet/mellanox/mlx5/core/eswitch.c | 6 +++++- drivers/net/ethernet/mellanox/mlx5/core/eswitch.h | 1 + .../ethernet/mellanox/mlx5/core/eswitch_offloads.c | 12 +++++++++++- 3 files changed, 17 insertions(+), 2 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/eswitch.c +5 -1
@@ -1066,14 +1066,18 @@ static void mlx5_eswitch_event_handler_register(struct mlx5_eswitch *esw)if (esw->mode ==MLX5_ESWITCH_OFFLOADS &&mlx5_eswitch_is_funcs_handler (esw->dev)) {MLX5_NB_INIT (&esw->esw_funcs.nb, mlx5_esw_funcs_changed_handler,ESW_FUNCTIONS_CHANGED ); + esw->esw_funcs.notifier_enabled = true;mlx5_eq_notifier_register (esw->dev, &esw->esw_funcs.nb); } }static void mlx5_eswitch_event_handler_unregister (struct mlx5_eswitch *esw) { -if (esw->mode ==MLX5_ESWITCH_OFFLOADS &&mlx5_eswitch_is_funcs_handler (esw->dev)) +if (esw->mode ==MLX5_ESWITCH_OFFLOADS && +mlx5_eswitch_is_funcs_handler (esw->dev)) { + esw->esw_funcs.notifier_enabled = false;mlx5_eq_notifier_unregister (esw->dev, &esw->esw_funcs.nb); + }flush_workqueue (esw->work_queue); }
drivers/net/ethernet/mellanox/mlx5/core/eswitch.h +1 -0
@@ -338,6 +338,7 @@ struct mlx5_host_work {struct mlx5_esw_functions {struct mlx5_nb nb; +bool notifier_enabled;bool host_funcs_disabled;u16 num_vfs;u16 num_ec_vfs;
drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c +11 -1
@@ -3597,7 +3597,17 @@ esw_vfs_changed_event_handler(struct mlx5_eswitch *esw, const u32 *out)return ; devlink =priv_to_devlink (esw->dev); -devl_lock (devlink); +/* Repeatedly try to grab the lock with a delay while this work is +* still relevant. +* This allows a concurrent mlx5_eswitch_event_handler_unregister +* (holding the devlink lock) to flush the wq without deadlocking. +*/ +while (!devl_trylock (devlink)) { +if (!esw->esw_funcs.notifier_enabled) +return ; +schedule_timeout_interruptible (msecs_to_jiffies (10 )); + } +/* Number of VFs can only change from "0 to x" or "x to 0". */ if (esw->esw_funcs.num_vfs >0 ) {mlx5_eswitch_unload_vf_vports (esw, esw->esw_funcs.num_vfs);
Signature · 1 line
2.44.0
Tariq Toukan
maintainerPATCH 3/4 net/mlx5: Fix vhca_id access call trace use before alloc
In reply to Tariq ToukanFrom: Parav Pandit <[email protected]>
HCA CAP structure is allocated in mlx5_hca_caps_alloc(). mlx5_mdev_init()
mlx5_hca_caps_alloc()
And HCA CAP is read from the device in mlx5_init_one().
The vhca_id's debugfs file is published even before above two operations are done.
Due to this when user reads the vhca id before the initialization, following call trace is observed.
Fix this by deferring debugfs publication until the HCA CAP is allocated and read from the device.
BUG: kernel NULL pointer dereference, address: 0000000000000004 PGD 0 P4D 0 Oops: Oops: 0000 [#1] SMP PTI CPU: 23 UID: 0 PID: 6605 Comm: cat Kdump: loaded Not tainted 6.18.0-rc7-sf+ #110 PREEMPT(full) Hardware name: Supermicro SYS-6028U-TR4+/X10DRU-i+, BIOS 2.0b 08/09/2016 RIP: 0010:vhca_id_show+0x17/0x30 [mlx5_core] Code: cb 66 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 0f 1f 44 00 00 48 8b 47 70 48 c7 c6 45 f0 12 c1 48 8b 80 70 03 00 00 <8b> 50 04 0f ca 0f b7 d2 e8 8c 82 47 cb 31 c0 c3 cc cc cc cc 0f 1f RSP: 0018:ffffd37f4f337d40 EFLAGS: 00010203 RAX: 0000000000000000 RBX: ffff8f18445c9b40 RCX: 0000000000000001 RDX: ffff8f1109825180 RSI: ffffffffc112f045 RDI: ffff8f18445c9b40 RBP: 0000000000000000 R08: 0000645eac0d2928 R09: 0000000000000006 R10: ffffd37f4f337d48 R11: 0000000000000000 R12: ffffd37f4f337dd8 R13: ffffd37f4f337db0 R14: ffff8f18445c9b68 R15: 0000000000000001 FS: 00007f3eea099580(0000) GS:ffff8f2090f1f000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 0000000000000004 CR3: 00000008b64e4006 CR4: 00000000003726f0 Call Trace: <TASK> seq_read_iter+0x11f/0x4f0 ? _raw_spin_unlock+0x15/0x30 ? do_anonymous_page+0x104/0x810 seq_read+0xf6/0x120 ? srso_alias_untrain_ret+0x1/0x10 full_proxy_read+0x5c/0x90 vfs_read+0xad/0x320 ? handle_mm_fault+0x1ab/0x290 ksys_read+0x52/0xd0 do_syscall_64+0x61/0x11e0 entry_SYSCALL_64_after_hwframe+0x76/0x7e
--- .../net/ethernet/mellanox/mlx5/core/debugfs.c | 16 ++++++++++++++++ drivers/net/ethernet/mellanox/mlx5/core/main.c | 14 +++----------- .../net/ethernet/mellanox/mlx5/core/mlx5_core.h | 1 + .../ethernet/mellanox/mlx5/core/sf/dev/driver.c | 1 + 4 files changed, 21 insertions(+), 11 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/debugfs.c +16 -0
@@ -613,3 +613,19 @@ void mlx5_debug_cq_remove(struct mlx5_core_dev *dev, struct mlx5_core_cq *cq) cq->dbg =NULL ; } } + +static int vhca_id_show (struct seq_file *file,void *priv) +{ +struct mlx5_core_dev *dev = file->private; + +seq_printf (file,"0x%x\n" ,MLX5_CAP_GEN (dev, vhca_id)); +return 0 ; +} + +DEFINE_SHOW_ATTRIBUTE (vhca_id); + +void mlx5_vhca_debugfs_init (struct mlx5_core_dev *dev) +{ +debugfs_create_file ("vhca_id" ,0400 , dev->priv.dbg.dbg_root, dev, + &vhca_id_fops); +}
drivers/net/ethernet/mellanox/mlx5/core/main.c +3 -11
@@ -1806,16 +1806,6 @@ static int mlx5_hca_caps_alloc(struct mlx5_core_dev *dev)return -ENOMEM ; } -static int vhca_id_show (struct seq_file *file,void *priv) -{ -struct mlx5_core_dev *dev = file->private; - -seq_printf (file,"0x%x\n" ,MLX5_CAP_GEN (dev, vhca_id)); -return 0 ; -} - -DEFINE_SHOW_ATTRIBUTE (vhca_id); -static int mlx5_notifiers_init (struct mlx5_core_dev *dev) {int err;
@@ -1884,7 +1874,7 @@ int mlx5_mdev_init(struct mlx5_core_dev *dev, int profile_idx) priv->numa_node =dev_to_node (mlx5_core_dma_dev (dev)); priv->dbg.dbg_root =debugfs_create_dir (dev_name (dev->device), mlx5_debugfs_root); -debugfs_create_file ("vhca_id" ,0400 , priv->dbg.dbg_root, dev, &vhca_id_fops); +INIT_LIST_HEAD (&priv->traps); err =mlx5_cmd_init (dev);
@@ -2022,6 +2012,8 @@ static int probe_one(struct pci_dev *pdev, const struct pci_device_id *id) goto err_init_one; } +mlx5_vhca_debugfs_init (dev); +pci_save_state (pdev);return 0 ;
drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.h +1 -0
@@ -258,6 +258,7 @@ int mlx5_wait_for_pages(struct mlx5_core_dev *dev, int *pages);void mlx5_cmd_flush (struct mlx5_core_dev *dev);void mlx5_cq_debugfs_init (struct mlx5_core_dev *dev);void mlx5_cq_debugfs_cleanup (struct mlx5_core_dev *dev); +void mlx5_vhca_debugfs_init (struct mlx5_core_dev *dev);int mlx5_query_pcam_reg (struct mlx5_core_dev *dev,u32 *pcam,u8 feature_group,u8 access_reg_group);
drivers/net/ethernet/mellanox/mlx5/core/sf/dev/driver.c +1 -0
@@ -76,6 +76,7 @@ static int mlx5_sf_dev_probe(struct auxiliary_device *adev, const struct auxilia goto init_one_err; } +mlx5_vhca_debugfs_init (mdev);return 0 ; init_one_err:
Signature · 1 line
2.44.0
Tariq Toukan
maintainerPATCH 4/4 net/mlx5e: Skip ESN replay window setup for IPsec crypto offload
In reply to Tariq ToukanFrom: Jianbo Liu <[email protected]>
Commit a5e400a985df ("net/mlx5e: Honor user choice of IPsec replay window size") introduced logic to setup the ESN replay window size. This logic is only valid for packet offload.
However, the check to skip this block only covered outbound offloads. It was not skipped for crypto offload, causing it to fall through to the new switch statement and trigger its WARN_ON default case (for instance, if a window larger than 256 bits was configured).
Fix this by amending the condition to also skip the replay window setup if the offload type is not XFRM_DEV_OFFLOAD_PACKET.
--- drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec.c +2 -1
@@ -430,7 +430,8 @@ void mlx5e_ipsec_build_accel_xfrm_attrs(struct mlx5e_ipsec_sa_entry *sa_entry, attrs->replay_esn.esn = sa_entry->esn_state.esn; attrs->replay_esn.esn_msb = sa_entry->esn_state.esn_msb; attrs->replay_esn.overlap = sa_entry->esn_state.overlap; -if (attrs->dir ==XFRM_DEV_OFFLOAD_OUT ) +if (attrs->dir ==XFRM_DEV_OFFLOAD_OUT || + attrs->type !=XFRM_DEV_OFFLOAD_PACKET ) goto skip_replay_window;switch (x->replay_esn->replay_window) {
Signature · 1 line
2.44.0
Quoted 4 lines · Tariq Toukan
Hi,
This patchset provides misc bug fixes from the team to the mlx5 core and Eth drivers.
Thanks Tariq,
These changes all look good to me.
For the series: