From: Zhiping Zhang <zhipingz@meta.com>
To: Jason Gunthorpe <jgg@ziepe.ca>, Leon Romanovsky <leon@kernel.org>,
Bjorn Helgaas <bhelgaas@google.com>, <linux-rdma@vger.kernel.org>,
<linux-pci@vger.kernel.org>, <netdev@vger.kernel.org>,
<dri-devel@lists.freedesktop.org>,
Keith Busch <kbusch@kernel.org>, Yochai Cohen <yochai@nvidia.com>,
Yishai Hadas <yishaih@nvidia.com>
Cc: Bjorn Helgaas <helgaas@kernel.org>, Zhiping Zhang <zhipingz@meta.com>
Subject: [RFC 2/2] RMDA MLX5: get tph for p2p access when registering dmabuf mr
Date: Tue, 10 Feb 2026 11:39:55 -0800 [thread overview]
Message-ID: <20260210194014.2147481-3-zhipingz@meta.com> (raw)
In-Reply-To: <20260210194014.2147481-1-zhipingz@meta.com>
The patch adds a local function to check and get tph info when available during
dmabuf mr registration. Note the DMAH workflow for CPU still takes precedence in
the process. Currently, it only works with the direct st_mode. Compatibility
with other st_modes will be added in the formal patch set.
Signed-off-by: Zhiping Zhang <zhipingz@meta.com>
---
drivers/infiniband/hw/mlx5/mr.c | 30 ++++++++++++++++++++++++++++++
1 file changed, 30 insertions(+)
diff --git a/drivers/infiniband/hw/mlx5/mr.c b/drivers/infiniband/hw/mlx5/mr.c
index 325fa04cbe8a..c3eb5b24ef29 100644
--- a/drivers/infiniband/hw/mlx5/mr.c
+++ b/drivers/infiniband/hw/mlx5/mr.c
@@ -46,6 +46,8 @@
#include "data_direct.h"
#include "dmah.h"
+MODULE_IMPORT_NS("DMA_BUF");
+
enum {
MAX_PENDING_REG_MR = 8,
};
@@ -1623,6 +1625,32 @@ static struct dma_buf_attach_ops mlx5_ib_dmabuf_attach_ops = {
.move_notify = mlx5_ib_dmabuf_invalidate_cb,
};
+static void get_tph_mr_dmabuf(struct mlx5_ib_dev *dev, int fd, u16 *st_index,
+ u8 *ph)
+{
+ int ret;
+ struct dma_buf *dmabuf;
+
+ dmabuf = dma_buf_get(fd);
+ if (IS_ERR(dmabuf))
+ return;
+
+ if (!dmabuf->ops->get_tph)
+ goto end_dbuf_put;
+
+ ret = dmabuf->ops->get_tph(dmabuf, st_index, ph);
+
+ if (ret) {
+ *st_index = MLX5_MKC_PCIE_TPH_NO_STEERING_TAG_INDEX;
+ *ph = MLX5_IB_NO_PH;
+ mlx5_ib_dbg(dev, "get_tph failed (%d)\n", ret);
+ goto end_dbuf_put;
+ }
+
+end_dbuf_put:
+ dma_buf_put(dmabuf);
+};
+
static struct ib_mr *
reg_user_mr_dmabuf(struct ib_pd *pd, struct device *dma_device,
u64 offset, u64 length, u64 virt_addr,
@@ -1662,6 +1690,8 @@ reg_user_mr_dmabuf(struct ib_pd *pd, struct device *dma_device,
ph = dmah->ph;
if (dmah->valid_fields & BIT(IB_DMAH_CPU_ID_EXISTS))
st_index = mdmah->st_index;
+ } else {
+ get_tph_mr_dmabuf(dev, fd, &st_index, &ph);
}
mr = alloc_cacheable_mr(pd, &umem_dmabuf->umem, virt_addr,
--
2.47.3
next prev parent reply other threads:[~2026-02-10 19:47 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-10 19:39 [RFC 0/2] Retrieve tph from dmabuf for PCIe P2P memory access Zhiping Zhang
2026-02-10 19:39 ` [RFC 1/2] Vfio: add callback to get tph info for dmabuf Zhiping Zhang
2026-02-27 0:56 ` Keith Busch
2026-03-06 19:27 ` Zhiping Zhang
2026-02-10 19:39 ` Zhiping Zhang [this message]
2026-02-27 1:21 ` [RFC 2/2] RMDA MLX5: get tph for p2p access when registering dmabuf mr Keith Busch
2026-03-01 17:55 ` Jason Gunthorpe
2026-03-06 20:48 ` Zhiping Zhang
-- strict thread matches above, loose matches on Subject: below --
2026-02-09 17:53 [RFC 0/2] Retrieve tph from dmabuf for PCIe P2P memory access Zhiping Zhang
2026-02-09 17:53 ` [RFC 2/2] RMDA MLX5: get tph for p2p access when registering dmabuf mr Zhiping Zhang
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=20260210194014.2147481-3-zhipingz@meta.com \
--to=zhipingz@meta.com \
--cc=bhelgaas@google.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=helgaas@kernel.org \
--cc=jgg@ziepe.ca \
--cc=kbusch@kernel.org \
--cc=leon@kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=linux-rdma@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=yishaih@nvidia.com \
--cc=yochai@nvidia.com \
/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