[PATCH rdma-next 0/3] RDMA/mlx5: Support pinned revocable dma-buf import

From: Edward Srouji

Date: Sat Nov 28 2026 - 08:36:51 EST


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@xxxxxxxxxx>
---
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 | 187 ++++++++++++++++++++--
drivers/infiniband/hw/mlx5/odp.c | 58 +------
4 files changed, 185 insertions(+), 81 deletions(-)
---
base-commit: 94e81a1f3ffabb388f7d0a9674bb1d3acc067e00
change-id: 20261128-mlx5-pinned-revocable-dmabuf-31e90029af9e

Best regards,
--
Edward Srouji <edwards@xxxxxxxxxx>