[Intel-gfx] [PATCH v3 9/9] dma-buf: Remove internal lock
Christian König
christian.koenig at amd.com
Wed Aug 24 14:10:31 UTC 2022
Am 24.08.22 um 12:22 schrieb Dmitry Osipenko:
> The internal dma-buf lock isn't needed anymore because the updated
> locking specification claims that dma-buf reservation must be locked
> by importers, and thus, the internal data is already protected by the
> reservation lock. Remove the obsoleted internal lock.
>
> Signed-off-by: Dmitry Osipenko <dmitry.osipenko at collabora.com>
Reviewed-by: Christian König <christian.koenig at amd.com>
> ---
> drivers/dma-buf/dma-buf.c | 14 ++++----------
> include/linux/dma-buf.h | 9 ---------
> 2 files changed, 4 insertions(+), 19 deletions(-)
>
> diff --git a/drivers/dma-buf/dma-buf.c b/drivers/dma-buf/dma-buf.c
> index 696d132b02f4..a0406254f0ae 100644
> --- a/drivers/dma-buf/dma-buf.c
> +++ b/drivers/dma-buf/dma-buf.c
> @@ -656,7 +656,6 @@ struct dma_buf *dma_buf_export(const struct dma_buf_export_info *exp_info)
>
> dmabuf->file = file;
>
> - mutex_init(&dmabuf->lock);
> INIT_LIST_HEAD(&dmabuf->attachments);
>
> mutex_lock(&db_list.lock);
> @@ -1503,7 +1502,7 @@ EXPORT_SYMBOL_NS_GPL(dma_buf_mmap_unlocked, DMA_BUF);
> int dma_buf_vmap(struct dma_buf *dmabuf, struct iosys_map *map)
> {
> struct iosys_map ptr;
> - int ret = 0;
> + int ret;
>
> iosys_map_clear(map);
>
> @@ -1515,28 +1514,25 @@ int dma_buf_vmap(struct dma_buf *dmabuf, struct iosys_map *map)
> if (!dmabuf->ops->vmap)
> return -EINVAL;
>
> - mutex_lock(&dmabuf->lock);
> if (dmabuf->vmapping_counter) {
> dmabuf->vmapping_counter++;
> BUG_ON(iosys_map_is_null(&dmabuf->vmap_ptr));
> *map = dmabuf->vmap_ptr;
> - goto out_unlock;
> + return 0;
> }
>
> BUG_ON(iosys_map_is_set(&dmabuf->vmap_ptr));
>
> ret = dmabuf->ops->vmap(dmabuf, &ptr);
> if (WARN_ON_ONCE(ret))
> - goto out_unlock;
> + return ret;
>
> dmabuf->vmap_ptr = ptr;
> dmabuf->vmapping_counter = 1;
>
> *map = dmabuf->vmap_ptr;
>
> -out_unlock:
> - mutex_unlock(&dmabuf->lock);
> - return ret;
> + return 0;
> }
> EXPORT_SYMBOL_NS_GPL(dma_buf_vmap, DMA_BUF);
>
> @@ -1578,13 +1574,11 @@ void dma_buf_vunmap(struct dma_buf *dmabuf, struct iosys_map *map)
> BUG_ON(dmabuf->vmapping_counter == 0);
> BUG_ON(!iosys_map_is_equal(&dmabuf->vmap_ptr, map));
>
> - mutex_lock(&dmabuf->lock);
> if (--dmabuf->vmapping_counter == 0) {
> if (dmabuf->ops->vunmap)
> dmabuf->ops->vunmap(dmabuf, map);
> iosys_map_clear(&dmabuf->vmap_ptr);
> }
> - mutex_unlock(&dmabuf->lock);
> }
> EXPORT_SYMBOL_NS_GPL(dma_buf_vunmap, DMA_BUF);
>
> diff --git a/include/linux/dma-buf.h b/include/linux/dma-buf.h
> index d48d534dc55c..aed6695bbb50 100644
> --- a/include/linux/dma-buf.h
> +++ b/include/linux/dma-buf.h
> @@ -326,15 +326,6 @@ struct dma_buf {
> /** @ops: dma_buf_ops associated with this buffer object. */
> const struct dma_buf_ops *ops;
>
> - /**
> - * @lock:
> - *
> - * Used internally to serialize list manipulation, attach/detach and
> - * vmap/unmap. Note that in many cases this is superseeded by
> - * dma_resv_lock() on @resv.
> - */
> - struct mutex lock;
> -
> /**
> * @vmapping_counter:
> *
More information about the Intel-gfx
mailing list