gpu: nvgpu: Fix build for Linux v5.18

Upstream commit 7938f4218168 ("dma-buf-map: Rename to iosys-map")
renames 'struct dma_buf_map' to 'struct iosys_map' and breaks building
the NVGPU driver with Linux v5.18-rc1. In the NVGPU driver there are
many places where 'dma_buf_map' is used and so to clean-up the code and
minimise the impact of this change, add a gk20a_dmabuf_vmap() and a
gk20a_dmabuf_vunmap() helper function. These new functions support all
kernel versions and eliminate a lot the KERNEL_VERSION ifdefs.

Bug 3598986

Change-Id: Id0f904ec0662f20f3d699b74efd9542d12344228
Signed-off-by: Jon Hunter <jonathanh@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvgpu/+/2693970
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
This commit is contained in:
Jon Hunter
2022-04-06 17:11:31 +01:00
committed by mobile promotions
parent 19a8adeae1
commit 86c0a696ed
7 changed files with 73 additions and 153 deletions

View File

@@ -1042,9 +1042,6 @@ __releases(&l->cde_app->mutex)
const s16 compbits_kind = 0;
u32 submit_op;
struct dma_buf_attachment *attachment;
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 11, 0)
struct dma_buf_map map;
#endif
nvgpu_log(g, gpu_dbg_cde, "compbits_byte_offset=%llu scatterbuffer_byte_offset=%llu",
compbits_byte_offset, scatterbuffer_byte_offset);
@@ -1135,12 +1132,7 @@ __releases(&l->cde_app->mutex)
struct sg_table *sgt;
void *scatter_buffer;
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 11, 0)
err = dma_buf_vmap(compbits_scatter_buf, &map);
surface = err ? NULL : map.vaddr;
#else
surface = dma_buf_vmap(compbits_scatter_buf);
#endif
surface = gk20a_dmabuf_vmap(compbits_scatter_buf);
if (!surface) {
nvgpu_warn(g, "dma_buf_vmap failed");
err = -EINVAL;
@@ -1189,11 +1181,7 @@ __releases(&l->cde_app->mutex)
goto exit_unmap_surface;
}
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 11, 0)
dma_buf_vunmap(compbits_scatter_buf, &map);
#else
dma_buf_vunmap(compbits_scatter_buf, surface);
#endif
gk20a_dmabuf_vunmap(compbits_scatter_buf, surface);
surface = NULL;
}
@@ -1282,13 +1270,8 @@ __releases(&l->cde_app->mutex)
return err;
exit_unmap_surface:
if (surface) {
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 11, 0)
dma_buf_vunmap(compbits_scatter_buf, &map);
#else
dma_buf_vunmap(compbits_scatter_buf, surface);
#endif
}
if (surface)
gk20a_dmabuf_vunmap(compbits_scatter_buf, surface);
exit_unmap_vaddr:
nvgpu_vm_unmap(cde_ctx->vm, map_vaddr, NULL);
exit_idle: