You are not logged in.
Pages: 1
Hi, does anyone tried to build this driver? As mentioned in the Wiki, this is first driver that oficially supports PRIME render offloading and this also support my hardware (GeForce 710M). So, I tried to build 435.17, but unsuccessful:
DKMS (dkms-3.2.1) make.log for nvidia/435.17 for kernel 6.16.0-arch2-1 (x86_64)
Sat Aug 16 22:08:13 MSK 2025
Building module(s)
# command: 'make' -j8 IGNORE_PREEMPT_RT_PRESENCE=1 NV_EXCLUDE_BUILD_MODULES='__EXCLUDE_MODULES' KERNEL_UNAME=6.16.0-arch2-1 IGNORE_CC_MISMATCH='__IGNORE_CC_MISMATCH' modules
make[1]: Entering directory '/usr/lib/modules/6.16.0-arch2-1/build'
make[2]: Entering directory '/var/lib/dkms/nvidia/435.17/build'
warning: the compiler differs from the one used to build the kernel
The kernel was built by: gcc (GCC) 15.2.1 20250813
You are using: cc (GCC) 15.2.1 20250813
SYMLINK nvidia/nv-kernel.o
SYMLINK nvidia-modeset/nv-modeset-kernel.o
CONFTEST: get_user_pages
CONFTEST: get_user_pages_remote
CONFTEST: follow_pfn
CONFTEST: hash__remap_4k_pfn
CONFTEST: set_pages_uc
CONFTEST: list_is_first
CONFTEST: set_memory_uc
CONFTEST: set_memory_array_uc
CONFTEST: acquire_console_sem
CONFTEST: console_lock
CONFTEST: ioremap_cache
CONFTEST: ioremap_wc
CONFTEST: acpi_walk_namespace
CONFTEST: sg_alloc_table
CONFTEST: pci_get_domain_bus_and_slot
CONFTEST: get_num_physpages
CONFTEST: efi_enabled
CONFTEST: pde_data
CONFTEST: proc_remove
CONFTEST: pm_vt_switch_required
CONFTEST: xen_ioemu_inject_msi
CONFTEST: phys_to_dma
CONFTEST: get_dma_ops
CONFTEST: write_cr4
CONFTEST: of_get_property
CONFTEST: of_find_node_by_phandle
CONFTEST: of_node_to_nid
CONFTEST: pnv_pci_get_npu_dev
CONFTEST: of_get_ibm_chip_id
CONFTEST: node_end_pfn
CONFTEST: pci_bus_address
CONFTEST: pci_stop_and_remove_bus_device
CONFTEST: pci_remove_bus_device
CONFTEST: register_cpu_notifier
CONFTEST: cpuhp_setup_state
CONFTEST: dma_map_resource
CONFTEST: backlight_device_register
CONFTEST: timer_setup
CONFTEST: pci_enable_msix_range
CONFTEST: do_gettimeofday
CONFTEST: kernel_read
CONFTEST: kernel_write
CONFTEST: kthread_create_on_node
CONFTEST: of_find_matching_node
CONFTEST: dev_is_pci
CONFTEST: dma_direct_map_resource
CONFTEST: tegra_get_platform
CONFTEST: vmalloc
CONFTEST: address_space_init_once
CONFTEST: kbasename
CONFTEST: vzalloc
CONFTEST: wait_on_bit_lock_argument_count
CONFTEST: bitmap_clear
CONFTEST: usleep_range
CONFTEST: radix_tree_empty
CONFTEST: radix_tree_replace_slot
CONFTEST: pnv_npu2_init_context
CONFTEST: vmf_insert_pfn
CONFTEST: cpumask_of_node
CONFTEST: smp_read_barrier_depends
CONFTEST: drm_dev_unref
CONFTEST: drm_reinit_primary_mode_group
CONFTEST: drm_gem_object_lookup
CONFTEST: drm_atomic_state_ref_counting
CONFTEST: drm_driver_has_gem_prime_res_obj
CONFTEST: drm_atomic_helper_connector_dpms
CONFTEST: drm_connector_funcs_have_mode_in_name
CONFTEST: drm_framebuffer_get
CONFTEST: drm_gem_object_get
CONFTEST: drm_dev_put
CONFTEST: is_export_symbol_gpl_of_node_to_nid
CONFTEST: is_export_symbol_present_swiotlb_map_sg_attrs
CONFTEST: is_export_symbol_present_swiotlb_dma_ops
CONFTEST: is_export_symbol_present_kthread_create_on_node
CONFTEST: acpi_op_remove
CONFTEST: outer_flush_all
CONFTEST: file_operations
CONFTEST: file_inode
CONFTEST: kuid_t
CONFTEST: dma_ops
CONFTEST: swiotlb_dma_ops
CONFTEST: noncoherent_swiotlb_dma_ops
CONFTEST: vm_fault_has_address
CONFTEST: backlight_properties_type
CONFTEST: vm_insert_pfn_prot
CONFTEST: vmf_insert_pfn_prot
CONFTEST: vm_ops_fault_removed_vma_arg
CONFTEST: vmbus_channel_has_ringbuffer_page
CONFTEST: device_driver_of_match_table
CONFTEST: device_of_node
CONFTEST: node_states_n_memory
CONFTEST: address_space
CONFTEST: backing_dev_info
CONFTEST: mm_context_t
CONFTEST: drm_bus_present
CONFTEST: drm_bus_has_bus_type
CONFTEST: drm_bus_has_get_irq
CONFTEST: drm_bus_has_get_name
CONFTEST: drm_driver_has_legacy_dev_list
CONFTEST: drm_driver_has_set_busid
CONFTEST: drm_crtc_state_has_connectors_changed
CONFTEST: drm_init_function_args
CONFTEST: drm_helper_mode_fill_fb_struct
CONFTEST: drm_master_drop_has_from_release_arg
CONFTEST: drm_driver_unload_has_int_return_type
CONFTEST: drm_atomic_helper_crtc_destroy_state_has_crtc_arg
CONFTEST: drm_crtc_helper_funcs_has_atomic_enable
CONFTEST: drm_mode_object_find_has_file_priv_arg
CONFTEST: dma_buf_owner
CONFTEST: drm_connector_list_iter
CONFTEST: drm_atomic_helper_swap_state_has_stall_arg
CONFTEST: dom0_kernel_present
CONFTEST: nvidia_vgpu_hyperv_available
CONFTEST: nvidia_vgpu_kvm_build
CONFTEST: nvidia_grid_build
CONFTEST: pm_runtime_available
CONFTEST: drm_available
CONFTEST: drm_atomic_available
CONFTEST: is_export_symbol_gpl_refcount_inc
CONFTEST: is_export_symbol_gpl_refcount_dec_and_test
CC [M] nvidia/nv-frontend.o
CC [M] nvidia/nv.o
CC [M] nvidia/nv-pci.o
CC [M] nvidia/nv-acpi.o
CC [M] nvidia/nv-cray.o
CC [M] nvidia/nv-dma.o
CC [M] nvidia/nv-gvi.o
CC [M] nvidia/nv-i2c.o
CC [M] nvidia/nv-mempool.o
In file included from /usr/lib/modules/6.16.0-arch2-1/build/include/linux/srcu.h:21,
from /usr/lib/modules/6.16.0-arch2-1/build/include/linux/notifier.h:16,
from /usr/lib/modules/6.16.0-arch2-1/build/arch/x86/include/asm/uprobes.h:13,
from /usr/lib/modules/6.16.0-arch2-1/build/include/linux/uprobes.h:65,
from /usr/lib/modules/6.16.0-arch2-1/build/include/linux/mm_types.h:16,
from /usr/lib/modules/6.16.0-arch2-1/build/include/linux/mmzone.h:22,
from /usr/lib/modules/6.16.0-arch2-1/build/include/linux/gfp.h:7,
from /usr/lib/modules/6.16.0-arch2-1/build/include/linux/mm.h:7,
from ././common/inc/nv-pgprot.h:17,
from ././common/inc/nv-linux.h:20,
from nvidia/nv-gvi.c:15:
nvidia/nv-gvi.c: In function 'nv_gvi_suspend':
/usr/lib/modules/6.16.0-arch2-1/build/include/linux/workqueue.h:765:9: warning: call to '__warn_flushing_systemwide_wq' declared with attribute warning: Please avoid flushing system-wide workqueues. [-Wattribute-warning]
765 | __warn_flushing_systemwide_wq(); \
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
nvidia/nv-gvi.c:72:5: note: in expansion of macro 'flush_scheduled_work'
72 | flush_scheduled_work();
| ^~~~~~~~~~~~~~~~~~~~
In file included from /usr/lib/modules/6.16.0-arch2-1/build/include/linux/srcu.h:21,
from /usr/lib/modules/6.16.0-arch2-1/build/include/linux/notifier.h:16,
from /usr/lib/modules/6.16.0-arch2-1/build/arch/x86/include/asm/uprobes.h:13,
from /usr/lib/modules/6.16.0-arch2-1/build/include/linux/uprobes.h:65,
from /usr/lib/modules/6.16.0-arch2-1/build/include/linux/mm_types.h:16,
from /usr/lib/modules/6.16.0-arch2-1/build/include/linux/mmzone.h:22,
from /usr/lib/modules/6.16.0-arch2-1/build/include/linux/gfp.h:7,
from /usr/lib/modules/6.16.0-arch2-1/build/include/linux/xarray.h:16,
from /usr/lib/modules/6.16.0-arch2-1/build/include/linux/radix-tree.h:21,
from /usr/lib/modules/6.16.0-arch2-1/build/include/linux/idr.h:15,
from /usr/lib/modules/6.16.0-arch2-1/build/include/linux/kernfs.h:12,
from /usr/lib/modules/6.16.0-arch2-1/build/include/linux/sysfs.h:16,
from /usr/lib/modules/6.16.0-arch2-1/build/include/linux/kobject.h:20,
from /usr/lib/modules/6.16.0-arch2-1/build/include/linux/pci.h:35,
from nvidia/nv-pci-table.h:14,
from nvidia/nv-pci.c:11:
nvidia/nv-pci.c: In function 'nv_pci_remove':
/usr/lib/modules/6.16.0-arch2-1/build/include/linux/workqueue.h:765:9: warning: call to '__warn_flushing_systemwide_wq' declared with attribute warning: Please avoid flushing system-wide workqueues. [-Wattribute-warning]
765 | __warn_flushing_systemwide_wq(); \
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
nvidia/nv-pci.c:649:9: note: in expansion of macro 'flush_scheduled_work'
649 | flush_scheduled_work();
| ^~~~~~~~~~~~~~~~~~~~
CC [M] nvidia/nv-mmap.o
CC [M] nvidia/nv-p2p.o
CC [M] nvidia/nv-pat.o
CC [M] nvidia/nv-procfs.o
CC [M] nvidia/nv-usermap.o
CC [M] nvidia/nv-vm.o
In file included from /usr/lib/modules/6.16.0-arch2-1/build/include/linux/srcu.h:21,
from /usr/lib/modules/6.16.0-arch2-1/build/include/linux/notifier.h:16,
from /usr/lib/modules/6.16.0-arch2-1/build/arch/x86/include/asm/uprobes.h:13,
from /usr/lib/modules/6.16.0-arch2-1/build/include/linux/uprobes.h:65,
from /usr/lib/modules/6.16.0-arch2-1/build/include/linux/mm_types.h:16,
from /usr/lib/modules/6.16.0-arch2-1/build/include/linux/mmzone.h:22,
from /usr/lib/modules/6.16.0-arch2-1/build/include/linux/gfp.h:7,
from /usr/lib/modules/6.16.0-arch2-1/build/include/linux/mm.h:7,
from ././common/inc/nv-pgprot.h:17,
from ././common/inc/nv-linux.h:20,
from nvidia/nv.c:14:
nvidia/nv.c: In function 'nv_stop_device':
/usr/lib/modules/6.16.0-arch2-1/build/include/linux/workqueue.h:765:9: warning: call to '__warn_flushing_systemwide_wq' declared with attribute warning: Please avoid flushing system-wide workqueues. [-Wattribute-warning]
765 | __warn_flushing_systemwide_wq(); \
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
nvidia/nv.c:1579:9: note: in expansion of macro 'flush_scheduled_work'
1579 | flush_scheduled_work();
| ^~~~~~~~~~~~~~~~~~~~
CC [M] nvidia/nv-vtophys.o
CC [M] nvidia/os-interface.o
CC [M] nvidia/os-mlock.o
CC [M] nvidia/os-pci.o
CC [M] nvidia/os-registry.o
CC [M] nvidia/os-usermap.o
CC [M] nvidia/nv-modeset-interface.o
CC [M] nvidia/nv-pci-table.o
CC [M] nvidia/nv-kthread-q.o
CC [M] nvidia/nv-memdbg.o
CC [M] nvidia/nv-ibmnpu.o
CC [M] nvidia/nv-report-err.o
CC [M] nvidia/nv-rsync.o
CC [M] nvidia/nv-msi.o
CC [M] nvidia/nv_uvm_interface.o
CC [M] nvidia/nvlink_linux.o
CC [M] nvidia/linux_nvswitch.o
CC [M] nvidia-uvm/uvm_utils.o
CC [M] nvidia-uvm/uvm_common.o
CC [M] nvidia-uvm/uvm_linux.o
CC [M] nvidia-uvm/nvstatus.o
CC [M] nvidia-uvm/nvCpuUuid.o
CC [M] nvidia-uvm/nv-kthread-q.o
CC [M] nvidia-uvm/nv-kthread-q-selftest.o
CC [M] nvidia-uvm/uvm8.o
CC [M] nvidia-uvm/uvm8_tools.o
CC [M] nvidia-uvm/uvm8_global.o
CC [M] nvidia-uvm/uvm8_gpu.o
CC [M] nvidia-uvm/uvm8_gpu_isr.o
CC [M] nvidia-uvm/uvm8_procfs.o
CC [M] nvidia-uvm/uvm8_va_space.o
CC [M] nvidia-uvm/uvm8_va_space_mm.o
CC [M] nvidia-uvm/uvm8_gpu_semaphore.o
CC [M] nvidia-uvm/uvm8_mem.o
CC [M] nvidia-uvm/uvm8_rm_mem.o
CC [M] nvidia-uvm/uvm8_channel.o
CC [M] nvidia-uvm/uvm8_lock.o
CC [M] nvidia-uvm/uvm8_hal.o
CC [M] nvidia-uvm/uvm8_range_tree.o
CC [M] nvidia-uvm/uvm8_range_allocator.o
CC [M] nvidia-uvm/uvm8_va_range.o
CC [M] nvidia-uvm/uvm8_va_block.o
CC [M] nvidia-uvm/uvm8_range_group.o
CC [M] nvidia-uvm/uvm8_gpu_replayable_faults.o
CC [M] nvidia-uvm/uvm8_gpu_non_replayable_faults.o
CC [M] nvidia-uvm/uvm8_gpu_access_counters.o
CC [M] nvidia-uvm/uvm8_perf_events.o
CC [M] nvidia-uvm/uvm8_perf_module.o
nvidia-uvm/uvm8_va_range.c: In function 'uvm_va_range_check_logical_permissions':
nvidia-uvm/uvm8_va_range.c:1632:81: warning: implicit conversion from 'uvm_fault_type_t' to 'uvm_fault_access_type_t' [-Wenum-conversion]
1632 | if (uvm_enable_builtin_tests && !fault_check_range_permission(va_range, access_type))
| ^~~~~~~~~~~
nvidia-uvm/uvm8_va_block.c: In function 'block_cpu_fault_locked':
nvidia-uvm/uvm8_va_block.c:9938:53: warning: implicit conversion from 'uvm_fault_access_type_t' to 'uvm_fault_type_t' [-Wenum-conversion]
9938 | fault_access_type,
| ^~~~~~~~~~~~~~~~~
nvidia-uvm/uvm8_gpu_replayable_faults.c: In function 'check_fault_access_permissions':
nvidia-uvm/uvm8_gpu_replayable_faults.c:1021:69: warning: implicit conversion from 'uvm_fault_access_type_t' to 'uvm_fault_type_t' [-Wenum-conversion]
1021 | fault_entry->fault_access_type,
| ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~
nvidia-uvm/uvm8_gpu_replayable_faults.c:1044:66: warning: implicit conversion from 'enum <anonymous>' to 'uvm_fault_type_t' [-Wenum-conversion]
1044 | UVM_FAULT_ACCESS_TYPE_READ,
| ^~~~~~~~~~~~~~~~~~~~~~~~~~
nvidia-uvm/uvm8_gpu_non_replayable_faults.c: In function 'service_managed_fault_in_block_locked':
nvidia-uvm/uvm8_gpu_non_replayable_faults.c:282:64: warning: implicit conversion from 'uvm_fault_access_type_t' to 'uvm_fault_type_t' [-Wenum-conversion]
282 | fault_entry->fault_access_type,
| ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~
CC [M] nvidia-uvm/uvm8_mmu.o
CC [M] nvidia-uvm/uvm8_pte_batch.o
CC [M] nvidia-uvm/uvm8_tlb_batch.o
CC [M] nvidia-uvm/uvm8_push.o
CC [M] nvidia-uvm/uvm8_pushbuffer.o
CC [M] nvidia-uvm/uvm8_thread_context.o
CC [M] nvidia-uvm/uvm8_tracker.o
CC [M] nvidia-uvm/uvm8_kepler.o
CC [M] nvidia-uvm/uvm8_kepler_ce.o
CC [M] nvidia-uvm/uvm8_kepler_host.o
CC [M] nvidia-uvm/uvm8_kepler_mmu.o
CC [M] nvidia-uvm/uvm8_maxwell.o
CC [M] nvidia-uvm/uvm8_maxwell_host.o
CC [M] nvidia-uvm/uvm8_pascal.o
CC [M] nvidia-uvm/uvm8_pascal_ce.o
CC [M] nvidia-uvm/uvm8_pascal_host.o
CC [M] nvidia-uvm/uvm8_pascal_mmu.o
CC [M] nvidia-uvm/uvm8_pascal_fault_buffer.o
CC [M] nvidia-uvm/uvm8_volta_host.o
CC [M] nvidia-uvm/uvm8_volta_mmu.o
CC [M] nvidia-uvm/uvm8_volta.o
CC [M] nvidia-uvm/uvm8_volta_fault_buffer.o
CC [M] nvidia-uvm/uvm8_volta_access_counter_buffer.o
CC [M] nvidia-uvm/uvm8_turing.o
CC [M] nvidia-uvm/uvm8_turing_mmu.o
CC [M] nvidia-uvm/uvm8_turing_host.o
CC [M] nvidia-uvm/uvm8_policy.o
CC [M] nvidia-uvm/uvm8_perf_utils.o
CC [M] nvidia-uvm/uvm8_kvmalloc.o
CC [M] nvidia-uvm/uvm8_pmm_sysmem.o
CC [M] nvidia-uvm/uvm8_pmm_gpu.o
CC [M] nvidia-uvm/uvm8_migrate.o
CC [M] nvidia-uvm/uvm8_populate_pageable.o
CC [M] nvidia-uvm/uvm8_migrate_pageable.o
CC [M] nvidia-uvm/uvm8_map_external.o
CC [M] nvidia-uvm/uvm8_user_channel.o
CC [M] nvidia-uvm/uvm8_hmm.o
CC [M] nvidia-uvm/uvm8_perf_heuristics.o
CC [M] nvidia-uvm/uvm8_perf_thrashing.o
CC [M] nvidia-uvm/uvm8_perf_prefetch.o
CC [M] nvidia-uvm/uvm8_ats_ibm.o
CC [M] nvidia-uvm/uvm8_ats_faults.o
CC [M] nvidia-uvm/uvm8_test.o
CC [M] nvidia-uvm/uvm8_test_rng.o
CC [M] nvidia-uvm/uvm8_range_tree_test.o
CC [M] nvidia-uvm/uvm8_range_allocator_test.o
CC [M] nvidia-uvm/uvm8_gpu_semaphore_test.o
CC [M] nvidia-uvm/uvm8_mem_test.o
CC [M] nvidia-uvm/uvm8_rm_mem_test.o
CC [M] nvidia-uvm/uvm8_page_tree_test.o
CC [M] nvidia-uvm/uvm8_tracker_test.o
CC [M] nvidia-uvm/uvm8_push_test.o
CC [M] nvidia-uvm/uvm8_channel_test.o
CC [M] nvidia-uvm/uvm8_ce_test.o
CC [M] nvidia-uvm/uvm8_lock_test.o
CC [M] nvidia-uvm/uvm8_perf_utils_test.o
CC [M] nvidia-uvm/uvm8_kvmalloc_test.o
CC [M] nvidia-uvm/uvm8_pmm_test.o
CC [M] nvidia-uvm/uvm8_pmm_sysmem_test.o
CC [M] nvidia-uvm/uvm8_perf_events_test.o
CC [M] nvidia-uvm/uvm8_perf_module_test.o
CC [M] nvidia-uvm/uvm8_get_rm_ptes_test.o
CC [M] nvidia-uvm/uvm8_fault_buffer_flush_test.o
CC [M] nvidia-uvm/uvm8_mmu_test.o
CC [M] nvidia-uvm/uvm8_peer_identity_mappings_test.o
CC [M] nvidia-uvm/uvm8_va_block_test.o
CC [M] nvidia-uvm/uvm8_range_group_tree_test.o
CC [M] nvidia-uvm/uvm8_thread_context_test.o
CC [M] nvidia-modeset/nvidia-modeset-linux.o
CC [M] nvidia-modeset/nv-kthread-q.o
CC [M] nvidia-drm/nvidia-drm.o
CC [M] nvidia-drm/nvidia-drm-drv.o
CC [M] nvidia-drm/nvidia-drm-utils.o
CC [M] nvidia-drm/nvidia-drm-crtc.o
CC [M] nvidia-drm/nvidia-drm-encoder.o
CC [M] nvidia-drm/nvidia-drm-connector.o
CC [M] nvidia-drm/nvidia-drm-gem.o
CC [M] nvidia-drm/nvidia-drm-fb.o
CC [M] nvidia-drm/nvidia-drm-modeset.o
CC [M] nvidia-drm/nvidia-drm-prime-fence.o
CC [M] nvidia-drm/nvidia-drm-linux.o
CC [M] nvidia-drm/nvidia-drm-helper.o
CC [M] nvidia-drm/nv-pci-table.o
CC [M] nvidia-drm/nvidia-drm-gem-nvkms-memory.o
CC [M] nvidia-drm/nvidia-drm-gem-user-memory.o
LD [M] nvidia.o
LD [M] nvidia-modeset.o
nvidia-modeset.o: warning: objtool: __x86_indirect_thunk_rax+0x0: unannotated intra-function call
make[4]: *** [/usr/lib/modules/6.16.0-arch2-1/build/scripts/Makefile.build:502: nvidia-modeset.o] Error 255
make[4]: *** Deleting file 'nvidia-modeset.o'
make[4]: *** Waiting for unfinished jobs....
nvidia.o: warning: objtool: __x86_indirect_thunk_rax+0x0: unannotated intra-function call
make[4]: *** [/usr/lib/modules/6.16.0-arch2-1/build/scripts/Makefile.build:502: nvidia.o] Error 255
make[4]: *** Deleting file 'nvidia.o'
make[3]: *** [/usr/lib/modules/6.16.0-arch2-1/build/Makefile:2003: .] Error 2
make[2]: *** [/usr/lib/modules/6.16.0-arch2-1/build/Makefile:248: __sub-make] Error 2
make[2]: Leaving directory '/var/lib/dkms/nvidia/435.17/build'
make[1]: *** [Makefile:248: __sub-make] Error 2
make[1]: Leaving directory '/usr/lib/modules/6.16.0-arch2-1/build'
make: *** [Makefile:81: modules] Error 2
# exit code: 2
# elapsed time: 00:00:54
----------------------------------------------------------------Obviously, this driver will not build without compatibilty patches for 6.15+ kernels. I do a lot of work on this, but now I have no idea how to fix this. Here is the dirty patch:
5a71d5a (HEAD -> new-variant) nvidia/nvidia.Kbuild, nvidia-modeset/nvidia-modeset.Kbuild: debugging creating symlinks
diff --git a/nvidia-modeset/nvidia-modeset.Kbuild b/nvidia-modeset/nvidia-modeset.Kbuild
index a0c8c00..503f1b0 100644
--- a/nvidia-modeset/nvidia-modeset.Kbuild
+++ b/nvidia-modeset/nvidia-modeset.Kbuild
@@ -41,7 +41,7 @@ NVIDIA_MODESET_BINARY_OBJECT := $(src)/nvidia-modeset/nv-modeset-kernel.o_binary
NVIDIA_MODESET_BINARY_OBJECT_O := nvidia-modeset/nv-modeset-kernel.o
quiet_cmd_symlink = SYMLINK $@
-cmd_symlink = ln -sf $< $@
+cmd_symlink = ln -sf -r $< $@
targets += $(NVIDIA_MODESET_BINARY_OBJECT_O)
diff --git a/nvidia/nvidia.Kbuild b/nvidia/nvidia.Kbuild
index 7c4d6db..d1c4144 100644
--- a/nvidia/nvidia.Kbuild
+++ b/nvidia/nvidia.Kbuild
@@ -41,7 +41,7 @@ NVIDIA_BINARY_OBJECT := $(src)/nvidia/nv-kernel.o_binary
NVIDIA_BINARY_OBJECT_O := nvidia/nv-kernel.o
quiet_cmd_symlink = SYMLINK $@
- cmd_symlink = ln -sf $< $@
+ cmd_symlink = ln -sf -r $< $@
targets += $(NVIDIA_BINARY_OBJECT_O)
b6f0f89 nvidia-modeset/{nvidia-modeset{-linux.c,.Kbuild}: add missing prototypes, use timer_delete_sync() on modern kernels, add trailing newline
diff --git a/nvidia-modeset/nvidia-modeset-linux.c b/nvidia-modeset/nvidia-modeset-linux.c
index 9d2efbf..29d4038 100644
--- a/nvidia-modeset/nvidia-modeset-linux.c
+++ b/nvidia-modeset/nvidia-modeset-linux.c
@@ -53,6 +53,16 @@
#define NVKMS_LOG_PREFIX "nvidia-modeset: "
+/* Prototypes for functions to suppress compliation varnings */
+struct nvkms_per_open *nvkms_open_common(enum NvKmsClientType type,
+ struct NvKmsKapiDevice *device,
+ int *status);
+
+void NVKMS_API_CALL nvkms_close_common(struct nvkms_per_open *popen);
+
+int NVKMS_API_CALL nvkms_ioctl_common(struct nvkms_per_open *popen,
+ NvU32 cmd, NvU64 address, const size_t size);
+
/*
* Convert from microseconds to jiffies. The conversion is:
* ((usec) * HZ / 1000000)
@@ -557,7 +567,11 @@ static void nvkms_kthread_q_callback(void *arg)
* pending timers and than waiting for workqueue callbacks.
*/
if (timer->kernel_timer_created) {
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(6, 4, 0)
del_timer_sync(&timer->kernel_timer);
+#else
+ timer_delete_sync(&timer -> kernel_timer);
+#endif
}
down(&nvkms_lock);
@@ -1368,10 +1382,30 @@ restart:
* completion, and we wait for queue completion with
* nv_kthread_q_stop below.
*/
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(5, 15, 0)
if (del_timer_sync(&timer->kernel_timer) == 1) {
/* We've deactivated timer so we need to clean after it */
list_del(&timer->timers_list);
-
+
+ /* We need to unlock spinlock because we are freeing memory which
+ * may sleep */
+ spin_unlock_irqrestore(&nvkms_timers.lock, flags);
+
+ if (timer->isRefPtr) {
+ nvkms_dec_ref(timer->dataPtr);
+ kfree(timer);
+ } else {
+ nvkms_free(timer, sizeof(*timer));
+ }
+
+ /* List could change when we were freeing memory. */
+ goto restart;
+ }
+#else
+ if (timer_delete_sync(&timer->kernel_timer) == 1) {
+ /* We've deactivated timer so we need to clean after it */
+ list_del(&timer->timers_list);
+
/* We need to unlock spinlock because we are freeing memory which
* may sleep */
spin_unlock_irqrestore(&nvkms_timers.lock, flags);
@@ -1386,6 +1420,7 @@ restart:
/* List could change when we were freeing memory. */
goto restart;
}
+#endif /* LINUX_VERSION_CODE <= KERNEL_VERSION(5, 15, 0) */
}
}
diff --git a/nvidia-modeset/nvidia-modeset.Kbuild b/nvidia-modeset/nvidia-modeset.Kbuild
index 349b337..a0c8c00 100644
--- a/nvidia-modeset/nvidia-modeset.Kbuild
+++ b/nvidia-modeset/nvidia-modeset.Kbuild
@@ -88,4 +88,4 @@ NV_CONFTEST_FUNCTION_COMPILE_TESTS += proc_remove
NV_CONFTEST_FUNCTION_COMPILE_TESTS += timer_setup
NV_CONFTEST_FUNCTION_COMPILE_TESTS += do_gettimeofday
NV_CONFTEST_FUNCTION_COMPILE_TESTS += kthread_create_on_node
-NV_CONFTEST_SYMBOL_COMPILE_TESTS += is_export_symbol_present_kthread_create_on_node
\ No newline at end of file
+NV_CONFTEST_SYMBOL_COMPILE_TESTS += is_export_symbol_present_kthread_create_on_node
3dc0d71 (origin/new-variant) nvidia-uvm/uvm8_{migrate,policy,populate_pageable}.c: avoid vma -> vm_next on kernels > 5.15, drop mmap_sem usage
diff --git a/nvidia-uvm/uvm8_migrate.c b/nvidia-uvm/uvm8_migrate.c
index caf0531..93dbe3f 100644
--- a/nvidia-uvm/uvm8_migrate.c
+++ b/nvidia-uvm/uvm8_migrate.c
@@ -945,7 +945,12 @@ done:
// benchmarks to see if a two-pass approach would be faster (first
// pass pushes all GPU work asynchronously, second pass updates CPU
// mappings synchronously).
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(5, 15, 0)
uvm_up_read_mmap_sem_out_of_order(¤t->mm->mmap_sem);
+#else
+ mmap_read_unlock(current -> mm);
+#endif
+
if (tracker_ptr) {
if (params->semaphoreAddress && status == NV_OK) {
// Need to do a semaphore release.
@@ -990,7 +995,11 @@ NV_STATUS uvm_api_migrate_range_group(UVM_MIGRATE_RANGE_GROUP_PARAMS *params, st
uvm_gpu_t *gpu = NULL;
// mmap_sem will be needed if we have to create CPU mappings
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(5, 15, 0)
uvm_down_read_mmap_sem(¤t->mm->mmap_sem);
+#else
+ mmap_read_lock(current -> mm);
+#endif
uvm_va_space_down_read(va_space);
if (uvm_uuid_is_cpu(¶ms->destinationUuid)) {
@@ -1035,8 +1044,11 @@ done:
// benchmarks to see if a two-pass approach would be faster (first
// pass pushes all GPU work asynchronously, second pass updates CPU
// mappings synchronously).
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(5, 15, 0)
uvm_up_read_mmap_sem_out_of_order(¤t->mm->mmap_sem);
-
+#else
+ mmap_read_unlock(current -> mm);
+#endif
tracker_status = uvm_tracker_wait_deinit(&local_tracker);
uvm_va_space_up_read(va_space);
diff --git a/nvidia-uvm/uvm8_policy.c b/nvidia-uvm/uvm8_policy.c
index fc60242..5c4c619 100644
--- a/nvidia-uvm/uvm8_policy.c
+++ b/nvidia-uvm/uvm8_policy.c
@@ -51,7 +51,11 @@ bool uvm_is_valid_vma_range(NvU64 start, NvU64 length)
if (vma->vm_end >= end)
return true;
start = vma->vm_end;
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(5, 15, 0)
vma = vma->vm_next;
+#else
+ vma = find_vma(current -> mm, vma -> vm_end);
+#endif
}
return false;
diff --git a/nvidia-uvm/uvm8_populate_pageable.c b/nvidia-uvm/uvm8_populate_pageable.c
index 831261e..f14faaf 100644
--- a/nvidia-uvm/uvm8_populate_pageable.c
+++ b/nvidia-uvm/uvm8_populate_pageable.c
@@ -115,6 +115,7 @@ NV_STATUS uvm_populate_pageable(struct mm_struct *mm,
// VMAs are validated and populated one at a time, since they may have
// different protection flags
// Validation of VM_SPECIAL flags is delegated to get_user_pages
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(5, 15, 0)
for (; vma && (vma->vm_start <= prev_outer); vma = vma->vm_next) {
NV_STATUS status = uvm_populate_pageable_vma(vma, start, outer - start, min_prot);
@@ -126,6 +127,19 @@ NV_STATUS uvm_populate_pageable(struct mm_struct *mm,
prev_outer = vma->vm_end;
}
+#else
+ for (; vma && (vma->vm_start <= prev_outer); vma = find_vma_intersection(mm, prev_outer, outer)) {
+ NV_STATUS status = uvm_populate_pageable_vma(vma, start, outer - start, min_prot);
+
+ if (status != NV_OK)
+ return status;
+
+ if (vma->vm_end >= outer)
+ return NV_OK;
+
+ prev_outer = vma->vm_end;
+ }
+#endif
// Input range not fully covered by VMAs.
return NV_ERR_INVALID_ADDRESS;
19473b2 nvidia-uvm/uvm8_migrate.c nvidia-uvm/uvm8_populate_pageable.c: use mmap_assert_lock() and mmap_read_{,un}lock() instead of lock/unlock functions that operates on mmap_sem
diff --git a/nvidia-uvm/uvm8_migrate.c b/nvidia-uvm/uvm8_migrate.c
index 0c72438..caf0531 100644
--- a/nvidia-uvm/uvm8_migrate.c
+++ b/nvidia-uvm/uvm8_migrate.c
@@ -596,7 +596,11 @@ static NV_STATUS uvm_migrate(uvm_va_space_t *va_space,
bool is_single_block;
bool should_do_cpu_preunmap;
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(5, 15, 0)
uvm_assert_mmap_sem_locked(¤t->mm->mmap_sem);
+#else
+ mmap_assert_locked(current -> mm);
+#endif
uvm_assert_rwsem_locked(&va_space->lock);
if (!first_va_range || first_va_range->type != UVM_VA_RANGE_TYPE_MANAGED)
@@ -855,7 +859,11 @@ NV_STATUS uvm_api_migrate(UVM_MIGRATE_PARAMS *params, struct file *filp)
}
// mmap_sem will be needed if we have to create CPU mappings
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(5, 15, 0)
uvm_down_read_mmap_sem(¤t->mm->mmap_sem);
+#else
+ mmap_read_lock(current -> mm);
+#endif
uvm_va_space_down_read(va_space);
if (!is_async) {
@@ -938,7 +946,6 @@ done:
// pass pushes all GPU work asynchronously, second pass updates CPU
// mappings synchronously).
uvm_up_read_mmap_sem_out_of_order(¤t->mm->mmap_sem);
-
if (tracker_ptr) {
if (params->semaphoreAddress && status == NV_OK) {
// Need to do a semaphore release.
diff --git a/nvidia-uvm/uvm8_populate_pageable.c b/nvidia-uvm/uvm8_populate_pageable.c
index c47975e..831261e 100644
--- a/nvidia-uvm/uvm8_populate_pageable.c
+++ b/nvidia-uvm/uvm8_populate_pageable.c
@@ -48,7 +48,11 @@ NV_STATUS uvm_populate_pageable_vma(struct vm_area_struct *vma,
UVM_ASSERT(PAGE_ALIGNED(outer));
UVM_ASSERT(vma->vm_end > start);
UVM_ASSERT(vma->vm_start < outer);
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(5, 15, 0)
uvm_assert_mmap_sem_locked(&mm->mmap_sem);
+#else
+ mmap_assert_locked(mm);
+#endif
if (!min_prot_ok)
return NV_ERR_INVALID_ADDRESS;
@@ -66,13 +70,19 @@ NV_STATUS uvm_populate_pageable_vma(struct vm_area_struct *vma,
// page fault handler. The page fault is caused by get_user_pages.
uvm_managed_vma = uvm_file_is_nvidia_uvm(vma->vm_file);
if (uvm_managed_vma)
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(5, 15, 0)
uvm_record_unlock_mmap_sem_read(&mm->mmap_sem);
-
+#else
+ mmap_read_unlock(mm);
+#endif
ret = NV_GET_USER_PAGES(start, vma_num_pages, is_writable, 0, NULL, NULL);
if (uvm_managed_vma)
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(5, 15, 0)
uvm_record_lock_mmap_sem_read(&mm->mmap_sem);
-
+#else
+ mmap_read_lock(mm);
+#endif
if (ret < 0)
return errno_to_nv_status(ret);
@@ -94,7 +104,11 @@ NV_STATUS uvm_populate_pageable(struct mm_struct *mm,
UVM_ASSERT(PAGE_ALIGNED(start));
UVM_ASSERT(PAGE_ALIGNED(length));
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(5, 15, 0)
uvm_assert_mmap_sem_locked(&mm->mmap_sem);
+#else
+ mmap_assert_locked(mm);
+#endif
vma = find_vma_intersection(mm, start, outer);
@@ -155,14 +169,21 @@ NV_STATUS uvm_api_populate_pageable(const UVM_POPULATE_PAGEABLE_PARAMS *params,
// mmap_sem is needed to traverse the vmas in the input range and call into
// get_user_pages
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(5, 15, 0)
uvm_down_read_mmap_sem(¤t->mm->mmap_sem);
+#else
+ mmap_read_lock(current -> mm);
+#endif
if (allow_managed || uvm_va_space_range_empty(va_space, params->base, params->base + params->length - 1))
status = uvm_populate_pageable(current->mm, params->base, params->length, min_prot);
else
status = NV_ERR_INVALID_ADDRESS;
-
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(5, 15, 0)
uvm_up_read_mmap_sem(¤t->mm->mmap_sem);
+#else
+ mmap_read_unlock(current -> mm);
+#endif
return status;
}
a2986eb nvidia-uvm/uvm8_policy.c: replace uvm8_{up,down}_read_mmap_sem() to mmap_read_{lock,unlock}()
diff --git a/nvidia-uvm/uvm8_policy.c b/nvidia-uvm/uvm8_policy.c
index 4053d08..fc60242 100644
--- a/nvidia-uvm/uvm8_policy.c
+++ b/nvidia-uvm/uvm8_policy.c
@@ -39,7 +39,11 @@ bool uvm_is_valid_vma_range(NvU64 start, NvU64 length)
const NvU64 end = start + length;
struct vm_area_struct *vma;
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(5, 15, 0)
uvm_assert_mmap_sem_locked(¤t->mm->mmap_sem);
+#else
+ mmap_assert_locked(current -> mm);
+#endif
vma = find_vma_intersection(current->mm, start, end);
@@ -232,7 +236,12 @@ NV_STATUS uvm_api_set_preferred_location(const UVM_SET_PREFERRED_LOCATION_PARAMS
UVM_ASSERT(va_space);
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(5, 15, 0)
uvm_down_read_mmap_sem(¤t->mm->mmap_sem);
+#else
+ mmap_read_lock(current -> mm);
+#endif
+
uvm_va_space_down_write(va_space);
has_va_space_write_lock = true;
@@ -305,8 +314,12 @@ done:
uvm_va_space_up_write(va_space);
else
uvm_va_space_up_read(va_space);
- uvm_up_read_mmap_sem(¤t->mm->mmap_sem);
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(5, 15, 0)
+ uvm_up_read_mmap_sem(¤t->mm->mmap_sem);
+#else
+ mmap_read_unlock(current -> mm);
+#endif
return status == NV_OK ? tracker_status : status;
}
@@ -317,7 +330,12 @@ NV_STATUS uvm_api_unset_preferred_location(const UVM_UNSET_PREFERRED_LOCATION_PA
UVM_ASSERT(va_space);
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(5, 15, 0)
uvm_down_read_mmap_sem(¤t->mm->mmap_sem);
+#else
+ mmap_read_lock(current -> mm);
+#endif
+
uvm_va_space_down_write(va_space);
status = uvm_api_range_type_check(va_space, params->requestedBase, params->length);
@@ -328,7 +346,11 @@ NV_STATUS uvm_api_unset_preferred_location(const UVM_UNSET_PREFERRED_LOCATION_PA
status = NV_OK;
uvm_va_space_up_write(va_space);
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(5, 15, 0)
uvm_up_read_mmap_sem(¤t->mm->mmap_sem);
+#else
+ mmap_read_unlock(current -> mm);
+#endif
return status;
}
@@ -409,7 +431,11 @@ static NV_STATUS accessed_by_set(uvm_va_space_t *va_space,
UVM_ASSERT(va_space);
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(5, 15, 0)
uvm_down_read_mmap_sem(¤t->mm->mmap_sem);
+#else
+ mmap_read_lock(current -> mm);
+#endif
uvm_va_space_down_write(va_space);
status = uvm_api_range_type_check(va_space, base, length);
@@ -473,7 +499,11 @@ static NV_STATUS accessed_by_set(uvm_va_space_t *va_space,
done:
uvm_va_space_up_write(va_space);
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(5, 15, 0)
uvm_up_read_mmap_sem(¤t->mm->mmap_sem);
+#else
+ mmap_read_unlock(current -> mm);
+#endif
return status;
}
@@ -656,7 +686,12 @@ static NV_STATUS read_duplication_set(uvm_va_space_t *va_space, NvU64 base, NvU6
UVM_ASSERT(va_space);
// We need mmap_sem as we may create CPU mappings
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(5, 15, 0)
uvm_down_read_mmap_sem(¤t->mm->mmap_sem);
+#else
+ mmap_read_lock(current -> mm);
+#endif
+
uvm_va_space_down_write(va_space);
status = uvm_api_range_type_check(va_space, base, length);
@@ -710,7 +745,11 @@ static NV_STATUS read_duplication_set(uvm_va_space_t *va_space, NvU64 base, NvU6
done:
uvm_va_space_up_write(va_space);
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(5, 15, 0)
uvm_up_read_mmap_sem(¤t->mm->mmap_sem);
+#else
+ mmap_read_unlock(current -> mm);
+#endif
return status;
}
182878e nvidia-uvm/uvm8_{kepler,pascal}_mmu.c: add missing prototypes
diff --git a/nvidia-uvm/uvm8_kepler_mmu.c b/nvidia-uvm/uvm8_kepler_mmu.c
index 1fa2227..b6b57f1 100644
--- a/nvidia-uvm/uvm8_kepler_mmu.c
+++ b/nvidia-uvm/uvm8_kepler_mmu.c
@@ -44,6 +44,12 @@
#define MMU_BIG 0
#define MMU_SMALL 1
+static uvm_mmu_mode_hal_t *uvm_hal_mmu_mode_kepler(NvU32 big_page_size);
+static void uvm_hal_kepler_mmu_enable_prefetch_faults_unsupported(uvm_gpu_t *gpu);
+static uvm_mmu_engine_type_t uvm_hal_kepler_mmu_engine_id_to_type_unsupported(NvU16 mmu_engine_id);
+static NvU16 uvm_hal_kepler_mmu_client_id_to_utlb_id_unsupported(NvU16 client_id);
+static void uvm_hal_kepler_mmu_disable_prefetch_faults_unsupported(uvm_gpu_t *gpu);
+
static NvU32 entries_per_index_kepler(NvU32 depth)
{
UVM_ASSERT(depth < 2);
diff --git a/nvidia-uvm/uvm8_pascal_mmu.c b/nvidia-uvm/uvm8_pascal_mmu.c
index a5af378..ee22533 100644
--- a/nvidia-uvm/uvm8_pascal_mmu.c
+++ b/nvidia-uvm/uvm8_pascal_mmu.c
@@ -45,6 +45,11 @@
#define MMU_BIG 0
#define MMU_SMALL 1
+static uvm_mmu_mode_hal_t *uvm_hal_mmu_mode_pascal(NvU32 big_page_size);
+static void uvm_hal_pascal_mmu_enable_prefetch_faults(uvm_gpu_t *gpu);
+static void uvm_hal_pascal_mmu_disable_prefetch_faults(uvm_gpu_t *gpu);
+static NvU16 uvm_hal_pascal_mmu_client_id_to_utlb_id(NvU16 client_id);
+
static NvU32 entries_per_index_pascal(NvU32 depth)
{
UVM_ASSERT(depth < 5);
@@ -171,7 +176,7 @@ static NvLength entry_size_pascal(NvU32 depth)
static NvU32 index_bits_pascal(NvU32 depth, NvU32 page_size)
{
- const static NvU32 bit_widths[] = {2, 9, 9, 8};
+ static const NvU32 bit_widths[] = {2, 9, 9, 8};
// some code paths keep on querying this until they get a 0, meaning only the page offset remains.
UVM_ASSERT(depth < 5);
if (depth < 4) {
4a82513 nvidia-uvm/uvm8_gpu_access_counters.c: use mmap_read_{,un}lock() instead of uvm_{up,down}_read_mmap_sem_locked()
diff --git a/nvidia-uvm/uvm8_gpu_access_counters.c b/nvidia-uvm/uvm8_gpu_access_counters.c
index 7588556..bc36662 100644
--- a/nvidia-uvm/uvm8_gpu_access_counters.c
+++ b/nvidia-uvm/uvm8_gpu_access_counters.c
@@ -1180,7 +1180,11 @@ static NV_STATUS service_phys_single_va_block(uvm_gpu_t *gpu,
// in order to lock it before locking the VA space.
va_space_mm = uvm_va_space_mm_retain(va_space);
if (va_space_mm)
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(5, 15, 0)
uvm_down_read_mmap_sem(&va_space_mm->mm->mmap_sem);
+#else
+ mmap_read_lock(va_space_mm -> mm);
+#endif
// Re-check that the VA block is valid after taking the VA space lock
uvm_va_space_down_read(va_space);
@@ -1222,7 +1226,11 @@ done:
uvm_va_space_up_read(va_space);
if (va_space_mm) {
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(5, 15, 0)
uvm_up_read_mmap_sem(&va_space_mm->mm->mmap_sem);
+#else
+ mmap_read_unlock(va_space_mm -> mm);
+#endif
uvm_va_space_mm_release(va_space_mm);
}
dc6b360 nvidia-uvm/uvm8_gpu_{non_,}replayable.c: use mmap_read_{,un}lock() instead of uvm_{up,down}_read_mmap_sem_locked()
diff --git a/nvidia-uvm/uvm8_gpu_non_replayable_faults.c b/nvidia-uvm/uvm8_gpu_non_replayable_faults.c
index dca990b..9466cd4 100644
--- a/nvidia-uvm/uvm8_gpu_non_replayable_faults.c
+++ b/nvidia-uvm/uvm8_gpu_non_replayable_faults.c
@@ -509,7 +509,11 @@ static NV_STATUS service_fault(uvm_gpu_t *gpu, uvm_fault_buffer_entry_t *fault_e
// TODO: Bug 1867098: Taking mmap_sem here may deadlock between RM
// and UVM.
if (va_space_mm)
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(5, 15, 0)
uvm_down_read_mmap_sem(&va_space_mm->mm->mmap_sem);
+#else
+ mmap_read_lock(va_space_mm -> mm);
+#endif
uvm_va_space_down_read(va_space);
@@ -560,7 +564,11 @@ static NV_STATUS service_fault(uvm_gpu_t *gpu, uvm_fault_buffer_entry_t *fault_e
exit_no_channel:
uvm_va_space_up_read(va_space);
if (va_space_mm) {
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(5, 15, 0)
uvm_up_read_mmap_sem(&va_space_mm->mm->mmap_sem);
+#else
+ mmap_read_unlock(va_space_mm -> mm);
+#endif
uvm_va_space_mm_release(va_space_mm);
}
diff --git a/nvidia-uvm/uvm8_gpu_replayable_faults.c b/nvidia-uvm/uvm8_gpu_replayable_faults.c
index 73dbe61..a4985c9 100644
--- a/nvidia-uvm/uvm8_gpu_replayable_faults.c
+++ b/nvidia-uvm/uvm8_gpu_replayable_faults.c
@@ -1464,7 +1464,11 @@ static NV_STATUS service_fault_batch(uvm_gpu_t *gpu,
uvm_va_space_up_read(va_space);
if (va_space_mm) {
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(5, 15, 0)
uvm_up_read_mmap_sem(&va_space_mm->mm->mmap_sem);
+#else
+ mmap_read_unlock(va_space_mm -> mm);
+#endif
uvm_va_space_mm_release(va_space_mm);
va_space_mm = NULL;
}
@@ -1483,7 +1487,11 @@ static NV_STATUS service_fault_batch(uvm_gpu_t *gpu,
// TODO: Bug 1867098: Taking mmap_sem here may deadlock between RM
// and UVM.
if (va_space_mm)
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(5, 15, 0)
uvm_down_read_mmap_sem(&va_space_mm->mm->mmap_sem);
+#else
+ mmap_read_lock(va_space_mm -> mm);
+#endif
uvm_va_space_down_read(va_space);
@@ -1590,7 +1598,11 @@ fail:
if (va_space != NULL) {
uvm_va_space_up_read(va_space);
if (va_space_mm) {
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(5, 15, 0)
uvm_up_read_mmap_sem(&va_space_mm->mm->mmap_sem);
+#else
+ mmap_read_unlock(va_space_mm -> mm);
+#endif
uvm_va_space_mm_release(va_space_mm);
}
}
9d877d2 nvidia-uvm/uvm8_ats_faults.h: use mmap_assert_locked() instead of uvm_assert_mmap_sem_locked()
diff --git a/nvidia-uvm/uvm8_ats_faults.h b/nvidia-uvm/uvm8_ats_faults.h
index e001b60..4c21bb5 100644
--- a/nvidia-uvm/uvm8_ats_faults.h
+++ b/nvidia-uvm/uvm8_ats_faults.h
@@ -25,6 +25,7 @@
#include "uvm8_lock.h"
#include "uvm8_global.h"
#include "uvm8_va_space.h"
+#include <linux/version.h>
NV_STATUS uvm_ats_service_fault_entry(uvm_gpu_va_space_t *gpu_va_space,
uvm_fault_buffer_entry_t *current_entry,
@@ -39,7 +40,11 @@ NV_STATUS uvm_ats_invalidate_tlbs(uvm_gpu_va_space_t *gpu_va_space,
static bool uvm_can_ats_service_faults(uvm_gpu_va_space_t *gpu_va_space, struct mm_struct *mm)
{
if (mm)
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(5, 15, 0)
uvm_assert_mmap_sem_locked(&mm->mmap_sem);
+#else
+ mmap_assert_locked(mm);
+#endif
if (gpu_va_space->ats.enabled)
UVM_ASSERT(g_uvm_global.ats.enabled);
4b4e436 nvidia-uvm/uvm8_va_{block,range}.c: use mmap_read{,un}lock() instead of uvm_{up,down}_read_mmap_sem()
diff --git a/nvidia-uvm/uvm8_va_block.c b/nvidia-uvm/uvm8_va_block.c
index cba60f3..47c56ff 100644
--- a/nvidia-uvm/uvm8_va_block.c
+++ b/nvidia-uvm/uvm8_va_block.c
@@ -6516,7 +6516,12 @@ static NV_STATUS block_map_cpu_page_to(uvm_va_block_t *block,
// us, so we can safely operate on the vma but we can't use
// uvm_va_range_vma_current.
vma = uvm_va_range_vma(va_range);
+
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(5, 15, 0)
uvm_assert_mmap_sem_locked(&vma->vm_mm->mmap_sem);
+#else
+ mmap_assert_locked(vma -> vm_mm);
+#endif
// Add the mapping
addr = uvm_va_block_cpu_page_address(block, page_index);
@@ -10662,7 +10667,12 @@ NV_STATUS uvm8_test_change_pte_mapping(UVM_TEST_CHANGE_PTE_MAPPING_PARAMS *param
// mmap_sem isn't needed for invalidating CPU mappings, but it will be
// needed for inserting them.
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(5, 15, 0)
uvm_down_read_mmap_sem(¤t->mm->mmap_sem);
+#else
+ mmap_read_lock(current -> mm);
+#endif
+
uvm_va_space_down_read(va_space);
if (uvm_uuid_is_cpu(¶ms->uuid)) {
@@ -10745,7 +10755,11 @@ out_block:
out:
uvm_va_space_up_read(va_space);
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(5, 15, 0)
uvm_up_read_mmap_sem(¤t->mm->mmap_sem);
+#else
+ mmap_read_unlock(current -> mm);
+#endif
uvm_va_block_context_free(block_context);
@@ -10760,7 +10774,12 @@ NV_STATUS uvm8_test_va_block_info(UVM_TEST_VA_BLOCK_INFO_PARAMS *params, struct
BUILD_BUG_ON(UVM_TEST_VA_BLOCK_SIZE != UVM_VA_BLOCK_SIZE);
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(5, 15, 0)
uvm_down_read_mmap_sem(¤t->mm->mmap_sem);
+#else
+ mmap_read_lock(current -> mm);
+#endif
+
uvm_va_space_down_read(va_space);
status = uvm_va_block_find(va_space, params->lookup_address, &va_block);
@@ -10778,7 +10797,12 @@ NV_STATUS uvm8_test_va_block_info(UVM_TEST_VA_BLOCK_INFO_PARAMS *params, struct
out:
uvm_va_space_up_read(va_space);
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(5, 15, 0)
uvm_up_read_mmap_sem(¤t->mm->mmap_sem);
+#else
+ mmap_read_unlock(current -> mm);
+#endif
+
return status;
}
@@ -10795,7 +10819,12 @@ NV_STATUS uvm8_test_va_residency_info(UVM_TEST_VA_RESIDENCY_INFO_PARAMS *params,
unsigned release_block_count = 0;
NvU64 addr = UVM_ALIGN_DOWN(params->lookup_address, PAGE_SIZE);
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(5, 15, 0)
uvm_down_read_mmap_sem(¤t->mm->mmap_sem);
+#else
+ mmap_read_unlock(current -> mm);
+#endif
+
uvm_va_space_down_read(va_space);
va_range = uvm_va_range_find(va_space, addr);
@@ -10938,7 +10967,11 @@ out:
uvm_va_block_release(block);
}
uvm_va_space_up_read(va_space);
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(5, 15, 0)
uvm_up_read_mmap_sem(¤t->mm->mmap_sem);
+#else
+ mmap_read_unlock(current -> mm);
+#endif
return status;
}
diff --git a/nvidia-uvm/uvm8_va_range.c b/nvidia-uvm/uvm8_va_range.c
index 5f0ca21..7f0f426 100644
--- a/nvidia-uvm/uvm8_va_range.c
+++ b/nvidia-uvm/uvm8_va_range.c
@@ -1794,7 +1794,11 @@ NV_STATUS uvm8_test_va_range_info(UVM_TEST_VA_RANGE_INFO_PARAMS *params, struct
va_space = uvm_va_space_get(filp);
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(5, 15, 0)
uvm_down_read_mmap_sem(¤t->mm->mmap_sem);
+#else
+ mmap_read_lock(current -> mm);
+#endif
uvm_va_space_down_read(va_space);
va_range = uvm_va_range_find(va_space, params->lookup_address);
@@ -1855,7 +1859,11 @@ NV_STATUS uvm8_test_va_range_info(UVM_TEST_VA_RANGE_INFO_PARAMS *params, struct
out:
uvm_va_space_up_read(va_space);
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(5, 15, 0)
uvm_up_read_mmap_sem(¤t->mm->mmap_sem);
+#else
+ mmap_read_unlock(current -> mm);
+#endif
return status;
}
4c68462 nvidia-uvm/uvm8_mem.c: use mmap_assert_locked() instead of uvm_assert_mmap_sem_locked()
diff --git a/nvidia-uvm/uvm8_mem.c b/nvidia-uvm/uvm8_mem.c
index c0eed57..a36ea2c 100644
--- a/nvidia-uvm/uvm8_mem.c
+++ b/nvidia-uvm/uvm8_mem.c
@@ -481,7 +481,11 @@ static NV_STATUS uvm_mem_map_cpu_to_sysmem_user(uvm_mem_t *mem, struct vm_area_s
UVM_ASSERT(uvm_mem_is_sysmem(mem));
UVM_ASSERT(mem->is_user_allocation);
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(5, 15, 0)
uvm_assert_mmap_sem_locked(&vma->vm_mm->mmap_sem);
+#else
+ mmap_assert_locked(vma -> vm_mm);
+#endif
// TODO: Bug 1995015: high-order page allocations need to be allocated as
// compound pages in order to be able to use vm_insert_page on them. This
@@ -505,7 +509,11 @@ static NV_STATUS uvm_mem_map_cpu_to_vidmem_user(uvm_mem_t *mem, struct vm_area_s
size_t num_chunk_pages = mem->chunk_size / PAGE_SIZE;
UVM_ASSERT(mem->is_user_allocation);
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(5, 15, 0)
uvm_assert_mmap_sem_locked(&vma->vm_mm->mmap_sem);
+#else
+ mmap_assert_locked(vma->vm_mm);
+#endif
UVM_ASSERT(!uvm_mem_is_sysmem(mem));
UVM_ASSERT(mem->backing_gpu != NULL);
UVM_ASSERT(mem->backing_gpu->numa_info.enabled);
37e43c2 nvidia-uvm/uvm8_va_space{,_mm}.c: replace uvm_{up,down}_read_mmap_sem() to mmap_read_{,un}lock()
diff --git a/nvidia-uvm/uvm8_va_space.c b/nvidia-uvm/uvm8_va_space.c
index 1349ff0..509df45 100644
--- a/nvidia-uvm/uvm8_va_space.c
+++ b/nvidia-uvm/uvm8_va_space.c
@@ -848,7 +848,7 @@ NV_STATUS uvm_va_space_unregister_gpu(uvm_va_space_t *va_space, const NvProcesso
uvm_processor_mask_clear(&va_space->gpu_unregister_in_progress, gpu->id);
uvm_va_space_up_write(va_space);
-##if LINUX_VERSION_CODE <= KERNEL_VERSION(5, 15, 0)
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(5, 15, 0)
uvm_up_read_mmap_sem(¤t->mm->mmap_sem);
#else
mmap_read_unlock(current -> mm);
@@ -1287,10 +1287,13 @@ NV_STATUS uvm_va_space_register_gpu_va_space(uvm_va_space_t *va_space,
gpu_va_space->ats.ats_mm = ats_mm;
uvm_ats_ibm_mm_lock(ats_mm);
uvm_ats_ibm_register_lock(va_space);
-
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(5, 15, 0)
uvm_down_write_mmap_sem(¤t->mm->mmap_sem);
- uvm_va_space_down_write(va_space);
+#else
+ mmap_write_lock(current -> mm);
+#endif
+ uvm_va_space_down_write(va_space);
if (!uvm_processor_mask_test(&va_space->registered_gpus, gpu->id)) {
status = NV_ERR_INVALID_DEVICE;
goto error;
@@ -1341,7 +1344,11 @@ NV_STATUS uvm_va_space_register_gpu_va_space(uvm_va_space_t *va_space,
}
uvm_va_space_up_write(va_space);
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(5, 15, 0)
uvm_up_write_mmap_sem(¤t->mm->mmap_sem);
+#else
+ mmap_write_unlock(current -> mm);
+#endif
uvm_ats_ibm_register_unlock(va_space);
uvm_ats_ibm_mm_unlock(ats_mm);
uvm_gpu_release(gpu);
@@ -1359,7 +1366,11 @@ error:
}
uvm_va_space_up_write(va_space);
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(5, 15, 0)
uvm_up_write_mmap_sem(¤t->mm->mmap_sem);
+#else
+ mmap_write_unlock(current -> mm);
+#endif
uvm_ats_ibm_register_unlock(va_space);
error_unlocked:
@@ -1446,7 +1457,11 @@ NV_STATUS uvm_va_space_unregister_gpu_va_space(uvm_va_space_t *va_space, const N
uvm_va_space_up_read_rm(va_space);
uvm_ats_ibm_mm_lock(ats_mm);
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(5, 15, 0)
uvm_down_read_mmap_sem(¤t->mm->mmap_sem);
+#else
+ mmap_read_lock(current -> mm);
+#endif
uvm_va_space_down_write(va_space);
// We dropped the lock so we have to re-verify that this gpu_va_space is
@@ -1470,7 +1485,11 @@ NV_STATUS uvm_va_space_unregister_gpu_va_space(uvm_va_space_t *va_space, const N
done:
uvm_va_space_up_write(va_space);
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(5, 15, 0)
uvm_up_read_mmap_sem(¤t->mm->mmap_sem);
+#else
+ mmap_read_unlock(current -> mm);
+#endif
uvm_deferred_free_object_list(&deferred_free_list);
// The deferred free above will have called
diff --git a/nvidia-uvm/uvm8_va_space_mm.c b/nvidia-uvm/uvm8_va_space_mm.c
index d3b7b75..8139927 100644
--- a/nvidia-uvm/uvm8_va_space_mm.c
+++ b/nvidia-uvm/uvm8_va_space_mm.c
@@ -532,10 +532,15 @@ static NV_STATUS mm_read64(struct mm_struct *mm, NvU64 addr, NvU64 *val)
NvU64 *mapping;
UVM_ASSERT(IS_ALIGNED(addr, sizeof(val)));
-
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(5, 15, 0)
uvm_down_read_mmap_sem(&mm->mmap_sem);
ret = NV_GET_USER_PAGES_REMOTE(NULL, mm, (unsigned long)addr, 1, write, force, &page, NULL);
uvm_up_read_mmap_sem(&mm->mmap_sem);
+#else
+ mmap_read_lock(current -> mm);
+ ret = NV_GET_USER_PAGES_REMOTE(NULL, mm, (unsigned long)addr, 1, write, force, &page, NULL);
+ mmap_read_unlock(current -> mm);
+#endif
if (ret < 0)
return errno_to_nv_status(ret);
bad6020 nvidia-uvm/uvm8_gpu.c: replace PCI_DMA_BIDIRECTIONAL to DMA_BIDIRECTIONAL, pci_{,un}map_page() to dma_{,un}map_page()
diff --git a/nvidia-uvm/uvm8_gpu.c b/nvidia-uvm/uvm8_gpu.c
index cbfef09..0464340 100644
--- a/nvidia-uvm/uvm8_gpu.c
+++ b/nvidia-uvm/uvm8_gpu.c
@@ -2376,21 +2376,26 @@ NV_STATUS uvm_gpu_map_cpu_pages(uvm_gpu_t *gpu, struct page *page, size_t size,
#if LINUX_VERSION_CODE <= KERNEL_VERSION(5, 15, 0)
NvU64 dma_addr = pci_map_page(gpu->pci_dev, page, 0, size, PCI_DMA_BIDIRECTIONAL);
#else
- dma_addr_t dma_addr = dma_map_page(gpu, page, 0, size, DMA_BIDIRECTIONAL);
+ struct device *dev = &gpu -> pci_dev -> dev;
+ NvU64 dma_addr = (NvU64)dma_map_page(dev, page, 0, size, DMA_BIDIRECTIONAL);
#endif
UVM_ASSERT(PAGE_ALIGNED(size));
#if LINUX_VERSION_CODE <= KERNEL_VERSION(5, 15, 0)
- if (pci_dma_mapping_error(gpu->pci_dev, dma_addr))
+ if (pci_dma_mapping_error(dev, dma_addr))
return NV_ERR_OPERATING_SYSTEM;
#else
- if (dma_mapping_error(gpu->pci_dev, dma_addr))
+ if (dma_mapping_error(dev, dma_addr))
return NV_ERR_OPERATING_SYSTEM;
#endif
if (dma_addr < gpu->dma_addressable_start || dma_addr + size - 1 > gpu->dma_addressable_limit) {
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(5, 15, 0)
pci_unmap_page(gpu->pci_dev, dma_addr, size, PCI_DMA_BIDIRECTIONAL);
+#else
+ dma_unmap_page(dev, dma_addr, size, DMA_BIDIRECTIONAL);
+#endif
UVM_ERR_PRINT_RL("PCI mapped range [0x%llx, 0x%llx) not in the addressable range [0x%llx, 0x%llx), GPU %s\n",
dma_addr,
dma_addr + (NvU64)size,
@@ -2412,7 +2417,6 @@ NV_STATUS uvm_gpu_map_cpu_pages(uvm_gpu_t *gpu, struct page *page, size_t size,
// transformations being applied here.
if (gpu->npu_dev)
dma_addr = nv_compress_nvlink_addr(dma_addr);
-
*dma_addr_out = dma_addr;
return NV_OK;
}
@@ -2423,8 +2427,14 @@ void uvm_gpu_unmap_cpu_pages(uvm_gpu_t *gpu, NvU64 dma_address, size_t size)
if (gpu->npu_dev)
dma_address = nv_expand_nvlink_addr(dma_address);
+
dma_address += gpu->dma_addressable_start;
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(5, 15, 0)
pci_unmap_page(gpu->pci_dev, dma_address, size, PCI_DMA_BIDIRECTIONAL);
+#else
+ struct device *dev = &gpu -> pci_dev -> dev;
+ dma_unmap_page(dev, dma_address, size, DMA_BIDIRECTIONAL);
+#endif
atomic64_sub(size, &gpu->mapped_cpu_pages_size);
}
9cf80d9 nvidia-uvm/uvm8_va_space.c: replace uvm_{up,down}_read_mmap_sem() to mmap_read_{,un}lock()
diff --git a/nvidia-uvm/uvm8_va_space.c b/nvidia-uvm/uvm8_va_space.c
index 055e0fc..1349ff0 100644
--- a/nvidia-uvm/uvm8_va_space.c
+++ b/nvidia-uvm/uvm8_va_space.c
@@ -39,6 +39,7 @@
#include "uvm_common.h"
#include "nv_uvm_interface.h"
#include "nv-kthread-q.h"
+#include <linux/version.h>
static bool processor_mask_array_test(const uvm_processor_mask_t *mask,
uvm_processor_id_t mask_id,
@@ -818,7 +819,11 @@ NV_STATUS uvm_va_space_unregister_gpu(uvm_va_space_t *va_space, const NvProcesso
// The mmap_sem lock is needed to establish CPU mappings to any pages
// evicted from the GPU if accessed by CPU is set for them.
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(5, 15, 0)
uvm_down_read_mmap_sem(¤t->mm->mmap_sem);
+#else
+ mmap_read_lock(current -> mm);
+#endif
uvm_va_space_down_write(va_space);
@@ -843,8 +848,11 @@ NV_STATUS uvm_va_space_unregister_gpu(uvm_va_space_t *va_space, const NvProcesso
uvm_processor_mask_clear(&va_space->gpu_unregister_in_progress, gpu->id);
uvm_va_space_up_write(va_space);
+##if LINUX_VERSION_CODE <= KERNEL_VERSION(5, 15, 0)
uvm_up_read_mmap_sem(¤t->mm->mmap_sem);
-
+#else
+ mmap_read_unlock(current -> mm);
+#endif
uvm_deferred_free_object_list(&deferred_free_list);
if (ats_mm) {
90f1169 nvidia-uvm/uvm8_gpu.c: replace PCI_DMA_BIDIRECTIONAL, pci_map_page() and pci_dma_mapping_error()
diff --git a/nvidia-uvm/uvm8_gpu.c b/nvidia-uvm/uvm8_gpu.c
index 8683537..cbfef09 100644
--- a/nvidia-uvm/uvm8_gpu.c
+++ b/nvidia-uvm/uvm8_gpu.c
@@ -41,6 +41,7 @@
#include "nv-kthread-q.h"
#include "uvm8_gpu_access_counters.h"
#include "uvm8_test.h"
+#include <linux/version.h>
static void remove_gpu(uvm_gpu_t *gpu);
static void disable_peer_access(uvm_gpu_t *gpu0, uvm_gpu_t *gpu1);
@@ -2372,12 +2373,21 @@ out:
NV_STATUS uvm_gpu_map_cpu_pages(uvm_gpu_t *gpu, struct page *page, size_t size, NvU64 *dma_addr_out)
{
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(5, 15, 0)
NvU64 dma_addr = pci_map_page(gpu->pci_dev, page, 0, size, PCI_DMA_BIDIRECTIONAL);
+#else
+ dma_addr_t dma_addr = dma_map_page(gpu, page, 0, size, DMA_BIDIRECTIONAL);
+#endif
UVM_ASSERT(PAGE_ALIGNED(size));
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(5, 15, 0)
if (pci_dma_mapping_error(gpu->pci_dev, dma_addr))
return NV_ERR_OPERATING_SYSTEM;
+#else
+ if (dma_mapping_error(gpu->pci_dev, dma_addr))
+ return NV_ERR_OPERATING_SYSTEM;
+#endif
if (dma_addr < gpu->dma_addressable_start || dma_addr + size - 1 > gpu->dma_addressable_limit) {
pci_unmap_page(gpu->pci_dev, dma_addr, size, PCI_DMA_BIDIRECTIONAL);
5fa1c31 nvidia-uvm/uvm8_tools.c: add missing prototypes for uvm_tools_{init,exit}()
diff --git a/nvidia-uvm/uvm8_tools.c b/nvidia-uvm/uvm8_tools.c
index ae0dcc1..9ff1553 100644
--- a/nvidia-uvm/uvm8_tools.c
+++ b/nvidia-uvm/uvm8_tools.c
@@ -184,16 +184,22 @@ static struct kmem_cache *g_tools_replay_data_cache __read_mostly = NULL;
static struct kmem_cache *g_tools_block_map_remote_data_cache __read_mostly = NULL;
static struct kmem_cache *g_tools_map_remote_data_cache __read_mostly = NULL;
static uvm_spinlock_t g_tools_channel_list_lock;
+
static LIST_HEAD(g_tools_channel_list);
static nv_kthread_q_t g_tools_queue;
-
+static int uvm_tools_init(dev_t uvm_base_dev);
+static void uvm_tools_exit(void);
static NV_STATUS tools_update_status(uvm_va_space_t *va_space);
static uvm_tools_event_tracker_t *tools_event_tracker(struct file *filp)
{
long event_tracker = atomic_long_read((atomic_long_t *)&filp->private_data);
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(5, 15, 0)
smp_read_barrier_depends();
+#else
+ READ_ONCE(event_tracker);
+#endif
return (uvm_tools_event_tracker_t *)event_tracker;
}
c17d211 nvidia-uvm/uvm8.c: replacements to mmap_{read,write}_{lock,unlock}() related to mmap_sem
diff --git a/nvidia-uvm/uvm8.c b/nvidia-uvm/uvm8.c
index 1c6c850..03759b9 100644
--- a/nvidia-uvm/uvm8.c
+++ b/nvidia-uvm/uvm8.c
@@ -368,7 +368,11 @@ static void uvm_vm_open_managed(struct vm_area_struct *vma)
}
// At this point we are guaranteed that the mmap_sem is held in write mode.
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(5, 15, 0)
uvm_record_lock_mmap_sem_write(¤t->mm->mmap_sem);
+#else
+ mmap_assert_write_locked(current -> mm);
+#endif
// Split vmas should always fall entirely within the old one, and be on one
// side.
@@ -417,7 +421,11 @@ static void uvm_vm_open_managed(struct vm_area_struct *vma)
out:
uvm_va_space_up_write(va_space);
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(5, 15, 0)
uvm_record_unlock_mmap_sem_write(¤t->mm->mmap_sem);
+#else
+ mmap_write_unlock(current -> mm);
+#endif
}
static void uvm_vm_open_managed_entry(struct vm_area_struct *vma)
@@ -432,8 +440,11 @@ static void uvm_vm_close_managed(struct vm_area_struct *vma)
bool is_uvm_teardown = false;
if (current->mm != NULL)
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(5, 15, 0)
uvm_record_lock_mmap_sem_write(¤t->mm->mmap_sem);
-
+#else
+ mmap_write_lock(current -> mm);
+#endif
if (current->mm == NULL) {
// current->mm will be NULL on process teardown. In that case, we want
// to stop all user channels before unmapping the managed allocations to
@@ -462,7 +473,11 @@ static void uvm_vm_close_managed(struct vm_area_struct *vma)
uvm_va_space_up_write(va_space);
if (current->mm != NULL)
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(5, 15, 0)
uvm_record_unlock_mmap_sem_write(¤t->mm->mmap_sem);
+#else
+ mmap_write_unlock(current -> mm);
+#endif
}
static void uvm_vm_close_managed_entry(struct vm_area_struct *vma)
@@ -510,7 +525,11 @@ static vm_fault_t uvm_vm_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
// The mmap_sem might be held in write mode, but the mode doesn't matter for
// the purpose of lock ordering and we don't rely on it being in write
// anywhere so just record it as read mode in all cases.
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(5, 15, 0)
uvm_record_lock_mmap_sem_read(&vma->vm_mm->mmap_sem);
+#else
+ mmap_read_lock(current -> mm);
+#endif
do {
bool do_sleep = false;
@@ -573,8 +592,11 @@ static vm_fault_t uvm_vm_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
}
uvm_va_space_up_read(va_space);
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(5, 15, 0)
uvm_record_unlock_mmap_sem_read(&vma->vm_mm->mmap_sem);
-
+#else
+ mmap_read_unlock(current -> mm);
+#endif
if (status == NV_OK) {
status = uvm_global_mask_check_ecc_error(&gpus_to_check_for_ecc);
uvm_global_mask_release(&gpus_to_check_for_ecc);
@@ -649,7 +671,11 @@ static void uvm_vm_open_semaphore_pool(struct vm_area_struct *vma)
bool is_fork = (vma->vm_mm != origin_vma->vm_mm);
NV_STATUS status;
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(5, 15, 0)
uvm_record_lock_mmap_sem_write(¤t->mm->mmap_sem);
+#else
+ mmap_write_lock(current -> mm);
+#endif
uvm_va_space_down_write(va_space);
@@ -689,7 +715,11 @@ static void uvm_vm_open_semaphore_pool(struct vm_area_struct *vma)
uvm_va_space_up_write(va_space);
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(5, 15, 0)
uvm_record_unlock_mmap_sem_write(¤t->mm->mmap_sem);
+#else
+ mmap_write_unlock(current -> mm);
+#endif
}
static void uvm_vm_open_semaphore_pool_entry(struct vm_area_struct *vma)
@@ -704,7 +734,11 @@ static void uvm_vm_close_semaphore_pool(struct vm_area_struct *vma)
uvm_va_space_t *va_space = uvm_va_space_get(vma->vm_file);
if (current->mm != NULL)
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(5, 15, 0)
uvm_record_lock_mmap_sem_write(¤t->mm->mmap_sem);
+#else
+ mmap_write_lock(current -> mm);
+#endif
uvm_va_space_down_read(va_space);
@@ -713,7 +747,11 @@ static void uvm_vm_close_semaphore_pool(struct vm_area_struct *vma)
uvm_va_space_up_read(va_space);
if (current->mm != NULL)
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(5, 15, 0)
uvm_record_unlock_mmap_sem_write(¤t->mm->mmap_sem);
+#else
+ mmap_write_unlock(current -> mm);
+#endif
}
static void uvm_vm_close_semaphore_pool_entry(struct vm_area_struct *vma)
@@ -770,8 +808,11 @@ static int uvm_mmap(struct file *filp, struct vm_area_struct *vma)
uvm_disable_vma(vma);
return 0;
}
-
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(5, 15, 0)
uvm_record_lock_mmap_sem_write(¤t->mm->mmap_sem);
+#else
+ mmap_write_lock(current -> mm);
+#endif
// VM_MIXEDMAP Required to use vm_insert_page
//
@@ -785,7 +826,11 @@ static int uvm_mmap(struct file *filp, struct vm_area_struct *vma)
// Using VM_DONTCOPY would be nice, but madvise(MADV_DOFORK) can reset that
// so we have to handle vm_open on fork anyway. We could disable MADV_DOFORK
// with VM_IO, but that causes other mapping issues.
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(5, 15, 0)
vma->vm_flags |= VM_MIXEDMAP | VM_DONTEXPAND;
+#else
+ set_current_state(VM_MIXEDMAP | VM_DONTEXPAND);
+#endif
vma->vm_ops = &uvm_vm_ops_managed;
@@ -838,7 +883,11 @@ out:
if (ret != 0 && vma_wrapper_allocated)
uvm_vma_wrapper_destroy(vma->vm_private_data);
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(5, 15, 0)
uvm_record_unlock_mmap_sem_write(¤t->mm->mmap_sem);
+#else
+ mmap_write_unlock(current->mm);
+#endif
uvm_up_read(&g_uvm_global.pm.lock);
@@ -858,7 +907,11 @@ static NV_STATUS uvm_api_initialize(UVM_INITIALIZE_PARAMS *params, struct file *
if ((params->flags & ~UVM_INIT_FLAGS_MASK))
return NV_ERR_INVALID_ARGUMENT;
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(5, 15, 0)
uvm_down_write_mmap_sem(¤t->mm->mmap_sem);
+#else
+ mmap_read_lock(current -> mm);
+#endif
uvm_va_space_down_write(va_space);
if (va_space->initialized) {
@@ -873,10 +926,13 @@ static NV_STATUS uvm_api_initialize(UVM_INITIALIZE_PARAMS *params, struct file *
if (status == NV_OK)
va_space->initialized = true;
}
-
uvm_va_space_up_write(va_space);
- uvm_up_write_mmap_sem(¤t->mm->mmap_sem);
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(5, 15, 0)
+ uvm_up_write_mmap_sem(¤t->mm->mmap_sem);
+#else
+ mmap_read_unlock(current -> mm);
+#endif
return status;
}
1edd87d nvidia/nv-mmap.c: nv_encode_caching(): __attribute__((__fallthrough__));
diff --git a/nvidia/nv-mmap.c b/nvidia/nv-mmap.c
index ed67769..cd336c7 100644
--- a/nvidia/nv-mmap.c
+++ b/nvidia/nv-mmap.c
@@ -333,6 +333,9 @@ int nv_encode_caching(
case NV_MEMORY_CACHED:
if (NV_ALLOW_CACHING(memory_type))
break;
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 0, 0)
+ __attribute__((__fallthrough__));
+#endif
default:
nv_printf(NV_DBG_ERRORS,
"NVRM: VM: cache type %d not supported for memory type %d!\n",
ea9fc93 conftest.sh, nvidia-uvm/uvm8_va_range.h, nvidia-uvm/nvidia-uvm.Kbuild: switch from smp_read_barrier_depends() to READ_ONCE()
diff --git a/conftest.sh b/conftest.sh
index d7aeddb..1749941 100755
--- a/conftest.sh
+++ b/conftest.sh
@@ -3440,6 +3440,27 @@ compile_test() {
compile_check_conftest "$CODE" "NV_TEGRA_GET_PLATFORM_PRESENT" "" "functions"
;;
+ # Since the version 4.16, smp_read_barrier_depends was removed from Linux.
+ # So, we need todetermine its presence.
+ smp_read_barrier_depends)
+ echo "$CONFTEST_PREAMBLE
+ #include <linux/smp.h>
+ void conftest_read_barrier_depends(void) {
+ smp_read_barrier_depends(NULL);
+ }
+ " > conftest$$.c
+
+ $CC $CFLAGS -c conftest$$.c > /dev/null 2>&1
+ rm conftest$$.c
+ if [ -f conftest$$.o ]; then
+ echo "#define NV_SMP_READ_BARRIER_DEPENDS_PRESENT" | append_conftest "functions"
+ return
+ else
+ echo "#undef NV_SMP_READ_BARRIER_DEPENDS_PRESENT" | append_conftest "functions"
+ fi
+
+ ;;
+
# When adding a new conftest entry, please use the correct format for
# specifying the relevant upstream Linux kernel commit.
#
@@ -3451,6 +3472,7 @@ compile_test() {
echo "Error: unknown conftest '$1' requested" >&2
exit 1
;;
+
esac
}
diff --git a/nvidia-uvm/nvidia-uvm.Kbuild b/nvidia-uvm/nvidia-uvm.Kbuild
index c7fe851..f03eb92 100644
--- a/nvidia-uvm/nvidia-uvm.Kbuild
+++ b/nvidia-uvm/nvidia-uvm.Kbuild
@@ -90,6 +90,7 @@ NV_CONFTEST_FUNCTION_COMPILE_TESTS += do_gettimeofday
NV_CONFTEST_FUNCTION_COMPILE_TESTS += kthread_create_on_node
NV_CONFTEST_FUNCTION_COMPILE_TESTS += vmf_insert_pfn
NV_CONFTEST_FUNCTION_COMPILE_TESTS += cpumask_of_node
+NV_CONFTEST_FUNCTION_COMPILE_TESTS += smp_read_barrier_depends
NV_CONFTEST_TYPE_COMPILE_TESTS += outer_flush_all
NV_CONFTEST_TYPE_COMPILE_TESTS += file_operations
diff --git a/nvidia-uvm/uvm8_va_range.h b/nvidia-uvm/uvm8_va_range.h
index bcb77ef..cf171ba 100644
--- a/nvidia-uvm/uvm8_va_range.h
+++ b/nvidia-uvm/uvm8_va_range.h
@@ -42,6 +42,9 @@
#include "uvm8_tracker.h"
#include "uvm_ioctl.h"
#include <linux/version.h>
+#if !defined(NV_SMP_READ_BARRIER_DEPENDS_PRESENT)
+#include <asm-generic/rwonce.h>
+#endif
// VA Ranges are the UVM driver equivalent of Linux kernel vmas. They represent
// user allocations of any page-aligned size. We maintain these as a separate
@@ -745,7 +748,11 @@ static uvm_va_block_t *uvm_va_range_block(uvm_va_range_t *va_range, size_t index
// make sure that any initialization of this block by the creating thread is
// visible to later accesses in this thread, which requires a data
// dependency barrier.
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(5, 15, 0)
smp_read_barrier_depends();
+#else
+ READ_ONCE(block);
+#endif
return block;
}
d01a483 nvidia-uvm/uvm8_tools.c: switch from {up,down}_read() to mmap_read_{lock,unlock}()
diff --git a/nvidia-uvm/uvm8_tools.c b/nvidia-uvm/uvm8_tools.c
index ad51b36..ae0dcc1 100644
--- a/nvidia-uvm/uvm8_tools.c
+++ b/nvidia-uvm/uvm8_tools.c
@@ -35,6 +35,7 @@
#include "uvm8_range_group.h"
#include "uvm8_mem.h"
#include "nv_speculation_barrier.h"
+#include <linux/version.h>
// We limit the number of times a page can be retained by the kernel
// to prevent the user from maliciously passing UVM tools the same page
@@ -255,9 +256,17 @@ static NV_STATUS map_user_pages(NvU64 user_va, NvU64 size, void **addr, struct p
goto fail;
}
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(5, 15, 0)
down_read(¤t->mm->mmap_sem);
+#else
+ mmap_read_lock(current -> mm);
+#endif
ret = NV_GET_USER_PAGES(user_va, num_pages, 1, 0, *pages, vmas);
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(5, 15, 0)
up_read(¤t->mm->mmap_sem);
+#else
+ mmap_read_unlock(current -> mm);
+#endif
if (ret != num_pages) {
status = NV_ERR_INVALID_ARGUMENT;
goto fail;
2b0b852 nvidia-uvm/uvm8_lock.h: use mmap_assert_locked(vma -> vm_mm) instead of uvm_assert_mmap_sem_locked(vma -> vm_mm -> mmap_sem)
diff --git a/nvidia-uvm/uvm8_va_range.h b/nvidia-uvm/uvm8_va_range.h
index 49b3b43..bcb77ef 100644
--- a/nvidia-uvm/uvm8_va_range.h
+++ b/nvidia-uvm/uvm8_va_range.h
@@ -41,6 +41,7 @@
#include "uvm8_mem.h"
#include "uvm8_tracker.h"
#include "uvm_ioctl.h"
+#include <linux/version.h>
// VA Ranges are the UVM driver equivalent of Linux kernel vmas. They represent
// user allocations of any page-aligned size. We maintain these as a separate
@@ -678,7 +679,11 @@ static struct vm_area_struct *uvm_va_range_vma_check(uvm_va_range_t *va_range, s
if (mm != vma->vm_mm)
return NULL;
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(5, 15, 0)
uvm_assert_mmap_sem_locked(&vma->vm_mm->mmap_sem);
+#else
+ mmap_assert_locked(vma -> vm_mm);
+#endif
return vma;
}
5884a07 nvidia-uvm/nv-kthread-q-selftest.c: add a prototype for on_nvq_assert()
diff --git a/nvidia-uvm/nv-kthread-q-selftest.c b/nvidia-uvm/nv-kthread-q-selftest.c
index e23eba8..1c5846a 100644
--- a/nvidia-uvm/nv-kthread-q-selftest.c
+++ b/nvidia-uvm/nv-kthread-q-selftest.c
@@ -38,6 +38,8 @@
#endif
#include "nv-linux.h"
+void on_nvq_assert(void);
+
// Below are just a very few lines of printing and test assertion support.
// It is important to avoid dependencies on other modules, because nv-kthread-q
// and its self test are supposed to only require:
f3ac62f nvidia-uvm/uvm_linux.h: switch from getrawmonotonic() to ktime_get_raw()
diff --git a/nvidia-uvm/uvm_linux.h b/nvidia-uvm/uvm_linux.h
index bc7d50d..9f80d5a 100644
--- a/nvidia-uvm/uvm_linux.h
+++ b/nvidia-uvm/uvm_linux.h
@@ -289,6 +289,7 @@ static inline uint64_t NV_DIV64(uint64_t dividend, uint64_t divisor, uint64_t *r
#if defined(CLOCK_MONOTONIC_RAW)
/* Return a nanosecond-precise value */
+#if !defined(NVCPU_X86_64) && LINUX_VERSION_CODE <= KERNEL_VERSION(4, 0, 0)
static inline NvU64 NV_GETTIME(void)
{
struct timespec ts = {0};
@@ -298,6 +299,18 @@ static inline NvU64 NV_GETTIME(void)
/* Wraps around every 583 years */
return (ts.tv_sec * 1000000000ULL + ts.tv_nsec);
}
+#else /* !defined(NVCPU_X86_64) && LINUX_VERSION_CODE <= KERNEL_VERSION(4, 0, 0) */
+#include <linux/timekeeping.h>
+static inline NvU64 NV_GETTIME(void)
+{
+ struct timespec64 *ts = NULL;
+
+ ktime_get_raw_ts64(ts);
+
+ /* Wraps around every 583 years */
+ return (ts -> tv_sec * 1000000000ULL + ts -> tv_nsec);
+}
+#endif/* !defined(NVCPU_X86_64) && LINUX_VERSION_CODE <= KERNEL_VERSION(4, 0, 0) */
#else
/* We can only return a microsecond-precise value with the
* available non-GPL symbols. */
fe02527 nvidia/linux_nvswitch.c: initialize ts before call timespec64_to_ns()
diff --git a/nvidia/linux_nvswitch.c b/nvidia/linux_nvswitch.c
index daafc3c..2998b1e 100644
--- a/nvidia/linux_nvswitch.c
+++ b/nvidia/linux_nvswitch.c
@@ -1595,7 +1595,7 @@ nvswitch_os_get_platform_time
getnstimeofday(&ts);
return ((NvU64) timespec_to_ns(&ts));
#else
- struct timespec64 *ts;
+ struct timespec64 *ts = NULL;
return ((NvU64) timespec64_to_ns(ts));
#endif
4de356f conftest.sh: rework pnv_npu2_init_context() to be correct
diff --git a/conftest.sh b/conftest.sh
index 3c3018f..d7aeddb 100755
--- a/conftest.sh
+++ b/conftest.sh
@@ -2726,8 +2726,6 @@ compile_test() {
return
fi
- echo "#define NV_PNV_NPU2_INIT_CONTEXT_PRESENT" | append_conftest "functions"
-
# Check the callback signature
echo "$CONFTEST_PREAMBLE
#if defined(NV_ASM_POWERNV_H_PRESENT)
@@ -2745,12 +2743,14 @@ compile_test() {
$CC $CFLAGS -c conftest$$.c > /dev/null 2>&1
rm -f conftest$$.c
if [ -f conftest$$.o ]; then
+ echo "#define NV_PNV_NPU2_INIT_CONTEXT_PRESENT" | append_conftest "functions"
echo "#define NV_PNV_NPU2_INIT_CONTEXT_CALLBACK_RETURNS_VOID" | append_conftest "functions"
rm -f conftest$$.o
return
fi
echo "#undef NV_PNV_NPU2_INIT_CONTEXT_CALLBACK_RETURNS_VOID" | append_conftest "functions"
+ echo "#undef NV_PNV_NPU2_INIT_CONTEXT_PRESENT" | append_conftest "functions"
;;
of_get_ibm_chip_id)
4b4d5a2 nvidia/linux_nvswitch.c: fix missing prototypes, named constants, variables. Replace missing functions pci_map_single(), pci_unmap_single(), pci_set_dma_mask()
diff --git a/nvidia/linux_nvswitch.c b/nvidia/linux_nvswitch.c
index 181dbec..daafc3c 100644
--- a/nvidia/linux_nvswitch.c
+++ b/nvidia/linux_nvswitch.c
@@ -29,6 +29,7 @@
#include "nv-procfs.h"
#include "nvlink_common.h"
#include "nvlink_errors.h"
+#include "nvlink_proto.h"
#include "nv-kthread-q.h"
#include <linux/module.h>
@@ -49,7 +50,7 @@
#include "export_nvswitch.h"
#include "ioctl_nvswitch.h"
-const static struct
+static const struct
{
NvlStatus status;
int err;
@@ -1588,10 +1589,16 @@ nvswitch_os_get_platform_time
void
)
{
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(5, 15, 0)
struct timespec ts;
getnstimeofday(&ts);
return ((NvU64) timespec_to_ns(&ts));
+#else
+ struct timespec64 *ts;
+
+ return ((NvU64) timespec64_to_ns(ts));
+#endif
}
void
@@ -1821,12 +1828,21 @@ _nvswitch_to_pci_dma_direction
NvU32 direction
)
{
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(5, 15, 0)
if (direction == NVSWITCH_DMA_DIR_TO_SYSMEM)
return PCI_DMA_FROMDEVICE;
else if (direction == NVSWITCH_DMA_DIR_FROM_SYSMEM)
return PCI_DMA_TODEVICE;
else
return PCI_DMA_BIDIRECTIONAL;
+#else
+ if (direction == NVSWITCH_DMA_DIR_TO_SYSMEM)
+ return DMA_FROM_DEVICE;
+ else if (direction == NVSWITCH_DMA_DIR_FROM_SYSMEM)
+ return DMA_TO_DEVICE;
+ else
+ return DMA_BIDIRECTIONAL;
+#endif
}
NvlStatus
@@ -1841,21 +1857,30 @@ nvswitch_os_map_dma_region
)
{
int dma_dir;
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(5, 15, 0)
struct pci_dev *pdev = (struct pci_dev *)os_handle;
-
+#else
+ struct device *pdev = (struct device *)os_handle;
+#endif
if (!pdev || !cpu_addr || !dma_handle)
return -NVL_BAD_ARGS;
dma_dir = _nvswitch_to_pci_dma_direction(direction);
-
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(5, 15, 0)
*dma_handle = (NvU64)pci_map_single(pdev, cpu_addr, size, dma_dir);
-
if (pci_dma_mapping_error(pdev, *dma_handle))
{
pr_err("nvidia-nvswitch: unable to create PCI DMA mapping\n");
return -NVL_ERR_GENERIC;
}
-
+#else
+ *dma_handle = (NvU64)dma_map_single(pdev, cpu_addr, size, dma_dir);
+ if (dma_mapping_error(pdev, *dma_handle))
+ {
+ pr_err("nvidia-nvswitch: unable to create PCI DMA mapping\n");
+ return -NVL_ERR_GENERIC;
+ }
+#endif
return NVL_SUCCESS;
}
@@ -1871,15 +1896,20 @@ nvswitch_os_unmap_dma_region
)
{
int dma_dir;
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(5, 15, 0)
struct pci_dev *pdev = (struct pci_dev *)os_handle;
-
+#else
+ struct device *pdev = (struct device *)os_handle;
+#endif
if (!pdev || !cpu_addr)
return -NVL_BAD_ARGS;
dma_dir = _nvswitch_to_pci_dma_direction(direction);
-
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(5, 15, 0)
pci_unmap_single(pdev, dma_handle, size, dma_dir);
-
+#else
+ dma_unmap_single(pdev, dma_handle, size, dma_dir);
+#endif
return NVL_SUCCESS;
}
@@ -1891,14 +1921,20 @@ nvswitch_os_set_dma_mask
NvU32 dma_addr_width
)
{
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(5, 15, 0)
struct pci_dev *pdev = (struct pci_dev *)os_handle;
-
+#else
+ struct device *pdev = (struct device *)os_handle;
+#endif
if (!pdev)
return -NVL_BAD_ARGS;
-
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(5, 15, 0)
if (pci_set_dma_mask(pdev, DMA_BIT_MASK(dma_addr_width)))
return -NVL_ERR_GENERIC;
-
+#else
+ if (dma_set_mask(pdev, DMA_BIT_MASK(dma_addr_width)))
+ return -NVL_ERR_GENERIC;
+#endif
return NVL_SUCCESS;
}
@@ -1913,15 +1949,20 @@ nvswitch_os_sync_dma_region_for_cpu
)
{
int dma_dir;
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(5, 15, 0)
struct pci_dev *pdev = (struct pci_dev *)os_handle;
-
+#else
+ struct device *pdev = (struct device *)os_handle;
+#endif
if (!pdev)
return -NVL_BAD_ARGS;
dma_dir = _nvswitch_to_pci_dma_direction(direction);
-
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(5, 15, 0)
pci_dma_sync_single_for_cpu(pdev, dma_handle, size, dma_dir);
-
+#else
+ dma_sync_single_for_cpu(pdev, dma_handle, size, dma_dir);
+#endif
return NVL_SUCCESS;
}
@@ -1936,14 +1977,19 @@ nvswitch_os_sync_dma_region_for_device
)
{
int dma_dir;
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(5, 15, 0)
struct pci_dev *pdev = (struct pci_dev *)os_handle;
-
+#else
+ struct device *pdev = (struct device *)os_handle;
+#endif
if (!pdev)
return -NVL_BAD_ARGS;
dma_dir = _nvswitch_to_pci_dma_direction(direction);
-
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(5, 15, 0)
pci_dma_sync_single_for_device(pdev, dma_handle, size, dma_dir);
-
+#else
+ dma_sync_single_for_device(pdev, dma_handle, size, dma_dir);
+#endif
return NVL_SUCCESS;
}
e80325e nvidia/nv-ibmnpu.c : use set_current_state(TASK_INTERRUPTIBLE), nvidia/nvlink_linux.c: go away missing prototypes and unused variables nvidia/nvlink_linux.h: nvidia/os-mlock.c :
diff --git a/nvidia/nv-ibmnpu.c b/nvidia/nv-ibmnpu.c
index 41a1976..9775450 100644
--- a/nvidia/nv-ibmnpu.c
+++ b/nvidia/nv-ibmnpu.c
@@ -236,7 +236,7 @@ void nv_init_ibmnpu_info(nv_state_t *nv)
}
nv_init_ibmnpu_numa_info(nv);
-#endif
+#endif /* defined(NV_PNV_PCI_GET_NPU_DEV_PRESENT) */
}
void nv_destroy_ibmnpu_info(nv_state_t *nv)
@@ -403,7 +403,8 @@ void NV_API_CALL nv_ibmnpu_cache_flush_range(nv_state_t *nv, NvU64 cpu_virtual,
CACHE_FLUSH();
}
-#else
+#else /* defined(NVCPU_PPC64LE) */
+#include "nv-ibmnpu.h"
void nv_init_ibmnpu_info(nv_state_t *nv)
{
@@ -451,4 +452,4 @@ void nv_ibmnpu_cache_flush_numa_region(nv_state_t *nv)
{
}
-#endif
+#endif /* defined(NVCPU_PPC64LE) */
diff --git a/nvidia/nvlink_linux.c b/nvidia/nvlink_linux.c
index 28fb7ad..21369cd 100644
--- a/nvidia/nvlink_linux.c
+++ b/nvidia/nvlink_linux.c
@@ -609,7 +609,12 @@ void NVLINK_API_CALL nvlink_sleep(unsigned int ms)
// the requested timeout has expired, loop until less
// than a jiffie of the desired delay remains.
//
+
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(4, 0, 0)
current->state = TASK_INTERRUPTIBLE;
+#else
+ set_current_state(TASK_INTERRUPTIBLE);
+#endif
do
{
schedule_timeout(jiffies);
diff --git a/nvidia/nvlink_linux.h b/nvidia/nvlink_linux.h
index 867f727..3c54f37 100644
--- a/nvidia/nvlink_linux.h
+++ b/nvidia/nvlink_linux.h
@@ -36,4 +36,7 @@
#define NVLINK_DEVICE_NAME "nvidia-nvlink"
#define NVLINK_NUM_MINOR_DEVICES 1
+int __init nvlink_core_init(void);
+void nvlink_core_exit(void);
+
#endif //_NVLINK_LINUX_H_
diff --git a/nvidia/os-mlock.c b/nvidia/os-mlock.c
index 5d4900c..8f71c9a 100644
--- a/nvidia/os-mlock.c
+++ b/nvidia/os-mlock.c
@@ -138,7 +138,7 @@ NV_STATUS NV_API_CALL os_lock_user_pages(
#if LINUX_VERSION_CODE <= KERNEL_VERSION(5, 8, 0)
down_read(&mm->mmap_sem);
#else
- mmap_read_lock(current->mm);
+ mmap_read_lock(mm);
#endif
# if LINUX_VERSION_CODE <= KERNEL_VERSION(4, 19, 0)
@@ -152,7 +152,7 @@ NV_STATUS NV_API_CALL os_lock_user_pages(
#if LINUX_VERSION_CODE <= KERNEL_VERSION(5, 8, 0)
up_read(&mm->mmap_sem);
#else
- mmap_read_unlock(current -> mm);
+ mmap_read_unlock(mm);
#endif
pinned = ret;
4a8da70 conftest.sh nvidia/nvidia.Kbuild nvidia/os-mlock.c: add check for follow_pfn() and unsafe_follow_pfn() presence
diff --git a/conftest.sh b/conftest.sh
index 342cb72..3c3018f 100755
--- a/conftest.sh
+++ b/conftest.sh
@@ -555,6 +555,43 @@ compile_test() {
compile_check_conftest "$CODE" "NV_HASH__REMAP_4K_PFN_PRESENT" "" "functions"
;;
+ follow_pfn)
+ #
+ # Determine if unsafe_follow_pfn() is present.
+ #
+ # unsafe_follow_pfn() was added by commit 69bacee7f9ad
+ # ("mm: Add unsafe_follow_pfn") in v5.13-rc1.
+ #
+ echo "$CONFTEST_PREAMBLE
+ #include <linux/mm.h>
+ void conftest_follow_pfn(void) {
+ follow_pfn();
+ }" > conftest$$.c
+
+ $CC $CFLAGS -c conftest$$.c > /dev/null 2>&1
+ rm conftest$$.c
+ if [ -f conftest$$.o ]; then
+ echo "#define NV_FOLLOW_PFN_PRESENT" | append_conftest "functions"
+ return
+ else
+ echo "#undef NV_FOLLOW_PFN_PRESENT" | append_conftest "functions"
+ echo "$CONFTEST_PREAMBLE
+ #include <linux/mm.h>
+ void conftest_unsafe_follow_pfn(void) {
+ unsafe_follow_pfn();
+ }" > conftest$$.c
+
+ $CC $CFLAGS -c conftest$$.c > /dev/null 2>&1
+ rm conftest$$.c
+ if [ -f conftest$$.o ]; then
+ echo "#define NV_UNSAFE_FOLLOW_PFN_PRESENT" | append_conftest "functions"
+ return
+ else
+ echo "#undef NV_UNSAFE_FOLLOW_PFN_PRESENT" | append_conftest "functions"
+ fi
+ fi
+ ;;
+
acpi_op_remove)
#
# Determine the number of arguments to pass to the
diff --git a/nvidia/nvidia.Kbuild b/nvidia/nvidia.Kbuild
index a61d57d..7c4d6db 100644
--- a/nvidia/nvidia.Kbuild
+++ b/nvidia/nvidia.Kbuild
@@ -98,6 +98,7 @@ NV_OBJECTS_DEPEND_ON_CONFTEST += $(NVIDIA_OBJECTS)
NV_CONFTEST_FUNCTION_COMPILE_TESTS += get_user_pages
NV_CONFTEST_FUNCTION_COMPILE_TESTS += get_user_pages_remote
+NV_CONFTEST_FUNCTION_COMPILE_TESTS += follow_pfn
NV_CONFTEST_FUNCTION_COMPILE_TESTS += hash__remap_4k_pfn
NV_CONFTEST_FUNCTION_COMPILE_TESTS += set_pages_uc
NV_CONFTEST_FUNCTION_COMPILE_TESTS += list_is_first
diff --git a/nvidia/os-mlock.c b/nvidia/os-mlock.c
index 10ccd25..5d4900c 100644
--- a/nvidia/os-mlock.c
+++ b/nvidia/os-mlock.c
@@ -15,6 +15,20 @@
#include "nv-linux.h"
#include <linux/version.h>
+static inline int nv_follow_pfn(struct vm_area_struct *vma,
+ unsigned long address,
+ unsigned long *pfn)
+{
+#if defined(NV_FOLLOW_PFN_PRESENT)
+ return follow_pfn(vma, address, pfn);
+#elif defined(NV_UNSAFE_FOLLOW_PFN_PRESENT)
+ return unsafe_follow_pfn(vma, address, pfn);
+#else
+ return -1;
+#endif
+}
+
+
NV_STATUS NV_API_CALL os_lookup_user_io_memory(
void *address,
NvU64 page_count,
@@ -59,7 +73,7 @@ NV_STATUS NV_API_CALL os_lookup_user_io_memory(
for (i = 0; i < page_count; i++)
{
- ret = follow_pfn(vma, ((NvUPtr)address + (i * PAGE_SIZE)), &pfn);
+ ret = nv_follow_pfn(vma, ((NvUPtr)address + (i * PAGE_SIZE)), &pfn);
if (ret < 0)
{
os_free_mem(*pte_array);
ed54d43 common/inc/nv-mm.h, conftest.sh: rework get_user_pages_remote() stuff
diff --git a/common/inc/nv-mm.h b/common/inc/nv-mm.h
index 86f3372..af7080f 100644
--- a/common/inc/nv-mm.h
+++ b/common/inc/nv-mm.h
@@ -115,9 +115,9 @@ static inline long NV_GET_USER_PAGES(unsigned long start, unsigned long nr_pages
* get_user_pages_remote() added 'locked' parameter
* 2016 Dec 14:5b56d49fc31dbb0487e14ead790fc81ca9fb2c99
*/
-
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(4, 19, 0)
#if defined(NV_GET_USER_PAGES_REMOTE_PRESENT)
- #if defined(NV_GET_USER_PAGES_REMOTE_HAS_WRITE_AND_FORCE_ARGS)
+ #if defined(NV_GET_USER_PAGES_REMOTE_HAS_WRITE_AND_FORCE)
#define NV_GET_USER_PAGES_REMOTE get_user_pages_remote
#else
static inline long NV_GET_USER_PAGES_REMOTE(struct task_struct *tsk,
@@ -136,7 +136,7 @@ static inline long NV_GET_USER_PAGES(unsigned long start, unsigned long nr_pages
if (force)
flags |= FOLL_FORCE;
- #if defined(NV_GET_USER_PAGES_REMOTE_HAS_LOCKED_ARG)
+ #if defined(NV_GET_USER_PAGES_REMOTE_HAS_LOCKED)
return get_user_pages_remote(tsk, mm, start, nr_pages, flags,
pages, vmas, NULL);
@@ -151,7 +151,7 @@ static inline long NV_GET_USER_PAGES(unsigned long start, unsigned long nr_pages
}
#endif
#else
- #if defined(NV_GET_USER_PAGES_HAS_WRITE_AND_FORCE_ARGS)
+ #if defined(NV_GET_USER_PAGES_HAS_WRITE_AND_FORCE)
#define NV_GET_USER_PAGES_REMOTE get_user_pages
#else
#include <linux/mm.h>
@@ -176,7 +176,35 @@ static inline long NV_GET_USER_PAGES(unsigned long start, unsigned long nr_pages
return get_user_pages(tsk, mm, start, nr_pages, flags, pages, vmas);
}
#endif
-#endif
+#endif /* defined(NV_GET_USER_PAGES_REMOTE_PRESENT) */
+#else /* LINUX_VERSION_CODE <= KERNEL_VERSION(4, 19, 0) */
+#if defined(NV_GET_USER_PAGES_REMOTE_HAS_GUP_FLAGS)
+ #include <linux/mm.h>
+ #include <linux/sched.h>
+
+ static inline long NV_GET_USER_PAGES_REMOTE(struct task_struct *tsk,
+ struct mm_struct *mm,
+ unsigned long start,
+ unsigned long nr_pages,
+ int write,
+ int force,
+ struct page **pages,
+ struct vm_area_struct **vmas)
+ {
+ unsigned int flags = 0;
+ int *locked = NULL;
+
+ if (write)
+ flags |= FOLL_WRITE;
+ if (force)
+ flags |= FOLL_FORCE;
+
+ return get_user_pages_remote(mm, start, nr_pages, flags, pages, locked);
+ }
+#else
+#error Unknown get_user_pages_remote implementation!
+#endif /* defined(NV_GET_USER_PAGES_REMOTE_HAS_GUP_FLAGS) */
+#endif /* LINUX_VERSION_CODE <= KERNEL_VERSION(4, 19, 0) */
/*
* The .virtual_address field was effectively renamed to .address, by these
diff --git a/conftest.sh b/conftest.sh
index 847bd52..342cb72 100755
--- a/conftest.sh
+++ b/conftest.sh
@@ -2452,33 +2452,10 @@ compile_test() {
# commit 5b56d49fc31d ("mm: add locked parameter to
# get_user_pages_remote()") in v4.10 (2016-12-14)
#
- # conftest #1: check if get_user_pages_remote() is available
- # return if not available.
- # Fall through to conftest #2 if it is present
- #
- echo "$CONFTEST_PREAMBLE
- #include <linux/mm.h>
- void conftest_get_user_pages_remote(void) {
- get_user_pages_remote();
- }" > conftest$$.c
-
- $CC $CFLAGS -c conftest$$.c > /dev/null 2>&1
- rm -f conftest$$.c
-
- if [ -f conftest$$.o ]; then
- echo "#undef NV_GET_USER_PAGES_REMOTE_PRESENT" | append_conftest "functions"
- echo "#undef NV_GET_USER_PAGES_REMOTE_HAS_WRITE_AND_FORCE_ARGS" | append_conftest "functions"
- echo "#undef NV_GET_USER_PAGES_REMOTE_HAS_LOCKED_ARG" | append_conftest "functions"
- rm -f conftest$$.o
- return
- fi
-
- #
- # conftest #2: check if get_user_pages_remote() has write and
+ # conftest #1: check if get_user_pages_remote() has write and
# force arguments. Return if these arguments are present
# Fall through to conftest #3 if these args are absent.
#
- echo "#define NV_GET_USER_PAGES_REMOTE_PRESENT" | append_conftest "functions"
echo "$CONFTEST_PREAMBLE
#include <linux/mm.h>
long get_user_pages_remote(struct task_struct *tsk,
@@ -2496,14 +2473,16 @@ compile_test() {
rm -f conftest$$.c
if [ -f conftest$$.o ]; then
- echo "#define NV_GET_USER_PAGES_REMOTE_HAS_WRITE_AND_FORCE_ARGS" | append_conftest "functions"
- echo "#undef NV_GET_USER_PAGES_REMOTE_HAS_LOCKED_ARG" | append_conftest "functions"
+ echo "#define NV_GET_USER_PAGES_REMOTE_HAS_WRITE_AND_FORCE" | append_conftest "functions"
+ echo "#define NV_GET_USER_PAGES_REMOTE_PRESENT" | append_conftest "functions"
rm -f conftest$$.o
return
+ else
+ echo "#undef NV_GET_USER_PAGES_REMOTE_HAS_WRITE_AND_FORCE" | append_conftest "functions"
fi
-
- # conftest #3: check if get_user_pages_remote() has locked argument
-
+ #
+ # conftest #2: check if get_user_pages_remote() has locked argument.
+ #
echo "$CONFTEST_PREAMBLE
#include <linux/mm.h>
long get_user_pages_remote(struct task_struct *tsk,
@@ -2521,12 +2500,42 @@ compile_test() {
rm -f conftest$$.c
if [ -f conftest$$.o ]; then
- echo "#define NV_GET_USER_PAGES_REMOTE_HAS_LOCKED_ARG" | append_conftest "functions"
+ echo "#define NV_GET_USER_PAGES_REMOTE_PRESENT" | append_conftest "functions"
+ echo "#define NV_GET_USER_PAGES_REMOTE_HAS_LOCKED" | append_conftest "functions"
rm -f conftest$$.o
else
- echo "#undef NV_GET_USER_PAGES_REMOTE_HAS_LOCKED_ARG" | append_conftest "functions"
+ echo "#undef NV_GET_USER_PAGES_REMOTE_HAS_LOCKED" | append_conftest "functions"
+ fi
+ #
+ # conftest #3: check if get_user_pages_remote() has gup_flags argument, since the removal
+ # of tsk, write, force and vmas arguments. Return if this argument are present
+ # Fall through to undef get_user_pages_remote presence.
+ #
+ echo "$CONFTEST_PREAMBLE
+ #include <linux/mm.h>
+ void conftest_get_user_pages_remote(void) {
+ struct mm_struct *mm = NULL;
+ unsigned long start = 0;
+ unsigned long nr_pages = 0;
+ unsigned int gup_flags = 0;
+ struct page **pages = NULL;
+ int *locked = NULL;
+
+ get_user_pages_remote(mm, start, nr_pages, gup_flags, pages, locked);
+ return;
+ }" > conftest$$.c
+
+ $CC $CFLAGS -c conftest$$.c > /dev/null 2>&1
+ rm -f conftest$$.c
+
+ if [ -f conftest$$.o ]; then
+ echo "#define NV_GET_USER_PAGES_REMOTE_PRESENT" | append_conftest "functions"
+ echo "#define NV_GET_USER_PAGES_REMOTE_HAS_GUP_FLAGS" | append_conftest "functions"
+ rm -f conftest$$.o
+ return
+ else
+ echo "#undef NV_GET_USER_PAGES_REMOTE_PRESENT" | append_conftest "functions"
fi
- echo "#undef NV_GET_USER_PAGES_REMOTE_HAS_WRITE_AND_FORCE_ARGS" | append_conftest "functions"
;;
776629f common/inc/nv-mm.h, nvidia/os-mlock.c: rework get_user_pages() call
diff --git a/common/inc/nv-mm.h b/common/inc/nv-mm.h
index 290f2c9..86f3372 100644
--- a/common/inc/nv-mm.h
+++ b/common/inc/nv-mm.h
@@ -47,56 +47,53 @@ typedef int vm_fault_t;
*
*/
-#if defined(NV_GET_USER_PAGES_HAS_TASK_STRUCT)
- #if defined(NV_GET_USER_PAGES_HAS_WRITE_AND_FORCE_ARGS)
- #define NV_GET_USER_PAGES(start, nr_pages, write, force, pages, vmas) \
- get_user_pages(current, current->mm, start, nr_pages, write, force, pages, vmas)
- #else
- #include <linux/mm.h>
- #include <linux/sched.h>
+#if defined(NV_GET_USER_PAGES_PRESENT)
+#include <linux/mm.h>
+#include <linux/sched.h>
- static inline long NV_GET_USER_PAGES(unsigned long start,
- unsigned long nr_pages,
- int write,
- int force,
- struct page **pages,
- struct vm_area_struct **vmas)
- {
- unsigned int flags = 0;
+#if defined(NV_GET_USER_PAGES_HAS_WRITE_AND_FORCE) && defined(NV_GET_USER_PAGES_HAS_VMAS)
+#define NV_GET_USER_PAGES(start, nr_pages, write, force, pages, vmas) \
+ get_user_pages(start, nr_pages, write, force, pages, vmas)
- if (write)
- flags |= FOLL_WRITE;
- if (force)
- flags |= FOLL_FORCE;
+#elif defined(NV_GET_USER_PAGES_HAS_GUP_FLAGS) && defined(NV_GET_USER_PAGES_HAS_VMAS)
+static inline long NV_GET_USER_PAGES(start, nr_pages, write, force, pages, vmas) {
+ unsigned int flags = 0;
- return get_user_pages(current, current->mm, start, nr_pages, flags,
- pages, vmas);
- }
- #endif
-#else
- #if defined(NV_GET_USER_PAGES_HAS_WRITE_AND_FORCE_ARGS)
- #define NV_GET_USER_PAGES get_user_pages
- #else
- #include <linux/mm.h>
+ if (write)
+ flags |= FOLL_WRITE;
+ if (force)
+ flags |= FOLL_FORCE;
- static inline long NV_GET_USER_PAGES(unsigned long start,
- unsigned long nr_pages,
- int write,
- int force,
- struct page **pages,
- struct vm_area_struct **vmas)
- {
- unsigned int flags = 0;
+ return get_user_pages(start, nr_pages, flags, pages, vmas);
+}
+#elif defined(NV_GET_USER_PAGES_HAS_GUP_FLAGS) && defined(NV_GET_USER_PAGES_HAS_TASK_STRUCT) \
+ && defined(NV_GET_USER_PAGES_HAS_VMAS) && defined(NV_GET_USER_PAGES_HAS_MM_STRUCT)
- if (write)
- flags |= FOLL_WRITE;
- if (force)
- flags |= FOLL_FORCE;
+/* Just drop unused parameters here */
+static inline long NV_GET_USER_PAGES(start, nr_pages, write, force, pages, vmas) {
+ unsigned int flags = 0;
- return get_user_pages(start, nr_pages, flags, pages, vmas);
- }
- #endif
-#endif
+ if (write)
+ flags |= FOLL_WRITE;
+ if (force)
+ flags |= FOLL_FORCE;
+
+ return get_user_pages(tsk, mm, start, nr_pages, flags, pages, vmas);
+}
+#elif defined(NV_GET_USER_PAGES_HAS_GUP_FLAGS)
+static inline long NV_GET_USER_PAGES(unsigned long start, unsigned long nr_pages, int write, int force,
+ struct page **pages, struct vm_area_struct **vmas) {
+ unsigned int flags = 0;
+
+ if (write)
+ flags |= FOLL_WRITE;
+ if (force)
+ flags |= FOLL_FORCE;
+
+ return get_user_pages(start, nr_pages, flags, pages);
+}
+#endif /* defined(NV_GET_USER_PAGES_HAS_WRITE_AND_FORCE) && defined(NV_GET_USER_PAGES_HAS_VMAS) */
+#endif /* defined(NV_GET_USER_PAGES_PRESENT) */
/* get_user_pages_remote() was added by:
* 2016 Feb 12: 1e9877902dc7e11d2be038371c6fbf2dfcd469d7
diff --git a/nvidia/os-mlock.c b/nvidia/os-mlock.c
index 60fe26c..10ccd25 100644
--- a/nvidia/os-mlock.c
+++ b/nvidia/os-mlock.c
@@ -99,7 +99,11 @@ NV_STATUS NV_API_CALL os_lock_user_pages(
struct page **user_pages;
NvU64 i, pinned;
NvBool write = 1, force = 0;
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(4, 19, 0)
int ret;
+#else
+ long ret;
+#endif
if (!NV_MAY_SLEEP())
{
@@ -123,8 +127,13 @@ NV_STATUS NV_API_CALL os_lock_user_pages(
mmap_read_lock(current->mm);
#endif
+# if LINUX_VERSION_CODE <= KERNEL_VERSION(4, 19, 0)
ret = NV_GET_USER_PAGES((unsigned long)address,
page_count, write, force, user_pages, NULL);
+#else
+ ret = NV_GET_USER_PAGES((unsigned long)address, (unsigned long)page_count,
+ write, force, user_pages, NULL);
+#endif
#if LINUX_VERSION_CODE <= KERNEL_VERSION(5, 8, 0)
up_read(&mm->mmap_sem);
6da16dc conftest.sh: add conftest for get_user_pages(unsigned long start, unsigned long nr_pages, unsigned int gup_flags, struct page **pages)
diff --git a/conftest.sh b/conftest.sh
index 11088a9..847bd52 100755
--- a/conftest.sh
+++ b/conftest.sh
@@ -2345,18 +2345,17 @@ compile_test() {
$CC $CFLAGS -c conftest$$.c > /dev/null 2>&1
rm -f conftest$$.c
if [ -f conftest$$.o ]; then
- echo "#define NV_GET_USER_PAGES_HAS_WRITE_AND_FORCE_ARGS" | append_conftest "functions"
- echo "#undef NV_GET_USER_PAGES_HAS_TASK_STRUCT" | append_conftest "functions"
+ echo "#define NV_GET_USER_PAGES_PRESENT" | append_conftest "functions"
+ echo "#define NV_GET_USER_PAGES_HAS_WRITE_AND_FORCE" | append_conftest "functions"
+ echo "#define NV_GET_USER_PAGES_HAS_VMAS" | append_conftest "functions"
rm -f conftest$$.o
return
fi
-
# Conftest #2: Check if get_user_pages has gup_flags instead of
# write and force parameters. And that gup doesn't accept a
# task_struct and mm_struct as its first arguments.
# Return if available.
# Fall through to conftest #3 on failure.
-
echo "$CONFTEST_PREAMBLE
#include <linux/mm.h>
long get_user_pages(unsigned long start,
@@ -2371,12 +2370,12 @@ compile_test() {
rm -f conftest$$.c
if [ -f conftest$$.o ]; then
- echo "#undef NV_GET_USER_PAGES_HAS_WRITE_AND_FORCE_ARGS" | append_conftest "functions"
- echo "#undef NV_GET_USER_PAGES_HAS_TASK_STRUCT" | append_conftest "functions"
+ echo "#define NV_GET_USER_PAGES_PRESENT" | append_conftest "functions"
+ echo "#define NV_GET_USER_PAGES_HAS_GUP_FLAGS" | append_conftest "functions"
+ echo "#define NV_GET_USER_PAGES_HAS_VMAS" | append_conftest "functions"
rm -f conftest$$.o
return
fi
-
# Conftest #3: Check if get_user_pages has gup_flags instead of
# write and force parameters AND that gup has task_struct and
# mm_struct as its first arguments.
@@ -2399,16 +2398,40 @@ compile_test() {
rm -f conftest$$.c
if [ -f conftest$$.o ]; then
- echo "#undef NV_GET_USER_PAGES_HAS_WRITE_AND_FORCE_ARGS" | append_conftest "functions"
+ echo "#define NV_GET_USER_PAGES_PRESENT" | append_conftest "functions"
+ echo "#define NV_GET_USER_PAGES_HAS_GUP_FLAGS" | append_conftest "functions"
echo "#define NV_GET_USER_PAGES_HAS_TASK_STRUCT" | append_conftest "functions"
+ echo "#define NV_GET_USER_PAGES_HAS_VMAS" | append_conftest "functions"
+ echo "#define NV_GET_USER_PAGES_HAS_MM_STRUCT" | append_conftest "functions"
rm -f conftest$$.o
return
fi
+ # Conftest #4: Check if get_user_pages has gup_flags instead of
+ # write and force parameters. And that gup doesn't accept a
+ # task_struct, mm_struct and vm_area_struct.
+ # Return if available.
+ # Fall through to conftest #3 on failure.
+
+ echo "$CONFTEST_PREAMBLE
+ #include <linux/mm.h>
+ long get_user_pages(unsigned long start,
+ unsigned long nr_pages,
+ unsigned int gup_flags,
+ struct page **pages) {
+ return 0;
+ }" > conftest$$.c
- echo "#define NV_GET_USER_PAGES_HAS_WRITE_AND_FORCE_ARGS" | append_conftest "functions"
- echo "#define NV_GET_USER_PAGES_HAS_TASK_STRUCT" | append_conftest "functions"
+ $CC $CFLAGS -c conftest$$.c > /dev/null 2>&1
+ rm -f conftest$$.c
- return
+ if [ -f conftest$$.o ]; then
+ echo "#define NV_GET_USER_PAGES_PRESENT" | append_conftest "functions"
+ echo "#define NV_GET_USER_PAGES_HAS_GUP_FLAGS" | append_conftest "functions"
+ rm -f conftest$$.o
+ return
+ else
+ echo "#undef NV_GET_USER_PAGES_PRESENT" | append_conftest "functions"
+ fi
;;
get_user_pages_remote)
80c7d14 nvidia/nvidia.Kbuild, nvidia-drm/nvidia-drm.Kbuild, nvidia-uvm/nvidia-uvm.Kbuild: run get_user_pages{,_remote} function tests only once
diff --git a/nvidia-drm/nvidia-drm.Kbuild b/nvidia-drm/nvidia-drm.Kbuild
index 921deea..16956f8 100644
--- a/nvidia-drm/nvidia-drm.Kbuild
+++ b/nvidia-drm/nvidia-drm.Kbuild
@@ -54,8 +54,6 @@ NV_CONFTEST_GENERIC_COMPILE_TESTS += is_export_symbol_gpl_refcount_dec_and_test
NV_CONFTEST_FUNCTION_COMPILE_TESTS += drm_dev_unref
NV_CONFTEST_FUNCTION_COMPILE_TESTS += drm_reinit_primary_mode_group
-NV_CONFTEST_FUNCTION_COMPILE_TESTS += get_user_pages_remote
-NV_CONFTEST_FUNCTION_COMPILE_TESTS += get_user_pages
NV_CONFTEST_FUNCTION_COMPILE_TESTS += drm_gem_object_lookup
NV_CONFTEST_FUNCTION_COMPILE_TESTS += drm_atomic_state_ref_counting
NV_CONFTEST_FUNCTION_COMPILE_TESTS += drm_driver_has_gem_prime_res_obj
diff --git a/nvidia-uvm/nvidia-uvm.Kbuild b/nvidia-uvm/nvidia-uvm.Kbuild
index cee9fb9..c7fe851 100644
--- a/nvidia-uvm/nvidia-uvm.Kbuild
+++ b/nvidia-uvm/nvidia-uvm.Kbuild
@@ -97,8 +97,6 @@ NV_CONFTEST_TYPE_COMPILE_TESTS += kuid_t
NV_CONFTEST_TYPE_COMPILE_TESTS += address_space
NV_CONFTEST_TYPE_COMPILE_TESTS += backing_dev_info
NV_CONFTEST_TYPE_COMPILE_TESTS += mm_context_t
-NV_CONFTEST_TYPE_COMPILE_TESTS += get_user_pages_remote
-NV_CONFTEST_TYPE_COMPILE_TESTS += get_user_pages
NV_CONFTEST_TYPE_COMPILE_TESTS += vm_fault_has_address
NV_CONFTEST_TYPE_COMPILE_TESTS += vm_ops_fault_removed_vma_arg
NV_CONFTEST_TYPE_COMPILE_TESTS += node_states_n_memory
diff --git a/nvidia/nvidia.Kbuild b/nvidia/nvidia.Kbuild
index 87e13ee..a61d57d 100644
--- a/nvidia/nvidia.Kbuild
+++ b/nvidia/nvidia.Kbuild
@@ -96,6 +96,8 @@ $(obj)/$(NVIDIA_INTERFACE): $(addprefix $(obj)/,$(NVIDIA_OBJECTS))
NV_OBJECTS_DEPEND_ON_CONFTEST += $(NVIDIA_OBJECTS)
+NV_CONFTEST_FUNCTION_COMPILE_TESTS += get_user_pages
+NV_CONFTEST_FUNCTION_COMPILE_TESTS += get_user_pages_remote
NV_CONFTEST_FUNCTION_COMPILE_TESTS += hash__remap_4k_pfn
NV_CONFTEST_FUNCTION_COMPILE_TESTS += set_pages_uc
NV_CONFTEST_FUNCTION_COMPILE_TESTS += list_is_first
@@ -169,6 +171,4 @@ NV_CONFTEST_GENERIC_COMPILE_TESTS += dom0_kernel_present
NV_CONFTEST_GENERIC_COMPILE_TESTS += nvidia_vgpu_hyperv_available
NV_CONFTEST_GENERIC_COMPILE_TESTS += nvidia_vgpu_kvm_build
NV_CONFTEST_GENERIC_COMPILE_TESTS += nvidia_grid_build
-NV_CONFTEST_GENERIC_COMPILE_TESTS += get_user_pages
-NV_CONFTEST_GENERIC_COMPILE_TESTS += get_user_pages_remote
NV_CONFTEST_GENERIC_COMPILE_TESTS += pm_runtime_available
ec3598b common/inc/nv-mm.h: undo changes on get_user_pages{,_remote}() test made by 6aa3b07
diff --git a/common/inc/nv-mm.h b/common/inc/nv-mm.h
index c206cdf..290f2c9 100644
--- a/common/inc/nv-mm.h
+++ b/common/inc/nv-mm.h
@@ -29,10 +29,156 @@
typedef int vm_fault_t;
#endif
-#if defined(NV_GET_USER_PAGES_PRESENT) || defined(NV_GET_USER_PAGES_REMOTE_PRESENT)
-#include <linux/mm.h>
+/* get_user_pages
+ *
+ * The 8-argument version of get_user_pages was deprecated by commit
+ * (2016 Feb 12: cde70140fed8429acf7a14e2e2cbd3e329036653)for the non-remote case
+ * (calling get_user_pages with current and current->mm).
+ *
+ * Completely moved to the 6 argument version of get_user_pages -
+ * 2016 Apr 4: c12d2da56d0e07d230968ee2305aaa86b93a6832
+ *
+ * write and force parameters were replaced with gup_flags by -
+ * 2016 Oct 12: 768ae309a96103ed02eb1e111e838c87854d8b51
+ *
+ * A 7-argument version of get_user_pages was introduced into linux-4.4.y by
+ * commit 8e50b8b07f462ab4b91bc1491b1c91bd75e4ad40 which cherry-picked the
+ * replacement of the write and force parameters with gup_flags
+ *
+ */
+
+#if defined(NV_GET_USER_PAGES_HAS_TASK_STRUCT)
+ #if defined(NV_GET_USER_PAGES_HAS_WRITE_AND_FORCE_ARGS)
+ #define NV_GET_USER_PAGES(start, nr_pages, write, force, pages, vmas) \
+ get_user_pages(current, current->mm, start, nr_pages, write, force, pages, vmas)
+ #else
+ #include <linux/mm.h>
+ #include <linux/sched.h>
+
+ static inline long NV_GET_USER_PAGES(unsigned long start,
+ unsigned long nr_pages,
+ int write,
+ int force,
+ struct page **pages,
+ struct vm_area_struct **vmas)
+ {
+ unsigned int flags = 0;
+
+ if (write)
+ flags |= FOLL_WRITE;
+ if (force)
+ flags |= FOLL_FORCE;
+
+ return get_user_pages(current, current->mm, start, nr_pages, flags,
+ pages, vmas);
+ }
+ #endif
+#else
+ #if defined(NV_GET_USER_PAGES_HAS_WRITE_AND_FORCE_ARGS)
+ #define NV_GET_USER_PAGES get_user_pages
+ #else
+ #include <linux/mm.h>
+
+ static inline long NV_GET_USER_PAGES(unsigned long start,
+ unsigned long nr_pages,
+ int write,
+ int force,
+ struct page **pages,
+ struct vm_area_struct **vmas)
+ {
+ unsigned int flags = 0;
+
+ if (write)
+ flags |= FOLL_WRITE;
+ if (force)
+ flags |= FOLL_FORCE;
+
+ return get_user_pages(start, nr_pages, flags, pages, vmas);
+ }
+ #endif
+#endif
+
+/* get_user_pages_remote() was added by:
+ * 2016 Feb 12: 1e9877902dc7e11d2be038371c6fbf2dfcd469d7
+ *
+ * The very next commit (cde70140fed8429acf7a14e2e2cbd3e329036653)
+ * deprecated the 8-argument version of get_user_pages for the
+ * non-remote case (calling get_user_pages with current and current->mm).
+ *
+ * The guidelines are: call NV_GET_USER_PAGES_REMOTE if you need the 8-argument
+ * version that uses something other than current and current->mm. Use
+ * NV_GET_USER_PAGES if you are refering to current and current->mm.
+ *
+ * Note that get_user_pages_remote() requires the caller to hold a reference on
+ * the task_struct (if non-NULL) and the mm_struct. This will always be true
+ * when using current and current->mm. If the kernel passes the driver a vma
+ * via driver callback, the kernel holds a reference on vma->vm_mm over that
+ * callback.
+ *
+ * get_user_pages_remote() added 'locked' parameter
+ * 2016 Dec 14:5b56d49fc31dbb0487e14ead790fc81ca9fb2c99
+ */
+
+#if defined(NV_GET_USER_PAGES_REMOTE_PRESENT)
+ #if defined(NV_GET_USER_PAGES_REMOTE_HAS_WRITE_AND_FORCE_ARGS)
+ #define NV_GET_USER_PAGES_REMOTE get_user_pages_remote
+ #else
+ static inline long NV_GET_USER_PAGES_REMOTE(struct task_struct *tsk,
+ struct mm_struct *mm,
+ unsigned long start,
+ unsigned long nr_pages,
+ int write,
+ int force,
+ struct page **pages,
+ struct vm_area_struct **vmas)
+ {
+ unsigned int flags = 0;
+
+ if (write)
+ flags |= FOLL_WRITE;
+ if (force)
+ flags |= FOLL_FORCE;
+
+ #if defined(NV_GET_USER_PAGES_REMOTE_HAS_LOCKED_ARG)
+
+ return get_user_pages_remote(tsk, mm, start, nr_pages, flags,
+ pages, vmas, NULL);
+
+ #else
+
+ return get_user_pages_remote(tsk, mm, start, nr_pages, flags,
+ pages, vmas);
+
+ #endif
+
+ }
+ #endif
#else
-#error Unknown function get_user_pages or get_user_pages_remote
+ #if defined(NV_GET_USER_PAGES_HAS_WRITE_AND_FORCE_ARGS)
+ #define NV_GET_USER_PAGES_REMOTE get_user_pages
+ #else
+ #include <linux/mm.h>
+ #include <linux/sched.h>
+
+ static inline long NV_GET_USER_PAGES_REMOTE(struct task_struct *tsk,
+ struct mm_struct *mm,
+ unsigned long start,
+ unsigned long nr_pages,
+ int write,
+ int force,
+ struct page **pages,
+ struct vm_area_struct **vmas)
+ {
+ unsigned int flags = 0;
+
+ if (write)
+ flags |= FOLL_WRITE;
+ if (force)
+ flags |= FOLL_FORCE;
+
+ return get_user_pages(tsk, mm, start, nr_pages, flags, pages, vmas);
+ }
+ #endif
#endif
/*
58451c9 conftest.sh : undo changes on get_user_pages{,_remote}() test made by 3a5fd9d
diff --git a/conftest.sh b/conftest.sh
index 8d2f64b..11088a9 100755
--- a/conftest.sh
+++ b/conftest.sh
@@ -2303,69 +2303,208 @@ compile_test() {
return
fi
;;
+
get_user_pages)
#
- # Determine if the function get_user_pages() is present
+ # Conftest for get_user_pages()
+ #
+ # Use long type for get_user_pages and unsigned long for nr_pages
+ # by commit 28a35716d317 ("mm: use long type for page counts
+ # in mm_populate() and get_user_pages()") in v3.9 (2013-02-22)
+ #
+ # Removed struct task_struct *tsk & struct mm_struct *mm from
+ # get_user_pages by commit cde70140fed8 ("mm/gup: Overload
+ # get_user_pages() functions") in v4.6 (2016-02-12)
+ #
+ # Replaced get_user_pages6 with get_user_pages by commit
+ # c12d2da56d0e ("mm/gup: Remove the macro overload API migration
+ # helpers from the get_user*() APIs") in v4.6 (2016-04-04)
+ #
+ # Replaced write and force parameters with gup_flags by
+ # commit 768ae309a961 ("mm: replace get_user_pages() write/force
+ # parameters with gup_flags") in v4.9 (2016-10-13)
+ #
+ # linux-4.4.168 cherry-picked commit 768ae309a961 without
+ # c12d2da56d0e which is covered in Conftest #3.
+ #
+ # Conftest #1: Check if get_user_pages accepts 6 arguments.
+ # Return if true.
+ # Fall through to conftest #2 on failure.
#
echo "$CONFTEST_PREAMBLE
- #include <linux/version.h>
#include <linux/mm.h>
- int conftest_get_user_pages(void) {
- #if LINUX_VERSION_CODE < KERNEL_VERSION(3, 0, 0)
- long get_user_pages(unsigned long start, unsigned long nr_pages, int write, int force, struct page **pages,
- struct vm_area_struct **vmas);
- #elif LINUX_VERSION_CODE < KERNEL_VERSION(5, 0, 0)
- long get_user_pages(unsigned long start, int nr_pages, int write, struct page **pages, stuct mv_area_struct **vmas);
- #elif LINUX_VERSION_CODE >= KERNEL_VERSION(5, 0, 0)
- long get_user_pages(unsigned long start, unsigned long nr_pages, unsigned int gup_flags, struct page **pages);
- #endif
+ long get_user_pages(unsigned long start,
+ unsigned long nr_pages,
+ int write,
+ int force,
+ struct page **pages,
+ struct vm_area_struct **vmas) {
return 0;
}" > conftest$$.c
$CC $CFLAGS -c conftest$$.c > /dev/null 2>&1
rm -f conftest$$.c
if [ -f conftest$$.o ]; then
- echo "#define NV_GET_USER_PAGES_PRESENT" | append_conftest "functions"
+ echo "#define NV_GET_USER_PAGES_HAS_WRITE_AND_FORCE_ARGS" | append_conftest "functions"
+ echo "#undef NV_GET_USER_PAGES_HAS_TASK_STRUCT" | append_conftest "functions"
rm -f conftest$$.o
return
- else
- echo "#undef NV_GET_USER_PAGES_PRESENT" | append_conftest "functions"
fi
+
+ # Conftest #2: Check if get_user_pages has gup_flags instead of
+ # write and force parameters. And that gup doesn't accept a
+ # task_struct and mm_struct as its first arguments.
+ # Return if available.
+ # Fall through to conftest #3 on failure.
+
+ echo "$CONFTEST_PREAMBLE
+ #include <linux/mm.h>
+ long get_user_pages(unsigned long start,
+ unsigned long nr_pages,
+ unsigned int gup_flags,
+ struct page **pages,
+ struct vm_area_struct **vmas) {
+ return 0;
+ }" > conftest$$.c
+
+ $CC $CFLAGS -c conftest$$.c > /dev/null 2>&1
+ rm -f conftest$$.c
+
+ if [ -f conftest$$.o ]; then
+ echo "#undef NV_GET_USER_PAGES_HAS_WRITE_AND_FORCE_ARGS" | append_conftest "functions"
+ echo "#undef NV_GET_USER_PAGES_HAS_TASK_STRUCT" | append_conftest "functions"
+ rm -f conftest$$.o
+ return
+ fi
+
+ # Conftest #3: Check if get_user_pages has gup_flags instead of
+ # write and force parameters AND that gup has task_struct and
+ # mm_struct as its first arguments.
+ # Return if available.
+ # Fall through to default case if absent.
+
+ echo "$CONFTEST_PREAMBLE
+ #include <linux/mm.h>
+ long get_user_pages(struct task_struct *tsk,
+ struct mm_struct *mm,
+ unsigned long start,
+ unsigned long nr_pages,
+ unsigned int gup_flags,
+ struct page **pages,
+ struct vm_area_struct **vmas) {
+ return 0;
+ }" > conftest$$.c
+
+ $CC $CFLAGS -c conftest$$.c > /dev/null 2>&1
+ rm -f conftest$$.c
+
+ if [ -f conftest$$.o ]; then
+ echo "#undef NV_GET_USER_PAGES_HAS_WRITE_AND_FORCE_ARGS" | append_conftest "functions"
+ echo "#define NV_GET_USER_PAGES_HAS_TASK_STRUCT" | append_conftest "functions"
+ rm -f conftest$$.o
+ return
+ fi
+
+ echo "#define NV_GET_USER_PAGES_HAS_WRITE_AND_FORCE_ARGS" | append_conftest "functions"
+ echo "#define NV_GET_USER_PAGES_HAS_TASK_STRUCT" | append_conftest "functions"
+
+ return
;;
get_user_pages_remote)
#
- # Determine if the function get_user_pages_remote() is present
+ # Determine if the function get_user_pages_remote() is
+ # present and has write/force parameters.
+ #
+ # get_user_pages_remote() was added by commit 1e9877902dc7
+ # ("mm/gup: Introduce get_user_pages_remote()") in v4.6 (2016-02-12)
+ #
+ # get_user_pages[_remote]() write/force parameters
+ # replaced with gup_flags by commits 768ae309a961 ("mm: replace
+ # get_user_pages() write/force parameters with gup_flags") and
+ # commit 9beae1ea8930 ("mm: replace get_user_pages_remote()
+ # write/force parameters with gup_flags") in v4.9 (2016-10-13)
+ #
+ # get_user_pages_remote() added 'locked' parameter by
+ # commit 5b56d49fc31d ("mm: add locked parameter to
+ # get_user_pages_remote()") in v4.10 (2016-12-14)
#
+ # conftest #1: check if get_user_pages_remote() is available
+ # return if not available.
+ # Fall through to conftest #2 if it is present
+ #
+ echo "$CONFTEST_PREAMBLE
+ #include <linux/mm.h>
+ void conftest_get_user_pages_remote(void) {
+ get_user_pages_remote();
+ }" > conftest$$.c
+ $CC $CFLAGS -c conftest$$.c > /dev/null 2>&1
+ rm -f conftest$$.c
+
+ if [ -f conftest$$.o ]; then
+ echo "#undef NV_GET_USER_PAGES_REMOTE_PRESENT" | append_conftest "functions"
+ echo "#undef NV_GET_USER_PAGES_REMOTE_HAS_WRITE_AND_FORCE_ARGS" | append_conftest "functions"
+ echo "#undef NV_GET_USER_PAGES_REMOTE_HAS_LOCKED_ARG" | append_conftest "functions"
+ rm -f conftest$$.o
+ return
+ fi
+
+ #
+ # conftest #2: check if get_user_pages_remote() has write and
+ # force arguments. Return if these arguments are present
+ # Fall through to conftest #3 if these args are absent.
+ #
+ echo "#define NV_GET_USER_PAGES_REMOTE_PRESENT" | append_conftest "functions"
echo "$CONFTEST_PREAMBLE
- #include <linux/version.h>
#include <linux/mm.h>
- int conftest_get_user_pages_remote(void) {
- #if LINUX_VERSION_CODE <= KERNEL_VERSION(4, 6, 0)
- long get_user_pages_remote(struct task_struct *tsk, struct mm_struct *mm, unsigned long start,
- unsigned long nr_pages, int write, int force, struct page **pages,
- struct vm_area_struct **vmas);
- #elif LINUX_VERSION_CODE < KERNEL_VERSION(6, 0, 0)
- int get_user_pages_remote(struct task_struct *task, unsigned long start, unsigned long nr_pages,
- int write, struct page **pages, struct mm_struct **mm);
- #elif LINUX_VERSION_CODE >= KERNEL_VERSION(6, 0, 0)
- long get_user_pages_remote(struct mm_struct *mm, unsigned long start, unsigned long nr_pages,
- unsigned int gup_flags, struct page **pages, int *locked);
- #endif
- return 0;
+ long get_user_pages_remote(struct task_struct *tsk,
+ struct mm_struct *mm,
+ unsigned long start,
+ unsigned long nr_pages,
+ int write,
+ int force,
+ struct page **pages,
+ struct vm_area_struct **vmas) {
+ return 0;
}" > conftest$$.c
$CC $CFLAGS -c conftest$$.c > /dev/null 2>&1
rm -f conftest$$.c
if [ -f conftest$$.o ]; then
- echo "#define NV_GET_USER_PAGES_REMOTE_PRESENT" | append_conftest "functions"
+ echo "#define NV_GET_USER_PAGES_REMOTE_HAS_WRITE_AND_FORCE_ARGS" | append_conftest "functions"
+ echo "#undef NV_GET_USER_PAGES_REMOTE_HAS_LOCKED_ARG" | append_conftest "functions"
rm -f conftest$$.o
return
+ fi
+
+ # conftest #3: check if get_user_pages_remote() has locked argument
+
+ echo "$CONFTEST_PREAMBLE
+ #include <linux/mm.h>
+ long get_user_pages_remote(struct task_struct *tsk,
+ struct mm_struct *mm,
+ unsigned long start,
+ unsigned long nr_pages,
+ unsigned int gup_flags,
+ struct page **pages,
+ struct vm_area_struct **vmas,
+ int *locked) {
+ return 0;
+ }" > conftest$$.c
+
+ $CC $CFLAGS -c conftest$$.c > /dev/null 2>&1
+ rm -f conftest$$.c
+
+ if [ -f conftest$$.o ]; then
+ echo "#define NV_GET_USER_PAGES_REMOTE_HAS_LOCKED_ARG" | append_conftest "functions"
+ rm -f conftest$$.o
else
- echo "#undef NV_GET_USER_PAGES_REMOTE_PRESENT" | append_conftest "functions"
+ echo "#undef NV_GET_USER_PAGES_REMOTE_HAS_LOCKED_ARG" | append_conftest "functions"
fi
+ echo "#undef NV_GET_USER_PAGES_REMOTE_HAS_WRITE_AND_FORCE_ARGS" | append_conftest "functions"
+
;;
usleep_range)
fd455fd common/inc/nv-time.h, nvidia/os-interface.c: initialize nv_timeval_t variables
diff --git a/common/inc/nv-time.h b/common/inc/nv-time.h
index ee8bf03..28da895 100644
--- a/common/inc/nv-time.h
+++ b/common/inc/nv-time.h
@@ -50,7 +50,7 @@ struct nv_timeval_t {
};
static inline void nv_gettimeofday(struct nv_timeval_t *tv) {
- struct timespec64 *now;
+ struct timespec64 *now = { 0 };
ktime_get_real_ts64(now);
tv -> tv_sec = now -> tv_sec;
diff --git a/nvidia/os-interface.c b/nvidia/os-interface.c
index e4112b0..f7f1996 100644
--- a/nvidia/os-interface.c
+++ b/nvidia/os-interface.c
@@ -464,9 +464,9 @@ NV_STATUS NV_API_CALL os_get_current_time(
)
{
#if LINUX_VERSION_CODE <= KERNEL_VERSION(4, 0, 0)
- struct timeval *tm;
+ struct timeval *tm = { 0 };
#else
- struct nv_timeval_t *tm;
+ struct nv_timeval_t *tm = { 0 };
#endif
nv_gettimeofday(tm);
@@ -482,7 +482,7 @@ NV_STATUS NV_API_CALL os_get_current_time(
void NV_API_CALL os_get_current_tick(NvU64 *nseconds)
{
#if defined(NVCPU_X86_64)
- struct timespec64 *ts;
+ struct timespec64 *ts = { 0 };
jiffies_to_timespec64(jiffies, ts);
#else
@@ -605,16 +605,16 @@ NV_STATUS NV_API_CALL os_delay(NvU32 MilliSeconds)
unsigned long jiffies;
unsigned long mdelay_safe_msec;
#if LINUX_VERSION_CODE <= KERNEL_VERSION(4, 0, 0)
- struct timeval *tm_end, *tm_aux;
+ struct timeval *tm_end = { 0 }, *tm_aux = { 0 };
#else
- struct nv_timeval_t *tm_end, *tm_aux;
+ struct nv_timeval_t *tm_end = { 0 }, *tm_aux = { 0 };
#endif /* LINUX_VERSION_CODE <= KERNEL_VERSION(4, 0, 0) */
#ifdef NV_CHECK_DELAY_ACCURACY
#if LINUX_VERSION_CODE <= KERNEL_VERSION(4, 0, 0)
- struct timeval *tm_start;
+ struct timeval *tm_start = { 0 };
#else
- struct nv_timeval_t *tm_start;
+ struct nv_timeval_t *tm_start = { 0 );
#endif /* LINUX_VERSION_CODE <= KERNEL_VERSION(4, 0, 0) */
#endif
0b41134 common/inc/nv-linux.h: work-around for broken efi_get_secureboot_mode()
diff --git a/common/inc/nv-linux.h b/common/inc/nv-linux.h
index e307589..f854e3e 100644
--- a/common/inc/nv-linux.h
+++ b/common/inc/nv-linux.h
@@ -207,6 +207,7 @@ static inline uid_t __kuid_val(uid_t uid)
#include <asm-generic/pci-dma-compat.h>
#endif
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(6, 15, 0)
#if defined(NV_EFI_ENABLED_PRESENT) && defined(NV_EFI_ENABLED_ARGUMENT_COUNT)
#if (NV_EFI_ENABLED_ARGUMENT_COUNT == 1)
#define NV_EFI_ENABLED() efi_enabled(EFI_BOOT)
@@ -218,6 +219,11 @@ static inline uid_t __kuid_val(uid_t uid)
#else
#define NV_EFI_ENABLED() 0
#endif
+#else /* LINUX_VERSION_CODE <= KERNEL_VERSION(6, 15, 0) */
+#if defined(CONFIG_EFI)
+#define NV_EFI_ENABLED() 1
+#endif
+#endif /* LINUX_VERSION_CODE <= KERNEL_VERSION(6, 15, 0) */
#if defined(CONFIG_CRAY_XT)
#include <cray/cray_nvidia.h>
3a98074 nvidia/os-interface.c: use set_current_state(TASK_INTERRUPTIBLE)
diff --git a/nvidia/os-interface.c b/nvidia/os-interface.c
index 08ed079..e4112b0 100644
--- a/nvidia/os-interface.c
+++ b/nvidia/os-interface.c
@@ -648,7 +648,11 @@ NV_STATUS NV_API_CALL os_delay(NvU32 MilliSeconds)
// the requested timeout has expired, loop until less
// than a jiffie of the desired delay remains.
//
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(4, 0, 0)
current->state = TASK_INTERRUPTIBLE;
+#else
+ set_current_state(TASK_INTERRUPTIBLE);
+#endif
do
{
schedule_timeout(jiffies);
3b98bcf common/inc/nv-linux.h: fix macros NV_EFI_ENABLED
diff --git a/common/inc/nv-linux.h b/common/inc/nv-linux.h
index 60989ae..e307589 100644
--- a/common/inc/nv-linux.h
+++ b/common/inc/nv-linux.h
@@ -214,7 +214,7 @@ static inline uid_t __kuid_val(uid_t uid)
#error "NV_EFI_ENABLED_ARGUMENT_COUNT value unrecognized!"
#endif
#elif (defined(NV_EFI_ENABLED_PRESENT) || defined(efi_enabled))
-#define NV_EFI_ENABLED() efi_enabled
+#define NV_EFI_ENABLED() efi_enabled()
#else
#define NV_EFI_ENABLED() 0
#endif
b4992b4 nvidia/os-interface.{c,h}: fixes about timeval, nv_timeval_t and its companions
diff --git a/common/inc/os-interface.h b/common/inc/os-interface.h
index f7d2034..2e727bd 100644
--- a/common/inc/os-interface.h
+++ b/common/inc/os-interface.h
@@ -68,7 +68,11 @@ NvU8 NV_API_CALL os_get_page_shift (void);
NvU64 NV_API_CALL os_get_num_phys_pages (void);
NV_STATUS NV_API_CALL os_alloc_mem (void **, NvU64);
void NV_API_CALL os_free_mem (void *);
+#if defined(NVCPU_X86_64)
+NV_STATUS NV_API_CALL os_get_current_time (NvU64 *, NvU64 *);
+#else
NV_STATUS NV_API_CALL os_get_current_time (NvU32 *, NvU32 *);
+#endif
void NV_API_CALL os_get_current_tick (NvU64 *);
NvU64 NV_API_CALL os_get_tick_resolution (void);
NV_STATUS NV_API_CALL os_delay (NvU32);
diff --git a/nvidia/os-interface.c b/nvidia/os-interface.c
index e3d1414..08ed079 100644
--- a/nvidia/os-interface.c
+++ b/nvidia/os-interface.c
@@ -454,20 +454,25 @@ void NV_API_CALL os_free_mem(void *address)
*****************************************************************************/
NV_STATUS NV_API_CALL os_get_current_time(
+#if defined(NVCPU_X86_64)
+ NvU64 *seconds,
+ NvU64 *useconds
+#else
NvU32 *seconds,
NvU32 *useconds
+#endif
)
{
#if LINUX_VERSION_CODE <= KERNEL_VERSION(4, 0, 0)
- struct timeval tm;
+ struct timeval *tm;
#else
- struct nv_timeval_t tm;
+ struct nv_timeval_t *tm;
#endif
- nv_gettimeofday(&tm);
+ nv_gettimeofday(tm);
- *seconds = tm.tv_sec;
- *useconds = tm.tv_usec;
+ *seconds = tm -> tv_sec;
+ *useconds = tm -> tv_usec;
return NV_OK;
}
@@ -476,11 +481,17 @@ NV_STATUS NV_API_CALL os_get_current_time(
void NV_API_CALL os_get_current_tick(NvU64 *nseconds)
{
+#if defined(NVCPU_X86_64)
+ struct timespec64 *ts;
+
+ jiffies_to_timespec64(jiffies, ts);
+#else
struct timespec ts;
- jiffies_to_timespec(jiffies, &ts);
+ jiffies_to_timespec(jiffies, ts);
+#endif /* defined(NVCPU_X86_64) */
- *nseconds = ((NvU64)ts.tv_sec * NSEC_PER_SEC + (NvU64)ts.tv_nsec);
+ *nseconds = ((NvU64)(ts -> tv_sec) * NSEC_PER_SEC + (NvU64)(ts -> tv_nsec));
}
NvU64 NV_API_CALL os_get_tick_resolution(void)
@@ -488,7 +499,7 @@ NvU64 NV_API_CALL os_get_tick_resolution(void)
return (NvU64)jiffies_to_usecs(1) * NSEC_PER_USEC;
}
-#else
+#else /* BITS_PER_LONG >= 64 */
void NV_API_CALL os_get_current_tick(NvU64 *nseconds)
{
@@ -504,12 +515,14 @@ void NV_API_CALL os_get_current_tick(NvU64 *nseconds)
* (more than a second or so) while the Resman is actively tracking a
* timeout.
*/
- NvU32 seconds, useconds;
-
- (void) os_get_current_time(&seconds, &useconds);
+#if defined(NVCPU_X86_64)
+ NvU64 *seconds, *useconds;
+#else
+ NvU32 *seconds, *useconds;
+#endif
+ (void) os_get_current_time(seconds, useconds);
- *nseconds = ((NvU64)seconds * NSEC_PER_SEC +
- (NvU64)useconds * NSEC_PER_USEC);
+ *nseconds = (*seconds * NSEC_PER_SEC + *useconds * NSEC_PER_USEC);
}
NvU64 NV_API_CALL os_get_tick_resolution(void)
@@ -521,7 +534,7 @@ NvU64 NV_API_CALL os_get_tick_resolution(void)
return 1000ULL;
}
-#endif
+#endif /* BITS_PER_LONG >= 64 */
//---------------------------------------------------------------------------
//
@@ -549,11 +562,11 @@ NV_STATUS NV_API_CALL os_delay_us(NvU32 MicroSeconds)
#ifdef NV_CHECK_DELAY_ACCURACY
#if LINUX_VERSION_CODE <= KERNEL_VERSION(4, 0, 0)
- struct timeval tm1, tm2;
+ struct timeval *tm1, *tm2;
#else
- struct nv_timeval_t tm1, tm2;
+ struct nv_timeval_t *tm1, *tm2;
#endif /* LINUX_VERSION_CODE <= KERNEL_VERSION(4, 0, 0) */
- nv_gettimeofday(&tm1);
+ nv_gettimeofday(tm1);
#endif /* NV_CHECK_DELAY_ACCURACY */
if (in_irq() && (MicroSeconds > NV_MAX_ISR_DELAY_US))
@@ -568,9 +581,9 @@ NV_STATUS NV_API_CALL os_delay_us(NvU32 MicroSeconds)
udelay(usec);
#ifdef NV_CHECK_DELAY_ACCURACY
- nv_gettimeofday(&tm2);
+ nv_gettimeofday(tm2);
nv_printf(NV_DBG_ERRORS, "NVRM: osDelayUs %d: 0x%x 0x%x\n",
- MicroSeconds, tm2.tv_sec - tm1.tv_sec, tm2.tv_usec - tm1.tv_usec);
+ MicroSeconds, (tm2 -> tv_sec) - (tm1 -> tv_sec), (tm2 -> tv_usec) - (tm1 -> tv_usec));
#endif
return NV_OK;
@@ -591,18 +604,23 @@ NV_STATUS NV_API_CALL os_delay(NvU32 MilliSeconds)
unsigned long MicroSeconds;
unsigned long jiffies;
unsigned long mdelay_safe_msec;
- struct timeval tm_end, tm_aux;
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(4, 0, 0)
+ struct timeval *tm_end, *tm_aux;
+#else
+ struct nv_timeval_t *tm_end, *tm_aux;
+#endif /* LINUX_VERSION_CODE <= KERNEL_VERSION(4, 0, 0) */
+
#ifdef NV_CHECK_DELAY_ACCURACY
#if LINUX_VERSION_CODE <= KERNEL_VERSION(4, 0, 0)
- struct timeval tm_start;
+ struct timeval *tm_start;
#else
- struct nv_timeval_t tm_start;
+ struct nv_timeval_t *tm_start;
#endif /* LINUX_VERSION_CODE <= KERNEL_VERSION(4, 0, 0) */
#endif
- nv_gettimeofday(&tm_aux);
+ nv_gettimeofday(tm_aux);
#ifdef NV_CHECK_DELAY_ACCURACY
- tm_start = tm_aux;
+ *tm_start = *tm_aux;
#endif
if (in_irq() && (MilliSeconds > NV_MAX_ISR_DELAY_MS))
@@ -615,9 +633,9 @@ NV_STATUS NV_API_CALL os_delay(NvU32 MilliSeconds)
}
MicroSeconds = MilliSeconds * 1000;
- tm_end.tv_usec = MicroSeconds;
- tm_end.tv_sec = 0;
- NV_TIMERADD(&tm_aux, &tm_end, &tm_end);
+ tm_end -> tv_usec = MicroSeconds;
+ tm_end -> tv_sec = 0;
+ NV_TIMERADD(tm_aux, tm_end, tm_end);
/* do we have a full jiffie to wait? */
jiffies = NV_USECS_TO_JIFFIES(MicroSeconds);
@@ -634,11 +652,11 @@ NV_STATUS NV_API_CALL os_delay(NvU32 MilliSeconds)
do
{
schedule_timeout(jiffies);
- nv_gettimeofday(&tm_aux);
- if (NV_TIMERCMP(&tm_aux, &tm_end, <))
+ nv_gettimeofday(tm_aux);
+ if (NV_TIMERCMP(tm_aux, tm_end, <))
{
- NV_TIMERSUB(&tm_end, &tm_aux, &tm_aux);
- MicroSeconds = tm_aux.tv_usec + tm_aux.tv_sec * 1000000;
+ NV_TIMERSUB(tm_end, tm_aux, tm_aux);
+ MicroSeconds = (tm_aux -> tv_usec) + (tm_aux -> tv_sec) * 1000000;
}
else
MicroSeconds = 0;
@@ -656,10 +674,10 @@ NV_STATUS NV_API_CALL os_delay(NvU32 MilliSeconds)
udelay(MicroSeconds);
}
#ifdef NV_CHECK_DELAY_ACCURACY
- nv_gettimeofday(&tm_aux);
- timersub(&tm_aux, &tm_start, &tm_aux);
+ nv_gettimeofday(tm_aux);
+ timersub(tm_aux, tm_start, tm_aux);
nv_printf(NV_DBG_ERRORS, "NVRM: osDelay %dmsec: %d.%06dsec\n",
- MilliSeconds, tm_aux.tv_sec, tm_aux.tv_usec);
+ MilliSeconds, tm_aux -> tv_sec, tm_aux -> tv_usec);
#endif
return NV_OK;
2ea7c3b conftest.sh: fix acquire_console_sem and console_lock tests to be correct
diff --git a/conftest.sh b/conftest.sh
index e53b8f5..8d2f64b 100755
--- a/conftest.sh
+++ b/conftest.sh
@@ -652,13 +652,21 @@ compile_test() {
# ("console: rename acquire/release_console_sem() to
# console_lock/unlock()") in v2.6.38
#
- CODE="
+ echo "$CONFTEST_PREAMBLE
#include <linux/console.h>
void conftest_acquire_console_sem(void) {
- acquire_console_sem(NULL);
- }"
+ acquire_console_sem();
+ }" > conftest$$.c
- compile_check_conftest "$CODE" "NV_ACQUIRE_CONSOLE_SEM_PRESENT" "" "functions"
+ $CC $CFLAGS -c conftest$$.c > /dev/null 2>&1
+ rm -f conftest$$.c
+ if [ -f conftest$$.o ]; then
+ rm -f conftest$$.o
+ echo "#define NV_ACQUIRE_CONSOLE_SEM_PRESENT" | append_conftest "functions"
+ return
+ else
+ echo "#undef NV_ACQUIRE_CONSOLE_SEM_PRESENT" | append_conftest "functions"
+ fi
;;
console_lock)
@@ -669,13 +677,21 @@ compile_test() {
# acquire/release_console_sem() to console_lock/unlock()") in
# v2.6.38. Function was renamed from acquire_console_sem()
#
- CODE="
+ echo "$CONFTEST_PREAMBLE
#include <linux/console.h>
void conftest_console_lock(void) {
- console_lock(NULL);
- }"
+ console_lock();
+ }" > conftest$$.c
- compile_check_conftest "$CODE" "NV_CONSOLE_LOCK_PRESENT" "" "functions"
+ $CC $CFLAGS -c conftest$$.c > /dev/null 2>&1
+ rm -f conftest$$.c
+ if [ -f conftest$$.o ]; then
+ rm conftest$$.o
+ echo "#define NV_CONSOLE_LOCK_PRESENT" | append_conftest "functions"
+ return
+ else
+ echo "undef NV_CONSOLE_LOCK_PRESENT" | append_conftest "functions"
+ fi
;;
register_cpu_notifier)
b63843d nvidia/os-mlock.c: switch from {up,down}_read() to mmap_read_{lock,unlock}()
diff --git a/nvidia/os-mlock.c b/nvidia/os-mlock.c
index 1900fa1..60fe26c 100644
--- a/nvidia/os-mlock.c
+++ b/nvidia/os-mlock.c
@@ -13,6 +13,7 @@
#include "os-interface.h"
#include "nv-linux.h"
+#include <linux/version.h>
NV_STATUS NV_API_CALL os_lookup_user_io_memory(
void *address,
@@ -43,8 +44,11 @@ NV_STATUS NV_API_CALL os_lookup_user_io_memory(
return rmStatus;
}
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(5, 8, 0)
down_read(&mm->mmap_sem);
-
+#else
+ mmap_read_lock(current->mm);
+#endif
vma = find_vma(mm, (NvUPtr)address);
if ((vma == NULL) || ((vma->vm_flags & (VM_IO | VM_PFNMAP)) == 0))
{
@@ -76,8 +80,11 @@ NV_STATUS NV_API_CALL os_lookup_user_io_memory(
}
done:
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(5, 8, 0)
up_read(&mm->mmap_sem);
-
+#else
+ mmap_read_unlock(current -> mm);
+#endif
return rmStatus;
}
@@ -110,10 +117,21 @@ NV_STATUS NV_API_CALL os_lock_user_pages(
return rmStatus;
}
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(5, 8, 0)
down_read(&mm->mmap_sem);
+#else
+ mmap_read_lock(current->mm);
+#endif
+
ret = NV_GET_USER_PAGES((unsigned long)address,
page_count, write, force, user_pages, NULL);
+
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(5, 8, 0)
up_read(&mm->mmap_sem);
+#else
+ mmap_read_unlock(current -> mm);
+#endif
+
pinned = ret;
if (ret < 0)
0860923 common/inc/nv-time.h, nvidia-modeset/nvidia-modeset-linux.c, nvidia-uvm/uvm_linux.h, nvidia/nvlink_linux.c, nvidia/os-interface.c: switch to nv_timeval_t
diff --git a/common/inc/nv-time.h b/common/inc/nv-time.h
index 968b873..ee8bf03 100644
--- a/common/inc/nv-time.h
+++ b/common/inc/nv-time.h
@@ -24,9 +24,10 @@
#define __NV_TIME_H__
#include "conftest.h"
-
#include <linux/ktime.h>
+#include <linux/version.h>
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(4, 0, 0)
static inline void nv_gettimeofday(struct timeval *tv)
{
#ifdef NV_DO_GETTIMEOFDAY_PRESENT
@@ -42,5 +43,19 @@ static inline void nv_gettimeofday(struct timeval *tv)
};
#endif // NV_DO_GETTIMEOFDAY_PRESENT
}
+#else
+struct nv_timeval_t {
+ time64_t tv_sec;
+ long tv_usec;
+};
+
+static inline void nv_gettimeofday(struct nv_timeval_t *tv) {
+ struct timespec64 *now;
+
+ ktime_get_real_ts64(now);
+ tv -> tv_sec = now -> tv_sec;
+ tv -> tv_usec = now -> tv_nsec / 1000;
+}
+#endif /* LINUX_VERSION_CODE <= KERNEL_VERSION(4. 0, 0) */
#endif // __NV_TIME_H__
diff --git a/nvidia-modeset/nvidia-modeset-linux.c b/nvidia-modeset/nvidia-modeset-linux.c
index 0ca2c7d..9d2efbf 100644
--- a/nvidia-modeset/nvidia-modeset-linux.c
+++ b/nvidia-modeset/nvidia-modeset-linux.c
@@ -21,6 +21,7 @@
#include <linux/file.h>
#include <linux/list.h>
#include <linux/rwsem.h>
+#include <linux/version.h>
#include "nvstatus.h"
@@ -266,8 +267,11 @@ void NVKMS_API_CALL nvkms_usleep(NvU64 usec)
NvU64 NVKMS_API_CALL nvkms_get_usec(void)
{
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(4, 0, 0)
struct timeval tv;
-
+#else
+ struct nv_timeval_t tv;
+#endif
nv_gettimeofday(&tv);
return (((NvU64)tv.tv_sec) * 1000000) + tv.tv_usec;
diff --git a/nvidia-uvm/uvm_linux.h b/nvidia-uvm/uvm_linux.h
index e81fc95..bc7d50d 100644
--- a/nvidia-uvm/uvm_linux.h
+++ b/nvidia-uvm/uvm_linux.h
@@ -47,6 +47,7 @@
#include <linux/prio_tree.h>
#endif
+#include <linux/version.h>
#include <linux/jhash.h>
#include <linux/rwsem.h>
#include <linux/rbtree.h>
@@ -302,7 +303,11 @@ static inline NvU64 NV_GETTIME(void)
* available non-GPL symbols. */
static inline NvU64 NV_GETTIME(void)
{
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(4, 0, 0)
struct timeval tv = {0};
+#else
+ struct nv_timeval_t tv;
+#endif /* LINUX_VERSION_CODE <= KERNEL_VERSION(4, 0, 0) */
nv_gettimeofday(&tv);
diff --git a/nvidia/nvlink_linux.c b/nvidia/nvlink_linux.c
index a5eb280..28fb7ad 100644
--- a/nvidia/nvlink_linux.c
+++ b/nvidia/nvlink_linux.c
@@ -31,6 +31,7 @@
#include "nv-procfs.h"
#include "nv-time.h"
+#include <linux/version.h>
#include <linux/module.h>
#include <linux/major.h>
#include <linux/cdev.h>
@@ -508,8 +509,13 @@ void * NVLINK_API_CALL nvlink_memcpy(void *dest, void *src, NvLength size)
static NvBool nv_timer_less_than
(
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(4, 0, 0)
const struct timeval *a,
const struct timeval *b
+#else
+ const struct nv_timeval_t *a,
+ const struct nv_timeval_t *b
+#endif
)
{
return (a->tv_sec == b->tv_sec) ? (a->tv_usec < b->tv_usec)
@@ -518,9 +524,15 @@ static NvBool nv_timer_less_than
static void nv_timeradd
(
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(4, 0, 0)
const struct timeval *a,
const struct timeval *b,
struct timeval *result
+#else
+ const struct nv_timeval_t *a,
+ const struct nv_timeval_t *b,
+ struct nv_timeval_t *result
+#endif
)
{
result->tv_sec = a->tv_sec + b->tv_sec;
@@ -534,9 +546,15 @@ static void nv_timeradd
static void nv_timersub
(
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(4, 0, 0)
const struct timeval *a,
const struct timeval *b,
struct timeval *result
+#else
+ const struct nv_timeval_t *a,
+ const struct nv_timeval_t *b,
+ struct nv_timeval_t *result
+#endif
)
{
result->tv_sec = a->tv_sec - b->tv_sec;
@@ -556,7 +574,11 @@ void NVLINK_API_CALL nvlink_sleep(unsigned int ms)
unsigned long us;
unsigned long jiffies;
unsigned long mdelay_safe_msec;
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(4, 0, 0)
struct timeval tm_end, tm_aux;
+#else
+ struct nv_timeval_t tm_end, tm_aux;
+#endif
nv_gettimeofday(&tm_aux);
diff --git a/nvidia/os-interface.c b/nvidia/os-interface.c
index 9e1771a..e3d1414 100644
--- a/nvidia/os-interface.c
+++ b/nvidia/os-interface.c
@@ -16,7 +16,7 @@
#include "nv-time.h"
-
+#include <linux/version.h>
@@ -458,7 +458,11 @@ NV_STATUS NV_API_CALL os_get_current_time(
NvU32 *useconds
)
{
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(4, 0, 0)
struct timeval tm;
+#else
+ struct nv_timeval_t tm;
+#endif
nv_gettimeofday(&tm);
@@ -544,10 +548,13 @@ NV_STATUS NV_API_CALL os_delay_us(NvU32 MicroSeconds)
unsigned long usec;
#ifdef NV_CHECK_DELAY_ACCURACY
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(4, 0, 0)
struct timeval tm1, tm2;
-
+#else
+ struct nv_timeval_t tm1, tm2;
+#endif /* LINUX_VERSION_CODE <= KERNEL_VERSION(4, 0, 0) */
nv_gettimeofday(&tm1);
-#endif
+#endif /* NV_CHECK_DELAY_ACCURACY */
if (in_irq() && (MicroSeconds > NV_MAX_ISR_DELAY_US))
return NV_ERR_GENERIC;
@@ -586,7 +593,11 @@ NV_STATUS NV_API_CALL os_delay(NvU32 MilliSeconds)
unsigned long mdelay_safe_msec;
struct timeval tm_end, tm_aux;
#ifdef NV_CHECK_DELAY_ACCURACY
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(4, 0, 0)
struct timeval tm_start;
+#else
+ struct nv_timeval_t tm_start;
+#endif /* LINUX_VERSION_CODE <= KERNEL_VERSION(4, 0, 0) */
#endif
nv_gettimeofday(&tm_aux);
@@ -1904,7 +1915,11 @@ static NV_STATUS NV_API_CALL _os_ipmi_receive_resp
{
struct ipmi_recv_msg *rx_msg;
int err_no;
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(4, 0, 0)
struct timeval tv;
+#else
+ struct nv_timeval_t tv;
+#endif
NvU64 start_time;
nv_gettimeofday(&tv);
0d47387 conftest.sh: correct check for gettimeofday() presence
diff --git a/conftest.sh b/conftest.sh
index 291f1d7..e53b8f5 100755
--- a/conftest.sh
+++ b/conftest.sh
@@ -2923,13 +2923,21 @@ compile_test() {
# 97fc79f97b1111c80010d34ee66312b88f531e41 (2006-06-09) in v2.6.16,
# includes linux/time.h and/or linux/timekeeping.h.
#
- CODE="
+ echo "$CONFTEST_PREAMBLE
#include <linux/ktime.h>
void conftest_do_gettimeofday(void) {
do_gettimeofday();
- }"
+ }" > conftest$$.c
- compile_check_conftest "$CODE" "NV_DO_GETTIMEOFDAY_PRESENT" "" "functions"
+ $CC $CFLAGS -c conftest$$.c > /dev/null 2>&1
+ rm conftest$$.c
+ if [ -f conftest$$.o ]; then
+ rm -f conftest$$.o
+ echo "#define NV_DO_GETTIMEOFDAY_PRESENT" | append_conftest "functions"
+ return
+ else
+ echo "#undef NV_DO_GETTIMEOFDAY_PRESENT" | append_conftest "functions"
+ fi
;;
drm_framebuffer_get)
2ec1bfe conftest.sh: do a correct test for set_memory_array_uc() presence
diff --git a/conftest.sh b/conftest.sh
index 280d3dd..291f1d7 100755
--- a/conftest.sh
+++ b/conftest.sh
@@ -430,17 +430,24 @@ compile_test() {
# Determine if the set_memory_array_uc() function is present.
# It does not exist on all architectures.
#
- CODE="
+ echo "$CONFTEST_PREAMBLE
#if defined(NV_ASM_SET_MEMORY_H_PRESENT)
#include <asm/set_memory.h>
#else
#include <asm/cacheflush.h>
#endif
void conftest_set_memory_array_uc(void) {
- set_memory_array_uc();
- }"
+ set_memory_array_uc(NULL);
+ }" > conftest$$.c
- compile_check_conftest "$CODE" "NV_SET_MEMORY_ARRAY_UC_PRESENT" "" "functions"
+ $CC $CFLAGS -c conftest$$.c > /dev/null 2>&1
+ rm -f conftest$$.c
+ if [ -f conftest$$.o ]; then
+ rm -f conftest$$.o
+ echo "#define NV_SET_MEMORY_ARRAY_UC_PRESENT" | append_conftest "functions"
+ else
+ echo "#undef NV_SET_MEMORY_ARRAY_UC_PRESENT" | append_conftest "functions"
+ fi
;;
list_is_first)
59c8901 nvidia/nv-procfs.c: add a prototype for exercise_error_forwarding_va()
diff --git a/nvidia/nv-procfs.c b/nvidia/nv-procfs.c
index ee1879d..c2c2796 100644
--- a/nvidia/nv-procfs.c
+++ b/nvidia/nv-procfs.c
@@ -61,6 +61,7 @@ static nv_pm_action_depth_t nv_pm_action_depth = NV_PM_ACTION_DEPTH_DEFAULT;
#endif
static int nv_procfs_read_registry(struct seq_file *s, void *v);
+static void exercise_error_forwarding_va(nv_state_t *nv, NvU32 err, const char *fmt, ...);
#define NV_NUMA_STATUS_MSG_LEN (32)
#define NV_PROC_WRITE_BUFFER_SIZE (64 * PAGE_SIZE)
@@ -685,7 +686,7 @@ static struct proc_ops nv_procfs_suspend_fops = {
/*
* Forwards error to nv_log_error which exposes data to vendor callback
*/
-void
+static void
exercise_error_forwarding_va(
nv_state_t *nv,
NvU32 err,
0ef1943 nvidia/nv-procfs.c: replace 'const struct file_operations *' with 'const struct proc_ops *'
diff --git a/nvidia/nv-procfs.c b/nvidia/nv-procfs.c
index f8206a5..ee1879d 100644
--- a/nvidia/nv-procfs.c
+++ b/nvidia/nv-procfs.c
@@ -22,6 +22,7 @@
#include "conftest/patches.h"
#include "rmil.h"
#include "nv-ibmnpu.h"
+#include <linux/version.h>
#define NV_DEFINE_SINGLE_NVRM_PROCFS_FILE(name) \
NV_DEFINE_SINGLE_PROCFS_FILE(name, \
@@ -481,6 +482,7 @@ done:
return ((status < 0) ? status : (int)count);
}
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(5, 17, 0)
static struct file_operations nv_procfs_registry_fops = {
.owner = THIS_MODULE,
.open = nv_procfs_open_registry,
@@ -489,6 +491,15 @@ static struct file_operations nv_procfs_registry_fops = {
.llseek = seq_lseek,
.release = nv_procfs_close_registry,
};
+#else
+static struct proc_ops nv_procfs_registry_fops = {
+ .proc_open = nv_procfs_open_registry,
+ .proc_read = seq_read,
+ .proc_write = nv_procfs_write_file,
+ .proc_lseek = seq_lseek,
+ .proc_release = nv_procfs_close_registry,
+};
+#endif /* LINUX_VERSION_CODE <= KERNEL_VERSION(5, 17, 0) */
#if defined(CONFIG_PM)
static int
@@ -560,6 +571,7 @@ nv_procfs_open_suspend_depth(
return single_open(file, nv_procfs_show_suspend_depth, NULL);
}
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(5, 17, 0)
static struct file_operations nv_procfs_suspend_depth_fops = {
.owner = THIS_MODULE,
.open = nv_procfs_open_suspend_depth,
@@ -568,6 +580,15 @@ static struct file_operations nv_procfs_suspend_depth_fops = {
.llseek = seq_lseek,
.release = single_release
};
+#else
+static struct proc_ops nv_procfs_suspend_depth_fops = {
+ .proc_open = nv_procfs_open_suspend_depth,
+ .proc_read = seq_read,
+ .proc_write = nv_procfs_write_suspend_depth,
+ .proc_lseek = seq_lseek,
+ .proc_release = single_release
+};
+#endif /* LINUX_VERSION_CODE <= KERNEL_VERSION(5, 17, 0) */
static int
nv_procfs_show_suspend(
@@ -641,15 +662,24 @@ nv_procfs_open_suspend(
{
return single_open(file, nv_procfs_show_suspend, NULL);
}
-
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(5, 17, 0)
static struct file_operations nv_procfs_suspend_fops = {
- .owner = THIS_MODULE,
- .open = nv_procfs_open_suspend,
- .read = seq_read,
- .write = nv_procfs_write_suspend,
- .llseek = seq_lseek,
- .release = single_release
+ .owner = THIS_MODULE,
+ .open = nv_procfs_open_suspend,
+ .read = seq_read,
+ .write = nv_procfs_write_suspend,
+ .llseek = seq_lseek,
+ .release = single_release
};
+#else
+static struct proc_ops nv_procfs_suspend_fops = {
+ .proc_open = nv_procfs_open_suspend,
+ .proc_read = seq_read,
+ .proc_write = nv_procfs_write_suspend,
+ .proc_lseek = seq_lseek,
+ .proc_release = single_release
+};
+#endif /* LINUX_VERSION_CODE <= KERNEL_VERSION(5, 17, 0) */
#endif
/*
@@ -753,12 +783,20 @@ done:
return status;
}
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(5, 17, 0)
static struct file_operations nv_procfs_exercise_error_forwarding_fops = {
.owner = THIS_MODULE,
.open = nv_procfs_open_exercise_error_forwarding,
.write = nv_procfs_write_file,
.release = nv_procfs_close_exercise_error_forwarding,
};
+#else
+static struct proc_ops nv_procfs_exercise_error_forwarding_fops = {
+ .proc_open = nv_procfs_open_exercise_error_forwarding,
+ .proc_write = nv_procfs_write_file,
+ .proc_release = nv_procfs_close_exercise_error_forwarding,
+};
+#endif /* LINUX_VERSION_CODE <= KERNEL_VERSION(5, 17, 0) */
static int
nv_procfs_read_unbind_lock(
@@ -880,6 +918,7 @@ done:
return rc;
}
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(5, 17, 0)
static struct file_operations nv_procfs_unbind_lock_fops = {
.owner = THIS_MODULE,
.open = nv_procfs_open_unbind_lock,
@@ -888,6 +927,15 @@ static struct file_operations nv_procfs_unbind_lock_fops = {
.llseek = seq_lseek,
.release = nv_procfs_close_unbind_lock,
};
+#else
+static struct proc_ops nv_procfs_unbind_lock_fops = {
+ .proc_open = nv_procfs_open_unbind_lock,
+ .proc_read = seq_read,
+ .proc_write = nv_procfs_write_file,
+ .proc_lseek = seq_lseek,
+ .proc_release = nv_procfs_close_unbind_lock,
+};
+#endif /* LINUX_VERSION_CODE <= KERNEL_VERSION(5, 17, 0) */
static const char*
numa_status_describe(nv_numa_status_t state)
@@ -1216,6 +1264,7 @@ done:
return retval;
}
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(5, 17, 0)
static const struct file_operations nv_procfs_numa_status_fops = {
.owner = THIS_MODULE,
.open = nv_procfs_open_numa_status,
@@ -1224,7 +1273,17 @@ static const struct file_operations nv_procfs_numa_status_fops = {
.llseek = seq_lseek,
.release = nv_procfs_close_numa_status,
};
+#else
+static const struct proc_ops nv_procfs_numa_status_fops = {
+ .proc_open = nv_procfs_open_numa_status,
+ .proc_read = seq_read,
+ .proc_write = nv_procfs_write_file,
+ .proc_lseek = seq_lseek,
+ .proc_release = nv_procfs_close_numa_status,
+};
+#endif /* LINUX_VERSION_CODE <= KERNEL_VERSION(5, 17, 0) */
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(5, 17, 0)
static const struct file_operations nv_procfs_offline_pages_fops = {
.owner = THIS_MODULE,
.open = nv_procfs_open_offline_pages,
@@ -1232,6 +1291,14 @@ static const struct file_operations nv_procfs_offline_pages_fops = {
.llseek = seq_lseek,
.release = nv_procfs_close_offline_pages,
};
+#else
+static const struct proc_ops nv_procfs_offline_pages_fops = {
+ .proc_open = nv_procfs_open_offline_pages,
+ .proc_read = seq_read,
+ .proc_lseek = seq_lseek,
+ .proc_release = nv_procfs_close_offline_pages,
+};
+#endif /* LINUX_VERSION_CODE <= KERNEL_VERSION(5, 17, 0) */
static int
nv_procfs_read_text_file(
7539178 common/inc/nv-procfs.h: replace 'const struct file_operations *' with 'const struct proc_ops *'
diff --git a/common/inc/nv-procfs.h b/common/inc/nv-procfs.h
index fd7a2b5..04619f6 100644
--- a/common/inc/nv-procfs.h
+++ b/common/inc/nv-procfs.h
@@ -11,6 +11,7 @@
#define _NV_PROCFS_H
#include "conftest.h"
+#include <linux/version.h>
#ifdef CONFIG_PROC_FS
#include <linux/proc_fs.h>
@@ -28,6 +29,7 @@
#define IS_EXERCISE_ERROR_FORWARDING_ENABLED() (EXERCISE_ERROR_FORWARDING)
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(5, 17, 0)
#define NV_CREATE_PROC_FILE(filename,parent,__name,__data) \
({ \
struct proc_dir_entry *__entry; \
@@ -38,6 +40,18 @@
__entry = proc_create_data(filename, mode, parent, fops, __data);\
__entry; \
})
+#else
+#define NV_CREATE_PROC_FILE(filename,parent,__name,__data) \
+ ({ \
+ struct proc_dir_entry *__entry; \
+ int mode = (S_IFREG | S_IRUGO); \
+ const struct proc_ops *fops = &nv_procfs_##__name##_fops; \
+ if (fops->proc_write != 0) \
+ mode |= S_IWUSR; \
+ __entry = proc_create_data(filename, mode, parent, fops, __data);\
+ __entry; \
+ })
+#endif /* LINUX_VERSION_CODE <= KERNEL_VERSION(5, 17, 0) */
/*
* proc_mkdir_mode exists in Linux 2.6.9, but isn't exported until Linux 3.0.
@@ -81,6 +95,7 @@
remove_proc_entry(entry->name, entry->parent);
#endif
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(5, 17, 0)
#define NV_DEFINE_SINGLE_PROCFS_FILE(name, open_callback, close_callback) \
static int nv_procfs_open_##name( \
struct inode *inode, \
@@ -118,6 +133,44 @@
.llseek = seq_lseek, \
.release = nv_procfs_release_##name, \
};
+#else
+#define NV_DEFINE_SINGLE_PROCFS_FILE(name, open_callback, close_callback) \
+ static int nv_procfs_open_##name( \
+ struct inode *inode, \
+ struct file *filep \
+ ) \
+ { \
+ int ret; \
+ ret = single_open(filep, nv_procfs_read_##name, \
+ NV_PDE_DATA(inode)); \
+ if (ret < 0) \
+ { \
+ return ret; \
+ } \
+ ret = open_callback(); \
+ if (ret < 0) \
+ { \
+ single_release(inode, filep); \
+ } \
+ return ret; \
+ } \
+ \
+ static int nv_procfs_release_##name( \
+ struct inode *inode, \
+ struct file *filep \
+ ) \
+ { \
+ close_callback(); \
+ return single_release(inode, filep); \
+ } \
+ \
+ static const struct proc_ops nv_procfs_##name##_fops = { \
+ .proc_open = nv_procfs_open_##name, \
+ .proc_read = seq_read, \
+ .proc_lseek = seq_lseek, \
+ .proc_release = nv_procfs_release_##name, \
+ };
+#endif /* #if LINUX_VERSION_CODE <= KERNEL_VERSION(5, 17, 0) */
#endif /* CONFIG_PROC_FS */
6ff6922 common/inc/nv-procfs.h: replace PDE_DATA() macros with pde_data()
diff --git a/common/inc/nv-procfs.h b/common/inc/nv-procfs.h
index 8b53f86..fd7a2b5 100644
--- a/common/inc/nv-procfs.h
+++ b/common/inc/nv-procfs.h
@@ -64,8 +64,12 @@
})
#if defined(NV_PDE_DATA_PRESENT)
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(5, 17, 0)
# define NV_PDE_DATA(inode) PDE_DATA(inode)
#else
+# define NV_PDE_DATA(inode) pde_data(inode)
+#endif /* LINUX_VERSION_CODE <= KERNEL_VERSION(5, 17, 0) */
+#else
# define NV_PDE_DATA(inode) PDE(inode)->data
#endif
c10d9e9 nvidia/nv-mmap.c: use vm_flags_reset() to reset flags
diff --git a/nvidia/nv-mmap.c b/nvidia/nv-mmap.c
index 4487a6a..ed67769 100644
--- a/nvidia/nv-mmap.c
+++ b/nvidia/nv-mmap.c
@@ -648,8 +648,13 @@ int nvidia_mmap_helper(
if ((prot & NV_PROTECT_WRITEABLE) == 0)
{
vma->vm_page_prot = NV_PGPROT_READ_ONLY(vma->vm_page_prot);
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(6, 4, 0)
vma->vm_flags &= ~VM_WRITE;
vma->vm_flags &= ~VM_MAYWRITE;
+#else
+ vm_flags_clear(vma, VM_WRITE);
+ vm_flags_clear(vma, VM_MAYWRITE);
+#endif
}
vma->vm_ops = &nv_vm_ops;
197863e common/inc/nv-linux.h: nv_is_dma_direct() should return a value
diff --git a/common/inc/nv-linux.h b/common/inc/nv-linux.h
index 69a7af0..60989ae 100644
--- a/common/inc/nv-linux.h
+++ b/common/inc/nv-linux.h
@@ -1182,6 +1182,7 @@ static inline NvBool nv_is_dma_direct(struct device *dev)
return NV_TRUE;
#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(6, 4, 0) */
#endif
+ return NV_FALSE;
}
/**
6693f68 nvidia/nv-mmap.c: use vm_flags_set() to set flags
diff --git a/nvidia/nv-mmap.c b/nvidia/nv-mmap.c
index e77d53b..4487a6a 100644
--- a/nvidia/nv-mmap.c
+++ b/nvidia/nv-mmap.c
@@ -342,7 +342,7 @@ int nv_encode_caching(
return 0;
}
-int static nvidia_mmap_peer_io(
+static int nvidia_mmap_peer_io(
struct vm_area_struct *vma,
nv_alloc_t *at,
NvU64 page_index,
@@ -363,7 +363,7 @@ int static nvidia_mmap_peer_io(
return ret;
}
-int static nvidia_mmap_sysmem(
+static int nvidia_mmap_sysmem(
struct vm_area_struct *vma,
nv_alloc_t *at,
NvU64 page_index,
@@ -566,7 +566,11 @@ int nvidia_mmap_helper(
}
up(&nvl->mmap_lock);
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(6, 4, 0)
vma->vm_flags |= VM_IO | VM_PFNMAP | VM_DONTEXPAND;
+#else
+ vm_flags_set(vma, (VM_IO | VM_PFNMAP | VM_DONTEXPAND));
+#endif
}
else
{
@@ -632,9 +636,13 @@ int nvidia_mmap_helper(
}
NV_PRINT_AT(NV_DBG_MEMINFO, at);
-
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(6, 4, 0)
vma->vm_flags |= (VM_IO | VM_LOCKED | VM_RESERVED);
vma->vm_flags |= (VM_DONTEXPAND | VM_DONTDUMP);
+#else
+ vm_flags_set(vma, (VM_IO | VM_LOCKED | VM_RESERVED));
+ vm_flags_set(vma, (VM_DONTEXPAND | VM_DONTDUMP));
+#endif
}
if ((prot & NV_PROTECT_WRITEABLE) == 0)
b393651 nvidia/nv.c: replace del_timer_sync() with timer_delete_sync()
diff --git a/nvidia/nv.c b/nvidia/nv.c
index a14d6c2..b62d3bf 100644
--- a/nvidia/nv.c
+++ b/nvidia/nv.c
@@ -3426,7 +3426,11 @@ int NV_API_CALL nv_stop_rc_timer(
nv_printf(NV_DBG_INFO, "NVRM: stopping rc timer\n");
nv->rc_timer_enabled = 0;
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(6, 4, 0)
del_timer_sync(&nvl->rc_timer.kernel_timer);
+#else
+ timer_delete_sync(&nvl->rc_timer.kernel_timer);
+#endif
nv_printf(NV_DBG_INFO, "NVRM: rc timer stopped\n");
return 0;
50d47cb nvidia/nv.c: replace pci_set_dma_mask() with dma_set_mask()
diff --git a/nvidia/nv.c b/nvidia/nv.c
index fd11c84..a14d6c2 100644
--- a/nvidia/nv.c
+++ b/nvidia/nv.c
@@ -2647,7 +2647,11 @@ nv_set_dma_address_size(
if (!nvl->tce_bypass_enabled)
{
NvU64 new_mask = (((NvU64)1) << phys_addr_bits) - 1;
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(6, 4, 0)
pci_set_dma_mask(nvl->pci_dev, new_mask);
+#else
+ dma_set_mask(nvl->dev, new_mask);
+#endif
}
}
e41adac nvidia/nv-acpi.c: implicit declaration of acpi_bus_get_device()
diff --git a/nvidia/nv-acpi.c b/nvidia/nv-acpi.c
index 0c43bc4..41da90b 100644
--- a/nvidia/nv-acpi.c
+++ b/nvidia/nv-acpi.c
@@ -652,7 +652,7 @@ static void nv_uninstall_notifier(nv_acpi_t *pNvAcpiObject, acpi_notify_handler
* check if the NVIF, _DSM and WMMX methods are present in the acpi namespace.
* store NVIF, _DSM and WMMX handle if found.
*/
-
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(6, 4, 0)
void NV_API_CALL nv_acpi_methods_init(NvU32 *handlesPresent)
{
struct acpi_device *device = NULL;
@@ -721,7 +721,72 @@ void NV_API_CALL nv_acpi_methods_init(NvU32 *handlesPresent)
return;
}
-
+#else
+void NV_API_CALL nv_acpi_methods_init(NvU32 *handlesPresent)
+{
+#if defined(NV_ACPI_BUS_GET_DEVICE_PRESENT)
+ struct acpi_device *device = NULL;
+ int retVal = -1;
+#endif
+
+ if (!handlesPresent) // Caller passed us invalid pointer.
+ return;
+
+ *handlesPresent = 0;
+
+ NV_ACPI_WALK_NAMESPACE(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT,
+ ACPI_UINT32_MAX, nv_acpi_find_methods, NULL, NULL);
+
+ if (nvif_handle)
+ {
+ *handlesPresent = NV_ACPI_NVIF_HANDLE_PRESENT;
+#if defined(NV_ACPI_BUS_GET_DEVICE_PRESENT)
+ do
+ {
+ if (!nvif_parent_gpu_handle) /* unknown error */
+ break;
+
+ retVal = acpi_bus_get_device(nvif_parent_gpu_handle, &device);
+
+ if (ACPI_FAILURE(retVal) || !device)
+ break;
+
+ if (device->driver_data)
+ {
+ nvif_parent_gpu_handle = NULL;
+ break; /* Someone else has already populated this device
+ nodes' structures. So nothing more to be done */
+ }
+
+ device->driver_data = nv_install_notifier(device->handle, nv_acpi_event);
+
+
+ if (!device->driver_data)
+ nvif_parent_gpu_handle = NULL;
+
+ } while (0);
+#endif
+ }
+
+ if (wmmx_handle)
+ *handlesPresent = *handlesPresent | NV_ACPI_WMMX_HANDLE_PRESENT;
+
+ if (psr_handle)
+ {
+ // Since _PSR is not a per-GPU construct we only need to register a
+ // single notifier for the _PSR event. Skip registration for subsequent
+ // devices
+ if (psr_nv_acpi_object == NULL)
+ {
+ psr_nv_acpi_object = nv_install_notifier(psr_device_handle, nv_acpi_powersource_hotplug_event);
+ }
+ }
+
+ return;
+}
+
+#endif
+
acpi_status nv_acpi_find_methods(
acpi_handle handle,
u32 nest_level,
@@ -760,7 +825,7 @@ acpi_status nv_acpi_find_methods(
return 0;
}
-
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(6, 4, 0)
void NV_API_CALL nv_acpi_methods_uninit(void)
{
struct acpi_device *device = NULL;
@@ -791,7 +856,39 @@ void NV_API_CALL nv_acpi_methods_uninit(void)
return;
}
+#else
+void NV_API_CALL nv_acpi_methods_uninit(void)
+{
+ struct acpi_device *device = NULL;
+
+ nvif_handle = NULL;
+ wmmx_handle = NULL;
+
+ if (psr_nv_acpi_object != NULL)
+ {
+ nv_uninstall_notifier(psr_nv_acpi_object, nv_acpi_powersource_hotplug_event);
+
+ psr_handle = NULL;
+ psr_device_handle = NULL;
+ psr_nv_acpi_object = NULL;
+ }
+
+ if (nvif_parent_gpu_handle == NULL)
+ return;
+
+#if defined(NV_ACPI_BUS_GET_DEVICE_PRESENT)
+ acpi_bus_get_device(nvif_parent_gpu_handle, &device);
+
+ nv_uninstall_notifier(device->driver_data, nv_acpi_event);
+#endif
+
+ device->driver_data = NULL;
+ nvif_parent_gpu_handle = NULL;
+
+ return;
+}
+#endif
static NV_STATUS nv_acpi_extract_integer(
const union acpi_object *acpi_object,
void *buffer,
cbf3d42 common/inc/nv.h: relpacement for removed device.children member
diff --git a/common/inc/nv.h b/common/inc/nv.h
index 15daade..4ff6ee0 100644
--- a/common/inc/nv.h
+++ b/common/inc/nv.h
@@ -12,6 +12,8 @@
#ifndef _NV_H_
#define _NV_H_
+#include <linux/version.h>
+
#ifndef _CONFTEST_H
#include "conftest.h"
#endif
@@ -745,7 +747,11 @@ void NV_API_CALL nv_acpi_methods_uninit (void);
NV_STATUS NV_API_CALL nv_acpi_method (NvU32, NvU32, NvU32, void *, NvU16, NvU32 *, void *, NvU16 *);
NV_STATUS NV_API_CALL nv_acpi_dsm_method (nv_state_t *, NvU8 *, NvU32, NvU32, void *, NvU16, NvU32 *, void *, NvU16 *);
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(6, 4, 0)
NV_STATUS NV_API_CALL nv_acpi_ddc_method (nv_state_t *, void *, NvU32 *);
+#else
+NV_STATUS NV_API_CALL nv_acpi_ddc_method (nv_state_t *, void *, NvU32 *, NvBool);
+#endif
NV_STATUS NV_API_CALL nv_acpi_dod_method (nv_state_t *, NvU32 *, NvU32 *);
NV_STATUS NV_API_CALL nv_acpi_rom_method (nv_state_t *, NvU32 *, NvU32 *);
NvBool NV_API_CALL nv_acpi_upstreamport_power_resource_method_present (void *);
0a4426a nvidia/nv-acpi.c: relpacement for removed device.children member
diff --git a/nvidia/nv-acpi.c b/nvidia/nv-acpi.c
index 7f38ebd..0c43bc4 100644
--- a/nvidia/nv-acpi.c
+++ b/nvidia/nv-acpi.c
@@ -16,6 +16,7 @@
#include "nv-reg.h"
#include "conftest.h"
#include <linux/acpi.h>
+#include <linux/version.h>
#if defined(NV_LINUX_ACPI_EVENTS_SUPPORTED)
static NV_STATUS nv_acpi_extract_integer (const union acpi_object *, void *, NvU32, NvU32 *);
@@ -239,7 +240,11 @@ static int nv_acpi_add(struct acpi_device *device)
union acpi_object control_argument_0 = { ACPI_TYPE_INTEGER };
struct acpi_object_list control_argument_list = { 0, NULL };
nvidia_stack_t *sp = NULL;
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(6, 4, 0)
struct list_head *node, *next;
+#else
+ acpi_handle handle;
+#endif
unsigned long long device_id = 0;
int device_counter = 0;
@@ -267,7 +272,7 @@ static int nv_acpi_add(struct acpi_device *device)
pNvAcpiObject->sp = sp;
// grab handles to all the important nodes representing devices
-
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(6, 4, 0)
list_for_each_safe(node, next, &device->children)
{
struct acpi_device *dev =
@@ -309,6 +314,48 @@ static int nv_acpi_add(struct acpi_device *device)
device_counter++;
}
+#else
+ do
+ {
+ status = acpi_get_next_object(ACPI_TYPE_DEVICE, device->handle,
+ handle, &handle);
+ if (ACPI_FAILURE(status) || (handle == NULL))
+ break;
+
+ if (device_counter == NV_MAXNUM_DISPLAY_DEVICES)
+ {
+ nv_printf(NV_DBG_ERRORS,
+ "NVRM: nv_acpi_add: Total number of devices cannot exceed %d\n",
+ NV_MAXNUM_DISPLAY_DEVICES);
+ break;
+ }
+
+ status =
+ acpi_evaluate_integer(handle, "_ADR", NULL, &device_id);
+ if (ACPI_FAILURE(status))
+ /* Couldnt query device_id for this device */
+ continue;
+
+ device_id = (device_id & 0xffff);
+
+ if ((device_id != 0x100) && /* Not a known CRT device-id */
+ (device_id != 0x200) && /* Not a known TV device-id */
+ (device_id != 0x0110) && (device_id != 0x0118) && (device_id != 0x0400) && /* Not an LCD*/
+ (device_id != 0x0111) && (device_id != 0x0120) && (device_id != 0x0300)) /* Not a known DVI device-id */
+ {
+ /* This isnt a known device Id.
+ Do default switching on this system. */
+ pNvAcpiObject->default_display_mask = 1;
+ break;
+ }
+
+ pNvAcpiObject->pNvVideo[device_counter].dev_id = device_id;
+ pNvAcpiObject->pNvVideo[device_counter].dev_handle = handle;
+
+ device_counter++;
+
+ } while (handle != NULL);
+#endif
// arg 0, bits 1:0, 0 = enable events
control_argument_0.integer.type = ACPI_TYPE_INTEGER;
@@ -1273,6 +1320,7 @@ NV_STATUS NV_API_CALL nv_acpi_dsm_method(
/*
* This function executes a _DDC ACPI method.
*/
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(6, 4, 0)
NV_STATUS NV_API_CALL nv_acpi_ddc_method(
nv_state_t *nv,
void *pEdidBuffer,
@@ -1386,6 +1434,122 @@ NV_STATUS NV_API_CALL nv_acpi_ddc_method(
kfree(output.pointer);
return NV_OK;
}
+#else
+NV_STATUS NV_API_CALL nv_acpi_ddc_method(
+ nv_state_t *nv,
+ void *pEdidBuffer,
+ NvU32 *pSize,
+ NvBool bReadMultiBlock
+)
+{
+ acpi_status status;
+ union acpi_object *ddc = NULL;
+ NvU32 i, largestEdidSize;
+ acpi_handle dev_handle = NULL;
+ acpi_handle lcd_dev_handle = NULL;
+ acpi_handle handle = NULL;
+
+ if (!nv_acpi_get_device_handle(nv, &dev_handle))
+ return NV_ERR_NOT_SUPPORTED;
+
+ if (!dev_handle)
+ return NV_ERR_INVALID_ARGUMENT;
+
+ if (!NV_MAY_SLEEP())
+ {
+#if defined(DEBUG)
+ nv_printf(NV_DBG_ERRORS,
+ "NVRM: %s: invalid context!\n",
+ __FUNCTION__);
+#endif
+ return NV_ERR_NOT_SUPPORTED;
+ }
+
+ while (lcd_dev_handle == NULL)
+ {
+ unsigned long long device_id = 0;
+
+ status = acpi_get_next_object(ACPI_TYPE_DEVICE, dev_handle,
+ handle, &handle);
+ if (ACPI_FAILURE(status) || (handle == NULL))
+ break;
+
+ status = acpi_evaluate_integer(handle, "_ADR", NULL, &device_id);
+ if (ACPI_FAILURE(status))
+ /* Couldnt query device_id for this device */
+ continue;
+
+ switch (device_id & 0xffff) {
+ case 0x0110:
+ case 0x0118:
+ case 0x0400:
+ case 0xA420:
+ lcd_dev_handle = handle;
+ nv_printf(NV_DBG_INFO, "NVRM: %s Found LCD: %x\n",
+ __FUNCTION__, device_id);
+ break;
+ default:
+ break;
+ }
+ }
+
+ if (lcd_dev_handle == NULL)
+ {
+ nv_printf(NV_DBG_INFO, "NVRM: %s LCD not found\n", __FUNCTION__);
+ return NV_ERR_GENERIC;
+ }
+
+ //
+ // As per ACPI Spec 3.0:
+ // ARG0 = 0x1 for 128 bytes edid buffer
+ // ARG0 = 0x2 for 256 bytes edid buffer
+ //
+
+ largestEdidSize = bReadMultiBlock ? 2 : 1;
+
+ for (i = largestEdidSize; i >= 1; i--)
+ {
+ struct acpi_buffer output = { ACPI_ALLOCATE_BUFFER, NULL };
+ union acpi_object ddc_arg0 = { ACPI_TYPE_INTEGER };
+ struct acpi_object_list input = { 1, &ddc_arg0 };
+
+ ddc_arg0.integer.value = i;
+ status = acpi_evaluate_object(lcd_dev_handle, "_DDC", &input, &output);
+ if (ACPI_SUCCESS(status)) {
+ ddc = output.pointer;
+ break;
+ }
+ }
+
+ if (ACPI_FAILURE(status))
+ {
+ nv_printf(NV_DBG_INFO,
+ "NVRM: %s: failed status: %08x \n",
+ __FUNCTION__,
+ status);
+ return NV_ERR_GENERIC;
+ }
+ else
+ {
+ if (ddc && (ddc->type == ACPI_TYPE_BUFFER) && (ddc->buffer.length > 0))
+ {
+ if (ddc->buffer.length <= *pSize)
+ {
+ *pSize = NV_MIN(*pSize, ddc->buffer.length);
+ memcpy(pEdidBuffer, ddc->buffer.pointer, *pSize);
+ }
+ else
+ {
+ kfree(ddc);
+ return NV_ERR_BUFFER_TOO_SMALL;
+ }
+ }
+ }
+
+ kfree(ddc);
+ return NV_OK;
+}
+#endif
/*
* This function executes a _ROM ACPI method.
0c2ff03 nvidia/nv-dma.c, nvidia/nv.c: add missing prototypes
diff --git a/nvidia/nv-acpi.c b/nvidia/nv-acpi.c
index afbe626..7f38ebd 100644
--- a/nvidia/nv-acpi.c
+++ b/nvidia/nv-acpi.c
@@ -397,7 +397,7 @@ static NV_ACPI_DEVICE_OPS_REMOVE_TYPE nv_acpi_remove(struct acpi_device *device)
module_put(THIS_MODULE);
device->driver_data = NULL;
}
-#if !defined(NV_ACPI_DEVICE_OPS_REMOVE_IS_VOID
+#if !defined(NV_ACPI_DEVICE_OPS_REMOVE_IS_VOID)
return status;
#endif
}
diff --git a/nvidia/nv-dma.c b/nvidia/nv-dma.c
index 18ca32c..bc2cf9a 100644
--- a/nvidia/nv-dma.c
+++ b/nvidia/nv-dma.c
@@ -20,6 +20,7 @@ NV_STATUS nv_map_dma_map_scatterlist (nv_dma_map_t *dma_map);
void nv_unmap_dma_map_scatterlist (nv_dma_map_t *dma_map);
static void nv_dma_unmap_contig (nv_dma_map_t *dma_map);
static void nv_dma_unmap_scatterlist (nv_dma_map_t *dma_map);
+static void nv_load_dma_map_scatterlist(nv_dma_map_t *dma_map, NvU64 *va_array);
static NV_STATUS nv_dma_map_contig(
nv_state_t *nv,
@@ -217,7 +218,7 @@ void nv_destroy_dma_map_scatterlist(nv_dma_map_t *dma_map)
os_free_mem(dma_map->mapping.discontig.submaps);
}
-void nv_load_dma_map_scatterlist(
+static inline void nv_load_dma_map_scatterlist(
nv_dma_map_t *dma_map,
NvU64 *va_array
)
diff --git a/nvidia/nv.c b/nvidia/nv.c
index 0289587..fd11c84 100644
--- a/nvidia/nv.c
+++ b/nvidia/nv.c
@@ -92,6 +92,9 @@ NvBool nv_ats_supported = NVCPU_IS_PPC64LE;
#define NV_DBG_EVENTINFO NV_DBG_INFO
#endif
+int __init nvidia_init_module(void);
+void nvidia_exit_module(void);
+
/***
*** STATIC functions, only in this file
***/
1427eb9 conftest.sh, nvidia/nv-acpi.c: check if acpi_op_remove is void or int
diff --git a/conftest.sh b/conftest.sh
index 3925596..280d3dd 100755
--- a/conftest.sh
+++ b/conftest.sh
@@ -551,19 +551,22 @@ compile_test() {
acpi_op_remove)
#
# Determine the number of arguments to pass to the
- # 'acpi_op_remove' routine.
+ # 'acpi_op_remove' routine and its type. Modern kernels requires
+ # that 'acpi_op_remove' need to be void.
#
# Second parameter removed by commit 51fac8388a03
# ("ACPI: Remove useless type argument of driver .remove()
# operation") in v3.9
#
+ # Test if function is int, one argument
+ #
echo "$CONFTEST_PREAMBLE
#include <linux/acpi.h>
- acpi_op_remove conftest_op_remove_routine;
+ acpi_op_remove conftest_op_remove_routine(struct acpi_device *device);
int conftest_acpi_device_ops_remove(struct acpi_device *device) {
- return conftest_op_remove_routine(device);
+ return conftest_op_remove_routine(NULL);
}" > conftest$$.c
$CC $CFLAGS -c conftest$$.c > /dev/null 2>&1
@@ -572,19 +575,65 @@ compile_test() {
if [ -f conftest$$.o ]; then
rm -f conftest$$.o
echo "#define NV_ACPI_DEVICE_OPS_REMOVE_ARGUMENT_COUNT 1" | append_conftest "types"
+ echo "#undef NV_ACPI_DEVICE_OPS_REMOVE_IS_VOID" | append_conftest "types"
return
fi
-
- CODE="
+ # Test if function is int, two arguments
+ echo "$CONFTEST_PREAMBLE
#include <linux/acpi.h>
- acpi_op_remove conftest_op_remove_routine;
+ acpi_op_remove conftest_op_remove_routine(struct acpi_device *device, int type);
int conftest_acpi_device_ops_remove(struct acpi_device *device, int type) {
- return conftest_op_remove_routine(device, type);
- }"
+ return conftest_op_remove_routine(NULL, 0);
+ }" > conftest$$.c
+
+ $CC $CFLAGS -c conftest$$.c > /dev/null 2>&1
+ rm -f conftest$$.c
+
+ if [ -f conftest$$.o ]; then
+ rm -f conftest$$.o
+ echo "#define NV_ACPI_DEVICE_OPS_REMOVE_ARGUMENT_COUNT 2" | append_conftest "types"
+ echo "#undef NV_ACPI_DEVICE_OPS_REMOVE_IS_VOID" | append_conftest "types"
+ return
+ fi
+ # Test if function is void, one argument
+ echo "$CONFTEST_PREAMBLE
+ #include <linux/acpi.h>
+
+ acpi_op_remove conftest_op_remove_routine(struct acpi_device *device);
+
+ void conftest_acpi_device_ops_remove(struct acpi_device *device) {
+ conftest_op_remove_routine(NULL);
+ }" > conftest$$.c
+
+ $CC $CFLAGS -c conftest$$.c > /dev/null 2>&1
+ rm -f conftest$$.c
+
+ if [ -f conftest$$.o ]; then
+ rm -f conftest$$.o
+ echo "#define NV_ACPI_DEVICE_OPS_REMOVE_ARGUMENT_COUNT 1" | append_conftest "types"
+ echo "#define NV_ACPI_DEVICE_OPS_REMOVE_IS_VOID" | append_conftest "types"
+ return
+ fi
+ # Test if function is void, two arguments
+ echo "$CONFTEST_PREAMBLE
+ #include <linux/acpi.h>
- compile_check_conftest "$CODE" "NV_ACPI_DEVICE_OPS_REMOVE_ARGUMENT_COUNT" "2" "types"
+ acpi_op_remove conftest_op_remove_routine(struct acpi_device *device, int type);
+
+ void conftest_acpi_device_ops_remove(struct acpi_device *device, int type) {
+ conftest_op_remove_routine(NULL, 0);
+ }" > conftest$$.c
+
+ $CC $CFLAGS -c conftest$$.c > /dev/null 2>&1
+ rm -f conftest$$.c
+
+ if [ -f conftest$$.o ]; then
+ rm -f conftest$$.o
+ echo "#define NV_ACPI_DEVICE_OPS_REMOVE_ARGUMENT_COUNT 2" | append_conftest "types"
+ echo "#define NV_ACPI_DEVICE_OPS_REMOVE_IS_VOID" | append_conftest "types"
+ fi
;;
acquire_console_sem)
diff --git a/nvidia/nv-acpi.c b/nvidia/nv-acpi.c
index 47d4cb5..afbe626 100644
--- a/nvidia/nv-acpi.c
+++ b/nvidia/nv-acpi.c
@@ -14,7 +14,7 @@
#include "os-interface.h"
#include "nv-linux.h"
#include "nv-reg.h"
-
+#include "conftest.h"
#include <linux/acpi.h>
#if defined(NV_LINUX_ACPI_EVENTS_SUPPORTED)
@@ -25,10 +25,16 @@ static NV_STATUS nv_acpi_extract_object (const union acpi_object *, void *, N
static int nv_acpi_add (struct acpi_device *);
-#if !defined(NV_ACPI_DEVICE_OPS_REMOVE_ARGUMENT_COUNT) || (NV_ACPI_DEVICE_OPS_REMOVE_ARGUMENT_COUNT == 2)
-static int nv_acpi_remove_two_args(struct acpi_device *device, int type);
+#if !defined(NV_ACPI_DEVICE_OPS_REMOVE_IS_VOID)
+#define NV_ACPI_DEVICE_OPS_REMOVE_TYPE int
+#else
+#define NV_ACPI_DEVICE_OPS_REMOVE_TYPE void
+#endif
+
+#if defined(NV_ACPI_DEVICE_OPS_REMOVE_ARGUMENT_COUNT) && (NV_ACPI_DEVICE_OPS_REMOVE_ARGUMENT_COUNT == 2)
+static NV_ACPI_DEVICE_OPS_REMOVE_TYPE nv_acpi_remove(struct acpi_device *device, int type);
#else
-static int nv_acpi_remove_one_arg(struct acpi_device *device);
+static NV_ACPI_DEVICE_OPS_REMOVE_TYPE nv_acpi_remove(struct acpi_device *device);
#endif
static void nv_acpi_event (acpi_handle, u32, void *);
@@ -80,11 +86,7 @@ static const struct acpi_driver nv_acpi_driver_template = {
.ids = nv_video_device_ids,
.ops = {
.add = nv_acpi_add,
-#if !defined(NV_ACPI_DEVICE_OPS_REMOVE_ARGUMENT_COUNT) || (NV_ACPI_DEVICE_OPS_REMOVE_ARGUMENT_COUNT == 2)
- .remove = nv_acpi_remove_two_args,
-#else
- .remove = nv_acpi_remove_one_arg,
-#endif
+ .remove = nv_acpi_remove,
},
};
@@ -342,10 +344,10 @@ static int nv_acpi_add(struct acpi_device *device)
return 0;
}
-#if !defined(NV_ACPI_DEVICE_OPS_REMOVE_ARGUMENT_COUNT) || (NV_ACPI_DEVICE_OPS_REMOVE_ARGUMENT_COUNT == 2)
-static int nv_acpi_remove_two_args(struct acpi_device *device, int type)
+#if defined(NV_ACPI_DEVICE_OPS_REMOVE_ARGUMENT_COUNT) && (NV_ACPI_DEVICE_OPS_REMOVE_ARGUMENT_COUNT == 2)
+static NV_ACPI_DEVICE_OPS_REMOVE_TYPE nv_acpi_remove(struct acpi_device *device, int type)
#else
-static int nv_acpi_remove_one_arg(struct acpi_device *device)
+static NV_ACPI_DEVICE_OPS_REMOVE_TYPE nv_acpi_remove(struct acpi_device *device)
#endif
{
/*
@@ -395,8 +397,9 @@ static int nv_acpi_remove_one_arg(struct acpi_device *device)
module_put(THIS_MODULE);
device->driver_data = NULL;
}
-
+#if !defined(NV_ACPI_DEVICE_OPS_REMOVE_IS_VOID
return status;
+#endif
}
/*
a97d5fc common/inc/nv-linux.h: replace dma_is_direct() with dma_direct_supported()
diff --git a/common/inc/nv-linux.h b/common/inc/nv-linux.h
index 2ad632e..69a7af0 100644
--- a/common/inc/nv-linux.h
+++ b/common/inc/nv-linux.h
@@ -1168,14 +1168,20 @@ static inline NvU32 nv_alloc_init_flags(int cached, int contiguous, int zeroed)
*/
static inline NvBool nv_is_dma_direct(struct device *dev)
{
+#if defined(NV_DMA_IS_DIRECT_PRESENT)
+#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 4, 0)
NvBool is_direct = NV_FALSE;
-#if defined(NV_DMA_IS_DIRECT_PRESENT)
if (dma_is_direct(get_dma_ops(dev)))
is_direct = NV_TRUE;
-#endif
return is_direct;
+#else
+ u64 mask = dma_direct_get_required_mask(dev);
+ if(dma_direct_supported(dev, mask))
+ return NV_TRUE;
+#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(6, 4, 0) */
+#endif
}
/**
809fc2d common/inc/nv-linux.h: include linux/dma-direct.h when NV_PHYS_TO_DMA_PRESENT is defined
diff --git a/common/inc/nv-linux.h b/common/inc/nv-linux.h
index 661aaae..2ad632e 100644
--- a/common/inc/nv-linux.h
+++ b/common/inc/nv-linux.h
@@ -176,6 +176,9 @@ static inline uid_t __kuid_val(uid_t uid)
#include <linux/pagemap.h>
#include <linux/dma-mapping.h>
+#if defined(NV_PHYS_TO_DMA_PRESENT)
+#include <linux/dma-direct.h>
+#endif
#if defined(CONFIG_SWIOTLB) && defined(NVCPU_AARCH64)
#include <linux/swiotlb.h>
7660b13 common/inc/nv-linux.h: use ioremap() instead of ioremap_nocache() on linux > 4.0
diff --git a/common/inc/nv-linux.h b/common/inc/nv-linux.h
index 0848875..661aaae 100644
--- a/common/inc/nv-linux.h
+++ b/common/inc/nv-linux.h
@@ -540,7 +540,11 @@ static inline void *nv_ioremap(NvU64 phys, NvU64 size)
static inline void *nv_ioremap_nocache(NvU64 phys, NvU64 size)
{
+#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 0, 0)
void *ptr = ioremap_nocache(phys, size);
+#else
+ void *ptr = ioremap(phys, size);
+#endif
if (ptr) {
NV_MEMDBG_ADD(ptr, size);
}
9b7fa0c common/inc/nv-linux.h: NV_MEMDBG* macroses: Fix -Wempty-body warnings
diff --git a/common/inc/nv-linux.h b/common/inc/nv-linux.h
index db79536..0848875 100644
--- a/common/inc/nv-linux.h
+++ b/common/inc/nv-linux.h
@@ -517,8 +517,9 @@ static inline void *nv_vmalloc(unsigned long size)
void *ptr = __vmalloc(size, GFP_KERNEL, PAGE_KERNEL);
#endif
#endif /* defined(NV_LINUX__VMALLOC_H_PRESENT) && defined (NV_LINUX__VMALLOC_H_ARGUMENT_COUNT) */
- if (ptr)
+ if (ptr) {
NV_MEMDBG_ADD(ptr, size);
+ }
return ptr;
}
@@ -531,16 +532,18 @@ static inline void nv_vfree(void *ptr, NvU32 size)
static inline void *nv_ioremap(NvU64 phys, NvU64 size)
{
void *ptr = ioremap(phys, size);
- if (ptr)
+ if (ptr) {
NV_MEMDBG_ADD(ptr, size);
+ }
return ptr;
}
static inline void *nv_ioremap_nocache(NvU64 phys, NvU64 size)
{
void *ptr = ioremap_nocache(phys, size);
- if (ptr)
+ if (ptr) {
NV_MEMDBG_ADD(ptr, size);
+ }
return ptr;
}
@@ -548,8 +551,9 @@ static inline void *nv_ioremap_cache(NvU64 phys, NvU64 size)
{
#if defined(NV_IOREMAP_CACHE_PRESENT)
void *ptr = ioremap_cache(phys, size);
- if (ptr)
+ if (ptr) {
NV_MEMDBG_ADD(ptr, size);
+ }
return ptr;
#elif defined(NVCPU_PPC64LE)
//
@@ -566,8 +570,9 @@ static inline void *nv_ioremap_cache(NvU64 phys, NvU64 size)
// support on power.
//
void *ptr = ioremap_prot(phys, size, pgprot_val(PAGE_KERNEL));
- if (ptr)
+ if (ptr) {
NV_MEMDBG_ADD(ptr, size);
+ }
return ptr;
#else
return nv_ioremap(phys, size);
@@ -578,8 +583,9 @@ static inline void *nv_ioremap_wc(NvU64 phys, NvU64 size)
{
#if defined(NV_IOREMAP_WC_PRESENT)
void *ptr = ioremap_wc(phys, size);
- if (ptr)
+ if (ptr) {
NV_MEMDBG_ADD(ptr, size);
+ }
return ptr;
#else
return nv_ioremap_nocache(phys, size);
@@ -606,15 +612,17 @@ static NvBool nv_numa_node_has_memory(int node_id)
#define NV_KMALLOC(ptr, size) \
{ \
(ptr) = kmalloc(size, NV_GFP_KERNEL); \
- if (ptr) \
+ if (ptr) { \
NV_MEMDBG_ADD(ptr, size); \
+ } \
}
#define NV_KMALLOC_ATOMIC(ptr, size) \
{ \
(ptr) = kmalloc(size, NV_GFP_ATOMIC); \
- if (ptr) \
+ if (ptr) { \
NV_MEMDBG_ADD(ptr, size); \
+ } \
}
@@ -654,8 +662,9 @@ static inline NvUPtr nv_vmap(struct page **pages, NvU32 page_count,
#endif
/* All memory cached in PPC64LE; can't honor 'cached' input. */
ptr = vmap(pages, page_count, VM_MAP, prot);
- if (ptr)
+ if (ptr) {
NV_MEMDBG_ADD(ptr, page_count * PAGE_SIZE);
+ }
return (NvUPtr)ptr;
}
28cf71b conftest.sh, common/inc/nv-linux.h, nvidia/nvidia.Kbuild: __vmalloc: check for count of arguments
diff --git a/common/inc/nv-linux.h b/common/inc/nv-linux.h
index 1df85b4..db79536 100644
--- a/common/inc/nv-linux.h
+++ b/common/inc/nv-linux.h
@@ -510,7 +510,13 @@ extern int nv_pat_mode;
static inline void *nv_vmalloc(unsigned long size)
{
+#if defined(NV_LINUX__VMALLOC_H_PRESENT) && defined (NV_LINUX__VMALLOC_H_ARGUMENT_COUNT)
+#if (NV_LINUX__VMALLOC_H_ARGUMENT_COUNT == 2)
+ void *ptr = __vmalloc(size, GFP_KERNEL);
+#elif (NV_LINUX__VMALLOC_H_ARGUMENT_COUNT == 3)
void *ptr = __vmalloc(size, GFP_KERNEL, PAGE_KERNEL);
+#endif
+#endif /* defined(NV_LINUX__VMALLOC_H_PRESENT) && defined (NV_LINUX__VMALLOC_H_ARGUMENT_COUNT) */
if (ptr)
NV_MEMDBG_ADD(ptr, size);
return ptr;
diff --git a/conftest.sh b/conftest.sh
index 70eca5a..3925596 100755
--- a/conftest.sh
+++ b/conftest.sh
@@ -1910,6 +1910,42 @@ compile_test() {
compile_check_conftest "$CODE" "NV_VZALLOC_PRESENT" "" "functions"
;;
+ vmalloc)
+ #
+ # Determine if the vmalloc function is present and what number of arguments
+ # it accepts
+ CODE="
+ #include <linux/vmalloc.h>
+ #include <linux/stddef.h>
+ void conftest_vmalloc(void) {
+ void *addr = NULL;
+ addr = __vmalloc(1, 0);
+ vfree(addr);
+ }" > conftest$$.c
+ $CC $CFLAGS -c conftest$$.c
+ if [ -f conftest$$.o ]; then
+ rm -f conftest$$.o
+ echo "#define NV_LINUX__VMALLOC_H_PRESENT" | append_conftest "functions"
+ echo "#define NV_LINUX__VMALLOC_H_ARGUMENT_COUNT 2" | append_conftest "functions"
+ else
+ CODE="
+ #include <linux/vmalloc.h>
+ #include <linux/stddef.h>
+ void conftest_vmalloc(void) {
+ void *addr = NULL;
+ addr = __vmalloc(1, 0, 0);
+ vfree(addr);
+ }" > conftest$$.c
+ $CC $CFLAGS -c conftest$$.c
+ if [ -f conftest$$.o ]; then
+ rm -f conftest$$.o
+ echo "#define NV_LINUX__VMALLOC_H_PRESENT" | append_conftest "functions"
+ echo "#define NV_LINUX__VMALLOC_H_ARGUMENT_COUNT 3" | append_conftest "functions"
+ else
+ echo "#undef NV_LINUX__VMALLOC_H_PRESENT" | append_conftest "functions"
+ fi
+ fi
+ ;;
drm_driver_has_set_busid)
#
diff --git a/nvidia/nvidia.Kbuild b/nvidia/nvidia.Kbuild
index 4db52a5..87e13ee 100644
--- a/nvidia/nvidia.Kbuild
+++ b/nvidia/nvidia.Kbuild
@@ -140,6 +140,7 @@ NV_CONFTEST_FUNCTION_COMPILE_TESTS += of_find_matching_node
NV_CONFTEST_FUNCTION_COMPILE_TESTS += dev_is_pci
NV_CONFTEST_FUNCTION_COMPILE_TESTS += dma_direct_map_resource
NV_CONFTEST_FUNCTION_COMPILE_TESTS += tegra_get_platform
+NV_CONFTEST_FUNCTION_COMPILE_TESTS += vmalloc
NV_CONFTEST_SYMBOL_COMPILE_TESTS += is_export_symbol_gpl_of_node_to_nid
NV_CONFTEST_SYMBOL_COMPILE_TESTS += is_export_symbol_present_swiotlb_map_sg_attrs
5d25be6 conftest.sh, common/inc/nv-linux.h: check for compat32.h header
diff --git a/common/inc/nv-linux.h b/common/inc/nv-linux.h
index 44b9233..1df85b4 100644
--- a/common/inc/nv-linux.h
+++ b/common/inc/nv-linux.h
@@ -165,8 +165,10 @@ static inline uid_t __kuid_val(uid_t uid)
#if defined(NVCPU_X86_64) && !defined(HAVE_COMPAT_IOCTL)
#include <linux/syscalls.h> /* sys_ioctl() */
+#if defined(NV_LINUX_IOCTL32_H_PRESENT)
#include <linux/ioctl32.h> /* register_ioctl32_conversion() */
#endif
+#endif
#if defined(CONFIG_VGA_ARB)
#include <linux/vgaarb.h>
diff --git a/conftest.sh b/conftest.sh
index 88f3891..70eca5a 100755
--- a/conftest.sh
+++ b/conftest.sh
@@ -117,6 +117,7 @@ test_headers() {
FILES="$FILES linux/sched/signal.h"
FILES="$FILES linux/sched/task.h"
FILES="$FILES linux/sched/task_stack.h"
+ FILES="$FILES linux/ioctl32.h"
FILES="$FILES xen/ioemu.h"
FILES="$FILES linux/fence.h"
FILES="$FILES soc/tegra/chip-id.h"
0c0810f conftest.sh, common/inc/nv-linux.h: check for linux/kmap_types.h header presence
diff --git a/common/inc/nv-linux.h b/common/inc/nv-linux.h
index 1ddecf3..44b9233 100644
--- a/common/inc/nv-linux.h
+++ b/common/inc/nv-linux.h
@@ -118,7 +118,12 @@
#include <linux/moduleparam.h> /* module_param() */
#include <asm/tlbflush.h> /* flush_tlb(), flush_tlb_all() */
+
+#if defined(NV_LINUX_KMAP_TYPES_H_PRESENT)
#include <asm/kmap_types.h> /* page table entry lookup */
+#elif !defined(_LINUX_MM_H)
+#include <linux/mm.h>
+#endif
#include <linux/pci.h> /* pci_find_class, etc */
#include <linux/interrupt.h> /* tasklets, interrupt helpers */
diff --git a/conftest.sh b/conftest.sh
index 5f8535e..88f3891 100755
--- a/conftest.sh
+++ b/conftest.sh
@@ -106,6 +106,7 @@ test_headers() {
FILES="$FILES linux/screen_info.h"
FILES="$FILES linux/semaphore.h"
FILES="$FILES linux/printk.h"
+ FILES="$FILES linux/kmap_types.h"
FILES="$FILES linux/ratelimit.h"
FILES="$FILES linux/prio_tree.h"
FILES="$FILES linux/log2.h"
0dffd24 common/inc/nv.h: check and include conftest.h
diff --git a/common/inc/nv.h b/common/inc/nv.h
index 364a88a..15daade 100644
--- a/common/inc/nv.h
+++ b/common/inc/nv.h
@@ -12,7 +12,9 @@
#ifndef _NV_H_
#define _NV_H_
-
+#ifndef _CONFTEST_H
+#include "conftest.h"
+#endif
#if !defined(NVLIMITS_H_MISSING)
#include <nvlimits.h>
@@ -22,6 +24,7 @@
#include <nvtypes.h>
#include <nvCpuUuid.h>
+
#if defined(NV_LINUX_STDARG_H_PRESENT)
#include <linux/stdarg.h>
#else
0e3f22a common/inc/nv-mm.h: use standard get_user_pages() and get_user_pages_remote() functions
diff --git a/common/inc/nv-mm.h b/common/inc/nv-mm.h
index 88c33fe..c206cdf 100644
--- a/common/inc/nv-mm.h
+++ b/common/inc/nv-mm.h
@@ -29,159 +29,12 @@
typedef int vm_fault_t;
#endif
-/* get_user_pages
- *
- * The 8-argument version of get_user_pages was deprecated by commit
- * (2016 Feb 12: cde70140fed8429acf7a14e2e2cbd3e329036653)for the non-remote case
- * (calling get_user_pages with current and current->mm).
- *
- * Completely moved to the 6 argument version of get_user_pages -
- * 2016 Apr 4: c12d2da56d0e07d230968ee2305aaa86b93a6832
- *
- * write and force parameters were replaced with gup_flags by -
- * 2016 Oct 12: 768ae309a96103ed02eb1e111e838c87854d8b51
- *
- * A 7-argument version of get_user_pages was introduced into linux-4.4.y by
- * commit 8e50b8b07f462ab4b91bc1491b1c91bd75e4ad40 which cherry-picked the
- * replacement of the write and force parameters with gup_flags
- *
- */
-
-#if defined(NV_GET_USER_PAGES_HAS_TASK_STRUCT)
- #if defined(NV_GET_USER_PAGES_HAS_WRITE_AND_FORCE_ARGS)
- #define NV_GET_USER_PAGES(start, nr_pages, write, force, pages, vmas) \
- get_user_pages(current, current->mm, start, nr_pages, write, force, pages, vmas)
- #else
- #include <linux/mm.h>
- #include <linux/sched.h>
-
- static inline long NV_GET_USER_PAGES(unsigned long start,
- unsigned long nr_pages,
- int write,
- int force,
- struct page **pages,
- struct vm_area_struct **vmas)
- {
- unsigned int flags = 0;
-
- if (write)
- flags |= FOLL_WRITE;
- if (force)
- flags |= FOLL_FORCE;
-
- return get_user_pages(current, current->mm, start, nr_pages, flags,
- pages, vmas);
- }
- #endif
+#if defined(NV_GET_USER_PAGES_PRESENT) || defined(NV_GET_USER_PAGES_REMOTE_PRESENT)
+#include <linux/mm.h>
#else
- #if defined(NV_GET_USER_PAGES_HAS_WRITE_AND_FORCE_ARGS)
- #define NV_GET_USER_PAGES get_user_pages
- #else
- #include <linux/mm.h>
-
- static inline long NV_GET_USER_PAGES(unsigned long start,
- unsigned long nr_pages,
- int write,
- int force,
- struct page **pages,
- struct vm_area_struct **vmas)
- {
- unsigned int flags = 0;
-
- if (write)
- flags |= FOLL_WRITE;
- if (force)
- flags |= FOLL_FORCE;
-
- return get_user_pages(start, nr_pages, flags, pages, vmas);
- }
- #endif
+#error Unknown function get_user_pages or get_user_pages_remote
#endif
-/* get_user_pages_remote() was added by:
- * 2016 Feb 12: 1e9877902dc7e11d2be038371c6fbf2dfcd469d7
- *
- * The very next commit (cde70140fed8429acf7a14e2e2cbd3e329036653)
- * deprecated the 8-argument version of get_user_pages for the
- * non-remote case (calling get_user_pages with current and current->mm).
- *
- * The guidelines are: call NV_GET_USER_PAGES_REMOTE if you need the 8-argument
- * version that uses something other than current and current->mm. Use
- * NV_GET_USER_PAGES if you are refering to current and current->mm.
- *
- * Note that get_user_pages_remote() requires the caller to hold a reference on
- * the task_struct (if non-NULL) and the mm_struct. This will always be true
- * when using current and current->mm. If the kernel passes the driver a vma
- * via driver callback, the kernel holds a reference on vma->vm_mm over that
- * callback.
- *
- * get_user_pages_remote() added 'locked' parameter
- * 2016 Dec 14:5b56d49fc31dbb0487e14ead790fc81ca9fb2c99
- */
-
-#if defined(NV_GET_USER_PAGES_REMOTE_PRESENT)
- #if defined(NV_GET_USER_PAGES_REMOTE_HAS_WRITE_AND_FORCE_ARGS)
- #define NV_GET_USER_PAGES_REMOTE get_user_pages_remote
- #else
- static inline long NV_GET_USER_PAGES_REMOTE(struct task_struct *tsk,
- struct mm_struct *mm,
- unsigned long start,
- unsigned long nr_pages,
- int write,
- int force,
- struct page **pages,
- struct vm_area_struct **vmas)
- {
- unsigned int flags = 0;
-
- if (write)
- flags |= FOLL_WRITE;
- if (force)
- flags |= FOLL_FORCE;
-
- #if defined(NV_GET_USER_PAGES_REMOTE_HAS_LOCKED_ARG)
-
- return get_user_pages_remote(tsk, mm, start, nr_pages, flags,
- pages, vmas, NULL);
-
- #else
-
- return get_user_pages_remote(tsk, mm, start, nr_pages, flags,
- pages, vmas);
-
- #endif
-
- }
- #endif
-#else
- #if defined(NV_GET_USER_PAGES_HAS_WRITE_AND_FORCE_ARGS)
- #define NV_GET_USER_PAGES_REMOTE get_user_pages
- #else
- #include <linux/mm.h>
- #include <linux/sched.h>
-
- static inline long NV_GET_USER_PAGES_REMOTE(struct task_struct *tsk,
- struct mm_struct *mm,
- unsigned long start,
- unsigned long nr_pages,
- int write,
- int force,
- struct page **pages,
- struct vm_area_struct **vmas)
- {
- unsigned int flags = 0;
-
- if (write)
- flags |= FOLL_WRITE;
- if (force)
- flags |= FOLL_FORCE;
-
- return get_user_pages(tsk, mm, start, nr_pages, flags, pages, vmas);
- }
- #endif
-#endif
-
-
/*
* The .virtual_address field was effectively renamed to .address, by these
* two commits:
b8daf9d conftest.sh: correctly checking for get_user_pages() and get_user_pages_remote() presence
diff --git a/conftest.sh b/conftest.sh
index e64e23a..5f8535e 100755
--- a/conftest.sh
+++ b/conftest.sh
@@ -2195,205 +2195,67 @@ compile_test() {
;;
get_user_pages)
#
- # Conftest for get_user_pages()
+ # Determine if the function get_user_pages() is present
#
- # Use long type for get_user_pages and unsigned long for nr_pages
- # by commit 28a35716d317 ("mm: use long type for page counts
- # in mm_populate() and get_user_pages()") in v3.9 (2013-02-22)
- #
- # Removed struct task_struct *tsk & struct mm_struct *mm from
- # get_user_pages by commit cde70140fed8 ("mm/gup: Overload
- # get_user_pages() functions") in v4.6 (2016-02-12)
- #
- # Replaced get_user_pages6 with get_user_pages by commit
- # c12d2da56d0e ("mm/gup: Remove the macro overload API migration
- # helpers from the get_user*() APIs") in v4.6 (2016-04-04)
- #
- # Replaced write and force parameters with gup_flags by
- # commit 768ae309a961 ("mm: replace get_user_pages() write/force
- # parameters with gup_flags") in v4.9 (2016-10-13)
- #
- # linux-4.4.168 cherry-picked commit 768ae309a961 without
- # c12d2da56d0e which is covered in Conftest #3.
- #
- # Conftest #1: Check if get_user_pages accepts 6 arguments.
- # Return if true.
- # Fall through to conftest #2 on failure.
- #
- echo "$CONFTEST_PREAMBLE
- #include <linux/mm.h>
- long get_user_pages(unsigned long start,
- unsigned long nr_pages,
- int write,
- int force,
- struct page **pages,
- struct vm_area_struct **vmas) {
- return 0;
- }" > conftest$$.c
-
- $CC $CFLAGS -c conftest$$.c > /dev/null 2>&1
- rm -f conftest$$.c
- if [ -f conftest$$.o ]; then
- echo "#define NV_GET_USER_PAGES_HAS_WRITE_AND_FORCE_ARGS" | append_conftest "functions"
- echo "#undef NV_GET_USER_PAGES_HAS_TASK_STRUCT" | append_conftest "functions"
- rm -f conftest$$.o
- return
- fi
-
- # Conftest #2: Check if get_user_pages has gup_flags instead of
- # write and force parameters. And that gup doesn't accept a
- # task_struct and mm_struct as its first arguments.
- # Return if available.
- # Fall through to conftest #3 on failure.
-
- echo "$CONFTEST_PREAMBLE
- #include <linux/mm.h>
- long get_user_pages(unsigned long start,
- unsigned long nr_pages,
- unsigned int gup_flags,
- struct page **pages,
- struct vm_area_struct **vmas) {
- return 0;
- }" > conftest$$.c
-
- $CC $CFLAGS -c conftest$$.c > /dev/null 2>&1
- rm -f conftest$$.c
-
- if [ -f conftest$$.o ]; then
- echo "#undef NV_GET_USER_PAGES_HAS_WRITE_AND_FORCE_ARGS" | append_conftest "functions"
- echo "#undef NV_GET_USER_PAGES_HAS_TASK_STRUCT" | append_conftest "functions"
- rm -f conftest$$.o
- return
- fi
-
- # Conftest #3: Check if get_user_pages has gup_flags instead of
- # write and force parameters AND that gup has task_struct and
- # mm_struct as its first arguments.
- # Return if available.
- # Fall through to default case if absent.
-
echo "$CONFTEST_PREAMBLE
+ #include <linux/version.h>
#include <linux/mm.h>
- long get_user_pages(struct task_struct *tsk,
- struct mm_struct *mm,
- unsigned long start,
- unsigned long nr_pages,
- unsigned int gup_flags,
- struct page **pages,
- struct vm_area_struct **vmas) {
+ int conftest_get_user_pages(void) {
+ #if LINUX_VERSION_CODE < KERNEL_VERSION(3, 0, 0)
+ long get_user_pages(unsigned long start, unsigned long nr_pages, int write, int force, struct page **pages,
+ struct vm_area_struct **vmas);
+ #elif LINUX_VERSION_CODE < KERNEL_VERSION(5, 0, 0)
+ long get_user_pages(unsigned long start, int nr_pages, int write, struct page **pages, stuct mv_area_struct **vmas);
+ #elif LINUX_VERSION_CODE >= KERNEL_VERSION(5, 0, 0)
+ long get_user_pages(unsigned long start, unsigned long nr_pages, unsigned int gup_flags, struct page **pages);
+ #endif
return 0;
}" > conftest$$.c
$CC $CFLAGS -c conftest$$.c > /dev/null 2>&1
rm -f conftest$$.c
-
if [ -f conftest$$.o ]; then
- echo "#undef NV_GET_USER_PAGES_HAS_WRITE_AND_FORCE_ARGS" | append_conftest "functions"
- echo "#define NV_GET_USER_PAGES_HAS_TASK_STRUCT" | append_conftest "functions"
+ echo "#define NV_GET_USER_PAGES_PRESENT" | append_conftest "functions"
rm -f conftest$$.o
return
+ else
+ echo "#undef NV_GET_USER_PAGES_PRESENT" | append_conftest "functions"
fi
-
- echo "#define NV_GET_USER_PAGES_HAS_WRITE_AND_FORCE_ARGS" | append_conftest "functions"
- echo "#define NV_GET_USER_PAGES_HAS_TASK_STRUCT" | append_conftest "functions"
-
- return
;;
get_user_pages_remote)
#
- # Determine if the function get_user_pages_remote() is
- # present and has write/force parameters.
- #
- # get_user_pages_remote() was added by commit 1e9877902dc7
- # ("mm/gup: Introduce get_user_pages_remote()") in v4.6 (2016-02-12)
- #
- # get_user_pages[_remote]() write/force parameters
- # replaced with gup_flags by commits 768ae309a961 ("mm: replace
- # get_user_pages() write/force parameters with gup_flags") and
- # commit 9beae1ea8930 ("mm: replace get_user_pages_remote()
- # write/force parameters with gup_flags") in v4.9 (2016-10-13)
- #
- # get_user_pages_remote() added 'locked' parameter by
- # commit 5b56d49fc31d ("mm: add locked parameter to
- # get_user_pages_remote()") in v4.10 (2016-12-14)
+ # Determine if the function get_user_pages_remote() is present
#
- # conftest #1: check if get_user_pages_remote() is available
- # return if not available.
- # Fall through to conftest #2 if it is present
- #
- echo "$CONFTEST_PREAMBLE
- #include <linux/mm.h>
- void conftest_get_user_pages_remote(void) {
- get_user_pages_remote();
- }" > conftest$$.c
- $CC $CFLAGS -c conftest$$.c > /dev/null 2>&1
- rm -f conftest$$.c
-
- if [ -f conftest$$.o ]; then
- echo "#undef NV_GET_USER_PAGES_REMOTE_PRESENT" | append_conftest "functions"
- echo "#undef NV_GET_USER_PAGES_REMOTE_HAS_WRITE_AND_FORCE_ARGS" | append_conftest "functions"
- echo "#undef NV_GET_USER_PAGES_REMOTE_HAS_LOCKED_ARG" | append_conftest "functions"
- rm -f conftest$$.o
- return
- fi
-
- #
- # conftest #2: check if get_user_pages_remote() has write and
- # force arguments. Return if these arguments are present
- # Fall through to conftest #3 if these args are absent.
- #
- echo "#define NV_GET_USER_PAGES_REMOTE_PRESENT" | append_conftest "functions"
echo "$CONFTEST_PREAMBLE
+ #include <linux/version.h>
#include <linux/mm.h>
- long get_user_pages_remote(struct task_struct *tsk,
- struct mm_struct *mm,
- unsigned long start,
- unsigned long nr_pages,
- int write,
- int force,
- struct page **pages,
- struct vm_area_struct **vmas) {
- return 0;
+ int conftest_get_user_pages_remote(void) {
+ #if LINUX_VERSION_CODE <= KERNEL_VERSION(4, 6, 0)
+ long get_user_pages_remote(struct task_struct *tsk, struct mm_struct *mm, unsigned long start,
+ unsigned long nr_pages, int write, int force, struct page **pages,
+ struct vm_area_struct **vmas);
+ #elif LINUX_VERSION_CODE < KERNEL_VERSION(6, 0, 0)
+ int get_user_pages_remote(struct task_struct *task, unsigned long start, unsigned long nr_pages,
+ int write, struct page **pages, struct mm_struct **mm);
+ #elif LINUX_VERSION_CODE >= KERNEL_VERSION(6, 0, 0)
+ long get_user_pages_remote(struct mm_struct *mm, unsigned long start, unsigned long nr_pages,
+ unsigned int gup_flags, struct page **pages, int *locked);
+ #endif
+ return 0;
}" > conftest$$.c
$CC $CFLAGS -c conftest$$.c > /dev/null 2>&1
rm -f conftest$$.c
if [ -f conftest$$.o ]; then
- echo "#define NV_GET_USER_PAGES_REMOTE_HAS_WRITE_AND_FORCE_ARGS" | append_conftest "functions"
- echo "#undef NV_GET_USER_PAGES_REMOTE_HAS_LOCKED_ARG" | append_conftest "functions"
+ echo "#define NV_GET_USER_PAGES_REMOTE_PRESENT" | append_conftest "functions"
rm -f conftest$$.o
return
- fi
-
- # conftest #3: check if get_user_pages_remote() has locked argument
-
- echo "$CONFTEST_PREAMBLE
- #include <linux/mm.h>
- long get_user_pages_remote(struct task_struct *tsk,
- struct mm_struct *mm,
- unsigned long start,
- unsigned long nr_pages,
- unsigned int gup_flags,
- struct page **pages,
- struct vm_area_struct **vmas,
- int *locked) {
- return 0;
- }" > conftest$$.c
-
- $CC $CFLAGS -c conftest$$.c > /dev/null 2>&1
- rm -f conftest$$.c
-
- if [ -f conftest$$.o ]; then
- echo "#define NV_GET_USER_PAGES_REMOTE_HAS_LOCKED_ARG" | append_conftest "functions"
- rm -f conftest$$.o
else
- echo "#undef NV_GET_USER_PAGES_REMOTE_HAS_LOCKED_ARG" | append_conftest "functions"
+ echo "#undef NV_GET_USER_PAGES_REMOTE_PRESENT" | append_conftest "functions"
fi
- echo "#undef NV_GET_USER_PAGES_REMOTE_HAS_WRITE_AND_FORCE_ARGS" | append_conftest "functions"
-
;;
usleep_range)
8da5c83 Kbuild, conftest.sh nvidia-modeset/nvidia-modeset-os-interface.h, nvidia-modeset/nvkms.h: include conftest.h, check presence and use linux/stddef.h, use NVIDIA_UNDEF_LEGACY_BIT_MACROS
diff --git a/Kbuild b/Kbuild
index 4476d85..e19e064 100644
--- a/Kbuild
+++ b/Kbuild
@@ -63,7 +63,7 @@ ccflags-y += -D__KERNEL__ -DMODULE -DNVRM -DNV_VERSION_STRING=\"435.17\" -Wno-un
ccflags-y += -fno-strict-aliasing -mno-red-zone -mcmodel=kernel -DNV_UVM_ENABLE
ccflags-y += $(call cc-option,-Werror=undef,)
ccflags-y += -DNV_SPECTRE_V2=1
-ccflags-y += -DNV_UNDEF_LEGACY_BIT_MACRO
+ccflags-y += -DNVIDIA_UNDEF_LEGACY_BIT_MACROS
#
# Detect SGI UV systems and apply system-specific optimizations.
diff --git a/conftest.sh b/conftest.sh
index e2e6d18..e64e23a 100755
--- a/conftest.sh
+++ b/conftest.sh
@@ -121,6 +121,7 @@ test_headers() {
FILES="$FILES soc/tegra/chip-id.h"
FILES="$FILES video/nv_internal.h"
FILES="$FILES linux/stdarg.h"
+ FILES="$FILES linux/stddef.h"
# Arch specific headers which need testing
FILES_ARCH="asm/book3s/64/hash-64k.h"
@@ -134,7 +135,7 @@ test_headers() {
}
build_cflags() {
- BASE_CFLAGS="-std=gnu17 -DNV_UNDEF_LEGACY_BIT_MACRO -O2 -D__KERNEL__ \
+ BASE_CFLAGS="-std=gnu17 -DNVIDIA_UNDEF_LEGACY_BIT_MACROS -O2 -D__KERNEL__ \
-DKBUILD_BASENAME=\"#conftest$$\" -DKBUILD_MODNAME=\"#conftest$$\" \
-nostdinc -isystem $ISYSTEM"
diff --git a/nvidia-modeset/nvidia-modeset-os-interface.h b/nvidia-modeset/nvidia-modeset-os-interface.h
index aecb2bb..b5df814 100644
--- a/nvidia-modeset/nvidia-modeset-os-interface.h
+++ b/nvidia-modeset/nvidia-modeset-os-interface.h
@@ -12,11 +12,15 @@
* Define the entry points which the NVKMS kernel interface layer
* provides to core NVKMS.
*/
-
+#include "conftest.h"
#if !defined(_NVIDIA_MODESET_OS_INTERFACE_H_)
#define _NVIDIA_MODESET_OS_INTERFACE_H_
-#include <stddef.h> /* size_t */
+#if defined(NV_LINUX_STDDEF_H_PRESENT)
+#include <linux/stddef.h> /* size_t */
+#else
+#include <stddef.h>
+#endif
#if defined(NV_LINUX_STDARG_H_PRESENT)
#include <linux/stdarg.h> /* va_list */
#else
diff --git a/nvidia-modeset/nvkms.h b/nvidia-modeset/nvkms.h
index d99904f..6f7ca3f 100644
--- a/nvidia-modeset/nvkms.h
+++ b/nvidia-modeset/nvkms.h
@@ -9,7 +9,12 @@
#define __NV_KMS_H__
#include "nvtypes.h"
-#include <stddef.h> /* size_t */
+
+#if defined(NV_LINUX_STDDEF_H_PRESENT)
+#include <linux/stddef.h>
+#else
+#include <stddef.h> /* size_t */
+#endif
#include "nvkms-kapi.h"
31bff0a conftest.sh, common/inc/nv-linux.h: wait_on_bit_lock() from wait_bit.h
diff --git a/common/inc/nv-linux.h b/common/inc/nv-linux.h
index 97af7fa..1ddecf3 100644
--- a/common/inc/nv-linux.h
+++ b/common/inc/nv-linux.h
@@ -84,6 +84,9 @@
#include <linux/list.h> /* circular linked list */
#include <linux/stddef.h> /* NULL, offsetof */
#include <linux/wait.h> /* wait queues */
+#if defined(NV_LINUX_WAIT_BIT_H_PRESENT)
+#include <linux/wait_bit.h> /* wait_on_bit_lock() */
+#endif
#include <linux/string.h> /* strchr(), strpbrk() */
#include <linux/ctype.h> /* isspace(), etc */
diff --git a/conftest.sh b/conftest.sh
index 9c87d6c..e2e6d18 100755
--- a/conftest.sh
+++ b/conftest.sh
@@ -111,6 +111,8 @@ test_headers() {
FILES="$FILES linux/log2.h"
FILES="$FILES linux/of.h"
FILES="$FILES linux/bug.h"
+ FILES="$FILES linux/wait.h"
+ FILES="$FILES linux/wait_bit.h"
FILES="$FILES linux/sched/signal.h"
FILES="$FILES linux/sched/task.h"
FILES="$FILES linux/sched/task_stack.h"
@@ -1999,6 +2001,7 @@ compile_test() {
if [ -f conftest$$.o ]; then
rm -f conftest$$.o
echo "#define NV_WAIT_ON_BIT_LOCK_ARGUMENT_COUNT 3" | append_conftest "functions"
+ echo "#define NV_WAIT_ON_BIT_LOCK_FROM_WAIT_H_PRESENT" | append_conftest "functions"
return
fi
@@ -2014,8 +2017,47 @@ compile_test() {
if [ -f conftest$$.o ]; then
rm -f conftest$$.o
echo "#define NV_WAIT_ON_BIT_LOCK_ARGUMENT_COUNT 4" | append_conftest "functions"
+ echo "#define NV_WAIT_ON_BIT_LOCK_FROM_WAIT_H_PRESENT" | append_conftest "functions"
return
fi
+ echo "#undef NV_WAIT_ON_BIT_LOCK_FROM_WAIT_H_PRESENT" | append_conftest "functions"
+
+ # We should keep using linux/wait.h and an alternative API, wait_event().
+ # But kernels 6.0 and higher still provides wait_on_bit_lock, see linux/wat_bit.h
+ # TODO: use alternative API.
+ # Test if function requires 3 args
+ echo "$CONFTEST_PREAMBLE
+ #include <linux/wait_bit.h>
+ void conftest_wait_on_bit_lock(void) {
+ wait_on_bit_lock(NULL, 0, 0);
+ }" > conftest$$.c
+
+ $CC $CFLAGS -c conftest$$.c > /dev/null 2>&1
+ rm -f conftest$$.c
+
+ if [ -f conftest$$.o ]; then
+ rm -f conftest$$.o
+ echo "#define NV_WAIT_ON_BIT_LOCK_ARGUMENT_COUNT 3" | append_conftest "functions"
+ echo "#define NV_WAIT_ON_BIT_LOCK_FROM_WAIT_BIT_H_PRESENT" | append_conftest "functions"
+ return
+ fi
+ # Test if linux/wait.h provides alternate mechanism. Test if 4 args
+ echo "$CONFTEST_PREAMBLE
+ #include <linux/wait_bit.h>
+ void conftest_wait_on_bit_lock(void) {
+ wait_on_bit_lock(NULL, 0, NULL, 0);
+ }" > conftest$$.c
+
+ $CC $CFLAGS -c conftest$$.c > /dev/null 2>&1
+ rm -f conftest$$.c
+
+ if [ -f conftest$$.o ]; then
+ rm -f conftest$$.o
+ echo "#define NV_WAIT_ON_BIT_ARGUMENT_COUNT 4" | append_conftest "functions"
+ echo "#define NV_WAIT_ON_BIT_LOCK_FROM_WAIT_BIT_H_PRESENT" | append_conftest "functions"
+ return
+ fi
+
echo "#error wait_on_bit_lock() conftest failed!" | append_conftest "functions"
;;
13a3dfc conftest.sh: add UNDEF_LEGACY_BIT_MACRO and -std=gnu17 in BASE_CFLAGS
diff --git a/conftest.sh b/conftest.sh
index af3e2b7..9c87d6c 100755
--- a/conftest.sh
+++ b/conftest.sh
@@ -132,7 +132,7 @@ test_headers() {
}
build_cflags() {
- BASE_CFLAGS="-O2 -D__KERNEL__ \
+ BASE_CFLAGS="-std=gnu17 -DNV_UNDEF_LEGACY_BIT_MACRO -O2 -D__KERNEL__ \
-DKBUILD_BASENAME=\"#conftest$$\" -DKBUILD_MODNAME=\"#conftest$$\" \
-nostdinc -isystem $ISYSTEM"
b1bd493 common/inc/nv.h: fix typo
diff --git a/common/inc/nv.h b/common/inc/nv.h
index d850cae..364a88a 100644
--- a/common/inc/nv.h
+++ b/common/inc/nv.h
@@ -22,7 +22,7 @@
#include <nvtypes.h>
#include <nvCpuUuid.h>
-#if definde(NV_LINUX_STDARG_H_PRESENT)
+#if defined(NV_LINUX_STDARG_H_PRESENT)
#include <linux/stdarg.h>
#else
#include <stdarg.h>
863f5f4 common/inc/os-interface.h: include conftest.h
diff --git a/common/inc/os-interface.h b/common/inc/os-interface.h
index ee985da..f7d2034 100644
--- a/common/inc/os-interface.h
+++ b/common/inc/os-interface.h
@@ -23,6 +23,7 @@
* Operating system wrapper functions used to abstract the OS. *
* *
\***************************************************************************/
+#include "conftest.h"
#if defined(NV_LINUX_STDARG_H_PRESENT)
#include <linux/stdarg.h>
#else
bcd5da1 Kbuild: add forgotten double quotes
diff --git a/Kbuild b/Kbuild
index e45c605..4476d85 100644
--- a/Kbuild
+++ b/Kbuild
@@ -96,7 +96,7 @@ NV_CONFTEST_HEADER := $(obj)/conftest/headers.h
NV_CONFTEST_CMD := /bin/sh $(NV_CONFTEST_SCRIPT) \
"$(CC)" $(ARCH) $(NV_KERNEL_SOURCES) $(NV_KERNEL_OUTPUT)
-NV_CONFTEST_CFLAGS := $(shell CFLAGS=$(ccflags-y) $(NV_CONFTEST_CMD) build_cflags)
+NV_CONFTEST_CFLAGS := $(shell CFLAGS="$(ccflags-y)" $(NV_CONFTEST_CMD) build_cflags)
NV_CONFTEST_COMPILE_TEST_HEADERS := $(obj)/conftest/macros.h
NV_CONFTEST_COMPILE_TEST_HEADERS += $(obj)/conftest/functions.h
8110a70 common/inc/nv.h common/inc/os-interface.h conftest.sh nvidia-modeset/nvidia-modeset-os-interface.h nvidia-uvm/uvm8_mmu.c: include linux/stdarg.h instead of one from glibc
diff --git a/common/inc/nv.h b/common/inc/nv.h
index 1247711..d850cae 100644
--- a/common/inc/nv.h
+++ b/common/inc/nv.h
@@ -22,7 +22,11 @@
#include <nvtypes.h>
#include <nvCpuUuid.h>
+#if definde(NV_LINUX_STDARG_H_PRESENT)
+#include <linux/stdarg.h>
+#else
#include <stdarg.h>
+#endif
#if !defined(NV_KERNEL_INTERFACE_API_H_MISSING)
#include <nv-kernel-interface-api.h>
diff --git a/common/inc/os-interface.h b/common/inc/os-interface.h
index 5d9090f..ee985da 100644
--- a/common/inc/os-interface.h
+++ b/common/inc/os-interface.h
@@ -23,8 +23,11 @@
* Operating system wrapper functions used to abstract the OS. *
* *
\***************************************************************************/
-
+#if defined(NV_LINUX_STDARG_H_PRESENT)
+#include <linux/stdarg.h>
+#else
#include <stdarg.h>
+#endif
#include <nv-kernel-interface-api.h>
#include "nvipmi.h"
diff --git a/conftest.sh b/conftest.sh
index c00c826..af3e2b7 100755
--- a/conftest.sh
+++ b/conftest.sh
@@ -118,6 +118,7 @@ test_headers() {
FILES="$FILES linux/fence.h"
FILES="$FILES soc/tegra/chip-id.h"
FILES="$FILES video/nv_internal.h"
+ FILES="$FILES linux/stdarg.h"
# Arch specific headers which need testing
FILES_ARCH="asm/book3s/64/hash-64k.h"
diff --git a/nvidia-modeset/nvidia-modeset-os-interface.h b/nvidia-modeset/nvidia-modeset-os-interface.h
index a7bb7c9..aecb2bb 100644
--- a/nvidia-modeset/nvidia-modeset-os-interface.h
+++ b/nvidia-modeset/nvidia-modeset-os-interface.h
@@ -17,7 +17,11 @@
#define _NVIDIA_MODESET_OS_INTERFACE_H_
#include <stddef.h> /* size_t */
-#include <stdarg.h> /* va_list */
+#if defined(NV_LINUX_STDARG_H_PRESENT)
+#include <linux/stdarg.h> /* va_list */
+#else
+#include <stdarg.h>
+#endif
#include "nvtypes.h" /* NvU8 */
diff --git a/nvidia-uvm/uvm8_mmu.c b/nvidia-uvm/uvm8_mmu.c
index 9166586..a7b0987 100644
--- a/nvidia-uvm/uvm8_mmu.c
+++ b/nvidia-uvm/uvm8_mmu.c
@@ -21,6 +21,7 @@
*******************************************************************************/
+#include "conftest.h"
#include "uvmtypes.h"
#include "uvm8_forward_decl.h"
#include "uvm8_gpu.h"
@@ -32,7 +33,11 @@
#include "uvm8_push.h"
#include "uvm8_mem.h"
#include "uvm8_va_space.h"
+#if defined(NV_LINUX_STDARG_H_PRESENT)
+#include <linux/stdarg.h>
+#else
#include <stdarg.h>
+#endif
// The page tree has 5 levels on pascal, and the root is never freed by a normal 'put' operation
// which leaves a maximum of 4 levels
fb6c76b conftest.sh: correcty provide CFLAGS from Kbuild to conftest.sh
diff --git a/Kbuild b/Kbuild
index 668ce14..e45c605 100644
--- a/Kbuild
+++ b/Kbuild
@@ -56,19 +56,21 @@ $(foreach _module, $(NV_KERNEL_MODULES), \
# $(EXTRA_CFLAGS) to ccflags-y for compatibility.
#
-EXTRA_CFLAGS += -I$(src)/common/inc
-EXTRA_CFLAGS += -I$(src)
-EXTRA_CFLAGS += -Wall -MD $(DEFINES) $(INCLUDES) -Wno-cast-qual -Wno-error -Wno-format-extra-args
-EXTRA_CFLAGS += -D__KERNEL__ -DMODULE -DNVRM -DNV_VERSION_STRING=\"435.17\" -Wno-unused-function -Wuninitialized -fno-strict-aliasing -mno-red-zone -mcmodel=kernel -DNV_UVM_ENABLE
-EXTRA_CFLAGS += $(call cc-option,-Werror=undef,)
-EXTRA_CFLAGS += -DNV_SPECTRE_V2=$(NV_SPECTRE_V2)
+ccflags-y += -I$(src)/common/inc
+ccflags-y += -I$(src)
+ccflags-y += -Wall -MD $(DEFINES) $(INCLUDES) -Wno-cast-qual -Wno-error -Wno-format-extra-args
+ccflags-y += -D__KERNEL__ -DMODULE -DNVRM -DNV_VERSION_STRING=\"435.17\" -Wno-unused-function -Wuninitialized
+ccflags-y += -fno-strict-aliasing -mno-red-zone -mcmodel=kernel -DNV_UVM_ENABLE
+ccflags-y += $(call cc-option,-Werror=undef,)
+ccflags-y += -DNV_SPECTRE_V2=1
+ccflags-y += -DNV_UNDEF_LEGACY_BIT_MACRO
#
# Detect SGI UV systems and apply system-specific optimizations.
#
ifneq ($(wildcard /proc/sgi_uv),)
- EXTRA_CFLAGS += -DNV_CONFIG_X86_UV
+ ccflags-y += -DNV_CONFIG_X86_UV
endif
@@ -94,7 +96,7 @@ NV_CONFTEST_HEADER := $(obj)/conftest/headers.h
NV_CONFTEST_CMD := /bin/sh $(NV_CONFTEST_SCRIPT) \
"$(CC)" $(ARCH) $(NV_KERNEL_SOURCES) $(NV_KERNEL_OUTPUT)
-NV_CONFTEST_CFLAGS := $(shell $(NV_CONFTEST_CMD) build_cflags)
+NV_CONFTEST_CFLAGS := $(shell CFLAGS=$(ccflags-y) $(NV_CONFTEST_CMD) build_cflags)
NV_CONFTEST_COMPILE_TEST_HEADERS := $(obj)/conftest/macros.h
NV_CONFTEST_COMPILE_TEST_HEADERS += $(obj)/conftest/functions.hAny ideas? Main goal is to provide the package.
Last edited by yars068 (2025-08-16 20:10:22)
Offline
GeForce 710M is a GF117M chip ie. Fermi?
According to https://www.nvidia.com/en-us/drivers/details/149785/ the driver only supports the GeForce GT 710 which is a GK208 Kepler chip?
Offline
GeForce 710M is a GF117M chip ie. Fermi?
Yes. Hmm, yes, this is my mistake here. My chip supports by only 390xx legacy driver
I see the driver's readme by searching device IDs, which is "17aa:3902", but yes, scroll up and see that is only legacy. Any way, this gave me some experience on building nvidia drivers. Thanks.
UPD. There is new 396.24 driver, which should support GeForce 710M, so then I will try to build it.
Last edited by yars068 (2025-08-16 21:30:25)
Offline
17aa:3902 isn't a(n nvidia) device ID, you're looking for something that starts w/ "10de", but lspci will also list the chip name.
And don't feel sorry:
If I had it my way, the marketing staff of the various HW vendors (and starting w/ nvidia and AMD for sure) would be lined up to stick their hands into boxes with snakes. Some are venomous, some are not.
But the boxes are only labeled with how scary I feel the snake looks.
Which is about as accurate or misleading as their branding strategies.
Offline
UPD. There is new 396.24 driver, which should support GeForce 710M, so then I will try to build it.
What gives you that idea?
https://wiki.archlinux.org/title/NVIDIA#Installation to do this right.
Offline
17aa:3902 isn't a(n nvidia) device ID, you're looking for something that starts w/ "10de", but lspci will also list the chip name.
Yes, 10de is Nvidia ID, but this affects a desktop cards. 17aa:3902 is Lenovo ID, but actual manufacturer is Nvidia:
sudo lspci -knns 1:0
[sudo] password for yars:
01:00.0 3D controller [0302]: NVIDIA Corporation GF117M [GeForce 610M/710M/810M/820M / GT 620M/625M/630M/720M] [10de:1140] (rev a1)
Subsystem: Lenovo GeForce 710M [17aa:3902]
Kernel modules: nouveauOffline
yars068 wrote:UPD. There is new 396.24 driver, which should support GeForce 710M, so then I will try to build it.
What gives you that idea?
https://wiki.archlinux.org/title/NVIDIA#Installation to do this right.
Not sure that PRIME render offloading will works on 390xx driver, I was used this driver with Bumblebee. Also 396xx driver have some improvements and fixes compared to 390xx. So I tried to up the driver version to latest that supports my hardware.
Last edited by yars068 (2025-08-17 06:16:46)
Offline
Where does https://www.nvidia.com/en-us/drivers/details/133863/ list the 710M ?
It does absolutely not matter in what kind of case Lenovo jammed it, it's still a Fermi chip.
Is this an https://en.wikipedia.org/wiki/XY_problem ?
Offline
Where does https://www.nvidia.com/en-us/drivers/details/133863/ list the 710M ?
See https://download.nvidia.com/XFree86/Lin … chips.html.
Is this an https://en.wikipedia.org/wiki/XY_problem ?
No, this is not XY problem.
It does absolutely not matter in what kind of case Lenovo jammed it, it's still a Fermi chip.
Yes, I know.
UPD. GeForce 710M appears many times in the readme's Appendix A, with different PCI device ID, PCI subsystem vendor ID and PCI subsystem device ID. But if my chip is only mentioned as Lenovo device, so I should keep using 390xx driver...
Last edited by yars068 (2025-08-17 08:45:21)
Offline
1140 is only listed under
The 390.xx driver supports the following set of GPUs:
?
Offline
1140 is only listed under
The 390.xx driver supports the following set of GPUs:
?
No, but 1140 10de -- no match. But 17aa 3902 -- is only under this line. This is Kepler chip, not Fermi.
Last edited by yars068 (2025-08-17 09:07:53)
Offline
No, it's GF1XX, not GKXXX. It's Fermi, and the 390 series was the last driver to support it, no matter how hard you wish.
Offline
17aa is lenovo's vendor id and of course matches several kepler (and maxwell, turing, ada,, ... chips but your exact chip (17aa 3902) is aliased to 1140 and only listed under 390xx (since, as Scimmia pointed out, this is the last driver to support Fermi chips)
Offline
Pages: 1