nvsciipc: use CONFIG_TEGRA_VIRTUALIZATION

Use CONFIG_TEGRA_VIRTUALIZATION to remove dependency on
ivc-cdev.ko and tegra_hv.ko in native Linux.

Bug 3861841

Change-Id: I671a0eec76713715d7fc79cb730aeaa7ab460043
Signed-off-by: Joshua Cha <joshuac@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/2830878
Reviewed-by: svcacv <svcacv@nvidia.com>
Reviewed-by: Suresh Venkatachalam <skathirampat@nvidia.com>
Reviewed-by: Kurt Yi <kyi@nvidia.com>
GVS: Gerrit_Virtual_Submit <buildbot_gerritrpt@nvidia.com>
This commit is contained in:
Joshua Cha
2022-12-20 08:52:26 +08:00
committed by mobile promotions
parent 46858f60e8
commit 7f189297bd
2 changed files with 20 additions and 0 deletions

View File

@@ -5,5 +5,11 @@
# Makefile for NvSciIpc driver # Makefile for NvSciIpc driver
# #
ifeq ($(CONFIG_TEGRA_OOT_MODULE),m)
ccflags-y += -DCONFIG_TEGRA_OOT_MODULE
ifeq ($(CONFIG_TEGRA_VIRTUALIZATION),y)
ccflags-y += -DCONFIG_TEGRA_VIRTUALIZATION
endif
endif
obj-m += nvsciipc.o obj-m += nvsciipc.o

View File

@@ -31,9 +31,13 @@
#include <linux/of.h> #include <linux/of.h>
#include <linux/fs.h> #include <linux/fs.h>
#ifdef CONFIG_TEGRA_VIRTUALIZATION
#include <soc/tegra/virt/syscalls.h> #include <soc/tegra/virt/syscalls.h>
#ifdef CONFIG_TEGRA_OOT_MODULE
#include <soc/tegra/virt/hv-ivc.h> #include <soc/tegra/virt/hv-ivc.h>
#endif /* CONFIG_TEGRA_OOT_MODULE */
#include <uapi/linux/tegra-ivc-dev.h> #include <uapi/linux/tegra-ivc-dev.h>
#endif /* CONFIG_TEGRA_VIRTUALIZATION */
#include "nvsciipc.h" #include "nvsciipc.h"
@@ -46,7 +50,9 @@ DEFINE_MUTEX(nvsciipc_mutex);
static struct platform_device *nvsciipc_pdev; static struct platform_device *nvsciipc_pdev;
static struct nvsciipc *ctx; static struct nvsciipc *ctx;
#ifdef CONFIG_TEGRA_VIRTUALIZATION
static int32_t s_guestid = -1; static int32_t s_guestid = -1;
#endif /* CONFIG_TEGRA_VIRTUALIZATION */
NvSciError NvSciIpcEndpointGetAuthToken(NvSciIpcEndpoint handle, NvSciError NvSciIpcEndpointGetAuthToken(NvSciIpcEndpoint handle,
NvSciIpcEndpointAuthToken *authToken) NvSciIpcEndpointAuthToken *authToken)
@@ -471,6 +477,7 @@ static int nvsciipc_ioctl_set_db(struct nvsciipc *ctx, unsigned int cmd,
} }
} }
#ifdef CONFIG_TEGRA_VIRTUALIZATION
if (s_guestid != -1) { if (s_guestid != -1) {
struct nvsciipc_config_entry *entry; struct nvsciipc_config_entry *entry;
union nvsciipc_vuid_64 vuid64; union nvsciipc_vuid_64 vuid64;
@@ -491,6 +498,7 @@ static int nvsciipc_ioctl_set_db(struct nvsciipc *ctx, unsigned int cmd,
(void)ivc_cdev_get_peer_vmid(entry->id, &entry->peer_vmid); (void)ivc_cdev_get_peer_vmid(entry->id, &entry->peer_vmid);
} }
} }
#endif /* CONFIG_TEGRA_VIRTUALIZATION */
kfree(entry_ptr); kfree(entry_ptr);
@@ -588,10 +596,14 @@ static long nvsciipc_dev_ioctl(struct file *filp, unsigned int cmd,
break; break;
#endif /* DEBUG_AUTH_API */ #endif /* DEBUG_AUTH_API */
case NVSCIIPC_IOCTL_GET_VMID: case NVSCIIPC_IOCTL_GET_VMID:
#ifdef CONFIG_TEGRA_VIRTUALIZATION
if (copy_to_user((void __user *) arg, &s_guestid, if (copy_to_user((void __user *) arg, &s_guestid,
sizeof(s_guestid))) { sizeof(s_guestid))) {
ret = -EFAULT; ret = -EFAULT;
} }
#else
ret = -EFAULT;
#endif /* CONFIG_TEGRA_VIRTUALIZATION */
break; break;
default: default:
ERR("unrecognised ioctl cmd: 0x%x\n", cmd); ERR("unrecognised ioctl cmd: 0x%x\n", cmd);
@@ -704,6 +716,7 @@ static int nvsciipc_probe(struct platform_device *pdev)
} }
dev_set_drvdata(ctx->device, ctx); dev_set_drvdata(ctx->device, ctx);
#ifdef CONFIG_TEGRA_VIRTUALIZATION
if (is_tegra_hypervisor_mode()) { if (is_tegra_hypervisor_mode()) {
ret = hyp_read_gid(&s_guestid); ret = hyp_read_gid(&s_guestid);
if (ret != 0) { if (ret != 0) {
@@ -712,6 +725,7 @@ static int nvsciipc_probe(struct platform_device *pdev)
} }
INFO("guestid: %d\n", s_guestid); INFO("guestid: %d\n", s_guestid);
} }
#endif /* CONFIG_TEGRA_VIRTUALIZATION */
INFO("loaded module\n"); INFO("loaded module\n");