lkml.org 
[lkml]   [2021]   [Mar]   [11]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [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.

\
 
 \ /
  Last update: 2021-03-11 13:28    [W:0.101 / U:0.700 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site