From: Zhiping Zhang <zhipingz@meta.com>
To: Alex Williamson <alex@shazbot.org>,
Jason Gunthorpe <jgg@ziepe.ca>, Leon Romanovsky <leon@kernel.org>
Cc: Bjorn Helgaas <helgaas@kernel.org>, <kvm@vger.kernel.org>,
<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>,
Zhiping Zhang <zhipingz@meta.com>
Subject: [PATCH v3 0/2] vfio/dma-buf: add TPH support for peer-to-peer access
Date: Tue, 12 May 2026 11:47:47 -0700 [thread overview]
Message-ID: <20260512184755.4137227-1-zhipingz@meta.com> (raw)
This series adds TLP Processing Hints (TPH) support to the VFIO dma-buf
export path, allowing importing drivers (e.g. mlx5) to use the exporter's
steering tag when performing peer-to-peer DMA into a VFIO-owned device.
Patch 1 adds the dma-buf get_tph callback and the new vfio uAPI.
Patch 2 wires up the mlx5 RDMA driver as a consumer.
Changes since v2:
- uAPI now carries both the 8-bit ST and 16-bit Extended ST values,
gated by a flags field, because the two are distinct namespaces in
the PCIe TPH ST table and a numeric range check on a single value
cannot pick the right one.
- Add pcie_tph_get_st_width() in <linux/pci-tph.h> so mlx5 doesn't
dereference pci_dev::tph_req_type directly.
- Validate that the TLP Processing Hint fits in the 2-bit spec field
in VFIO_DEVICE_FEATURE_DMA_BUF_TPH; previously an out-of-range
userspace value would be stored unchecked.
- Publish/consume ordering for the TPH metadata: writers store the
flags last with smp_store_release() under memory_lock; readers run
lockless with smp_load_acquire() on the flags. This avoids an
unprotected read in get_tph() and removes the AB-BA risk that
would appear if the reader took memory_lock while an importer held
dma_resv_lock.
- Convert vfio_pci_dma_buf::revoked from a bitfield to bool to
eliminate the cross-lock RMW on a shared bitfield byte (revoked is
written under dma_resv_lock; the new TPH fields are written under
memory_lock).
- mlx5 reuses the dma_buf pointer that the umem already resolved
instead of calling dma_buf_get(fd) a second time, closing a TOCTOU
where a concurrent dup2() could substitute a different dma_buf
between umem creation and the TPH lookup.
- mlx5 now tracks per-MR ownership of the allocated steering-tag
index (dmabuf_st_index / dmabuf_st_owned on mlx5_ib_mr) and frees
it both when the firmware mkey is destroyed and when the MR is
revoked-and-recycled into the FRMR pool.
Previous link:
v2: https://lore.kernel.org/linux-pci/20260430200704.352228-1-zhipingz@meta.com/
Zhiping Zhang (2):
vfio: add dma-buf get_tph callback and DMA_BUF_TPH feature
RDMA/mlx5: get tph for p2p access when registering dma-buf mr
drivers/infiniband/hw/mlx5/mlx5_ib.h | 6 +
drivers/infiniband/hw/mlx5/mr.c | 72 ++++++++++-
.../net/ethernet/mellanox/mlx5/core/lib/st.c | 27 +++--
drivers/pci/tph.c | 20 ++++
drivers/vfio/pci/vfio_pci_core.c | 3 +
drivers/vfio/pci/vfio_pci_dmabuf.c | 113 +++++++++++++++++-
drivers/vfio/pci/vfio_pci_priv.h | 11 ++
include/linux/dma-buf.h | 21 ++++
include/linux/mlx5/driver.h | 7 ++
include/linux/pci-tph.h | 2 +
include/uapi/linux/vfio.h | 35 ++++++
11 files changed, 306 insertions(+), 11 deletions(-)
--
2.52.0
next reply other threads:[~2026-05-12 18:59 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-12 18:47 Zhiping Zhang [this message]
2026-05-12 18:47 ` [PATCH v3 1/2] vfio: add dma-buf get_tph callback and DMA_BUF_TPH feature Zhiping Zhang
2026-05-13 1:33 ` fengchengwen
2026-05-14 6:08 ` Zhiping Zhang
2026-05-16 3:07 ` Claude review: " Claude Code Review Bot
2026-05-12 18:47 ` [PATCH v3 2/2] RDMA/mlx5: get tph for p2p access when registering dma-buf mr Zhiping Zhang
2026-05-13 1:49 ` fengchengwen
2026-05-13 6:37 ` Zhiping Zhang
2026-05-16 3:07 ` Claude review: " Claude Code Review Bot
2026-05-16 3:07 ` Claude review: vfio/dma-buf: add TPH support for peer-to-peer access Claude Code Review Bot
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=20260512184755.4137227-1-zhipingz@meta.com \
--to=zhipingz@meta.com \
--cc=alex@shazbot.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=helgaas@kernel.org \
--cc=jgg@ziepe.ca \
--cc=kbusch@kernel.org \
--cc=kvm@vger.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