From: Luis R. Rodriguez Date: Wed, 10 Apr 2013 11:35:21 +0000 (-0700) Subject: compat: add helpers to aid backport of generic DMA changes for v4l X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=e535a0b86d237c9b9a06a518ec0a0a639954e6ae;p=openwrt%2Fstaging%2Fblogic.git compat: add helpers to aid backport of generic DMA changes for v4l Commit c60520fa needs to be reverted for older kernels because although we can backport some large changes to DMA that ended up extending some core dma data structures, for details see bca0fa5f as an example. To *aid* with the driver changes required add a helper that lets us call what we used to do, thus requiring a smaller delta on the upstream code. We're only adding this for >= 3.2 as this is required only for media which are also only supporting on >= 3.2. commit c60520fa50cd86d64bc8ebb34300ddc4ca91393d Author: Marek Szyprowski Date: Thu Jun 14 11:32:21 2012 -0300 [media] v4l: vb2-dma-contig: let mmap method to use dma_mmap_coherent call Let mmap method to use dma_mmap_coherent call. Moreover, this patch removes vb2_mmap_pfn_range from videobuf2 helpers as it was suggested by Laurent Pinchart. The function is no longer used in vb2 code. Signed-off-by: Marek Szyprowski Signed-off-by: Tomasz Stanislawski Acked-by: Laurent Pinchart Acked-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Luis R. Rodriguez Signed-off-by: Johannes Berg --- diff --git a/backport/compat/compat-3.9.c b/backport/compat/compat-3.9.c index 61a062a682db..56c40d37aabe 100644 --- a/backport/compat/compat-3.9.c +++ b/backport/compat/compat-3.9.c @@ -12,6 +12,49 @@ #include #include +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,2,0)) +/** + * vb2_mmap_pfn_range() - map physical pages to userspace + * @vma: virtual memory region for the mapping + * @paddr: starting physical address of the memory to be mapped + * @size: size of the memory to be mapped + * @vm_ops: vm operations to be assigned to the created area + * @priv: private data to be associated with the area + * + * Returns 0 on success. + */ +int vb2_mmap_pfn_range(struct vm_area_struct *vma, unsigned long paddr, + unsigned long size, + const struct vm_operations_struct *vm_ops, + void *priv) +{ + int ret; + + size = min_t(unsigned long, vma->vm_end - vma->vm_start, size); + + vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot); + ret = remap_pfn_range(vma, vma->vm_start, paddr >> PAGE_SHIFT, + size, vma->vm_page_prot); + if (ret) { + printk(KERN_ERR "Remapping memory failed, error: %d\n", ret); + return ret; + } + + vma->vm_flags |= VM_DONTEXPAND | VM_DONTDUMP; + vma->vm_private_data = priv; + vma->vm_ops = vm_ops; + + vma->vm_ops->open(vma); + + pr_debug("%s: mapped paddr 0x%08lx at 0x%08lx, size %ld\n", + __func__, paddr, vma->vm_start, size); + + return 0; +} +EXPORT_SYMBOL_GPL(vb2_mmap_pfn_range); +#endif + + #ifdef __sg_page_iter_next void __sg_page_iter_start(struct sg_page_iter *piter, diff --git a/backport/include/linux/compat-3.9.h b/backport/include/linux/compat-3.9.h index 2a1f2da9f9f6..a939e0b9270e 100644 --- a/backport/include/linux/compat-3.9.h +++ b/backport/include/linux/compat-3.9.h @@ -18,6 +18,13 @@ #include #include +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,2,0)) +int vb2_mmap_pfn_range(struct vm_area_struct *vma, unsigned long paddr, + unsigned long size, + const struct vm_operations_struct *vm_ops, + void *priv); +#endif + /* module_platform_driver_probe() - Helper macro for drivers that don't do * anything special in module init/exit. This eliminates a lot of * boilerplate. Each module may only use this macro once, and