From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: Niels Dossche <dossche.niels@gmail.com>,
Jason Gunthorpe <jgg@nvidia.com>, Sasha Levin <sashal@kernel.org>,
dennis.dalessandro@cornelisnetworks.com,
linux-rdma@vger.kernel.org
Subject: [PATCH AUTOSEL 5.4 01/20] IB/rdmavt: add missing locks in rvt_ruc_loopback
Date: Wed, 1 Jun 2022 09:58:43 -0400 [thread overview]
Message-ID: <20220601135902.2004823-1-sashal@kernel.org> (raw)
From: Niels Dossche <dossche.niels@gmail.com>
[ 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 | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/drivers/infiniband/sw/rdmavt/qp.c b/drivers/infiniband/sw/rdmavt/qp.c
index 48e8612c1bc8..e97c13967174 100644
--- a/drivers/infiniband/sw/rdmavt/qp.c
+++ b/drivers/infiniband/sw/rdmavt/qp.c
@@ -2812,7 +2812,7 @@ void rvt_qp_iter(struct rvt_dev_info *rdi,
EXPORT_SYMBOL(rvt_qp_iter);
/*
- * This should be called with s_lock held.
+ * This should be called with s_lock and r_lock held.
*/
void rvt_send_complete(struct rvt_qp *qp, struct rvt_swqe *wqe,
enum ib_wc_status status)
@@ -3171,7 +3171,9 @@ void rvt_ruc_loopback(struct rvt_qp *sqp)
rvp->n_loop_pkts++;
flush_send:
sqp->s_rnr_retry = sqp->s_rnr_retry_cnt;
+ spin_lock(&sqp->r_lock);
rvt_send_complete(sqp, wqe, send_status);
+ spin_unlock(&sqp->r_lock);
if (local_ops) {
atomic_dec(&sqp->local_ops_pending);
local_ops = 0;
@@ -3225,7 +3227,9 @@ void rvt_ruc_loopback(struct rvt_qp *sqp)
spin_unlock_irqrestore(&qp->r_lock, flags);
serr_no_r_lock:
spin_lock_irqsave(&sqp->s_lock, flags);
+ spin_lock(&sqp->r_lock);
rvt_send_complete(sqp, wqe, send_status);
+ spin_unlock(&sqp->r_lock);
if (sqp->ibqp.qp_type == IB_QPT_RC) {
int lastwqe;
--
2.35.1
next reply other threads:[~2022-06-01 14:06 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-01 13:58 Sasha Levin [this message]
2022-06-01 13:58 ` [PATCH AUTOSEL 5.4 02/20] ARM: dts: ox820: align interrupt controller node name with dtschema Sasha Levin
2022-06-01 13:58 ` [PATCH AUTOSEL 5.4 03/20] PM / devfreq: rk3399_dmc: Disable edev on remove() Sasha Levin
2022-06-01 13:58 ` [PATCH AUTOSEL 5.4 04/20] fs: jfs: fix possible NULL pointer dereference in dbFree() Sasha Levin
2022-06-01 13:58 ` [PATCH AUTOSEL 5.4 05/20] arm64: Expand ESR_ELx_WFx_ISS_TI to match its ARMv8.7 definition Sasha Levin
2022-06-01 13:58 ` [PATCH AUTOSEL 5.4 06/20] ARM: OMAP1: clock: Fix UART rate reporting algorithm Sasha Levin
2022-06-01 13:58 ` [PATCH AUTOSEL 5.4 07/20] selftests/resctrl: Change the default limited time to 120 seconds Sasha Levin
2022-06-01 13:58 ` [PATCH AUTOSEL 5.4 08/20] powerpc/fadump: Fix fadump to work with a different endian capture kernel Sasha Levin
2022-06-01 13:58 ` [PATCH AUTOSEL 5.4 09/20] fat: add ratelimit to fat*_ent_bread() Sasha Levin
2022-06-01 13:58 ` [PATCH AUTOSEL 5.4 10/20] ARM: versatile: Add missing of_node_put in dcscb_init Sasha Levin
2022-06-01 13:58 ` [PATCH AUTOSEL 5.4 11/20] ARM: dts: exynos: add atmel,24c128 fallback to Samsung EEPROM Sasha Levin
2022-06-01 13:58 ` [PATCH AUTOSEL 5.4 12/20] ARM: hisi: Add missing of_node_put after of_find_compatible_node Sasha Levin
2022-06-01 13:58 ` [PATCH AUTOSEL 5.4 13/20] PCI: Avoid pci_dev_lock() AB/BA deadlock with sriov_numvfs_store() Sasha Levin
2022-06-01 13:58 ` [PATCH AUTOSEL 5.4 14/20] tracing: incorrect isolate_mote_t cast in mm_vmscan_lru_isolate Sasha Levin
2022-06-01 13:58 ` [PATCH AUTOSEL 5.4 15/20] powerpc/xics: fix refcount leak in icp_opal_init() Sasha Levin
2022-06-01 13:58 ` [PATCH AUTOSEL 5.4 16/20] powerpc/powernv: fix missing of_node_put in uv_init() Sasha Levin
2022-06-01 13:58 ` [PATCH AUTOSEL 5.4 17/20] macintosh/via-pmu: Fix build failure when CONFIG_INPUT is disabled Sasha Levin
2022-06-01 13:59 ` [PATCH AUTOSEL 5.4 18/20] powerpc/iommu: Add missing of_node_put in iommu_init_early_dart Sasha Levin
2022-06-01 13:59 ` [PATCH AUTOSEL 5.4 19/20] RDMA/hfi1: Prevent panic when SDMA is disabled Sasha Levin
2022-06-01 13:59 ` [PATCH AUTOSEL 5.4 20/20] drm: fix EDID struct for old ARM OABI format Sasha Levin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220601135902.2004823-1-sashal@kernel.org \
--to=sashal@kernel.org \
--cc=dennis.dalessandro@cornelisnetworks.com \
--cc=dossche.niels@gmail.com \
--cc=jgg@nvidia.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rdma@vger.kernel.org \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox