From 9fab6f05af5777e242a4105c6870d2c19a5c5009 Mon Sep 17 00:00:00 2001 From: Jon Hunter Date: Fri, 28 Jul 2023 17:16:45 +0100 Subject: [PATCH] gpu: nvgpu: Add compilation flag for iosys-map.h Determining whether the header file iosys-map.h is present in the kernel is currently determine by kernel version. However, for Linux v5.15, iosys-map.h has been backported in order to support simple-framebuffer for early display. Therefore, we cannot rely on the kernel version to indicate whether iosys-map is present. This is also true for 3rd party Linux kernels that backport changes as well. Fix this by adding a compile time flag, that will be set accordingly by the conftest script if this header is present. Bug 4119327 Bug 4228080 Change-Id: I303b1060643b18709a236be5e0268d39cf540054 Signed-off-by: Jon Hunter Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvgpu/+/2974081 (cherry picked from commit 41c1afb165122e98004005b8513d131b492269e9) Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvgpu/+/2946965 Reviewed-by: Sagar Kamble GVS: Gerrit_Virtual_Submit --- drivers/gpu/nvgpu/Makefile | 1 + drivers/gpu/nvgpu/Makefile.linux.configs | 1 + drivers/gpu/nvgpu/os/linux/dmabuf_priv.c | 10 +++++++--- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/nvgpu/Makefile b/drivers/gpu/nvgpu/Makefile index c1c261134..7148e6689 100644 --- a/drivers/gpu/nvgpu/Makefile +++ b/drivers/gpu/nvgpu/Makefile @@ -54,6 +54,7 @@ endif # When compiling as OOT module, include the headers from nvidia-oot tree. ifeq ($(CONFIG_TEGRA_OOT_MODULE),m) +ccflags-y += -I$(srctree.nvconftest) ccflags-y += -I$(srctree.nvidia)/include endif diff --git a/drivers/gpu/nvgpu/Makefile.linux.configs b/drivers/gpu/nvgpu/Makefile.linux.configs index 97431350a..31d441dd2 100644 --- a/drivers/gpu/nvgpu/Makefile.linux.configs +++ b/drivers/gpu/nvgpu/Makefile.linux.configs @@ -49,6 +49,7 @@ CONFIG_NVGPU_SUPPORT_GV11B := y ifeq ($(CONFIG_TEGRA_OOT_MODULE),m) CONFIG_TEGRA_HOST1X_NEXT := m CONFIG_TEGRA_NVMAP_NEXT := m +ccflags-y += -DCONFIG_NVIDIA_CONFTEST ifeq ($(CONFIG_TEGRA_VIRTUALIZATION),y) CONFIG_TEGRA_GR_VIRTUALIZATION := y ccflags-y += -DCONFIG_TEGRA_GR_VIRTUALIZATION diff --git a/drivers/gpu/nvgpu/os/linux/dmabuf_priv.c b/drivers/gpu/nvgpu/os/linux/dmabuf_priv.c index 4d8f63b30..cbfc1cb0b 100644 --- a/drivers/gpu/nvgpu/os/linux/dmabuf_priv.c +++ b/drivers/gpu/nvgpu/os/linux/dmabuf_priv.c @@ -14,6 +14,10 @@ * along with this program. If not, see . */ +#if defined(CONFIG_NVIDIA_CONFTEST) +#include +#endif + #include #include #include @@ -25,7 +29,7 @@ #endif #include #include -#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 18, 0) +#if defined(NV_LINUX_IOSYS_MAP_H_PRESENT) #include #elif LINUX_VERSION_CODE >= KERNEL_VERSION(5, 11, 0) #include @@ -358,7 +362,7 @@ out: static 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) +#if defined(NV_LINUX_IOSYS_MAP_H_PRESENT) struct iosys_map map = {0}; #else struct dma_buf_map map = {0}; @@ -386,7 +390,7 @@ void *gk20a_dmabuf_vmap(struct dma_buf *dmabuf) 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) +#if defined(NV_LINUX_IOSYS_MAP_H_PRESENT) struct iosys_map map = IOSYS_MAP_INIT_VADDR(addr); #else struct dma_buf_map map = DMA_BUF_MAP_INIT_VADDR(addr);