Skip to contentSkip to conversation

RDMA/bnxt_re: Generic driver fixes

PATCH Superseded Selvin Xavier 1 participant 13 messages Jun 10

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Selvin Xavier

author maintainer
#0 lore raw

cover RDMA/bnxt_re: Generic driver fixes

Includes fixes for few issues pointed by sashiko. Also, some generic fixes found during internal code reviews.

Please review and Apply.

Thanks,
Selvin Xavier

Selvin Xavier (11):
RDMA/bnxt_re : Initialize dpi variable to zero RDMA/bnxt_re: Add ownership check while getting the CQ toggle page RDMA/bnxt_re: Add ownership check while getting the SRQ toggle page RDMA/bnxt_re: Avoid displaying the kernel pointer RDMA/bnxt_re: Add a max slot check for SQ
RDMA/bnxt_re: Avoid repeated requests to allocate WC pages RDMA/bnxt_re: Avoid any race while handling the hash list of CQ RDMA/bnxt_re: Avoid any race while handling the hash list of SRQ RDMA/bnxt_re: Fix the cleanup upon error during srq create RDMA/bnxt_re: Fix the cleanup upon error during CQ create RDMA/bnxt_re: Fail DBR related page allocation UAPIs if the feature is
disabled

 drivers/infiniband/hw/bnxt_re/bnxt_re.h  |  2 ++
 drivers/infiniband/hw/bnxt_re/ib_verbs.c | 35 ++++++++++++++++++++++--
 drivers/infiniband/hw/bnxt_re/ib_verbs.h |  2 ++
 drivers/infiniband/hw/bnxt_re/main.c     |  4 +--
 drivers/infiniband/hw/bnxt_re/qplib_sp.h |  1 +
 drivers/infiniband/hw/bnxt_re/uapi.c     | 19 ++++++++++++-
 6 files changed, 57 insertions(+), 6 deletions(-)
Signature · 1 line
2.39.3
author maintainer
#1 lore raw

PATCH 1/11 RDMA/bnxt_re : Initialize dpi variable to zero

dpi is initialized only for BNXT_RE_ALLOC_WC_PAGE, but copied for all the cases. So initialize the dpi to 0.

Fixes eee6268421a2 ("RDMA/bnxt_re: Move the UAPI methods to a dedicated file")
Fixes 360da60d6c6e ("RDMA/bnxt_re: Enable low latency push")
---
 drivers/infiniband/hw/bnxt_re/uapi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/infiniband/hw/bnxt_re/uapi.c +1 -1
index 9e68b4a7e952..b9922360f11b 100644
@@ -76,8 +76,8 @@ static int UVERBS_HANDLER(BNXT_RE_METHOD_ALLOC_PAGE)(struct uverbs_attr_bundle *
 	struct ib_ucontext *ib_uctx;
 	struct bnxt_re_dev *rdev;
 	u64 mmap_offset;
+	u32 dpi = 0;
 	u32 length;
-	u32 dpi;
 	u64 addr;
 	int err;
 
Signature · 1 line
2.39.3
author maintainer
#2 lore raw

PATCH 2/11 RDMA/bnxt_re: Add ownership check while getting the CQ toggle page

In reply to Selvin Xavier

The cq resource id provided by user-space is used for searching the driver CQ structure. Validate if the context currently issuing the request is same as the context created the resource.

Fixes eee6268421a2 ("RDMA/bnxt_re: Move the UAPI methods to a dedicated file")
Fixes e275919d9669 ("RDMA/bnxt_re: Share a page to expose per CQ info with userspace")
---
 drivers/infiniband/hw/bnxt_re/ib_verbs.c | 1 +
 drivers/infiniband/hw/bnxt_re/ib_verbs.h | 1 +
 drivers/infiniband/hw/bnxt_re/uapi.c     | 3 +++
 3 files changed, 5 insertions(+)
drivers/infiniband/hw/bnxt_re/ib_verbs.c +1 -0
index b1c489867fc7..239eeb019550 100644
@@ -3489,6 +3489,7 @@ int bnxt_re_create_user_cq(struct ib_cq *ibcq, const struct ib_cq_init_attr *att
 		return -EINVAL;
 
 	cq->rdev = rdev;
+	cq->uctx = &uctx->ib_uctx;
 	cctx = rdev->chip_ctx;
 	cq->qplib_cq.cq_handle = (u64)(unsigned long)(&cq->qplib_cq);
 
drivers/infiniband/hw/bnxt_re/ib_verbs.h +1 -0
index 4d6d1259a795..0ef8a8b20430 100644
@@ -102,6 +102,7 @@ struct bnxt_re_qp {
 struct bnxt_re_cq {
 	struct ib_cq		ib_cq;
 	struct bnxt_re_dev	*rdev;
+	struct ib_ucontext	*uctx;
 	spinlock_t              cq_lock;	/* protect cq */
 	u16			cq_count;
 	u16			cq_period;
drivers/infiniband/hw/bnxt_re/uapi.c +3 -0
index b9922360f11b..09026ef0441e 100644
@@ -251,6 +251,9 @@ static int UVERBS_HANDLER(BNXT_RE_METHOD_GET_TOGGLE_MEM)(struct uverbs_attr_bund
 		if (!cq)
 			return -EINVAL;
 
+		if (cq->uctx != ib_uctx)
+			return -EINVAL;
+
 		addr = (u64)cq->uctx_cq_page;
 		break;
 	case BNXT_RE_SRQ_TOGGLE_MEM:
Signature · 1 line
2.39.3
author maintainer
#3 lore raw

PATCH 3/11 RDMA/bnxt_re: Add ownership check while getting the SRQ toggle page

In reply to Selvin Xavier

The SRQ resource id provided by user-space is used for searching the driver SRQ structure. Validate if the context currently issuing the request is same as the context created the resource.

Fixes eee6268421a2 ("RDMA/bnxt_re: Move the UAPI methods to a dedicated file")
Fixes 181028a0d84c ("RDMA/bnxt_re: Share a page to expose per SRQ info with userspace")
---
 drivers/infiniband/hw/bnxt_re/ib_verbs.c | 1 +
 drivers/infiniband/hw/bnxt_re/ib_verbs.h | 1 +
 drivers/infiniband/hw/bnxt_re/uapi.c     | 3 +++
 3 files changed, 5 insertions(+)
drivers/infiniband/hw/bnxt_re/ib_verbs.c +1 -0
index 239eeb019550..eed918b9cdf1 100644
@@ -2225,6 +2225,7 @@ int bnxt_re_create_srq(struct ib_srq *ib_srq,
 
 	uctx = rdma_udata_to_drv_context(udata, struct bnxt_re_ucontext, ib_uctx);
 	srq->rdev = rdev;
+	srq->uctx = udata ? &uctx->ib_uctx : NULL;
 	srq->qplib_srq.pd = &pd->qplib_pd;
 	srq->qplib_srq.dpi = &rdev->dpi_privileged;
 	/* Allocate 1 more than what's provided so posting max doesn't
drivers/infiniband/hw/bnxt_re/ib_verbs.h +1 -0
index 0ef8a8b20430..f81978797e48 100644
@@ -73,6 +73,7 @@ struct bnxt_re_ah {
 struct bnxt_re_srq {
 	struct ib_srq		ib_srq;
 	struct bnxt_re_dev	*rdev;
+	struct ib_ucontext	*uctx;
 	u32			srq_limit;
 	struct bnxt_qplib_srq	qplib_srq;
 	struct ib_umem		*umem;
drivers/infiniband/hw/bnxt_re/uapi.c +3 -0
index 09026ef0441e..0fceaf52bf4d 100644
@@ -261,6 +261,9 @@ static int UVERBS_HANDLER(BNXT_RE_METHOD_GET_TOGGLE_MEM)(struct uverbs_attr_bund
 		if (!srq)
 			return -EINVAL;
 
+		if (srq->uctx != ib_uctx)
+			return -EINVAL;
+
 		addr = (u64)srq->uctx_srq_page;
 		break;
 
Signature · 1 line
2.39.3
author maintainer
#4 lore raw

PATCH 4/11 RDMA/bnxt_re: Avoid displaying the kernel pointer

In reply to Selvin Xavier

While dumping the info on MR using the rdma tool, we dump the mr_hwq which is a kernel pointer. There is no need to expose this value for end user. So avoid it.

Fixes 7363eb76b7f3 ("RDMA/bnxt_re: Support driver specific data collection using rdma tool")
---
 drivers/infiniband/hw/bnxt_re/main.c | 2 --
 1 file changed, 2 deletions(-)
drivers/infiniband/hw/bnxt_re/main.c +0 -2
index a892f1172917..d25fdc458120 100644
@@ -1093,8 +1093,6 @@ static int bnxt_re_fill_res_mr_entry(struct sk_buff *msg, struct ib_mr *ib_mr)
 		goto err;
 	if (rdma_nl_put_driver_u32(msg, "element_size", mr_hwq->element_size))
 		goto err;
-	if (rdma_nl_put_driver_u64_hex(msg, "hwq", (unsigned long)mr_hwq))
-		goto err;
 	if (rdma_nl_put_driver_u64_hex(msg, "va", mr->qplib_mr.va))
 		goto err;
 
Signature · 1 line
2.39.3
author maintainer
#5 lore raw

PATCH 5/11 RDMA/bnxt_re: Add a max slot check for SQ

In reply to Selvin Xavier

The variable WQE mode must be validated against the maximum slots supported by HW. The max supported value is 64K. Adding a max check and fail if user supplied value is more than the max supported.

Fixes d8ea645d6984 ("RDMA/bnxt_re: Handle variable WQE support for user applications")
---
 drivers/infiniband/hw/bnxt_re/ib_verbs.c | 3 +++
 drivers/infiniband/hw/bnxt_re/qplib_sp.h | 1 +
 2 files changed, 4 insertions(+)
drivers/infiniband/hw/bnxt_re/ib_verbs.c +3 -0
index eed918b9cdf1..eb428d2409d6 100644
@@ -1748,6 +1748,9 @@ static int bnxt_re_init_qp_attr(struct bnxt_re_qp *qp, struct bnxt_re_pd *pd,
 		return qptype;
 	qplqp->type = (u8)qptype;
 	qplqp->wqe_mode = bnxt_re_is_var_size_supported(rdev, uctx);
+	if (uctx && qplqp->wqe_mode == BNXT_QPLIB_WQE_MODE_VARIABLE &&
+	    ureq->sq_slots > BNXT_RE_MAX_SQ_SLOTS)
+		return -EINVAL;
 	if (fixed_que_attr) {
 		if (qplqp->wqe_mode != BNXT_QPLIB_WQE_MODE_VARIABLE)
 			return -EOPNOTSUPP;
drivers/infiniband/hw/bnxt_re/qplib_sp.h +1 -0
index 9fadd637cb5b..c4193ae75b54 100644
@@ -369,6 +369,7 @@ int bnxt_qplib_destroy_flow(struct bnxt_qplib_res *res);
 #define BNXT_VAR_MAX_SLOT_ALIGN 256
 #define BNXT_VAR_MAX_SGE        13
 #define BNXT_RE_MAX_RQ_WQES     65536
+#define BNXT_RE_MAX_SQ_SLOTS    65536
 
 #define BNXT_STATIC_MAX_SGE	6
 
Signature · 1 line
2.39.3
author maintainer
#6 lore raw

PATCH 6/11 RDMA/bnxt_re: Avoid repeated requests to allocate WC pages

In reply to Selvin Xavier

Applications can request for allocating multiple WC pages for the same ucontext. As of now, supporting only 1 WC page per ucontext. Adding a check to fail the repeated requests.

Fixes eee6268421a2 ("RDMA/bnxt_re: Move the UAPI methods to a dedicated file")
Fixes 360da60d6c6e ("RDMA/bnxt_re: Enable low latency push")
---
 drivers/infiniband/hw/bnxt_re/uapi.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/infiniband/hw/bnxt_re/uapi.c +3 -0
index 0fceaf52bf4d..abd8f90ca0fb 100644
@@ -99,6 +99,9 @@ static int UVERBS_HANDLER(BNXT_RE_METHOD_ALLOC_PAGE)(struct uverbs_attr_bundle *
 	switch (alloc_type) {
 	case BNXT_RE_ALLOC_WC_PAGE:
 		if (cctx->modes.db_push)  {
+			/* already allocated — one WC page per context */
+			if (uctx->wcdpi.dbr)
+				return -EEXIST;
 			if (bnxt_qplib_alloc_dpi(&rdev->qplib_res, &uctx->wcdpi,
 						 uctx, BNXT_QPLIB_DPI_TYPE_WC))
 				return -ENOMEM;
Signature · 1 line
2.39.3
author maintainer
#7 lore raw

Re: [PATCH 06/11] RDMA/bnxt_re: Avoid repeated requests to allocate WC pages

Quoted 18 lines · Selvin Xavier

Applications can request for allocating multiple WC pages for the same ucontext. As of now, supporting only 1 WC page per ucontext. Adding a check to fail the repeated requests.

Fixes eee6268421a2 ("RDMA/bnxt_re: Move the UAPI methods to a dedicated file")
Fixes 360da60d6c6e ("RDMA/bnxt_re: Enable low latency push")
---
 drivers/infiniband/hw/bnxt_re/uapi.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/infiniband/hw/bnxt_re/uapi.c +0 -0
index 0fceaf52bf4d..abd8f90ca0fb 100644

drivers/infiniband/hw/bnxt_re/uapi.c static int UVERBS_HANDLER(BNXT_RE_METHOD_ALLOC_PAGE)(struct uverbs_attr_bundle * · line 104

Quoted 6 lines
drivers/infiniband/hw/bnxt_re/uapi.c +3 -0
@@ -99,6 +99,9 @@ static int UVERBS_HANDLER(BNXT_RE_METHOD_ALLOC_PAGE)(struct uverbs_attr_bundle *
        switch (alloc_type) {
        case BNXT_RE_ALLOC_WC_PAGE:
                if (cctx->modes.db_push)  {
+                       /* already allocated — one WC page per context */
+                       if (uctx->wcdpi.dbr)
+                               return -EEXIST;

Sashiko pointed out a regression about a synchronization issue. I will rework on it. thanks.

Quoted 6 lines
drivers/infiniband/hw/bnxt_re/uapi.c +0 -1
                        if (bnxt_qplib_alloc_dpi(&rdev->qplib_res, &uctx->wcdpi,
                                                 uctx, BNXT_QPLIB_DPI_TYPE_WC))
                                return -ENOMEM;
--

2.39.3

author maintainer
#8 lore raw

PATCH 7/11 RDMA/bnxt_re: Avoid any race while handling the hash list of CQ

In reply to Selvin Xavier

Adding/Deleting to/from hash list needs to be synchronized with the traversing of the hash list. Adding a mutex for this synchronization to avoid any usage of the CQ structures after the CQ is freed.

Fixes e275919d9669 ("RDMA/bnxt_re: Share a page to expose per CQ info with userspace")
---
 drivers/infiniband/hw/bnxt_re/bnxt_re.h  | 1 +
 drivers/infiniband/hw/bnxt_re/ib_verbs.c | 4 ++++
 drivers/infiniband/hw/bnxt_re/main.c     | 1 +
 drivers/infiniband/hw/bnxt_re/uapi.c     | 2 ++
 4 files changed, 8 insertions(+)
drivers/infiniband/hw/bnxt_re/bnxt_re.h +1 -0
index 3a7ce4729fcf..c346dec14dec 100644
@@ -217,6 +217,7 @@ struct bnxt_re_dev {
 	struct delayed_work dbq_pacing_work;
 	DECLARE_HASHTABLE(cq_hash, MAX_CQ_HASH_BITS);
 	DECLARE_HASHTABLE(srq_hash, MAX_SRQ_HASH_BITS);
+	struct mutex			cq_hash_lock;  /* guards cq_hash  */
 	struct dentry			*dbg_root;
 	struct dentry			*qp_debugfs;
 	unsigned long			event_bitmap;
drivers/infiniband/hw/bnxt_re/ib_verbs.c +4 -0
index eb428d2409d6..15d54b718dbe 100644
@@ -3458,7 +3458,9 @@ int bnxt_re_destroy_cq(struct ib_cq *ib_cq, struct ib_udata *udata)
 
 	if (cctx->modes.toggle_bits & BNXT_QPLIB_CQ_TOGGLE_BIT) {
 		free_page((unsigned long)cq->uctx_cq_page);
+		mutex_lock(&rdev->cq_hash_lock);
 		hash_del(&cq->hash_entry);
+		mutex_unlock(&rdev->cq_hash_lock);
 	}
 	bnxt_qplib_destroy_cq(&rdev->qplib_res, &cq->qplib_cq);
 
@@ -3536,7 +3538,9 @@ int bnxt_re_create_user_cq(struct ib_cq *ibcq, const struct ib_cq_init_attr *att
 	spin_lock_init(&cq->cq_lock);
 
 	if (cctx->modes.toggle_bits & BNXT_QPLIB_CQ_TOGGLE_BIT) {
+		mutex_lock(&rdev->cq_hash_lock);
 		hash_add(rdev->cq_hash, &cq->hash_entry, cq->qplib_cq.id);
+		mutex_unlock(&rdev->cq_hash_lock);
 		/* Allocate a page */
 		cq->uctx_cq_page = (void *)get_zeroed_page(GFP_KERNEL);
 		if (!cq->uctx_cq_page) {
drivers/infiniband/hw/bnxt_re/main.c +1 -0
index d25fdc458120..8e6257a4e048 100644
@@ -2338,6 +2338,7 @@ static int bnxt_re_dev_init(struct bnxt_re_dev *rdev, u8 op_type)
 			bnxt_re_vf_res_config(rdev);
 	}
 	hash_init(rdev->cq_hash);
+	mutex_init(&rdev->cq_hash_lock);
 	if (rdev->chip_ctx->modes.toggle_bits & BNXT_QPLIB_SRQ_TOGGLE_BIT)
 		hash_init(rdev->srq_hash);
 
drivers/infiniband/hw/bnxt_re/uapi.c +2 -0
index abd8f90ca0fb..5f56db41a445 100644
@@ -26,12 +26,14 @@ static struct bnxt_re_cq *bnxt_re_search_for_cq(struct bnxt_re_dev *rdev, u32 cq
 {
 	struct bnxt_re_cq *cq = NULL, *tmp_cq;
 
+	mutex_lock(&rdev->cq_hash_lock);
 	hash_for_each_possible(rdev->cq_hash, tmp_cq, hash_entry, cq_id) {
 		if (tmp_cq->qplib_cq.id == cq_id) {
 			cq = tmp_cq;
 			break;
 		}
 	}
+	mutex_unlock(&rdev->cq_hash_lock);
 	return cq;
 }
 
Signature · 1 line
2.39.3
author maintainer
#9 lore raw

PATCH 8/11 RDMA/bnxt_re: Avoid any race while handling the hash list of SRQ

In reply to Selvin Xavier

Adding/Deleting to/from hash list needs to be synchronized with the traversing of the hash list. Adding a mutex for this synchronization to avoid any usage of the SRQ structures after the SRQ is freed.

Fixes 181028a0d84c ("RDMA/bnxt_re: Share a page to expose per SRQ info with userspace")
---
 drivers/infiniband/hw/bnxt_re/bnxt_re.h  | 1 +
 drivers/infiniband/hw/bnxt_re/ib_verbs.c | 4 ++++
 drivers/infiniband/hw/bnxt_re/main.c     | 1 +
 drivers/infiniband/hw/bnxt_re/uapi.c     | 2 ++
 4 files changed, 8 insertions(+)
drivers/infiniband/hw/bnxt_re/bnxt_re.h +1 -0
index c346dec14dec..5fec474fcc2e 100644
@@ -218,6 +218,7 @@ struct bnxt_re_dev {
 	DECLARE_HASHTABLE(cq_hash, MAX_CQ_HASH_BITS);
 	DECLARE_HASHTABLE(srq_hash, MAX_SRQ_HASH_BITS);
 	struct mutex			cq_hash_lock;  /* guards cq_hash  */
+	struct mutex			srq_hash_lock; /* guards srq_hash */
 	struct dentry			*dbg_root;
 	struct dentry			*qp_debugfs;
 	unsigned long			event_bitmap;
drivers/infiniband/hw/bnxt_re/ib_verbs.c +4 -0
index 15d54b718dbe..b415a3a25721 100644
@@ -2154,7 +2154,9 @@ int bnxt_re_destroy_srq(struct ib_srq *ib_srq, struct ib_udata *udata)
 
 	if (rdev->chip_ctx->modes.toggle_bits & BNXT_QPLIB_SRQ_TOGGLE_BIT) {
 		free_page((unsigned long)srq->uctx_srq_page);
+		mutex_lock(&rdev->srq_hash_lock);
 		hash_del(&srq->hash_entry);
+		mutex_unlock(&rdev->srq_hash_lock);
 	}
 	bnxt_qplib_destroy_srq(&rdev->qplib_res, qplib_srq);
 	ib_umem_release(srq->umem);
@@ -2264,7 +2266,9 @@ int bnxt_re_create_srq(struct ib_srq *ib_srq,
 
 		resp.srqid = srq->qplib_srq.id;
 		if (rdev->chip_ctx->modes.toggle_bits & BNXT_QPLIB_SRQ_TOGGLE_BIT) {
+			mutex_lock(&rdev->srq_hash_lock);
 			hash_add(rdev->srq_hash, &srq->hash_entry, srq->qplib_srq.id);
+			mutex_unlock(&rdev->srq_hash_lock);
 			srq->uctx_srq_page = (void *)get_zeroed_page(GFP_KERNEL);
 			if (!srq->uctx_srq_page) {
 				rc = -ENOMEM;
drivers/infiniband/hw/bnxt_re/main.c +1 -0
index 8e6257a4e048..6915fc3f1392 100644
@@ -2341,6 +2341,7 @@ static int bnxt_re_dev_init(struct bnxt_re_dev *rdev, u8 op_type)
 	mutex_init(&rdev->cq_hash_lock);
 	if (rdev->chip_ctx->modes.toggle_bits & BNXT_QPLIB_SRQ_TOGGLE_BIT)
 		hash_init(rdev->srq_hash);
+	mutex_init(&rdev->srq_hash_lock);
 
 	bnxt_re_debugfs_add_pdev(rdev);
 
drivers/infiniband/hw/bnxt_re/uapi.c +2 -0
index 5f56db41a445..54d7e99e47d2 100644
@@ -41,12 +41,14 @@ static struct bnxt_re_srq *bnxt_re_search_for_srq(struct bnxt_re_dev *rdev, u32
 {
 	struct bnxt_re_srq *srq = NULL, *tmp_srq;
 
+	mutex_lock(&rdev->srq_hash_lock);
 	hash_for_each_possible(rdev->srq_hash, tmp_srq, hash_entry, srq_id) {
 		if (tmp_srq->qplib_srq.id == srq_id) {
 			srq = tmp_srq;
 			break;
 		}
 	}
+	mutex_unlock(&rdev->srq_hash_lock);
 	return srq;
 }
 
Signature · 1 line
2.39.3
author maintainer
#10 lore raw

PATCH 9/11 RDMA/bnxt_re: Fix the cleanup upon error during srq create

In reply to Selvin Xavier

Fix the failure path of SRQ create. Destroy the SRQ from HW and delete from the hashlist if the page allocation fails. Also, add an explicit check for NULL before calling free_page.

Fixes 181028a0d84c ("RDMA/bnxt_re: Share a page to expose per SRQ info with userspace")
---
 drivers/infiniband/hw/bnxt_re/ib_verbs.c | 9 +++++++++
 1 file changed, 9 insertions(+)
drivers/infiniband/hw/bnxt_re/ib_verbs.c +9 -0
index b415a3a25721..3d5659442c29 100644
@@ -2272,6 +2272,8 @@ int bnxt_re_create_srq(struct ib_srq *ib_srq,
 			srq->uctx_srq_page = (void *)get_zeroed_page(GFP_KERNEL);
 			if (!srq->uctx_srq_page) {
 				rc = -ENOMEM;
+				bnxt_qplib_destroy_srq(&rdev->qplib_res,
+						       &srq->qplib_srq);
 				goto fail;
 			}
 			resp.comp_mask |= BNXT_RE_SRQ_TOGGLE_PAGE_SUPPORT;
@@ -2291,6 +2293,13 @@ int bnxt_re_create_srq(struct ib_srq *ib_srq,
 	return 0;
 
 fail:
+	if (rdev->chip_ctx->modes.toggle_bits & BNXT_QPLIB_SRQ_TOGGLE_BIT) {
+		mutex_lock(&rdev->srq_hash_lock);
+		hash_del(&srq->hash_entry);
+		mutex_unlock(&rdev->srq_hash_lock);
+		if (srq->uctx_srq_page)
+			free_page((unsigned long)srq->uctx_srq_page);
+	}
 	ib_umem_release(srq->umem);
 exit:
 	return rc;
Signature · 1 line
2.39.3
author maintainer
#11 lore raw

PATCH 10/11 RDMA/bnxt_re: Fix the cleanup upon error during CQ create

In reply to Selvin Xavier

Fix the failure path of SRQ create. Destroy the SRQ from HW and delete from the hashlist if the page allocation fails. Also, add an explicit check for NULL before calling free_page.

Fixes e275919d9669 ("RDMA/bnxt_re: Share a page to expose per CQ info with userspace")
---
 drivers/infiniband/hw/bnxt_re/ib_verbs.c | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)
drivers/infiniband/hw/bnxt_re/ib_verbs.c +10 -3
index 3d5659442c29..dd1afa4a2b2c 100644
@@ -3568,14 +3568,21 @@ int bnxt_re_create_user_cq(struct ib_cq *ibcq, const struct ib_cq_init_attr *att
 	resp.phase = cq->qplib_cq.period;
 	rc = ib_respond_udata(udata, resp);
 	if (rc)
-		goto free_mem;
+		goto free_page;
 
 	return 0;
 
-free_mem:
-	free_page((unsigned long)cq->uctx_cq_page);
+free_page:
+	if (cq->uctx_cq_page)
+		free_page((unsigned long)cq->uctx_cq_page);
+
 destroy_cq:
 	bnxt_qplib_destroy_cq(&rdev->qplib_res, &cq->qplib_cq);
+	if (cctx->modes.toggle_bits & BNXT_QPLIB_CQ_TOGGLE_BIT) {
+		mutex_lock(&rdev->cq_hash_lock);
+		hash_del(&cq->hash_entry);
+		mutex_unlock(&rdev->cq_hash_lock);
+	}
 free_umem:
 	ib_umem_release(cq->umem);
 	return rc;
Signature · 1 line
2.39.3
author maintainer
#12 lore raw

PATCH 11/11 RDMA/bnxt_re: Fail DBR related page allocation UAPIs if the feature is disabled

In reply to Selvin Xavier

No need to support the DBR related page allocations if the pacing feature is disabled. Fail the request if pacing is disabled.

Fixes ea2224857882 ("RDMA/bnxt_re: Update alloc_page uapi for pacing")
---
 drivers/infiniband/hw/bnxt_re/uapi.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/infiniband/hw/bnxt_re/uapi.c +4 -0
index 54d7e99e47d2..3621a9972170 100644
@@ -119,12 +119,16 @@ static int UVERBS_HANDLER(BNXT_RE_METHOD_ALLOC_PAGE)(struct uverbs_attr_bundle *
 
 		break;
 	case BNXT_RE_ALLOC_DBR_BAR_PAGE:
+		if (!rdev->pacing.dbr_pacing)
+			return -EOPNOTSUPP;
 		length = PAGE_SIZE;
 		addr = (u64)rdev->pacing.dbr_bar_addr;
 		mmap_flag = BNXT_RE_MMAP_DBR_BAR;
 		break;
 
 	case BNXT_RE_ALLOC_DBR_PAGE:
+		if (!rdev->pacing.dbr_pacing)
+			return -EOPNOTSUPP;
 		length = PAGE_SIZE;
 		addr = (u64)rdev->pacing.dbr_page;
 		mmap_flag = BNXT_RE_MMAP_DBR_PAGE;
Signature · 1 line
2.39.3