From 50850d5851a41385e762d83bc3b0c2fef7a3ca4e Mon Sep 17 00:00:00 2001 From: Chris Dragan Date: Wed, 19 Apr 2023 10:00:35 -0700 Subject: [PATCH] misc: mods: import module DMA_BUF if needed Bug 4036660 Change-Id: I687d582151615b50d7402d26d2f64fe604fc1d7c Signed-off-by: Chris Dragan Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/2890935 Reviewed-by: svcacv Reviewed-by: Sachin Nikam GVS: Gerrit_Virtual_Submit --- drivers/misc/mods/Makefile | 3 +-- drivers/misc/mods/mods_dmabuf.c | 6 +++++- drivers/misc/mods/mods_internal.h | 4 ++-- drivers/misc/mods/mods_krnl.c | 2 +- 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/drivers/misc/mods/Makefile b/drivers/misc/mods/Makefile index 4d9132a0..a01b29d8 100644 --- a/drivers/misc/mods/Makefile +++ b/drivers/misc/mods/Makefile @@ -20,6 +20,7 @@ mods-$(CONFIG_TEGRA_IVC) += mods_bpmpipc.o mods-$(CONFIG_COMMON_CLK) += mods_clock.o mods-$(CONFIG_DEBUG_FS) += mods_debugfs.o mods-$(CONFIG_DMA_ENGINE) += mods_dma.o +mods-$(CONFIG_DMA_SHARED_BUFFER) += mods_dmabuf.o mods-$(CONFIG_ARCH_TEGRA) += mods_ipi.o mods-$(CONFIG_NET) += mods_netdevice.o mods-$(CONFIG_ARCH_TEGRA) += mods_oist.o @@ -33,8 +34,6 @@ mods-$(CONFIG_TRUSTY) += mods_tz.o mods-objs := mods.dtb.o ifneq ($(CONFIG_TEGRA_OOT_MODULE),m) -ccflags-y += -DMODS_HAS_DMABUF ccflags-y += -DMODS_HAS_PROD -mods-$(CONFIG_DMA_SHARED_BUFFER) += mods_dmabuf.o mods-$(CONFIG_ARCH_TEGRA) += mods_tegraprod.o endif diff --git a/drivers/misc/mods/mods_dmabuf.c b/drivers/misc/mods/mods_dmabuf.c index b55ab093..051d1800 100644 --- a/drivers/misc/mods/mods_dmabuf.c +++ b/drivers/misc/mods/mods_dmabuf.c @@ -2,7 +2,7 @@ /* * This file is part of NVIDIA MODS kernel driver. * - * Copyright (c) 2014-2022, NVIDIA CORPORATION. All rights reserved. + * Copyright (c) 2014-2023, NVIDIA CORPORATION. All rights reserved. * * NVIDIA MODS kernel driver is free software: you can redistribute it and/or * modify it under the terms of the GNU General Public License, @@ -25,6 +25,10 @@ #include "mods_internal.h" +#if KERNEL_VERSION(5, 4, 0) <= MODS_KERNEL_VERSION +MODULE_IMPORT_NS(DMA_BUF); +#endif + static struct device *dummy_device; static bool dummy_device_registered; diff --git a/drivers/misc/mods/mods_internal.h b/drivers/misc/mods/mods_internal.h index a25c8cf7..31b3aa20 100644 --- a/drivers/misc/mods/mods_internal.h +++ b/drivers/misc/mods/mods_internal.h @@ -671,7 +671,7 @@ int esc_mods_net_force_link(struct mods_client *client, struct MODS_NET_DEVICE_NAME *p); #endif -#if defined(MODS_HAS_DMABUF) && defined(CONFIG_DMA_SHARED_BUFFER) +#if defined(MODS_HAS_TEGRA) && defined(CONFIG_DMA_SHARED_BUFFER) int esc_mods_dmabuf_get_phys_addr(struct mods_client *client, struct MODS_DMABUF_GET_PHYSICAL_ADDRESS *p); #else @@ -735,7 +735,7 @@ static inline int mods_create_debugfs(struct miscdevice *modsdev) static inline void mods_remove_debugfs(void) {} #endif /* CONFIG_DEBUG_FS */ -#if defined(MODS_HAS_DMABUF) && defined(CONFIG_DMA_SHARED_BUFFER) +#if defined(MODS_HAS_TEGRA) && defined(CONFIG_DMA_SHARED_BUFFER) int mods_init_dmabuf(void); void mods_exit_dmabuf(void); #else diff --git a/drivers/misc/mods/mods_krnl.c b/drivers/misc/mods/mods_krnl.c index 135d7545..105b1ee4 100644 --- a/drivers/misc/mods/mods_krnl.c +++ b/drivers/misc/mods/mods_krnl.c @@ -2656,7 +2656,7 @@ static long mods_krnl_ioctl(struct file *fp, MODS_FLUSH_CPU_CACHE_RANGE); break; #endif -#if defined(MODS_HAS_DMABUF) +#if defined(MODS_HAS_TEGRA) && defined(CONFIG_DMA_SHARED_BUFFER) case MODS_ESC_DMABUF_GET_PHYSICAL_ADDRESS: MODS_IOCTL(MODS_ESC_DMABUF_GET_PHYSICAL_ADDRESS, esc_mods_dmabuf_get_phys_addr,