Skip to content

Commit 23543b3

Browse files
committed
media: videobuf2: Stop using internal dma-buf lock
All drivers that use dma-bufs have been moved to the updated locking specification and now dma-buf reservation is guaranteed to be locked by importers during the mapping operations. There is no need to take the internal dma-buf lock anymore. Remove locking from the videobuf2 memory allocators. Acked-by: Tomasz Figa <[email protected]> Acked-by: Hans Verkuil <[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 ae2e7f2 commit 23543b3

File tree

3 files changed

+3
-30
lines changed

3 files changed

+3
-30
lines changed

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

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -382,18 +382,12 @@ static struct sg_table *vb2_dc_dmabuf_ops_map(
382382
struct dma_buf_attachment *db_attach, enum dma_data_direction dma_dir)
383383
{
384384
struct vb2_dc_attachment *attach = db_attach->priv;
385-
/* stealing dmabuf mutex to serialize map/unmap operations */
386-
struct mutex *lock = &db_attach->dmabuf->lock;
387385
struct sg_table *sgt;
388386

389-
mutex_lock(lock);
390-
391387
sgt = &attach->sgt;
392388
/* return previously mapped sg table */
393-
if (attach->dma_dir == dma_dir) {
394-
mutex_unlock(lock);
389+
if (attach->dma_dir == dma_dir)
395390
return sgt;
396-
}
397391

398392
/* release any previous cache */
399393
if (attach->dma_dir != DMA_NONE) {
@@ -409,14 +403,11 @@ static struct sg_table *vb2_dc_dmabuf_ops_map(
409403
if (dma_map_sgtable(db_attach->dev, sgt, dma_dir,
410404
DMA_ATTR_SKIP_CPU_SYNC)) {
411405
pr_err("failed to map scatterlist\n");
412-
mutex_unlock(lock);
413406
return ERR_PTR(-EIO);
414407
}
415408

416409
attach->dma_dir = dma_dir;
417410

418-
mutex_unlock(lock);
419-
420411
return sgt;
421412
}
422413

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

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -424,18 +424,12 @@ static struct sg_table *vb2_dma_sg_dmabuf_ops_map(
424424
struct dma_buf_attachment *db_attach, enum dma_data_direction dma_dir)
425425
{
426426
struct vb2_dma_sg_attachment *attach = db_attach->priv;
427-
/* stealing dmabuf mutex to serialize map/unmap operations */
428-
struct mutex *lock = &db_attach->dmabuf->lock;
429427
struct sg_table *sgt;
430428

431-
mutex_lock(lock);
432-
433429
sgt = &attach->sgt;
434430
/* return previously mapped sg table */
435-
if (attach->dma_dir == dma_dir) {
436-
mutex_unlock(lock);
431+
if (attach->dma_dir == dma_dir)
437432
return sgt;
438-
}
439433

440434
/* release any previous cache */
441435
if (attach->dma_dir != DMA_NONE) {
@@ -446,14 +440,11 @@ static struct sg_table *vb2_dma_sg_dmabuf_ops_map(
446440
/* mapping to the client with new direction */
447441
if (dma_map_sgtable(db_attach->dev, sgt, dma_dir, 0)) {
448442
pr_err("failed to map scatterlist\n");
449-
mutex_unlock(lock);
450443
return ERR_PTR(-EIO);
451444
}
452445

453446
attach->dma_dir = dma_dir;
454447

455-
mutex_unlock(lock);
456-
457448
return sgt;
458449
}
459450

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

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -267,18 +267,12 @@ static struct sg_table *vb2_vmalloc_dmabuf_ops_map(
267267
struct dma_buf_attachment *db_attach, enum dma_data_direction dma_dir)
268268
{
269269
struct vb2_vmalloc_attachment *attach = db_attach->priv;
270-
/* stealing dmabuf mutex to serialize map/unmap operations */
271-
struct mutex *lock = &db_attach->dmabuf->lock;
272270
struct sg_table *sgt;
273271

274-
mutex_lock(lock);
275-
276272
sgt = &attach->sgt;
277273
/* return previously mapped sg table */
278-
if (attach->dma_dir == dma_dir) {
279-
mutex_unlock(lock);
274+
if (attach->dma_dir == dma_dir)
280275
return sgt;
281-
}
282276

283277
/* release any previous cache */
284278
if (attach->dma_dir != DMA_NONE) {
@@ -289,14 +283,11 @@ static struct sg_table *vb2_vmalloc_dmabuf_ops_map(
289283
/* mapping to the client with new direction */
290284
if (dma_map_sgtable(db_attach->dev, sgt, dma_dir, 0)) {
291285
pr_err("failed to map scatterlist\n");
292-
mutex_unlock(lock);
293286
return ERR_PTR(-EIO);
294287
}
295288

296289
attach->dma_dir = dma_dir;
297290

298-
mutex_unlock(lock);
299-
300291
return sgt;
301292
}
302293

0 commit comments

Comments
 (0)