Skip cache sync for GEM CMA objects?
Subsystems (2)
Hi all,
GEM CMA uses dma_alloc_writecombine() when allocating the CMA objects. So IINM the GEM buffers are cache coherent. So is there any reason why DMA_ATTR_SKIP_CPU_SYNC is not passed to dma_map_sg() when GEM CMA prepares the buffer for dma on behalf of the dma-buf user? Is this just an oversight or is there something I have missed?
Thanks,
Steve
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
RFC PATCH 1/1 drm: use dma_map_sg_attrs for GEM CMA objects
The GEM CMA helper allocates GEM objects with dma_alloc_writecombine(), so the objects are cache coherent, and the exporter methods for these objects can skip cache sync.
To accomplish this a dma atrribute is added to drm_gem_object, and is used with dma_map_sg_attrs/dma_unmap_sg_attrs in drm_gem_map_dma_buf/drm_gem_map_detach. GEM CMA sets the attribute to DMA_ATTR_SKIP_CPU_SYNC when the object is allocated in drm_gem_cma_create().
--- drivers/gpu/drm/drm_gem.c | 1 + drivers/gpu/drm/drm_gem_cma_helper.c | 2 ++ drivers/gpu/drm/drm_prime.c | 7 ++++--- include/drm/drm_gem.h | 5 +++++ 4 files changed, 12 insertions(+), 3 deletions(-)
drivers/gpu/drm/drm_gem.c +1 -0
@@ -169,6 +169,7 @@ void drm_gem_private_object_init(struct drm_device *dev, obj->handle_count =0 ; obj->size = size;drm_vma_node_reset (&obj->vma_node); +init_dma_attrs (&obj->dma_attrs); }EXPORT_SYMBOL (drm_gem_private_object_init);
drivers/gpu/drm/drm_gem_cma_helper.c +2 -0
@@ -75,6 +75,8 @@ __drm_gem_cma_create(struct drm_device *drm, size_t size) goto error; } +dma_set_attr (DMA_ATTR_SKIP_CPU_SYNC , &gem_obj->dma_attrs); +return cma_obj; error:
drivers/gpu/drm/drm_prime.c +4 -3
@@ -153,8 +153,8 @@ static void drm_gem_map_detach(struct dma_buf *dma_buf, sgt = prime_attach->sgt;if (sgt) {if (prime_attach->dir !=DMA_NONE ) -dma_unmap_sg (attach->dev, sgt->sgl, sgt->nents, - prime_attach->dir); +dma_unmap_sg_attrs (attach->dev, sgt->sgl, sgt->nents, + prime_attach->dir, &obj->dma_attrs);sg_free_table (sgt); }
@@ -201,7 +201,8 @@ static struct sg_table *drm_gem_map_dma_buf(struct dma_buf_attachment *attach, sgt = obj->dev->driver->gem_prime_get_sg_table (obj);if (!IS_ERR (sgt)) { -if (!dma_map_sg (attach->dev, sgt->sgl, sgt->nents, dir)) { +if (!dma_map_sg_attrs (attach->dev, sgt->sgl, sgt->nents, + dir, &obj->dma_attrs)) {sg_free_table (sgt);kfree (sgt); sgt =ERR_PTR (-ENOMEM );
include/drm/drm_gem.h +5 -0
@@ -104,6 +104,11 @@ struct drm_gem_object {struct dma_buf *dma_buf;/** +* dma_attrs - DMA attributes for this GEM object +*/ +struct dma_attrs dma_attrs; + +/** * import_attach - dma buf attachment backing this object * * Any foreign dma_buf imported as a gem object has this set to the
Signature · 6 lines
1.9.1 _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel