mirror of
git://nv-tegra.nvidia.com/linux-nv-oot.git
synced 2025-12-22 09:11:26 +03:00
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:
committed by
mobile promotions
parent
2664f7f2b7
commit
ed7a856cf7
@@ -180,8 +180,10 @@ static struct sg_table *nvmap_dmabuf_map_dma_buf(struct dma_buf_attachment *atta
|
|||||||
if (sgt)
|
if (sgt)
|
||||||
goto cache_hit;
|
goto cache_hit;
|
||||||
|
|
||||||
|
get_device(attach->dev);
|
||||||
sgt = __nvmap_sg_table(NULL, info->handle);
|
sgt = __nvmap_sg_table(NULL, info->handle);
|
||||||
if (IS_ERR(sgt)) {
|
if (IS_ERR(sgt)) {
|
||||||
|
put_device(attach->dev);
|
||||||
atomic_dec(&info->handle->pin);
|
atomic_dec(&info->handle->pin);
|
||||||
mutex_unlock(&info->maps_lock);
|
mutex_unlock(&info->maps_lock);
|
||||||
return sgt;
|
return sgt;
|
||||||
@@ -224,6 +226,7 @@ cache_hit:
|
|||||||
|
|
||||||
err_map:
|
err_map:
|
||||||
__nvmap_free_sg_table(NULL, info->handle, sgt);
|
__nvmap_free_sg_table(NULL, info->handle, sgt);
|
||||||
|
put_device(attach->dev);
|
||||||
atomic_dec(&info->handle->pin);
|
atomic_dec(&info->handle->pin);
|
||||||
mutex_unlock(&info->maps_lock);
|
mutex_unlock(&info->maps_lock);
|
||||||
return ERR_PTR(-ENOMEM);
|
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);
|
dir, DMA_ATTR_SKIP_CPU_SYNC);
|
||||||
}
|
}
|
||||||
__nvmap_free_sg_table(NULL, info->handle, sgt);
|
__nvmap_free_sg_table(NULL, info->handle, sgt);
|
||||||
|
put_device(dev);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void nvmap_dmabuf_unmap_dma_buf(struct dma_buf_attachment *attach,
|
static void nvmap_dmabuf_unmap_dma_buf(struct dma_buf_attachment *attach,
|
||||||
|
|||||||
Reference in New Issue
Block a user