Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

dma-buf: Make .invalidate_mapping() truly optional

The .invalidate_mapping() callback is documented as optional, yet it
effectively became mandatory whenever importer_ops were provided. This
led to cases where RDMA non-ODP code had to supply an empty stub.

Relax the checks in the dma-buf core so the callback can be omitted,
allowing RDMA code to drop the unnecessary function.

Removing the stub allows the next patch to tell that RDMA does not support
.invalidate_mapping() by checking for a NULL op.

Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Christian König <christian.koenig@amd.com>
Link: https://lore.kernel.org/r/20260131-dmabuf-revoke-v7-5-463d956bd527@nvidia.com

authored by

Leon Romanovsky and committed by
Christian König
575157b1 1a8a5227

+2 -14
+2 -4
drivers/dma-buf/dma-buf.c
··· 1016 1016 if (WARN_ON(!dmabuf || !dev)) 1017 1017 return ERR_PTR(-EINVAL); 1018 1018 1019 - if (WARN_ON(importer_ops && !importer_ops->invalidate_mappings)) 1020 - return ERR_PTR(-EINVAL); 1021 - 1022 1019 attach = kzalloc_obj(*attach); 1023 1020 if (!attach) 1024 1021 return ERR_PTR(-ENOMEM); ··· 1333 1336 dma_resv_assert_held(dmabuf->resv); 1334 1337 1335 1338 list_for_each_entry(attach, &dmabuf->attachments, node) 1336 - if (attach->importer_ops) 1339 + if (attach->importer_ops && 1340 + attach->importer_ops->invalidate_mappings) 1337 1341 attach->importer_ops->invalidate_mappings(attach); 1338 1342 } 1339 1343 EXPORT_SYMBOL_NS_GPL(dma_buf_invalidate_mappings, "DMA_BUF");
-10
drivers/infiniband/core/umem_dmabuf.c
··· 181 181 } 182 182 EXPORT_SYMBOL(ib_umem_dmabuf_get); 183 183 184 - static void 185 - ib_umem_dmabuf_unsupported_move_notify(struct dma_buf_attachment *attach) 186 - { 187 - struct ib_umem_dmabuf *umem_dmabuf = attach->importer_priv; 188 - 189 - ibdev_warn_ratelimited(umem_dmabuf->umem.ibdev, 190 - "Invalidate callback should not be called when memory is pinned\n"); 191 - } 192 - 193 184 static struct dma_buf_attach_ops ib_umem_dmabuf_attach_pinned_ops = { 194 185 .allow_peer2peer = true, 195 - .invalidate_mappings = ib_umem_dmabuf_unsupported_move_notify, 196 186 }; 197 187 198 188 struct ib_umem_dmabuf *