[PATCH RFC 19/26] treewide: Rename dma_buf_attach() to dma_buf_sgt_attach()

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

This attach function always creates a SGT mapping type importer.

Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
---
Documentation/gpu/todo.rst | 2 +-
drivers/accel/amdxdna/amdxdna_gem.c | 2 +-
drivers/accel/ivpu/ivpu_gem.c | 2 +-
drivers/accel/qaic/qaic_data.c | 2 +-
drivers/dma-buf/dma-buf.c | 14 +++++++-------
drivers/gpu/drm/armada/armada_gem.c | 2 +-
drivers/gpu/drm/drm_gem_shmem_helper.c | 2 +-
drivers/gpu/drm/drm_prime.c | 2 +-
drivers/gpu/drm/i915/gem/i915_gem_dmabuf.c | 2 +-
.../gpu/drm/i915/gem/selftests/i915_gem_dmabuf.c | 2 +-
drivers/gpu/drm/omapdrm/omap_gem_dmabuf.c | 2 +-
drivers/gpu/drm/tegra/gem.c | 4 ++--
drivers/iio/industrialio-buffer.c | 2 +-
.../media/common/videobuf2/videobuf2-dma-contig.c | 2 +-
drivers/media/common/videobuf2/videobuf2-dma-sg.c | 2 +-
.../media/platform/nvidia/tegra-vde/dmabuf-cache.c | 2 +-
drivers/misc/fastrpc.c | 2 +-
drivers/usb/gadget/function/f_fs.c | 2 +-
drivers/xen/gntdev-dmabuf.c | 2 +-
include/linux/dma-buf.h | 10 +++++-----
io_uring/zcrx.c | 2 +-
net/core/devmem.c | 2 +-
22 files changed, 33 insertions(+), 33 deletions(-)

diff --git a/Documentation/gpu/todo.rst b/Documentation/gpu/todo.rst
index 9013ced318cb97..9a690a1bf62b5a 100644
--- a/Documentation/gpu/todo.rst
+++ b/Documentation/gpu/todo.rst
@@ -608,7 +608,7 @@ Remove automatic page mapping from dma-buf importing

When importing dma-bufs, the dma-buf and PRIME frameworks automatically map
imported pages into the importer's DMA area. drm_gem_prime_fd_to_handle() and
-drm_gem_prime_handle_to_fd() require that importers call dma_buf_attach()
+drm_gem_prime_handle_to_fd() require that importers call dma_buf_sgt_attach()
even if they never do actual device DMA, but only CPU access through
dma_buf_vmap(). This is a problem for USB devices, which do not support DMA
operations.
diff --git a/drivers/accel/amdxdna/amdxdna_gem.c b/drivers/accel/amdxdna/amdxdna_gem.c
index ccc78aeeb4c0fc..ddaf3f59adaf6c 100644
--- a/drivers/accel/amdxdna/amdxdna_gem.c
+++ b/drivers/accel/amdxdna/amdxdna_gem.c
@@ -605,7 +605,7 @@ amdxdna_gem_prime_import(struct drm_device *dev, struct dma_buf *dma_buf)

get_dma_buf(dma_buf);

- attach = dma_buf_attach(dma_buf, dev->dev);
+ attach = dma_buf_sgt_attach(dma_buf, dev->dev);
if (IS_ERR(attach)) {
ret = PTR_ERR(attach);
goto put_buf;
diff --git a/drivers/accel/ivpu/ivpu_gem.c b/drivers/accel/ivpu/ivpu_gem.c
index 1fcb454f4cb33b..4d26244a394daf 100644
--- a/drivers/accel/ivpu/ivpu_gem.c
+++ b/drivers/accel/ivpu/ivpu_gem.c
@@ -219,7 +219,7 @@ struct drm_gem_object *ivpu_gem_prime_import(struct drm_device *dev,
struct ivpu_bo *bo;
int ret;

- attach = dma_buf_attach(dma_buf, attach_dev);
+ attach = dma_buf_sgt_attach(dma_buf, attach_dev);
if (IS_ERR(attach))
return ERR_CAST(attach);

diff --git a/drivers/accel/qaic/qaic_data.c b/drivers/accel/qaic/qaic_data.c
index 8e2e597bc1ff03..19126309105165 100644
--- a/drivers/accel/qaic/qaic_data.c
+++ b/drivers/accel/qaic/qaic_data.c
@@ -831,7 +831,7 @@ struct drm_gem_object *qaic_gem_prime_import(struct drm_device *dev, struct dma_
obj = &bo->base;
get_dma_buf(dma_buf);

- attach = dma_buf_attach(dma_buf, dev->dev);
+ attach = dma_buf_sgt_attach(dma_buf, dev->dev);
if (IS_ERR(attach)) {
ret = PTR_ERR(attach);
goto attach_fail;
diff --git a/drivers/dma-buf/dma-buf.c b/drivers/dma-buf/dma-buf.c
index 35d3bbb4bb053c..ded9331a493c36 100644
--- a/drivers/dma-buf/dma-buf.c
+++ b/drivers/dma-buf/dma-buf.c
@@ -646,7 +646,7 @@ static struct file *dma_buf_getfile(size_t size, int flags)
* 2. Userspace passes this file-descriptors to all drivers it wants this buffer
* to share with: First the file descriptor is converted to a &dma_buf using
* dma_buf_get(). Then the buffer is attached to the device using
- * dma_buf_attach().
+ * dma_buf_sgt_attach().
*
* Up to this stage the exporter is still free to migrate or reallocate the
* backing storage.
@@ -875,7 +875,7 @@ dma_buf_pin_on_map(struct dma_buf_attachment *attach)
* 2. Importers must not hold the dma-buf reservation lock when calling these
* functions:
*
- * - dma_buf_attach()
+ * - dma_buf_sgt_attach()
* - dma_buf_dynamic_attach()
* - dma_buf_detach()
* - dma_buf_export()
@@ -999,15 +999,15 @@ struct dma_buf_attachment *dma_buf_mapping_attach(
EXPORT_SYMBOL_NS_GPL(dma_buf_mapping_attach, "DMA_BUF");

/**
- * dma_buf_attach - Wrapper for dma_buf_mapping_attach
+ * dma_buf_sgt_attach - Wrapper for dma_buf_mapping_attach
* @dmabuf: [in] buffer to attach device to.
* @dev: [in] device to be attached.
*
* Wrapper to call dma_buf_mapping_attach() for drivers which still use a static
* mapping.
*/
-struct dma_buf_attachment *dma_buf_attach(struct dma_buf *dmabuf,
- struct device *dev)
+struct dma_buf_attachment *dma_buf_sgt_attach(struct dma_buf *dmabuf,
+ struct device *dev)
{
struct dma_buf_mapping_match sgt_match[] = {
DMA_BUF_IMAPPING_SGT(dev, DMA_SGT_NO_P2P),
@@ -1016,7 +1016,7 @@ struct dma_buf_attachment *dma_buf_attach(struct dma_buf *dmabuf,
return dma_buf_mapping_attach(dmabuf, sgt_match, ARRAY_SIZE(sgt_match),
NULL, NULL);
}
-EXPORT_SYMBOL_NS_GPL(dma_buf_attach, "DMA_BUF");
+EXPORT_SYMBOL_NS_GPL(dma_buf_sgt_attach, "DMA_BUF");

/**
* dma_buf_dynamic_attach - Add the device to dma_buf's attachments list
@@ -1048,7 +1048,7 @@ EXPORT_SYMBOL_NS_GPL(dma_buf_dynamic_attach, "DMA_BUF");
* @dmabuf: [in] buffer to detach from.
* @attach: [in] attachment to be detached; is free'd after this call.
*
- * Clean up a device attachment obtained by calling dma_buf_attach().
+ * Clean up a device attachment obtained by calling dma_buf_sgt_attach().
*
* Optionally this calls &dma_buf_ops.detach for device-specific detach.
*/
diff --git a/drivers/gpu/drm/armada/armada_gem.c b/drivers/gpu/drm/armada/armada_gem.c
index dee5fef5eb4f7b..a2efa57114e283 100644
--- a/drivers/gpu/drm/armada/armada_gem.c
+++ b/drivers/gpu/drm/armada/armada_gem.c
@@ -518,7 +518,7 @@ armada_gem_prime_import(struct drm_device *dev, struct dma_buf *buf)
}
}

- attach = dma_buf_attach(buf, dev->dev);
+ attach = dma_buf_sgt_attach(buf, dev->dev);
if (IS_ERR(attach))
return ERR_CAST(attach);

diff --git a/drivers/gpu/drm/drm_gem_shmem_helper.c b/drivers/gpu/drm/drm_gem_shmem_helper.c
index f13eb5f36e8a97..8e7c4ac9ab85f8 100644
--- a/drivers/gpu/drm/drm_gem_shmem_helper.c
+++ b/drivers/gpu/drm/drm_gem_shmem_helper.c
@@ -865,7 +865,7 @@ struct drm_gem_object *drm_gem_shmem_prime_import_no_map(struct drm_device *dev,
return obj;
}

- attach = dma_buf_attach(dma_buf, dev->dev);
+ attach = dma_buf_sgt_attach(dma_buf, dev->dev);
if (IS_ERR(attach))
return ERR_CAST(attach);

diff --git a/drivers/gpu/drm/drm_prime.c b/drivers/gpu/drm/drm_prime.c
index 6f98d0c123dc8d..6fecc3c1b362d3 100644
--- a/drivers/gpu/drm/drm_prime.c
+++ b/drivers/gpu/drm/drm_prime.c
@@ -999,7 +999,7 @@ struct drm_gem_object *drm_gem_prime_import_dev(struct drm_device *dev,
if (!dev->driver->gem_prime_import_sg_table)
return ERR_PTR(-EINVAL);

- attach = dma_buf_attach(dma_buf, attach_dev);
+ attach = dma_buf_sgt_attach(dma_buf, attach_dev);
if (IS_ERR(attach))
return ERR_CAST(attach);

diff --git a/drivers/gpu/drm/i915/gem/i915_gem_dmabuf.c b/drivers/gpu/drm/i915/gem/i915_gem_dmabuf.c
index 325442948fafe0..069367edcad2a5 100644
--- a/drivers/gpu/drm/i915/gem/i915_gem_dmabuf.c
+++ b/drivers/gpu/drm/i915/gem/i915_gem_dmabuf.c
@@ -306,7 +306,7 @@ struct drm_gem_object *i915_gem_prime_import(struct drm_device *dev,
return ERR_PTR(-E2BIG);

/* need to attach */
- attach = dma_buf_attach(dma_buf, dev->dev);
+ attach = dma_buf_sgt_attach(dma_buf, dev->dev);
if (IS_ERR(attach))
return ERR_CAST(attach);

diff --git a/drivers/gpu/drm/i915/gem/selftests/i915_gem_dmabuf.c b/drivers/gpu/drm/i915/gem/selftests/i915_gem_dmabuf.c
index 6b6d235fd3e9fd..3c193e6d9d11e2 100644
--- a/drivers/gpu/drm/i915/gem/selftests/i915_gem_dmabuf.c
+++ b/drivers/gpu/drm/i915/gem/selftests/i915_gem_dmabuf.c
@@ -287,7 +287,7 @@ static int igt_dmabuf_import_same_driver(struct drm_i915_private *i915,
goto out_import;

/* Now try a fake an importer */
- import_attach = dma_buf_attach(dmabuf, obj->base.dev->dev);
+ import_attach = dma_buf_sgt_attach(dmabuf, obj->base.dev->dev);
if (IS_ERR(import_attach)) {
err = PTR_ERR(import_attach);
goto out_import;
diff --git a/drivers/gpu/drm/omapdrm/omap_gem_dmabuf.c b/drivers/gpu/drm/omapdrm/omap_gem_dmabuf.c
index c549b94b2e8ad5..ca0962a995099a 100644
--- a/drivers/gpu/drm/omapdrm/omap_gem_dmabuf.c
+++ b/drivers/gpu/drm/omapdrm/omap_gem_dmabuf.c
@@ -115,7 +115,7 @@ struct drm_gem_object *omap_gem_prime_import(struct drm_device *dev,
}
}

- attach = dma_buf_attach(dma_buf, dev->dev);
+ attach = dma_buf_sgt_attach(dma_buf, dev->dev);
if (IS_ERR(attach))
return ERR_CAST(attach);

diff --git a/drivers/gpu/drm/tegra/gem.c b/drivers/gpu/drm/tegra/gem.c
index 6b93f4d42df26c..19c83556e147c1 100644
--- a/drivers/gpu/drm/tegra/gem.c
+++ b/drivers/gpu/drm/tegra/gem.c
@@ -80,7 +80,7 @@ static struct host1x_bo_mapping *tegra_bo_pin(struct device *dev, struct host1x_
if (obj->dma_buf) {
struct dma_buf *buf = obj->dma_buf;

- map->attach = dma_buf_attach(buf, dev);
+ map->attach = dma_buf_sgt_attach(buf, dev);
if (IS_ERR(map->attach)) {
err = PTR_ERR(map->attach);
goto free;
@@ -472,7 +472,7 @@ static struct tegra_bo *tegra_bo_import(struct drm_device *drm,
* domain, map it first to the DRM device to get an sgt.
*/
if (tegra->domain) {
- attach = dma_buf_attach(buf, drm->dev);
+ attach = dma_buf_sgt_attach(buf, drm->dev);
if (IS_ERR(attach)) {
err = PTR_ERR(attach);
goto free;
diff --git a/drivers/iio/industrialio-buffer.c b/drivers/iio/industrialio-buffer.c
index 973db853525958..0d170978108cae 100644
--- a/drivers/iio/industrialio-buffer.c
+++ b/drivers/iio/industrialio-buffer.c
@@ -1688,7 +1688,7 @@ static int iio_buffer_attach_dmabuf(struct iio_dev_buffer_pair *ib,
goto err_free_priv;
}

- attach = dma_buf_attach(dmabuf, dma_dev);
+ attach = dma_buf_sgt_attach(dmabuf, dma_dev);
if (IS_ERR(attach)) {
err = PTR_ERR(attach);
goto err_dmabuf_put;
diff --git a/drivers/media/common/videobuf2/videobuf2-dma-contig.c b/drivers/media/common/videobuf2/videobuf2-dma-contig.c
index 6c18a0b33546e8..0e40799687d4ee 100644
--- a/drivers/media/common/videobuf2/videobuf2-dma-contig.c
+++ b/drivers/media/common/videobuf2/videobuf2-dma-contig.c
@@ -789,7 +789,7 @@ static void *vb2_dc_attach_dmabuf(struct vb2_buffer *vb, struct device *dev,
buf->vb = vb;

/* create attachment for the dmabuf with the user device */
- dba = dma_buf_attach(dbuf, buf->dev);
+ dba = dma_buf_sgt_attach(dbuf, buf->dev);
if (IS_ERR(dba)) {
pr_err("failed to attach dmabuf\n");
kfree(buf);
diff --git a/drivers/media/common/videobuf2/videobuf2-dma-sg.c b/drivers/media/common/videobuf2/videobuf2-dma-sg.c
index a5b855f055e358..a397498d669111 100644
--- a/drivers/media/common/videobuf2/videobuf2-dma-sg.c
+++ b/drivers/media/common/videobuf2/videobuf2-dma-sg.c
@@ -637,7 +637,7 @@ static void *vb2_dma_sg_attach_dmabuf(struct vb2_buffer *vb, struct device *dev,

buf->dev = dev;
/* create attachment for the dmabuf with the user device */
- dba = dma_buf_attach(dbuf, buf->dev);
+ dba = dma_buf_sgt_attach(dbuf, buf->dev);
if (IS_ERR(dba)) {
pr_err("failed to attach dmabuf\n");
kfree(buf);
diff --git a/drivers/media/platform/nvidia/tegra-vde/dmabuf-cache.c b/drivers/media/platform/nvidia/tegra-vde/dmabuf-cache.c
index 04ea8ffd4836c9..02175c39cfddf9 100644
--- a/drivers/media/platform/nvidia/tegra-vde/dmabuf-cache.c
+++ b/drivers/media/platform/nvidia/tegra-vde/dmabuf-cache.c
@@ -96,7 +96,7 @@ int tegra_vde_dmabuf_cache_map(struct tegra_vde *vde,
goto ref;
}

- attachment = dma_buf_attach(dmabuf, dev);
+ attachment = dma_buf_sgt_attach(dmabuf, dev);
if (IS_ERR(attachment)) {
dev_err(dev, "Failed to attach dmabuf\n");
err = PTR_ERR(attachment);
diff --git a/drivers/misc/fastrpc.c b/drivers/misc/fastrpc.c
index a7376d4a07c73c..391026b15a6dc3 100644
--- a/drivers/misc/fastrpc.c
+++ b/drivers/misc/fastrpc.c
@@ -772,7 +772,7 @@ static int fastrpc_map_attach(struct fastrpc_user *fl, int fd,
goto get_err;
}

- map->attach = dma_buf_attach(map->buf, sess->dev);
+ map->attach = dma_buf_sgt_attach(map->buf, sess->dev);
if (IS_ERR(map->attach)) {
dev_err(sess->dev, "Failed to attach dmabuf\n");
err = PTR_ERR(map->attach);
diff --git a/drivers/usb/gadget/function/f_fs.c b/drivers/usb/gadget/function/f_fs.c
index a6adbd132669e3..e66715f289d497 100644
--- a/drivers/usb/gadget/function/f_fs.c
+++ b/drivers/usb/gadget/function/f_fs.c
@@ -1502,7 +1502,7 @@ static int ffs_dmabuf_attach(struct file *file, int fd)
if (IS_ERR(dmabuf))
return PTR_ERR(dmabuf);

- attach = dma_buf_attach(dmabuf, gadget->dev.parent);
+ attach = dma_buf_sgt_attach(dmabuf, gadget->dev.parent);
if (IS_ERR(attach)) {
err = PTR_ERR(attach);
goto err_dmabuf_put;
diff --git a/drivers/xen/gntdev-dmabuf.c b/drivers/xen/gntdev-dmabuf.c
index 927265ae7a5dc8..b53bf6d92d27c2 100644
--- a/drivers/xen/gntdev-dmabuf.c
+++ b/drivers/xen/gntdev-dmabuf.c
@@ -582,7 +582,7 @@ dmabuf_imp_to_refs(struct gntdev_dmabuf_priv *priv, struct device *dev,
gntdev_dmabuf->priv = priv;
gntdev_dmabuf->fd = fd;

- attach = dma_buf_attach(dma_buf, dev);
+ attach = dma_buf_sgt_attach(dma_buf, dev);
if (IS_ERR(attach)) {
ret = ERR_CAST(attach);
goto fail_free_obj;
diff --git a/include/linux/dma-buf.h b/include/linux/dma-buf.h
index 7fde67e1b4f459..456ed5767c05eb 100644
--- a/include/linux/dma-buf.h
+++ b/include/linux/dma-buf.h
@@ -70,7 +70,7 @@ struct dma_buf_ops {
/**
* @attach:
*
- * This is called from dma_buf_attach() to make sure that a given
+ * This is called from dma_buf_sgt_attach() to make sure that a given
* &dma_buf_attachment.dev can access the provided &dma_buf. Exporters
* which support buffer objects in special locations like VRAM or
* device-specific carveout areas should check whether the buffer could
@@ -118,7 +118,7 @@ struct dma_buf_ops {
* exclusive with @cache_sgt_mapping.
*
* This is called automatically for non-dynamic importers from
- * dma_buf_attach().
+ * dma_buf_sgt_attach().
*
* Note that similar to non-dynamic exporters in their @map_dma_buf
* callback the driver must guarantee that the memory is available for
@@ -473,7 +473,7 @@ struct dma_buf_attach_ops {
* and its user device(s). The list contains one attachment struct per device
* attached to the buffer.
*
- * An attachment is created by calling dma_buf_attach(), and released again by
+ * An attachment is created by calling dma_buf_sgt_attach(), and released again by
* calling dma_buf_detach(). The DMA mapping itself needed to initiate a
* transfer is created by dma_buf_sgt_map_attachment() and freed again by calling
* dma_buf_sgt_unmap_attachment().
@@ -558,8 +558,8 @@ static inline bool dma_buf_is_dynamic(struct dma_buf *dmabuf)
return !!dmabuf->ops->pin;
}

-struct dma_buf_attachment *dma_buf_attach(struct dma_buf *dmabuf,
- struct device *dev);
+struct dma_buf_attachment *dma_buf_sgt_attach(struct dma_buf *dmabuf,
+ struct device *dev);
struct dma_buf_attachment *
dma_buf_dynamic_attach(struct dma_buf *dmabuf, struct device *dev,
const struct dma_buf_attach_ops *importer_ops,
diff --git a/io_uring/zcrx.c b/io_uring/zcrx.c
index 623fb97b8c5209..acc7a0b48c660e 100644
--- a/io_uring/zcrx.c
+++ b/io_uring/zcrx.c
@@ -130,7 +130,7 @@ static int io_import_dmabuf(struct io_zcrx_ifq *ifq,
goto err;
}

- mem->attach = dma_buf_attach(mem->dmabuf, ifq->dev);
+ mem->attach = dma_buf_sgt_attach(mem->dmabuf, ifq->dev);
if (IS_ERR(mem->attach)) {
ret = PTR_ERR(mem->attach);
mem->attach = NULL;
diff --git a/net/core/devmem.c b/net/core/devmem.c
index 9a1393d144e404..d4a86faf18c2f2 100644
--- a/net/core/devmem.c
+++ b/net/core/devmem.c
@@ -216,7 +216,7 @@ net_devmem_bind_dmabuf(struct net_device *dev,
binding->dmabuf = dmabuf;
binding->direction = direction;

- binding->attachment = dma_buf_attach(binding->dmabuf, dma_dev);
+ binding->attachment = dma_buf_sgt_attach(binding->dmabuf, dma_dev);
if (IS_ERR(binding->attachment)) {
err = PTR_ERR(binding->attachment);
NL_SET_ERR_MSG(extack, "Failed to bind dmabuf to device");
--
2.43.0