Skip to contentSkip to conversation

] RDMA/siw: Fix SQ/RQ drain logic

PATCH Superseded Bernard Metzler 2 participants 3 messages Oct 2, 2019

Subsystems (2)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 ] RDMA/siw: Fix SQ/RQ drain logic

Storage ULPs (e.g. iSER & NVMeOF) use ib_drain_qp() to drain QP/CQ. Current SIW's own drain routines do not properly wait until all SQ/RQ elements are completed and reaped from the CQ. This may cause touch after free issues. New logic relies on generic __ib_drain_sq()/__ib_drain_rq() posting a final work request, which SIW immediately flushes to CQ.

Fixes 303ae1cdfdf7 ("rdma/siw: application interface")
---
 drivers/infiniband/sw/siw/siw_main.c  |  20 -----
 drivers/infiniband/sw/siw/siw_verbs.c | 103 +++++++++++++++++++++-----
 2 files changed, 86 insertions(+), 37 deletions(-)
drivers/infiniband/sw/siw/siw_main.c +0 -20
index 05a92f997f60..fb01407a310f 100644
@@ -248,24 +248,6 @@ static struct ib_qp *siw_get_base_qp(struct ib_device *base_dev, int id)
 	return NULL;
 }
 
-static void siw_verbs_sq_flush(struct ib_qp *base_qp)
-{
-	struct siw_qp *qp = to_siw_qp(base_qp);
-
-	down_write(&qp->state_lock);
-	siw_sq_flush(qp);
-	up_write(&qp->state_lock);
-}
-
-static void siw_verbs_rq_flush(struct ib_qp *base_qp)
-{
-	struct siw_qp *qp = to_siw_qp(base_qp);
-
-	down_write(&qp->state_lock);
-	siw_rq_flush(qp);
-	up_write(&qp->state_lock);
-}
-
 static const struct ib_device_ops siw_device_ops = {
 	.owner = THIS_MODULE,
 	.uverbs_abi_ver = SIW_ABI_VERSION,
@@ -284,8 +266,6 @@ static const struct ib_device_ops siw_device_ops = {
 	.destroy_cq = siw_destroy_cq,
 	.destroy_qp = siw_destroy_qp,
 	.destroy_srq = siw_destroy_srq,
-	.drain_rq = siw_verbs_rq_flush,
-	.drain_sq = siw_verbs_sq_flush,
 	.get_dma_mr = siw_get_dma_mr,
 	.get_port_immutable = siw_get_port_immutable,
 	.iw_accept = siw_accept,
drivers/infiniband/sw/siw/siw_verbs.c +86 -17

136 lines not on this page · raw message

Signature · 1 line
2.17.2
#1 lore raw
Quoted 8 lines · Bernard Metzler

Storage ULPs (e.g. iSER & NVMeOF) use ib_drain_qp() to drain QP/CQ. Current SIW's own drain routines do not properly wait until all SQ/RQ elements are completed and reaped from the CQ. This may cause touch after free issues. New logic relies on generic __ib_drain_sq()/__ib_drain_rq() posting a final work request, which SIW immediately flushes to CQ.

Quoted 8 lines
Fixes 303ae1cdfdf7 ("rdma/siw: application interface")
---
 drivers/infiniband/sw/siw/siw_main.c  |  20 -----
 drivers/infiniband/sw/siw/siw_verbs.c | 103 +++++++++++++++++++++-----
 2 files changed, 86 insertions(+), 37 deletions(-)

I didn't follow after v1 discussion and will be glad to see changelog, what is the reason for v2?

Thanks,

#2 lore raw

-----"Leon Romanovsky" <[email protected]> wrote: -----

Quoted 23 lines

To: "Bernard Metzler" <[email protected]>
From: "Leon Romanovsky" <[email protected]>
Date: 10/02/2019 03:32PM
Cc: [email protected], [email protected], [email protected], [email protected], [email protected], [email protected]
Subject: [EXTERNAL] Re: [[PATCH v2 for-next]] RDMA/siw: Fix SQ/RQ drain logic

Quoted 8 lines · Bernard Metzler

Storage ULPs (e.g. iSER & NVMeOF) use ib_drain_qp() to drain QP/CQ. Current SIW's own drain routines do not properly wait until all SQ/RQ elements are completed and reaped from the CQ. This may cause touch after free issues. New logic relies on generic __ib_drain_sq()/__ib_drain_rq() posting a final work request, which SIW immediately flushes to CQ.

Quoted 6 lines
Fixes 303ae1cdfdf7 ("rdma/siw: application interface")
---
 drivers/infiniband/sw/siw/siw_main.c  |  20 -----
 drivers/infiniband/sw/siw/siw_verbs.c | 103
Quoted 8 lines

+++++++++++++++++++++-----

Quoted 2 lines
 2 files changed, 86 insertions(+), 37 deletions(-)

I didn't follow after v1 discussion and will be glad to see changelog,
what is the reason for v2?

Absolutely. Let me resend the patch with below change log.

Sorry & best regards,
Bernard.

v1 -> v2:
- Accept SQ and RQ work requests, if QP is in ERROR state. In that case, immediately flush WR's to CQ. This already provides needed functionality to support ib_drain_sq()/ib_drain_rq() without extra state checking in the fast path.