Skip to contentSkip to conversation

videobuf-dma-contig: replace vm_iomap_memory() with remap_pfn_range().

PATCH New Fancy Fang 1 participant 1 message Sep 2, 2014 Media (V4L/DVB)

lore
Share & tools
lore

Fancy Fang

author
#0 lore raw

PATCH 1/1 videobuf-dma-contig: replace vm_iomap_memory() with remap_pfn_range().

When user requests V4L2_MEMORY_MMAP type buffers, the videobuf-core will assign the corresponding offset to the 'boff' field of the videobuf_buffer for each requested buffer sequentially. Later, user may call mmap() to map one or all of the buffers with the 'offset' parameter which is equal to its 'boff' value. Obviously, the 'offset' value is only used to find the matched buffer instead of to be the real offset from the buffer's physical start address as used by vm_iomap_memory(). So, in some case that if the offset is not zero, vm_iomap_memory() will fail.

---
 drivers/media/v4l2-core/videobuf-dma-contig.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/media/v4l2-core/videobuf-dma-contig.c +3 -1
index bf80f0f..8bd9889 100644
@@ -305,7 +305,9 @@ static int __videobuf_mmap_mapper(struct videobuf_queue *q,
 	/* Try to remap memory */
 	size = vma->vm_end - vma->vm_start;
 	vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
-	retval = vm_iomap_memory(vma, mem->dma_handle, size);
+	retval = remap_pfn_range(vma, vma->vm_start,
+				 mem->dma_handle >> PAGE_SHIFT,
+				 size, vma->vm_page_prot);
 	if (retval) {
 		dev_err(q->dev, "mmap: remap failed with error %d. ",
 			retval);
Signature · 1 line
1.9.1