Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a52c8e24 authored by Leon Romanovsky's avatar Leon Romanovsky Committed by Doug Ledford
Browse files

RDMA: Clean destroy CQ in drivers do not return errors



Like all other destroy commands, .destroy_cq() call is not supposed
to fail. In all flows, the attempt to return earlier caused to memory
leaks.

This patch converts .destroy_cq() to do not return any errors.

Signed-off-by: default avatarLeon Romanovsky <leonro@mellanox.com>
Acked-by: default avatarGal Pressman <galpress@amazon.com>
Acked-by: default avatarDennis Dalessandro <dennis.dalessandro@intel.com>
Signed-off-by: default avatarDoug Ledford <dledford@redhat.com>
parent 147b308e
Loading
Loading
Loading
Loading
+1 −4
Original line number Diff line number Diff line
@@ -207,8 +207,6 @@ EXPORT_SYMBOL(__ib_alloc_cq_user);
 */
void ib_free_cq_user(struct ib_cq *cq, struct ib_udata *udata)
{
	int ret;

	if (WARN_ON_ONCE(atomic_read(&cq->usecnt)))
		return;

@@ -228,7 +226,6 @@ void ib_free_cq_user(struct ib_cq *cq, struct ib_udata *udata)

	kfree(cq->wc);
	rdma_restrack_del(&cq->res);
	ret = cq->device->ops.destroy_cq(cq, udata);
	WARN_ON_ONCE(ret);
	cq->device->ops.destroy_cq(cq, udata);
}
EXPORT_SYMBOL(ib_free_cq_user);
+2 −1
Original line number Diff line number Diff line
@@ -1949,7 +1949,8 @@ int ib_destroy_cq_user(struct ib_cq *cq, struct ib_udata *udata)
		return -EBUSY;

	rdma_restrack_del(&cq->res);
	return cq->device->ops.destroy_cq(cq, udata);
	cq->device->ops.destroy_cq(cq, udata);
	return 0;
}
EXPORT_SYMBOL(ib_destroy_cq_user);

+3 −10
Original line number Diff line number Diff line
@@ -2517,9 +2517,8 @@ int bnxt_re_post_recv(struct ib_qp *ib_qp, const struct ib_recv_wr *wr,
}

/* Completion Queues */
int bnxt_re_destroy_cq(struct ib_cq *ib_cq, struct ib_udata *udata)
void bnxt_re_destroy_cq(struct ib_cq *ib_cq, struct ib_udata *udata)
{
	int rc;
	struct bnxt_re_cq *cq;
	struct bnxt_qplib_nq *nq;
	struct bnxt_re_dev *rdev;
@@ -2528,20 +2527,14 @@ int bnxt_re_destroy_cq(struct ib_cq *ib_cq, struct ib_udata *udata)
	rdev = cq->rdev;
	nq = cq->qplib_cq.nq;

	rc = bnxt_qplib_destroy_cq(&rdev->qplib_res, &cq->qplib_cq);
	if (rc) {
		dev_err(rdev_to_dev(rdev), "Failed to destroy HW CQ");
		return rc;
	}
	if (!IS_ERR_OR_NULL(cq->umem))
	bnxt_qplib_destroy_cq(&rdev->qplib_res, &cq->qplib_cq);
	if (!cq->umem)
		ib_umem_release(cq->umem);

	atomic_dec(&rdev->cq_count);
	nq->budget--;
	kfree(cq->cql);
	kfree(cq);

	return 0;
}

struct ib_cq *bnxt_re_create_cq(struct ib_device *ibdev,
+1 −1
Original line number Diff line number Diff line
@@ -193,7 +193,7 @@ int bnxt_re_post_recv(struct ib_qp *qp, const struct ib_recv_wr *recv_wr,
struct ib_cq *bnxt_re_create_cq(struct ib_device *ibdev,
				const struct ib_cq_init_attr *attr,
				struct ib_udata *udata);
int bnxt_re_destroy_cq(struct ib_cq *cq, struct ib_udata *udata);
void bnxt_re_destroy_cq(struct ib_cq *cq, struct ib_udata *udata);
int bnxt_re_poll_cq(struct ib_cq *cq, int num_entries, struct ib_wc *wc);
int bnxt_re_req_notify_cq(struct ib_cq *cq, enum ib_cq_notify_flags flags);
struct ib_mr *bnxt_re_get_dma_mr(struct ib_pd *pd, int mr_access_flags);
+2 −4
Original line number Diff line number Diff line
@@ -303,17 +303,15 @@ int cxio_create_qp(struct cxio_rdev *rdev_p, u32 kernel_domain,
	return -ENOMEM;
}

int cxio_destroy_cq(struct cxio_rdev *rdev_p, struct t3_cq *cq)
void cxio_destroy_cq(struct cxio_rdev *rdev_p, struct t3_cq *cq)
{
	int err;
	err = cxio_hal_clear_cq_ctx(rdev_p, cq->cqid);
	cxio_hal_clear_cq_ctx(rdev_p, cq->cqid);
	kfree(cq->sw_queue);
	dma_free_coherent(&(rdev_p->rnic_info.pdev->dev),
			  (1UL << (cq->size_log2))
			  * sizeof(struct t3_cqe) + 1, cq->queue,
			  dma_unmap_addr(cq, mapping));
	cxio_hal_put_cqid(rdev_p->rscp, cq->cqid);
	return err;
}

int cxio_destroy_qp(struct cxio_rdev *rdev_p, struct t3_wq *wq,
Loading