NVIDIA – Early Patch for 5.9 Available..
There is already an early NVIDIA 450.57 patch for Kernel 5.9, and thanks to Pete for the info, and Isaak I. Aleksandrov for the patch .. This was not shown in the general list I had at https://gitlab.com/users/EULA/snippets, but the direct link is here: https://gitlab.com/EULA/snippets/-/blob/55de41ae16851dc0fc7973901c1f71007b2a4efb/NVIDIA/450.57/kernel-5.9.patch
I have tested this with the August 9th pre-release I used in my previous article, and 450.57 + patch now compiles OK..
ld -r -o /home/rgadsdon/NVIDIA-Linux-x86_64-450.57/kernel/nvidia-modeset/nv-modeset-interface.o /home/rgadsdon/NVIDIA-Linux-x86_64-450.57/kernel/nvidia-modeset/nvidia-modeset-linux.o /home/rgadsdon/NVIDIA-Linux-x86_64-450.57/kernel/nvidia-modeset/nv-kthread-q.o
MODPOST /home/rgadsdon/NVIDIA-Linux-x86_64-450.57/kernel/Module.symvers
CC [M] /home/rgadsdon/NVIDIA-Linux-x86_64-450.57/kernel/nvidia-drm.mod.o
LD [M] /home/rgadsdon/NVIDIA-Linux-x86_64-450.57/kernel/nvidia-drm.ko
CC [M] /home/rgadsdon/NVIDIA-Linux-x86_64-450.57/kernel/nvidia-modeset.mod.o
LD [M] /home/rgadsdon/NVIDIA-Linux-x86_64-450.57/kernel/nvidia-modeset.ko
CC [M] /home/rgadsdon/NVIDIA-Linux-x86_64-450.57/kernel/nvidia-uvm.mod.o
LD [M] /home/rgadsdon/NVIDIA-Linux-x86_64-450.57/kernel/nvidia-uvm.ko
CC [M] /home/rgadsdon/NVIDIA-Linux-x86_64-450.57/kernel/nvidia.mod.o
LD [M] /home/rgadsdon/NVIDIA-Linux-x86_64-450.57/kernel/nvidia.ko
make[1]: Leaving directory '/usr/src/linux-5.9-rc1pre0809'
Robert Gadsdon. August 13th 2020.
Credit where credit’s due… The guy Isaak I. Aleksandrov seems to have modified the nvidia patch for the 5.9 kernel. at least for the 450.57 drivers.
At my system thet seem to compile and run fine as far as my simple test went. Nice job!
diff –git a/kernel/common/inc/nv-mm.h b/kernel/common/inc/nv-mm.h
index b04ff67..2df20a3 100644
— a/kernel/common/inc/nv-mm.h
+++ b/kernel/common/inc/nv-mm.h
@@ -142,10 +142,15 @@ typedef int vm_fault_t;
#if defined(NV_GET_USER_PAGES_REMOTE_HAS_LOCKED_ARG)
return get_user_pages_remote(tsk, mm, start, nr_pages, flags,
pages, vmas, NULL);
+ #elif defined(NV_GET_USER_PAGES_REMOTE_REMOVED_TSK_ARG)
+
+ return get_user_pages_remote(mm, start, nr_pages, flags,
+ pages, vmas, NULL);
+
#else
return get_user_pages_remote(tsk, mm, start, nr_pages, flags,
pages, vmas);
diff –git a/kernel/conftest.sh b/kernel/conftest.sh
index a4ebf81..dd383ba 100755
— a/kernel/conftest.sh
+++ b/kernel/conftest.sh
@@ -2032,10 +2032,69 @@ compile_test() {
}”
compile_check_conftest “$CODE” “NV_DRM_DRIVER_HAS_LEGACY_DEV_LIST” “” “types”
;;
+ drm_driver_has_gem_free_object)
+ CODE=”
+ #if defined(NV_DRM_DRMP_H_PRESENT)
+ #include
+ #endif
+
+ #if defined(NV_DRM_DRM_DRV_H_PRESENT)
+ #include
+ #endif
+
+ int conftest_drm_driver_has_gem_free_object(void) {
+ return offsetof(struct drm_driver, gem_free_object);
+ }”
+
+ compile_check_conftest “$CODE” “NV_DRM_DRIVER_HAS_GEM_FREE_OBJECT” “” “types”
+ ;;
+
+ drm_display_mode_has_vrefresh)
+ CODE=”
+ #if defined(NV_DRM_DRMP_H_PRESENT)
+ #include
+ #endif
+
+ #if defined(NV_DRM_DRM_DRV_H_PRESENT)
+ #include
+ #endif
+
+ int conftest_drm_display_mode_has_vrefresh(void) {
+ return offsetof(struct drm_display_mode, vrefresh);
+ }”
+
+ compile_check_conftest “$CODE” “NV_DRM_DISPLAY_MODE_HAS_VREFRESH” “” “types”
+ ;;
+
+ drm_master_set_returns_int)
+ CODE=”
+ #if defined(NV_DRM_DRMP_H_PRESENT)
+ #include
+ #endif
+
+ #if defined(NV_DRM_DRM_DRV_H_PRESENT)
+ #include
+ #endif
+
+ static int nv_master_set(struct drm_device *x, struct drm_file *y, bool z)
+ {
+ return 1;
+ }
+
+ int conftest_drm_master_set_returns_int(void) {
+ struct drm_driver nv_drm_driver;
+ nv_drm_driver.master_set = nv_master_set;
+
+ return nv_drm_driver.master_set(NULL, NULL, false);
+ }”
+
+ compile_check_conftest “$CODE” “NV_DRM_MASTER_SET_RETURNS_INT” “” “generic”
+ ;;
+
jiffies_to_timespec)
#
# Determine if jiffies_to_timespec() is present
#
# removed by commit 751addac78b6
@@ -2643,10 +2702,33 @@ compile_test() {
else
echo “#undef NV_GET_USER_PAGES_REMOTE_HAS_LOCKED_ARG” | append_conftest “functions”
fi
echo “#undef NV_GET_USER_PAGES_REMOTE_HAS_WRITE_AND_FORCE_ARGS” | append_conftest “functions”
+ # conftest #4: check if get_user_pages_remote() has removed tsk argument
+
+ echo “$CONFTEST_PREAMBLE
+ #include
+ long get_user_pages_remote(struct mm_struct *mm,
+ unsigned long start,
+ unsigned long nr_pages,
+ unsigned int gup_flags,
+ struct page **pages,
+ struct vm_area_struct **vmas,
+ int *locked) {
+ return 0;
+ }” > conftest$$.c
+
+ $CC $CFLAGS -c conftest$$.c > /dev/null 2>&1
+ rm -f conftest$$.c
+
+ if [ -f conftest$$.o ]; then
+ echo “#define NV_GET_USER_PAGES_REMOTE_REMOVED_TSK_ARG” | append_conftest “functions”
+ rm -f conftest$$.o
+ else
+ echo “#undef NV_GET_USER_PAGES_REMOTE_REMOVED_TSK_ARG” | append_conftest “functions”
+ fi
;;
usleep_range)
#
# Determine if the function usleep_range() is present.
@@ -2708,10 +2790,25 @@ compile_test() {
else
echo “#define NV_DRM_GEM_OBJECT_LOOKUP_ARGUMENT_COUNT 2” | append_conftest “functions”
fi
;;
+ drm_gem_object_put_unlocked)
+ CODE=”
+ #if defined(NV_DRM_DRMP_H_PRESENT)
+ #include
+ #endif
+ #if defined(NV_DRM_DRM_GEM_H_PRESENT)
+ #include
+ #endif
+ int conftest_drm_gem_object_put_unlocked(void) {
+ drm_gem_object_put_unlocked();
+ }”
+
+ compile_check_conftest “$CODE” “NV_DRM_GEM_OBJECT_PUT_UNLOCKED_PRESENT” “” “functions”
+ ;;
+
drm_master_drop_has_from_release_arg)
#
# Determine if drm_driver::master_drop() has ‘from_release’ argument.
#
# Last argument ‘bool from_release’ has been removed by commit
@@ -3799,10 +3896,30 @@ compile_test() {
compile_check_conftest “$CODE” “NV_MM_HAS_MMAP_LOCK” “” “types”
;;
+ smp_read_barrier_depends)
+ CODE=”
+ #include
+ void conftest_smp_read_barrier_depends(void) {
+ smp_read_barrier_depends(0);
+ }”
+
+ compile_check_conftest “$CODE” “NV_SMP_READ_BARRIER_DEPENDS_PRESENT” “” “functions”
+ ;;
+
+ vga_tryget)
+ CODE=”
+ #include
+ void conftest_vga_tryget(void) {
+ vga_tryget();
+ }”
+
+ compile_check_conftest “$CODE” “NV_VGA_TRYGET_PRESENT” “” “functions”
+ ;;
+
# When adding a new conftest entry, please use the correct format for
# specifying the relevant upstream Linux kernel commit.
#
# was added|removed|etc by commit (“<commit message")
# in ().
diff –git a/kernel/nvidia-drm/nvidia-drm-drv.c b/kernel/nvidia-drm/nvidia-drm-drv.c
index c6ba478..9ac664a 100644
— a/kernel/nvidia-drm/nvidia-drm-drv.c
+++ b/kernel/nvidia-drm/nvidia-drm-drv.c
@@ -471,20 +471,29 @@ static void nv_drm_unload(struct drm_device *dev)
}
#endif
#if defined(NV_DRM_ATOMIC_MODESET_AVAILABLE)
+#if defined(NV_DRM_MASTER_SET_RETURNS_INT)
static int nv_drm_master_set(struct drm_device *dev,
struct drm_file *file_priv, bool from_open)
+#else
+static void nv_drm_master_set(struct drm_device *dev,
+ struct drm_file *file_priv, bool from_open)
+#endif
{
struct nv_drm_device *nv_dev = to_nv_device(dev);
+#if defined(NV_DRM_MASTER_SET_RETURNS_INT)
if (!nvKms->grabOwnership(nv_dev->pDevice)) {
return -EINVAL;
}
return 0;
+#else
+ nvKms->grabOwnership(nv_dev->pDevice);
+#endif
}
#if defined(NV_DRM_MASTER_DROP_HAS_FROM_RELEASE_ARG)
static
void nv_drm_master_drop(struct drm_device *dev,
@@ -717,11 +726,15 @@ static struct drm_driver nv_drm_driver = {
#if defined(NV_DRM_DRIVER_PRIME_FLAG_PRESENT)
DRIVER_PRIME |
#endif
DRIVER_GEM | DRIVER_RENDER,
+#if defined(NV_DRM_DRIVER_HAS_GEM_FREE_OBJECT)
.gem_free_object = nv_drm_gem_free,
+#else
+ .gem_free_object_unlocked = nv_drm_gem_free,
+#endif
.ioctls = nv_drm_ioctls,
.num_ioctls = ARRAY_SIZE(nv_drm_ioctls),
.prime_handle_to_fd = drm_gem_prime_handle_to_fd,
diff –git a/kernel/nvidia-drm/nvidia-drm-gem.h b/kernel/nvidia-drm/nvidia-drm-gem.h
index 4e7ffd3..6185085 100644
— a/kernel/nvidia-drm/nvidia-drm-gem.h
+++ b/kernel/nvidia-drm/nvidia-drm-gem.h
@@ -94,11 +94,15 @@ static inline struct nv_drm_gem_object *to_nv_gem_object(
static inline void
nv_drm_gem_object_unreference_unlocked(struct nv_drm_gem_object *nv_gem)
{
#if defined(NV_DRM_GEM_OBJECT_GET_PRESENT)
+#if defined(NV_DRM_GEM_OBJECT_PUT_UNLOCKED_PRESENT)
drm_gem_object_put_unlocked(&nv_gem->base);
+#else
+ drm_gem_object_put(&nv_gem->base);
+#endif
#else
drm_gem_object_unreference_unlocked(&nv_gem->base);
#endif
}
@@ -143,11 +147,10 @@ void nv_drm_gem_object_init(struct nv_drm_device *nv_dev,
nv_dma_resv_init(&nv_gem->resv);
#if defined(NV_DRM_GEM_OBJECT_HAS_RESV)
nv_gem->base.resv = &nv_gem->resv;
#endif
–
#endif
drm_gem_private_object_init(dev, &nv_gem->base, size);
}
diff –git a/kernel/nvidia-drm/nvidia-drm-utils.c b/kernel/nvidia-drm/nvidia-drm-utils.c
index da485c6..600ca63 100644
— a/kernel/nvidia-drm/nvidia-drm-utils.c
+++ b/kernel/nvidia-drm/nvidia-drm-utils.c
@@ -101,11 +101,13 @@ int nvkms_connector_type_to_drm_connector_type(NvKmsConnectorType type,
void
nvkms_display_mode_to_drm_mode(const struct NvKmsKapiDisplayMode *displayMode,
struct drm_display_mode *mode)
{
+#if defined(NV_DRM_DISPLAY_MODE_HAS_VREFRESH)
mode->vrefresh = (displayMode->timings.refreshRate + 500) / 1000; /* In Hz */
+#endif
mode->clock = (displayMode->timings.pixelClockHz + 500) / 1000; /* In Hz */
mode->hdisplay = displayMode->timings.hVisible;
mode->hsync_start = displayMode->timings.hSyncStart;
@@ -157,11 +159,13 @@ nvkms_display_mode_to_drm_mode(const struct NvKmsKapiDisplayMode *displayMode,
}
void drm_mode_to_nvkms_display_mode(const struct drm_display_mode *src,
struct NvKmsKapiDisplayMode *dst)
{
+#if defined(NV_DRM_DISPLAY_MODE_HAS_VREFRESH)
dst->timings.refreshRate = src->vrefresh * 1000;
+#endif
dst->timings.pixelClockHz = src->clock * 1000; /* In Hz */
dst->timings.hVisible = src->hdisplay;
dst->timings.hSyncStart = src->hsync_start;
diff –git a/kernel/nvidia-drm/nvidia-drm.Kbuild b/kernel/nvidia-drm/nvidia-drm.Kbuild
index fd17ea1..1fc565b 100644
— a/kernel/nvidia-drm/nvidia-drm.Kbuild
+++ b/kernel/nvidia-drm/nvidia-drm.Kbuild
@@ -48,19 +48,21 @@ $(call ASSIGN_PER_OBJ_CFLAGS, $(NVIDIA_DRM_OBJECTS), $(NVIDIA_DRM_CFLAGS))
NV_OBJECTS_DEPEND_ON_CONFTEST += $(NVIDIA_DRM_OBJECTS)
NV_CONFTEST_GENERIC_COMPILE_TESTS += drm_available
NV_CONFTEST_GENERIC_COMPILE_TESTS += drm_atomic_available
+NV_CONFTEST_GENERIC_COMPILE_TESTS += drm_master_set_returns_int
NV_CONFTEST_GENERIC_COMPILE_TESTS += is_export_symbol_gpl_refcount_inc
NV_CONFTEST_GENERIC_COMPILE_TESTS += is_export_symbol_gpl_refcount_dec_and_test
NV_CONFTEST_GENERIC_COMPILE_TESTS += drm_alpha_blending_available
NV_CONFTEST_FUNCTION_COMPILE_TESTS += drm_dev_unref
NV_CONFTEST_FUNCTION_COMPILE_TESTS += drm_reinit_primary_mode_group
NV_CONFTEST_FUNCTION_COMPILE_TESTS += get_user_pages_remote
NV_CONFTEST_FUNCTION_COMPILE_TESTS += get_user_pages
NV_CONFTEST_FUNCTION_COMPILE_TESTS += drm_gem_object_lookup
+NV_CONFTEST_FUNCTION_COMPILE_TESTS += drm_gem_object_put_unlocked
NV_CONFTEST_FUNCTION_COMPILE_TESTS += drm_atomic_state_ref_counting
NV_CONFTEST_FUNCTION_COMPILE_TESTS += drm_driver_has_gem_prime_res_obj
NV_CONFTEST_FUNCTION_COMPILE_TESTS += drm_atomic_helper_connector_dpms
NV_CONFTEST_FUNCTION_COMPILE_TESTS += drm_connector_funcs_have_mode_in_name
NV_CONFTEST_FUNCTION_COMPILE_TESTS += vmf_insert_pfn
@@ -73,10 +75,12 @@ NV_CONFTEST_FUNCTION_COMPILE_TESTS += drm_connector_for_each_possible_encoder
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 += drm_driver_has_legacy_dev_list
+NV_CONFTEST_TYPE_COMPILE_TESTS += drm_driver_has_gem_free_object
+NV_CONFTEST_TYPE_COMPILE_TESTS += drm_display_mode_has_vrefresh
NV_CONFTEST_TYPE_COMPILE_TESTS += drm_driver_has_set_busid
NV_CONFTEST_TYPE_COMPILE_TESTS += drm_crtc_state_has_connectors_changed
NV_CONFTEST_TYPE_COMPILE_TESTS += drm_init_function_args
NV_CONFTEST_TYPE_COMPILE_TESTS += drm_helper_mode_fill_fb_struct
NV_CONFTEST_TYPE_COMPILE_TESTS += drm_master_drop_has_from_release_arg
diff –git a/kernel/nvidia-uvm/nvidia-uvm.Kbuild b/kernel/nvidia-uvm/nvidia-uvm.Kbuild
index 0a1a4e9..8e86b51 100644
— a/kernel/nvidia-uvm/nvidia-uvm.Kbuild
+++ b/kernel/nvidia-uvm/nvidia-uvm.Kbuild
@@ -97,10 +97,11 @@ NV_CONFTEST_FUNCTION_COMPILE_TESTS += console_lock
NV_CONFTEST_FUNCTION_COMPILE_TESTS += pci_bus_address
NV_CONFTEST_FUNCTION_COMPILE_TESTS += set_memory_uc
NV_CONFTEST_FUNCTION_COMPILE_TESTS += set_pages_uc
NV_CONFTEST_FUNCTION_COMPILE_TESTS += acpi_walk_namespace
NV_CONFTEST_FUNCTION_COMPILE_TESTS += ktime_get_raw_ts64
+NV_CONFTEST_FUNCTION_COMPILE_TESTS += smp_read_barrier_depends
NV_CONFTEST_TYPE_COMPILE_TESTS += outer_flush_all
NV_CONFTEST_TYPE_COMPILE_TESTS += file_operations
NV_CONFTEST_TYPE_COMPILE_TESTS += kuid_t
NV_CONFTEST_TYPE_COMPILE_TESTS += address_space
diff –git a/kernel/nvidia-uvm/uvm8_tools.c b/kernel/nvidia-uvm/uvm8_tools.c
index 620e1cc..e4d822f 100644
— a/kernel/nvidia-uvm/uvm8_tools.c
+++ b/kernel/nvidia-uvm/uvm8_tools.c
@@ -190,11 +190,15 @@ static NV_STATUS tools_update_status(uvm_va_space_t *va_space);
static uvm_tools_event_tracker_t *tools_event_tracker(struct file *filp)
{
long event_tracker = atomic_long_read((atomic_long_t *)&filp->private_data);
+#if defined(NV_SMP_READ_BARRIER_DEPENDS_PRESENT)
smp_read_barrier_depends();
+#else
+ smp_rmb();
+#endif
return (uvm_tools_event_tracker_t *)event_tracker;
}
static bool tracker_is_queue(uvm_tools_event_tracker_t *event_tracker)
{
diff –git a/kernel/nvidia-uvm/uvm8_va_range.h b/kernel/nvidia-uvm/uvm8_va_range.h
index 69cb0a0..f6c820a 100644
— a/kernel/nvidia-uvm/uvm8_va_range.h
+++ b/kernel/nvidia-uvm/uvm8_va_range.h
@@ -753,11 +753,15 @@ static uvm_va_block_t *uvm_va_range_block(uvm_va_range_t *va_range, size_t index
// Later accesses in this thread will read state out of block, potentially
// as soon as the block pointer is updated by another thread. We have to
// make sure that any initialization of this block by the creating thread is
// visible to later accesses in this thread, which requires a data
// dependency barrier.
+#if defined(NV_SMP_READ_BARRIER_DEPENDS_PRESENT)
smp_read_barrier_depends();
+#else
+ smp_mb();
+#endif
return block;
}
// Same as uvm_va_range_block except that the block is created if not already
// present in the array. If NV_OK is returned, the block has been allocated
diff –git a/kernel/nvidia/nv-pci.c b/kernel/nvidia/nv-pci.c
index 9a8a715..a308c7d 100644
— a/kernel/nvidia/nv-pci.c
+++ b/kernel/nvidia/nv-pci.c
@@ -421,11 +421,11 @@ nv_pci_probe
#endif
pci_set_master(pci_dev);
#if defined(CONFIG_VGA_ARB) && !defined(NVCPU_PPC64LE)
-#if defined(VGA_DEFAULT_DEVICE)
+#if defined(NV_VGA_TRYGET_PRESENT) && defined(VGA_DEFAULT_DEVICE)
vga_tryget(VGA_DEFAULT_DEVICE, VGA_RSRC_LEGACY_MASK);
#endif
vga_set_legacy_decoding(pci_dev, VGA_RSRC_NONE);
#endif
diff –git a/kernel/nvidia/nvidia.Kbuild b/kernel/nvidia/nvidia.Kbuild
index 424f6e6..ce8114a 100644
— a/kernel/nvidia/nvidia.Kbuild
+++ b/kernel/nvidia/nvidia.Kbuild
@@ -144,10 +144,11 @@ NV_CONFTEST_FUNCTION_COMPILE_TESTS += tegra_get_platform
NV_CONFTEST_FUNCTION_COMPILE_TESTS += flush_cache_all
NV_CONFTEST_FUNCTION_COMPILE_TESTS += vmf_insert_pfn
NV_CONFTEST_FUNCTION_COMPILE_TESTS += jiffies_to_timespec
NV_CONFTEST_FUNCTION_COMPILE_TESTS += ktime_get_raw_ts64
NV_CONFTEST_FUNCTION_COMPILE_TESTS += ktime_get_real_ts64
+NV_CONFTEST_FUNCTION_COMPILE_TESTS += vga_tryget
NV_CONFTEST_SYMBOL_COMPILE_TESTS += is_export_symbol_gpl_of_node_to_nid
NV_CONFTEST_SYMBOL_COMPILE_TESTS += is_export_symbol_present_swiotlb_map_sg_attrs
NV_CONFTEST_SYMBOL_COMPILE_TESTS += is_export_symbol_present_swiotlb_dma_ops
NV_CONFTEST_SYMBOL_COMPILE_TESTS += is_export_symbol_present___close_fd
This patch however doe not work for the newer nvidia 450-66 drivers which are just released. however as the differences seemed minimal i took a shot at slightly modification for these as well: Use at your own risk though, i suspect some issues may arise as i did not look much further than dos it compile? and did it boot to a graphical environment. as i’m in no way a guru this should be considered as stable as a microsoft 1.0 product
diff –git a/kernel/common/inc/nv-mm.h b/kernel/common/inc/nv-mm.h
index b04ff67..2df20a3 100644
— a/kernel/common/inc/nv-mm.h
+++ b/kernel/common/inc/nv-mm.h
@@ -142,10 +142,15 @@ typedef int vm_fault_t;
#if defined(NV_GET_USER_PAGES_REMOTE_HAS_LOCKED_ARG)
return get_user_pages_remote(tsk, mm, start, nr_pages, flags,
pages, vmas, NULL);
+ #elif defined(NV_GET_USER_PAGES_REMOTE_REMOVED_TSK_ARG)
+
+ return get_user_pages_remote(mm, start, nr_pages, flags,
+ pages, vmas, NULL);
+
#else
return get_user_pages_remote(tsk, mm, start, nr_pages, flags,
pages, vmas);
diff –git a/kernel/conftest.sh b/kernel/conftest.sh
index a4ebf81..dd383ba 100755
— a/kernel/conftest.sh
+++ b/kernel/conftest.sh
@@ -2032,10 +2032,69 @@ compile_test() {
}”
compile_check_conftest “$CODE” “NV_DRM_DRIVER_HAS_LEGACY_DEV_LIST” “” “types”
;;
+ drm_driver_has_gem_free_object)
+ CODE=”
+ #if defined(NV_DRM_DRMP_H_PRESENT)
+ #include
+ #endif
+
+ #if defined(NV_DRM_DRM_DRV_H_PRESENT)
+ #include
+ #endif
+
+ int conftest_drm_driver_has_gem_free_object(void) {
+ return offsetof(struct drm_driver, gem_free_object);
+ }”
+
+ compile_check_conftest “$CODE” “NV_DRM_DRIVER_HAS_GEM_FREE_OBJECT” “” “types”
+ ;;
+
+ drm_display_mode_has_vrefresh)
+ CODE=”
+ #if defined(NV_DRM_DRMP_H_PRESENT)
+ #include
+ #endif
+
+ #if defined(NV_DRM_DRM_DRV_H_PRESENT)
+ #include
+ #endif
+
+ int conftest_drm_display_mode_has_vrefresh(void) {
+ return offsetof(struct drm_display_mode, vrefresh);
+ }”
+
+ compile_check_conftest “$CODE” “NV_DRM_DISPLAY_MODE_HAS_VREFRESH” “” “types”
+ ;;
+
+ drm_master_set_returns_int)
+ CODE=”
+ #if defined(NV_DRM_DRMP_H_PRESENT)
+ #include
+ #endif
+
+ #if defined(NV_DRM_DRM_DRV_H_PRESENT)
+ #include
+ #endif
+
+ static int nv_master_set(struct drm_device *x, struct drm_file *y, bool z)
+ {
+ return 1;
+ }
+
+ int conftest_drm_master_set_returns_int(void) {
+ struct drm_driver nv_drm_driver;
+ nv_drm_driver.master_set = nv_master_set;
+
+ return nv_drm_driver.master_set(NULL, NULL, false);
+ }”
+
+ compile_check_conftest “$CODE” “NV_DRM_MASTER_SET_RETURNS_INT” “” “generic”
+ ;;
+
jiffies_to_timespec)
#
# Determine if jiffies_to_timespec() is present
#
# removed by commit 751addac78b6
@@ -2643,10 +2702,33 @@ compile_test() {
else
echo “#undef NV_GET_USER_PAGES_REMOTE_HAS_LOCKED_ARG” | append_conftest “functions”
fi
echo “#undef NV_GET_USER_PAGES_REMOTE_HAS_WRITE_AND_FORCE_ARGS” | append_conftest “functions”
+ # conftest #4: check if get_user_pages_remote() has removed tsk argument
+
+ echo “$CONFTEST_PREAMBLE
+ #include
+ long get_user_pages_remote(struct mm_struct *mm,
+ unsigned long start,
+ unsigned long nr_pages,
+ unsigned int gup_flags,
+ struct page **pages,
+ struct vm_area_struct **vmas,
+ int *locked) {
+ return 0;
+ }” > conftest$$.c
+
+ $CC $CFLAGS -c conftest$$.c > /dev/null 2>&1
+ rm -f conftest$$.c
+
+ if [ -f conftest$$.o ]; then
+ echo “#define NV_GET_USER_PAGES_REMOTE_REMOVED_TSK_ARG” | append_conftest “functions”
+ rm -f conftest$$.o
+ else
+ echo “#undef NV_GET_USER_PAGES_REMOTE_REMOVED_TSK_ARG” | append_conftest “functions”
+ fi
;;
usleep_range)
#
# Determine if the function usleep_range() is present.
@@ -2708,10 +2790,25 @@ compile_test() {
else
echo “#define NV_DRM_GEM_OBJECT_LOOKUP_ARGUMENT_COUNT 2” | append_conftest “functions”
fi
;;
+ drm_gem_object_put_unlocked)
+ CODE=”
+ #if defined(NV_DRM_DRMP_H_PRESENT)
+ #include
+ #endif
+ #if defined(NV_DRM_DRM_GEM_H_PRESENT)
+ #include
+ #endif
+ int conftest_drm_gem_object_put_unlocked(void) {
+ drm_gem_object_put_unlocked();
+ }”
+
+ compile_check_conftest “$CODE” “NV_DRM_GEM_OBJECT_PUT_UNLOCKED_PRESENT” “” “functions”
+ ;;
+
drm_master_drop_has_from_release_arg)
#
# Determine if drm_driver::master_drop() has ‘from_release’ argument.
#
# Last argument ‘bool from_release’ has been removed by commit
@@ -3799,10 +3896,30 @@ compile_test() {
compile_check_conftest “$CODE” “NV_MM_HAS_MMAP_LOCK” “” “types”
;;
+ smp_read_barrier_depends)
+ CODE=”
+ #include
+ void conftest_smp_read_barrier_depends(void) {
+ smp_read_barrier_depends(0);
+ }”
+
+ compile_check_conftest “$CODE” “NV_SMP_READ_BARRIER_DEPENDS_PRESENT” “” “functions”
+ ;;
+
+ vga_tryget)
+ CODE=”
+ #include
+ void conftest_vga_tryget(void) {
+ vga_tryget();
+ }”
+
+ compile_check_conftest “$CODE” “NV_VGA_TRYGET_PRESENT” “” “functions”
+ ;;
+
# When adding a new conftest entry, please use the correct format for
# specifying the relevant upstream Linux kernel commit.
#
# was added|removed|etc by commit (“<commit message")
# in ().
diff –git a/kernel/nvidia-drm/nvidia-drm-drv.c b/kernel/nvidia-drm/nvidia-drm-drv.c
index c6ba478..9ac664a 100644
— a/kernel/nvidia-drm/nvidia-drm-drv.c
+++ b/kernel/nvidia-drm/nvidia-drm-drv.c
@@ -471,20 +471,29 @@ static void nv_drm_unload(struct drm_device *dev)
}
#endif
#if defined(NV_DRM_ATOMIC_MODESET_AVAILABLE)
+#if defined(NV_DRM_MASTER_SET_RETURNS_INT)
static int nv_drm_master_set(struct drm_device *dev,
struct drm_file *file_priv, bool from_open)
+#else
+static void nv_drm_master_set(struct drm_device *dev,
+ struct drm_file *file_priv, bool from_open)
+#endif
{
struct nv_drm_device *nv_dev = to_nv_device(dev);
+#if defined(NV_DRM_MASTER_SET_RETURNS_INT)
if (!nvKms->grabOwnership(nv_dev->pDevice)) {
return -EINVAL;
}
return 0;
+#else
+ nvKms->grabOwnership(nv_dev->pDevice);
+#endif
}
#if defined(NV_DRM_MASTER_DROP_HAS_FROM_RELEASE_ARG)
static
void nv_drm_master_drop(struct drm_device *dev,
@@ -717,11 +726,15 @@ static struct drm_driver nv_drm_driver = {
#if defined(NV_DRM_DRIVER_PRIME_FLAG_PRESENT)
DRIVER_PRIME |
#endif
DRIVER_GEM | DRIVER_RENDER,
+#if defined(NV_DRM_DRIVER_HAS_GEM_FREE_OBJECT)
.gem_free_object = nv_drm_gem_free,
+#else
+ .gem_free_object_unlocked = nv_drm_gem_free,
+#endif
.ioctls = nv_drm_ioctls,
.num_ioctls = ARRAY_SIZE(nv_drm_ioctls),
.prime_handle_to_fd = drm_gem_prime_handle_to_fd,
diff –git a/kernel/nvidia-drm/nvidia-drm-gem.h b/kernel/nvidia-drm/nvidia-drm-gem.h
index 4e7ffd3..6185085 100644
— a/kernel/nvidia-drm/nvidia-drm-gem.h
+++ b/kernel/nvidia-drm/nvidia-drm-gem.h
@@ -94,11 +94,15 @@ static inline struct nv_drm_gem_object *to_nv_gem_object(
static inline void
nv_drm_gem_object_unreference_unlocked(struct nv_drm_gem_object *nv_gem)
{
#if defined(NV_DRM_GEM_OBJECT_GET_PRESENT)
+#if defined(NV_DRM_GEM_OBJECT_PUT_UNLOCKED_PRESENT)
drm_gem_object_put_unlocked(&nv_gem->base);
+#else
+ drm_gem_object_put(&nv_gem->base);
+#endif
#else
drm_gem_object_unreference_unlocked(&nv_gem->base);
#endif
}
@@ -143,11 +147,10 @@ void nv_drm_gem_object_init(struct nv_drm_device *nv_dev,
nv_dma_resv_init(&nv_gem->resv);
#if defined(NV_DRM_GEM_OBJECT_HAS_RESV)
nv_gem->base.resv = &nv_gem->resv;
#endif
–
#endif
drm_gem_private_object_init(dev, &nv_gem->base, size);
}
diff –git a/kernel/nvidia-drm/nvidia-drm-utils.c b/kernel/nvidia-drm/nvidia-drm-utils.c
index da485c6..600ca63 100644
— a/kernel/nvidia-drm/nvidia-drm-utils.c
+++ b/kernel/nvidia-drm/nvidia-drm-utils.c
@@ -101,11 +101,13 @@ int nvkms_connector_type_to_drm_connector_type(NvKmsConnectorType type,
void
nvkms_display_mode_to_drm_mode(const struct NvKmsKapiDisplayMode *displayMode,
struct drm_display_mode *mode)
{
+#if defined(NV_DRM_DISPLAY_MODE_HAS_VREFRESH)
mode->vrefresh = (displayMode->timings.refreshRate + 500) / 1000; /* In Hz */
+#endif
mode->clock = (displayMode->timings.pixelClockHz + 500) / 1000; /* In Hz */
mode->hdisplay = displayMode->timings.hVisible;
mode->hsync_start = displayMode->timings.hSyncStart;
@@ -157,11 +159,13 @@ nvkms_display_mode_to_drm_mode(const struct NvKmsKapiDisplayMode *displayMode,
}
void drm_mode_to_nvkms_display_mode(const struct drm_display_mode *src,
struct NvKmsKapiDisplayMode *dst)
{
+#if defined(NV_DRM_DISPLAY_MODE_HAS_VREFRESH)
dst->timings.refreshRate = src->vrefresh * 1000;
+#endif
dst->timings.pixelClockHz = src->clock * 1000; /* In Hz */
dst->timings.hVisible = src->hdisplay;
dst->timings.hSyncStart = src->hsync_start;
diff –git a/kernel/nvidia-drm/nvidia-drm.Kbuild b/kernel/nvidia-drm/nvidia-drm.Kbuild
index fd17ea1..1fc565b 100644
— a/kernel/nvidia-drm/nvidia-drm.Kbuild
+++ b/kernel/nvidia-drm/nvidia-drm.Kbuild
@@ -48,19 +48,21 @@ $(call ASSIGN_PER_OBJ_CFLAGS, $(NVIDIA_DRM_OBJECTS), $(NVIDIA_DRM_CFLAGS))
NV_OBJECTS_DEPEND_ON_CONFTEST += $(NVIDIA_DRM_OBJECTS)
NV_CONFTEST_GENERIC_COMPILE_TESTS += drm_available
NV_CONFTEST_GENERIC_COMPILE_TESTS += drm_atomic_available
+NV_CONFTEST_GENERIC_COMPILE_TESTS += drm_master_set_returns_int
NV_CONFTEST_GENERIC_COMPILE_TESTS += is_export_symbol_gpl_refcount_inc
NV_CONFTEST_GENERIC_COMPILE_TESTS += is_export_symbol_gpl_refcount_dec_and_test
NV_CONFTEST_GENERIC_COMPILE_TESTS += drm_alpha_blending_available
NV_CONFTEST_FUNCTION_COMPILE_TESTS += drm_dev_unref
NV_CONFTEST_FUNCTION_COMPILE_TESTS += drm_reinit_primary_mode_group
NV_CONFTEST_FUNCTION_COMPILE_TESTS += get_user_pages_remote
NV_CONFTEST_FUNCTION_COMPILE_TESTS += get_user_pages
NV_CONFTEST_FUNCTION_COMPILE_TESTS += drm_gem_object_lookup
+NV_CONFTEST_FUNCTION_COMPILE_TESTS += drm_gem_object_put_unlocked
NV_CONFTEST_FUNCTION_COMPILE_TESTS += drm_atomic_state_ref_counting
NV_CONFTEST_FUNCTION_COMPILE_TESTS += drm_driver_has_gem_prime_res_obj
NV_CONFTEST_FUNCTION_COMPILE_TESTS += drm_atomic_helper_connector_dpms
NV_CONFTEST_FUNCTION_COMPILE_TESTS += drm_connector_funcs_have_mode_in_name
NV_CONFTEST_FUNCTION_COMPILE_TESTS += vmf_insert_pfn
@@ -73,10 +75,12 @@ NV_CONFTEST_FUNCTION_COMPILE_TESTS += drm_connector_for_each_possible_encoder
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 += drm_driver_has_legacy_dev_list
+NV_CONFTEST_TYPE_COMPILE_TESTS += drm_driver_has_gem_free_object
+NV_CONFTEST_TYPE_COMPILE_TESTS += drm_display_mode_has_vrefresh
NV_CONFTEST_TYPE_COMPILE_TESTS += drm_driver_has_set_busid
NV_CONFTEST_TYPE_COMPILE_TESTS += drm_crtc_state_has_connectors_changed
NV_CONFTEST_TYPE_COMPILE_TESTS += drm_init_function_args
NV_CONFTEST_TYPE_COMPILE_TESTS += drm_helper_mode_fill_fb_struct
NV_CONFTEST_TYPE_COMPILE_TESTS += drm_master_drop_has_from_release_arg
diff –git a/kernel/nvidia-uvm/nvidia-uvm.Kbuild b/kernel/nvidia-uvm/nvidia-uvm.Kbuild
index 0a1a4e9..8e86b51 100644
— a/kernel/nvidia-uvm/nvidia-uvm.Kbuild
+++ b/kernel/nvidia-uvm/nvidia-uvm.Kbuild
@@ -97,10 +97,11 @@ NV_CONFTEST_FUNCTION_COMPILE_TESTS += console_lock
NV_CONFTEST_FUNCTION_COMPILE_TESTS += pci_bus_address
NV_CONFTEST_FUNCTION_COMPILE_TESTS += set_memory_uc
NV_CONFTEST_FUNCTION_COMPILE_TESTS += set_pages_uc
NV_CONFTEST_FUNCTION_COMPILE_TESTS += acpi_walk_namespace
NV_CONFTEST_FUNCTION_COMPILE_TESTS += ktime_get_raw_ts64
+NV_CONFTEST_FUNCTION_COMPILE_TESTS += smp_read_barrier_depends
NV_CONFTEST_TYPE_COMPILE_TESTS += outer_flush_all
NV_CONFTEST_TYPE_COMPILE_TESTS += file_operations
NV_CONFTEST_TYPE_COMPILE_TESTS += kuid_t
NV_CONFTEST_TYPE_COMPILE_TESTS += address_space
diff –git a/kernel/nvidia-uvm/uvm8_tools.c b/kernel/nvidia-uvm/uvm8_tools.c
index 620e1cc..e4d822f 100644
— a/kernel/nvidia-uvm/uvm8_tools.c
+++ b/kernel/nvidia-uvm/uvm8_tools.c
@@ -190,11 +190,15 @@ static NV_STATUS tools_update_status(uvm_va_space_t *va_space);
static uvm_tools_event_tracker_t *tools_event_tracker(struct file *filp)
{
long event_tracker = atomic_long_read((atomic_long_t *)&filp->private_data);
+#if defined(NV_SMP_READ_BARRIER_DEPENDS_PRESENT)
smp_read_barrier_depends();
+#else
+ smp_rmb();
+#endif
return (uvm_tools_event_tracker_t *)event_tracker;
}
static bool tracker_is_queue(uvm_tools_event_tracker_t *event_tracker)
{
diff –git a/kernel/nvidia-uvm/uvm8_va_range.h b/kernel/nvidia-uvm/uvm8_va_range.h
index 69cb0a0..f6c820a 100644
— a/kernel/nvidia-uvm/uvm8_va_range.h
+++ b/kernel/nvidia-uvm/uvm8_va_range.h
@@ -753,11 +753,15 @@ static uvm_va_block_t *uvm_va_range_block(uvm_va_range_t *va_range, size_t index
// Later accesses in this thread will read state out of block, potentially
// as soon as the block pointer is updated by another thread. We have to
// make sure that any initialization of this block by the creating thread is
// visible to later accesses in this thread, which requires a data
// dependency barrier.
+#if defined(NV_SMP_READ_BARRIER_DEPENDS_PRESENT)
smp_read_barrier_depends();
+#else
+ smp_mb();
+#endif
return block;
}
// Same as uvm_va_range_block except that the block is created if not already
// present in the array. If NV_OK is returned, the block has been allocated
diff –git a/kernel/nvidia/nv-pci.c b/kernel/nvidia/nv-pci.c
index 9a8a715..a308c7d 100644
— a/kernel/nvidia/nv-pci.c
+++ b/kernel/nvidia/nv-pci.c
@@ -421,11 +421,11 @@ nv_pci_probe
#endif
pci_set_master(pci_dev);
#if defined(CONFIG_VGA_ARB) && !defined(NVCPU_PPC64LE)
-#if defined(VGA_DEFAULT_DEVICE)
+#if defined(NV_VGA_TRYGET_PRESENT) && defined(VGA_DEFAULT_DEVICE)
vga_tryget(VGA_DEFAULT_DEVICE, VGA_RSRC_LEGACY_MASK);
#endif
vga_set_legacy_decoding(pci_dev, VGA_RSRC_NONE);
#endif
— a/kernel/nvidia/nvidia.Kbuild 2020-08-12 21:56:36.000000000 +0200
+++ b/kernel/nvidia/nvidia.Kbuild 2020-08-19 01:25:26.899047909 +0200
@@ -146,6 +146,7 @@
NV_CONFTEST_FUNCTION_COMPILE_TESTS += jiffies_to_timespec
NV_CONFTEST_FUNCTION_COMPILE_TESTS += ktime_get_raw_ts64
NV_CONFTEST_FUNCTION_COMPILE_TESTS += ktime_get_real_ts64
+NV_CONFTEST_FUNCTION_COMPILE_TESTS += vga_tryget
NV_CONFTEST_SYMBOL_COMPILE_TESTS += is_export_symbol_gpl_of_node_to_nid
NV_CONFTEST_SYMBOL_COMPILE_TESTS += is_export_symbol_gpl_sme_active
Patch data in html gets messed up, so unable to cut/paste, in any case..
RG.