gpu: nvgpu: avoid using priv data for non-compressed buffer

Instead of allocating priv data for all external buffers, allocate
only on a demand basis for when compression is requested either in CDE
or via libnvrm_gpu.

This will allow allocators like nvidia-drm to use non-compressed
buffers without needing to avoid the core drm checks.
e.g. drm_gem_prime_import_dev that checks for
if (dma_buf->ops == &drm_gem_prime_dmabuf_ops)"

This patch also gets rid of optimization of dma_buf's attach/detach
calls. Now, nvgpu instead needs to call attach/detach for everytime
the dmabuf fd is imported.

Change-Id: Idefd269b32974106e85ff09e17ebc752b92f830c
Signed-off-by: Debarshi Dutta <ddutta@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvgpu/+/2372213
Tested-by: Yogish Kulkarni <yogishk@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Reviewed-by: automaticguardword <automaticguardword@nvidia.com>
Reviewed-by: Sagar Kamble <skamble@nvidia.com>
Reviewed-by: Alex Waterman <alexw@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
This commit is contained in:
Debarshi Dutta
2020-07-08 13:31:13 +05:30
committed by Alex Waterman
parent 58ce9156a8
commit 08ec6e874d
6 changed files with 48 additions and 87 deletions

View File

@@ -1140,10 +1140,10 @@ __releases(&l->cde_app->mutex)
nvgpu_log(g, gpu_dbg_cde, "surface=0x%p scatterBuffer=0x%p",
surface, scatter_buffer);
sgt = nvgpu_mm_pin_privdata(dev_from_gk20a(g), compbits_scatter_buf,
sgt = nvgpu_mm_pin(dev_from_gk20a(g), compbits_scatter_buf,
&attachment);
if (IS_ERR(sgt)) {
nvgpu_warn(g,
nvgpu_err(g,
"mm_pin failed");
err = -EINVAL;
goto exit_unmap_surface;
@@ -1156,7 +1156,7 @@ __releases(&l->cde_app->mutex)
#endif
if (err != 0) {
nvgpu_warn(g, "buffer access setup failed");
nvgpu_mm_unpin_privdata(dev_from_gk20a(g), compbits_scatter_buf,
nvgpu_mm_unpin(dev_from_gk20a(g), compbits_scatter_buf,
attachment, sgt);
goto exit_unmap_surface;
}
@@ -1172,7 +1172,7 @@ __releases(&l->cde_app->mutex)
#endif
WARN_ON(err);
nvgpu_mm_unpin_privdata(dev_from_gk20a(g), compbits_scatter_buf,
nvgpu_mm_unpin(dev_from_gk20a(g), compbits_scatter_buf,
attachment, sgt);
if (err)
goto exit_unmap_surface;