Hello,
My static analysis tool reports a possible deadlock in the mlx4 driver
in Linux 5.16:
mlx4_xdp_set()
mutex_lock(&mdev->state_lock); --> Line 2778 (Lock A)
mlx4_en_try_alloc_resources()
mlx4_en_alloc_resources()
mlx4_en_destroy_tx_ring()
mlx4_qp_free()
wait_for_completion(&qp->free); --> Line 528 (Wait X)
mlx4_en_reset_config()
mutex_lock(&mdev->state_lock); --> Line 3522 (Lock A)
mlx4_en_try_alloc_resources()
mlx4_en_alloc_resources()
mlx4_en_destroy_tx_ring()
mlx4_qp_free()
complete(&qp->free); --> Line 527 (Wake X)
When mlx4_xdp_set() is executed, "Wait X" is performed by holding "Lock
A". If mlx4_en_reset_config() is executed at this time, "Wake X" cannot
be performed to wake up "Wait X" in mlx4_xdp_set(), because "Lock A" has
been already hold by mlx4_xdp_set(), causing a possible deadlock.
I am not quite sure whether this possible problem is real and how to fix
it if it is real.
Any feedback would be appreciated, thanks :)
Best wishes,
Jia-Ju Bai