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

@@ -433,14 +433,9 @@ int nvgpu_usermode_buf_from_dmabuf(struct gk20a *g, int dmabuf_fd,
goto put_dmabuf;
}
err = gk20a_dmabuf_alloc_drvdata(dmabuf, dev);
if (err != 0) {
goto put_dmabuf;
}
sgt = nvgpu_mm_pin_privdata(dev, dmabuf, &attachment);
sgt = nvgpu_mm_pin(dev, dmabuf, &attachment);
if (IS_ERR(sgt)) {
nvgpu_warn(g, "Failed to pin dma_buf!");
nvgpu_err(g, "Failed to pin dma_buf!");
err = PTR_ERR(sgt);
goto put_dmabuf;
}
@@ -476,7 +471,7 @@ void nvgpu_os_channel_free_usermode_buffers(struct nvgpu_channel *c)
struct device *dev = dev_from_gk20a(g);
if (priv->usermode.gpfifo.dmabuf != NULL) {
nvgpu_mm_unpin_privdata(dev, priv->usermode.gpfifo.dmabuf,
nvgpu_mm_unpin(dev, priv->usermode.gpfifo.dmabuf,
priv->usermode.gpfifo.attachment,
priv->usermode.gpfifo.sgt);
dma_buf_put(priv->usermode.gpfifo.dmabuf);
@@ -484,7 +479,7 @@ void nvgpu_os_channel_free_usermode_buffers(struct nvgpu_channel *c)
}
if (priv->usermode.userd.dmabuf != NULL) {
nvgpu_mm_unpin_privdata(dev, priv->usermode.userd.dmabuf,
nvgpu_mm_unpin(dev, priv->usermode.userd.dmabuf,
priv->usermode.userd.attachment,
priv->usermode.userd.sgt);
dma_buf_put(priv->usermode.userd.dmabuf);
@@ -547,7 +542,7 @@ static int nvgpu_channel_alloc_usermode_buffers(struct nvgpu_channel *c,
unmap_free_gpfifo:
nvgpu_dma_unmap_free(c->vm, &c->usermode_gpfifo);
free_gpfifo:
nvgpu_mm_unpin_privdata(dev, priv->usermode.gpfifo.dmabuf,
nvgpu_mm_unpin(dev, priv->usermode.gpfifo.dmabuf,
priv->usermode.gpfifo.attachment,
priv->usermode.gpfifo.sgt);
dma_buf_put(priv->usermode.gpfifo.dmabuf);