[PATCH RFC 08/26] drm/vmwgfx: Use match_mapping instead of dummy calls

Jason Gunthorpe
2026-02-18T00:12:11Z

vmwgfx is creating a DMA-buf that cannot be attached by providing
always fail functions for dma_buf_ops.

The attach/detach callbacks are already optional inside DMA-buf, but
dma_buf_export() is checking for non-null map/unmap callbacks.

Instead use the mapping type interface and provide an always fail
match_mapping(). Remove the unused SGT and attach/detach functions, they
can never be called if match_mapping() fails.

Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
---
drivers/gpu/drm/vmwgfx/vmwgfx_prime.c | 32 +++++----------------------
1 file changed, 5 insertions(+), 27 deletions(-)

diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_prime.c b/drivers/gpu/drm/vmwgfx/vmwgfx_prime.c
index 598b90ac7590b5..90e4342a378d5d 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_prime.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_prime.c
@@ -35,41 +35,19 @@
#include "vmwgfx_bo.h"
#include "ttm_object.h"
#include <linux/dma-buf.h>
+#include <linux/dma-buf-mapping.h>

/*
- * DMA-BUF attach- and mapping methods. No need to implement
- * these until we have other virtual devices use them.
+ * No need to implement these until we have other virtual devices use them.
*/
-
-static int vmw_prime_map_attach(struct dma_buf *dma_buf,
- struct dma_buf_attachment *attach)
-{
- return -ENOSYS;
-}
-
-static void vmw_prime_map_detach(struct dma_buf *dma_buf,
- struct dma_buf_attachment *attach)
-{
-}
-
-static struct sg_table *vmw_prime_map_dma_buf(struct dma_buf_attachment *attach,
- enum dma_data_direction dir)
-{
- return ERR_PTR(-ENOSYS);
-}
-
-static void vmw_prime_unmap_dma_buf(struct dma_buf_attachment *attach,
- struct sg_table *sgb,
- enum dma_data_direction dir)
+static int vmw_prime_match_mapping(struct dma_buf_match_args *args)
{
+ return -EOPNOTSUPP;
}

const struct dma_buf_ops vmw_prime_dmabuf_ops = {
- .attach = vmw_prime_map_attach,
- .detach = vmw_prime_map_detach,
- .map_dma_buf = vmw_prime_map_dma_buf,
- .unmap_dma_buf = vmw_prime_unmap_dma_buf,
.release = NULL,
+ .match_mapping = vmw_prime_match_mapping,
};

int vmw_prime_fd_to_handle(struct drm_device *dev,
--
2.43.0