Linux RDMA and InfiniBand development
 help / color / mirror / Atom feed
* [PATCH rdma-next v2 0/3] RDMA/mlx5: Support pinned revocable dma-buf import
@ 2026-11-29 15:25 Edward Srouji
  2026-11-29 15:25 ` [PATCH rdma-next v2 1/3] RDMA/uverbs: Permit dma-buf export to work with pinned importers Edward Srouji
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: Edward Srouji @ 2026-11-29 15:25 UTC (permalink / raw)
  To: Jason Gunthorpe, Leon Romanovsky, Sumit Semwal,
	Christian König, Philipp Stanner
  Cc: linux-rdma, linux-kernel, linux-media, dri-devel, linaro-mm-sig,
	Edward Srouji, Chiara Meiohas, Yishai Hadas

Today mlx5 imports every dma-buf as movable. The mkey is sized for the
worst case, one entry per PAGE_SIZE of the dma-buf, and an invalidation
zaps the mkey and relies on ODP page faults to map it again. This makes
dma-buf MRs depend on CONFIG_INFINIBAND_ON_DEMAND_PAGING, and wastes
translation entries for exporters that never move their memory, such as
when GPU or device memory is registered for peer-to-peer DMA.

Exporters of PCI BAR memory, VFIO and the uverbs dma-buf export, do not
move the memory, but they must be able to take it away on a reset or a
memory-disable. The dma-buf core supports this with pinned revocable
attachments (dma_buf_attach_revocable()), and irdma already imports
dma-bufs this way, see commit 4707bf5f6c86 ("RDMA/irdma: Add support for
revocable pinned dmabuf import").

This series adds the same support to mlx5:

- Patch 1 lets the uverbs dma-buf export accept pinned importers that
  can handle a revoke.

- Patch 2 moves the dma-buf MR init out of the ODP-only odp.c into mr.c,
  with no functional change.

- Patch 3 makes mlx5 try a pinned revocable import first. When the
  exporter grants it, the buffer cannot move, so the mkey is sized
  exactly to its mapping. Otherwise mlx5 falls back to the existing
  movable import, which is the only case that still requires ODP. On a
  revoke the mkey is disabled with a UMR, so the device stops accessing
  the buffer before the exporter takes the memory away.

Signed-off-by: Edward Srouji <edwards@nvidia.com>
---
Changes in v2:
- Rebase on top of wip/leon-for-next, adapting to the mlx5 device
  helper renames (mr_to_dev(), mr_to_mdev() returning the core device).
- The WARN_ON(!page_size) in alloc_cacheable_mr() that Sashiko reported
  on v1 is fixed separately for rdma-rc:
  https://lore.kernel.org/linux-rdma/20261129-mlx5-no-warn-page-size-v1-1-02b15ebaea8c@nvidia.com/
- Link to v1: https://lore.kernel.org/r/20261128-mlx5-pinned-revocable-dmabuf-v1-0-a4cde143a58e@nvidia.com

---
Chiara Meiohas (2):
      RDMA/uverbs: Permit dma-buf export to work with pinned importers
      RDMA/mlx5: Move dma-buf MR init out of ODP-only compilation

Yishai Hadas (1):
      RDMA/mlx5: Try pinned revocable dmabuf import by default

 drivers/infiniband/core/uverbs_std_types_dmabuf.c |  14 +-
 drivers/infiniband/hw/mlx5/mlx5_ib.h              |   7 +-
 drivers/infiniband/hw/mlx5/mr.c                   | 188 ++++++++++++++++++++--
 drivers/infiniband/hw/mlx5/odp.c                  |  59 +------
 4 files changed, 186 insertions(+), 82 deletions(-)
---
base-commit: a8671ee9bde18105775c2307bc71b0933bd24ed4
change-id: 20261128-mlx5-pinned-revocable-dmabuf-31e90029af9e

Best regards,
-- 
Edward Srouji <edwards@nvidia.com>


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

end of thread, other threads:[~2026-11-29 16:24 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-29 15:25 [PATCH rdma-next v2 0/3] RDMA/mlx5: Support pinned revocable dma-buf import Edward Srouji
2026-11-29 15:25 ` [PATCH rdma-next v2 1/3] RDMA/uverbs: Permit dma-buf export to work with pinned importers Edward Srouji
2026-11-29 15:25 ` [PATCH rdma-next v2 2/3] RDMA/mlx5: Move dma-buf MR init out of ODP-only compilation Edward Srouji
2026-11-29 15:25 ` [PATCH rdma-next v2 3/3] RDMA/mlx5: Try pinned revocable dmabuf import by default Edward Srouji
2026-11-29 15:45   ` sashiko-bot
2026-11-29 16:24     ` Edward Srouji
2026-11-29 15:45 ` [PATCH rdma-next v2 0/3] RDMA/mlx5: Support pinned revocable dma-buf import sashiko-bot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox