Commit 4099040e authored by Lad, Prabhakar's avatar Lad, Prabhakar Committed by Mauro Carvalho Chehab

[media] videobuf-dma-contig: restore buffer mapping for uncached bufers

from commit a8f3c203
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: default avatarLad, Prabhakar <prabhakar.lad@ti.com>
Signed-off-by: default avatarHadli, Manjunath <manjunath.hadli@ti.com>
Acked-by: default avatarFederico Vaga <federico.vaga@gmail.com>
Acked-by: default avatarHans Verkuil <hans.verkuil@cisco.com>
Cc: stable@kernel.org
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent 4faba767
...@@ -359,32 +359,43 @@ static int __videobuf_mmap_mapper(struct videobuf_queue *q, ...@@ -359,32 +359,43 @@ static int __videobuf_mmap_mapper(struct videobuf_queue *q,
size = vma->vm_end - vma->vm_start; size = vma->vm_end - vma->vm_start;
size = (size < mem->size) ? size : mem->size; size = (size < mem->size) ? size : mem->size;
if (!mem->cached) if (!mem->cached) {
vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot); vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
retval = remap_pfn_range(vma, vma->vm_start,
pos = (unsigned long)mem->vaddr; mem->dma_handle >> PAGE_SHIFT,
size, vma->vm_page_prot);
while (size > 0) {
page = virt_to_page((void *)pos);
if (NULL == page) {
dev_err(q->dev, "mmap: virt_to_page failed\n");
__videobuf_dc_free(q->dev, mem);
goto error;
}
retval = vm_insert_page(vma, start, page);
if (retval) { if (retval) {
dev_err(q->dev, "mmap: insert failed with error %d\n", dev_err(q->dev, "mmap: remap failed with error %d. ",
retval); retval);
__videobuf_dc_free(q->dev, mem); dma_free_coherent(q->dev, mem->size,
mem->vaddr, mem->dma_handle);
goto error; goto error;
} }
start += PAGE_SIZE; } else {
pos += PAGE_SIZE; pos = (unsigned long)mem->vaddr;
while (size > 0) {
page = virt_to_page((void *)pos);
if (NULL == page) {
dev_err(q->dev, "mmap: virt_to_page failed\n");
__videobuf_dc_free(q->dev, mem);
goto error;
}
retval = vm_insert_page(vma, start, page);
if (retval) {
dev_err(q->dev, "mmap: insert failed with error %d\n",
retval);
__videobuf_dc_free(q->dev, mem);
goto error;
}
start += PAGE_SIZE;
pos += PAGE_SIZE;
if (size > PAGE_SIZE) if (size > PAGE_SIZE)
size -= PAGE_SIZE; size -= PAGE_SIZE;
else else
size = 0; size = 0;
}
} }
vma->vm_ops = &videobuf_vm_ops; vma->vm_ops = &videobuf_vm_ops;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment