Skip to content

Commit 6377ed0

Browse files
Moshe ShemeshSaeed Mahameed
Moshe Shemesh
authored and
Saeed Mahameed
committed
net/mlx5: Fix health work queue spin lock to IRQ safe
spin_lock/unlock of health->wq_lock should be IRQ safe. It was changed to spin_lock_irqsave since adding commit 0179720 ("net/mlx5: Introduce trigger_health_work function") which uses spin_lock from asynchronous event (IRQ) context. Thus, all spin_lock/unlock of health->wq_lock should have been moved to IRQ safe mode. However, one occurrence on new code using this lock missed that change, resulting in possible deadlock: kernel: Possible unsafe locking scenario: kernel: CPU0 kernel: ---- kernel: lock(&(&health->wq_lock)->rlock); kernel: <Interrupt> kernel: lock(&(&health->wq_lock)->rlock); kernel: #12 *** DEADLOCK *** Fixes: 2a0165a ("net/mlx5: Cancel delayed recovery work when unloading the driver") Signed-off-by: Moshe Shemesh <[email protected]> Signed-off-by: Saeed Mahameed <[email protected]>
1 parent 5c25f65 commit 6377ed0

File tree

1 file changed

+3
-2
lines changed
  • drivers/net/ethernet/mellanox/mlx5/core

1 file changed

+3
-2
lines changed

drivers/net/ethernet/mellanox/mlx5/core/health.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -356,10 +356,11 @@ void mlx5_drain_health_wq(struct mlx5_core_dev *dev)
356356
void mlx5_drain_health_recovery(struct mlx5_core_dev *dev)
357357
{
358358
struct mlx5_core_health *health = &dev->priv.health;
359+
unsigned long flags;
359360

360-
spin_lock(&health->wq_lock);
361+
spin_lock_irqsave(&health->wq_lock, flags);
361362
set_bit(MLX5_DROP_NEW_RECOVERY_WORK, &health->flags);
362-
spin_unlock(&health->wq_lock);
363+
spin_unlock_irqrestore(&health->wq_lock, flags);
363364
cancel_delayed_work_sync(&dev->priv.health.recover_work);
364365
}
365366

0 commit comments

Comments
 (0)