gpu: nvgpu: Add support for Linux v5.11

For Linux v5.11, commit 6619ccf1bb1d ("dma-buf: Use struct dma_buf_map
in dma_buf_vmap() interfaces") changes to the dma_buf_vmap() and
dma_buf_vunmap() APIs to pass a new parameter of type
'struct dma_buf_map'. Update the NVGPU to support these updated APIs
for Linux v5.11+.

Finally, the legacy dma_buf_vmap() API returns NULL on error and not an
error code and so correct the test of the return value in the function
gk20a_cde_convert().

Bug 200687525

Change-Id: Ie20f101e965fa0f2c650d9b30ff4558ce1256c12
Signed-off-by: Jon Hunter <jonathanh@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvgpu/+/2469555
Reviewed-by: Sagar Kamble <skamble@nvidia.com>
Reviewed-by: Alex Waterman <alexw@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
GVS: Gerrit_Virtual_Submit
This commit is contained in:
Jon Hunter
2021-01-12 19:10:02 +00:00
committed by mobile promotions
parent a03da4a077
commit ddf8f12197
4 changed files with 127 additions and 10 deletions

View File

@@ -1,7 +1,7 @@
/*
* Color decompression engine support
*
* Copyright (c) 2014-2020, NVIDIA Corporation. All rights reserved.
* Copyright (c) 2014-2021, NVIDIA Corporation. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
@@ -1042,6 +1042,9 @@ __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);
@@ -1128,10 +1131,14 @@ __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);
if (IS_ERR(surface)) {
nvgpu_warn(g,
"dma_buf_vmap failed");
#endif
if (!surface) {
nvgpu_warn(g, "dma_buf_vmap failed");
err = -EINVAL;
goto exit_unmap_vaddr;
}
@@ -1178,7 +1185,11 @@ __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
surface = NULL;
}
@@ -1268,7 +1279,11 @@ __releases(&l->cde_app->mutex)
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
}
exit_unmap_vaddr:
nvgpu_vm_unmap(cde_ctx->vm, map_vaddr, NULL);