Skip to content

Commit a26ee3b

Browse files
committed
media: videobuf2: Prepare to dynamic dma-buf locking specification
Prepare V4L2 memory allocators to the common dynamic dma-buf locking convention by starting to use the unlocked versions of dma-buf API functions. Acked-by: Tomasz Figa <[email protected]> Acked-by: Christian König <[email protected]> Signed-off-by: Dmitry Osipenko <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
1 parent e841ad8 commit a26ee3b

File tree

3 files changed

+13
-12
lines changed

3 files changed

+13
-12
lines changed

drivers/media/common/videobuf2/videobuf2-dma-contig.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ static void *vb2_dc_vaddr(struct vb2_buffer *vb, void *buf_priv)
101101
if (buf->db_attach) {
102102
struct iosys_map map;
103103

104-
if (!dma_buf_vmap(buf->db_attach->dmabuf, &map))
104+
if (!dma_buf_vmap_unlocked(buf->db_attach->dmabuf, &map))
105105
buf->vaddr = map.vaddr;
106106

107107
return buf->vaddr;
@@ -711,7 +711,7 @@ static int vb2_dc_map_dmabuf(void *mem_priv)
711711
}
712712

713713
/* get the associated scatterlist for this buffer */
714-
sgt = dma_buf_map_attachment(buf->db_attach, buf->dma_dir);
714+
sgt = dma_buf_map_attachment_unlocked(buf->db_attach, buf->dma_dir);
715715
if (IS_ERR(sgt)) {
716716
pr_err("Error getting dmabuf scatterlist\n");
717717
return -EINVAL;
@@ -722,7 +722,8 @@ static int vb2_dc_map_dmabuf(void *mem_priv)
722722
if (contig_size < buf->size) {
723723
pr_err("contiguous chunk is too small %lu/%lu\n",
724724
contig_size, buf->size);
725-
dma_buf_unmap_attachment(buf->db_attach, sgt, buf->dma_dir);
725+
dma_buf_unmap_attachment_unlocked(buf->db_attach, sgt,
726+
buf->dma_dir);
726727
return -EFAULT;
727728
}
728729

@@ -750,10 +751,10 @@ static void vb2_dc_unmap_dmabuf(void *mem_priv)
750751
}
751752

752753
if (buf->vaddr) {
753-
dma_buf_vunmap(buf->db_attach->dmabuf, &map);
754+
dma_buf_vunmap_unlocked(buf->db_attach->dmabuf, &map);
754755
buf->vaddr = NULL;
755756
}
756-
dma_buf_unmap_attachment(buf->db_attach, sgt, buf->dma_dir);
757+
dma_buf_unmap_attachment_unlocked(buf->db_attach, sgt, buf->dma_dir);
757758

758759
buf->dma_addr = 0;
759760
buf->dma_sgt = NULL;

drivers/media/common/videobuf2/videobuf2-dma-sg.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ static void *vb2_dma_sg_vaddr(struct vb2_buffer *vb, void *buf_priv)
309309

310310
if (!buf->vaddr) {
311311
if (buf->db_attach) {
312-
ret = dma_buf_vmap(buf->db_attach->dmabuf, &map);
312+
ret = dma_buf_vmap_unlocked(buf->db_attach->dmabuf, &map);
313313
buf->vaddr = ret ? NULL : map.vaddr;
314314
} else {
315315
buf->vaddr = vm_map_ram(buf->pages, buf->num_pages, -1);
@@ -565,7 +565,7 @@ static int vb2_dma_sg_map_dmabuf(void *mem_priv)
565565
}
566566

567567
/* get the associated scatterlist for this buffer */
568-
sgt = dma_buf_map_attachment(buf->db_attach, buf->dma_dir);
568+
sgt = dma_buf_map_attachment_unlocked(buf->db_attach, buf->dma_dir);
569569
if (IS_ERR(sgt)) {
570570
pr_err("Error getting dmabuf scatterlist\n");
571571
return -EINVAL;
@@ -594,10 +594,10 @@ static void vb2_dma_sg_unmap_dmabuf(void *mem_priv)
594594
}
595595

596596
if (buf->vaddr) {
597-
dma_buf_vunmap(buf->db_attach->dmabuf, &map);
597+
dma_buf_vunmap_unlocked(buf->db_attach->dmabuf, &map);
598598
buf->vaddr = NULL;
599599
}
600-
dma_buf_unmap_attachment(buf->db_attach, sgt, buf->dma_dir);
600+
dma_buf_unmap_attachment_unlocked(buf->db_attach, sgt, buf->dma_dir);
601601

602602
buf->dma_sgt = NULL;
603603
}

drivers/media/common/videobuf2/videobuf2-vmalloc.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@ static int vb2_vmalloc_map_dmabuf(void *mem_priv)
376376
struct iosys_map map;
377377
int ret;
378378

379-
ret = dma_buf_vmap(buf->dbuf, &map);
379+
ret = dma_buf_vmap_unlocked(buf->dbuf, &map);
380380
if (ret)
381381
return -EFAULT;
382382
buf->vaddr = map.vaddr;
@@ -389,7 +389,7 @@ static void vb2_vmalloc_unmap_dmabuf(void *mem_priv)
389389
struct vb2_vmalloc_buf *buf = mem_priv;
390390
struct iosys_map map = IOSYS_MAP_INIT_VADDR(buf->vaddr);
391391

392-
dma_buf_vunmap(buf->dbuf, &map);
392+
dma_buf_vunmap_unlocked(buf->dbuf, &map);
393393
buf->vaddr = NULL;
394394
}
395395

@@ -399,7 +399,7 @@ static void vb2_vmalloc_detach_dmabuf(void *mem_priv)
399399
struct iosys_map map = IOSYS_MAP_INIT_VADDR(buf->vaddr);
400400

401401
if (buf->vaddr)
402-
dma_buf_vunmap(buf->dbuf, &map);
402+
dma_buf_vunmap_unlocked(buf->dbuf, &map);
403403

404404
kfree(buf);
405405
}

0 commit comments

Comments
 (0)