From e44977aeeddd98813161adba4df24132a9601427 Mon Sep 17 00:00:00 2001 From: Daniel Vetter Date: Tue, 4 Apr 2023 14:19:32 +0200 Subject: drm/dma-helpers: Don't change vma flags MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This code was added in b65e64f7ccd4 ("drm/cma: Use dma_mmap_writecombine() to mmap buffer"), but does not explain why it's needed. It should be entirely unnecessary, because remap_pfn_range(), which is what the various dma_mmap functiosn are built on top of, does already unconditionally adjust the vma flags: https://elixir.bootlin.com/linux/v6.1-rc6/source/mm/memory.c#L2518 More importantly, it does uncondtionally set VM_PFNMAP, so clearing that does not make much sense. Patch motived by discussions around enforcing VM_PFNMAP semantics for all dma-buf users, where Thomas asked why dma helpers will work with that dma_buf_mmap() contract. FIXME: There are dma implementations which don't set VM_PFNMAP. This is a can of worms. References: https://lore.kernel.org/dri-devel/5c3c8d4f-2c06-9210-b00a-4d0ff6f6fbb7@suse.de/ Cc: Laurent Pinchart Cc: Dave Airlie Cc: Maarten Lankhorst Cc: Maxime Ripard Cc: Thomas Zimmermann Cc: Sumit Semwal Cc: "Christian König" Signed-off-by: Daniel Vetter --- drivers/gpu/drm/drm_gem_dma_helper.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/drm_gem_dma_helper.c b/drivers/gpu/drm/drm_gem_dma_helper.c index 870b90b78bc4..d1f2a358f441 100644 --- a/drivers/gpu/drm/drm_gem_dma_helper.c +++ b/drivers/gpu/drm/drm_gem_dma_helper.c @@ -525,12 +525,10 @@ int drm_gem_dma_mmap(struct drm_gem_dma_object *dma_obj, struct vm_area_struct * int ret; /* - * Clear the VM_PFNMAP flag that was set by drm_gem_mmap(), and set the - * vm_pgoff (used as a fake buffer offset by DRM) to 0 as we want to map - * the whole buffer. + * Set the vm_pgoff (used as a fake buffer offset by DRM) to 0 as we + * want to map the whole buffer. */ vma->vm_pgoff -= drm_vma_node_start(&obj->vma_node); - vm_flags_mod(vma, VM_DONTEXPAND, VM_PFNMAP); if (dma_obj->map_noncoherent) { vma->vm_page_prot = vm_get_page_prot(vma->vm_flags); -- cgit v1.2.3