Skip to contentSkip to conversation

RDMA/bnxt_re: Update create_qp to use QP buffer umem attrs

PATCH Applied Sriharsha Basavapatna 2 participants 3 messages Jun 2 – Jun 8

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 RDMA/bnxt_re: Update create_qp to use QP buffer umem attrs

Use ib_umem_get_attr_or_va() helper to pin QP buffer umems. Pass attribute ids SQ_BUF_UMEM and RQ_BUF_UMEM for respective buffers.

---
 drivers/infiniband/hw/bnxt_re/ib_verbs.c | 22 +++++++++++++---------
 1 file changed, 13 insertions(+), 9 deletions(-)
drivers/infiniband/hw/bnxt_re/ib_verbs.c +13 -9
index c1c4ddc615e2..f389fc0471e6 100644
@@ -1195,7 +1195,8 @@ static int bnxt_re_init_user_qp(struct bnxt_re_dev *rdev, struct bnxt_re_pd *pd,
 				struct bnxt_re_qp *qp, struct bnxt_re_ucontext *cntx,
 				struct bnxt_re_qp_req *ureq,
 				bool fixed_que_attr,
-				struct bnxt_re_dbr_obj *dbr_obj)
+				struct bnxt_re_dbr_obj *dbr_obj,
+				struct uverbs_attr_bundle *attrs)
 {
 	struct bnxt_qplib_qp *qplib_qp;
 	struct ib_umem *umem;
@@ -1210,8 +1211,9 @@ static int bnxt_re_init_user_qp(struct bnxt_re_dev *rdev, struct bnxt_re_pd *pd,
 		bytes += bnxt_re_get_psn_bytes(rdev, cntx, qplib_qp, ureq, fixed_que_attr);
 
 	bytes = PAGE_ALIGN(bytes);
-	umem = ib_umem_get_va(&rdev->ibdev, ureq->qpsva, bytes,
-			      IB_ACCESS_LOCAL_WRITE);
+	umem = ib_umem_get_attr_or_va(&rdev->ibdev, attrs,
+				      UVERBS_ATTR_CREATE_QP_SQ_BUF_UMEM,
+				      ureq->qpsva, bytes, IB_ACCESS_LOCAL_WRITE);
 	if (IS_ERR(umem))
 		return PTR_ERR(umem);
 
@@ -1225,8 +1227,9 @@ static int bnxt_re_init_user_qp(struct bnxt_re_dev *rdev, struct bnxt_re_pd *pd,
 
 	bytes = (qplib_qp->rq.max_wqe * qplib_qp->rq.wqe_size);
 	bytes = PAGE_ALIGN(bytes);
-	umem = ib_umem_get_va(&rdev->ibdev, ureq->qprva, bytes,
-			      IB_ACCESS_LOCAL_WRITE);
+	umem = ib_umem_get_attr_or_va(&rdev->ibdev, attrs,
+				      UVERBS_ATTR_CREATE_QP_RQ_BUF_UMEM,
+				      ureq->qprva, bytes, IB_ACCESS_LOCAL_WRITE);
 	if (IS_ERR(umem)) {
 		rc = PTR_ERR(umem);
 		goto fail;
@@ -1718,7 +1721,8 @@ static int bnxt_re_init_qp_attr(struct bnxt_re_qp *qp, struct bnxt_re_pd *pd,
 				struct bnxt_re_ucontext *uctx,
 				struct bnxt_re_qp_req *ureq,
 				struct bnxt_re_dbr_obj *dbr_obj,
-				bool fixed_que_attr)
+				bool fixed_que_attr,
+				struct uverbs_attr_bundle *attrs)
 {
 	struct bnxt_qplib_dev_attr *dev_attr;
 	struct bnxt_qplib_qp *qplqp;
@@ -1792,7 +1796,7 @@ static int bnxt_re_init_qp_attr(struct bnxt_re_qp *qp, struct bnxt_re_pd *pd,
 
 	if (uctx) { /* This will update DPI and qp_handle */
 		rc = bnxt_re_init_user_qp(rdev, pd, qp, uctx, ureq, fixed_que_attr,
-					  dbr_obj);
+					  dbr_obj, attrs);
 		if (rc)
 			return rc;
 	}
@@ -1928,9 +1932,9 @@ static int bnxt_re_add_unique_gid(struct bnxt_re_dev *rdev)
 int bnxt_re_create_qp(struct ib_qp *ib_qp, struct ib_qp_init_attr *qp_init_attr,
 		      struct ib_udata *udata)
 {
+	struct uverbs_attr_bundle *attrs = NULL;
 	struct bnxt_re_dbr_obj *dbr_obj = NULL;
 	struct bnxt_qplib_dev_attr *dev_attr;
-	struct uverbs_attr_bundle *attrs;
 	struct bnxt_re_ucontext *uctx;
 	bool fixed_que_attr = false;
 	struct bnxt_re_qp_req ureq;
@@ -1976,7 +1980,7 @@ int bnxt_re_create_qp(struct ib_qp *ib_qp, struct ib_qp_init_attr *qp_init_attr,
 
 	qp->rdev = rdev;
 	rc = bnxt_re_init_qp_attr(qp, pd, qp_init_attr, uctx, &ureq,
-				  dbr_obj, fixed_que_attr);
+				  dbr_obj, fixed_que_attr, attrs);
 	if (rc)
 		goto fail;
 
Signature · 1 line
2.51.2.636.ga99f379adf
maintainer Applied
#1 lore raw
Quoted 9 lines · Sriharsha Basavapatna

Use ib_umem_get_attr_or_va() helper to pin QP buffer umems. Pass attribute ids SQ_BUF_UMEM and RQ_BUF_UMEM for respective buffers.

---
 drivers/infiniband/hw/bnxt_re/ib_verbs.c | 22 +++++++++++++---------
 1 file changed, 13 insertions(+), 9 deletions(-)

Applied, but please read the sashiko report and send a patch fixing all the maths overflows in this driver for the uapi. Any maths from a udata should be done with checked arithmetic.

Jason

#2 lore raw
Quoted 12 lines · Jason Gunthorpe
Quoted 9 lines · Sriharsha Basavapatna

Use ib_umem_get_attr_or_va() helper to pin QP buffer umems. Pass attribute ids SQ_BUF_UMEM and RQ_BUF_UMEM for respective buffers.

---
 drivers/infiniband/hw/bnxt_re/ib_verbs.c | 22 +++++++++++++---------
 1 file changed, 13 insertions(+), 9 deletions(-)
Quoted 3 lines

Applied, but please read the sashiko report and send a patch fixing all the maths overflows in this driver for the uapi. Any maths from a udata should be done with checked arithmetic.

Selvin is preparing a bug-fix series that includes the fix for this issue pointed out by Sashiko.
Thanks,
-Harsha

Quoted 2 lines

Jason