aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/videobuf-dma-contig.c
diff options
context:
space:
mode:
authorLad, Prabhakar <prabhakar.lad@ti.com>2012-06-22 05:19:28 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2012-07-30 17:52:56 -0400
commit4099040eaaa4fe543c4e915b8cab51b1d843edee (patch)
tree6d91bf61b5fe963240d69fd0252e4c69e5ddc677 /drivers/media/video/videobuf-dma-contig.c
parent4faba767c6243b43ad975406fe027be7394e4591 (diff)
[media] videobuf-dma-contig: restore buffer mapping for uncached bufers
from commit a8f3c203e19b702fa5e8e83a9b6fb3c5a6d1cce4 restore the mapping scheme for uncached buffers, which was changed in a common scheme for cached and uncached. This apparently was wrong, and was probably intended only for cached buffers. the fix fixes the crash observed while mapping uncached buffers. Signed-off-by: Lad, Prabhakar <prabhakar.lad@ti.com> Signed-off-by: Hadli, Manjunath <manjunath.hadli@ti.com> Acked-by: Federico Vaga <federico.vaga@gmail.com> Acked-by: Hans Verkuil <hans.verkuil@cisco.com> Cc: stable@kernel.org Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/video/videobuf-dma-contig.c')
-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;