V4L: videobuf, don't use dma addr as physical
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 15 lines · Linux Kernel Mailing List
Gitweb: http://git.kernel.org/linus/35d9f510b67b10338161aba6229d4f55b4000f5b Commit: 35d9f510b67b10338161aba6229d4f55b4000f5b Parent: 4093a5c4a3f59cba1a085bbf87b6ffdddc5a443d Author: Jiri Slaby <[email protected]> AuthorDate: Mon Feb 28 06:37:02 2011 -0300 Committer: Mauro Carvalho Chehab <[email protected]> CommitDate: Tue Mar 22 06:51:54 2011 -0300[media] V4L: videobuf, don't use dma addr as physical
mem->dma_handleis a dma address obtained bydma_alloc_coherentwhich needn't be a physical address in presence of IOMMU, as
a hardware IOMMU can (and most likely) will return a bus address where physical != bus address.
Quoted 5 lines
So ensure we are remapping (
remap_pfn_range) the right page in__videobuf_mmap_mapperby usingvirt_to_phys(mem->vaddr)and notmem->dma_handle.While at it, use
PFN_DOWNinstead of explicit shift.
Sadly that doesn't work on all archs either... some will return addresses in the "vmalloc" space from dma_alloc_coherent() (due to the need to create non-cachable mappings there) and you can't pass those through virt_to_phys() either.
I'm sad that thing got merged at all. This whole videobuf2 looks like an unreviewed pile of crap to me. It re-invents dma pool management, re-invents even kref's, etc...
As for mmap'ing DMA, there's an attempt at fixing that done by the Alsa folks in the form of dma_mmap_coherent(). (See sound/core/pcm_native.c).
Only ARM implements it now. We need to move the
#define ARCH_HAS_DMA_MMAP_COHERENT
Out of the sound code into an ARM header tho, that way you can use it too, and I shall implement a variant for non-coherent embedded PPCs while at it (I'll take care of that last part).
Ben.
Quoted 25 lines
[[email protected]: Fix compilation breakage due to the lack of a comma]Signed-off-by Jiri Slaby <[email protected]>Reviewed-by Konrad Rzeszutek Wilk <[email protected]>Signed-off-by Mauro Carvalho Chehab <[email protected]>--- drivers/media/video/videobuf-dma-contig.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)drivers/media/video/videobuf-dma-contig.c +1
-2@@ -300,7 +300,7 @@ static int __videobuf_mmap_mapper(struct videobuf_queue *q, vma->vm_page_prot =pgprot_noncached (vma->vm_page_prot); retval =remap_pfn_range (vma, vma->vm_start, - mem->dma_handle >>PAGE_SHIFT , +PFN_DOWN (virt_to_phys (mem->vaddr)), size, vma->vm_page_prot);if (retval) {dev_err (q->dev,"mmap: remap failed with error %d. " , retval); --To unsubscribe from this list: send the line "unsubscribe git-commits-head" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html