From 2ce330f11afe94f23937e08cfa85a8f5a26aeceb Mon Sep 17 00:00:00 2001 From: Lael Jones Date: Fri, 8 Oct 2021 08:07:07 -0700 Subject: [PATCH] misc: mods: Replace CONFIG_ARCH_TEGRA The perforce version of the MODS kernel driver does not pull in any of the Tegra specific driver functions. This prevents the perforce driver from being compiled on any Tegra system or non Tegra system with CONFIG_ARCH_TEGRA=y. To allow the perforce driver to be compiled replace CONFIG_ARCH_TEGRA with MODS_HAS_TEGRA which is set based on CONFIG_ARCH_TEGRA in git but left unset in perforce. Bug 3397113 Signed-off-by: Lael Jones Change-Id: Ie113d632c4dcc372058b9a1e3a549a70b8f7c03f Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2607859 Reviewed-by: svcacv Reviewed-by: svc_kernel_abi Reviewed-by: Chris Dragan Reviewed-by: Sachin Nikam Reviewed-by: mobile promotions GVS: Gerrit_Virtual_Submit Tested-by: mobile promotions --- drivers/misc/mods/mods_config.h | 4 ++++ drivers/misc/mods/mods_debugfs.c | 10 +++++----- drivers/misc/mods/mods_internal.h | 14 +++++++------- drivers/misc/mods/mods_irq.c | 6 +++--- drivers/misc/mods/mods_krnl.c | 22 +++++++++++----------- drivers/misc/mods/mods_mem.c | 10 +++++----- 6 files changed, 35 insertions(+), 31 deletions(-) diff --git a/drivers/misc/mods/mods_config.h b/drivers/misc/mods/mods_config.h index a475d46e..e2a9d340 100644 --- a/drivers/misc/mods/mods_config.h +++ b/drivers/misc/mods/mods_config.h @@ -96,4 +96,8 @@ # define MODS_HAS_ARM64_READ_FTR_REG 1 #endif +#if defined(CONFIG_ARCH_TEGRA) +# define MODS_HAS_TEGRA 1 +#endif + #endif /* _MODS_CONFIG_H_ */ diff --git a/drivers/misc/mods/mods_debugfs.c b/drivers/misc/mods/mods_debugfs.c index 1fba4bdb..dc29bc07 100644 --- a/drivers/misc/mods/mods_debugfs.c +++ b/drivers/misc/mods/mods_debugfs.c @@ -2,7 +2,7 @@ /* * mods_debugfs.c - This file is part of NVIDIA MODS kernel driver. * - * Copyright (c) 2014-2020, NVIDIA CORPORATION. All rights reserved. + * Copyright (c) 2014-2021, 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, @@ -33,7 +33,7 @@ static struct dentry *mods_debugfs_dir; #include "mods_ras.h" #endif -#if defined(CONFIG_ARCH_TEGRA) && defined(CONFIG_TEGRA_KFUSE) +#if defined(MODS_HAS_TEGRA) && defined(CONFIG_TEGRA_KFUSE) #include #endif @@ -423,7 +423,7 @@ static const struct file_operations mods_dc_crc_latched_fops = { }; #endif /* CONFIG_TEGRA_DC */ -#if defined(CONFIG_ARCH_TEGRA) && defined(CONFIG_TEGRA_KFUSE) +#if defined(MODS_HAS_TEGRA) && defined(CONFIG_TEGRA_KFUSE) static int mods_kfuse_show(struct seq_file *s, void *unused) { unsigned int buf[KFUSE_DATA_SZ / 4]; @@ -453,7 +453,7 @@ static const struct file_operations mods_kfuse_fops = { .llseek = seq_lseek, .release = single_release, }; -#endif /* CONFIG_ARCH_TEGRA */ +#endif /* MODS_HAS_TEGRA */ static int mods_debug_get(void *data, u64 *val) { @@ -617,7 +617,7 @@ int mods_create_debugfs(struct miscdevice *modsdev) goto remove_out; } -#if defined(CONFIG_ARCH_TEGRA) && defined(CONFIG_TEGRA_KFUSE) +#if defined(MODS_HAS_TEGRA) && defined(CONFIG_TEGRA_KFUSE) retval = debugfs_create_file("kfuse_data", 0444, mods_debugfs_dir, 0, &mods_kfuse_fops); if (IS_ERR(retval)) { diff --git a/drivers/misc/mods/mods_internal.h b/drivers/misc/mods/mods_internal.h index 73117a3e..8ff97887 100644 --- a/drivers/misc/mods/mods_internal.h +++ b/drivers/misc/mods/mods_internal.h @@ -434,7 +434,7 @@ int mods_find_pci_dev(struct mods_client *client, #endif /* clock */ -#if defined(CONFIG_ARCH_TEGRA) && defined(CONFIG_COMMON_CLK) && \ +#if defined(MODS_HAS_TEGRA) && defined(CONFIG_COMMON_CLK) && \ defined(CONFIG_OF_RESOLVE) && defined(CONFIG_OF_DYNAMIC) void mods_init_clock_api(void); void mods_shutdown_clock_api(void); @@ -565,7 +565,7 @@ int esc_mods_pci_reset_function(struct mods_client *client, struct mods_pci_dev_2 *pcidev); #endif /* irq */ -#if defined(CONFIG_ARCH_TEGRA) && defined(CONFIG_OF) && defined(CONFIG_OF_IRQ) +#if defined(MODS_HAS_TEGRA) && defined(CONFIG_OF) && defined(CONFIG_OF_IRQ) int esc_mods_map_irq(struct mods_client *client, struct MODS_DT_INFO *p); int esc_mods_map_irq_to_gpio(struct mods_client *client, struct MODS_GPIO_INFO *p); @@ -593,7 +593,7 @@ int esc_mods_register_irq_4(struct mods_client *client, int esc_mods_query_irq_3(struct mods_client *client, struct MODS_QUERY_IRQ_3 *p); -#ifdef CONFIG_ARCH_TEGRA +#ifdef MODS_HAS_TEGRA /* bpmp uphy */ int esc_mods_bpmp_set_pcie_state(struct mods_client *client, @@ -656,12 +656,12 @@ int esc_mods_tegra_dc_config_possible(struct mods_client *client, struct MODS_TEGRA_DC_CONFIG_POSSIBLE *p); #endif -#if defined(CONFIG_ARCH_TEGRA) && defined(CONFIG_NET) +#if defined(MODS_HAS_TEGRA) && defined(CONFIG_NET) int esc_mods_net_force_link(struct mods_client *client, struct MODS_NET_DEVICE_NAME *p); #endif -#if defined(CONFIG_ARCH_TEGRA) && 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 @@ -709,7 +709,7 @@ static inline int mods_create_debugfs(struct miscdevice *modsdev) static inline void mods_remove_debugfs(void) {} #endif /* CONFIG_DEBUG_FS */ -#if defined(CONFIG_ARCH_TEGRA) && 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 @@ -717,7 +717,7 @@ static inline int mods_init_dmabuf(void) { return 0; } static inline void mods_exit_dmabuf(void) {} #endif -#if defined(CONFIG_ARCH_TEGRA) +#if defined(MODS_HAS_TEGRA) int get_mods_smmu_device_index(const char *name); struct mods_smmu_dev *get_mods_smmu_device(u32 index); int smmu_driver_init(void); diff --git a/drivers/misc/mods/mods_irq.c b/drivers/misc/mods/mods_irq.c index 80f42261..a6aacdfa 100644 --- a/drivers/misc/mods/mods_irq.c +++ b/drivers/misc/mods/mods_irq.c @@ -2,7 +2,7 @@ /* * mods_irq.c - This file is part of NVIDIA MODS kernel driver. * - * Copyright (c) 2008-2020, NVIDIA CORPORATION. All rights reserved. + * Copyright (c) 2008-2021, 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, @@ -24,7 +24,7 @@ #include #include #include -#if defined(CONFIG_ARCH_TEGRA) && defined(CONFIG_OF) && defined(CONFIG_OF_IRQ) +#if defined(MODS_HAS_TEGRA) && defined(CONFIG_OF) && defined(CONFIG_OF_IRQ) #include #include #include @@ -1485,7 +1485,7 @@ int esc_mods_irq_handled(struct mods_client *client, return esc_mods_irq_handled_2(client, ®ister_irq); } -#if defined(CONFIG_ARCH_TEGRA) && defined(CONFIG_OF_IRQ) && defined(CONFIG_OF) +#if defined(MODS_HAS_TEGRA) && defined(CONFIG_OF_IRQ) && defined(CONFIG_OF) int esc_mods_map_irq(struct mods_client *client, struct MODS_DT_INFO *p) { diff --git a/drivers/misc/mods/mods_krnl.c b/drivers/misc/mods/mods_krnl.c index 9c7ceebb..1f1340b2 100644 --- a/drivers/misc/mods/mods_krnl.c +++ b/drivers/misc/mods/mods_krnl.c @@ -136,7 +136,7 @@ struct pci_driver mods_pci_driver = { * used to avoid globalization of variables * ***********************************************/ -#ifdef CONFIG_ARCH_TEGRA +#ifdef MODS_HAS_TEGRA # define MODS_MULTI_INSTANCE_DEFAULT_VALUE 1 #else # define MODS_MULTI_INSTANCE_DEFAULT_VALUE 0 @@ -439,7 +439,7 @@ static int __init mods_init_module(void) return -EBUSY; #endif -#if defined(CONFIG_ARCH_TEGRA) && defined(CONFIG_COMMON_CLK) && \ +#if defined(MODS_HAS_TEGRA) && defined(CONFIG_COMMON_CLK) && \ defined(CONFIG_OF_RESOLVE) && defined(CONFIG_OF_DYNAMIC) mods_init_clock_api(); #endif @@ -452,7 +452,7 @@ static int __init mods_init_module(void) if (rc < 0) return rc; -#if defined(CONFIG_ARCH_TEGRA) +#if defined(MODS_HAS_TEGRA) rc = smmu_driver_init(); if (rc < 0) return rc; @@ -483,7 +483,7 @@ static void __exit mods_exit_module(void) mods_cleanup_irq(); -#if defined(CONFIG_ARCH_TEGRA) +#if defined(MODS_HAS_TEGRA) smmu_driver_exit(); #endif @@ -493,7 +493,7 @@ static void __exit mods_exit_module(void) misc_deregister(&mods_dev); -#if defined(CONFIG_ARCH_TEGRA) && defined(CONFIG_COMMON_CLK) && \ +#if defined(MODS_HAS_TEGRA) && defined(CONFIG_COMMON_CLK) && \ defined(CONFIG_OF_RESOLVE) && defined(CONFIG_OF_DYNAMIC) mods_shutdown_clock_api(); #endif @@ -2151,7 +2151,7 @@ static long mods_krnl_ioctl(struct file *fp, err = -EINVAL; break; -#if defined(CONFIG_ARCH_TEGRA) && defined(CONFIG_OF) && defined(CONFIG_OF_IRQ) +#if defined(MODS_HAS_TEGRA) && defined(CONFIG_OF) && defined(CONFIG_OF_IRQ) case MODS_ESC_MAP_INTERRUPT: MODS_IOCTL(MODS_ESC_MAP_INTERRUPT, esc_mods_map_irq, MODS_DT_INFO); @@ -2270,7 +2270,7 @@ static long mods_krnl_ioctl(struct file *fp, esc_mods_get_kernel_version, MODS_GET_VERSION); break; -#if defined(CONFIG_ARCH_TEGRA) && defined(CONFIG_COMMON_CLK) && \ +#if defined(MODS_HAS_TEGRA) && defined(CONFIG_COMMON_CLK) && \ defined(CONFIG_OF_RESOLVE) && defined(CONFIG_OF_DYNAMIC) case MODS_ESC_GET_CLOCK_HANDLE: MODS_IOCTL(MODS_ESC_GET_CLOCK_HANDLE, @@ -2348,7 +2348,7 @@ static long mods_krnl_ioctl(struct file *fp, MODS_GET_RESET_HANDLE); break; #endif -#if defined(CONFIG_ARCH_TEGRA) +#if defined(MODS_HAS_TEGRA) case MODS_ESC_BPMP_SET_PCIE_STATE: MODS_IOCTL(MODS_ESC_BPMP_SET_PCIE_STATE, esc_mods_bpmp_set_pcie_state, @@ -2425,7 +2425,7 @@ static long mods_krnl_ioctl(struct file *fp, MODS_TEGRA_DC_CONFIG_POSSIBLE); break; #endif -#if defined(CONFIG_ARCH_TEGRA) && defined(CONFIG_NET) +#if defined(MODS_HAS_TEGRA) && defined(CONFIG_NET) case MODS_ESC_NET_FORCE_LINK: MODS_IOCTL(MODS_ESC_NET_FORCE_LINK, esc_mods_net_force_link, MODS_NET_DEVICE_NAME); @@ -2445,7 +2445,7 @@ static long mods_krnl_ioctl(struct file *fp, MODS_FLUSH_CPU_CACHE_RANGE); break; #endif -#ifdef CONFIG_ARCH_TEGRA +#ifdef MODS_HAS_TEGRA case MODS_ESC_DMABUF_GET_PHYSICAL_ADDRESS: MODS_IOCTL(MODS_ESC_DMABUF_GET_PHYSICAL_ADDRESS, esc_mods_dmabuf_get_phys_addr, @@ -2505,7 +2505,7 @@ static long mods_krnl_ioctl(struct file *fp, break; #endif -#if defined(CONFIG_ARCH_TEGRA) +#if defined(MODS_HAS_TEGRA) case MODS_ESC_TEGRA_PROD_IS_SUPPORTED: MODS_IOCTL(MODS_ESC_TEGRA_PROD_IS_SUPPORTED, esc_mods_tegra_prod_is_supported, diff --git a/drivers/misc/mods/mods_mem.c b/drivers/misc/mods/mods_mem.c index f795fda7..1f0767d8 100644 --- a/drivers/misc/mods/mods_mem.c +++ b/drivers/misc/mods/mods_mem.c @@ -36,7 +36,7 @@ static int mods_post_alloc(struct mods_client *client, u64 phys_addr, struct MODS_MEM_INFO *p_mem_info); -#if defined(CONFIG_ARCH_TEGRA) +#if defined(MODS_HAS_TEGRA) static int mods_smmu_unmap_memory(struct mods_client *client, struct MODS_MEM_INFO *p_mem_info); #endif @@ -535,7 +535,7 @@ static void mods_free_pages(struct mods_client *client, mods_restore_cache(client, p_mem_info); -#if defined(CONFIG_ARCH_TEGRA) +#if defined(MODS_HAS_TEGRA) if (p_mem_info->iommu_mapped) mods_smmu_unmap_memory(client, p_mem_info); #endif @@ -2053,7 +2053,7 @@ int esc_mods_dma_unmap_memory(struct mods_client *client, } #endif -#ifdef CONFIG_ARCH_TEGRA +#ifdef MODS_HAS_TEGRA /* map dma buffer by iommu */ int esc_mods_iommu_dma_map_memory(struct mods_client *client, struct MODS_IOMMU_DMA_MAP_MEMORY *p) @@ -2244,7 +2244,7 @@ static void clear_contiguous_cache(struct mods_client *client, u64 phys_start, u32 size) { -#ifdef CONFIG_ARCH_TEGRA +#ifdef MODS_HAS_TEGRA __flush_dcache_area((void *)(size_t)(virt_start), size); #else /* __flush_dcache_area is not exported in upstream kernels */ @@ -2443,7 +2443,7 @@ static int mods_post_alloc(struct mods_client *client, cl_error("kmap failed\n"); return -ENOMEM; } -#if defined(CONFIG_ARCH_TEGRA) && !defined(CONFIG_CPA) +#if defined(MODS_HAS_TEGRA) && !defined(CONFIG_CPA) clear_contiguous_cache(client, (u64)(size_t)ptr, phys_addr + (i << PAGE_SHIFT),