102102#include <linux/dma-buf.h>
103103#endif
104104
105- #if defined(NV_DRM_AVAILABLE )
106- #include <drm/drm_device.h>
107- #include <drm/drm_drv.h>
108-
109- #if defined(NV_DRM_DRMP_H_PRESENT )
110- #include <drm/drmP.h>
111- #endif
112-
113- #include <drm/drm_gem.h>
114- #endif /* NV_DRM_AVAILABLE */
115-
116105/* task and signal-related items */
117106#include <linux/sched/signal.h>
118107#include <linux/sched/task.h>
141130#include <asm/bitops.h> /* __set_bit() */
142131#include <linux/time.h> /* FD_SET() */
143132
144- #include "nv-list-helpers.h"
145-
146133/*
147134 * Use current->cred->euid, instead of calling current_euid().
148135 * The latter can pull in the GPL-only debug_lockdep_rcu_enabled()
@@ -274,14 +261,8 @@ extern int nv_pat_mode;
274261 user_function, NULL, args)
275262#endif
276263
277- #if defined(CONFIG_PREEMPT_RT ) || defined(CONFIG_PREEMPT_RT_FULL )
278- #define NV_CONFIG_PREEMPT_RT 1
279- #endif
280-
281264#define NV_PAGE_COUNT (page ) \
282265 ((unsigned int)page_count(page))
283- #define NV_GET_PAGE_FLAGS (page_ptr ) \
284- (NV_GET_PAGE_STRUCT(page_ptr->phys_addr)->flags)
285266
286267#if !defined(DEBUG ) && defined(__GFP_NOWARN )
287268#define NV_GFP_KERNEL (GFP_KERNEL | __GFP_NOWARN)
@@ -298,9 +279,9 @@ extern int nv_pat_mode;
298279 * such as Linux/x86-64; the alternative is to use an IOMMU such
299280 * as the one implemented with the K8 GART, if available.
300281 */
301- #define NV_GFP_DMA32 (NV_GFP_KERNEL | GFP_DMA32)
282+ #define NV_GFP_DMA32 (GFP_DMA32)
302283#else
303- #define NV_GFP_DMA32 (NV_GFP_KERNEL)
284+ #define NV_GFP_DMA32 0
304285#endif
305286
306287#if defined(NVCPU_AARCH64 ) || defined(NVCPU_RISCV64 )
@@ -388,11 +369,7 @@ static inline void nv_vfree(void *ptr, NvU64 size)
388369
389370static inline void * nv_ioremap (NvU64 phys , NvU64 size )
390371{
391- #if IS_ENABLED (CONFIG_INTEL_TDX_GUEST ) && defined(NV_IOREMAP_DRIVER_HARDENED_PRESENT )
392- void * ptr = ioremap_driver_hardened (phys , size );
393- #else
394372 void * ptr = ioremap (phys , size );
395- #endif
396373 NV_MEMDBG_ADD (ptr , size );
397374 return ptr ;
398375}
@@ -405,9 +382,7 @@ static inline void *nv_ioremap_nocache(NvU64 phys, NvU64 size)
405382static inline void * nv_ioremap_cache (NvU64 phys , NvU64 size )
406383{
407384 void * ptr = NULL ;
408- #if IS_ENABLED (CONFIG_INTEL_TDX_GUEST ) && defined(NV_IOREMAP_CACHE_SHARED_PRESENT )
409- ptr = ioremap_cache_shared (phys , size );
410- #elif defined(NV_IOREMAP_CACHE_PRESENT )
385+ #if defined(NV_IOREMAP_CACHE_PRESENT )
411386 ptr = ioremap_cache (phys , size );
412387#else
413388 return nv_ioremap (phys , size );
@@ -421,9 +396,7 @@ static inline void *nv_ioremap_cache(NvU64 phys, NvU64 size)
421396static inline void * nv_ioremap_wc (NvU64 phys , NvU64 size )
422397{
423398 void * ptr = NULL ;
424- #if IS_ENABLED (CONFIG_INTEL_TDX_GUEST ) && defined(NV_IOREMAP_DRIVER_HARDENED_WC_PRESENT )
425- ptr = ioremap_driver_hardened_wc (phys , size );
426- #elif defined(NV_IOREMAP_WC_PRESENT )
399+ #if defined(NV_IOREMAP_WC_PRESENT )
427400 ptr = ioremap_wc (phys , size );
428401#else
429402 return nv_ioremap_nocache (phys , size );
@@ -465,13 +438,7 @@ static NvBool nv_numa_node_has_memory(int node_id)
465438 NV_MEMDBG_ADD(ptr, size); \
466439 }
467440
468- #if defined(__GFP_RETRY_MAYFAIL )
469441#define NV_GFP_NO_OOM (NV_GFP_KERNEL | __GFP_RETRY_MAYFAIL)
470- #elif defined(__GFP_NORETRY )
471- #define NV_GFP_NO_OOM (NV_GFP_KERNEL | __GFP_NORETRY)
472- #else
473- #define NV_GFP_NO_OOM (NV_GFP_KERNEL)
474- #endif
475442
476443#define NV_KMALLOC_NO_OOM (ptr , size ) \
477444 { \
@@ -528,22 +495,12 @@ static inline pgprot_t nv_adjust_pgprot(pgprot_t vm_prot)
528495#endif
529496#endif
530497
531- #define NV_GET_CURRENT_PROCESS () current->tgid
532- #define NV_IN_ATOMIC () in_atomic()
533- #define NV_COPY_TO_USER (to , from , n ) copy_to_user(to, from, n)
534- #define NV_COPY_FROM_USER (to , from , n ) copy_from_user(to, from, n)
535-
536498#define NV_IS_SUSER () capable(CAP_SYS_ADMIN)
537- #define NV_CLI () local_irq_disable()
538- #define NV_SAVE_FLAGS (eflags ) local_save_flags(eflags)
539- #define NV_RESTORE_FLAGS (eflags ) local_irq_restore(eflags)
540- #define NV_MAY_SLEEP () (!irqs_disabled() && !in_interrupt() && !NV_IN_ATOMIC())
499+ #define NV_MAY_SLEEP () (!irqs_disabled() && !in_interrupt() && !in_atomic())
541500#define NV_MODULE_PARAMETER (x ) module_param(x, int, 0)
542501#define NV_MODULE_STRING_PARAMETER (x ) module_param(x, charp, 0)
543502#undef MODULE_PARM
544503
545- #define NV_NUM_CPUS () num_possible_cpus()
546-
547504#define NV_HAVE_MEMORY_ENCRYPT_DECRYPT 0
548505
549506#if defined(NVCPU_X86_64 ) && \
@@ -596,7 +553,6 @@ static inline dma_addr_t nv_phys_to_dma(struct device *dev, NvU64 pa)
596553#endif
597554}
598555
599- #define NV_GET_OFFSET_IN_PAGE (phys_page ) offset_in_page(phys_page)
600556#define NV_GET_PAGE_STRUCT (phys_page ) virt_to_page(__va(phys_page))
601557#define NV_VMA_PGOFF (vma ) ((vma)->vm_pgoff)
602558#define NV_VMA_SIZE (vma ) ((vma)->vm_end - (vma)->vm_start)
@@ -711,13 +667,6 @@ static inline dma_addr_t nv_phys_to_dma(struct device *dev, NvU64 pa)
711667# define minor (x ) MINOR(x)
712668#endif
713669
714- #if !defined(PCI_COMMAND_SERR )
715- #define PCI_COMMAND_SERR 0x100
716- #endif
717- #if !defined(PCI_COMMAND_INTX_DISABLE )
718- #define PCI_COMMAND_INTX_DISABLE 0x400
719- #endif
720-
721670#ifndef PCI_CAP_ID_EXP
722671#define PCI_CAP_ID_EXP 0x10
723672#endif
@@ -983,6 +932,7 @@ typedef struct nv_alloc_s {
983932 NvBool unencrypted : 1 ;
984933 NvBool coherent : 1 ;
985934 NvBool carveout : 1 ;
935+ NvBool pool : 1 ;
986936 } flags ;
987937 unsigned int cache_type ;
988938 unsigned int num_pages ;
@@ -1143,14 +1093,18 @@ typedef struct nv_dma_map_s {
11431093 i++, sm = &dm->mapping.discontig.submaps[i])
11441094
11451095/*
1146- * On 4K ARM kernels, use max submap size a multiple of 64K to keep nv-p2p happy.
1147- * Despite 4K OS pages, we still use 64K P2P pages due to dependent modules still using 64K.
1148- * Instead of using (4G-4K), use max submap size as (4G-64K) since the mapped IOVA range
1149- * must be aligned at 64K boundary.
1096+ * On 4K ARM kernels, use max submap size a multiple of 2M to avoid breaking up 2M page size
1097+ * sysmem allocations.
1098+ *
1099+ * Instead of using (4G-4K), use max submap size as (4G-2M) since the mapped IOVA range
1100+ * must be aligned at 2M boundary.
1101+ *
1102+ * Bug 5401803: Tracks migrating away from making IOMMU mappings using submaps in favor of
1103+ * using sg_chain() to chain a single large scatterlist.
11501104 */
11511105#if defined(CONFIG_ARM64_4K_PAGES )
11521106#define NV_DMA_U32_MAX_4K_PAGES ((NvU32)((NV_U32_MAX >> PAGE_SHIFT) + 1))
1153- #define NV_DMA_SUBMAP_MAX_PAGES ((NvU32)(NV_DMA_U32_MAX_4K_PAGES - 16 ))
1107+ #define NV_DMA_SUBMAP_MAX_PAGES ((NvU32)(NV_DMA_U32_MAX_4K_PAGES - 512 ))
11541108#else
11551109#define NV_DMA_SUBMAP_MAX_PAGES ((NvU32)(NV_U32_MAX >> PAGE_SHIFT))
11561110#endif
@@ -1294,7 +1248,8 @@ struct nv_pci_tegra_devfreq_dev;
12941248typedef struct nv_linux_state_s {
12951249 nv_state_t nv_state ;
12961250
1297- atomic_t usage_count ;
1251+ atomic_t usage_count ;
1252+
12981253 NvU32 suspend_count ;
12991254
13001255 struct device * dev ;
@@ -1470,6 +1425,8 @@ typedef struct nv_linux_state_s {
14701425
14711426 int (* devfreq_suspend )(struct device * dev );
14721427 int (* devfreq_resume )(struct device * dev );
1428+ int (* devfreq_enable_boost )(struct device * dev , unsigned int duration );
1429+ int (* devfreq_disable_boost )(struct device * dev );
14731430#endif
14741431} nv_linux_state_t ;
14751432
@@ -1640,6 +1597,7 @@ extern NvU32 NVreg_EnableUserNUMAManagement;
16401597extern NvU32 NVreg_RegisterPCIDriver ;
16411598extern NvU32 NVreg_RegisterPlatformDeviceDriver ;
16421599extern NvU32 NVreg_EnableResizableBar ;
1600+ extern NvU32 NVreg_TegraGpuPgMask ;
16431601extern NvU32 NVreg_EnableNonblockingOpen ;
16441602
16451603extern NvU32 num_probed_nv_devices ;
@@ -1697,10 +1655,7 @@ static inline NvU32 nv_default_irq_flags(nv_state_t *nv)
16971655 return flags ;
16981656}
16991657
1700- #define MODULE_BASE_NAME "nvidia"
1701- #define MODULE_INSTANCE_NUMBER 0
1702- #define MODULE_INSTANCE_STRING ""
1703- #define MODULE_NAME MODULE_BASE_NAME MODULE_INSTANCE_STRING
1658+ #define MODULE_NAME "nvidia"
17041659
17051660NvS32 nv_request_soc_irq (nv_linux_state_t * , NvU32 , nv_soc_irq_type_t , NvU32 , NvU32 , const char * );
17061661NV_STATUS nv_imp_icc_get (nv_state_t * nv );
0 commit comments