]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
net/mlx4_core: Fix locking in SRIOV mode when switching between events and polling
authorJack Morgenstein <jackm@dev.mellanox.co.il>
Tue, 12 Mar 2019 15:05:48 +0000 (17:05 +0200)
committerBen Hutchings <ben@decadent.org.uk>
Tue, 9 Jul 2019 21:04:17 +0000 (22:04 +0100)
commit7a437ebe1c2a1c0531b30e059c449b9ae1785aae
tree6fa4faed40bfae4cf919c09120db28ad58d6a153
parent1e70758c7e844fe50fc2d0ccbe17d78398f5c6b7
net/mlx4_core: Fix locking in SRIOV mode when switching between events and polling

commit c07d27927f2f2e96fcd27bb9fb330c9ea65612d0 upstream.

In procedures mlx4_cmd_use_events() and mlx4_cmd_use_polling(), we need to
guarantee that there are no FW commands in progress on the comm channel
(for VFs) or wrapped FW commands (on the PF) when SRIOV is active.

We do this by also taking the slave_cmd_mutex when SRIOV is active.

This is especially important when switching from event to polling, since we
free the command-context array during the switch.  If there are FW commands
in progress (e.g., waiting for a completion event), the completion event
handler will access freed memory.

Since the decision to use comm_wait or comm_poll is taken before grabbing
the event_sem/poll_sem in mlx4_comm_cmd_wait/poll, we must take the
slave_cmd_mutex as well (to guarantee that the decision to use events or
polling and the call to the appropriate cmd function are atomic).

Fixes: a7e1f04905e5 ("net/mlx4_core: Fix deadlock when switching between polling and event fw commands")
Signed-off-by: Jack Morgenstein <jackm@dev.mellanox.co.il>
Signed-off-by: Tariq Toukan <tariqt@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
drivers/net/ethernet/mellanox/mlx4/cmd.c