Messages in this thread | | | Date | Thu, 11 Mar 2021 12:26:42 +0000 | From | Christoph Hellwig <> | Subject | Re: [PATCH v2 3/5] drm: Add and export function drm_gem_cma_mmap_noncoherent |
| |
> +int drm_gem_cma_mmap_noncoherent(struct drm_gem_object *obj, > + struct vm_area_struct *vma) > +{ > + struct drm_gem_cma_object *cma_obj; > + unsigned long pfn; > + 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. > + */ > + vma->vm_pgoff -= drm_vma_node_start(&obj->vma_node); > + vma->vm_flags &= ~VM_PFNMAP; > + vma->vm_page_prot = vm_get_page_prot(vma->vm_flags); > + > + cma_obj = to_drm_gem_cma_obj(obj); > + > + pfn = PHYS_PFN(dma_to_phys(cma_obj->base.dev->dev, cma_obj->paddr)); > + > + ret = remap_pfn_range(vma, vma->vm_start, pfn, > + vma->vm_end - vma->vm_start, > + vma->vm_page_prot);
dma_to_phys must not be used by drivers.
I have a proper helper for this waiting for users:
http://git.infradead.org/users/hch/misc.git/commitdiff/96a546e7229ec53aadbdb7936d1e5e6cb5958952
If you can confirm the helpers works for you I can try to still sneak it to Linus for 5.12 to ease the merge pain.
| |