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,5 +1,5 @@
/*
* Copyright (c) 2020, NVIDIA CORPORATION. All rights reserved.
* Copyright (c) 2020-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,
@@ -351,6 +351,9 @@ static int nvgpu_prof_ioctl_alloc_pma_stream(struct nvgpu_profiler_object_priv *
struct mm_gk20a *mm = &g->mm;
u64 pma_bytes_available_buffer_offset;
struct dma_buf *dmabuf;
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 11, 0)
struct dma_buf_map map;
#endif
void *cpuva;
u32 pma_buffer_size;
int err;
@@ -405,7 +408,12 @@ static int nvgpu_prof_ioctl_alloc_pma_stream(struct nvgpu_profiler_object_priv *
goto err_unmap_pma;
}
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 11, 0)
err = dma_buf_vmap(dmabuf, &map);
cpuva = err ? NULL : map.vaddr;
#else
cpuva = dma_buf_vmap(dmabuf);
#endif
if (cpuva == NULL) {
err = -ENOMEM;
nvgpu_err(g, "failed to vmap available bytes buffer FD");
@@ -444,6 +452,9 @@ static void nvgpu_prof_free_pma_stream_priv_data(struct nvgpu_profiler_object_pr
struct nvgpu_profiler_object *prof = priv->prof;
struct gk20a *g = prof->g;
struct mm_gk20a *mm = &g->mm;
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 11, 0)
struct dma_buf_map map;
#endif
if (priv->pma_bytes_available_buffer_dmabuf == NULL) {
return;
@@ -456,8 +467,13 @@ static void nvgpu_prof_free_pma_stream_priv_data(struct nvgpu_profiler_object_pr
prof->pma_buffer_va = 0U;
prof->pma_buffer_size = 0U;
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 11, 0)
dma_buf_map_set_vaddr(&map, prof->pma_bytes_available_buffer_cpuva);
dma_buf_vunmap(priv->pma_bytes_available_buffer_dmabuf, &map);
#else
dma_buf_vunmap(priv->pma_bytes_available_buffer_dmabuf,
prof->pma_bytes_available_buffer_cpuva);
#endif
dma_buf_put(priv->pma_bytes_available_buffer_dmabuf);
priv->pma_bytes_available_buffer_dmabuf = NULL;
prof->pma_bytes_available_buffer_cpuva = NULL;