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 2/8] RDMA/mana_ib: Track PD per ucontext
Date: Fri, 6 Mar 2026 17:47:16 -0800 [thread overview]
Message-ID: <20260307014723.556523-3-longli@microsoft.com> (raw)
In-Reply-To: <20260307014723.556523-1-longli@microsoft.com>
Add per-ucontext list tracking for PD objects. Each PD is added to
the ucontext's pd_list on creation and removed on destruction. This
enables iterating over all PDs belonging to a ucontext, which will
be needed for service reset cleanup.
Signed-off-by: Long Li <longli@microsoft.com>
---
drivers/infiniband/hw/mana/main.c | 21 +++++++++++++++++++++
drivers/infiniband/hw/mana/mana_ib.h | 2 ++
2 files changed, 23 insertions(+)
diff --git a/drivers/infiniband/hw/mana/main.c b/drivers/infiniband/hw/mana/main.c
index fc28bdafcfd6..62d89ca06ba1 100644
--- a/drivers/infiniband/hw/mana/main.c
+++ b/drivers/infiniband/hw/mana/main.c
@@ -72,6 +72,7 @@ int mana_ib_alloc_pd(struct ib_pd *ibpd, struct ib_udata *udata)
struct ib_device *ibdev = ibpd->device;
struct gdma_create_pd_resp resp = {};
struct gdma_create_pd_req req = {};
+ struct mana_ib_ucontext *mana_ucontext;
enum gdma_pd_flags flags = 0;
struct mana_ib_dev *dev;
struct gdma_context *gc;
@@ -107,6 +108,16 @@ int mana_ib_alloc_pd(struct ib_pd *ibpd, struct ib_udata *udata)
mutex_init(&pd->vport_mutex);
pd->vport_use_count = 0;
+
+ INIT_LIST_HEAD(&pd->ucontext_list);
+ if (udata) {
+ mana_ucontext = rdma_udata_to_drv_context(udata,
+ struct mana_ib_ucontext, ibucontext);
+ mutex_lock(&mana_ucontext->lock);
+ list_add_tail(&pd->ucontext_list, &mana_ucontext->pd_list);
+ mutex_unlock(&mana_ucontext->lock);
+ }
+
return 0;
}
@@ -123,6 +134,15 @@ int mana_ib_dealloc_pd(struct ib_pd *ibpd, struct ib_udata *udata)
dev = container_of(ibdev, struct mana_ib_dev, ib_dev);
gc = mdev_to_gc(dev);
+ 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(&pd->ucontext_list);
+ mutex_unlock(&mana_ucontext->lock);
+ }
+
mana_gd_init_req_hdr(&req.hdr, GDMA_DESTROY_PD, sizeof(req),
sizeof(resp));
@@ -222,6 +242,7 @@ int mana_ib_alloc_ucontext(struct ib_ucontext *ibcontext,
ucontext->doorbell = doorbell_page;
mutex_init(&ucontext->lock);
+ INIT_LIST_HEAD(&ucontext->pd_list);
mutex_lock(&mdev->ucontext_lock);
list_add_tail(&ucontext->dev_list, &mdev->ucontext_list);
diff --git a/drivers/infiniband/hw/mana/mana_ib.h b/drivers/infiniband/hw/mana/mana_ib.h
index c7e333d3e9d8..6dba08bccc18 100644
--- a/drivers/infiniband/hw/mana/mana_ib.h
+++ b/drivers/infiniband/hw/mana/mana_ib.h
@@ -107,6 +107,7 @@ struct mana_ib_pd {
bool tx_shortform_allowed;
u32 tx_vp_offset;
+ struct list_head ucontext_list;
};
struct mana_ib_av {
@@ -203,6 +204,7 @@ struct mana_ib_ucontext {
struct list_head dev_list;
/* Protects resource lists below */
struct mutex lock;
+ struct list_head pd_list;
};
struct mana_ib_rwq_ind_table {
--
2.43.0
next prev parent reply other threads:[~2026-03-07 1:47 UTC|newest]
Thread overview: 16+ 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 ` Long Li [this message]
2026-03-07 1:47 ` [PATCH rdma-next 3/8] RDMA/mana_ib: Track CQ per ucontext Long Li
2026-03-07 1:47 ` [PATCH rdma-next 4/8] RDMA/mana_ib: Track WQ " Long Li
2026-03-07 1:47 ` [PATCH rdma-next 5/8] RDMA/mana_ib: Track QP " Long Li
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
2026-04-10 15:49 ` Jason Gunthorpe
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-3-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 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.