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

@@ -32,6 +32,7 @@
#include <nvgpu/tsg.h>
#include <nvgpu/fb.h>
#include "dmabuf_priv.h"
#include "platform_gk20a.h"
#include "os_linux.h"
#include "ioctl_prof.h"
@@ -380,9 +381,6 @@ static int nvgpu_prof_ioctl_alloc_pma_stream(struct nvgpu_profiler_object_priv *
u64 pma_buffer_offset;
struct dma_buf *pma_dmabuf;
struct dma_buf *pma_bytes_available_dmabuf;
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 11, 0)
struct dma_buf_map map;
#endif
void *cpuva;
u32 pma_buffer_size;
int err;
@@ -452,12 +450,7 @@ 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(pma_bytes_available_dmabuf, &map);
cpuva = err ? NULL : map.vaddr;
#else
cpuva = dma_buf_vmap(pma_bytes_available_dmabuf);
#endif
cpuva = gk20a_dmabuf_vmap(pma_bytes_available_dmabuf);
if (cpuva == NULL) {
err = -ENOMEM;
nvgpu_err(g, "failed to vmap available bytes buffer FD");
@@ -501,9 +494,6 @@ 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;
@@ -516,13 +506,8 @@ 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,
gk20a_dmabuf_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;