public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
From: Long Li <longli@microsoft.com>
To: Long Li <longli@microsoft.com>,
	Konstantin Taranov <kotaranov@microsoft.com>,
	Jakub Kicinski <kuba@kernel.org>,
	"David S . Miller" <davem@davemloft.net>,
	Paolo Abeni <pabeni@redhat.com>,
	Eric Dumazet <edumazet@google.com>,
	Andrew Lunn <andrew+netdev@lunn.ch>,
	Jason Gunthorpe <jgg@ziepe.ca>, Leon Romanovsky <leon@kernel.org>,
	Haiyang Zhang <haiyangz@microsoft.com>,
	"K . Y . Srinivasan" <kys@microsoft.com>,
	Wei Liu <wei.liu@kernel.org>, Dexuan Cui <decui@microsoft.com>
Cc: Simon Horman <horms@kernel.org>,
	netdev@vger.kernel.org, linux-rdma@vger.kernel.org,
	linux-hyperv@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH rdma-next 5/8] RDMA/mana_ib: Track QP per ucontext
Date: Fri,  6 Mar 2026 17:47:19 -0800	[thread overview]
Message-ID: <20260307014723.556523-6-longli@microsoft.com> (raw)
In-Reply-To: <20260307014723.556523-1-longli@microsoft.com>

Add per-ucontext list tracking for QP objects. Only RAW_PACKET QPs
are tracked since they persist across reset events. RC, UD and GSI
QPs are removed and re-added during reset by IB core and do not
need tracking.

Signed-off-by: Long Li <longli@microsoft.com>
---
 drivers/infiniband/hw/mana/main.c    |  1 +
 drivers/infiniband/hw/mana/mana_ib.h |  2 ++
 drivers/infiniband/hw/mana/qp.c      | 47 ++++++++++++++++++++++------
 3 files changed, 40 insertions(+), 10 deletions(-)

diff --git a/drivers/infiniband/hw/mana/main.c b/drivers/infiniband/hw/mana/main.c
index e6da5c8400f4..c6a859628ba3 100644
--- a/drivers/infiniband/hw/mana/main.c
+++ b/drivers/infiniband/hw/mana/main.c
@@ -244,6 +244,7 @@ int mana_ib_alloc_ucontext(struct ib_ucontext *ibcontext,
 	mutex_init(&ucontext->lock);
 	INIT_LIST_HEAD(&ucontext->pd_list);
 	INIT_LIST_HEAD(&ucontext->cq_list);
+	INIT_LIST_HEAD(&ucontext->qp_list);
 	INIT_LIST_HEAD(&ucontext->wq_list);
 
 	mutex_lock(&mdev->ucontext_lock);
diff --git a/drivers/infiniband/hw/mana/mana_ib.h b/drivers/infiniband/hw/mana/mana_ib.h
index 96b5a13470ae..9d90fda2c830 100644
--- a/drivers/infiniband/hw/mana/mana_ib.h
+++ b/drivers/infiniband/hw/mana/mana_ib.h
@@ -198,6 +198,7 @@ struct mana_ib_qp {
 
 	refcount_t		refcount;
 	struct completion	free;
+	struct list_head	ucontext_list;
 };
 
 struct mana_ib_ucontext {
@@ -208,6 +209,7 @@ struct mana_ib_ucontext {
 	struct mutex lock;
 	struct list_head pd_list;
 	struct list_head cq_list;
+	struct list_head qp_list;
 	struct list_head wq_list;
 };
 
diff --git a/drivers/infiniband/hw/mana/qp.c b/drivers/infiniband/hw/mana/qp.c
index 82f84f7ad37a..315bc54d8ae6 100644
--- a/drivers/infiniband/hw/mana/qp.c
+++ b/drivers/infiniband/hw/mana/qp.c
@@ -700,14 +700,31 @@ static int mana_ib_create_ud_qp(struct ib_qp *ibqp, struct ib_pd *ibpd,
 int mana_ib_create_qp(struct ib_qp *ibqp, struct ib_qp_init_attr *attr,
 		      struct ib_udata *udata)
 {
+	struct mana_ib_qp *qp = container_of(ibqp, struct mana_ib_qp, ibqp);
+	int err;
+
+	INIT_LIST_HEAD(&qp->ucontext_list);
+
 	switch (attr->qp_type) {
 	case IB_QPT_RAW_PACKET:
 		/* When rwq_ind_tbl is used, it's for creating WQs for RSS */
 		if (attr->rwq_ind_tbl)
-			return mana_ib_create_qp_rss(ibqp, ibqp->pd, attr,
-						     udata);
+			err = mana_ib_create_qp_rss(ibqp, ibqp->pd, attr,
+						    udata);
+		else
+			err = mana_ib_create_qp_raw(ibqp, ibqp->pd, attr,
+						    udata);
+
+		if (!err && udata) {
+			struct mana_ib_ucontext *mana_ucontext =
+				rdma_udata_to_drv_context(udata,
+					struct mana_ib_ucontext, ibucontext);
+			mutex_lock(&mana_ucontext->lock);
+			list_add_tail(&qp->ucontext_list, &mana_ucontext->qp_list);
+			mutex_unlock(&mana_ucontext->lock);
+		}
 
-		return mana_ib_create_qp_raw(ibqp, ibqp->pd, attr, udata);
+		return err;
 	case IB_QPT_RC:
 		return mana_ib_create_rc_qp(ibqp, ibqp->pd, attr, udata);
 	case IB_QPT_UD:
@@ -716,9 +733,8 @@ int mana_ib_create_qp(struct ib_qp *ibqp, struct ib_qp_init_attr *attr,
 	default:
 		ibdev_dbg(ibqp->device, "Creating QP type %u not supported\n",
 			  attr->qp_type);
+		return -EINVAL;
 	}
-
-	return -EINVAL;
 }
 
 static int mana_ib_gd_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr,
@@ -898,14 +914,26 @@ static int mana_ib_destroy_ud_qp(struct mana_ib_qp *qp, struct ib_udata *udata)
 int mana_ib_destroy_qp(struct ib_qp *ibqp, struct ib_udata *udata)
 {
 	struct mana_ib_qp *qp = container_of(ibqp, struct mana_ib_qp, ibqp);
+	int ret = -ENOENT;
 
 	switch (ibqp->qp_type) {
 	case IB_QPT_RAW_PACKET:
+		if (udata) {
+			struct mana_ib_ucontext *mana_ucontext =
+				rdma_udata_to_drv_context(udata,
+					struct mana_ib_ucontext, ibucontext);
+			mutex_lock(&mana_ucontext->lock);
+			list_del_init(&qp->ucontext_list);
+			mutex_unlock(&mana_ucontext->lock);
+		}
+
 		if (ibqp->rwq_ind_tbl)
-			return mana_ib_destroy_qp_rss(qp, ibqp->rwq_ind_tbl,
-						      udata);
+			ret = mana_ib_destroy_qp_rss(qp, ibqp->rwq_ind_tbl,
+						     udata);
+		else
+			ret = mana_ib_destroy_qp_raw(qp, udata);
 
-		return mana_ib_destroy_qp_raw(qp, udata);
+		return ret;
 	case IB_QPT_RC:
 		return mana_ib_destroy_rc_qp(qp, udata);
 	case IB_QPT_UD:
@@ -914,7 +942,6 @@ int mana_ib_destroy_qp(struct ib_qp *ibqp, struct ib_udata *udata)
 	default:
 		ibdev_dbg(ibqp->device, "Unexpected QP type %u\n",
 			  ibqp->qp_type);
+		return ret;
 	}
-
-	return -ENOENT;
 }
-- 
2.43.0


  parent reply	other threads:[~2026-03-07  1:47 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-07  1:47 [PATCH rdma-next 0/8] RDMA/mana_ib: Handle service reset for RDMA resources Long Li
2026-03-07  1:47 ` [PATCH rdma-next 1/8] RDMA/mana_ib: Track ucontext per device Long Li
2026-03-07  1:47 ` [PATCH rdma-next 2/8] RDMA/mana_ib: Track PD per ucontext Long Li
2026-03-07  1:47 ` [PATCH rdma-next 3/8] RDMA/mana_ib: Track CQ " Long Li
2026-03-07  1:47 ` [PATCH rdma-next 4/8] RDMA/mana_ib: Track WQ " Long Li
2026-03-07  1:47 ` Long Li [this message]
2026-03-07  1:47 ` [PATCH rdma-next 6/8] RDMA/mana_ib: Track MR " Long Li
2026-03-07  1:47 ` [PATCH rdma-next 7/8] RDMA/mana_ib: Notify service reset events to RDMA devices Long Li
2026-03-07  1:47 ` [PATCH rdma-next 8/8] RDMA/mana_ib: Skip firmware commands for invalidated handles Long Li
2026-03-07 17:38 ` [PATCH rdma-next 0/8] RDMA/mana_ib: Handle service reset for RDMA resources Leon Romanovsky
2026-03-13 16:59   ` Jason Gunthorpe
2026-03-16 20:08     ` Leon Romanovsky
2026-03-17 23:43       ` [EXTERNAL] " Long Li
2026-03-18 14:49         ` Leon Romanovsky
2026-03-21  0:49           ` Long Li

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260307014723.556523-6-longli@microsoft.com \
    --to=longli@microsoft.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=decui@microsoft.com \
    --cc=edumazet@google.com \
    --cc=haiyangz@microsoft.com \
    --cc=horms@kernel.org \
    --cc=jgg@ziepe.ca \
    --cc=kotaranov@microsoft.com \
    --cc=kuba@kernel.org \
    --cc=kys@microsoft.com \
    --cc=leon@kernel.org \
    --cc=linux-hyperv@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=wei.liu@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox