video: tegra: nvmap: Take refcount on device during map

When a dma_buf is getting mapped, take refcount on that device which
will is released when dma_buf is unmapped.
The device should be alive till all its buffers are unmapped.

Bug 4402923

Change-Id: I3ad257f5bdd7e705ac94bea6e81fef0fda46fbd2
Signed-off-by: Ashish Mhetre <amhetre@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3079901
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
This commit is contained in:
Ashish Mhetre
2024-02-20 04:12:26 +00:00
committed by mobile promotions
parent 2664f7f2b7
commit ed7a856cf7

View File

@@ -180,8 +180,10 @@ static struct sg_table *nvmap_dmabuf_map_dma_buf(struct dma_buf_attachment *atta
if (sgt)
goto cache_hit;
get_device(attach->dev);
sgt = __nvmap_sg_table(NULL, info->handle);
if (IS_ERR(sgt)) {
put_device(attach->dev);
atomic_dec(&info->handle->pin);
mutex_unlock(&info->maps_lock);
return sgt;
@@ -224,6 +226,7 @@ cache_hit:
err_map:
__nvmap_free_sg_table(NULL, info->handle, sgt);
put_device(attach->dev);
atomic_dec(&info->handle->pin);
mutex_unlock(&info->maps_lock);
return ERR_PTR(-ENOMEM);
@@ -247,6 +250,7 @@ static void __nvmap_dmabuf_unmap_dma_buf(struct nvmap_handle_sgt *nvmap_sgt)
dir, DMA_ATTR_SKIP_CPU_SYNC);
}
__nvmap_free_sg_table(NULL, info->handle, sgt);
put_device(dev);
}
static void nvmap_dmabuf_unmap_dma_buf(struct dma_buf_attachment *attach,