[PATCH rdma-next 1/3] RDMA/uverbs: Permit dma-buf export to work with pinned importers

From: Edward Srouji

Date: Sat Nov 28 2026 - 08:37:02 EST


From: Chiara Meiohas <cmeiohas@xxxxxxxxxx>

Till now the uverbs dma-buf export path (used to export PCI based
memory regions, e.g. device memory) has rejected pinned importers,
unconditionally failing .pin since it had no way to distinguish
importers that can handle a revoke from those that can't.

Using dma_buf_attach_revocable() it can tell the difference between
pinned importers that support the flow described in
dma_buf_invalidate_mappings() and those that don't.

Thus permit compatible pinned importers: drop the hardcoded-failing
.pin/.unpin and gate admission in .attach on revocability instead.

This follows the same approach taken in commit 6ffe939bf94fb ("vfio:
Permit VFIO to work with pinned importers").

Signed-off-by: Chiara Meiohas <cmeiohas@xxxxxxxxxx>
Signed-off-by: Yishai Hadas <yishaih@xxxxxxxxxx>
Signed-off-by: Edward Srouji <edwards@xxxxxxxxxx>
---
drivers/infiniband/core/uverbs_std_types_dmabuf.c | 14 +++-----------
1 file changed, 3 insertions(+), 11 deletions(-)

diff --git a/drivers/infiniband/core/uverbs_std_types_dmabuf.c b/drivers/infiniband/core/uverbs_std_types_dmabuf.c
index 8d8c997a48834cfd6a8c4c6ba867cc996a2406eb..4de527af01d265effdc042e186693b52b0c1ccec 100644
--- a/drivers/infiniband/core/uverbs_std_types_dmabuf.c
+++ b/drivers/infiniband/core/uverbs_std_types_dmabuf.c
@@ -18,6 +18,9 @@ static int uverbs_dmabuf_attach(struct dma_buf *dmabuf,
if (!attachment->peer2peer)
return -EOPNOTSUPP;

+ if (!dma_buf_attach_revocable(attachment))
+ return -EOPNOTSUPP;
+
return 0;
}

@@ -54,15 +57,6 @@ static void uverbs_dmabuf_unmap(struct dma_buf_attachment *attachment,
kref_put(&priv->kref, ib_uverbs_dmabuf_done);
}

-static int uverbs_dmabuf_pin(struct dma_buf_attachment *attach)
-{
- return -EOPNOTSUPP;
-}
-
-static void uverbs_dmabuf_unpin(struct dma_buf_attachment *attach)
-{
-}
-
static void uverbs_dmabuf_release(struct dma_buf *dmabuf)
{
struct ib_uverbs_dmabuf_file *priv = dmabuf->priv;
@@ -99,8 +93,6 @@ static const struct dma_buf_ops uverbs_dmabuf_ops = {
.attach = uverbs_dmabuf_attach,
.map_dma_buf = uverbs_dmabuf_map,
.unmap_dma_buf = uverbs_dmabuf_unmap,
- .pin = uverbs_dmabuf_pin,
- .unpin = uverbs_dmabuf_unpin,
.release = uverbs_dmabuf_release,
};


--
2.49.0