mirror of
git://nv-tegra.nvidia.com/linux-nvgpu.git
synced 2025-12-24 02:22:34 +03:00
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:
committed by
mobile promotions
parent
19a8adeae1
commit
86c0a696ed
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2017-2021, NVIDIA CORPORATION. All rights reserved.
|
||||
* Copyright (c) 2017-2022, 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,
|
||||
@@ -14,9 +14,15 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <linux/version.h>
|
||||
#include <linux/device.h>
|
||||
#include <linux/dma-buf.h>
|
||||
#include <linux/scatterlist.h>
|
||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 18, 0)
|
||||
#include <linux/iosys-map.h>
|
||||
#elif LINUX_VERSION_CODE >= KERNEL_VERSION(5, 11, 0)
|
||||
#include <linux/dma-buf-map.h>
|
||||
#endif
|
||||
|
||||
#include <nvgpu/comptags.h>
|
||||
#include <nvgpu/enabled.h>
|
||||
@@ -318,3 +324,38 @@ out:
|
||||
*state = s;
|
||||
return err;
|
||||
}
|
||||
|
||||
void *gk20a_dmabuf_vmap(struct dma_buf *dmabuf)
|
||||
{
|
||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 11, 0)
|
||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 18, 0)
|
||||
struct iosys_map map;
|
||||
#else
|
||||
struct dma_buf_map map;
|
||||
#endif
|
||||
/* Linux v5.11 and later kernels */
|
||||
if (dma_buf_vmap(dmabuf, &map))
|
||||
return NULL;
|
||||
|
||||
return map.vaddr;
|
||||
#else
|
||||
/* Linux v5.10 and earlier kernels */
|
||||
return dma_buf_vmap(dmabuf);
|
||||
#endif
|
||||
}
|
||||
|
||||
void gk20a_dmabuf_vunmap(struct dma_buf *dmabuf, void *addr)
|
||||
{
|
||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 11, 0)
|
||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 18, 0)
|
||||
struct iosys_map map = IOSYS_MAP_INIT_VADDR(addr);
|
||||
#else
|
||||
struct dma_buf_map map = DMA_BUF_MAP_INIT_VADDR(addr);
|
||||
#endif
|
||||
/* Linux v5.11 and later kernels */
|
||||
dma_buf_vunmap(dmabuf, &map);
|
||||
#else
|
||||
/* Linux v5.10 and earlier kernels */
|
||||
dma_buf_vunmap(dmabuf, addr);
|
||||
#endif
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user