hc
2024-02-19 1c055e55a242a33e574e48be530e06770a210dcd
kernel/drivers/media/v4l2-core/videobuf-dma-contig.c
....@@ -36,12 +36,11 @@
3636
3737 static int __videobuf_dc_alloc(struct device *dev,
3838 struct videobuf_dma_contig_memory *mem,
39
- unsigned long size, gfp_t flags)
39
+ unsigned long size)
4040 {
4141 mem->size = size;
42
- mem->vaddr = dma_alloc_coherent(dev, mem->size,
43
- &mem->dma_handle, flags);
44
-
42
+ mem->vaddr = dma_alloc_coherent(dev, mem->size, &mem->dma_handle,
43
+ GFP_KERNEL);
4544 if (!mem->vaddr) {
4645 dev_err(dev, "memory alloc size %ld failed\n", mem->size);
4746 return -ENOMEM;
....@@ -258,8 +257,7 @@
258257 return videobuf_dma_contig_user_get(mem, vb);
259258
260259 /* allocate memory for the read() method */
261
- if (__videobuf_dc_alloc(q->dev, mem, PAGE_ALIGN(vb->size),
262
- GFP_KERNEL))
260
+ if (__videobuf_dc_alloc(q->dev, mem, PAGE_ALIGN(vb->size)))
263261 return -ENOMEM;
264262 break;
265263 case V4L2_MEMORY_OVERLAY:
....@@ -295,22 +293,18 @@
295293 BUG_ON(!mem);
296294 MAGIC_CHECK(mem->magic, MAGIC_DC_MEM);
297295
298
- if (__videobuf_dc_alloc(q->dev, mem, PAGE_ALIGN(buf->bsize),
299
- GFP_KERNEL | __GFP_COMP))
296
+ if (__videobuf_dc_alloc(q->dev, mem, PAGE_ALIGN(buf->bsize)))
300297 goto error;
301
-
302
- /* Try to remap memory */
303
- vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
304298
305299 /* the "vm_pgoff" is just used in v4l2 to find the
306300 * corresponding buffer data structure which is allocated
307301 * earlier and it does not mean the offset from the physical
308302 * buffer start address as usual. So set it to 0 to pass
309
- * the sanity check in vm_iomap_memory().
303
+ * the sanity check in dma_mmap_coherent().
310304 */
311305 vma->vm_pgoff = 0;
312
-
313
- retval = vm_iomap_memory(vma, mem->dma_handle, mem->size);
306
+ retval = dma_mmap_coherent(q->dev, vma, mem->vaddr, mem->dma_handle,
307
+ mem->size);
314308 if (retval) {
315309 dev_err(q->dev, "mmap: remap failed with error %d. ",
316310 retval);