Commit aed763a
net/mlx5: Fix deadlock between devlink lock and esw->wq
esw->work_queue executes esw_functions_changed_event_handler ->
esw_vfs_changed_event_handler and acquires the devlink lock.
.eswitch_mode_set (acquires devlink lock in devlink_nl_pre_doit) ->
mlx5_devlink_eswitch_mode_set -> mlx5_eswitch_disable_locked ->
mlx5_eswitch_event_handler_unregister -> flush_workqueue deadlocks
when esw_vfs_changed_event_handler executes.
Fix that by no longer flushing the work to avoid the deadlock, and using
a generation counter to keep track of work relevance. This avoids an old
handler manipulating an esw that has undergone one or more mode changes:
- the counter is incremented in mlx5_eswitch_event_handler_unregister.
- the counter is read and passed to the ephemeral mlx5_host_work struct.
- the work handler takes the devlink lock and bails out if the current
generation is different than the one it was scheduled to operate on.
- mlx5_eswitch_cleanup does the final draining before destroying the wq.
No longer flushing the workqueue has the side effect of maybe no longer
cancelling pending vport_change_handler work items, but that's ok since
those are disabled elsewhere:
- mlx5_eswitch_disable_locked disables the vport eq notifier.
- mlx5_esw_vport_disable disarms the HW EQ notification and marks
vport->enabled under state_lock to false to prevent pending vport
handler from doing anything.
- mlx5_eswitch_cleanup destroys the workqueue and makes sure all events
are disabled/finished.
Fixes: f1bc646 ("net/mlx5: Use devl_ API in mlx5_esw_offloads_devlink_port_register")
Signed-off-by: Cosmin Ratiu <[email protected]>
Reviewed-by: Moshe Shemesh <[email protected]>
Reviewed-by: Dragos Tatulea <[email protected]>
Reviewed-by: Simon Horman <[email protected]>
Signed-off-by: Tariq Toukan <[email protected]>
Link: https://patch.msgid.link/[email protected]
Signed-off-by: Jakub Kicinski <[email protected]>1 parent 55f854d commit aed763a
3 files changed
Lines changed: 19 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1072 | 1072 | | |
1073 | 1073 | | |
1074 | 1074 | | |
1075 | | - | |
| 1075 | + | |
| 1076 | + | |
1076 | 1077 | | |
1077 | | - | |
1078 | | - | |
| 1078 | + | |
| 1079 | + | |
1079 | 1080 | | |
1080 | 1081 | | |
1081 | 1082 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
335 | 335 | | |
336 | 336 | | |
337 | 337 | | |
| 338 | + | |
338 | 339 | | |
339 | 340 | | |
340 | 341 | | |
341 | 342 | | |
| 343 | + | |
342 | 344 | | |
343 | 345 | | |
344 | 346 | | |
| |||
Lines changed: 13 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3582 | 3582 | | |
3583 | 3583 | | |
3584 | 3584 | | |
3585 | | - | |
| 3585 | + | |
| 3586 | + | |
3586 | 3587 | | |
3587 | 3588 | | |
3588 | 3589 | | |
3589 | 3590 | | |
3590 | 3591 | | |
| 3592 | + | |
| 3593 | + | |
| 3594 | + | |
| 3595 | + | |
| 3596 | + | |
| 3597 | + | |
| 3598 | + | |
3591 | 3599 | | |
3592 | 3600 | | |
3593 | 3601 | | |
3594 | 3602 | | |
3595 | 3603 | | |
3596 | 3604 | | |
3597 | | - | |
| 3605 | + | |
3598 | 3606 | | |
3599 | | - | |
3600 | | - | |
3601 | 3607 | | |
3602 | 3608 | | |
3603 | 3609 | | |
| |||
3612 | 3618 | | |
3613 | 3619 | | |
3614 | 3620 | | |
| 3621 | + | |
3615 | 3622 | | |
3616 | 3623 | | |
3617 | 3624 | | |
| |||
3628 | 3635 | | |
3629 | 3636 | | |
3630 | 3637 | | |
3631 | | - | |
| 3638 | + | |
3632 | 3639 | | |
3633 | 3640 | | |
3634 | 3641 | | |
| |||
3648 | 3655 | | |
3649 | 3656 | | |
3650 | 3657 | | |
| 3658 | + | |
3651 | 3659 | | |
3652 | 3660 | | |
3653 | 3661 | | |
| |||
0 commit comments