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);