diff options
| author | Cosmin Ratiu <cratiu@nvidia.com> | 2026-11-05 23:16:31 +0200 |
|---|---|---|
| committer | Jakub Kicinski <kuba@kernel.org> | 2026-11-10 15:33:09 -0800 |
| commit | b7e98883eeb72b736dbdeb443e1f43e45f8e5dc1 (patch) | |
| tree | 4a99e31036d2363593149872d09690e24b1d52e0 /tools/perf/scripts/python | |
| parent | b102f927c69e2d7cf849bcfb7f7b0cd6e52fc1b0 (diff) | |
net/mlx5e: Take HCA devcom lock before esw->mode_lock
Uplink ETH driver removal waits for any eswitch operation in progress
before removing REPs. Removal through mlx5_unregister_device() or
mlx5_detach_device() does this while holding the HCA devcom lock, which
is used by peer devices in the same group.
An E-Switch mode change can therefore race with a Socket Direct
secondary device removal:
T1: primary mode set T2: SD secondary dev removal
mlx5_devlink_eswitch_mode_set()
sets operation in progress
mlx5_unregister_device()
mlx5_devcom_comp_lock(hca)
...
mlx5e_remove()
mlx5_sd_get_adev() -> T1 dev
mlx5_eswitch_safe_aux_devs_remove()
waits for T1's operation
esw_offloads_start()
esw_mode_change()
mlx5_devcom_comp_lock(hca)
waits for T2's lock
The timeout in mlx5_eswitch_safe_aux_devs_remove() makes this not a
deadlock, but representor removal is skipped in that case which is
incorrect.
This bug was found by Sashiko inspecting the next patch in the series,
which removes the timeout. It wasn't reproduced but the scenario seems
plausible, albeit unlikely. This was undetectable by lockdep because the
down_read_trylock() in mlx5_esw_hold() doesn't register as a lock edge,
and also because it can't see the wait on the flag as a lock edge.
Fix the lock order so the HCA devcom lock is taken in
mlx5_devlink_eswitch_mode_set() before esw->mode_lock and held for the
duration of the mode change.
Expanding the HCA devcom lock critical section implies new lock edges
being added, but this is safe:
- mlx5_devlink_netdev_netns_immutable_set() adds HCA devcom -> RTNL, but
there's already a HCA devcom -> RTNL dependency in
mlx5_register_device() -..-> register_netdev()
- esw_offloads_disable/enable() -> esw devcom cleanup/init: adds HCA
devcom -> esw devcom. Nothing takes the HCA devcom lock while holding
the esw devcom lock.
Fixes: 2ae8c7edea87 ("net/mlx5: Fix Unbinding uplink-netdev in switchdev mode")
Signed-off-by: Cosmin Ratiu <cratiu@nvidia.com>
Reviewed-by: Jianbo Liu <jianbol@nvidia.com>
Signed-off-by: Tariq Toukan <tariqt@nvidia.com>
Link: https://patch.msgid.link/20261105211637.1083978-4-tariqt@nvidia.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Diffstat (limited to 'tools/perf/scripts/python')
0 files changed, 0 insertions, 0 deletions
