aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media/video')
-rw-r--r--drivers/media/video/videobuf-dma-contig.c53
1 files changed, 32 insertions, 21 deletions
diff --git a/drivers/media/video/videobuf-dma-contig.c b/drivers/media/video/videobuf-dma-contig.c
index 9b9a06fdd0f0..f68284655f20 100644
--- a/drivers/media/video/videobuf-dma-contig.c
+++ b/drivers/media/video/videobuf-dma-contig.c
@@ -359,32 +359,43 @@ static int __videobuf_mmap_mapper(struct videobuf_queue *q,
359 size = vma->vm_end - vma->vm_start; 359 size = vma->vm_end - vma->vm_start;
360 size = (size < mem->size) ? size : mem->size; 360 size = (size < mem->size) ? size : mem->size;
361 361
362 if (!mem->cached) 362 if (!mem->cached) {
363 vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot); 363 vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
364 364 retval = remap_pfn_range(vma, vma->vm_start,
365 pos = (unsigned long)mem->vaddr; 365 mem->dma_handle >> PAGE_SHIFT,
366 366 size, vma->vm_page_prot);
367 while (size > 0) {
368 page = virt_to_page((void *)pos);
369 if (NULL == page) {
370 dev_err(q->dev, "mmap: virt_to_page failed\n");
371 __videobuf_dc_free(q->dev, mem);
372 goto error;
373 }
374 retval = vm_insert_page(vma, start, page);
375 if (retval) { 367 if (retval) {
376 dev_err(q->dev, "mmap: insert failed with error %d\n", 368 dev_err(q->dev, "mmap: remap failed with error %d. ",
377 retval); 369 retval);
378 __videobuf_dc_free(q->dev, mem); 370 dma_free_coherent(q->dev, mem->size,
371 mem->vaddr, mem->dma_handle);
379 goto error; 372 goto error;
380 } 373 }
381 start += PAGE_SIZE; 374 } else {
382 pos += PAGE_SIZE; 375 pos = (unsigned long)mem->vaddr;
376
377 while (size > 0) {
378 page = virt_to_page((void *)pos);
379 if (NULL == page) {
380 dev_err(q->dev, "mmap: virt_to_page failed\n");
381 __videobuf_dc_free(q->dev, mem);
382 goto error;
383 }
384 retval = vm_insert_page(vma, start, page);
385 if (retval) {
386 dev_err(q->dev, "mmap: insert failed with error %d\n",
387 retval);
388 __videobuf_dc_free(q->dev, mem);
389 goto error;
390 }
391 start += PAGE_SIZE;
392 pos += PAGE_SIZE;
383 393
384 if (size > PAGE_SIZE) 394 if (size > PAGE_SIZE)
385 size -= PAGE_SIZE; 395 size -= PAGE_SIZE;
386 else 396 else
387 size = 0; 397 size = 0;
398 }
388 } 399 }
389 400
390 vma->vm_ops = &videobuf_vm_ops; 401 vma->vm_ops = &videobuf_vm_ops;