drm/shmem-helper: Fix comment describing dma-buf mappings
Subsystems (2)
PATCH 1/1 drm/shmem-helper: Fix comment describing dma-buf mappings
shmem->map_wc was set to false but the comment suggested WC was enabled for imported buffers.
--- drivers/gpu/drm/drm_gem_shmem_helper.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/drm_gem_shmem_helper.c +1 -1
@@ -75,7 +75,7 @@ __drm_gem_shmem_create(struct drm_device *dev, size_t size, bool private)if (private) {drm_gem_private_object_init (dev, obj, size); - shmem->map_wc = false;/* dma-buf mappings use always writecombine */ + shmem->map_wc = false;/* dma-buf mappings are never write-combined */ }else { ret =drm_gem_object_init (dev, obj, size); }
Signature · 1 line
2.43.0
Quoted 13 lines · Jacek Lawrynowicz
shmem->map_wc wasset tofalsebut the comment suggested WC was enabled for imported buffers.Signed-off-by Jacek Lawrynowicz <[email protected]>--- drivers/gpu/drm/drm_gem_shmem_helper.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/gpu/drm/drm_gem_shmem_helper.c +0
-0
drivers/gpu/drm/drm_gem_shmem_helper.c __drm_gem_shmem_create(struct drm_device *dev, size_t size, bool private) · line 78
Quoted 5 lines
drivers/gpu/drm/drm_gem_shmem_helper.c +1
-1@@ -75,7 +75,7 @@ __drm_gem_shmem_create(struct drm_device *dev, size_t size, bool private)if (private) {drm_gem_private_object_init (dev, obj, size); - shmem->map_wc = false;/* dma-buf mappings use always writecombine */ + shmem->map_wc = false;/* dma-buf mappings are never write-combined */
I think neither is correct, because for a dma_buf import it is up to the importer to set up everything, including whether mappings should be write-combined or not. And setting this to false ensures that helpers don't muck around with the caching setting.
Also there's private buffer objects for other reasons, but the overlap between drivers that have those and which use shmem helpers is zero.
So I think overall a better comment would be:
/* This disables all shmem helper caching code and leaves * all decision entirely to the buffer provider */
Maybe in a very old version where shmem helpers didn't correctly use the dma_buf functions there was some justification for the original comment, but that's been long ago fixed in a series of patches to make sure dma_buf_vmap/mmap are used consistently and directly.
Care to respin with a wording of your choice for the comment? If you're bored you could also try to dig through history a bit and collect some of the commits that made this comment largely obsolete, since I don't think any of the map_wc == true paths are even reachable anymore for private objects ...
Cheers, Sima
Quoted 6 lines
drivers/gpu/drm/drm_gem_shmem_helper.c +0
-0}else { ret =drm_gem_object_init (dev, obj, size); }Signature · 1 line
2.43.0
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch
Quoted 38 lines · Daniel Vetter
Quoted 13 lines · Jacek Lawrynowicz
shmem->map_wc wasset tofalsebut the comment suggested WC was enabled for imported buffers.Signed-off-by Jacek Lawrynowicz <[email protected]>--- drivers/gpu/drm/drm_gem_shmem_helper.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/gpu/drm/drm_gem_shmem_helper.c +0
-0drivers/gpu/drm/drm_gem_shmem_helper.c __drm_gem_shmem_create(struct drm_device *dev, size_t size, bool private) · line 78
Quoted 5 lines
drivers/gpu/drm/drm_gem_shmem_helper.c +1
-1@@ -75,7 +75,7 @@ __drm_gem_shmem_create(struct drm_device *dev, size_t size, bool private)if (private) {drm_gem_private_object_init (dev, obj, size); - shmem->map_wc = false;/* dma-buf mappings use always writecombine */ + shmem->map_wc = false;/* dma-buf mappings are never write-combined */ I think neither is correct, because for a
dma_bufimport it is up to the importer to set up everything, including whether mappings should be write-combined or not. And setting this to false ensures that helpers don't muck around with the caching setting.Also there's private buffer objects for other reasons, but the overlap between drivers that have those and which use shmem helpers is zero.
So I think overall a better comment would be:
/* This disables all shmem helper caching code and leaves * all decision entirely to the buffer provider */Maybe in a very old version where shmem helpers didn't correctly use the
dma_buffunctions there was some justification for the original comment, but that's been long ago fixed in a series of patches to make sure dma_buf_vmap/mmap are used consistently and directly.
Quoted 5 lines
Care to respin with a wording of your choice for the comment? If you're bored you could also try to dig through history a bit and collect some of the commits that made this comment largely obsolete, since I don't think any of the
map_wc== true paths are even reachable anymore for private objects ...
I think that it would be better to add drm_WARN() here - similar to WARNs for import_attach. Only v3d sets map_wc in gem_create_object() and it is easy to fix.
Would these warnings make sense?
__drm_gem_shmem_create():drm_WARN(dev, shmem->map_wc, "Object caching is controlled by the underlying dma-buf\n");
__drm_gem_dma_create():drm_WARN(dev, dma_obj->map_noncoherent, "Object caching is controlled by the underlying dma-buf\n");
Regards,
Jacek
Quoted 45 lines · Jacek Lawrynowicz
Quoted 38 lines · Daniel Vetter
Quoted 13 lines · Jacek Lawrynowicz
shmem->map_wc wasset tofalsebut the comment suggested WC was enabled for imported buffers.Signed-off-by Jacek Lawrynowicz <[email protected]>--- drivers/gpu/drm/drm_gem_shmem_helper.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/gpu/drm/drm_gem_shmem_helper.c +0
-0drivers/gpu/drm/drm_gem_shmem_helper.c __drm_gem_shmem_create(struct drm_device *dev, size_t size, bool private) · line 78
Quoted 5 lines
drivers/gpu/drm/drm_gem_shmem_helper.c +1
-1@@ -75,7 +75,7 @@ __drm_gem_shmem_create(struct drm_device *dev, size_t size, bool private)if (private) {drm_gem_private_object_init (dev, obj, size); - shmem->map_wc = false;/* dma-buf mappings use always writecombine */ + shmem->map_wc = false;/* dma-buf mappings are never write-combined */ I think neither is correct, because for a
dma_bufimport it is up to the importer to set up everything, including whether mappings should be write-combined or not. And setting this to false ensures that helpers don't muck around with the caching setting.Also there's private buffer objects for other reasons, but the overlap between drivers that have those and which use shmem helpers is zero.
So I think overall a better comment would be:
/* This disables all shmem helper caching code and leaves * all decision entirely to the buffer provider */Maybe in a very old version where shmem helpers didn't correctly use the
dma_buffunctions there was some justification for the original comment, but that's been long ago fixed in a series of patches to make sure dma_buf_vmap/mmap are used consistently and directly.Quoted 5 lines
Care to respin with a wording of your choice for the comment? If you're bored you could also try to dig through history a bit and collect some of the commits that made this comment largely obsolete, since I don't think any of the
map_wc== true paths are even reachable anymore for private objects ...
Quoted 3 lines
I think that it would be better to add
drm_WARN()here - similar to WARNs forimport_attach. Only v3d setsmap_wcingem_create_object()and it is easy to fix.
Would these warnings make sense?
I think v4c has the same pattern from a quick check ...
But yes if you're willing to do the full audit, then this sounds like the cleanest approach. To document the results of your audit please explain for each driver why it's already save in the patch that adds the belwo warning (or that you've fixed it in a preceeding patch), that makes checking things in review easier.
Quoted 5 lines
__drm_gem_shmem_create():drm_WARN(dev, shmem->map_wc, "Object caching is controlled by the underlying dma-buf\n");
__drm_gem_dma_create():drm_WARN(dev, dma_obj->map_noncoherent, "Object caching is controlled by the underlying dma-buf\n");
Yeah this sounds good.
Cheers, Sima
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch