IB/rdmavt: add missing locks in rvt_ruc_loopback
authorNiels Dossche <dossche.niels@gmail.com>
Mon, 28 Feb 2022 19:51:44 +0000 (20:51 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 9 Jun 2022 08:22:40 +0000 (10:22 +0200)
commitb6c6b398629d1fe266554b5c74986eb1db4b5362
tree038718692b9742ccc55130ff617bd83ee1f8f1fd
parentff876b6cf5785e9604cd407022db917734b5d7ad
IB/rdmavt: add missing locks in rvt_ruc_loopback

[ Upstream commit 22cbc6c2681a0a4fe76150270426e763d52353a4 ]

The documentation of the function rvt_error_qp says both r_lock and
s_lock need to be held when calling that function.
It also asserts using lockdep that both of those locks are held.
rvt_error_qp is called form rvt_send_cq, which is called from
rvt_qp_complete_swqe, which is called from rvt_send_complete, which is
called from rvt_ruc_loopback in two places. Both of these places do not
hold r_lock. Fix this by acquiring a spin_lock of r_lock in both of
these places.
The r_lock acquiring cannot be added in rvt_qp_complete_swqe because
some of its other callers already have r_lock acquired.

Link: https://lore.kernel.org/r/20220228195144.71946-1-dossche.niels@gmail.com
Signed-off-by: Niels Dossche <dossche.niels@gmail.com>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/infiniband/sw/rdmavt/qp.c