commit 0ab86d9dd06441e6cc9f6f1bb3064edb25476c14
Author: Łukasz Wojniłowicz <lukasz.wojnilowicz(a)gmail.com>
Date: Fri Jan 21 20:08:55 2022 +0100
Reduce the patchset to two patches
fix-build-issues.patch | 1605 ++++++++++++++++
...l-5.11.patch => import-files-from-390.147.patch | 1987 ++++----------------
kernel-5.10.patch | 24 -
kernel-5.14.patch | 148 --
kernel-5.7.patch | 744 --------
kernel-5.8.patch | 71 -
kernel-5.9.patch | 88 -
nv-linux-arm.patch | 12 -
nvidia-340xx-kmod.spec | 21 +-
9 files changed, 1943 insertions(+), 2757 deletions(-)
---
diff --git a/fix-build-issues.patch b/fix-build-issues.patch
new file mode 100644
index 0000000..3d83e75
--- /dev/null
+++ b/fix-build-issues.patch
@@ -0,0 +1,1605 @@
+diff -Naur a/kernel/conftest.Kbuild b/kernel/conftest.Kbuild
+--- a/kernel/conftest.Kbuild 1970-01-01 01:00:00.000000000 +0100
++++ b/kernel/conftest.Kbuild 2022-01-21 18:38:55.073844408 +0100
+@@ -0,0 +1,212 @@
++NV_CONFTEST_GENERIC_COMPILE_TESTS += drm_available
++NV_CONFTEST_GENERIC_COMPILE_TESTS += drm_atomic_available
++NV_CONFTEST_GENERIC_COMPILE_TESTS += dom0_kernel_present
++NV_CONFTEST_GENERIC_COMPILE_TESTS += nvmap_support
++
++NV_CONFTEST_FUNCTION_COMPILE_TESTS += remap_pfn_range
++NV_CONFTEST_FUNCTION_COMPILE_TESTS += vmap
++NV_CONFTEST_FUNCTION_COMPILE_TESTS += set_pages_uc
++NV_CONFTEST_FUNCTION_COMPILE_TESTS += set_memory_uc
++NV_CONFTEST_FUNCTION_COMPILE_TESTS += set_memory_array_uc
++NV_CONFTEST_FUNCTION_COMPILE_TESTS += change_page_attr
++NV_CONFTEST_FUNCTION_COMPILE_TESTS += pci_get_class
++NV_CONFTEST_FUNCTION_COMPILE_TESTS += pci_choose_state
++NV_CONFTEST_FUNCTION_COMPILE_TESTS += vm_insert_page
++NV_CONFTEST_FUNCTION_COMPILE_TESTS += acquire_console_sem
++NV_CONFTEST_FUNCTION_COMPILE_TESTS += console_lock
++NV_CONFTEST_FUNCTION_COMPILE_TESTS += kmem_cache_create
++NV_CONFTEST_FUNCTION_COMPILE_TESTS += kmem_cache_create_usercopy
++NV_CONFTEST_FUNCTION_COMPILE_TESTS += on_each_cpu
++NV_CONFTEST_FUNCTION_COMPILE_TESTS += smp_call_function
++NV_CONFTEST_FUNCTION_COMPILE_TESTS += acpi_evaluate_integer
++NV_CONFTEST_FUNCTION_COMPILE_TESTS += ioremap_cache
++NV_CONFTEST_FUNCTION_COMPILE_TESTS += ioremap_nocache
++NV_CONFTEST_FUNCTION_COMPILE_TESTS += ioremap_wc
++NV_CONFTEST_FUNCTION_COMPILE_TESTS += acpi_walk_namespace
++NV_CONFTEST_FUNCTION_COMPILE_TESTS += pci_domain_nr
++NV_CONFTEST_FUNCTION_COMPILE_TESTS += pci_dma_mapping_error
++NV_CONFTEST_FUNCTION_COMPILE_TESTS += file_operations
++NV_CONFTEST_FUNCTION_COMPILE_TESTS += proc_ops
++NV_CONFTEST_FUNCTION_COMPILE_TESTS += sg_alloc_table
++NV_CONFTEST_FUNCTION_COMPILE_TESTS += sg_init_table
++NV_CONFTEST_FUNCTION_COMPILE_TESTS += pci_get_domain_bus_and_slot
++NV_CONFTEST_FUNCTION_COMPILE_TESTS += get_num_physpages
++NV_CONFTEST_FUNCTION_COMPILE_TESTS += proc_create_data
++NV_CONFTEST_FUNCTION_COMPILE_TESTS += pde_data
++NV_CONFTEST_FUNCTION_COMPILE_TESTS += proc_remove
++NV_CONFTEST_FUNCTION_COMPILE_TESTS += pm_vt_switch_required
++NV_CONFTEST_FUNCTION_COMPILE_TESTS += pci_save_state
++NV_CONFTEST_FUNCTION_COMPILE_TESTS += drm_pci_set_busid
++NV_CONFTEST_FUNCTION_COMPILE_TESTS += write_cr4
++NV_CONFTEST_FUNCTION_COMPILE_TESTS += for_each_online_node
++NV_CONFTEST_FUNCTION_COMPILE_TESTS += node_end_pfn
++NV_CONFTEST_FUNCTION_COMPILE_TESTS += get_user_pages
++NV_CONFTEST_FUNCTION_COMPILE_TESTS += get_user_pages_remote
++NV_CONFTEST_FUNCTION_COMPILE_TESTS += register_cpu_notifier
++NV_CONFTEST_FUNCTION_COMPILE_TESTS += cpuhp_setup_state
++NV_CONFTEST_FUNCTION_COMPILE_TESTS += drm_get_pci_dev
++NV_CONFTEST_FUNCTION_COMPILE_TESTS += drm_pci_init
++NV_CONFTEST_FUNCTION_COMPILE_TESTS += drm_legacy_pci_init
++NV_CONFTEST_FUNCTION_COMPILE_TESTS += timer_setup
++NV_CONFTEST_FUNCTION_COMPILE_TESTS += do_gettimeofday
++NV_CONFTEST_FUNCTION_COMPILE_TESTS += drm_gem_object_put_unlocked
++NV_CONFTEST_FUNCTION_COMPILE_TESTS += efi_enabled
++
++NV_CONFTEST_FUNCTION_COMPILE_TESTS += drm_gem_object_get
++NV_CONFTEST_FUNCTION_COMPILE_TESTS += drm_atomic_state_ref_counting
++NV_CONFTEST_FUNCTION_COMPILE_TESTS += drm_gem_object_lookup
++NV_CONFTEST_FUNCTION_COMPILE_TESTS += drm_dev_put
++NV_CONFTEST_FUNCTION_COMPILE_TESTS += drm_framebuffer_get
++NV_CONFTEST_FUNCTION_COMPILE_TESTS += drm_connector_for_each_possible_encoder
++NV_CONFTEST_FUNCTION_COMPILE_TESTS += vga_tryget
++
++NV_CONFTEST_SYMBOL_COMPILE_TESTS += efi_enabled
++NV_CONFTEST_SYMBOL_COMPILE_TESTS += export_symbol_gpl_conftest
++
++NV_CONFTEST_TYPE_COMPILE_TESTS += i2c_adapter
++NV_CONFTEST_TYPE_COMPILE_TESTS += pm_message_t
++NV_CONFTEST_TYPE_COMPILE_TESTS += irq_handler_t
++NV_CONFTEST_TYPE_COMPILE_TESTS += acpi_device_ops
++NV_CONFTEST_TYPE_COMPILE_TESTS += acpi_op_remove
++NV_CONFTEST_TYPE_COMPILE_TESTS += acpi_device_id
++NV_CONFTEST_TYPE_COMPILE_TESTS += outer_flush_all
++NV_CONFTEST_TYPE_COMPILE_TESTS += proc_dir_entry
++NV_CONFTEST_TYPE_COMPILE_TESTS += scatterlist
++NV_CONFTEST_TYPE_COMPILE_TESTS += sg_table
++NV_CONFTEST_TYPE_COMPILE_TESTS += file_inode
++NV_CONFTEST_TYPE_COMPILE_TESTS += drm_bus_present
++NV_CONFTEST_TYPE_COMPILE_TESTS += drm_bus_has_bus_type
++NV_CONFTEST_TYPE_COMPILE_TESTS += drm_bus_has_get_irq
++NV_CONFTEST_TYPE_COMPILE_TESTS += drm_bus_has_get_name
++NV_CONFTEST_TYPE_COMPILE_TESTS += vm_fault_t
++NV_CONFTEST_TYPE_COMPILE_TESTS += vm_fault_present
++NV_CONFTEST_TYPE_COMPILE_TESTS += vm_fault_has_address
++NV_CONFTEST_TYPE_COMPILE_TESTS += drm_driver_unload_has_int_return_type
++NV_CONFTEST_TYPE_COMPILE_TESTS += drm_driver_legacy_feature_bit_present
++NV_CONFTEST_TYPE_COMPILE_TESTS += drm_driver_prime_flag_present
++
++NV_CONFTEST_TYPE_COMPILE_TESTS += timeval
++NV_CONFTEST_TYPE_COMPILE_TESTS += mm_has_mmap_lock
++NV_CONFTEST_TYPE_COMPILE_TESTS += drm_gem_object_vmap_has_map_arg
++NV_CONFTEST_TYPE_COMPILE_TESTS += drm_device_has_pdev
++NV_CONFTEST_TYPE_COMPILE_TESTS += drm_mode_object_find_has_file_priv_arg
++NV_CONFTEST_TYPE_COMPILE_TESTS += drm_prime_pages_to_sg_has_drm_device_arg
++NV_CONFTEST_TYPE_COMPILE_TESTS += drm_gem_object_has_resv
++
++NV_CONFTEST_TYPE_COMPILE_TESTS += drm_gem_prime_export_has_dev_arg
++NV_CONFTEST_TYPE_COMPILE_TESTS += drm_driver_has_gem_prime_callbacks
++NV_CONFTEST_TYPE_COMPILE_TESTS += drm_driver_has_gem_free_object
++NV_CONFTEST_TYPE_COMPILE_TESTS += drm_driver_has_gem_prime_res_obj
++NV_CONFTEST_TYPE_COMPILE_TESTS += vmalloc_has_pgprot_t_arg
++
++NV_CONFTEST_MACRO_COMPILE_TESTS += INIT_WORK
++
++# The conftest.sh script tests various aspects of the target kernel.
++# The per-module Kbuild files included above should:
++#
++# - Append to the NV_CONFTEST_*_COMPILE_TESTS variables to indicate
++# which conftests they require.
++# - Append to the NV_OBJECTS_DEPEND_ON_CONFTEST variable any object files
++# that depend on conftest.
++#
++# The conftest machinery below will run the requested tests and
++# generate the appropriate header files.
++#
++
++CC ?= cc
++HOST_CC ?= $(CC)
++LD ?= ld
++
++NV_CONFTEST_SCRIPT := $(src)/conftest.sh
++NV_CONFTEST_HEADER := $(obj)/conftest/headers.h
++
++NV_CONFTEST_CMD := /bin/sh $(NV_CONFTEST_SCRIPT) \
++ "$(CC)" "$(HOST_CC)" $(ARCH) $(KERNEL_SOURCES) $(KERNEL_OUTPUT)
++
++NV_CONFTEST_CFLAGS := $(shell $(NV_CONFTEST_CMD) build_cflags)
++
++NV_CONFTEST_COMPILE_TEST_HEADERS := $(obj)/conftest/macros.h
++NV_CONFTEST_COMPILE_TEST_HEADERS += $(obj)/conftest/functions.h
++NV_CONFTEST_COMPILE_TEST_HEADERS += $(obj)/conftest/symbols.h
++NV_CONFTEST_COMPILE_TEST_HEADERS += $(obj)/conftest/types.h
++NV_CONFTEST_COMPILE_TEST_HEADERS += $(obj)/conftest/generic.h
++
++NV_CONFTEST_HEADERS := $(obj)/conftest/patches.h
++NV_CONFTEST_HEADERS += $(obj)/conftest/headers.h
++NV_CONFTEST_HEADERS += $(NV_CONFTEST_COMPILE_TEST_HEADERS)
++
++
++#
++# Generate a header file for a single conftest compile test. Each compile test
++# header depends on conftest.sh, as well as the generated conftest/headers.h
++# file, which is included in the compile test preamble.
++#
++
++$(obj)/conftest/compile-tests/%.h: $(NV_CONFTEST_SCRIPT) $(NV_CONFTEST_HEADER)
++ @mkdir -p $(obj)/conftest/compile-tests
++ @echo " CONFTEST: $(notdir $*)"
++ @$(NV_CONFTEST_CMD) compile_tests '$(NV_CONFTEST_CFLAGS)' \
++ $(notdir $*) > $@
++
++#
++# Concatenate a conftest/*.h header from its constituent compile test headers
++#
++# $(1): The name of the concatenated header
++# $(2): The list of compile tests that make up the header
++#
++
++define NV_GENERATE_COMPILE_TEST_HEADER
++ $(obj)/conftest/$(1).h: $(addprefix $(obj)/conftest/compile-tests/,$(addsuffix
.h,$(2)))
++ @mkdir -p $(obj)/conftest
++ @# concatenate /dev/null to prevent cat from hanging when $$^ is empty
++ @cat $$^ /dev/null > $$@
++endef
++
++#
++# Generate the conftest compile test headers from the lists of compile tests
++# provided by the module-specific Kbuild files.
++#
++NV_CONFTEST_FUNCTION_COMPILE_TESTS ?=
++NV_CONFTEST_GENERIC_COMPILE_TESTS ?=
++NV_CONFTEST_MACRO_COMPILE_TESTS ?=
++NV_CONFTEST_SYMBOL_COMPILE_TESTS ?=
++NV_CONFTEST_TYPE_COMPILE_TESTS ?=
++
++$(eval $(call
NV_GENERATE_COMPILE_TEST_HEADER,functions,$(NV_CONFTEST_FUNCTION_COMPILE_TESTS)))
++$(eval $(call
NV_GENERATE_COMPILE_TEST_HEADER,generic,$(NV_CONFTEST_GENERIC_COMPILE_TESTS)))
++$(eval $(call
NV_GENERATE_COMPILE_TEST_HEADER,macros,$(NV_CONFTEST_MACRO_COMPILE_TESTS)))
++$(eval $(call
NV_GENERATE_COMPILE_TEST_HEADER,symbols,$(NV_CONFTEST_SYMBOL_COMPILE_TESTS)))
++$(eval $(call NV_GENERATE_COMPILE_TEST_HEADER,types,$(NV_CONFTEST_TYPE_COMPILE_TESTS)))
++
++$(obj)/conftest/patches.h: $(NV_CONFTEST_SCRIPT)
++ @mkdir -p $(obj)/conftest
++ @$(NV_CONFTEST_CMD) patch_check > $@
++
++$(obj)/conftest/headers.h: $(NV_CONFTEST_SCRIPT)
++ @mkdir -p $(obj)/conftest
++ @$(NV_CONFTEST_CMD) test_kernel_headers > $@
++
++clean-dirs := $(obj)/conftest
++
++
++# For any object files that depend on conftest, declare the dependency here.
++$(addprefix $(obj)/,$(NV_OBJECTS_DEPEND_ON_CONFTEST)): | $(NV_CONFTEST_HEADERS)
++
++# Sanity checks of the build environment and target system/kernel
++
++BUILD_SANITY_CHECKS = \
++ cc_sanity_check \
++ cc_version_check \
++ dom0_sanity_check \
++ xen_sanity_check \
++ preempt_rt_sanity_check \
++ vgpu_kvm_sanity_check
++
++.PHONY: $(BUILD_SANITY_CHECKS)
++
++$(BUILD_SANITY_CHECKS):
++ @$(NV_CONFTEST_CMD) $@ full_output
++
++# Perform all sanity checks before generating the conftest headers
++
++$(NV_CONFTEST_HEADERS): | $(BUILD_SANITY_CHECKS)
+diff -Naur a/kernel/conftest.sh b/kernel/conftest.sh
+--- a/kernel/conftest.sh 2022-01-21 18:37:50.022267249 +0100
++++ b/kernel/conftest.sh 2022-01-21 18:38:55.082844211 +0100
+@@ -113,6 +113,7 @@
+ FILES="$FILES drm/drm_vblank.h"
+ FILES="$FILES drm/drm_file.h"
+ FILES="$FILES drm/drm_ioctl.h"
++ FILES="$FILES drm/drm_pci.h"
+ FILES="$FILES drm/drm_device.h"
+ FILES="$FILES generated/autoconf.h"
+ FILES="$FILES generated/compile.h"
+@@ -121,6 +122,7 @@
+ FILES="$FILES linux/kconfig.h"
+ FILES="$FILES linux/screen_info.h"
+ FILES="$FILES linux/semaphore.h"
++ FILES="$FILES linux/nvmap.h"
+ FILES="$FILES linux/printk.h"
+ FILES="$FILES linux/ratelimit.h"
+ FILES="$FILES linux/prio_tree.h"
+@@ -133,6 +135,7 @@
+ FILES="$FILES xen/ioemu.h"
+ FILES="$FILES linux/fence.h"
+ FILES="$FILES linux/ktime.h"
++ FILES="$FILES linux/file.h"
+ FILES="$FILES linux/dma-resv.h"
+ FILES="$FILES linux/dma-map-ops.h"
+ FILES="$FILES linux/stdarg.h"
+@@ -143,6 +146,8 @@
+ FILES_ARCH="$FILES_ARCH asm/powernv.h"
+ FILES_ARCH="$FILES_ARCH asm/tlbflush.h"
+ FILES_ARCH="$FILES_ARCH asm/pgtable_types.h"
++ FILES_ARCH="$FILES_ARCH asm/kmap_types.h"
++ FILES_ARCH="$FILES_ARCH asm/pgtable.h"
+
+ translate_and_find_header_files $HEADERS $FILES
+ translate_and_find_header_files $HEADERS_ARCH $FILES_ARCH
+@@ -663,6 +668,63 @@
+ compile_check_conftest "$CODE" "NV_FOLLOW_PFN_PRESENT"
"" "functions"
+ ;;
+
++ vmap)
++ #
++ # Determine if the vmap() function is present and how
++ # many arguments it takes.
++ #
++ echo "$CONFTEST_PREAMBLE
++ #include <linux/vmalloc.h>
++ void conftest_vmap(void) {
++ vmap();
++ }" > conftest$$.c
++
++ $CC $CFLAGS -c conftest$$.c > /dev/null 2>&1
++ rm -f conftest$$.c
++
++ if [ -f conftest$$.o ]; then
++ echo "#undef NV_VMAP_PRESENT" | append_conftest
"functions"
++ rm -f conftest$$.o
++ return
++ fi
++
++ echo "$CONFTEST_PREAMBLE
++ #include <linux/vmalloc.h>
++ void *conftest_vmap(struct page **pages, int count) {
++ return vmap(pages, count);
++ }" > conftest$$.c
++
++ $CC $CFLAGS -c conftest$$.c > /dev/null 2>&1
++ rm -f conftest$$.c
++
++ if [ -f conftest$$.o ]; then
++ echo "#define NV_VMAP_PRESENT" | append_conftest
"functions"
++ echo "#define NV_VMAP_ARGUMENT_COUNT 2" | append_conftest
"functions"
++ rm -f conftest$$.o
++ return
++ fi
++
++ echo "$CONFTEST_PREAMBLE
++ #include <linux/vmalloc.h>
++ #include <linux/mm.h>
++ void *conftest_vmap(struct page **pages, int count) {
++ return vmap(pages, count, 0, PAGE_KERNEL);
++ }" > conftest$$.c
++
++ $CC $CFLAGS -c conftest$$.c > /dev/null 2>&1
++ rm -f conftest$$.c
++
++ if [ -f conftest$$.o ]; then
++ echo "#define NV_VMAP_PRESENT" | append_conftest
"functions"
++ echo "#define NV_VMAP_ARGUMENT_COUNT 4" | append_conftest
"functions"
++ rm -f conftest$$.o
++ return
++ else
++ echo "#error vmap() conftest failed!" | append_conftest
"functions"
++ return
++ fi
++ ;;
++
+ i2c_adapter)
+ #
+ # Determine if the 'i2c_adapter' structure has the
+@@ -1111,6 +1173,16 @@
+ compile_check_conftest "$CODE"
"NV_CPUHP_SETUP_STATE_PRESENT" "" "functions"
+ ;;
+
++ nvmap_support)
++ # check if nvmap is supported.
++ if [ -f nv-android.h ]; then
++ echo "#define HAVE_NV_ANDROID" | append_conftest
"generic"
++ return
++ else
++ echo "#undef HAVE_NV_ANDROID" | append_conftest
"generic"
++ fi
++ ;;
++
+ acpi_evaluate_integer)
+ #
+ # Determine if the acpi_evaluate_integer() function is
+@@ -1426,6 +1498,47 @@
+ compile_check_conftest "$CODE"
"NV_FILE_OPERATIONS_HAS_COMPAT_IOCTL" "" "types"
+ ;;
+
++ sg_init_table)
++ #
++ # Determine if the sg_init_table() function is present.
++ #
++ echo "$CONFTEST_PREAMBLE
++ #include <linux/scatterlist.h>
++ void conftest_sg_init_table(struct scatterlist *sgl,
++ unsigned int nents) {
++ }" > conftest$$.c
++
++ $CC $CFLAGS -c conftest$$.c > /dev/null 2>&1
++ rm -f conftest$$.c
++
++ if [ ! -f conftest$$.o ]; then
++ echo "#undef NV_SG_INIT_TABLE_PRESENT" | append_conftest
"functions"
++ return
++
++ fi
++ rm -f conftest$$.o
++
++ echo "$CONFTEST_PREAMBLE
++ #include <linux/types.h>
++ #include <linux/scatterlist.h>
++ void conftest_sg_init_table(struct scatterlist *sgl,
++ unsigned int nents) {
++ sg_init_table();
++ }" > conftest$$.c
++
++ $CC $CFLAGS -c conftest$$.c > /dev/null 2>&1
++ rm -f conftest$$.c
++
++ if [ -f conftest$$.o ]; then
++ echo "#undef NV_SG_INIT_TABLE_PRESENT" | append_conftest
"functions"
++ rm -f conftest$$.o
++ return
++ else
++ echo "#define NV_SG_INIT_TABLE_PRESENT" | append_conftest
"functions"
++ return
++ fi
++ ;;
++
+ sg_table)
+ #
+ # Determine if the struct sg_table type is present.
+@@ -2034,6 +2147,21 @@
+ compile_check_conftest "$CODE" "NV_FILE_HAS_INODE"
"" "types"
+ ;;
+
++ drm_pci_set_busid)
++ #
++ # Determine if the drm_pci_set_busid function is present.
++ #
++ CODE="
++ #if defined(NV_DRM_DRMP_H_PRESENT)
++ #include <drm/drmP.h>
++ #endif
++ void conftest_drm_pci_set_busid(void) {
++ drm_pci_set_busid();
++ }"
++
++ compile_check_conftest "$CODE"
"NV_DRM_PCI_SET_BUSID_PRESENT" "" "functions"
++ ;;
++
+ xen_ioemu_inject_msi)
+ #
+ # Determine if the xen_ioemu_inject_msi() function is present.
+@@ -3411,6 +3539,64 @@
+ compile_check_conftest "$CODE"
"NV_DRM_DRIVER_UNLOAD_HAS_INT_RETURN_TYPE" "" "types"
+ ;;
+
++ drm_get_pci_dev)
++ #
++ # Determine if drm_get_pci_dev() is present.
++ #
++ CODE="
++ #if defined(NV_DRM_DRMP_H_PRESENT)
++ #include <drm/drmP.h>
++ #endif
++
++ #if defined(NV_DRM_DRM_PCI_H_PRESENT)
++ #include <drm/drm_pci.h>
++ #endif
++
++ void conftest_drm_legacy_pci_init(void) {
++ drm_get_pci_dev();
++ }"
++
++ compile_check_conftest "$CODE"
"NV_DRM_GET_PCI_DEV_PRESENT" "" "functions"
++ ;;
++
++ drm_pci_init)
++ #
++ # Determine if drm_pci_init() is present.
++ #
++ CODE="
++ #if defined(NV_DRM_DRMP_H_PRESENT)
++ #include <drm/drmP.h>
++ #endif
++
++ void conftest_drm_legacy_pci_init(void) {
++ drm_pci_init();
++ }"
++
++ compile_check_conftest "$CODE" "NV_DRM_PCI_INIT_PRESENT"
"" "functions"
++ ;;
++
++ drm_legacy_pci_init)
++ #
++ # Determine if drm_legacy_pci_init() is present. drm_pci_init() was
++ # deprecated and renamed to drm_legacy_pci_init by:
++ #
++ # 2017-05-24 10631d724deff712343d96dd3017cd323349f761
++ #
++ CODE="
++ #if defined(NV_DRM_DRMP_H_PRESENT)
++ #include <drm/drmP.h>
++ #endif
++
++ #if defined(NV_DRM_DRM_PCI_H_PRESENT)
++ #include <drm/drm_pci.h>
++ #endif
++ void conftest_drm_legacy_pci_init(void) {
++ drm_legacy_pci_init();
++ }"
++
++ compile_check_conftest "$CODE"
"NV_DRM_LEGACY_PCI_INIT_PRESENT" "" "functions"
++ ;;
++
+ kref_has_refcount_of_type_refcount_t)
+ CODE="
+ #include <linux/kref.h>
+@@ -3963,6 +4149,30 @@
+ compile_check_conftest "$CODE"
"NV_DMA_IS_DIRECT_PRESENT" "" "functions"
+ ;;
+
++ drm_driver_legacy_feature_bit_present)
++ #
++ # Determine if the DRIVER_LEGACY feature bit is present, either as a
++ # preprocessor macro or in an enum.
++ #
++ # The DRIVER_* feature bits were changed from CPP macros to an enum
++ # with commit 0e2a933b02c972919f7478364177eb76cd4ae00d (2019-01-29).
++ #
++ CODE="
++ #if defined(NV_DRM_DRMP_H_PRESENT)
++ #include <drm/drmP.h>
++ #endif
++
++ #if defined(NV_DRM_DRM_DRV_H_PRESENT)
++ #include <drm/drm_drv.h>
++ #endif
++
++ void conftest_drm_driver_legacy_feature_bit_present(struct drm_driver *drv)
{
++ drv->driver_features = DRIVER_LEGACY;
++ }"
++
++ compile_check_conftest "$CODE"
"NV_DRM_DRIVER_LEGACY_FEATURE_BIT_PRESENT" "" "types"
++ ;;
++
+ drm_driver_prime_flag_present)
+ #
+ # Determine whether driver feature flag DRIVER_PRIME is present.
+diff -Naur a/kernel/dkms.conf b/kernel/dkms.conf
+--- a/kernel/dkms.conf 2022-01-21 18:37:49.976268255 +0100
++++ b/kernel/dkms.conf 2022-01-21 18:38:55.084844167 +0100
+@@ -1,7 +1,13 @@
++if [ -x /usr/bin/nproc ]; then
++ num_cpu_cores=$(nproc)
++else
++ num_cpu_cores=1
++fi
++
+ PACKAGE_NAME="nvidia"
+ PACKAGE_VERSION="340.108"
+ BUILT_MODULE_NAME[0]="$PACKAGE_NAME"
+ DEST_MODULE_LOCATION[0]="/kernel/drivers/video"
+-MAKE[0]="make module KERNEL_UNAME=${kernelver}"
++MAKE[0]="make -j$num_cpu_cores module KERNEL_UNAME=${kernelver}"
+ CLEAN="make clean"
+ AUTOINSTALL="yes"
+diff -Naur a/kernel/Makefile b/kernel/Makefile
+--- a/kernel/Makefile 2022-01-21 18:37:49.975268277 +0100
++++ b/kernel/Makefile 2022-01-21 18:38:55.073844408 +0100
+@@ -70,11 +70,11 @@
+ MODULE_GLUE_OBJS := $(patsubst %.c,%.o,nv-frontend.c)
+ $(MODULE_NAME)-objs := $(MODULE_GLUE_OBJS)
+ else
+- MODULE_GLUE_OBJS := $(patsubst %.c,%.o, nv.c nv-acpi.c nv-chrdev.c nv-cray.c nv-dma.c
nv-drm.c nv-gvi.c nv-i2c.c nv-mempool.c nv-mmap.c nv-p2p.c nv-pat.c nv-procfs.c
nv-usermap.c nv-vm.c nv-vtophys.c os-interface.c os-mlock.c os-pci.c os-registry.c
os-smp.c os-usermap.c nv_uvm_interface.c)
++ MODULE_GLUE_OBJS := $(patsubst %.c,%.o, nv.c nv-acpi.c nv-chrdev.c nv-cray.c nv-dma.c
nv-drm.c nv-gvi.c nv-i2c.c nv-mempool.c nv-mmap.c nv-p2p.c nv-pat.c nv-procfs.c
nv-usermap.c nv-vm.c nv-vtophys.c os-interface.c os-mlock.c os-pci.c os-registry.c
os-smp.c os-usermap.c nv_uvm_interface.c nvidia-drm-linux.c nvidia-drm-gem.c
nvidia-drm-helper.c nvidia-drm-gem-user-memory.c)
+ $(MODULE_NAME)-objs := $(CORE_OBJS) $(MODULE_GLUE_OBJS)
+ endif
+ else
+- MODULE_GLUE_OBJS := $(patsubst %.c,%.o, nv.c nv-acpi.c nv-chrdev.c nv-cray.c nv-dma.c
nv-drm.c nv-gvi.c nv-i2c.c nv-mempool.c nv-mmap.c nv-p2p.c nv-pat.c nv-procfs.c
nv-usermap.c nv-vm.c nv-vtophys.c os-interface.c os-mlock.c os-pci.c os-registry.c
os-smp.c os-usermap.c nv_uvm_interface.c) $(patsubst %.c,%.o,nv-frontend.c)
++ MODULE_GLUE_OBJS := $(patsubst %.c,%.o, nv.c nv-acpi.c nv-chrdev.c nv-cray.c nv-dma.c
nv-drm.c nv-gvi.c nv-i2c.c nv-mempool.c nv-mmap.c nv-p2p.c nv-pat.c nv-procfs.c
nv-usermap.c nv-vm.c nv-vtophys.c os-interface.c os-mlock.c os-pci.c os-registry.c
os-smp.c os-usermap.c nv_uvm_interface.c nvidia-drm-linux.c nvidia-drm-gem.c
nvidia-drm-helper.c nvidia-drm-gem-user-memory.c) $(patsubst %.c,%.o,nv-frontend.c)
+ $(MODULE_NAME)-objs := $(CORE_OBJS) $(MODULE_GLUE_OBJS)
+ endif
+
+@@ -168,7 +168,7 @@
+ EXTRA_CFLAGS += -DNV_BUILD_MODULE_INSTANCES=0
+ endif
+
+-EXTRA_CFLAGS += -UDEBUG -U_DEBUG -DNDEBUG
++EXTRA_CFLAGS += -UDEBUG -U_DEBUG -DNDEBUG -DNV_KERNEL_INTERFACE_LAYER
+
+ #
+ # Include common definitions; we rely on the definition of the source path to
+@@ -178,6 +178,7 @@
+
+ src ?= .
+ include $(src)/nvidia-modules-common.mk
++include $(src)/conftest.Kbuild
+
+ #
+ # Generate multiple targets at runtime depending on the items present in
+diff -Naur a/kernel/nv.c b/kernel/nv.c
+--- a/kernel/nv.c 2022-01-21 18:37:49.981268146 +0100
++++ b/kernel/nv.c 2022-01-21 18:38:55.104843730 +0100
+@@ -752,7 +752,7 @@
+ NV_SPIN_LOCK_INIT(&km_lock);
+ #endif
+
+- NV_KMEM_CACHE_CREATE(nv_stack_t_cache, NV_STACK_CACHE_STR, nv_stack_t);
++ NV_KMEM_CACHE_CREATE_USERCOPY(nv_stack_t_cache, NV_STACK_CACHE_STR, nv_stack_t);
+ if (nv_stack_t_cache == NULL)
+ {
+ nv_printf(NV_DBG_ERRORS, "NVRM: stack cache allocation failed!\n");
+@@ -2785,7 +2785,11 @@
+
+ #if defined(CONFIG_VGA_ARB)
+ #if defined(VGA_DEFAULT_DEVICE)
++#if defined(NV_VGA_TRYGET_PRESENT)
+ vga_tryget(VGA_DEFAULT_DEVICE, VGA_RSRC_LEGACY_MASK);
++#else
++ vga_get(VGA_DEFAULT_DEVICE, VGA_RSRC_LEGACY_MASK, 0);
++#endif
+ #endif
+ vga_set_legacy_decoding(dev, VGA_RSRC_NONE);
+ #endif
+diff -Naur a/kernel/nv-drm.c b/kernel/nv-drm.c
+--- a/kernel/nv-drm.c 2022-01-21 18:37:49.977268233 +0100
++++ b/kernel/nv-drm.c 2022-01-21 18:38:55.086844123 +0100
+@@ -23,6 +23,11 @@
+ #include <linux/file.h>
+ #endif
+
++#include <nvidia-drm-priv.h>
++#include <nvidia-drm-ioctl.h>
++#include <nvidia-drm-gem-user-memory.h>
++#include <nvidia-drm-helper.h>
++
+ #if defined(NV_DRM_DRM_DRV_H_PRESENT)
+ #include <drm/drm_drv.h>
+ #endif
+@@ -55,6 +60,8 @@
+ #define nv_drm_pci_exit drm_pci_exit
+ #endif
+
++static struct nv_drm_device *dev_list = NULL;
++
+ extern nv_linux_state_t *nv_linux_devices;
+
+ struct nv_gem_object {
+@@ -62,20 +69,35 @@
+ struct page **pages;
+ };
+
++#if !defined(NV_DRM_DEVICE_HAS_PDEV)
++#include <drm/drm_legacy.h>
++struct nv_drm_extra_priv_data {
++ struct pci_dev *pdev;
++ struct drm_agp_head *agp;
++};
++#endif
++
+ static int nv_drm_load(
+ struct drm_device *dev,
+ unsigned long flags
+ )
+ {
+ nv_linux_state_t *nvl;
++#if !defined(NV_DRM_DEVICE_HAS_PDEV)
++ struct nv_drm_extra_priv_data *extra = dev->dev_private;
++#endif
+
+ for (nvl = nv_linux_devices; nvl != NULL; nvl = nvl->next)
+ {
+- if (nvl->dev == dev->pdev)
+- {
+- nvl->drm = dev;
+- return 0;
+- }
++#if defined(NV_DRM_DEVICE_HAS_PDEV)
++ if (nvl->dev == dev->pdev)
++#else
++ if (nvl->dev == extra->pdev)
++#endif
++ {
++ nvl->drm = dev;
++ return 0;
++ }
+ }
+
+ return -ENODEV;
+@@ -92,11 +114,18 @@
+ )
+ {
+ nv_linux_state_t *nvl;
++#if !defined(NV_DRM_DEVICE_HAS_PDEV)
++ struct nv_drm_extra_priv_data *extra = dev->dev_private;
++#endif
+
+ for (nvl = nv_linux_devices; nvl != NULL; nvl = nvl->next)
+ {
+- if (nvl->dev == dev->pdev)
+- {
++#if defined(NV_DRM_DEVICE_HAS_PDEV)
++ if (nvl->dev == dev->pdev)
++#else
++ if (nvl->dev == extra->pdev)
++#endif
++ {
+ BUG_ON(nvl->drm != dev);
+ nvl->drm = NULL;
+ return 0;
+@@ -131,32 +160,49 @@
+ NV_KFREE(nv_obj, sizeof(*nv_obj));
+ }
+
+-static struct sg_table* nv_gem_prime_get_sg_table(
+- struct drm_gem_object *obj
+-)
++static int nv_drm_get_dev_info_ioctl(struct drm_device *dev,
++ void *data, struct drm_file *filep)
+ {
+- struct nv_gem_object *nv_obj = container_of(obj, struct nv_gem_object, base);
+- int page_count = obj->size >> PAGE_SHIFT;
++ struct nv_drm_device *nv_dev = to_nv_device(dev);
++ struct drm_nvidia_get_dev_info_params *params = data;
+
+- return drm_prime_pages_to_sg(nv_obj->pages, page_count);
+-}
++ if (dev->primary == NULL) {
++ return -ENOENT;
++ }
+
+-static void* nv_gem_prime_vmap(
+- struct drm_gem_object *obj
+-)
+-{
+- struct nv_gem_object *nv_obj = container_of(obj, struct nv_gem_object, base);
+- int page_count = obj->size >> PAGE_SHIFT;
++ params->gpu_id = nv_dev->gpu_info.gpu_id;
++ params->primary_index = dev->primary->index;
+
+- return vmap(nv_obj->pages, page_count, VM_USERMAP, PAGE_KERNEL);
++ return 0;
+ }
+
+-static void nv_gem_prime_vunmap(
+- struct drm_gem_object *obj,
+- void *virtual
+-)
+-{
+- vunmap(virtual);
++static
++int nv_drm_get_client_capability_ioctl(struct drm_device *dev,
++ void *data, struct drm_file *filep)
++{
++ struct drm_nvidia_get_client_capability_params *params = data;
++
++ switch (params->capability) {
++#if defined(DRM_CLIENT_CAP_STEREO_3D)
++ case DRM_CLIENT_CAP_STEREO_3D:
++ params->value = filep->stereo_allowed;
++ break;
++#endif
++#if defined(DRM_CLIENT_CAP_UNIVERSAL_PLANES)
++ case DRM_CLIENT_CAP_UNIVERSAL_PLANES:
++ params->value = filep->universal_planes;
++ break;
++#endif
++#if defined(DRM_CLIENT_CAP_ATOMIC)
++ case DRM_CLIENT_CAP_ATOMIC:
++ params->value = filep->atomic;
++ break;
++#endif
++ default:
++ return -EINVAL;
++ }
++
++ return 0;
+ }
+
+ static const struct file_operations nv_drm_fops = {
+@@ -170,6 +216,43 @@
+ .llseek = noop_llseek,
+ };
+
++static const struct drm_ioctl_desc nv_drm_ioctls[] = {
++// #if defined(NV_DRM_ATOMIC_MODESET_AVAILABLE)
++// DRM_IOCTL_DEF_DRV(NVIDIA_GEM_IMPORT_NVKMS_MEMORY,
++// nv_drm_gem_import_nvkms_memory_ioctl,
++// DRM_UNLOCKED),
++// #endif /* NV_DRM_ATOMIC_MODESET_AVAILABLE */
++//
++ DRM_IOCTL_DEF_DRV(NVIDIA_GEM_IMPORT_USERSPACE_MEMORY,
++ nv_drm_gem_import_userspace_memory_ioctl,
++ DRM_RENDER_ALLOW|DRM_UNLOCKED),
++ DRM_IOCTL_DEF_DRV(NVIDIA_GET_DEV_INFO,
++ nv_drm_get_dev_info_ioctl,
++ DRM_RENDER_ALLOW|DRM_UNLOCKED),
++
++// #if defined(NV_DRM_FENCE_AVAILABLE)
++// DRM_IOCTL_DEF_DRV(NVIDIA_FENCE_SUPPORTED,
++// nv_drm_fence_supported_ioctl,
++// DRM_RENDER_ALLOW|DRM_UNLOCKED),
++// DRM_IOCTL_DEF_DRV(NVIDIA_FENCE_CONTEXT_CREATE,
++// nv_drm_fence_context_create_ioctl,
++// DRM_RENDER_ALLOW|DRM_UNLOCKED),
++// DRM_IOCTL_DEF_DRV(NVIDIA_GEM_FENCE_ATTACH,
++// nv_drm_gem_fence_attach_ioctl,
++// DRM_RENDER_ALLOW|DRM_UNLOCKED),
++// #endif
++
++ DRM_IOCTL_DEF_DRV(NVIDIA_GET_CLIENT_CAPABILITY,
++ nv_drm_get_client_capability_ioctl,
++ 0),
++// #if defined(NV_DRM_ATOMIC_MODESET_AVAILABLE)
++// DRM_IOCTL_DEF_DRV(NVIDIA_GET_CRTC_CRC32,
++// nv_drm_get_crtc_crc32_ioctl,
++// DRM_RENDER_ALLOW|DRM_UNLOCKED),
++// #endif /* NV_DRM_ATOMIC_MODESET_AVAILABLE */
++};
++
++
+ static struct drm_driver nv_drm_driver = {
+
+ .driver_features = DRIVER_GEM
+@@ -188,13 +271,24 @@
+ .set_busid = drm_pci_set_busid,
+ #endif
+
++#if defined(NV_DRM_DRIVER_HAS_GEM_FREE_OBJECT)
+ .gem_free_object = nv_gem_free,
++#endif
++
++ .ioctls = nv_drm_ioctls,
++ .num_ioctls = ARRAY_SIZE(nv_drm_ioctls),
+
+ .prime_handle_to_fd = drm_gem_prime_handle_to_fd,
+- .gem_prime_export = drm_gem_prime_export,
+- .gem_prime_get_sg_table = nv_gem_prime_get_sg_table,
+- .gem_prime_vmap = nv_gem_prime_vmap,
+- .gem_prime_vunmap = nv_gem_prime_vunmap,
++#if defined(NV_DRM_DRIVER_HAS_GEM_PRIME_CALLBACKS)
++ .gem_prime_export = nv_drm_gem_prime_export,
++ .gem_prime_get_sg_table = nv_drm_gem_prime_get_sg_table,
++ .gem_prime_vmap = nv_drm_gem_prime_vmap,
++ .gem_prime_vunmap = nv_drm_gem_prime_vunmap,
++#endif
++
++#if defined(NV_DRM_DRIVER_HAS_GEM_PRIME_RES_OBJ)
++ .gem_prime_res_obj = nv_drm_gem_prime_res_obj,
++#endif
+
+ .name = "nvidia-drm",
+ .desc = "NVIDIA DRM driver",
+@@ -202,7 +296,206 @@
+ .major = 0,
+ .minor = 0,
+ .patchlevel = 0,
++
++#if defined(NV_DRM_DRIVER_HAS_DEVICE_LIST)
++ .device_list = LIST_HEAD_INIT(nv_drm_driver.device_list),
++#elif defined(NV_DRM_DRIVER_HAS_LEGACY_DEV_LIST)
++ .legacy_dev_list = LIST_HEAD_INIT(nv_drm_driver.legacy_dev_list),
++#endif
+ };
++
++/*!
++ * Enumerate the available physical GPUs that can be used with NVKMS.
++ *
++ * \param [out] gpuInfo The information of the enumerated GPUs.
++ * It is an array of NVIDIA_MAX_GPUS elements.
++ *
++ * \return Count of enumerated gpus.
++ */
++
++/*
++ * Implemented based on code from drm_legacy_pci_{init,exit}
++ * Extracted from tag: v5.6.3, file: drivers/gpu/drm/drm_pci.c
++ */
++static NvU32 nvKmsenumerateGpus(nv_gpu_info_t *gpuInfo, struct drm_driver *driver,
struct pci_driver *pdriver)
++{
++ NvU32 gpu_count = 0;
++
++ struct pci_dev *pdev = NULL;
++ const struct pci_device_id *pid;
++ int i;
++
++ DRM_DEBUG("\n");
++
++ for (i = 0; pdriver->id_table[i].vendor != 0; i++) {
++ pid = &pdriver->id_table[i];
++
++ /* Loop around setting up a DRM device for each PCI device
++ * matching our ID and device class. If we had the internal
++ * function that pci_get_subsys and pci_get_class used, we'd
++ * be able to just pass pid in instead of doing a two-stage
++ * thing.
++ */
++ pdev = NULL;
++ while ((pdev =
++ pci_get_subsys(pid->vendor, pid->device, pid->subvendor,
++ pid->subdevice, pdev)) != NULL) {
++
++ if ((pdev->class & pid->class_mask) != pid->class)
++ continue;
++
++ /* stealth mode requires a manual probe */
++ pci_dev_get(pdev);
++
++ gpuInfo[i].gpu_id = pid->device;
++ gpuInfo[i].pci_info.domain = pci_domain_nr(pdev->bus);
++ gpuInfo[i].pci_info.bus = pdev->bus->number;
++ gpuInfo[i].pci_info.slot = PCI_SLOT(pdev->devfn);
++ gpuInfo[i].pci_info.function = PCI_FUNC(pdev->devfn);
++ gpuInfo[i].os_dev_ptr = pdev;
++ gpu_count += 1;
++ }
++ }
++ return gpu_count;
++}
++
++/*
++ * Helper function for allocate/register DRM device for given NVIDIA GPU ID.
++ */
++static void nv_drm_register_drm_device(const nv_gpu_info_t *gpu_info)
++{
++ struct nv_drm_device *nv_dev = NULL;
++ struct drm_device *dev = NULL;
++ struct nv_drm_extra_priv_data *extra;
++ struct pci_dev *pdev = gpu_info->os_dev_ptr;
++
++ DRM_DEBUG(
++ "Registering device for NVIDIA GPU ID 0x08%x",
++ gpu_info->gpu_id);
++
++ /* Allocate NVIDIA-DRM device */
++
++ nv_dev = nv_drm_calloc(1, sizeof(*nv_dev));
++
++ if (nv_dev == NULL) {
++ NV_DRM_LOG_ERR(
++ "Failed to allocate memmory for NVIDIA-DRM device object");
++ return;
++ }
++
++ nv_dev->gpu_info = *gpu_info;
++
++#if defined(NV_DRM_ATOMIC_MODESET_AVAILABLE)
++ mutex_init(&nv_dev->lock);
++#endif
++
++ /* Allocate DRM device */
++
++ dev = drm_dev_alloc(&nv_drm_driver, &pdev->dev);
++
++ if (dev == NULL) {
++ NV_DRM_DEV_LOG_ERR(nv_dev, "Failed to allocate device");
++ goto failed_drm_alloc;
++ }
++
++ dev->dev_private = nv_dev;
++ nv_dev->dev = dev;
++
++#if defined(NV_DRM_DEVICE_HAS_PDEV)
++ dev->pdev = pdev;
++#else
++ extra = kzalloc(sizeof(*extra), GFP_KERNEL);
++ extra->pdev = pdev;
++ dev->dev_private = extra;
++#endif
++
++ /* Register DRM device to DRM sub-system */
++
++ if (drm_dev_register(dev, 0) != 0) {
++ NV_DRM_DEV_LOG_ERR(nv_dev, "Failed to register device");
++ goto failed_drm_register;
++ }
++
++ /* Add NVIDIA-DRM device into list */
++
++ nv_dev->next = dev_list;
++ dev_list = nv_dev;
++
++ return; /* Success */
++
++failed_drm_register:
++
++ nv_drm_dev_free(dev);
++
++failed_drm_alloc:
++
++ nv_drm_free(nv_dev);
++}
++
++/*
++ * Enumerate NVIDIA GPUs and allocate/register DRM device for each of them.
++ */
++int nv_drm_probe_devices(struct drm_driver *driver, struct pci_driver *pdriver)
++{
++ nv_gpu_info_t *gpu_info = NULL;
++ NvU32 gpu_count = 0;
++ NvU32 i;
++
++ int ret = 0;
++
++// nv_drm_update_drm_driver_features();
++
++ /* Enumerate NVIDIA GPUs */
++
++ gpu_info = nv_drm_calloc(NV_MAX_GPUS, sizeof(*gpu_info));
++
++ if (gpu_info == NULL) {
++ ret = -ENOMEM;
++
++ NV_DRM_LOG_ERR("Failed to allocate gpu ids arrays");
++ goto done;
++ }
++
++ gpu_count = nvKmsenumerateGpus(gpu_info, driver, pdriver);
++// gpu_count = nvKms->enumerateGpus(gpu_info);
++
++ if (gpu_count == 0) {
++ NV_DRM_LOG_INFO("Not found NVIDIA GPUs");
++ goto done;
++ }
++
++ WARN_ON(gpu_count > NV_MAX_GPUS);
++
++ /* Register DRM device for each NVIDIA GPU */
++
++ for (i = 0; i < gpu_count; i++) {
++ nv_drm_register_drm_device(&gpu_info[i]);
++ }
++
++done:
++
++ nv_drm_free(gpu_info);
++
++ return ret;
++}
++
++/*
++ * Unregister all NVIDIA DRM devices.
++ */
++void nv_drm_remove_devices(void)
++{
++ while (dev_list != NULL) {
++ struct nv_drm_device *next = dev_list->next;
++
++ drm_dev_unregister(dev_list->dev);
++ nv_drm_dev_free(dev_list->dev);
++
++ nv_drm_free(dev_list);
++
++ dev_list = next;
++ }
++}
++
+ #endif /* defined(NV_DRM_AVAILABLE) */
+
+ int __init nv_drm_init(
+@@ -211,7 +504,7 @@
+ {
+ int ret = 0;
+ #if defined(NV_DRM_AVAILABLE)
+- ret = nv_drm_pci_init(&nv_drm_driver, pci_driver);
++ ret = nv_drm_probe_devices(&nv_drm_driver, pci_driver);
+ #endif
+ return ret;
+ }
+@@ -221,7 +514,7 @@
+ )
+ {
+ #if defined(NV_DRM_AVAILABLE)
+- nv_drm_pci_exit(&nv_drm_driver, pci_driver);
++ nv_drm_remove_devices();
+ #endif
+ }
+
+@@ -282,9 +575,15 @@
+ goto done;
+ }
+
+-#if defined(NV_DRM_GEM_OBJECT_PUT_UNLOCKED_PRESENT)
++#if defined(NV_DRM_GEM_OBJECT_GET_PRESENT)
++
++#if defined(NV_DRM_GEM_OBJECT_PUT_UNLOCK_PRESENT)
+ drm_gem_object_put_unlocked(&nv_obj->base);
+ #else
++ drm_gem_object_put(&nv_obj->base);
++#endif
++
++#else
+ drm_gem_object_unreference_unlocked(&nv_obj->base);
+ #endif
+
+diff -Naur a/kernel/nv.h b/kernel/nv.h
+--- a/kernel/nv.h 2022-01-21 18:37:49.981268146 +0100
++++ b/kernel/nv.h 2022-01-21 18:38:55.106843686 +0100
+@@ -13,7 +13,7 @@
+ #define _NV_H_
+
+ #include <nvtypes.h>
+-#include <stdarg.h>
++#include "nv_stdarg.h"
+
+ #if !defined(NV_MIN)
+ #define NV_MIN(_a,_b) ((_a) < (_b) ? (_a) : (_b))
+diff -Naur a/kernel/nvidia-drm-gem.c b/kernel/nvidia-drm-gem.c
+--- a/kernel/nvidia-drm-gem.c 2022-01-21 18:37:50.025267183 +0100
++++ b/kernel/nvidia-drm-gem.c 2022-01-21 18:38:55.109843620 +0100
+@@ -26,10 +26,10 @@
+
+ #include "nvidia-drm-priv.h"
+ #include "nvidia-drm-ioctl.h"
+-#include "nvidia-drm-prime-fence.h"
++// #include "nvidia-drm-prime-fence.h"
+ #include "nvidia-drm-gem.h"
+ #include "nvidia-dma-resv-helper.h"
+-#include "nvidia-drm-gem-nvkms-memory.h"
++// #include "nvidia-drm-gem-nvkms-memory.h"
+
+ #if defined(NV_DRM_DRM_PRIME_H_PRESENT)
+ #include <drm/drm_prime.h>
+@@ -88,9 +88,9 @@
+ .vunmap = nv_drm_gem_prime_vunmap,
+ #endif
+
+-#if defined(NV_DRM_ATOMIC_MODESET_AVAILABLE)
+- .vm_ops = &nv_drm_gem_vma_ops,
+-#endif
++// #if defined(NV_DRM_ATOMIC_MODESET_AVAILABLE)
++// .vm_ops = &nv_drm_gem_vma_ops,
++// #endif
+
+ #endif
+ };
+diff -Naur a/kernel/nvidia-drm-linux.c b/kernel/nvidia-drm-linux.c
+--- a/kernel/nvidia-drm-linux.c 2022-01-21 18:37:50.027267140 +0100
++++ b/kernel/nvidia-drm-linux.c 2022-01-21 18:38:55.111843577 +0100
+@@ -25,7 +25,6 @@
+ #include <linux/err.h>
+
+ #include "nvidia-drm-os-interface.h"
+-#include "nvidia-drm.h"
+
+ #include "nvidia-drm-conftest.h"
+
+@@ -161,25 +160,3 @@
+ * Linux loading support code.
+ *************************************************************************/
+
+-static int __init nv_linux_drm_init(void)
+-{
+- return nv_drm_init();
+-}
+-
+-static void __exit nv_linux_drm_exit(void)
+-{
+- nv_drm_exit();
+-}
+-
+-module_init(nv_linux_drm_init);
+-module_exit(nv_linux_drm_exit);
+-
+-#if defined(MODULE_LICENSE)
+- MODULE_LICENSE("MIT");
+-#endif
+-#if defined(MODULE_INFO)
+- MODULE_INFO(supported, "external");
+-#endif
+-#if defined(MODULE_VERSION)
+- MODULE_VERSION(NV_VERSION_STRING);
+-#endif
+diff -Naur a/kernel/nvidia-modules-common.mk b/kernel/nvidia-modules-common.mk
+--- a/kernel/nvidia-modules-common.mk 2022-01-21 18:37:49.982268124 +0100
++++ b/kernel/nvidia-modules-common.mk 2022-01-21 18:38:55.112843555 +0100
+@@ -149,7 +149,7 @@
+ CONFTEST_HEADERS := $(obj)/conftest.h $(CONFTEST_COMPILE_TEST_HEADERS) \
+ $(obj)/conftest/patches.h
+
+-$(obj)/conftest.h $(CONFTEST_COMPILE_TEST_HEADERS): conftest-compile-test
++# $(obj)/conftest.h $(CONFTEST_COMPILE_TEST_HEADERS): conftest-compile-test
+
+ conftest-compile-test: $(src)/conftest.sh
+ @if ! $(CONFTEST) compile_tests $(COMPILE_TESTS); then exit 1; fi
+@@ -222,6 +222,7 @@
+ define BUILD_MODULE_RULE
+ $(1): build-sanity-checks $(3)
+ @echo "NVIDIA: calling KBUILD..."; \
++ touch .nv-kernel.o.cmd; \
+ $$(MAKE) "CC=$$(CC)" NV_MODULE_SUFFIX=$$(strip $(2)) $$(KBUILD_PARAMS)
modules; \
+ echo "NVIDIA: left KBUILD."; \
+ if ! [ -f $(1) ]; then \
+@@ -317,7 +318,7 @@
+ @$(RM) -f build-in.o nv-linux*.o *.d .*.cmd .*.flags
+ @$(RM) -f $(MODULE_NAME)*.o $(MODULE_NAME)*.ko*
+ @$(RM) -f $(MODULE_NAME)*.mod* $(VERSION_HEADER) *~
+- @$(RM) -f conftest*.c conftest.h
++ @$(RM) -f conftest*.c
+ @$(RM) -rf conftest
+ @$(RM) -rf Module*.symvers .tmp_versions modules.order
+
+diff -Naur a/kernel/nv-linux.h b/kernel/nv-linux.h
+--- a/kernel/nv-linux.h 2022-01-21 18:37:49.978268211 +0100
++++ b/kernel/nv-linux.h 2022-01-21 18:38:55.092843992 +0100
+@@ -119,12 +119,15 @@
+ #include <asm/tlbflush.h> /* flush_tlb(), flush_tlb_all() */
+ #include <linux/cpu.h> /* CPU hotplug support */
+ #endif
+-#include <asm/kmap_types.h> /* page table entry lookup */
++#if defined(NV_ASM_KMAP_TYPES_H_PRESENT)
++ #include <asm/kmap_types.h> /* page table entry lookup */
++#endif
+
+ #include <linux/pci.h> /* pci_find_class, etc */
+ #include <linux/interrupt.h> /* tasklets, interrupt helpers */
+ #include <linux/timer.h>
+-
++#include <linux/file.h> /* fget(), fput()
++*/
+ #include <asm/div64.h> /* do_div() */
+ #if defined(NV_ASM_SYSTEM_H_PRESENT)
+ #include <asm/system.h> /* cli, sli, save_flags */
+@@ -134,7 +137,7 @@
+ #include <asm/page.h> /* PAGE_OFFSET */
+ #include <asm/pgtable.h> /* pte bit definitions */
+
+-#if defined(NVCPU_X86_64) && !defined(HAVE_COMPAT_IOCTL)
++#if defined(NVCPU_X86_64) && !defined(NV_FILE_OPERATIONS_HAS_COMPAT_IOCTL)
+ #include <linux/syscalls.h> /* sys_ioctl() */
+ #include <linux/ioctl32.h> /* register_ioctl32_conversion() */
+ #endif
+@@ -255,7 +258,8 @@
+ * NVIDIA graphics driver has no way of knowing and is unlikely
+ * to work correctly.
+ */
+-#if defined(CONFIG_XEN) && !defined(CONFIG_PARAVIRT)
++#if defined(CONFIG_XEN) && !defined(CONFIG_PARAVIRT) && \
++ !defined(NVCPU_ARM)
+ #include <asm/maddr.h>
+ #include <xen/interface/memory.h>
+ #define NV_XEN_SUPPORT_FULLY_VIRTUALIZED_KERNEL
+@@ -669,11 +673,19 @@
+ # define KM_FREE_RECORD(a,b,c)
+ #endif
+
++#if !defined(NV_VMALLOC_HAS_PGPROT_T_ARG)
++#define NV_VMALLOC(ptr, size) \
++ { \
++ (ptr) = __vmalloc(size, GFP_KERNEL); \
++ VM_ALLOC_RECORD(ptr, size, "vm_vmalloc"); \
++ }
++#else
+ #define NV_VMALLOC(ptr, size) \
+ { \
+ (ptr) = __vmalloc(size, GFP_KERNEL, PAGE_KERNEL); \
+ VM_ALLOC_RECORD(ptr, size, "vm_vmalloc"); \
+ }
++#endif
+
+ #define NV_VFREE(ptr, size) \
+ { \
+@@ -688,11 +700,16 @@
+ VM_ALLOC_RECORD(ptr, size, "vm_ioremap"); \
+ }
+
++#if defined(NV_IOREMAP_NOCACHE_PRESENT)
+ #define NV_IOREMAP_NOCACHE(ptr, physaddr, size) \
+ { \
+ (ptr) = ioremap_nocache(physaddr, size); \
+ VM_ALLOC_RECORD(ptr, size, "vm_ioremap_nocache"); \
+ }
++#else
++#define NV_IOREMAP_NOCACHE(ptr, physaddr, size) \
++ NV_IOREMAP(ptr, physaddr, size)
++#endif
+
+ #if defined(NV_IOREMAP_CACHE_PRESENT)
+ #define NV_IOREMAP_CACHE(ptr, physaddr, size) \
+@@ -774,6 +791,17 @@
+ #error "NV_KMEM_CACHE_CREATE() undefined (kmem_cache_create() unavailable)!"
+ #endif
+
++#if defined(NV_KMEM_CACHE_CREATE_USERCOPY_PRESENT)
++#define NV_KMEM_CACHE_CREATE_USERCOPY(kmem_cache, name, type) \
++ { \
++ kmem_cache = kmem_cache_create_usercopy(name, sizeof(type), \
++ 0, 0, 0, sizeof(type), NULL); \
++ }
++#else
++#define NV_KMEM_CACHE_CREATE_USERCOPY(kmem_cache, name, type) \
++ NV_KMEM_CACHE_CREATE(kmem_cache, name, type)
++#endif
++
+ #define NV_KMEM_CACHE_ALLOC(ptr, kmem_cache, type) \
+ { \
+ (ptr) = kmem_cache_alloc(kmem_cache, GFP_KERNEL); \
+@@ -1971,6 +1999,19 @@
+ })
+ #endif
+
++#if defined(NV_PROC_OPS_PRESENT)
++#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 = NV_CREATE_PROC_ENTRY(filename, mode, parent, fops, \
++ __data); \
++ __entry; \
++ })
++#else
+ #define NV_CREATE_PROC_FILE(filename,parent,__name,__data) \
+ ({ \
+ struct proc_dir_entry *__entry; \
+@@ -1982,6 +2023,7 @@
+ __data); \
+ __entry; \
+ })
++#endif
+
+ /*
+ * proc_mkdir_mode exists in Linux 2.6.9, but isn't exported until Linux 3.0.
+@@ -2023,6 +2065,24 @@
+ remove_proc_entry(entry->name, entry->parent);
+ #endif
+
++#if defined(NV_PROC_OPS_PRESENT)
++#define NV_DEFINE_PROCFS_SINGLE_FILE(__name) \
++ static int nv_procfs_open_##__name( \
++ struct inode *inode, \
++ struct file *filep \
++ ) \
++ { \
++ return single_open(filep, nv_procfs_read_##__name, \
++ NV_PDE_DATA(inode)); \
++ } \
++ \
++ 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 = single_release, \
++ };
++#else
+ #define NV_DEFINE_PROCFS_SINGLE_FILE(__name) \
+ static int nv_procfs_open_##__name( \
+ struct inode *inode, \
+@@ -2040,6 +2100,7 @@
+ .llseek = seq_lseek, \
+ .release = single_release, \
+ };
++#endif
+
+ #endif /* CONFIG_PROC_FS */
+
+@@ -2187,9 +2248,13 @@
+ flags |= FOLL_FORCE;
+
+ #if defined(NV_GET_USER_PAGES_REMOTE_HAS_LOCKED_ARG)
+-
++ #if defined (NV_GET_USER_PAGES_REMOTE_HAS_TSK_ARG)
+ return get_user_pages_remote(tsk, mm, start, nr_pages, flags,
+ pages, vmas, NULL);
++ #else
++ return get_user_pages_remote(mm, start, nr_pages, flags,
++ pages, vmas, NULL);
++ #endif
+
+ #else
+
+diff -Naur a/kernel/nv-procfs.c b/kernel/nv-procfs.c
+--- a/kernel/nv-procfs.c 2022-01-21 18:37:49.978268211 +0100
++++ b/kernel/nv-procfs.c 2022-01-21 18:38:55.095843926 +0100
+@@ -409,6 +409,15 @@
+ return ((status < 0) ? status : (int)count);
+ }
+
++#if defined(NV_PROC_OPS_PRESENT)
++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,
++};
++#else
+ static struct file_operations nv_procfs_registry_fops = {
+ .owner = THIS_MODULE,
+ .open = nv_procfs_open_registry,
+@@ -417,6 +426,7 @@
+ .llseek = seq_lseek,
+ .release = nv_procfs_close_registry,
+ };
++#endif
+
+ static int
+ nv_procfs_read_unbind_lock(
+@@ -538,6 +548,15 @@
+ return rc;
+ }
+
++#if defined(NV_PROC_OPS_PRESENT)
++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,
++};
++#else
+ static struct file_operations nv_procfs_unbind_lock_fops = {
+ .owner = THIS_MODULE,
+ .open = nv_procfs_open_unbind_lock,
+@@ -546,6 +565,7 @@
+ .llseek = seq_lseek,
+ .release = nv_procfs_close_unbind_lock,
+ };
++#endif
+
+ static int
+ nv_procfs_read_text_file(
+diff -Naur a/kernel/nv-vm.c b/kernel/nv-vm.c
+--- a/kernel/nv-vm.c 2022-01-21 18:37:49.979268189 +0100
++++ b/kernel/nv-vm.c 2022-01-21 18:38:55.097843883 +0100
+@@ -12,6 +12,9 @@
+ #include "os-interface.h"
+ #include "nv.h"
+ #include "nv-linux.h"
++#if defined(NV_ASM_SET_MEMORY_H_PRESENT)
++#include <asm/set_memory.h>
++#endif
+
+ static inline void nv_set_contig_memory_uc(nv_pte_t *page_ptr, NvU32 num_pages)
+ {
+diff -Naur a/kernel/os-interface.c b/kernel/os-interface.c
+--- a/kernel/os-interface.c 2022-01-21 18:37:49.982268124 +0100
++++ b/kernel/os-interface.c 2022-01-21 18:38:55.115843489 +0100
+@@ -439,7 +439,7 @@
+ NvU32 *useconds
+ )
+ {
+- struct timeval tm;
++ nv_timeval tm;
+
+ nv_gettimeofday(&tm);
+
+@@ -474,7 +474,7 @@
+ unsigned long usec;
+
+ #ifdef NV_CHECK_DELAY_ACCURACY
+- struct timeval tm1, tm2;
++ nv_timeval tm1, tm2;
+
+ nv_gettimeofday(&tm1);
+ #endif
+@@ -514,9 +514,9 @@
+ unsigned long MicroSeconds;
+ unsigned long jiffies;
+ unsigned long mdelay_safe_msec;
+- struct timeval tm_end, tm_aux;
++ nv_timeval tm_end, tm_aux;
+ #ifdef NV_CHECK_DELAY_ACCURACY
+- struct timeval tm_start;
++ nv_timeval tm_start;
+ #endif
+
+ nv_gettimeofday(&tm_aux);
+@@ -549,7 +549,7 @@
+ // the requested timeout has expired, loop until less
+ // than a jiffie of the desired delay remains.
+ //
+- current->state = TASK_INTERRUPTIBLE;
++ set_current_state(TASK_INTERRUPTIBLE);
+ do
+ {
+ schedule_timeout(jiffies);
+diff -Naur a/kernel/os-interface.h b/kernel/os-interface.h
+--- a/kernel/os-interface.h 2022-01-21 18:37:49.982268124 +0100
++++ b/kernel/os-interface.h 2022-01-21 18:38:55.116843467 +0100
+@@ -24,7 +24,7 @@
+ * *
+ \***************************************************************************/
+
+-#include <stdarg.h>
++#include "nv_stdarg.h"
+
+ /*
+ * Define away Microsoft compiler extensions when possible
+diff -Naur a/kernel/os-mlock.c b/kernel/os-mlock.c
+--- a/kernel/os-mlock.c 2022-01-21 18:37:49.983268102 +0100
++++ b/kernel/os-mlock.c 2022-01-21 18:38:55.117843445 +0100
+@@ -44,11 +44,19 @@
+ return rmStatus;
+ }
+
++#if defined(NV_MM_HAS_MMAP_LOCK)
++ down_read(&mm->mmap_lock);
++ ret = NV_GET_USER_PAGES((unsigned long)address,
++ page_count, write, force, user_pages, NULL);
++ up_read(&mm->mmap_lock);
++ pinned = ret;
++#else
+ down_read(&mm->mmap_sem);
+ ret = NV_GET_USER_PAGES((unsigned long)address,
+ page_count, write, force, user_pages, NULL);
+ up_read(&mm->mmap_sem);
+ pinned = ret;
++#endif
+
+ if (ret < 0)
+ {
+diff -Naur a/kernel/uvm/conftest.sh b/kernel/uvm/conftest.sh
+--- a/kernel/uvm/conftest.sh 2022-01-21 18:37:49.984268080 +0100
++++ b/kernel/uvm/conftest.sh 2022-01-21 18:38:55.119843402 +0100
+@@ -176,6 +176,7 @@
+ FILES="$FILES linux/ktime.h"
+ FILES="$FILES linux/file.h"
+
++ FILES_ARCH="$FILES_ARCH asm/pgtable.h"
+ FILES_ARCH="$FILES_ARCH asm/set_memory.h"
+
+ translate_and_find_header_files $HEADERS $FILES
+@@ -440,6 +441,9 @@
+ # Determine if the set_memory_array_uc() function is present.
+ #
+ CODE="
++ #if defined(NV_ASM_PGTABLE_H_PRESENT)
++ #include <asm/pgtable.h>
++ #endif
+ #if defined(NV_ASM_SET_MEMORY_H_PRESENT)
+ #include <asm/set_memory.h>
+ #else
+diff -Naur a/kernel/uvm/Makefile b/kernel/uvm/Makefile
+--- a/kernel/uvm/Makefile 2022-01-21 18:37:49.983268102 +0100
++++ b/kernel/uvm/Makefile 2022-01-21 18:38:55.117843445 +0100
+@@ -207,6 +207,7 @@
+
+ RM_MODULE_SYMVERS:= $(RM_OUT_DIR)/Module.symvers
+ UVM_MODULE_SYMVERS:= $(obj)/Module.symvers
++KBUILD_EXTRA_SYMBOLS:= $(UVM_MODULE_SYMVERS)
+
+ module $(MODULE_NAME).ko: $(UVM_MODULE_SYMVERS) debug_diagnostics_printing
+
+diff -Naur a/kernel/uvm/nvidia_uvm_linux.h b/kernel/uvm/nvidia_uvm_linux.h
+--- a/kernel/uvm/nvidia_uvm_linux.h 2022-01-21 18:37:49.985268058 +0100
++++ b/kernel/uvm/nvidia_uvm_linux.h 2022-01-21 18:38:55.120843380 +0100
+@@ -141,7 +141,9 @@
+ #if !defined(NV_VMWARE)
+ #include <asm/tlbflush.h> /* flush_tlb(), flush_tlb_all() */
+ #endif
+-#include <asm/kmap_types.h> /* page table entry lookup */
++#if defined(NV_ASM_KMAP_TYPES_H_PRESENT)
++ #include <asm/kmap_types.h> /* page table entry lookup */
++#endif
+
+ #include <linux/interrupt.h> /* tasklets, interrupt helpers */
+ #include <linux/timer.h>
+@@ -156,7 +158,7 @@
+ #include <asm/page.h> /* PAGE_OFFSET */
+ #include <asm/pgtable.h> /* pte bit definitions */
+
+-#if defined(NVCPU_X86_64) && !defined(HAVE_COMPAT_IOCTL)
++#if defined(NVCPU_X86_64) && !defined(NV_FILE_OPERATIONS_HAS_COMPAT_IOCTL)
+ #include <linux/syscalls.h> /* sys_ioctl() */
+ #include <linux/ioctl32.h> /* register_ioctl32_conversion() */
+ #endif
+diff -Naur a/kernel/uvm/nvidia_uvm_lite_api.c b/kernel/uvm/nvidia_uvm_lite_api.c
+--- a/kernel/uvm/nvidia_uvm_lite_api.c 2022-01-21 18:37:49.986268036 +0100
++++ b/kernel/uvm/nvidia_uvm_lite_api.c 2022-01-21 18:38:55.121843358 +0100
+@@ -30,6 +30,10 @@
+ #include "uvm_gpu_ops_tests.h"
+ #endif
+
++#if defined (NV_MM_HAS_MMAP_LOCK)
++#define mmap_sem mmap_lock
++#endif
++
+ //
+ // nvidia_uvm_lite_api.c
+ //
+diff -Naur a/kernel/uvm/nvidia_uvm_lite.c b/kernel/uvm/nvidia_uvm_lite.c
+--- a/kernel/uvm/nvidia_uvm_lite.c 2022-01-21 18:37:49.986268036 +0100
++++ b/kernel/uvm/nvidia_uvm_lite.c 2022-01-21 18:38:55.121843358 +0100
+@@ -131,8 +131,8 @@
+ RM_STATUS _preexisting_error_on_channel(UvmGpuMigrationTracking *pMigTracker,
+ UvmCommitRecord *pRecord);
+
+-static void _set_timeout_in_usec(struct timeval *src,
+- struct timeval *result,
++static void _set_timeout_in_usec(struct nv_timeval *src,
++ struct nv_timeval *result,
+ unsigned long timeoutInUsec)
+ {
+ if (!src || !result)
+@@ -820,7 +820,13 @@
+ }
+
+ #if defined(NV_VM_OPERATIONS_STRUCT_HAS_FAULT)
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 17, 0)
++vm_fault_t _fault(struct vm_fault *vmf)
++#elif LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0)
++int _fault(struct vm_fault *vmf)
++#else
+ int _fault(struct vm_area_struct *vma, struct vm_fault *vmf)
++#endif
+ {
+ #if defined(NV_VM_FAULT_HAS_ADDRESS)
+ unsigned long vaddr = vmf->address;
+@@ -828,8 +834,15 @@
+ unsigned long vaddr = (unsigned long)vmf->virtual_address;
+ #endif
+ struct page *page = NULL;
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 17, 0)
++ vm_fault_t retval;
++#else
+ int retval;
+
++#endif
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0)
++ struct vm_area_struct *vma = vmf->vma;
++#endif
+ retval = _fault_common(vma, vaddr, &page, vmf->flags);
+
+ vmf->page = page;
+@@ -868,7 +881,13 @@
+ // it's dealing with anonymous mapping (see handle_pte_fault).
+ //
+ #if defined(NV_VM_OPERATIONS_STRUCT_HAS_FAULT)
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 17, 0)
++vm_fault_t _sigbus_fault(struct vm_fault *vmf)
++#elif LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0)
++int _sigbus_fault(struct vm_fault *vmf)
++#else
+ int _sigbus_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
++#endif
+ {
+ vmf->page = NULL;
+ return VM_FAULT_SIGBUS;
+@@ -1992,9 +2011,9 @@
+ static RM_STATUS _check_ecc_errors(UvmGpuMigrationTracking *pMigTracker,
+ NvBool *pIsEccErrorSet)
+ {
+- struct timeval eccErrorStartTime = {0};
+- struct timeval eccErrorCurrentTime = {0};
+- struct timeval eccTimeout = {0};
++ struct nv_timeval eccErrorStartTime = {0};
++ struct nv_timeval eccErrorCurrentTime = {0};
++ struct nv_timeval eccTimeout = {0};
+ NvBool bEccErrorTimeout = NV_FALSE;
+ NvBool bEccIncomingError = NV_FALSE;
+ unsigned rmInterruptSet = 0;
diff --git a/kernel-5.11.patch b/import-files-from-390.147.patch
similarity index 82%
rename from kernel-5.11.patch
rename to import-files-from-390.147.patch
index c503e7f..24bc362 100644
--- a/kernel-5.11.patch
+++ b/import-files-from-390.147.patch
@@ -1,6 +1,6 @@
diff -Naur a/kernel/conftest.h b/kernel/conftest.h
--- a/kernel/conftest.h 1970-01-01 01:00:00.000000000 +0100
-+++ b/kernel/conftest.h 2021-06-09 21:37:47.508578460 +0200
++++ b/kernel/conftest.h 2022-01-21 18:37:50.019267315 +0100
@@ -0,0 +1,11 @@
+#ifndef _CONFTEST_H
+#define _CONFTEST_H
@@ -14,8 +14,8 @@ diff -Naur a/kernel/conftest.h b/kernel/conftest.h
+
+#endif
diff -Naur a/kernel/conftest.sh b/kernel/conftest.sh
---- a/kernel/conftest.sh 2021-06-09 20:45:03.126250601 +0200
-+++ b/kernel/conftest.sh 2021-06-09 21:37:47.510578416 +0200
+--- a/kernel/conftest.sh 2019-12-11 23:04:24.000000000 +0100
++++ b/kernel/conftest.sh 2022-01-21 18:37:50.022267249 +0100
@@ -24,7 +24,6 @@
OUTPUT=$5
XEN_PRESENT=1
@@ -155,7 +155,7 @@ diff -Naur a/kernel/conftest.sh b/kernel/conftest.sh
FILES="$FILES linux/printk.h"
FILES="$FILES linux/ratelimit.h"
FILES="$FILES linux/prio_tree.h"
-@@ -171,28 +129,22 @@
+@@ -171,27 +129,23 @@
FILES="$FILES linux/bug.h"
FILES="$FILES linux/sched/signal.h"
FILES="$FILES linux/sched/task.h"
@@ -166,8 +166,8 @@ diff -Naur a/kernel/conftest.sh b/kernel/conftest.sh
- FILES="$FILES linux/file.h"
+ FILES="$FILES linux/dma-resv.h"
+ FILES="$FILES linux/dma-map-ops.h"
++ FILES="$FILES linux/stdarg.h"
-- FILES_ARCH="$FILES_ARCH asm/pgtable.h"
+ # Arch specific headers which need testing
+ FILES_ARCH="asm/book3s/64/hash-64k.h"
FILES_ARCH="$FILES_ARCH asm/set_memory.h"
@@ -192,7 +192,7 @@ diff -Naur a/kernel/conftest.sh b/kernel/conftest.sh
}
build_cflags() {
-@@ -203,72 +155,61 @@
+@@ -202,72 +156,61 @@
if [ "$OUTPUT" != "$SOURCES" ]; then
OUTPUT_CFLAGS="-I$OUTPUT/include2 -I$OUTPUT/include"
if [ -f "$OUTPUT/include/generated/autoconf.h" ]; then
@@ -306,7 +306,7 @@ diff -Naur a/kernel/conftest.sh b/kernel/conftest.sh
if [ -n "$BUILD_PARAMS" ]; then
CFLAGS="$CFLAGS -D$BUILD_PARAMS"
fi
-@@ -289,9 +230,31 @@
+@@ -288,9 +231,31 @@
CFLAGS="$CFLAGS -DCC_HAVE_ASM_GOTO"
fi
fi
@@ -339,7 +339,7 @@ diff -Naur a/kernel/conftest.sh b/kernel/conftest.sh
#if defined(NV_LINUX_KCONFIG_H_PRESENT)
#include <linux/kconfig.h>
#endif
-@@ -357,6 +320,47 @@
+@@ -356,6 +321,47 @@
fi
}
@@ -387,7 +387,7 @@ diff -Naur a/kernel/conftest.sh b/kernel/conftest.sh
get_configuration_option() {
#
# Print the value of given configuration option, if defined
-@@ -425,6 +429,9 @@
+@@ -424,6 +430,9 @@
#
CODE="
#if defined(NV_ASM_SET_MEMORY_H_PRESENT)
@@ -397,13 +397,9 @@ diff -Naur a/kernel/conftest.sh b/kernel/conftest.sh
#include <asm/set_memory.h>
#else
#include <asm/cacheflush.h>
-@@ -441,10 +448,10 @@
- # Determine if the set_memory_array_uc() function is present.
+@@ -441,6 +450,9 @@
#
CODE="
-- #if defined(NV_ASM_PGTABLE_H_PRESENT)
-- #include <asm/pgtable.h>
-- #endif
#if defined(NV_ASM_SET_MEMORY_H_PRESENT)
+ #if defined(NV_ASM_PGTABLE_TYPES_H_PRESENT)
+ #include <asm/pgtable_types.h>
@@ -411,7 +407,7 @@ diff -Naur a/kernel/conftest.sh b/kernel/conftest.sh
#include <asm/set_memory.h>
#else
#include <asm/cacheflush.h>
-@@ -456,12 +463,50 @@
+@@ -452,12 +464,50 @@
compile_check_conftest "$CODE"
"NV_SET_MEMORY_ARRAY_UC_PRESENT" "" "functions"
;;
@@ -462,7 +458,7 @@ diff -Naur a/kernel/conftest.sh b/kernel/conftest.sh
#include <asm/set_memory.h>
#else
#include <asm/cacheflush.h>
-@@ -495,9 +540,7 @@
+@@ -491,9 +541,7 @@
#include <linux/version.h>
#include <linux/utsname.h>
#include <linux/mm.h>
@@ -473,7 +469,7 @@ diff -Naur a/kernel/conftest.sh b/kernel/conftest.sh
void conftest_change_page_attr(void) {
change_page_attr();
}"
-@@ -558,6 +601,20 @@
+@@ -554,6 +602,20 @@
fi
;;
@@ -494,7 +490,7 @@ diff -Naur a/kernel/conftest.sh b/kernel/conftest.sh
remap_pfn_range)
#
# Determine if the remap_pfn_range() function is
-@@ -572,61 +629,37 @@
+@@ -568,61 +630,37 @@
compile_check_conftest "$CODE"
"NV_REMAP_PFN_RANGE_PRESENT" "" "functions"
;;
@@ -581,7 +577,7 @@ diff -Naur a/kernel/conftest.sh b/kernel/conftest.sh
;;
i2c_adapter)
-@@ -772,6 +805,20 @@
+@@ -768,6 +806,20 @@
fi
;;
@@ -602,29 +598,7 @@ diff -Naur a/kernel/conftest.sh b/kernel/conftest.sh
acpi_device_ops)
#
# Determine if the 'acpi_device_ops' structure has
-@@ -918,21 +965,6 @@
- fi
- ;;
-
-- kmem_cache_create_usercopy)
-- #
-- # Determine if the kmem_cache_create_usercopy function exists.
-- #
-- # This function was added by:
-- # 2017-06-10 8eb8284b412906181357c2b0110d879d5af95e52
-- CODE="
-- #include <linux/slab.h>
-- void kmem_cache_create_usercopy(void) {
-- kmem_cache_create_usercopy();
-- }"
--
-- compile_check_conftest "$CODE"
"NV_KMEM_CACHE_CREATE_USERCOPY_PRESENT" "" "functions"
-- ;;
--
- smp_call_function)
- #
- # Determine if the smp_call_function() function is
-@@ -1078,16 +1110,6 @@
+@@ -1059,16 +1111,6 @@
compile_check_conftest "$CODE"
"NV_CPUHP_SETUP_STATE_PRESENT" "" "functions"
;;
@@ -641,30 +615,30 @@ diff -Naur a/kernel/conftest.sh b/kernel/conftest.sh
acpi_evaluate_integer)
#
# Determine if the acpi_evaluate_integer() function is
-@@ -1211,9 +1233,6 @@
- #
- # Determine if the ioremap_nocache() function is present.
+@@ -1188,6 +1230,19 @@
+ compile_check_conftest "$CODE"
"NV_IOREMAP_CACHE_PRESENT" "" "functions"
+ ;;
+
++ ioremap_nocache)
++ #
++ # Determine if the ioremap_nocache() function is present.
++ #
++ CODE="
++ #include <asm/io.h>
++ void conftest_ioremap_nocache(void) {
++ ioremap_nocache();
++ }"
++
++ compile_check_conftest "$CODE"
"NV_IOREMAP_NOCACHE_PRESENT" "" "functions"
++ ;;
++
+ ioremap_wc)
#
-- # Removed by commit 4bdc0d676a64 ("remove ioremap_nocache and
-- # devm_ioremap_nocache") in v5.6 (2020-01-06)
-- #
- CODE="
- #include <asm/io.h>
- void conftest_ioremap_nocache(void) {
-@@ -1406,57 +1425,6 @@
+ # Determine if the ioremap_wc() function is present.
+@@ -1371,47 +1426,6 @@
compile_check_conftest "$CODE"
"NV_FILE_OPERATIONS_HAS_COMPAT_IOCTL" "" "types"
;;
-- proc_ops)
-- CODE="
-- #include <linux/proc_fs.h>
-- int conftest_proc_ops(void) {
-- return offsetof(struct proc_ops, proc_open);
-- }"
--
-- compile_check_conftest "$CODE" "NV_HAVE_PROC_OPS"
"" "types"
-- ;;
--
- sg_init_table)
- #
- # Determine if the sg_init_table() function is present.
@@ -709,7 +683,7 @@ diff -Naur a/kernel/conftest.sh b/kernel/conftest.sh
sg_table)
#
# Determine if the struct sg_table type is present.
-@@ -1476,7 +1444,7 @@
+@@ -1431,7 +1445,7 @@
#
echo "$CONFTEST_PREAMBLE
#include <linux/scatterlist.h>
@@ -718,7 +692,7 @@ diff -Naur a/kernel/conftest.sh b/kernel/conftest.sh
}" > conftest$$.c
$CC $CFLAGS -c conftest$$.c > /dev/null 2>&1
-@@ -1492,7 +1460,7 @@
+@@ -1447,7 +1461,7 @@
CODE="
#include <linux/scatterlist.h>
@@ -727,7 +701,7 @@ diff -Naur a/kernel/conftest.sh b/kernel/conftest.sh
sg_alloc_table();
}"
-@@ -1565,6 +1533,197 @@
+@@ -1520,6 +1534,197 @@
return
;;
@@ -925,7 +899,7 @@ diff -Naur a/kernel/conftest.sh b/kernel/conftest.sh
drm_available)
#
# Determine if the DRM subsystem is usable
-@@ -1578,26 +1737,47 @@
+@@ -1533,26 +1738,47 @@
#include <drm/drm_drv.h>
#endif
@@ -983,7 +957,7 @@ diff -Naur a/kernel/conftest.sh b/kernel/conftest.sh
proc_create_data)
#
# Determine if the proc_create_data() function is present.
-@@ -1655,7 +1835,7 @@
+@@ -1610,7 +1836,7 @@
vm_operations_struct)
#
# Determine if the 'vm_operations_struct' structure has
@@ -992,7 +966,7 @@ diff -Naur a/kernel/conftest.sh b/kernel/conftest.sh
#
CODE="
#include <linux/mm.h>
-@@ -1664,45 +1844,56 @@
+@@ -1619,45 +1845,56 @@
}"
compile_check_conftest "$CODE"
"NV_VM_OPERATIONS_STRUCT_HAS_FAULT" "" "types"
@@ -1076,7 +1050,7 @@ diff -Naur a/kernel/conftest.sh b/kernel/conftest.sh
task_struct)
#
# Determine if the 'task_struct' structure has
-@@ -1717,6 +1908,20 @@
+@@ -1672,6 +1909,20 @@
compile_check_conftest "$CODE" "NV_TASK_STRUCT_HAS_CRED"
"" "types"
;;
@@ -1097,7 +1071,7 @@ diff -Naur a/kernel/conftest.sh b/kernel/conftest.sh
address_space)
#
# Determine if the 'address_space' structure has
-@@ -1800,6 +2005,19 @@
+@@ -1755,6 +2006,19 @@
compile_check_conftest "$CODE"
"NV_PM_VT_SWITCH_REQUIRED_PRESENT" "" "functions"
;;
@@ -1117,7 +1091,7 @@ diff -Naur a/kernel/conftest.sh b/kernel/conftest.sh
file_inode)
#
-@@ -1815,19 +2033,133 @@
+@@ -1770,19 +2034,133 @@
compile_check_conftest "$CODE" "NV_FILE_HAS_INODE"
"" "types"
;;
@@ -1135,9 +1109,7 @@ diff -Naur a/kernel/conftest.sh b/kernel/conftest.sh
+ #include <xen/interface/xen.h>
+ #include <xen/hvm.h>
+ #include <xen/ioemu.h>
- #endif
-- void conftest_drm_pci_set_busid(void) {
-- drm_pci_set_busid();
++ #endif
+ void conftest_xen_ioemu_inject_msi(void) {
+ xen_ioemu_inject_msi();
+ }"
@@ -1166,9 +1138,8 @@ diff -Naur a/kernel/conftest.sh b/kernel/conftest.sh
+ #include <linux/dma-mapping.h>
+ void conftest_dma_ops(void) {
+ (void)dma_ops;
- }"
-
-- compile_check_conftest "$CODE"
"NV_DRM_PCI_SET_BUSID_PRESENT" "" "functions"
++ }"
++
+ compile_check_conftest "$CODE" "NV_DMA_OPS_PRESENT"
"" "symbols"
+ ;;
+
@@ -1199,11 +1170,14 @@ diff -Naur a/kernel/conftest.sh b/kernel/conftest.sh
+ #include <linux/dma-map-ops.h>
+ #else
+ #include <linux/dma-mapping.h>
-+ #endif
+ #endif
+- void conftest_drm_pci_set_busid(void) {
+- drm_pci_set_busid();
+ void conftest_dma_map_ops(void) {
+ struct dma_map_ops ops;
-+ }"
-+
+ }"
+
+- compile_check_conftest "$CODE"
"NV_DRM_PCI_SET_BUSID_PRESENT" "" "functions"
+ compile_check_conftest "$CODE" "NV_DMA_MAP_OPS_PRESENT"
"" "types"
+ ;;
+
@@ -1258,7 +1232,7 @@ diff -Naur a/kernel/conftest.sh b/kernel/conftest.sh
;;
write_cr4)
-@@ -1843,6 +2175,66 @@
+@@ -1798,6 +2176,66 @@
compile_check_conftest "$CODE" "NV_WRITE_CR4_PRESENT"
"" "functions"
;;
@@ -1325,7 +1299,7 @@ diff -Naur a/kernel/conftest.sh b/kernel/conftest.sh
for_each_online_node)
#
# Determine if the for_each_online_node() function is present.
-@@ -1869,6 +2261,705 @@
+@@ -1824,6 +2262,705 @@
compile_check_conftest "$CODE" "NV_NODE_END_PFN_PRESENT"
"" "functions"
;;
@@ -2031,7 +2005,7 @@ diff -Naur a/kernel/conftest.sh b/kernel/conftest.sh
get_user_pages)
#
# Conftest for get_user_pages()
-@@ -1886,7 +2977,7 @@
+@@ -1841,7 +2978,7 @@
# 2016 Oct 12: 768ae309a96103ed02eb1e111e838c87854d8b51
#
# linux-4.4.168 cherry-picked commit 768ae309a961 without
@@ -2040,7 +2014,7 @@ diff -Naur a/kernel/conftest.sh b/kernel/conftest.sh
#
# Conftest #1: Check if get_user_pages accepts 6 arguments.
# Return if true.
-@@ -1966,7 +3057,6 @@
+@@ -1921,7 +3058,6 @@
return
fi
@@ -2048,7 +2022,7 @@ diff -Naur a/kernel/conftest.sh b/kernel/conftest.sh
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"
-@@ -1976,7 +3066,7 @@
+@@ -1931,7 +3067,7 @@
get_user_pages_remote)
#
# Determine if the function get_user_pages_remote() is
@@ -2057,7 +2031,7 @@ diff -Naur a/kernel/conftest.sh b/kernel/conftest.sh
#
# get_user_pages_remote() was added by:
# 2016 Feb 12: 1e9877902dc7e11d2be038371c6fbf2dfcd469d7
-@@ -1989,13 +3079,17 @@
+@@ -1944,13 +3080,17 @@
# get_user_pages_remote() added 'locked' parameter
# 2016 Dec 14:5b56d49fc31dbb0487e14ead790fc81ca9fb2c99
#
@@ -2076,7 +2050,7 @@ diff -Naur a/kernel/conftest.sh b/kernel/conftest.sh
get_user_pages_remote();
}" > conftest$$.c
-@@ -2004,6 +3098,7 @@
+@@ -1959,6 +3099,7 @@
if [ -f conftest$$.o ]; then
echo "#undef NV_GET_USER_PAGES_REMOTE_PRESENT" |
append_conftest "functions"
@@ -2084,7 +2058,7 @@ diff -Naur a/kernel/conftest.sh b/kernel/conftest.sh
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
-@@ -2031,14 +3126,20 @@
+@@ -1986,14 +3127,20 @@
rm -f conftest$$.c
if [ -f conftest$$.o ]; then
@@ -2106,7 +2080,7 @@ diff -Naur a/kernel/conftest.sh b/kernel/conftest.sh
echo "$CONFTEST_PREAMBLE
#include <linux/mm.h>
long get_user_pages_remote(struct task_struct *tsk,
-@@ -2056,95 +3157,438 @@
+@@ -2011,13 +3158,238 @@
rm -f conftest$$.c
if [ -f conftest$$.o ]; then
@@ -2161,20 +2135,16 @@ diff -Naur a/kernel/conftest.sh b/kernel/conftest.sh
+ }"
+ compile_check_conftest "$CODE" "NV_USLEEP_RANGE_PRESENT"
"" "functions"
- ;;
-
-- drm_driver_unload_has_int_return_type)
++ ;;
++
+ radix_tree_empty)
- #
-- # Determine if drm_driver::unload() returns integer value, which has
-- # been changed to void by commit -
++ #
+ # Determine if the function radix_tree_empty() is present.
- #
-- # 2017-01-06 11b3c20bdd15d17382068be569740de1dccb173d
++ #
+ # radix_tree_empty() was added by:
+ # 2016 May 21 : e9256efcc8e390fa4fcf796a0c0b47d642d77d32
- #
- CODE="
++ #
++ CODE="
+ #include <linux/radix-tree.h>
+ int conftest_radix_tree_empty(void) {
+ radix_tree_empty();
@@ -2194,18 +2164,16 @@ diff -Naur a/kernel/conftest.sh b/kernel/conftest.sh
+ # 2016-05-09 : a8ad0bd84f986072314595d05444719fdf29e412
+ #
+ echo "$CONFTEST_PREAMBLE
- #if defined(NV_DRM_DRMP_H_PRESENT)
- #include <drm/drmP.h>
- #endif
++ #if defined(NV_DRM_DRMP_H_PRESENT)
++ #include <drm/drmP.h>
++ #endif
+ #if defined(NV_DRM_DRM_GEM_H_PRESENT)
+ #include <drm/drm_gem.h>
+ #endif
+ void conftest_drm_gem_object_lookup(void) {
+ drm_gem_object_lookup(NULL, NULL, 0);
+ }" > conftest$$.c
-
-- #if defined(NV_DRM_DRM_DRV_H_PRESENT)
-- #include <drm/drm_drv.h>
++
+ $CC $CFLAGS -c conftest$$.c > /dev/null 2>&1
+ rm -f conftest$$.c
+
@@ -2219,22 +2187,17 @@ diff -Naur a/kernel/conftest.sh b/kernel/conftest.sh
+ echo "$CONFTEST_PREAMBLE
+ #if defined(NV_DRM_DRMP_H_PRESENT)
+ #include <drm/drmP.h>
- #endif
++ #endif
+ #if defined(NV_DRM_DRM_GEM_H_PRESENT)
+ #include <drm/drm_gem.h>
+ #endif
+ void conftest_drm_gem_object_lookup(void) {
+ drm_gem_object_lookup(NULL, 0);
+ }" > conftest$$.c
-
-- int conftest_drm_driver_unload_has_int_return_type(struct drm_driver *drv)
{
-- return drv->unload(NULL /* dev */);
-- }
-- "
++
+ $CC $CFLAGS -c conftest$$.c > /dev/null 2>&1
+ rm -f conftest$$.c
-
-- compile_check_conftest "$CODE"
"NV_DRM_DRIVER_UNLOAD_HAS_INT_RETURN_TYPE" "" "types"
++
+ if [ -f conftest$$.o ]; then
+ echo "#define NV_DRM_GEM_OBJECT_LOOKUP_PRESENT" |
append_conftest "functions"
+ echo "#define NV_DRM_GEM_OBJECT_LOOKUP_ARGUMENT_COUNT 2" |
append_conftest "functions"
@@ -2243,24 +2206,20 @@ diff -Naur a/kernel/conftest.sh b/kernel/conftest.sh
+ echo "#undef NV_DRM_GEM_OBJECT_LOOKUP_PRESENT" |
append_conftest "functions"
+ echo "#undef NV_DRM_GEM_OBJECT_LOOKUP_ARGUMENT_COUNT" |
append_conftest "functions"
+ fi
- ;;
-
-- drm_get_pci_dev)
++ ;;
++
+ drm_master_drop_has_from_release_arg)
- #
-- # Determine if drm_get_pci_dev() is present.
++ #
+ # Determine if drm_driver::master_drop() has 'from_release'
argument.
+ #
+ # Last argument 'bool from_release' has been removed by:
+ # 2016-06-21 : d6ed682eba54915ea56315bc2e5a33fca5922997
- #
- CODE="
- #if defined(NV_DRM_DRMP_H_PRESENT)
- #include <drm/drmP.h>
- #endif
-
-- #if defined(NV_DRM_DRM_PCI_H_PRESENT)
-- #include <drm/drm_pci.h>
++ #
++ CODE="
++ #if defined(NV_DRM_DRMP_H_PRESENT)
++ #include <drm/drmP.h>
++ #endif
++
+ void conftest_drm_master_drop_has_from_release_arg(struct drm_driver *drv)
{
+ drv->master_drop(NULL, NULL, false);
+ }"
@@ -2311,16 +2270,14 @@ diff -Naur a/kernel/conftest.sh b/kernel/conftest.sh
+ CODE="
+ #if defined(NV_DRM_DRM_ATOMIC_H_PRESENT)
+ #include <drm/drm_atomic.h>
- #endif
++ #endif
+ void conftest_drm_atomic_state_get(void) {
+ drm_atomic_state_get();
+ }"
+
+ compile_check_conftest "$CODE"
"NV_DRM_ATOMIC_STATE_REF_COUNTING_PRESENT" "" "functions"
+ ;;
-
-- void conftest_drm_legacy_pci_init(void) {
-- drm_get_pci_dev();
++
+ vm_ops_fault_removed_vma_arg)
+ #
+ # Determine if vma.vm_ops.fault takes (vma, vmf), or just (vmf)
@@ -2357,35 +2314,30 @@ diff -Naur a/kernel/conftest.sh b/kernel/conftest.sh
+ #endif
+ void conftest_pnv_npu2_init_context(void) {
+ pnv_npu2_init_context();
- }"
-
-- compile_check_conftest "$CODE"
"NV_DRM_GET_PCI_DEV_PRESENT" "" "functions"
++ }"
++
+ compile_check_conftest "$CODE"
"NV_PNV_NPU2_INIT_CONTEXT_PRESENT" "" "functions"
;;
-- drm_pci_init)
-+ drm_driver_unload_has_int_return_type)
-+ #
-+ # Determine if drm_driver::unload() returns integer value, which has
-+ # been changed to void by commit -
- #
-- # Determine if drm_pci_init() is present.
-+ # 2017-01-06 11b3c20bdd15d17382068be569740de1dccb173d
- #
- CODE="
- #if defined(NV_DRM_DRMP_H_PRESENT)
+ drm_driver_unload_has_int_return_type)
+@@ -2032,38 +3404,192 @@
#include <drm/drmP.h>
#endif
-- void conftest_drm_legacy_pci_init(void) {
-- drm_pci_init();
-+ int conftest_drm_driver_unload_has_int_return_type(struct drm_driver *drv)
{
-+ return drv->unload(NULL /* dev */);
+- #if defined(NV_DRM_DRM_DRV_H_PRESENT)
+- #include <drm/drm_drv.h>
+- #endif
+-
+ int conftest_drm_driver_unload_has_int_return_type(struct drm_driver *drv)
{
+ return drv->unload(NULL /* dev */);
+- }
+- "
+ }"
-+
-+ compile_check_conftest "$CODE"
"NV_DRM_DRIVER_UNLOAD_HAS_INT_RETURN_TYPE" "" "types"
-+ ;;
-+
+
+ compile_check_conftest "$CODE"
"NV_DRM_DRIVER_UNLOAD_HAS_INT_RETURN_TYPE" "" "types"
+ ;;
+
+- drm_legacy_pci_init)
+ kref_has_refcount_of_type_refcount_t)
+ CODE="
+ #include <linux/kref.h>
@@ -2406,21 +2358,28 @@ diff -Naur a/kernel/conftest.sh b/kernel/conftest.sh
+ ;;
+
+ drm_atomic_helper_disable_all)
-+ #
+ #
+- # Determine if drm_legacy_pci_init() is present. drm_pci_init() was
+- # deprecated and renamed to drm_legacy_pci_init by:
+ # Determine if the function drm_atomic_helper_disable_all() is
+ # present.
-+ #
+ #
+- # 2017-05-24 10631d724deff712343d96dd3017cd323349f761
+ # drm_atomic_helper_disable_all() has been added by:
+ # 2015-12-02 1494276000db789c6d2acd85747be4707051c801
-+ #
-+ CODE="
+ #
+ CODE="
+- #if defined(NV_DRM_DRMP_H_PRESENT)
+- #include <drm/drmP.h>
+ #if defined(NV_DRM_DRM_ATOMIC_HELPER_H_PRESENT)
+ #include <drm/drm_atomic_helper.h>
-+ #endif
+ #endif
+ void conftest_drm_atomic_helper_disable_all(void) {
+ drm_atomic_helper_disable_all();
+ }"
-+
+
+- #if defined(NV_DRM_DRM_PCI_H_PRESENT)
+- #include <drm/drm_pci.h>
+ compile_check_conftest "$CODE"
"NV_DRM_ATOMIC_HELPER_DISABLE_ALL_PRESENT" "" "functions"
+ ;;
+
@@ -2436,7 +2395,9 @@ diff -Naur a/kernel/conftest.sh b/kernel/conftest.sh
+ echo "$CONFTEST_PREAMBLE
+ #if defined(NV_DRM_DRM_ATOMIC_HELPER_H_PRESENT)
+ #include <drm/drm_atomic_helper.h>
-+ #endif
+ #endif
+- void conftest_drm_legacy_pci_init(void) {
+- drm_legacy_pci_init();
+ void conftest_drm_atomic_helper_set_config(void) {
+ drm_atomic_helper_set_config();
+ }" > conftest$$.c
@@ -2483,35 +2444,27 @@ diff -Naur a/kernel/conftest.sh b/kernel/conftest.sh
+ #endif
+ void conftest_drm_atomic_helper_crtc_destroy_state_has_crtc_arg(void) {
+ __drm_atomic_helper_crtc_destroy_state(NULL, NULL);
- }"
-
-- compile_check_conftest "$CODE" "NV_DRM_PCI_INIT_PRESENT"
"" "functions"
++ }"
++
+ compile_check_conftest "$CODE"
"NV_DRM_ATOMIC_HELPER_CRTC_DESTROY_STATE_HAS_CRTC_ARG" ""
"types"
- ;;
-
-- drm_legacy_pci_init)
++ ;;
++
+ drm_atomic_helper_connector_dpms)
- #
-- # Determine if drm_legacy_pci_init() is present. drm_pci_init() was
-- # deprecated and renamed to drm_legacy_pci_init by:
++ #
+ # Determine if the function drm_atomic_helper_connector_dpms() is present.
- #
-- # 2017-05-24 10631d724deff712343d96dd3017cd323349f761
++ #
+ # drm_atomic_helper_connector_dpms() was removed by:
+ # 2017-07-25 7d902c05b480cc44033dcb56e12e51b082656b42
- #
- CODE="
-- #if defined(NV_DRM_DRMP_H_PRESENT)
-- #include <drm/drmP.h>
++ #
++ CODE="
+ #if defined(NV_DRM_DRM_ATOMIC_HELPER_H_PRESENT)
+ #include <drm/drm_atomic_helper.h>
- #endif
++ #endif
+ void conftest_drm_atomic_helper_connector_dpms(void) {
+ drm_atomic_helper_connector_dpms();
-+ }"
+ }"
-- #if defined(NV_DRM_DRM_PCI_H_PRESENT)
-- #include <drm/drm_pci.h>
+- compile_check_conftest "$CODE"
"NV_DRM_LEGACY_PCI_INIT_PRESENT" "" "functions"
+ compile_check_conftest "$CODE"
"NV_DRM_ATOMIC_HELPER_CONNECTOR_DPMS_PRESENT" ""
"functions"
+ ;;
+
@@ -2526,9 +2479,7 @@ diff -Naur a/kernel/conftest.sh b/kernel/conftest.sh
+ #include <linux/backlight.h>
+ #if !defined(CONFIG_BACKLIGHT_CLASS_DEVICE)
+ #error Backlight class device not enabled
- #endif
-- void conftest_drm_legacy_pci_init(void) {
-- drm_legacy_pci_init();
++ #endif
+ void conftest_backlight_device_register(void) {
+ backlight_device_register(NULL, NULL, NULL, NULL, NULL);
+ }" > conftest$$.c
@@ -2556,9 +2507,8 @@ diff -Naur a/kernel/conftest.sh b/kernel/conftest.sh
+ void conftest_backlight_props_type(void) {
+ struct backlight_properties tmp;
+ tmp.type = BACKLIGHT_RAW;
- }"
-
-- compile_check_conftest "$CODE"
"NV_DRM_LEGACY_PCI_INIT_PRESENT" "" "functions"
++ }"
++
+ compile_check_conftest "$CODE"
"NV_BACKLIGHT_PROPERTIES_TYPE_PRESENT" "" "types"
+ ;;
+
@@ -2580,7 +2530,7 @@ diff -Naur a/kernel/conftest.sh b/kernel/conftest.sh
;;
timer_setup)
-@@ -2162,7 +3606,172 @@
+@@ -2081,7 +3607,172 @@
compile_check_conftest "$CODE" "NV_TIMER_SETUP_PRESENT"
"" "functions"
;;
@@ -2754,7 +2704,7 @@ diff -Naur a/kernel/conftest.sh b/kernel/conftest.sh
#
# Determine if the function do_gettimeofday() is
# present.
-@@ -2190,9 +3799,32 @@
+@@ -2109,9 +3800,32 @@
compile_check_conftest "$CODE"
"NV_DO_GETTIMEOFDAY_PRESENT" "" "functions"
;;
@@ -2789,7 +2739,7 @@ diff -Naur a/kernel/conftest.sh b/kernel/conftest.sh
#
# Added by commit e6b62714e87c8811d5564b6a0738dcde63a51774 (drm:
# Introduce drm_gem_object_{get,put}()) on 2017-02-28.
-@@ -2205,20 +3837,19 @@
+@@ -2124,20 +3838,19 @@
#if defined(NV_DRM_DRM_GEM_H_PRESENT)
#include <drm/drm_gem.h>
#endif
@@ -2817,7 +2767,7 @@ diff -Naur a/kernel/conftest.sh b/kernel/conftest.sh
#
CODE="
#if defined(NV_DRM_DRMP_H_PRESENT)
-@@ -2228,14 +3859,108 @@
+@@ -2147,14 +3860,108 @@
#if defined(NV_DRM_DRM_DRV_H_PRESENT)
#include <drm/drm_drv.h>
#endif
@@ -2857,9 +2807,7 @@ diff -Naur a/kernel/conftest.sh b/kernel/conftest.sh
+ void conftest_drm_connector_list_iter_begin(void) {
+ drm_connector_list_iter_begin();
+ }"
-
-- void conftest_drm_driver_legacy_feature_bit_present(struct drm_driver *drv)
{
-- drv->driver_features = DRIVER_LEGACY;
++
+ compile_check_conftest "$CODE"
"NV_DRM_CONNECTOR_LIST_ITER_BEGIN_PRESENT" "" "functions"
+ ;;
+
@@ -2879,11 +2827,12 @@ diff -Naur a/kernel/conftest.sh b/kernel/conftest.sh
+ struct drm_atomic_state *state,
+ bool stall) {
+ (void)drm_atomic_helper_swap_state(state, stall);
- }"
-
-- compile_check_conftest "$CODE"
"NV_DRM_DRIVER_LEGACY_FEATURE_BIT_PRESENT" "" "types"
-+ compile_check_conftest "$CODE"
"NV_DRM_ATOMIC_HELPER_SWAP_STATE_HAS_STALL_ARG" | append_conftest
"types"
++ }"
+
++ compile_check_conftest "$CODE"
"NV_DRM_ATOMIC_HELPER_SWAP_STATE_HAS_STALL_ARG" | append_conftest
"types"
+
+- void conftest_drm_driver_legacy_feature_bit_present(struct drm_driver *drv)
{
+- drv->driver_features = DRIVER_LEGACY;
+ #
+ # Determine if drm_atomic_helper_swap_state() returns int.
+ #
@@ -2899,8 +2848,9 @@ diff -Naur a/kernel/conftest.sh b/kernel/conftest.sh
+ struct drm_atomic_state *state,
+ bool stall) {
+ return drm_atomic_helper_swap_state(state, stall);
-+ }"
-+
+ }"
+
+- compile_check_conftest "$CODE"
"NV_DRM_DRIVER_LEGACY_FEATURE_BIT_PRESENT" "" "types"
+ compile_check_conftest "$CODE"
"NV_DRM_ATOMIC_HELPER_SWAP_STATE_RETURN_INT" | append_conftest
"types"
;;
@@ -2929,7 +2879,7 @@ diff -Naur a/kernel/conftest.sh b/kernel/conftest.sh
drm_driver_prime_flag_present)
#
-@@ -2262,6 +3987,7 @@
+@@ -2181,6 +3988,7 @@
#if defined(NV_DRM_DRM_DRV_H_PRESENT)
#include <drm/drm_drv.h>
#endif
@@ -2937,7 +2887,7 @@ diff -Naur a/kernel/conftest.sh b/kernel/conftest.sh
unsigned int drm_driver_prime_flag_present_conftest(void) {
return DRIVER_PRIME;
}"
-@@ -2269,12 +3995,453 @@
+@@ -2188,12 +3996,529 @@
compile_check_conftest "$CODE"
"NV_DRM_DRIVER_PRIME_FLAG_PRESENT" "" "types"
;;
@@ -3339,24 +3289,24 @@ diff -Naur a/kernel/conftest.sh b/kernel/conftest.sh
+ # atomic_check") passed the full atomic state to
+ # drm_crtc_helper_funcs::atomic_check()
+ #
-+ # Turning incompatible-pointer-types check into error is necessary
-+ # to make test fail if drm_crtc_helper_funcs::atomic_check is taking
-+ # 'crtc_state' instead of 'state', otherwise test simply
pass
-+ # because compilation succeeds throwing incompatible-pointer-types
-+ # warning. This test is expected to fail on Linux kernels <= v5.10,
-+ # the commit ea8daa7b9784 ("kbuild: Add option to turn incompatible
-+ # pointer check into error") has turned incompatible-pointer-types
-+ # check into error from v4.6.
++ # To test the signature of drm_crtc_helper_funcs::atomic_check(),
++ # declare a function prototype with typeof ::atomic_check(), and then
++ # define the corresponding function implementation with the expected
++ # signature. Successful compilation indicates that ::atomic_check()
++ # has the expected signature.
+ #
+ echo "$CONFTEST_PREAMBLE
+ #include <drm/drm_modeset_helper_vtables.h>
++
++ static const struct drm_crtc_helper_funcs *funcs;
++ typeof(*funcs->atomic_check)
conftest_drm_crtc_atomic_check_has_atomic_state_arg;
++
+ int conftest_drm_crtc_atomic_check_has_atomic_state_arg(
+ struct drm_crtc *crtc, struct drm_atomic_state *state) {
-+ const struct drm_crtc_helper_funcs *funcs = crtc->helper_private;
-+ return funcs->atomic_check(crtc, state);
++ return 0;
+ }" > conftest$$.c
+
-+ $CC $CFLAGS -Werror=incompatible-pointer-types -c conftest$$.c >
/dev/null 2>&1
++ $CC $CFLAGS -c conftest$$.c > /dev/null 2>&1
+ rm -f conftest$$.c
+
+ if [ -f conftest$$.o ]; then
@@ -3385,6 +3335,82 @@ diff -Naur a/kernel/conftest.sh b/kernel/conftest.sh
+
+ compile_check_conftest "$CODE"
"NV_DRM_GEM_OBJECT_VMAP_HAS_MAP_ARG" "" "types"
+ ;;
++
++ unsafe_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.
++ #
++ CODE="
++ #include <linux/mm.h>
++ void conftest_unsafe_follow_pfn(void) {
++ unsafe_follow_pfn();
++ }"
++
++ compile_check_conftest "$CODE"
"NV_UNSAFE_FOLLOW_PFN_PRESENT" "" "functions"
++ ;;
++
++ drm_plane_atomic_check_has_atomic_state_arg)
++ #
++ # Determine if drm_plane_helper_funcs::atomic_check takes 'state'
++ # argument of 'struct drm_atomic_state' type.
++ #
++ # The commit 7c11b99a8e58 ("drm/atomic: Pass the full state to
++ # planes atomic_check") passed the full atomic state to
++ # drm_plane_helper_funcs::atomic_check()
++ #
++ # To test the signature of drm_plane_helper_funcs::atomic_check(),
++ # declare a function prototype with typeof ::atomic_check(), and then
++ # define the corresponding function implementation with the expected
++ # signature. Successful compilation indicates that ::atomic_check()
++ # has the expected signature.
++ #
++ echo "$CONFTEST_PREAMBLE
++ #include <drm/drm_modeset_helper_vtables.h>
++
++ static const struct drm_plane_helper_funcs *funcs;
++ typeof(*funcs->atomic_check)
conftest_drm_plane_atomic_check_has_atomic_state_arg;
++
++ int conftest_drm_plane_atomic_check_has_atomic_state_arg(
++ struct drm_plane *plane, struct drm_atomic_state *state) {
++ return 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_DRM_PLANE_ATOMIC_CHECK_HAS_ATOMIC_STATE_ARG"
| append_conftest "types"
++ else
++ echo "#undef NV_DRM_PLANE_ATOMIC_CHECK_HAS_ATOMIC_STATE_ARG" |
append_conftest "types"
++ fi
++ ;;
++
++ drm_device_has_pdev)
++ #
++ # Determine if the 'drm_device' structure has a 'pdev'
field.
++ #
++ # Removed by commit b347e04452ff ("drm: Remove pdev field from
++ # struct drm_device") in v5.14-rc1.
++ #
++ CODE="
++ #if defined(NV_DRM_DRMP_H_PRESENT)
++ #include <drm/drmP.h>
++ #endif
++
++ #if defined(NV_DRM_DRM_DEVICE_H_PRESENT)
++ #include <drm/drm_device.h>
++ #endif
++
++ int conftest_drm_device_has_pdev(void) {
++ return offsetof(struct drm_device, pdev);
++ }"
++
++ compile_check_conftest "$CODE" "NV_DRM_DEVICE_HAS_PDEV"
"" "types"
++ ;;
esac
}
@@ -3394,7 +3420,7 @@ diff -Naur a/kernel/conftest.sh b/kernel/conftest.sh
case "$6" in
cc_sanity_check)
#
-@@ -2320,137 +4487,85 @@
+@@ -2239,137 +4564,85 @@
cc_version_check)
#
@@ -3502,23 +3528,23 @@ diff -Naur a/kernel/conftest.sh b/kernel/conftest.sh
echo "";
- echo "gcc-version-check failed:";
+ echo "Compiler version check failed:";
-+ echo "";
+ echo "";
+- echo "$MSG" | fmt -w 52
+ echo "The major and minor number of the compiler used to";
+ echo "compile the kernel:";
-+ echo "";
-+ echo "${kernel_cc_string}";
- echo "";
-- echo "$MSG" | fmt -w 52
-+ echo "does not match the compiler used here:";
echo "";
- echo "If you know what you are doing and want to override";
- echo "the gcc version check, you can do so by setting the";
- echo "IGNORE_CC_MISMATCH environment variable to
\"1\".";
-+ $CC --version
++ echo "${kernel_cc_string}";
echo "";
- echo "In any other case, set the CC environment variable";
- echo "to the name of the compiler that was used to compile";
- echo "the kernel.";
++ echo "does not match the compiler used here:";
++ echo "";
++ $CC --version
++ echo "";
+ echo "It is recommended to set the CC environment variable";
+ echo "to the compiler that was used to compile the kernel.";
echo ""
@@ -3594,7 +3620,7 @@ diff -Naur a/kernel/conftest.sh b/kernel/conftest.sh
fi
;;
-@@ -2530,52 +4645,6 @@
+@@ -2449,52 +4722,6 @@
fi
;;
@@ -3647,7 +3673,7 @@ diff -Naur a/kernel/conftest.sh b/kernel/conftest.sh
xen_sanity_check)
#
# Check if the target kernel is a Xen kernel. If so, exit, since
-@@ -2587,6 +4656,8 @@
+@@ -2506,6 +4733,8 @@
exit 0
fi
@@ -3656,7 +3682,7 @@ diff -Naur a/kernel/conftest.sh b/kernel/conftest.sh
if [ "$XEN_PRESENT" != "0" ]; then
echo "The kernel you are installing for is a Xen kernel!";
echo "";
-@@ -2652,7 +4723,7 @@
+@@ -2571,7 +4800,7 @@
for PATCH in patch-*.h; do
if [ -f $PATCH ]; then
@@ -3665,7 +3691,7 @@ diff -Naur a/kernel/conftest.sh b/kernel/conftest.sh
PATCHES="$PATCHES "`echo $PATCH | sed -s
's/patch-\(.*\)\.h/\1/'`
fi
done
-@@ -2660,14 +4731,11 @@
+@@ -2579,14 +4808,11 @@
echo "static struct {
const char *short_description;
const char *description;
@@ -3683,7 +3709,7 @@ diff -Naur a/kernel/conftest.sh b/kernel/conftest.sh
exit 0
;;
-@@ -2677,20 +4745,13 @@
+@@ -2596,20 +4822,13 @@
# Run a series of compile tests to determine the set of interfaces
# and features available in the target kernel.
#
@@ -3707,7 +3733,7 @@ diff -Naur a/kernel/conftest.sh b/kernel/conftest.sh
exit 0
;;
-@@ -2716,7 +4777,33 @@
+@@ -2635,7 +4854,33 @@
exit 1
fi
;;
@@ -3742,7 +3768,7 @@ diff -Naur a/kernel/conftest.sh b/kernel/conftest.sh
test_configuration_option)
#
# Check to see if the given config option is set.
-@@ -2760,4 +4847,25 @@
+@@ -2679,4 +4924,25 @@
exit 1
;;
@@ -3770,7 +3796,7 @@ diff -Naur a/kernel/conftest.sh b/kernel/conftest.sh
esac
diff -Naur a/kernel/nv-gpu-info.h b/kernel/nv-gpu-info.h
--- a/kernel/nv-gpu-info.h 1970-01-01 01:00:00.000000000 +0100
-+++ b/kernel/nv-gpu-info.h 2021-06-09 21:37:47.510578416 +0200
++++ b/kernel/nv-gpu-info.h 2022-01-21 18:37:50.022267249 +0100
@@ -0,0 +1,31 @@
+/* _NVRM_COPYRIGHT_BEGIN_
+ *
@@ -3805,7 +3831,7 @@ diff -Naur a/kernel/nv-gpu-info.h b/kernel/nv-gpu-info.h
+#endif /* _NV_GPU_INFO_H_ */
diff -Naur a/kernel/nvidia-dma-fence-helper.h b/kernel/nvidia-dma-fence-helper.h
--- a/kernel/nvidia-dma-fence-helper.h 1970-01-01 01:00:00.000000000 +0100
-+++ b/kernel/nvidia-dma-fence-helper.h 2021-06-09 21:37:47.510578416 +0200
++++ b/kernel/nvidia-dma-fence-helper.h 2022-01-21 18:37:50.023267227 +0100
@@ -0,0 +1,121 @@
+/*
+ * Copyright (c) 2017, NVIDIA CORPORATION. All rights reserved.
@@ -3930,7 +3956,7 @@ diff -Naur a/kernel/nvidia-dma-fence-helper.h
b/kernel/nvidia-dma-fence-helper.h
+#endif /* __NVIDIA_DMA_FENCE_HELPER_H__ */
diff -Naur a/kernel/nvidia-dma-resv-helper.h b/kernel/nvidia-dma-resv-helper.h
--- a/kernel/nvidia-dma-resv-helper.h 1970-01-01 01:00:00.000000000 +0100
-+++ b/kernel/nvidia-dma-resv-helper.h 2021-06-09 21:37:47.510578416 +0200
++++ b/kernel/nvidia-dma-resv-helper.h 2022-01-21 18:37:50.025267183 +0100
@@ -0,0 +1,80 @@
+/*
+ * Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved.
@@ -4014,7 +4040,7 @@ diff -Naur a/kernel/nvidia-dma-resv-helper.h
b/kernel/nvidia-dma-resv-helper.h
+#endif /* __NVIDIA_DMA_RESV_HELPER_H__ */
diff -Naur a/kernel/nvidia-drm-conftest.h b/kernel/nvidia-drm-conftest.h
--- a/kernel/nvidia-drm-conftest.h 1970-01-01 01:00:00.000000000 +0100
-+++ b/kernel/nvidia-drm-conftest.h 2021-06-09 21:37:47.510578416 +0200
++++ b/kernel/nvidia-drm-conftest.h 2022-01-21 18:37:50.025267183 +0100
@@ -0,0 +1,64 @@
+/*
+ * Copyright (c) 2017, NVIDIA CORPORATION. All rights reserved.
@@ -4082,7 +4108,7 @@ diff -Naur a/kernel/nvidia-drm-conftest.h
b/kernel/nvidia-drm-conftest.h
+#endif /* defined(__NVIDIA_DRM_CONFTEST_H__) */
diff -Naur a/kernel/nvidia-drm-gem.c b/kernel/nvidia-drm-gem.c
--- a/kernel/nvidia-drm-gem.c 1970-01-01 01:00:00.000000000 +0100
-+++ b/kernel/nvidia-drm-gem.c 2021-06-09 21:37:47.511578395 +0200
++++ b/kernel/nvidia-drm-gem.c 2022-01-21 18:37:50.025267183 +0100
@@ -0,0 +1,193 @@
+/*
+ * Copyright (c) 2015, NVIDIA CORPORATION. All rights reserved.
@@ -4279,7 +4305,7 @@ diff -Naur a/kernel/nvidia-drm-gem.c b/kernel/nvidia-drm-gem.c
+#endif /* NV_DRM_AVAILABLE */
diff -Naur a/kernel/nvidia-drm-gem.h b/kernel/nvidia-drm-gem.h
--- a/kernel/nvidia-drm-gem.h 1970-01-01 01:00:00.000000000 +0100
-+++ b/kernel/nvidia-drm-gem.h 2021-06-09 21:37:47.511578395 +0200
++++ b/kernel/nvidia-drm-gem.h 2022-01-21 18:37:50.026267161 +0100
@@ -0,0 +1,198 @@
+/*
+ * Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved.
@@ -4481,7 +4507,7 @@ diff -Naur a/kernel/nvidia-drm-gem.h b/kernel/nvidia-drm-gem.h
+#endif /* __NVIDIA_DRM_GEM_H__ */
diff -Naur a/kernel/nvidia-drm-gem-user-memory.c b/kernel/nvidia-drm-gem-user-memory.c
--- a/kernel/nvidia-drm-gem-user-memory.c 1970-01-01 01:00:00.000000000 +0100
-+++ b/kernel/nvidia-drm-gem-user-memory.c 2021-06-09 21:37:47.510578416 +0200
++++ b/kernel/nvidia-drm-gem-user-memory.c 2022-01-21 18:37:50.025267183 +0100
@@ -0,0 +1,139 @@
+/*
+ * Copyright (c) 2017, NVIDIA CORPORATION. All rights reserved.
@@ -4624,7 +4650,7 @@ diff -Naur a/kernel/nvidia-drm-gem-user-memory.c
b/kernel/nvidia-drm-gem-user-me
+#endif
diff -Naur a/kernel/nvidia-drm-gem-user-memory.h b/kernel/nvidia-drm-gem-user-memory.h
--- a/kernel/nvidia-drm-gem-user-memory.h 1970-01-01 01:00:00.000000000 +0100
-+++ b/kernel/nvidia-drm-gem-user-memory.h 2021-06-09 21:37:47.510578416 +0200
++++ b/kernel/nvidia-drm-gem-user-memory.h 2022-01-21 18:37:50.025267183 +0100
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 2017, NVIDIA CORPORATION. All rights reserved.
@@ -4681,7 +4707,7 @@ diff -Naur a/kernel/nvidia-drm-gem-user-memory.h
b/kernel/nvidia-drm-gem-user-me
+#endif /* __NVIDIA_DRM_GEM_USER_MEMORY_H__ */
diff -Naur a/kernel/nvidia-drm-helper.c b/kernel/nvidia-drm-helper.c
--- a/kernel/nvidia-drm-helper.c 1970-01-01 01:00:00.000000000 +0100
-+++ b/kernel/nvidia-drm-helper.c 2021-06-09 21:37:47.511578395 +0200
++++ b/kernel/nvidia-drm-helper.c 2022-01-21 18:37:50.026267161 +0100
@@ -0,0 +1,189 @@
+/*
+ * Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved.
@@ -4874,7 +4900,7 @@ diff -Naur a/kernel/nvidia-drm-helper.c
b/kernel/nvidia-drm-helper.c
+#endif /* NV_DRM_ATOMIC_MODESET_AVAILABLE */
diff -Naur a/kernel/nvidia-drm-helper.h b/kernel/nvidia-drm-helper.h
--- a/kernel/nvidia-drm-helper.h 1970-01-01 01:00:00.000000000 +0100
-+++ b/kernel/nvidia-drm-helper.h 2021-06-09 21:37:47.511578395 +0200
++++ b/kernel/nvidia-drm-helper.h 2022-01-21 18:37:50.027267140 +0100
@@ -0,0 +1,441 @@
+/*
+ * Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved.
@@ -5319,7 +5345,7 @@ diff -Naur a/kernel/nvidia-drm-helper.h
b/kernel/nvidia-drm-helper.h
+#endif /* __NVIDIA_DRM_HELPER_H__ */
diff -Naur a/kernel/nvidia-drm-ioctl.h b/kernel/nvidia-drm-ioctl.h
--- a/kernel/nvidia-drm-ioctl.h 1970-01-01 01:00:00.000000000 +0100
-+++ b/kernel/nvidia-drm-ioctl.h 2021-06-09 21:37:47.511578395 +0200
++++ b/kernel/nvidia-drm-ioctl.h 2022-01-21 18:37:50.027267140 +0100
@@ -0,0 +1,135 @@
+/*
+ * Copyright (c) 2015-2016, NVIDIA CORPORATION. All rights reserved.
@@ -5458,7 +5484,7 @@ diff -Naur a/kernel/nvidia-drm-ioctl.h b/kernel/nvidia-drm-ioctl.h
+#endif /* _UAPI_NVIDIA_DRM_IOCTL_H_ */
diff -Naur a/kernel/nvidia-drm-linux.c b/kernel/nvidia-drm-linux.c
--- a/kernel/nvidia-drm-linux.c 1970-01-01 01:00:00.000000000 +0100
-+++ b/kernel/nvidia-drm-linux.c 2021-06-09 21:37:47.511578395 +0200
++++ b/kernel/nvidia-drm-linux.c 2022-01-21 18:37:50.027267140 +0100
@@ -0,0 +1,185 @@
+/*
+ * Copyright (c) 2015, NVIDIA CORPORATION. All rights reserved.
@@ -5489,7 +5515,7 @@ diff -Naur a/kernel/nvidia-drm-linux.c b/kernel/nvidia-drm-linux.c
+#include "nvidia-drm-os-interface.h"
+#include "nvidia-drm.h"
+
-+#include "conftest.h"
++#include "nvidia-drm-conftest.h"
+
+#if defined(NV_DRM_AVAILABLE)
+
@@ -5647,7 +5673,7 @@ diff -Naur a/kernel/nvidia-drm-linux.c b/kernel/nvidia-drm-linux.c
+#endif
diff -Naur a/kernel/nvidia-drm-os-interface.h b/kernel/nvidia-drm-os-interface.h
--- a/kernel/nvidia-drm-os-interface.h 1970-01-01 01:00:00.000000000 +0100
-+++ b/kernel/nvidia-drm-os-interface.h 2021-06-09 21:37:47.512578373 +0200
++++ b/kernel/nvidia-drm-os-interface.h 2022-01-21 18:37:50.028267118 +0100
@@ -0,0 +1,56 @@
+/*
+ * Copyright (c) 2015, NVIDIA CORPORATION. All rights reserved.
@@ -5707,7 +5733,7 @@ diff -Naur a/kernel/nvidia-drm-os-interface.h
b/kernel/nvidia-drm-os-interface.h
+#endif /* __NVIDIA_DRM_OS_INTERFACE_H__ */
diff -Naur a/kernel/nvidia-drm-priv.h b/kernel/nvidia-drm-priv.h
--- a/kernel/nvidia-drm-priv.h 1970-01-01 01:00:00.000000000 +0100
-+++ b/kernel/nvidia-drm-priv.h 2021-06-09 21:37:47.512578373 +0200
++++ b/kernel/nvidia-drm-priv.h 2022-01-21 18:37:50.028267118 +0100
@@ -0,0 +1,119 @@
+/*
+ * Copyright (c) 2015, NVIDIA CORPORATION. All rights reserved.
@@ -5830,7 +5856,7 @@ diff -Naur a/kernel/nvidia-drm-priv.h b/kernel/nvidia-drm-priv.h
+#endif /* __NVIDIA_DRM_PRIV_H__ */
diff -Naur a/kernel/nvkms-api-types.h b/kernel/nvkms-api-types.h
--- a/kernel/nvkms-api-types.h 1970-01-01 01:00:00.000000000 +0100
-+++ b/kernel/nvkms-api-types.h 2021-06-09 21:37:47.512578373 +0200
++++ b/kernel/nvkms-api-types.h 2022-01-21 18:37:50.029267096 +0100
@@ -0,0 +1,306 @@
+/*
+ * Copyright (c) 2014-2015, NVIDIA CORPORATION. All rights reserved.
@@ -6140,7 +6166,7 @@ diff -Naur a/kernel/nvkms-api-types.h b/kernel/nvkms-api-types.h
+#endif /* NVKMS_API_TYPES_H */
diff -Naur a/kernel/nvkms-kapi.h b/kernel/nvkms-kapi.h
--- a/kernel/nvkms-kapi.h 1970-01-01 01:00:00.000000000 +0100
-+++ b/kernel/nvkms-kapi.h 2021-06-09 21:37:47.512578373 +0200
++++ b/kernel/nvkms-kapi.h 2022-01-21 18:37:50.029267096 +0100
@@ -0,0 +1,788 @@
+/* _NVRM_COPYRIGHT_BEGIN_
+ *
@@ -6932,7 +6958,7 @@ diff -Naur a/kernel/nvkms-kapi.h b/kernel/nvkms-kapi.h
+#endif /* defined(__NVKMS_KAPI_H__) */
diff -Naur a/kernel/nv-mm.h b/kernel/nv-mm.h
--- a/kernel/nv-mm.h 1970-01-01 01:00:00.000000000 +0100
-+++ b/kernel/nv-mm.h 2021-06-09 21:37:47.510578416 +0200
++++ b/kernel/nv-mm.h 2022-01-21 18:37:50.022267249 +0100
@@ -0,0 +1,285 @@
+/*******************************************************************************
+ Copyright (c) 2016-2017 NVIDIA Corporation
@@ -7219,1431 +7245,80 @@ diff -Naur a/kernel/nv-mm.h b/kernel/nv-mm.h
+}
+
+#endif // __NV_MM_H__
-diff -Naur a/kernel/conftest.Kbuild b/kernel/conftest.Kbuild
---- a/kernel/conftest.Kbuild 1970-01-01 01:00:00.000000000 +0100
-+++ b/kernel/conftest.Kbuild 2021-06-09 21:39:15.630612177 +0200
-@@ -0,0 +1,210 @@
-+NV_CONFTEST_GENERIC_COMPILE_TESTS += drm_available
-+NV_CONFTEST_GENERIC_COMPILE_TESTS += drm_atomic_available
-+NV_CONFTEST_GENERIC_COMPILE_TESTS += dom0_kernel_present
-+NV_CONFTEST_GENERIC_COMPILE_TESTS += nvmap_support
-+
-+NV_CONFTEST_FUNCTION_COMPILE_TESTS += remap_pfn_range
-+NV_CONFTEST_FUNCTION_COMPILE_TESTS += vmap
-+NV_CONFTEST_FUNCTION_COMPILE_TESTS += set_pages_uc
-+NV_CONFTEST_FUNCTION_COMPILE_TESTS += set_memory_uc
-+NV_CONFTEST_FUNCTION_COMPILE_TESTS += set_memory_array_uc
-+NV_CONFTEST_FUNCTION_COMPILE_TESTS += change_page_attr
-+NV_CONFTEST_FUNCTION_COMPILE_TESTS += pci_get_class
-+NV_CONFTEST_FUNCTION_COMPILE_TESTS += pci_choose_state
-+NV_CONFTEST_FUNCTION_COMPILE_TESTS += vm_insert_page
-+NV_CONFTEST_FUNCTION_COMPILE_TESTS += acquire_console_sem
-+NV_CONFTEST_FUNCTION_COMPILE_TESTS += console_lock
-+NV_CONFTEST_FUNCTION_COMPILE_TESTS += kmem_cache_create
-+NV_CONFTEST_FUNCTION_COMPILE_TESTS += kmem_cache_create_usercopy
-+NV_CONFTEST_FUNCTION_COMPILE_TESTS += on_each_cpu
-+NV_CONFTEST_FUNCTION_COMPILE_TESTS += smp_call_function
-+NV_CONFTEST_FUNCTION_COMPILE_TESTS += acpi_evaluate_integer
-+NV_CONFTEST_FUNCTION_COMPILE_TESTS += ioremap_cache
-+NV_CONFTEST_FUNCTION_COMPILE_TESTS += ioremap_nocache
-+NV_CONFTEST_FUNCTION_COMPILE_TESTS += ioremap_wc
-+NV_CONFTEST_FUNCTION_COMPILE_TESTS += acpi_walk_namespace
-+NV_CONFTEST_FUNCTION_COMPILE_TESTS += pci_domain_nr
-+NV_CONFTEST_FUNCTION_COMPILE_TESTS += pci_dma_mapping_error
-+NV_CONFTEST_FUNCTION_COMPILE_TESTS += file_operations
-+NV_CONFTEST_FUNCTION_COMPILE_TESTS += proc_ops
-+NV_CONFTEST_FUNCTION_COMPILE_TESTS += sg_alloc_table
-+NV_CONFTEST_FUNCTION_COMPILE_TESTS += sg_init_table
-+NV_CONFTEST_FUNCTION_COMPILE_TESTS += pci_get_domain_bus_and_slot
-+NV_CONFTEST_FUNCTION_COMPILE_TESTS += get_num_physpages
-+NV_CONFTEST_FUNCTION_COMPILE_TESTS += proc_create_data
-+NV_CONFTEST_FUNCTION_COMPILE_TESTS += pde_data
-+NV_CONFTEST_FUNCTION_COMPILE_TESTS += proc_remove
-+NV_CONFTEST_FUNCTION_COMPILE_TESTS += pm_vt_switch_required
-+NV_CONFTEST_FUNCTION_COMPILE_TESTS += pci_save_state
-+NV_CONFTEST_FUNCTION_COMPILE_TESTS += drm_pci_set_busid
-+NV_CONFTEST_FUNCTION_COMPILE_TESTS += write_cr4
-+NV_CONFTEST_FUNCTION_COMPILE_TESTS += for_each_online_node
-+NV_CONFTEST_FUNCTION_COMPILE_TESTS += node_end_pfn
-+NV_CONFTEST_FUNCTION_COMPILE_TESTS += get_user_pages
-+NV_CONFTEST_FUNCTION_COMPILE_TESTS += get_user_pages_remote
-+NV_CONFTEST_FUNCTION_COMPILE_TESTS += register_cpu_notifier
-+NV_CONFTEST_FUNCTION_COMPILE_TESTS += cpuhp_setup_state
-+NV_CONFTEST_FUNCTION_COMPILE_TESTS += drm_get_pci_dev
-+NV_CONFTEST_FUNCTION_COMPILE_TESTS += drm_pci_init
-+NV_CONFTEST_FUNCTION_COMPILE_TESTS += drm_legacy_pci_init
-+NV_CONFTEST_FUNCTION_COMPILE_TESTS += timer_setup
-+NV_CONFTEST_FUNCTION_COMPILE_TESTS += do_gettimeofday
-+NV_CONFTEST_FUNCTION_COMPILE_TESTS += drm_gem_object_put_unlocked
-+NV_CONFTEST_FUNCTION_COMPILE_TESTS += efi_enabled
-+
-+NV_CONFTEST_FUNCTION_COMPILE_TESTS += drm_gem_object_get
-+NV_CONFTEST_FUNCTION_COMPILE_TESTS += drm_atomic_state_ref_counting
-+NV_CONFTEST_FUNCTION_COMPILE_TESTS += drm_gem_object_lookup
-+NV_CONFTEST_FUNCTION_COMPILE_TESTS += drm_dev_put
-+NV_CONFTEST_FUNCTION_COMPILE_TESTS += drm_framebuffer_get
-+NV_CONFTEST_FUNCTION_COMPILE_TESTS += drm_connector_for_each_possible_encoder
-+NV_CONFTEST_FUNCTION_COMPILE_TESTS += vga_tryget
-+
-+NV_CONFTEST_SYMBOL_COMPILE_TESTS += efi_enabled
-+NV_CONFTEST_SYMBOL_COMPILE_TESTS += export_symbol_gpl_conftest
-+
-+NV_CONFTEST_TYPE_COMPILE_TESTS += i2c_adapter
-+NV_CONFTEST_TYPE_COMPILE_TESTS += pm_message_t
-+NV_CONFTEST_TYPE_COMPILE_TESTS += irq_handler_t
-+NV_CONFTEST_TYPE_COMPILE_TESTS += acpi_device_ops
-+NV_CONFTEST_TYPE_COMPILE_TESTS += acpi_op_remove
-+NV_CONFTEST_TYPE_COMPILE_TESTS += acpi_device_id
-+NV_CONFTEST_TYPE_COMPILE_TESTS += outer_flush_all
-+NV_CONFTEST_TYPE_COMPILE_TESTS += proc_dir_entry
-+NV_CONFTEST_TYPE_COMPILE_TESTS += scatterlist
-+NV_CONFTEST_TYPE_COMPILE_TESTS += sg_table
-+NV_CONFTEST_TYPE_COMPILE_TESTS += file_inode
-+NV_CONFTEST_TYPE_COMPILE_TESTS += drm_bus_present
-+NV_CONFTEST_TYPE_COMPILE_TESTS += drm_bus_has_bus_type
-+NV_CONFTEST_TYPE_COMPILE_TESTS += drm_bus_has_get_irq
-+NV_CONFTEST_TYPE_COMPILE_TESTS += drm_bus_has_get_name
-+NV_CONFTEST_TYPE_COMPILE_TESTS += vm_fault_t
-+NV_CONFTEST_TYPE_COMPILE_TESTS += vm_fault_present
-+NV_CONFTEST_TYPE_COMPILE_TESTS += vm_fault_has_address
-+NV_CONFTEST_TYPE_COMPILE_TESTS += drm_driver_unload_has_int_return_type
-+NV_CONFTEST_TYPE_COMPILE_TESTS += drm_driver_legacy_feature_bit_present
-+NV_CONFTEST_TYPE_COMPILE_TESTS += drm_driver_prime_flag_present
-+
-+NV_CONFTEST_TYPE_COMPILE_TESTS += mm_has_mmap_lock
-+NV_CONFTEST_TYPE_COMPILE_TESTS += drm_gem_object_vmap_has_map_arg
-+NV_CONFTEST_TYPE_COMPILE_TESTS += drm_mode_object_find_has_file_priv_arg
-+NV_CONFTEST_TYPE_COMPILE_TESTS += drm_prime_pages_to_sg_has_drm_device_arg
-+NV_CONFTEST_TYPE_COMPILE_TESTS += drm_gem_object_has_resv
-+
-+NV_CONFTEST_TYPE_COMPILE_TESTS += drm_gem_prime_export_has_dev_arg
-+NV_CONFTEST_TYPE_COMPILE_TESTS += drm_driver_has_gem_prime_callbacks
-+NV_CONFTEST_TYPE_COMPILE_TESTS += drm_driver_has_gem_free_object
-+NV_CONFTEST_TYPE_COMPILE_TESTS += drm_driver_has_gem_prime_res_obj
-+NV_CONFTEST_TYPE_COMPILE_TESTS += vmalloc_has_pgprot_t_arg
-+
-+NV_CONFTEST_MACRO_COMPILE_TESTS += INIT_WORK
-+
-+# The conftest.sh script tests various aspects of the target kernel.
-+# The per-module Kbuild files included above should:
-+#
-+# - Append to the NV_CONFTEST_*_COMPILE_TESTS variables to indicate
-+# which conftests they require.
-+# - Append to the NV_OBJECTS_DEPEND_ON_CONFTEST variable any object files
-+# that depend on conftest.
-+#
-+# The conftest machinery below will run the requested tests and
-+# generate the appropriate header files.
-+#
-+
-+CC ?= cc
-+HOST_CC ?= $(CC)
-+LD ?= ld
-+
-+NV_CONFTEST_SCRIPT := $(src)/conftest.sh
-+NV_CONFTEST_HEADER := $(obj)/conftest/headers.h
-+
-+NV_CONFTEST_CMD := /bin/sh $(NV_CONFTEST_SCRIPT) \
-+ "$(CC)" "$(HOST_CC)" $(ARCH) $(KERNEL_SOURCES) $(KERNEL_OUTPUT)
-+
-+NV_CONFTEST_CFLAGS := $(shell $(NV_CONFTEST_CMD) build_cflags)
-+
-+NV_CONFTEST_COMPILE_TEST_HEADERS := $(obj)/conftest/macros.h
-+NV_CONFTEST_COMPILE_TEST_HEADERS += $(obj)/conftest/functions.h
-+NV_CONFTEST_COMPILE_TEST_HEADERS += $(obj)/conftest/symbols.h
-+NV_CONFTEST_COMPILE_TEST_HEADERS += $(obj)/conftest/types.h
-+NV_CONFTEST_COMPILE_TEST_HEADERS += $(obj)/conftest/generic.h
-+
-+NV_CONFTEST_HEADERS := $(obj)/conftest/patches.h
-+NV_CONFTEST_HEADERS += $(obj)/conftest/headers.h
-+NV_CONFTEST_HEADERS += $(NV_CONFTEST_COMPILE_TEST_HEADERS)
-+
-+
-+#
-+# Generate a header file for a single conftest compile test. Each compile test
-+# header depends on conftest.sh, as well as the generated conftest/headers.h
-+# file, which is included in the compile test preamble.
-+#
-+
-+$(obj)/conftest/compile-tests/%.h: $(NV_CONFTEST_SCRIPT) $(NV_CONFTEST_HEADER)
-+ @mkdir -p $(obj)/conftest/compile-tests
-+ @echo " CONFTEST: $(notdir $*)"
-+ @$(NV_CONFTEST_CMD) compile_tests '$(NV_CONFTEST_CFLAGS)' \
-+ $(notdir $*) > $@
-+
-+#
-+# Concatenate a conftest/*.h header from its constituent compile test headers
-+#
-+# $(1): The name of the concatenated header
-+# $(2): The list of compile tests that make up the header
-+#
-+
-+define NV_GENERATE_COMPILE_TEST_HEADER
-+ $(obj)/conftest/$(1).h: $(addprefix $(obj)/conftest/compile-tests/,$(addsuffix
.h,$(2)))
-+ @mkdir -p $(obj)/conftest
-+ @# concatenate /dev/null to prevent cat from hanging when $$^ is empty
-+ @cat $$^ /dev/null > $$@
-+endef
-+
-+#
-+# Generate the conftest compile test headers from the lists of compile tests
-+# provided by the module-specific Kbuild files.
-+#
-+NV_CONFTEST_FUNCTION_COMPILE_TESTS ?=
-+NV_CONFTEST_GENERIC_COMPILE_TESTS ?=
-+NV_CONFTEST_MACRO_COMPILE_TESTS ?=
-+NV_CONFTEST_SYMBOL_COMPILE_TESTS ?=
-+NV_CONFTEST_TYPE_COMPILE_TESTS ?=
-+
-+$(eval $(call
NV_GENERATE_COMPILE_TEST_HEADER,functions,$(NV_CONFTEST_FUNCTION_COMPILE_TESTS)))
-+$(eval $(call
NV_GENERATE_COMPILE_TEST_HEADER,generic,$(NV_CONFTEST_GENERIC_COMPILE_TESTS)))
-+$(eval $(call
NV_GENERATE_COMPILE_TEST_HEADER,macros,$(NV_CONFTEST_MACRO_COMPILE_TESTS)))
-+$(eval $(call
NV_GENERATE_COMPILE_TEST_HEADER,symbols,$(NV_CONFTEST_SYMBOL_COMPILE_TESTS)))
-+$(eval $(call NV_GENERATE_COMPILE_TEST_HEADER,types,$(NV_CONFTEST_TYPE_COMPILE_TESTS)))
-+
-+$(obj)/conftest/patches.h: $(NV_CONFTEST_SCRIPT)
-+ @mkdir -p $(obj)/conftest
-+ @$(NV_CONFTEST_CMD) patch_check > $@
-+
-+$(obj)/conftest/headers.h: $(NV_CONFTEST_SCRIPT)
-+ @mkdir -p $(obj)/conftest
-+ @$(NV_CONFTEST_CMD) test_kernel_headers > $@
-+
-+clean-dirs := $(obj)/conftest
-+
-+
-+# For any object files that depend on conftest, declare the dependency here.
-+$(addprefix $(obj)/,$(NV_OBJECTS_DEPEND_ON_CONFTEST)): | $(NV_CONFTEST_HEADERS)
-+
-+# Sanity checks of the build environment and target system/kernel
-+
-+BUILD_SANITY_CHECKS = \
-+ cc_sanity_check \
-+ cc_version_check \
-+ dom0_sanity_check \
-+ xen_sanity_check \
-+ preempt_rt_sanity_check \
-+ vgpu_kvm_sanity_check
-+
-+.PHONY: $(BUILD_SANITY_CHECKS)
-+
-+$(BUILD_SANITY_CHECKS):
-+ @$(NV_CONFTEST_CMD) $@ full_output
-+
-+# Perform all sanity checks before generating the conftest headers
-+
-+$(NV_CONFTEST_HEADERS): | $(BUILD_SANITY_CHECKS)
-diff -Naur a/kernel/conftest.sh b/kernel/conftest.sh
---- a/kernel/conftest.sh 2021-06-09 21:37:47.510578416 +0200
-+++ b/kernel/conftest.sh 2021-06-11 10:09:39.116572777 +0200
-@@ -113,6 +113,7 @@
- FILES="$FILES drm/drm_vblank.h"
- FILES="$FILES drm/drm_file.h"
- FILES="$FILES drm/drm_ioctl.h"
-+ FILES="$FILES drm/drm_pci.h"
- FILES="$FILES drm/drm_device.h"
- FILES="$FILES generated/autoconf.h"
- FILES="$FILES generated/compile.h"
-@@ -121,6 +122,7 @@
- FILES="$FILES linux/kconfig.h"
- FILES="$FILES linux/screen_info.h"
- FILES="$FILES linux/semaphore.h"
-+ FILES="$FILES linux/nvmap.h"
- FILES="$FILES linux/printk.h"
- FILES="$FILES linux/ratelimit.h"
- FILES="$FILES linux/prio_tree.h"
-@@ -133,6 +135,7 @@
- FILES="$FILES xen/ioemu.h"
- FILES="$FILES linux/fence.h"
- FILES="$FILES linux/ktime.h"
-+ FILES="$FILES linux/file.h"
- FILES="$FILES linux/dma-resv.h"
- FILES="$FILES linux/dma-map-ops.h"
-
-@@ -142,6 +145,8 @@
- FILES_ARCH="$FILES_ARCH asm/powernv.h"
- FILES_ARCH="$FILES_ARCH asm/tlbflush.h"
- FILES_ARCH="$FILES_ARCH asm/pgtable_types.h"
-+ FILES_ARCH="$FILES_ARCH asm/kmap_types.h"
-+ FILES_ARCH="$FILES_ARCH asm/pgtable.h"
-
- translate_and_find_header_files $HEADERS $FILES
- translate_and_find_header_files $HEADERS_ARCH $FILES_ARCH
-@@ -662,6 +667,63 @@
- compile_check_conftest "$CODE" "NV_FOLLOW_PFN_PRESENT"
"" "functions"
- ;;
-
-+ vmap)
-+ #
-+ # Determine if the vmap() function is present and how
-+ # many arguments it takes.
-+ #
-+ echo "$CONFTEST_PREAMBLE
-+ #include <linux/vmalloc.h>
-+ void conftest_vmap(void) {
-+ vmap();
-+ }" > conftest$$.c
-+
-+ $CC $CFLAGS -c conftest$$.c > /dev/null 2>&1
-+ rm -f conftest$$.c
-+
-+ if [ -f conftest$$.o ]; then
-+ echo "#undef NV_VMAP_PRESENT" | append_conftest
"functions"
-+ rm -f conftest$$.o
-+ return
-+ fi
-+
-+ echo "$CONFTEST_PREAMBLE
-+ #include <linux/vmalloc.h>
-+ void *conftest_vmap(struct page **pages, int count) {
-+ return vmap(pages, count);
-+ }" > conftest$$.c
-+
-+ $CC $CFLAGS -c conftest$$.c > /dev/null 2>&1
-+ rm -f conftest$$.c
-+
-+ if [ -f conftest$$.o ]; then
-+ echo "#define NV_VMAP_PRESENT" | append_conftest
"functions"
-+ echo "#define NV_VMAP_ARGUMENT_COUNT 2" | append_conftest
"functions"
-+ rm -f conftest$$.o
-+ return
-+ fi
-+
-+ echo "$CONFTEST_PREAMBLE
-+ #include <linux/vmalloc.h>
-+ #include <linux/mm.h>
-+ void *conftest_vmap(struct page **pages, int count) {
-+ return vmap(pages, count, 0, PAGE_KERNEL);
-+ }" > conftest$$.c
-+
-+ $CC $CFLAGS -c conftest$$.c > /dev/null 2>&1
-+ rm -f conftest$$.c
-+
-+ if [ -f conftest$$.o ]; then
-+ echo "#define NV_VMAP_PRESENT" | append_conftest
"functions"
-+ echo "#define NV_VMAP_ARGUMENT_COUNT 4" | append_conftest
"functions"
-+ rm -f conftest$$.o
-+ return
-+ else
-+ echo "#error vmap() conftest failed!" | append_conftest
"functions"
-+ return
-+ fi
-+ ;;
-+
- i2c_adapter)
- #
- # Determine if the 'i2c_adapter' structure has the
-@@ -1110,6 +1172,16 @@
- compile_check_conftest "$CODE"
"NV_CPUHP_SETUP_STATE_PRESENT" "" "functions"
- ;;
-
-+ nvmap_support)
-+ # check if nvmap is supported.
-+ if [ -f nv-android.h ]; then
-+ echo "#define HAVE_NV_ANDROID" | append_conftest
"generic"
-+ return
-+ else
-+ echo "#undef HAVE_NV_ANDROID" | append_conftest
"generic"
-+ fi
-+ ;;
-+
- acpi_evaluate_integer)
- #
- # Determine if the acpi_evaluate_integer() function is
-@@ -1425,6 +1497,47 @@
- compile_check_conftest "$CODE"
"NV_FILE_OPERATIONS_HAS_COMPAT_IOCTL" "" "types"
- ;;
-
-+ sg_init_table)
-+ #
-+ # Determine if the sg_init_table() function is present.
-+ #
-+ echo "$CONFTEST_PREAMBLE
-+ #include <linux/scatterlist.h>
-+ void conftest_sg_init_table(struct scatterlist *sgl,
-+ unsigned int nents) {
-+ }" > conftest$$.c
-+
-+ $CC $CFLAGS -c conftest$$.c > /dev/null 2>&1
-+ rm -f conftest$$.c
-+
-+ if [ ! -f conftest$$.o ]; then
-+ echo "#undef NV_SG_INIT_TABLE_PRESENT" | append_conftest
"functions"
-+ return
-+
-+ fi
-+ rm -f conftest$$.o
-+
-+ echo "$CONFTEST_PREAMBLE
-+ #include <linux/types.h>
-+ #include <linux/scatterlist.h>
-+ void conftest_sg_init_table(struct scatterlist *sgl,
-+ unsigned int nents) {
-+ sg_init_table();
-+ }" > conftest$$.c
-+
-+ $CC $CFLAGS -c conftest$$.c > /dev/null 2>&1
-+ rm -f conftest$$.c
-+
-+ if [ -f conftest$$.o ]; then
-+ echo "#undef NV_SG_INIT_TABLE_PRESENT" | append_conftest
"functions"
-+ rm -f conftest$$.o
-+ return
-+ else
-+ echo "#define NV_SG_INIT_TABLE_PRESENT" | append_conftest
"functions"
-+ return
-+ fi
-+ ;;
-+
- sg_table)
- #
- # Determine if the struct sg_table type is present.
-@@ -2033,6 +2146,21 @@
- compile_check_conftest "$CODE" "NV_FILE_HAS_INODE"
"" "types"
- ;;
-
-+ drm_pci_set_busid)
-+ #
-+ # Determine if the drm_pci_set_busid function is present.
-+ #
-+ CODE="
-+ #if defined(NV_DRM_DRMP_H_PRESENT)
-+ #include <drm/drmP.h>
-+ #endif
-+ void conftest_drm_pci_set_busid(void) {
-+ drm_pci_set_busid();
-+ }"
-+
-+ compile_check_conftest "$CODE"
"NV_DRM_PCI_SET_BUSID_PRESENT" "" "functions"
-+ ;;
-+
- xen_ioemu_inject_msi)
- #
- # Determine if the xen_ioemu_inject_msi() function is present.
-@@ -2049,7 +2177,7 @@
- }"
-
- compile_check_conftest "$CODE" "NV_XEN_IOEMU_INJECT_MSI"
"" "functions"
-- ;;
-+ ;;
-
- phys_to_dma)
- #
-@@ -3410,6 +3538,64 @@
- compile_check_conftest "$CODE"
"NV_DRM_DRIVER_UNLOAD_HAS_INT_RETURN_TYPE" "" "types"
- ;;
-
-+ drm_get_pci_dev)
-+ #
-+ # Determine if drm_get_pci_dev() is present.
-+ #
-+ CODE="
-+ #if defined(NV_DRM_DRMP_H_PRESENT)
-+ #include <drm/drmP.h>
-+ #endif
-+
-+ #if defined(NV_DRM_DRM_PCI_H_PRESENT)
-+ #include <drm/drm_pci.h>
-+ #endif
-+
-+ void conftest_drm_legacy_pci_init(void) {
-+ drm_get_pci_dev();
-+ }"
-+
-+ compile_check_conftest "$CODE"
"NV_DRM_GET_PCI_DEV_PRESENT" "" "functions"
-+ ;;
-+
-+ drm_pci_init)
-+ #
-+ # Determine if drm_pci_init() is present.
-+ #
-+ CODE="
-+ #if defined(NV_DRM_DRMP_H_PRESENT)
-+ #include <drm/drmP.h>
-+ #endif
-+
-+ void conftest_drm_legacy_pci_init(void) {
-+ drm_pci_init();
-+ }"
-+
-+ compile_check_conftest "$CODE" "NV_DRM_PCI_INIT_PRESENT"
"" "functions"
-+ ;;
-+
-+ drm_legacy_pci_init)
-+ #
-+ # Determine if drm_legacy_pci_init() is present. drm_pci_init() was
-+ # deprecated and renamed to drm_legacy_pci_init by:
-+ #
-+ # 2017-05-24 10631d724deff712343d96dd3017cd323349f761
-+ #
-+ CODE="
-+ #if defined(NV_DRM_DRMP_H_PRESENT)
-+ #include <drm/drmP.h>
-+ #endif
-+
-+ #if defined(NV_DRM_DRM_PCI_H_PRESENT)
-+ #include <drm/drm_pci.h>
-+ #endif
-+ void conftest_drm_legacy_pci_init(void) {
-+ drm_legacy_pci_init();
-+ }"
-+
-+ compile_check_conftest "$CODE"
"NV_DRM_LEGACY_PCI_INIT_PRESENT" "" "functions"
-+ ;;
-+
- kref_has_refcount_of_type_refcount_t)
- CODE="
- #include <linux/kref.h>
-@@ -3962,6 +4148,30 @@
- compile_check_conftest "$CODE"
"NV_DMA_IS_DIRECT_PRESENT" "" "functions"
- ;;
-
-+ drm_driver_legacy_feature_bit_present)
-+ #
-+ # Determine if the DRIVER_LEGACY feature bit is present, either as a
-+ # preprocessor macro or in an enum.
-+ #
-+ # The DRIVER_* feature bits were changed from CPP macros to an enum
-+ # with commit 0e2a933b02c972919f7478364177eb76cd4ae00d (2019-01-29).
-+ #
-+ CODE="
-+ #if defined(NV_DRM_DRMP_H_PRESENT)
-+ #include <drm/drmP.h>
-+ #endif
-+
-+ #if defined(NV_DRM_DRM_DRV_H_PRESENT)
-+ #include <drm/drm_drv.h>
-+ #endif
-+
-+ void conftest_drm_driver_legacy_feature_bit_present(struct drm_driver *drv)
{
-+ drv->driver_features = DRIVER_LEGACY;
-+ }"
-+
-+ compile_check_conftest "$CODE"
"NV_DRM_DRIVER_LEGACY_FEATURE_BIT_PRESENT" "" "types"
-+ ;;
-+
- drm_driver_prime_flag_present)
- #
- # Determine whether driver feature flag DRIVER_PRIME is present.
-@@ -4094,6 +4304,11 @@
- "
-
- compile_check_conftest "$CODE" "NV_PROC_OPS_PRESENT"
"" "types"
-+ if [ -f conftest$$.o ]; then
-+ echo "#undef NV_HAVE_PROC_OPS" | append_conftest
"types"
-+ else
-+ echo "#define NV_HAVE_PROC_OPS" | append_conftest
"types"
-+ fi
- ;;
-
- timeval)
-diff -Naur a/kernel/Makefile b/kernel/Makefile
---- a/kernel/Makefile 2021-06-09 21:37:47.472579245 +0200
-+++ b/kernel/Makefile 2021-06-09 21:39:15.629612199 +0200
-@@ -70,11 +70,11 @@
- MODULE_GLUE_OBJS := $(patsubst %.c,%.o,nv-frontend.c)
- $(MODULE_NAME)-objs := $(MODULE_GLUE_OBJS)
- else
-- MODULE_GLUE_OBJS := $(patsubst %.c,%.o, nv.c nv-acpi.c nv-chrdev.c nv-cray.c nv-dma.c
nv-drm.c nv-gvi.c nv-i2c.c nv-mempool.c nv-mmap.c nv-p2p.c nv-pat.c nv-procfs.c
nv-usermap.c nv-vm.c nv-vtophys.c os-interface.c os-mlock.c os-pci.c os-registry.c
os-smp.c os-usermap.c nv_uvm_interface.c)
-+ MODULE_GLUE_OBJS := $(patsubst %.c,%.o, nv.c nv-acpi.c nv-chrdev.c nv-cray.c nv-dma.c
nv-drm.c nv-gvi.c nv-i2c.c nv-mempool.c nv-mmap.c nv-p2p.c nv-pat.c nv-procfs.c
nv-usermap.c nv-vm.c nv-vtophys.c os-interface.c os-mlock.c os-pci.c os-registry.c
os-smp.c os-usermap.c nv_uvm_interface.c nvidia-drm-linux.c nvidia-drm-gem.c
nvidia-drm-helper.c nvidia-drm-gem-user-memory.c)
- $(MODULE_NAME)-objs := $(CORE_OBJS) $(MODULE_GLUE_OBJS)
- endif
- else
-- MODULE_GLUE_OBJS := $(patsubst %.c,%.o, nv.c nv-acpi.c nv-chrdev.c nv-cray.c nv-dma.c
nv-drm.c nv-gvi.c nv-i2c.c nv-mempool.c nv-mmap.c nv-p2p.c nv-pat.c nv-procfs.c
nv-usermap.c nv-vm.c nv-vtophys.c os-interface.c os-mlock.c os-pci.c os-registry.c
os-smp.c os-usermap.c nv_uvm_interface.c) $(patsubst %.c,%.o,nv-frontend.c)
-+ MODULE_GLUE_OBJS := $(patsubst %.c,%.o, nv.c nv-acpi.c nv-chrdev.c nv-cray.c nv-dma.c
nv-drm.c nv-gvi.c nv-i2c.c nv-mempool.c nv-mmap.c nv-p2p.c nv-pat.c nv-procfs.c
nv-usermap.c nv-vm.c nv-vtophys.c os-interface.c os-mlock.c os-pci.c os-registry.c
os-smp.c os-usermap.c nv_uvm_interface.c nvidia-drm-linux.c nvidia-drm-gem.c
nvidia-drm-helper.c nvidia-drm-gem-user-memory.c) $(patsubst %.c,%.o,nv-frontend.c)
- $(MODULE_NAME)-objs := $(CORE_OBJS) $(MODULE_GLUE_OBJS)
- endif
-
-@@ -183,6 +183,7 @@
-
- src ?= .
- include $(src)/nvidia-modules-common.mk
-+include $(src)/conftest.Kbuild
-
- #
- # Generate multiple targets at runtime depending on the items present in
-diff -Naur a/kernel/nv.c b/kernel/nv.c
---- a/kernel/nv.c 2021-06-09 21:37:47.478579114 +0200
-+++ b/kernel/nv.c 2021-06-09 21:39:15.633612109 +0200
-@@ -2785,10 +2785,10 @@
-
- #if defined(CONFIG_VGA_ARB)
- #if defined(VGA_DEFAULT_DEVICE)
--#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 9, 0)
-- vga_get(VGA_DEFAULT_DEVICE, VGA_RSRC_LEGACY_MASK, 0);
--#else
-+#if defined(NV_VGA_TRYGET_PRESENT)
- vga_tryget(VGA_DEFAULT_DEVICE, VGA_RSRC_LEGACY_MASK);
-+#else
-+ vga_get(VGA_DEFAULT_DEVICE, VGA_RSRC_LEGACY_MASK, 0);
- #endif
- #endif
- vga_set_legacy_decoding(dev, VGA_RSRC_NONE);
-diff -Naur a/kernel/nv-drm.c b/kernel/nv-drm.c
---- a/kernel/nv-drm.c 2021-06-09 21:37:47.474579202 +0200
-+++ b/kernel/nv-drm.c 2021-06-09 22:13:02.593929252 +0200
-@@ -24,6 +24,11 @@
- #include <linux/file.h>
- #endif
-
-+#include <nvidia-drm-priv.h>
-+#include <nvidia-drm-ioctl.h>
-+#include <nvidia-drm-gem-user-memory.h>
-+#include <nvidia-drm-helper.h>
-+
- #if defined(NV_DRM_DRM_DRV_H_PRESENT)
- #include <drm/drm_drv.h>
- #endif
-@@ -51,237 +56,12 @@
- #if defined(NV_DRM_LEGACY_PCI_INIT_PRESENT)
- #define nv_drm_pci_init drm_legacy_pci_init
- #define nv_drm_pci_exit drm_legacy_pci_exit
--#elif defined(NV_DRM_PCI_INIT_PRESENT)
-+#else
- #define nv_drm_pci_init drm_pci_init
- #define nv_drm_pci_exit drm_pci_exit
--#else
--#if defined(NV_DRM_GET_PCI_DEV_PRESENT)
--#define nv_drm_get_pci_dev drm_get_pci_dev
--#else
--#include <drm/drm_agpsupport.h>
--
--struct nv_drm_agp_head {
-- struct agp_kern_info agp_info;
-- struct list_head memory;
-- unsigned long mode;
-- struct agp_bridge_data *bridge;
-- int enabled;
-- int acquired;
-- unsigned long base;
-- int agp_mtrr;
-- int cant_use_aperture;
-- unsigned long page_mask;
--};
--
--struct nv_drm_agp_mem {
-- unsigned long handle;
-- struct agp_memory *memory;
-- unsigned long bound;
-- int pages;
-- struct list_head head;
--};
--
--/*
-- * Code from drm_agp_init/nv_drm_{free,unbind}_agp
-- * Extracted from commit: 5b8b9d0c6d0e0f1993c6c56deaf9646942c49d94, file:
drivers/gpu/drm/drm_agpsupport.c
-- */
--struct drm_agp_head *nv_drm_agp_init(struct drm_device *dev)
--{
-- struct nv_drm_agp_head *head = NULL;
--
-- head = kzalloc(sizeof(*head), GFP_KERNEL);
-- if (!head)
-- return NULL;
-- head->bridge = agp_find_bridge(dev->pdev);
-- if (!head->bridge) {
-- head->bridge = agp_backend_acquire(dev->pdev);
-- if (!head->bridge) {
-- kfree(head);
-- return NULL;
-- }
-- agp_copy_info(head->bridge, &head->agp_info);
-- agp_backend_release(head->bridge);
-- } else {
-- agp_copy_info(head->bridge, &head->agp_info);
-- }
-- if (head->agp_info.chipset == NOT_SUPPORTED) {
-- kfree(head);
-- return NULL;
-- }
-- INIT_LIST_HEAD(&head->memory);
-- head->cant_use_aperture = head->agp_info.cant_use_aperture;
-- head->page_mask = head->agp_info.page_mask;
-- head->base = head->agp_info.aper_base;
-- return (struct drm_agp_head *)head;
--}
--
--void nv_drm_free_agp(struct agp_memory *handle, int pages)
--{
-- agp_free_memory(handle);
--}
--
--int nv_drm_unbind_agp(struct agp_memory *handle)
--{
-- return agp_unbind_memory(handle);
--}
--
--/*
-- * Code from drm_pci_agp_{clear,destroy,init}/drm_get_pci_dev
-- * Extracted from commit: 5b8b9d0c6d0e0f1993c6c56deaf9646942c49d94, file:
drivers/gpu/drm/drm_pci.c
-- */
--static void nv_drm_pci_agp_init(struct drm_device *dev)
--{
-- if (drm_core_check_feature(dev, DRIVER_USE_AGP)) {
-- if (pci_find_capability(dev->pdev, PCI_CAP_ID_AGP))
-- dev->agp = nv_drm_agp_init(dev);
-- if (dev->agp) {
-- dev->agp->agp_mtrr = arch_phys_wc_add(
-- dev->agp->agp_info.aper_base,
-- dev->agp->agp_info.aper_size *
-- 1024 * 1024);
-- }
-- }
--}
--
--void nv_drm_legacy_agp_clear(struct drm_device *dev)
--{
-- struct nv_drm_agp_mem *entry, *tempe;
--
-- if (!dev->agp)
-- return;
-- if (!drm_core_check_feature(dev, DRIVER_LEGACY))
-- return;
--
-- list_for_each_entry_safe(entry, tempe, &dev->agp->memory, head) {
-- if (entry->bound)
-- nv_drm_unbind_agp(entry->memory);
-- nv_drm_free_agp(entry->memory, entry->pages);
-- kfree(entry);
-- }
-- INIT_LIST_HEAD(&dev->agp->memory);
--
-- if (dev->agp->acquired)
-- drm_agp_release(dev);
--
-- dev->agp->acquired = 0;
-- dev->agp->enabled = 0;
--}
--
--void nv_drm_pci_agp_destroy(struct drm_device *dev)
--{
-- if (dev->agp) {
-- arch_phys_wc_del(dev->agp->agp_mtrr);
-- nv_drm_legacy_agp_clear(dev);
-- kfree(dev->agp);
-- dev->agp = NULL;
-- }
--}
--
--static int nv_drm_get_pci_dev(struct pci_dev *pdev,
-- const struct pci_device_id *ent,
-- struct drm_driver *driver)
--{
-- struct drm_device *dev;
-- int ret;
--
-- DRM_DEBUG("\n");
--
-- dev = drm_dev_alloc(driver, &pdev->dev);
-- if (IS_ERR(dev))
-- return PTR_ERR(dev);
--
-- ret = pci_enable_device(pdev);
-- if (ret)
-- goto err_free;
--
-- dev->pdev = pdev;
--#ifdef __alpha__
-- dev->hose = pdev->sysdata;
--#endif
--
-- if (drm_core_check_feature(dev, DRIVER_MODESET))
-- pci_set_drvdata(pdev, dev);
--
-- nv_drm_pci_agp_init(dev);
--
-- ret = drm_dev_register(dev, ent->driver_data);
-- if (ret)
-- goto err_agp;
--
-- /* No locking needed since shadow-attach is single-threaded since it may
-- * only be called from the per-driver module init hook. */
-- if (drm_core_check_feature(dev, DRIVER_LEGACY))
-- list_add_tail(&dev->legacy_dev_list, &driver->legacy_dev_list);
--
-- return 0;
--
--err_agp:
-- nv_drm_pci_agp_destroy(dev);
-- pci_disable_device(pdev);
--err_free:
-- drm_dev_put(dev);
-- return ret;
--}
- #endif
-
--/*
-- * Code from drm_legacy_pci_{init,exit}
-- * Extracted from tag: v5.6.3, file: drivers/gpu/drm/drm_pci.c
-- */
--int nv_drm_pci_init(struct drm_driver *driver, struct pci_driver *pdriver)
--{
-- struct pci_dev *pdev = NULL;
-- const struct pci_device_id *pid;
-- int i;
--
-- DRM_DEBUG("\n");
--
-- if (WARN_ON(!(driver->driver_features & DRIVER_LEGACY)))
-- return -EINVAL;
--
-- /* If not using KMS, fall back to stealth mode manual scanning. */
-- INIT_LIST_HEAD(&driver->legacy_dev_list);
-- for (i = 0; pdriver->id_table[i].vendor != 0; i++) {
-- pid = &pdriver->id_table[i];
--
-- /* Loop around setting up a DRM device for each PCI device
-- * matching our ID and device class. If we had the internal
-- * function that pci_get_subsys and pci_get_class used, we'd
-- * be able to just pass pid in instead of doing a two-stage
-- * thing.
-- */
-- pdev = NULL;
-- while ((pdev =
-- pci_get_subsys(pid->vendor, pid->device, pid->subvendor,
-- pid->subdevice, pdev)) != NULL) {
-- if ((pdev->class & pid->class_mask) != pid->class)
-- continue;
--
-- /* stealth mode requires a manual probe */
-- pci_dev_get(pdev);
-- nv_drm_get_pci_dev(pdev, pid, driver);
-- }
-- }
-- return 0;
--}
--
--void nv_drm_pci_exit(struct drm_driver *driver, struct pci_driver *pdriver)
--{
-- struct drm_device *dev, *tmp;
-- DRM_DEBUG("\n");
--
-- if (!(driver->driver_features & DRIVER_LEGACY)) {
-- WARN_ON(1);
-- } else {
-- list_for_each_entry_safe(dev, tmp, &driver->legacy_dev_list,
-- legacy_dev_list) {
-- list_del(&dev->legacy_dev_list);
-- drm_put_dev(dev);
-- }
-- }
-- DRM_INFO("Module unloaded\n");
--}
--#endif
-+static struct nv_drm_device *dev_list = NULL;
-
- extern nv_linux_state_t *nv_linux_devices;
-
-@@ -359,36 +139,49 @@
- NV_KFREE(nv_obj, sizeof(*nv_obj));
- }
-
--static struct sg_table* nv_gem_prime_get_sg_table(
-- struct drm_gem_object *obj
--)
-+static int nv_drm_get_dev_info_ioctl(struct drm_device *dev,
-+ void *data, struct drm_file *filep)
- {
-- struct nv_gem_object *nv_obj = container_of(obj, struct nv_gem_object, base);
-- int page_count = obj->size >> PAGE_SHIFT;
-+ struct nv_drm_device *nv_dev = to_nv_device(dev);
-+ struct drm_nvidia_get_dev_info_params *params = data;
-
-- #if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 10, 0)
-- return drm_prime_pages_to_sg(obj->dev, nv_obj->pages, page_count);
-- #else
-- return drm_prime_pages_to_sg(nv_obj->pages, page_count);
-- #endif
--}
-+ if (dev->primary == NULL) {
-+ return -ENOENT;
-+ }
-
--static void* nv_gem_prime_vmap(
-- struct drm_gem_object *obj
--)
--{
-- struct nv_gem_object *nv_obj = container_of(obj, struct nv_gem_object, base);
-- int page_count = obj->size >> PAGE_SHIFT;
-+ params->gpu_id = nv_dev->gpu_info.gpu_id;
-+ params->primary_index = dev->primary->index;
-
-- return vmap(nv_obj->pages, page_count, VM_USERMAP, PAGE_KERNEL);
-+ return 0;
- }
-
--static void nv_gem_prime_vunmap(
-- struct drm_gem_object *obj,
-- void *virtual
--)
--{
-- vunmap(virtual);
-+static
-+int nv_drm_get_client_capability_ioctl(struct drm_device *dev,
-+ void *data, struct drm_file *filep)
-+{
-+ struct drm_nvidia_get_client_capability_params *params = data;
-+
-+ switch (params->capability) {
-+#if defined(DRM_CLIENT_CAP_STEREO_3D)
-+ case DRM_CLIENT_CAP_STEREO_3D:
-+ params->value = filep->stereo_allowed;
-+ break;
-+#endif
-+#if defined(DRM_CLIENT_CAP_UNIVERSAL_PLANES)
-+ case DRM_CLIENT_CAP_UNIVERSAL_PLANES:
-+ params->value = filep->universal_planes;
-+ break;
-+#endif
-+#if defined(DRM_CLIENT_CAP_ATOMIC)
-+ case DRM_CLIENT_CAP_ATOMIC:
-+ params->value = filep->atomic;
-+ break;
-+#endif
-+ default:
-+ return -EINVAL;
-+ }
-+
-+ return 0;
- }
-
- static const struct file_operations nv_drm_fops = {
-@@ -402,6 +195,43 @@
- .llseek = noop_llseek,
- };
-
-+static const struct drm_ioctl_desc nv_drm_ioctls[] = {
-+// #if defined(NV_DRM_ATOMIC_MODESET_AVAILABLE)
-+// DRM_IOCTL_DEF_DRV(NVIDIA_GEM_IMPORT_NVKMS_MEMORY,
-+// nv_drm_gem_import_nvkms_memory_ioctl,
-+// DRM_UNLOCKED),
-+// #endif /* NV_DRM_ATOMIC_MODESET_AVAILABLE */
-+//
-+ DRM_IOCTL_DEF_DRV(NVIDIA_GEM_IMPORT_USERSPACE_MEMORY,
-+ nv_drm_gem_import_userspace_memory_ioctl,
-+ DRM_RENDER_ALLOW|DRM_UNLOCKED),
-+ DRM_IOCTL_DEF_DRV(NVIDIA_GET_DEV_INFO,
-+ nv_drm_get_dev_info_ioctl,
-+ DRM_RENDER_ALLOW|DRM_UNLOCKED),
-+
-+// #if defined(NV_DRM_FENCE_AVAILABLE)
-+// DRM_IOCTL_DEF_DRV(NVIDIA_FENCE_SUPPORTED,
-+// nv_drm_fence_supported_ioctl,
-+// DRM_RENDER_ALLOW|DRM_UNLOCKED),
-+// DRM_IOCTL_DEF_DRV(NVIDIA_FENCE_CONTEXT_CREATE,
-+// nv_drm_fence_context_create_ioctl,
-+// DRM_RENDER_ALLOW|DRM_UNLOCKED),
-+// DRM_IOCTL_DEF_DRV(NVIDIA_GEM_FENCE_ATTACH,
-+// nv_drm_gem_fence_attach_ioctl,
-+// DRM_RENDER_ALLOW|DRM_UNLOCKED),
-+// #endif
-+
-+ DRM_IOCTL_DEF_DRV(NVIDIA_GET_CLIENT_CAPABILITY,
-+ nv_drm_get_client_capability_ioctl,
-+ 0),
-+// #if defined(NV_DRM_ATOMIC_MODESET_AVAILABLE)
-+// DRM_IOCTL_DEF_DRV(NVIDIA_GET_CRTC_CRC32,
-+// nv_drm_get_crtc_crc32_ioctl,
-+// DRM_RENDER_ALLOW|DRM_UNLOCKED),
-+// #endif /* NV_DRM_ATOMIC_MODESET_AVAILABLE */
-+};
-+
-+
- static struct drm_driver nv_drm_driver = {
-
- .driver_features = DRIVER_GEM
-@@ -420,17 +250,26 @@
- .set_busid = drm_pci_set_busid,
- #endif
-
--#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 9, 0)
-- .gem_free_object_unlocked = nv_gem_free,
--#else
-+#if defined(NV_DRM_DRIVER_HAS_GEM_FREE_OBJECT)
- .gem_free_object = nv_gem_free,
-+#elif LINUX_VERSION_CODE <= KERNEL_VERSION(5, 10, 0)
-+ .gem_free_object_unlocked = nv_gem_free,
- #endif
-
-+ .ioctls = nv_drm_ioctls,
-+ .num_ioctls = ARRAY_SIZE(nv_drm_ioctls),
-+
- .prime_handle_to_fd = drm_gem_prime_handle_to_fd,
-- .gem_prime_export = drm_gem_prime_export,
-- .gem_prime_get_sg_table = nv_gem_prime_get_sg_table,
-- .gem_prime_vmap = nv_gem_prime_vmap,
-- .gem_prime_vunmap = nv_gem_prime_vunmap,
-+#if defined(NV_DRM_DRIVER_HAS_GEM_PRIME_CALLBACKS)
-+ .gem_prime_export = nv_drm_gem_prime_export,
-+ .gem_prime_get_sg_table = nv_drm_gem_prime_get_sg_table,
-+ .gem_prime_vmap = nv_drm_gem_prime_vmap,
-+ .gem_prime_vunmap = nv_drm_gem_prime_vunmap,
-+#endif
-+
-+#if defined(NV_DRM_DRIVER_HAS_GEM_PRIME_RES_OBJ)
-+ .gem_prime_res_obj = nv_drm_gem_prime_res_obj,
-+#endif
-
- .name = "nvidia-drm",
- .desc = "NVIDIA DRM driver",
-@@ -438,7 +277,198 @@
- .major = 0,
- .minor = 0,
- .patchlevel = 0,
-+
-+#if defined(NV_DRM_DRIVER_HAS_DEVICE_LIST)
-+ .device_list = LIST_HEAD_INIT(nv_drm_driver.device_list),
-+#elif defined(NV_DRM_DRIVER_HAS_LEGACY_DEV_LIST)
-+ .legacy_dev_list = LIST_HEAD_INIT(nv_drm_driver.legacy_dev_list),
-+#endif
- };
-+
-+/*!
-+ * Enumerate the available physical GPUs that can be used with NVKMS.
-+ *
-+ * \param [out] gpuInfo The information of the enumerated GPUs.
-+ * It is an array of NVIDIA_MAX_GPUS elements.
-+ *
-+ * \return Count of enumerated gpus.
-+ */
-+
-+/*
-+ * Implemented based on code from drm_legacy_pci_{init,exit}
-+ * Extracted from tag: v5.6.3, file: drivers/gpu/drm/drm_pci.c
-+ */
-+static NvU32 nvKmsenumerateGpus(nv_gpu_info_t *gpuInfo, struct drm_driver *driver,
struct pci_driver *pdriver)
-+{
-+ NvU32 gpu_count = 0;
-+
-+ struct pci_dev *pdev = NULL;
-+ const struct pci_device_id *pid;
-+ int i;
-+
-+ DRM_DEBUG("\n");
-+
-+ for (i = 0; pdriver->id_table[i].vendor != 0; i++) {
-+ pid = &pdriver->id_table[i];
-+
-+ /* Loop around setting up a DRM device for each PCI device
-+ * matching our ID and device class. If we had the internal
-+ * function that pci_get_subsys and pci_get_class used, we'd
-+ * be able to just pass pid in instead of doing a two-stage
-+ * thing.
-+ */
-+ pdev = NULL;
-+ while ((pdev =
-+ pci_get_subsys(pid->vendor, pid->device, pid->subvendor,
-+ pid->subdevice, pdev)) != NULL) {
-+
-+ if ((pdev->class & pid->class_mask) != pid->class)
-+ continue;
-+
-+ /* stealth mode requires a manual probe */
-+ pci_dev_get(pdev);
-+
-+ gpuInfo[i].gpu_id = pid->device;
-+ gpuInfo[i].pci_info.domain = pci_domain_nr(pdev->bus);
-+ gpuInfo[i].pci_info.bus = pdev->bus->number;
-+ gpuInfo[i].pci_info.slot = PCI_SLOT(pdev->devfn);
-+ gpuInfo[i].pci_info.function = PCI_FUNC(pdev->devfn);
-+ gpuInfo[i].os_dev_ptr = pdev;
-+ gpu_count += 1;
-+ }
-+ }
-+ return gpu_count;
-+}
-+
-+/*
-+ * Helper function for allocate/register DRM device for given NVIDIA GPU ID.
-+ */
-+static void nv_drm_register_drm_device(const nv_gpu_info_t *gpu_info)
-+{
-+ struct nv_drm_device *nv_dev = NULL;
-+ struct drm_device *dev = NULL;
-+ struct pci_dev *pdev = gpu_info->os_dev_ptr;
-+
-+ DRM_DEBUG(
-+ "Registering device for NVIDIA GPU ID 0x08%x",
-+ gpu_info->gpu_id);
-+
-+ /* Allocate NVIDIA-DRM device */
-+
-+ nv_dev = nv_drm_calloc(1, sizeof(*nv_dev));
-+
-+ if (nv_dev == NULL) {
-+ NV_DRM_LOG_ERR(
-+ "Failed to allocate memmory for NVIDIA-DRM device object");
-+ return;
-+ }
-+
-+ nv_dev->gpu_info = *gpu_info;
-+
-+#if defined(NV_DRM_ATOMIC_MODESET_AVAILABLE)
-+ mutex_init(&nv_dev->lock);
-+#endif
-+
-+ /* Allocate DRM device */
-+
-+ dev = drm_dev_alloc(&nv_drm_driver, &pdev->dev);
-+
-+ if (dev == NULL) {
-+ NV_DRM_DEV_LOG_ERR(nv_dev, "Failed to allocate device");
-+ goto failed_drm_alloc;
-+ }
-+
-+ dev->dev_private = nv_dev;
-+ nv_dev->dev = dev;
-+ dev->pdev = pdev;
-+
-+ /* Register DRM device to DRM sub-system */
-+
-+ if (drm_dev_register(dev, 0) != 0) {
-+ NV_DRM_DEV_LOG_ERR(nv_dev, "Failed to register device");
-+ goto failed_drm_register;
-+ }
-+
-+ /* Add NVIDIA-DRM device into list */
-+
-+ nv_dev->next = dev_list;
-+ dev_list = nv_dev;
-+
-+ return; /* Success */
-+
-+failed_drm_register:
-+
-+ nv_drm_dev_free(dev);
-+
-+failed_drm_alloc:
-+
-+ nv_drm_free(nv_dev);
-+}
-+
-+/*
-+ * Enumerate NVIDIA GPUs and allocate/register DRM device for each of them.
-+ */
-+int nv_drm_probe_devices(struct drm_driver *driver, struct pci_driver *pdriver)
-+{
-+ nv_gpu_info_t *gpu_info = NULL;
-+ NvU32 gpu_count = 0;
-+ NvU32 i;
-+
-+ int ret = 0;
-+
-+// nv_drm_update_drm_driver_features();
-+
-+ /* Enumerate NVIDIA GPUs */
-+
-+ gpu_info = nv_drm_calloc(NV_MAX_GPUS, sizeof(*gpu_info));
-+
-+ if (gpu_info == NULL) {
-+ ret = -ENOMEM;
-+
-+ NV_DRM_LOG_ERR("Failed to allocate gpu ids arrays");
-+ goto done;
-+ }
-+
-+ gpu_count = nvKmsenumerateGpus(gpu_info, driver, pdriver);
-+// gpu_count = nvKms->enumerateGpus(gpu_info);
-+
-+ if (gpu_count == 0) {
-+ NV_DRM_LOG_INFO("Not found NVIDIA GPUs");
-+ goto done;
-+ }
-+
-+ WARN_ON(gpu_count > NV_MAX_GPUS);
-+
-+ /* Register DRM device for each NVIDIA GPU */
-+
-+ for (i = 0; i < gpu_count; i++) {
-+ nv_drm_register_drm_device(&gpu_info[i]);
-+ }
-+
-+done:
-+
-+ nv_drm_free(gpu_info);
-+
-+ return ret;
-+}
-+
+diff -Naur a/kernel/nv_stdarg.h b/kernel/nv_stdarg.h
+--- a/kernel/nv_stdarg.h 1970-01-01 01:00:00.000000000 +0100
++++ b/kernel/nv_stdarg.h 2022-01-21 18:37:50.023267227 +0100
+@@ -0,0 +1,39 @@
+/*
-+ * Unregister all NVIDIA DRM devices.
++ * SPDX-FileCopyrightText: Copyright (c) 2021 NVIDIA CORPORATION & AFFILIATES. All
rights reserved.
++ * SPDX-License-Identifier: MIT
++ *
++ * Permission is hereby granted, free of charge, to any person obtaining a
++ * copy of this software and associated documentation files (the "Software"),
++ * to deal in the Software without restriction, including without limitation
++ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
++ * and/or sell copies of the Software, and to permit persons to whom the
++ * Software is furnished to do so, subject to the following conditions:
++ *
++ * The above copyright notice and this permission notice shall be included in
++ * all copies or substantial portions of the Software.
++ *
++ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
++ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
++ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
++ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
++ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
++ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
++ * DEALINGS IN THE SOFTWARE.
+ */
-+void nv_drm_remove_devices(void)
-+{
-+ while (dev_list != NULL) {
-+ struct nv_drm_device *next = dev_list->next;
+
-+ drm_dev_unregister(dev_list->dev);
-+ nv_drm_dev_free(dev_list->dev);
+
-+ nv_drm_free(dev_list);
++#ifndef _NV_STDARG_H_
++#define _NV_STDARG_H_
+
-+ dev_list = next;
-+ }
-+}
++#if defined(NV_KERNEL_INTERFACE_LAYER) && defined(NV_LINUX)
++ #include "conftest.h"
++ #if defined(NV_LINUX_STDARG_H_PRESENT)
++ #include <linux/stdarg.h>
++ #else
++ #include <stdarg.h>
++ #endif
++#else
++ #include <stdarg.h>
++#endif
+
- #endif /* defined(NV_DRM_AVAILABLE) */
-
- int __init nv_drm_init(
-@@ -447,7 +477,7 @@
- {
- int ret = 0;
- #if defined(NV_DRM_AVAILABLE)
-- ret = nv_drm_pci_init(&nv_drm_driver, pci_driver);
-+ ret = nv_drm_probe_devices(&nv_drm_driver, pci_driver);
- #endif
- return ret;
- }
-@@ -457,7 +487,7 @@
- )
- {
- #if defined(NV_DRM_AVAILABLE)
-- nv_drm_pci_exit(&nv_drm_driver, pci_driver);
-+ nv_drm_remove_devices();
- #endif
- }
-
-@@ -518,15 +548,17 @@
- goto done;
- }
++#endif // _NV_STDARG_H_
+diff -Naur a/kernel/nv-time.h b/kernel/nv-time.h
+--- a/kernel/nv-time.h 2019-12-11 23:04:24.000000000 +0100
++++ b/kernel/nv-time.h 2022-01-21 18:37:50.023267227 +0100
+@@ -23,12 +23,20 @@
+ #ifndef __NV_TIME_H__
+ #define __NV_TIME_H__
--#if defined(NV_DRM_GEM_OBJECT_PUT_UNLOCKED_PRESENT)
-+#if defined(NV_DRM_GEM_OBJECT_GET_PRESENT)
-+
-+#if defined(NV_DRM_GEM_OBJECT_PUT_UNLOCK_PRESENT)
- drm_gem_object_put_unlocked(&nv_obj->base);
- #else
--#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 9, 0)
-- drm_gem_object_put_locked(&nv_obj->base);
-+ drm_gem_object_put(&nv_obj->base);
-+#endif
++#include "conftest.h"
+
- #else
- drm_gem_object_unreference_unlocked(&nv_obj->base);
+ #include <linux/time.h>
+ #if defined(NV_LINUX_KTIME_H_PRESENT)
+ #include <linux/ktime.h>
#endif
--#endif
-
- status = RM_OK;
-
-diff -Naur a/kernel/nvidia-drm-gem.c b/kernel/nvidia-drm-gem.c
---- a/kernel/nvidia-drm-gem.c 2021-06-09 21:37:47.511578395 +0200
-+++ b/kernel/nvidia-drm-gem.c 2021-06-09 21:39:15.634612087 +0200
-@@ -26,10 +26,10 @@
-
- #include "nvidia-drm-priv.h"
- #include "nvidia-drm-ioctl.h"
--#include "nvidia-drm-prime-fence.h"
-+// #include "nvidia-drm-prime-fence.h"
- #include "nvidia-drm-gem.h"
- #include "nvidia-dma-resv-helper.h"
--#include "nvidia-drm-gem-nvkms-memory.h"
-+// #include "nvidia-drm-gem-nvkms-memory.h"
-
- #if defined(NV_DRM_DRM_PRIME_H_PRESENT)
- #include <drm/drm_prime.h>
-@@ -88,9 +88,9 @@
- .vunmap = nv_drm_gem_prime_vunmap,
- #endif
-
--#if defined(NV_DRM_ATOMIC_MODESET_AVAILABLE)
-- .vm_ops = &nv_drm_gem_vma_ops,
--#endif
-+// #if defined(NV_DRM_ATOMIC_MODESET_AVAILABLE)
-+// .vm_ops = &nv_drm_gem_vma_ops,
-+// #endif
-
- #endif
- };
-diff -Naur a/kernel/nvidia-drm-linux.c b/kernel/nvidia-drm-linux.c
---- a/kernel/nvidia-drm-linux.c 2021-06-09 21:37:47.511578395 +0200
-+++ b/kernel/nvidia-drm-linux.c 2021-06-09 21:39:15.634612087 +0200
-@@ -25,7 +25,6 @@
- #include <linux/err.h>
- #include "nvidia-drm-os-interface.h"
--#include "nvidia-drm.h"
-
- #include "conftest.h"
-
-@@ -161,25 +160,3 @@
- * Linux loading support code.
- *************************************************************************/
-
--static int __init nv_linux_drm_init(void)
--{
-- return nv_drm_init();
--}
--
--static void __exit nv_linux_drm_exit(void)
--{
-- nv_drm_exit();
--}
--
--module_init(nv_linux_drm_init);
--module_exit(nv_linux_drm_exit);
--
--#if defined(MODULE_LICENSE)
-- MODULE_LICENSE("MIT");
--#endif
--#if defined(MODULE_INFO)
-- MODULE_INFO(supported, "external");
--#endif
--#if defined(MODULE_VERSION)
-- MODULE_VERSION(NV_VERSION_STRING);
--#endif
-diff -Naur a/kernel/nvidia-modules-common.mk b/kernel/nvidia-modules-common.mk
---- a/kernel/nvidia-modules-common.mk 2021-06-09 21:37:47.478579114 +0200
-+++ b/kernel/nvidia-modules-common.mk 2021-06-09 21:39:15.634612087 +0200
-@@ -149,7 +149,7 @@
- CONFTEST_HEADERS := $(obj)/conftest.h $(CONFTEST_COMPILE_TEST_HEADERS) \
- $(obj)/conftest/patches.h
-
--$(obj)/conftest.h $(CONFTEST_COMPILE_TEST_HEADERS): conftest-compile-test
-+# $(obj)/conftest.h $(CONFTEST_COMPILE_TEST_HEADERS): conftest-compile-test
-
- conftest-compile-test: $(src)/conftest.sh
- @if ! $(CONFTEST) compile_tests $(COMPILE_TESTS); then exit 1; fi
-@@ -318,7 +318,7 @@
- @$(RM) -f build-in.o nv-linux*.o *.d .*.cmd .*.flags
- @$(RM) -f $(MODULE_NAME)*.o $(MODULE_NAME)*.ko*
- @$(RM) -f $(MODULE_NAME)*.mod* $(VERSION_HEADER) *~
-- @$(RM) -f conftest*.c conftest.h
-+ @$(RM) -f conftest*.c
- @$(RM) -rf conftest
- @$(RM) -rf Module*.symvers .tmp_versions modules.order
-
-diff -Naur a/kernel/nv-linux.h b/kernel/nv-linux.h
---- a/kernel/nv-linux.h 2021-06-09 21:37:47.476579158 +0200
-+++ b/kernel/nv-linux.h 2021-06-09 21:54:09.093016589 +0200
-@@ -119,12 +119,15 @@
- #include <asm/tlbflush.h> /* flush_tlb(), flush_tlb_all() */
- #include <linux/cpu.h> /* CPU hotplug support */
- #endif
--#include <asm/kmap_types.h> /* page table entry lookup */
-+#if defined(NV_ASM_KMAP_TYPES_H_PRESENT)
-+ #include <asm/kmap_types.h> /* page table entry lookup */
+-static inline void nv_gettimeofday(struct timeval *tv)
++#if defined (NV_TIMEVAL_PRESENT)
++typedef struct timeval nv_timeval;
++#else
++typedef struct __kernel_old_timeval nv_timeval;
+#endif
-
- #include <linux/pci.h> /* pci_find_class, etc */
- #include <linux/interrupt.h> /* tasklets, interrupt helpers */
- #include <linux/timer.h>
--
-+#include <linux/file.h> /* fget(), fput()
-+*/
- #include <asm/div64.h> /* do_div() */
- #if defined(NV_ASM_SYSTEM_H_PRESENT)
- #include <asm/system.h> /* cli, sli, save_flags */
-@@ -134,12 +137,10 @@
- #include <asm/page.h> /* PAGE_OFFSET */
- #include <asm/pgtable.h> /* pte bit definitions */
-
--#if defined(NVCPU_X86_64) && !defined(HAVE_COMPAT_IOCTL)
-+#if defined(NVCPU_X86_64) && !defined(NV_FILE_OPERATIONS_HAS_COMPAT_IOCTL)
- #include <linux/syscalls.h> /* sys_ioctl() */
--#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 9, 0)
- #include <linux/ioctl32.h> /* register_ioctl32_conversion() */
- #endif
--#endif
-
- #if !defined(NV_FILE_OPERATIONS_HAS_IOCTL) && \
- !defined(NV_FILE_OPERATIONS_HAS_UNLOCKED_IOCTL)
-@@ -672,7 +673,7 @@
- # define KM_FREE_RECORD(a,b,c)
- #endif
-
--#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 8, 0)
-+#if !defined(NV_VMALLOC_HAS_PGPROT_T_ARG)
- #define NV_VMALLOC(ptr, size) \
- { \
- (ptr) = __vmalloc(size, GFP_KERNEL); \
-@@ -2247,18 +2248,19 @@
- flags |= FOLL_FORCE;
-
- #if defined(NV_GET_USER_PAGES_REMOTE_HAS_LOCKED_ARG)
--
-+ #if defined (NV_GET_USER_PAGES_REMOTE_HAS_TSK_ARG)
- return get_user_pages_remote(tsk, mm, start, nr_pages, flags,
- pages, vmas, NULL);
--
-- #else
--#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 9, 0)
-+ #else
- return get_user_pages_remote(mm, start, nr_pages, flags,
- pages, vmas, NULL);
--#else
-+ #endif
-+
-+ #else
+
- return get_user_pages_remote(tsk, mm, start, nr_pages, flags,
- pages, vmas);
--#endif
-+
- #endif
-
- }
-diff -Naur a/kernel/nv-vm.c b/kernel/nv-vm.c
---- a/kernel/nv-vm.c 2021-06-09 21:37:47.476579158 +0200
-+++ b/kernel/nv-vm.c 2021-06-09 21:43:13.262501779 +0200
-@@ -12,6 +12,9 @@
- #include "os-interface.h"
- #include "nv.h"
- #include "nv-linux.h"
-+#if defined(NV_ASM_SET_MEMORY_H_PRESENT)
-+#include <asm/set_memory.h>
-+#endif
-
- static inline void nv_set_contig_memory_uc(nv_pte_t *page_ptr, NvU32 num_pages)
++static inline void nv_gettimeofday(nv_timeval *tv)
{
-diff -Naur a/kernel/os-mlock.c b/kernel/os-mlock.c
---- a/kernel/os-mlock.c 2021-06-09 21:37:47.478579114 +0200
-+++ b/kernel/os-mlock.c 2021-06-09 21:39:15.634612087 +0200
-@@ -44,7 +44,7 @@
- return rmStatus;
- }
-
--#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 8, 0)
-+#if defined(NV_MM_HAS_MMAP_LOCK)
- down_read(&mm->mmap_lock);
- ret = NV_GET_USER_PAGES((unsigned long)address,
- page_count, write, force, user_pages, NULL);
-diff -Naur a/kernel/uvm/nvidia_uvm_linux.h b/kernel/uvm/nvidia_uvm_linux.h
---- a/kernel/uvm/nvidia_uvm_linux.h 2021-06-09 21:37:47.479579092 +0200
-+++ b/kernel/uvm/nvidia_uvm_linux.h 2021-06-09 21:54:25.298653372 +0200
-@@ -141,7 +141,9 @@
- #if !defined(NV_VMWARE)
- #include <asm/tlbflush.h> /* flush_tlb(), flush_tlb_all() */
- #endif
--#include <asm/kmap_types.h> /* page table entry lookup */
-+#if defined(NV_ASM_KMAP_TYPES_H_PRESENT)
-+ #include <asm/kmap_types.h> /* page table entry lookup */
-+#endif
-
- #include <linux/interrupt.h> /* tasklets, interrupt helpers */
- #include <linux/timer.h>
-@@ -156,12 +158,10 @@
- #include <asm/page.h> /* PAGE_OFFSET */
- #include <asm/pgtable.h> /* pte bit definitions */
-
--#if defined(NVCPU_X86_64) && !defined(HAVE_COMPAT_IOCTL)
-+#if defined(NVCPU_X86_64) && !defined(NV_FILE_OPERATIONS_HAS_COMPAT_IOCTL)
- #include <linux/syscalls.h> /* sys_ioctl() */
--#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 9, 0)
- #include <linux/ioctl32.h> /* register_ioctl32_conversion() */
- #endif
--#endif
+ #ifdef NV_DO_GETTIMEOFDAY_PRESENT
+ do_gettimeofday(tv);
+@@ -37,7 +45,7 @@
- #if !defined(NV_FILE_OPERATIONS_HAS_IOCTL) && \
- !defined(NV_FILE_OPERATIONS_HAS_UNLOCKED_IOCTL)
-diff -Naur a/kernel/uvm/nvidia_uvm_lite_api.c b/kernel/uvm/nvidia_uvm_lite_api.c
---- a/kernel/uvm/nvidia_uvm_lite_api.c 2021-06-09 21:37:47.479579092 +0200
-+++ b/kernel/uvm/nvidia_uvm_lite_api.c 2021-06-09 21:39:15.635612064 +0200
-@@ -30,7 +30,7 @@
- #include "uvm_gpu_ops_tests.h"
- #endif
-
--#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 8, 0)
-+#if defined (NV_MM_HAS_MMAP_LOCK)
- #define mmap_sem mmap_lock
- #endif
+ ktime_get_real_ts64(&now);
+- *tv = (struct timeval) {
++ *tv = (nv_timeval) {
+ .tv_sec = now.tv_sec,
+ .tv_usec = now.tv_nsec/1000,
+ };
diff --git a/nvidia-340xx-kmod.spec b/nvidia-340xx-kmod.spec
index 78ccd0b..854d195 100644
--- a/nvidia-340xx-kmod.spec
+++ b/nvidia-340xx-kmod.spec
@@ -12,20 +12,15 @@ Name: nvidia-340xx-kmod
Epoch: 1
Version: 340.108
# Taken over by kmodtool
-Release: 16%{?dist}
+Release: 17%{?dist}
Summary: NVIDIA display driver kernel module
Group: System Environment/Kernel
License: Redistributable, no modification permitted
URL:
http://www.nvidia.com/
Source11: nvidia-kmodtool-excludekernel-filterfile
-Patch0: nv-linux-arm.patch
-Patch1: kernel-5.7.patch
-Patch2: kernel-5.8.patch
-Patch3: kernel-5.9.patch
-Patch4: kernel-5.10.patch
-Patch5: kernel-5.11.patch
-Patch6: kernel-5.14.patch
+Patch0: import-files-from-390.147.patch
+Patch1: fix-build-issues.patch
BuildRequires: elfutils-libelf-devel
BuildRequires: gcc
@@ -52,13 +47,8 @@ kmodtool --target %{_target_cpu} --repo rpmfusion --kmodname %{name}
--filterf
%setup -T -c
tar --use-compress-program xz -xf
%{_datadir}/%{name}-%{version}/%{name}-%{version}-%{_target_cpu}.tar.xz
# patch loop
-%patch1 -p1
-%patch2 -p1
-%patch3 -p1
-%patch4 -p1
-%patch5 -p1
-%patch6 -p1
%patch0 -p1
+%patch1 -p1
for kernel_version in %{?kernel_versions} ; do
cp -a kernel _kmod_build_${kernel_version%%___*}
@@ -87,6 +77,9 @@ done
%{?akmod_install}
%changelog
+* Fri Jan 21 2022 Łukasz Wojniłowicz <lukasz.wojnilowicz(a)gmail.com> - 1:340.108-17
+- Reduce the patchset to two patches
+
* Fri Nov 19 2021 Nicolas Chauvet <kwizart(a)gmail.com> - 1:340.108-16
- Rebuilt