All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH for-rc] rdma/qedr: Fix crash due to redundant release of device's qp memory
@ 2021-10-19  8:22 Prabhakar Kushwaha
  2021-10-19 23:28 ` Jason Gunthorpe
  0 siblings, 1 reply; 2+ messages in thread
From: Prabhakar Kushwaha @ 2021-10-19  8:22 UTC (permalink / raw)
  To: linux-rdma, dledford, jgg, mkalderon
  Cc: davem, kuba, smalin, aelior, palok, pkushwaha, prabhakar.pkin, malin1024

Device's QP memory should only be allocated and released by IB layer.
This patch removes the redundant release of the device's qp memory
and uses completion APIs to make sure that .destroy_qp() only return,
when qp reference becomes 0.

Fixes: 514aee660df4 ("RDMA: Globally allocate and release QP memory")
Acked-by: Michal Kalderon <michal.kalderon@marvell.com>
Signed-off-by: Ariel Elior <aelior@marvell.com>
Signed-off-by: Shai Malin <smalin@marvell.com>
Signed-off-by: Alok Prasad <palok@marvell.com>
Signed-off-by: Prabhakar Kushwaha <pkushwaha@marvell.com>
---
 drivers/infiniband/hw/qedr/qedr.h       | 1 +
 drivers/infiniband/hw/qedr/qedr_iw_cm.c | 2 +-
 drivers/infiniband/hw/qedr/verbs.c      | 5 ++++-
 3 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/infiniband/hw/qedr/qedr.h b/drivers/infiniband/hw/qedr/qedr.h
index 3cb4febaad0f..8def88cfa300 100644
--- a/drivers/infiniband/hw/qedr/qedr.h
+++ b/drivers/infiniband/hw/qedr/qedr.h
@@ -455,6 +455,7 @@ struct qedr_qp {
 	/* synchronization objects used with iwarp ep */
 	struct kref refcnt;
 	struct completion iwarp_cm_comp;
+	struct completion qp_rel_comp;
 	unsigned long iwarp_cm_flags; /* enum iwarp_cm_flags */
 };
 
diff --git a/drivers/infiniband/hw/qedr/qedr_iw_cm.c b/drivers/infiniband/hw/qedr/qedr_iw_cm.c
index 1715fbe0719d..a51fc6854984 100644
--- a/drivers/infiniband/hw/qedr/qedr_iw_cm.c
+++ b/drivers/infiniband/hw/qedr/qedr_iw_cm.c
@@ -83,7 +83,7 @@ static void qedr_iw_free_qp(struct kref *ref)
 {
 	struct qedr_qp *qp = container_of(ref, struct qedr_qp, refcnt);
 
-	kfree(qp);
+	complete(&qp->qp_rel_comp);
 }
 
 static void
diff --git a/drivers/infiniband/hw/qedr/verbs.c b/drivers/infiniband/hw/qedr/verbs.c
index 3fbf172dbbef..dcb3653db72d 100644
--- a/drivers/infiniband/hw/qedr/verbs.c
+++ b/drivers/infiniband/hw/qedr/verbs.c
@@ -1357,6 +1357,7 @@ static void qedr_set_common_qp_params(struct qedr_dev *dev,
 	if (rdma_protocol_iwarp(&dev->ibdev, 1)) {
 		kref_init(&qp->refcnt);
 		init_completion(&qp->iwarp_cm_comp);
+		init_completion(&qp->qp_rel_comp);
 	}
 
 	qp->pd = pd;
@@ -2857,8 +2858,10 @@ int qedr_destroy_qp(struct ib_qp *ibqp, struct ib_udata *udata)
 
 	qedr_free_qp_resources(dev, qp, udata);
 
-	if (rdma_protocol_iwarp(&dev->ibdev, 1))
+	if (rdma_protocol_iwarp(&dev->ibdev, 1)) {
 		qedr_iw_qp_rem_ref(&qp->ibqp);
+		wait_for_completion(&qp->qp_rel_comp);
+	}
 
 	return 0;
 }
-- 
2.24.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH for-rc] rdma/qedr: Fix crash due to redundant release of device's qp memory
  2021-10-19  8:22 [PATCH for-rc] rdma/qedr: Fix crash due to redundant release of device's qp memory Prabhakar Kushwaha
@ 2021-10-19 23:28 ` Jason Gunthorpe
  0 siblings, 0 replies; 2+ messages in thread
From: Jason Gunthorpe @ 2021-10-19 23:28 UTC (permalink / raw)
  To: Prabhakar Kushwaha
  Cc: linux-rdma, dledford, mkalderon, davem, kuba, smalin, aelior,
	palok, prabhakar.pkin, malin1024

On Tue, Oct 19, 2021 at 11:22:12AM +0300, Prabhakar Kushwaha wrote:
> Device's QP memory should only be allocated and released by IB layer.
> This patch removes the redundant release of the device's qp memory
> and uses completion APIs to make sure that .destroy_qp() only return,
> when qp reference becomes 0.
> 
> Fixes: 514aee660df4 ("RDMA: Globally allocate and release QP memory")
> Acked-by: Michal Kalderon <michal.kalderon@marvell.com>
> Signed-off-by: Ariel Elior <aelior@marvell.com>
> Signed-off-by: Shai Malin <smalin@marvell.com>
> Signed-off-by: Alok Prasad <palok@marvell.com>
> Signed-off-by: Prabhakar Kushwaha <pkushwaha@marvell.com>
> ---
>  drivers/infiniband/hw/qedr/qedr.h       | 1 +
>  drivers/infiniband/hw/qedr/qedr_iw_cm.c | 2 +-
>  drivers/infiniband/hw/qedr/verbs.c      | 5 ++++-
>  3 files changed, 6 insertions(+), 2 deletions(-)

Applied to for-rc, thanks

Jason

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-10-19 23:28 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-19  8:22 [PATCH for-rc] rdma/qedr: Fix crash due to redundant release of device's qp memory Prabhakar Kushwaha
2021-10-19 23:28 ` Jason Gunthorpe

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.