pull/10/head
Tk-Glitch 4 years ago
commit a9f671fe94

1082
PKGBUILD

File diff suppressed because it is too large Load Diff

@ -0,0 +1,27 @@
# Nvidia driver 440/435/430/418/415/410/396 series AIO installer
LIBGLVND compatible, with 32 bit libs and DKMS enabled out of the box (you will still be asked if you want to use the regular package). Installs for all currently installed kernels. Comes with custom patches to enhance kernel compatibility, dynamically applied when you're requesting a driver that's not compatible OOTB with your currently installed kernel(s).
Unwanted packages can be disabled with switches in the PKGBUILD. Defaults to complete installation.
You may need/want to add a pacman hook for nvidia depending on your setup : https://wiki.archlinux.org/index.php/NVIDIA#DRM_kernel_mode_setting
Vulkan dev drivers : https://developer.nvidia.com/vulkan-driver
Regular drivers : https://www.nvidia.com/object/unix.html
## My DKMS driver installed with kernel X.1 doesn't work/build anymore after I upgraded to kernel X.2! Help!
- Simply rebuild the packages so the script can detect your currently installed kernel(s) and patch your driver accordingly to fix compatibility issues.
# How to generate a package for a driver that isn't listed (390 and lower branches are not supported) :
- When you are prompted for driver version, select "custom" (choice 9).
- You'll then be asked the branch group. Select either "Vulkan dev" (choice 2) for Vulkan dev drivers or "stable or regular beta" (choice 1) for every other driver.
- Now you have to enter the version number of the desired driver. Vulkan dev drivers version is usually formatted as `mainbranch.version.subversion` (i.e.: 415.22.01) while the stable or regular beta drivers version is usually `mainbranch.version` (i.e.: 415.25)
- To finish, you'll be asked if you want dkms(recommended) or regular modules, similarly to the usual drivers versions.
# Optimus users :
- A great tool exists for you and works with these nvidia-all packages: https://github.com/Askannz/optimus-manager
- 435.17 beta has introduced PRIME render offload support. You can learn more about the needed setup here: http://us.download.nvidia.com/XFree86/Linux-x86_64/435.17/README/primerenderoffload.html
# Mostlyportable-gcc users :
- For non-dkms nvidia-all packages, setting your `CUSTOM_GCC_PATH` in .cfg is enough.
- For dkms nvidia-all packages, you'll need to make DKMS aware of your mostlyportable-gcc build. See: https://github.com/Tk-Glitch/PKGBUILDS/issues/334#issuecomment-537197636

@ -0,0 +1,41 @@
# nvidia-all config file
#### OPTIONS ####
# External config file to use - If the given file exists in path, it will override default config (customization.cfg) - Default is ~/.config/frogminer/nvidia-all.cfg
_EXT_CONFIG_PATH=~/.config/frogminer/nvidia-all.cfg
# Custom compiler root dirs - For non-dkms builds (see readme to use this with dkms) - Leave empty to use system compilers
# ! If your kernel was built with mostlyportable GCC, you need to use the exact same build here or module compilation will fail !
# Example: CUSTOM_GCC_PATH="/home/frog/PKGBUILDS/mostlyportable-gcc/gcc-mostlyportable-9.2.0"
CUSTOM_GCC_PATH=""
# Put the built packages in a versioned dir in the same folder as the nvidia-all PKGBUILD on exit - Will fail to install if running makepkg with -i option
_local_package_storing="false"
# If you want to ignore some packages, set them to "false". Default is all set to "true" for a complete installation.
_lib32="true"
_opencl="true"
_eglwayland="true"
# Set to "true" to unset Option "PrimaryGPU" "yes" in outputclass for PRIME Render offloading setups
_PRIME_render_offload="false"
# Attempt at fixing PRIME sync on kernel 5.4 and 5.5rc - https://devtalk.nvidia.com/default/topic/1068045/linux/5-4-kernel-breaks-prime-synchronization-/post/5416631/#5416631
_54_prime_fixing_attempt="false"
# Coolbits value - Enables fan control & overclocking from nvidia-settings - A value of 31 enables all features
_coolbits="31"
# Fix for https://bugs.archlinux.org/task/62142 affecting SLi configs
_62142_fix="true"
# Either "vulkandev" for vulkan developer drivers or "regular" for all others
_driver_branch=""
# Desired driver version - !! needs to be available from the selected branch above !!
_driver_version=""
# Set to "true" to use DKMS or "false" to use regular modules. You can also use "full" to build both dkms and regular packages (don't use it if you don't know you need it!).
_dkms=""

@ -0,0 +1,55 @@
diff --git a/kernel-dkms/conftest.sh b/kernel-dkms/conftest.sh
index e8de161..04d6683 100755
--- a/kernel-dkms/conftest.sh
+++ b/kernel-dkms/conftest.sh
@@ -1780,11 +1780,14 @@ compile_test() {
# Determine if atomic64_t and associated functions are defined
CODE="
#include <asm/atomic.h>
+ #include <linux/version.h>
void conftest_atomic64(void) {
atomic64_t data;
atomic64_read(&data);
atomic64_set(&data, 0);
+#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 16, 0)
atomic64_inc(&data);
+#endif
}"
compile_check_conftest "$CODE" "NV_ATOMIC64_PRESENT" "" "types"
diff --git a/kernel-dkms/nvidia-drm/nvidia-drm-gem-nvkms-memory.c b/kernel-dkms/nvidia-drm/nvidia-drm-gem-nvkms-memory.c
index 1db7777..863bb77 100644
--- a/kernel-dkms/nvidia-drm/nvidia-drm-gem-nvkms-memory.c
+++ b/kernel-dkms/nvidia-drm/nvidia-drm-gem-nvkms-memory.c
@@ -345,7 +347,11 @@ static int __nv_drm_vma_fault(struct vm_area_struct *vma,
page_offset = vmf->pgoff - drm_vma_node_start(&gem->vma_node);
+#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 19, 0)
ret = vm_insert_pfn(vma, address, pfn + page_offset);
+#else
+ ret = vmf_insert_pfn(vma, address, pfn + page_offset);
+#endif
switch (ret) {
case 0:
--- a/kernel-dkms/nvidia/os-interface.c 2018-11-15 21:56:59.000000000 -0600
+++ b/kernel-dkms/nvidia/os-interface.c 2018-11-26 21:53:39.970635906 -0600
@@ -1670,7 +1670,7 @@
struct nv_ipmi_softc
{
- ipmi_user_t p_user; // ptr to ipmi_msghandler user structure
+ struct ipmi_user *p_user;
spinlock_t msg_lock;
struct list_head msgs;
NvU32 seqNum; //request sequence number
@@ -1679,7 +1679,7 @@
static inline int
nv_ipmi_set_my_address
(
- ipmi_user_t user,
+ struct ipmi_user *user,
unsigned char address
)
{

@ -0,0 +1,16 @@
diff --git a/kernel-dkms/nvidia/linux_nvswitch.c b/kernel-dkms/nvidia/linux_nvswitch.c
index 75b5598..9841775 100644
--- a/kernel-dkms/nvidia/linux_nvswitch.c
+++ b/kernel-dkms/nvidia/linux_nvswitch.c
@@ -1582,7 +1582,11 @@ nvswitch_os_snprintf_time
struct tm t;
NvS32 date_end;
+#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 19, 0)
time_to_tm(time_nsec / NVSWITCH_NSEC_PER_SEC, 0, &t);
+#else
+ time64_to_tm(time_nsec / NVSWITCH_NSEC_PER_SEC, 0, &t);
+#endif
date_end = snprintf(date,
date_len,

@ -0,0 +1,55 @@
diff --git a/kernel-dkms/common/inc/nv-linux.h b/kernel-dkms/common/inc/nv-linux.h
index e235842..805e525 100644
--- a/kernel-dkms/common/inc/nv-linux.h
+++ b/kernel-dkms/common/inc/nv-linux.h
@@ -531,7 +531,11 @@ static inline void *nv_ioremap(NvU64 phys, NvU64 size)
static inline void *nv_ioremap_nocache(NvU64 phys, NvU64 size)
{
+#if defined(NV_IOREMAP_NOCACHE_PRESENT)
void *ptr = ioremap_nocache(phys, size);
+#else
+ void *ptr = ioremap(phys, size);
+#endif
if (ptr)
NV_MEMDBG_ADD(ptr, size);
return ptr;
diff --git a/kernel-dkms/nvidia/nvidia.Kbuild b/kernel-dkms/nvidia/nvidia.Kbuild
index 5ec3e65..2897e31 100644
--- a/kernel-dkms/nvidia/nvidia.Kbuild
+++ b/kernel-dkms/nvidia/nvidia.Kbuild
@@ -104,6 +104,7 @@ NV_CONFTEST_FUNCTION_COMPILE_TESTS += set_memory_array_uc
NV_CONFTEST_FUNCTION_COMPILE_TESTS += acquire_console_sem
NV_CONFTEST_FUNCTION_COMPILE_TESTS += console_lock
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 += sg_alloc_table
diff --git a/kernel-dkms/conftest.sh b/kernel-dkms/conftest.sh
index 57d85a4..4902248 100755
--- a/kernel-dkms/conftest.sh
+++ b/kernel-dkms/conftest.sh
@@ -780,6 +780,22 @@ compile_test() {
compile_check_conftest "$CODE" "NV_IOREMAP_CACHE_PRESENT" "" "functions"
;;
+ ioremap_nocache)
+ #
+ # Determine if the ioremap_nocache() function is present.
+ #
+ # 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) {
+ ioremap_nocache();
+ }"
+
+ compile_check_conftest "$CODE" "NV_IOREMAP_NOCACHE_PRESENT" "" "functions"
+ ;;
+
ioremap_wc)
#
# Determine if the ioremap_wc() function is present.

@ -0,0 +1,28 @@
diff --git a/kernel-dkms/nvidia-drm/nvidia-drm-gem-nvkms-memory.c b/kernel-dkms/nvidia-drm/nvidia-drm-gem-nvkms-memory.c
index b9cdaae..c73ed43 100644
--- a/kernel-dkms/nvidia-drm/nvidia-drm-gem-nvkms-memory.c
+++ b/kernel-dkms/nvidia-drm/nvidia-drm-gem-nvkms-memory.c
@@ -31,6 +31,8 @@
#include <drm/drm_drv.h>
#endif
+#include <linux/io.h>
+
#include "nv-mm.h"
static void __nv_drm_gem_nvkms_memory_free(struct nv_drm_gem_object *nv_gem)
diff --git a/kernel-dkms/nvidia-drm/nvidia-drm-linux.c b/kernel-dkms/nvidia-drm/nvidia-drm-linux.c
index 650b96d..1d3e658 100644
--- a/kernel-dkms/nvidia-drm/nvidia-drm-linux.c
+++ b/kernel-dkms/nvidia-drm/nvidia-drm-linux.c
@@ -35,6 +35,8 @@
#include <drm/drmP.h>
#endif
+#include <linux/vmalloc.h>
+
#include "nv-mm.h"
MODULE_PARM_DESC(

@ -0,0 +1,23 @@
From 681303f341929adacb8fd493c501f3864716ae9c Mon Sep 17 00:00:00 2001
From: Tk-Glitch <ti3nou@gmail.com>
Date: Mon, 9 Sep 2019 12:05:43 +0200
Subject: nv-vm: Replace __GFP_NORETRY flag by __GFP_RETRY_MAYFAIL
This is a test for DXVK issue #1100, suggested by NVIDIA.
https://github.com/doitsujin/dxvk/issues/1100
diff --git a/kernel-dkms/nvidia/nv-vm.c b/kernel-dkms/nvidia/nv-vm.c
index 09cd39bda..e1fd7cfd2 100644
--- a/kernel-dkms/nvidia/nv-vm.c
+++ b/kernel-dkms/nvidia/nv-vm.c
@@ -235,8 +235,8 @@ static unsigned int nv_compute_gfp_mask(
gfp_mask = NV_GFP_DMA32;
}
}
-#if defined(__GFP_NORETRY)
- gfp_mask |= __GFP_NORETRY;
+#if defined(__GFP_RETRY_MAYFAIL)
+ gfp_mask |= __GFP_RETRY_MAYFAIL;
#endif
#if defined(__GFP_ZERO)
if (at->flags & NV_ALLOC_TYPE_ZEROED)

@ -0,0 +1,33 @@
diff --git a/kernel-dkms/common/inc/nv-linux.h b/kernel-dkms/common/inc/nv-linux.h
index 10fc418..22ef968 100644
--- a/kernel-dkms/common/inc/nv-linux.h
+++ b/kernel-dkms/common/inc/nv-linux.h
@@ -175,7 +175,11 @@ static inline uid_t __kuid_val(kuid_t uid)
#if defined(NV_VM_INSERT_PAGE_PRESENT)
#include <linux/pagemap.h>
+#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 16, 0)
#include <linux/dma-mapping.h>
+#else
+#include <linux/dma-direct.h>
+#endif
#endif
#if defined(CONFIG_SWIOTLB) && defined(NVCPU_AARCH64)
diff --git a/kernel-dkms/conftest.sh b/kernel-dkms/conftest.sh
index b23dbb4..42dc576 100755
--- a/kernel-dkms/conftest.sh
+++ b/kernel-dkms/conftest.sh
@@ -1906,7 +1906,12 @@ compile_test() {
# Determine if the phys_to_dma function is present.
#
CODE="
+ #include <linux/version.h>
+#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 16, 0)
#include <linux/dma-mapping.h>
+#else
+ #include <linux/dma-direct.h>
+#endif
void conftest_phys_to_dma(void) {
phys_to_dma();
}"

@ -0,0 +1,75 @@
diff --git a/kernel-dkms/nvidia-drm/nvidia-drm-connector.c b/kernel-dkms/nvidia-drm/nvidia-drm-connector.c
index dbda66d..99333d9 100644
--- a/kernel-dkms/nvidia-drm/nvidia-drm-connector.c
+++ b/kernel-dkms/nvidia-drm/nvidia-drm-connector.c
@@ -226,7 +228,11 @@ static int nv_drm_connector_get_modes(struct drm_connector *connector)
if (nv_connector->edid != NULL) {
+#if LINUX_VERSION_CODE < KERNEL_VERSION(4,19,0)
drm_mode_connector_update_edid_property(
+#else
+ drm_connector_update_edid_property(
+#endif
connector, nv_connector->edid);
}
diff --git a/kernel-dkms/nvidia-drm/nvidia-drm-encoder.c b/kernel-dkms/nvidia-drm/nvidia-drm-encoder.c
index 3dc2400..e8b4aad 100644
--- a/kernel-dkms/nvidia-drm/nvidia-drm-encoder.c
+++ b/kernel-dkms/nvidia-drm/nvidia-drm-encoder.c
@@ -216,7 +218,11 @@ nv_drm_add_encoder(struct drm_device *dev, NvKmsKapiDisplay hDisplay)
/* Attach encoder and connector */
+#if LINUX_VERSION_CODE < KERNEL_VERSION(4,19,0)
ret = drm_mode_connector_attach_encoder(connector, encoder);
+#else
+ ret = drm_connector_attach_encoder(connector, encoder);
+#endif
if (ret != 0) {
NV_DRM_DEV_LOG_ERR(
diff --git a/kernel-dkms/conftest.sh b/kernel-dkms/conftest.sh
index dd61566..30c88a1 100755
--- a/kernel-dkms/conftest.sh
+++ b/kernel-dkms/conftest.sh
@@ -2363,17 +2363,22 @@ compile_test() {
;;
- drm_mode_connector_list_update_has_merge_type_bits_arg)
+ drm_connector_list_update_has_merge_type_bits_arg)
#
- # Detect if drm_mode_connector_list_update() has a
+ # Detect if drm_connector_list_update() has a
# 'merge_type_bits' second argument. This argument was
# remove by:
# 2015-12-03 6af3e6561243f167dabc03f732d27ff5365cd4a4
#
CODE="
#include <drm/drmP.h>
- void conftest_drm_mode_connector_list_update_has_merge_type_bits_arg(void) {
+ #include <linux/version.h>
+ void conftest_drm_connector_list_update_has_merge_type_bits_arg(void) {
+#if LINUX_VERSION_CODE < KERNEL_VERSION(4,19,0)
drm_mode_connector_list_update(
+#else
+ drm_connector_list_update(
+#endif
NULL, /* struct drm_connector *connector */
true); /* bool merge_type_bits */
}"
diff --git a/kernel-dkms/nvidia-drm/nvidia-drm.Kbuild b/kernel-dkms/nvidia-drm/nvidia-drm.Kbuild
index b4a45a7..3b7f3a1 100644
--- a/kernel-dkms/nvidia-drm/nvidia-drm.Kbuild
+++ b/kernel-dkms/nvidia-drm/nvidia-drm.Kbuild
@@ -74,7 +74,7 @@ NV_CONFTEST_TYPE_COMPILE_TESTS += drm_driver_has_legacy_dev_list
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_mode_connector_list_update_has_merge_type_bits_arg
+NV_CONFTEST_TYPE_COMPILE_TESTS += drm_connector_list_update_has_merge_type_bits_arg
NV_CONFTEST_TYPE_COMPILE_TESTS += drm_helper_mode_fill_fb_struct
NV_CONFTEST_TYPE_COMPILE_TESTS += drm_master_drop_has_from_release_arg
NV_CONFTEST_TYPE_COMPILE_TESTS += drm_driver_unload_has_int_return_type

@ -0,0 +1,646 @@
From 11adcf1e8d2fbebeb614390832de08388a46bcda Mon Sep 17 00:00:00 2001
From: Tk-Glitch <ti3nou@gmail.com>
Date: Mon, 28 Jan 2019 18:21:34 +0100
Subject: kernel 5.0 patch
diff --git a/kernel-dkms/common/inc/nv.h b/kernel-dkms/common/inc/nv.h
index d52c2a1ef..f6dc2dc32 100644
--- a/kernel-dkms/common/inc/nv.h
+++ b/kernel-dkms/common/inc/nv.h
@@ -603,6 +605,7 @@ typedef NV_STATUS (*nvPmaEvictRangeCallback)(void *, NvU64, NvU64);
#define NV_MAX_ISR_DELAY_US 20000
#define NV_MAX_ISR_DELAY_MS (NV_MAX_ISR_DELAY_US / 1000)
+#if LINUX_VERSION_CODE < KERNEL_VERSION(5,0,0)
#define NV_TIMERCMP(a, b, CMP) \
(((a)->tv_sec == (b)->tv_sec) ? \
((a)->tv_usec CMP (b)->tv_usec) : ((a)->tv_sec CMP (b)->tv_sec))
@@ -630,6 +633,35 @@ typedef NV_STATUS (*nvPmaEvictRangeCallback)(void *, NvU64, NvU64);
}
#define NV_TIMEVAL_TO_US(tv) ((NvU64)(tv).tv_sec * 1000000 + (tv).tv_usec)
+#else
+#define NV_TIMERCMP(a, b, CMP) \
+ (((a)->tv_sec == (b)->tv_sec) ? \
+ ((a)->tv_nsec CMP (b)->tv_nsec) : ((a)->tv_sec CMP (b)->tv_sec))
+
+#define NV_TIMERADD(a, b, result) \
+ { \
+ (result)->tv_sec = (a)->tv_sec + (b)->tv_sec; \
+ (result)->tv_nsec = (a)->tv_nsec + (b)->tv_nsec; \
+ if ((result)->tv_nsec >= NSEC_PER_SEC) \
+ { \
+ ++(result)->tv_sec; \
+ (result)->tv_nsec -= NSEC_PER_SEC; \
+ } \
+ }
+
+#define NV_TIMERSUB(a, b, result) \
+ { \
+ (result)->tv_sec = (a)->tv_sec - (b)->tv_sec; \
+ (result)->tv_nsec = (a)->tv_nsec - (b)->tv_nsec; \
+ if ((result)->tv_nsec < 0) \
+ { \
+ --(result)->tv_sec; \
+ (result)->tv_nsec += NSEC_PER_SEC; \
+ } \
+ }
+
+#define NV_TIMEVAL_TO_US(tv) ((NvU64)(tv).tv_sec * USEC_PER_SEC + (tv).tv_nsec/NSEC_PER_USEC)
+#endif
#ifndef NV_ALIGN_UP
#define NV_ALIGN_UP(v,g) (((v) + ((g) - 1)) & ~((g) - 1))
diff --git a/kernel-dkms/conftest.sh b/kernel-dkms/conftest.sh
index 0ae7a2662..9a71ae7b3 100755
--- a/kernel-dkms/conftest.sh
+++ b/kernel-dkms/conftest.sh
@@ -1653,6 +1653,24 @@ compile_test() {
compile_check_conftest "$CODE" "NV_DRM_AVAILABLE" "" "generic"
;;
+ drm_dev_put)
+ #
+ # Determine if drm_dev_put() is present.
+ #
+ CODE="
+ #include <linux/version.h>
+ #if defined(NV_DRM_DRMP_H_PRESENT)
+ #include <drm/drmP.h>
+ #endif
+#if LINUX_VERSION_CODE => KERNEL_VERSION(5,0,0)
+ void conftest_drm_dev_put(void) {
+ drm_dev_put();
+ }
+#endif"
+
+ compile_check_conftest "$CODE" "NV_DRM_DEV_PUT_PRESENT" "" "functions"
+ ;;
+
drm_dev_unref)
#
# Determine if drm_dev_unref() is present.
diff --git a/kernel-dkms/nvidia-drm/nvidia-drm-gem.h b/kernel-dkms/nvidia-drm/nvidia-drm-gem.h
index f276588db..7cbdbe632 100644
--- a/kernel-dkms/nvidia-drm/nvidia-drm-gem.h
+++ b/kernel-dkms/nvidia-drm/nvidia-drm-gem.h
@@ -79,7 +81,11 @@ static inline int nv_drm_gem_handle_create_drop_reference(
/* drop reference from allocate - handle holds it now */
+#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 0, 0)
drm_gem_object_unreference_unlocked(&nv_gem->base);
+#else
+ drm_gem_object_put_unlocked(&nv_gem->base);
+#endif
return ret;
}
@@ -148,13 +154,21 @@ static inline struct nv_drm_gem_object *nv_drm_gem_object_lookup(
static inline void
nv_drm_gem_object_unreference_unlocked(struct nv_drm_gem_object *nv_gem)
{
+#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 0, 0)
drm_gem_object_unreference_unlocked(&nv_gem->base);
+#else
+ drm_gem_object_put_unlocked(&nv_gem->base);
+#endif
}
static inline void
nv_drm_gem_object_unreference(struct nv_drm_gem_object *nv_gem)
{
+#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 0, 0)
drm_gem_object_unreference(&nv_gem->base);
+#else
+ drm_gem_object_put(&nv_gem->base);
+#endif
}
static inline int nv_drm_gem_handle_create(struct drm_file *filp,
diff --git a/kernel-dkms/nvidia-drm/nvidia-drm-helper.c b/kernel-dkms/nvidia-drm/nvidia-drm-helper.c
index 4ccf81929..7fb59bbb3 100644
--- a/kernel-dkms/nvidia-drm/nvidia-drm-helper.c
+++ b/kernel-dkms/nvidia-drm/nvidia-drm-helper.c
@@ -149,12 +151,20 @@ void nv_drm_atomic_clean_old_fb(struct drm_device *dev,
if (ret == 0) {
struct drm_framebuffer *new_fb = plane->state->fb;
if (new_fb)
+#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 0, 0)
drm_framebuffer_reference(new_fb);
+#else
+ drm_framebuffer_get(new_fb);
+#endif
plane->fb = new_fb;
plane->crtc = plane->state->crtc;
if (plane->old_fb)
+#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 0, 0)
drm_framebuffer_unreference(plane->old_fb);
+#else
+ drm_framebuffer_put(plane->old_fb);
+#endif
}
plane->old_fb = NULL;
}
diff --git a/kernel-dkms/nvidia-drm/nvidia-drm-helper.h b/kernel-dkms/nvidia-drm/nvidia-drm-helper.h
index efecc4ad7..2a0c3bbca 100644
--- a/kernel-dkms/nvidia-drm/nvidia-drm-helper.h
+++ b/kernel-dkms/nvidia-drm/nvidia-drm-helper.h
@@ -36,7 +36,9 @@
*/
static inline void nv_drm_dev_free(struct drm_device *dev)
{
-#if defined(NV_DRM_DEV_UNREF_PRESENT)
+#if defined(NV_DRM_DEV_PUT_PRESENT)
+ drm_dev_put(dev);
+#elif defined(NV_DRM_DEV_UNREF_PRESENT)
drm_dev_unref(dev);
#else
drm_dev_free(dev);
diff --git a/kernel-dkms/nvidia-drm/nvidia-drm-linux.c b/kernel-dkms/nvidia-drm/nvidia-drm-linux.c
index 5a2bbc18c..133d8fe64 100644
--- a/kernel-dkms/nvidia-drm/nvidia-drm-linux.c
+++ b/kernel-dkms/nvidia-drm/nvidia-drm-linux.c
@@ -151,11 +153,19 @@ void nv_drm_vunmap(void *address)
uint64_t nv_drm_get_time_usec(void)
{
+#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 0, 0)
struct timeval tv;
do_gettimeofday(&tv);
return (((uint64_t)tv.tv_sec) * 1000000) + tv.tv_usec;
+#else
+ struct timespec64 ts;
+
+ ktime_get_real_ts64(&ts);
+
+ return (((uint64_t)ts.tv_sec) * USEC_PER_SEC) + (((uint64_t)ts.tv_nsec) / NSEC_PER_USEC);
+#endif
}
#endif /* NV_DRM_AVAILABLE */
diff --git a/kernel-dkms/nvidia-drm/nvidia-drm.Kbuild b/kernel-dkms/nvidia-drm/nvidia-drm.Kbuild
index 466b51528..bcf8aff10 100644
--- a/kernel-dkms/nvidia-drm/nvidia-drm.Kbuild
+++ b/kernel-dkms/nvidia-drm/nvidia-drm.Kbuild
@@ -53,6 +53,7 @@ NV_CONFTEST_GENERIC_COMPILE_TESTS += drm_atomic_modeset_nonblocking_commit_avail
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_FUNCTION_COMPILE_TESTS += drm_dev_put
NV_CONFTEST_FUNCTION_COMPILE_TESTS += drm_dev_unref
NV_CONFTEST_FUNCTION_COMPILE_TESTS += drm_reinit_primary_mode_group
NV_CONFTEST_FUNCTION_COMPILE_TESTS += drm_atomic_set_mode_for_crtc
diff --git a/kernel-dkms/nvidia-modeset/nvidia-modeset-linux.c b/kernel-dkms/nvidia-modeset/nvidia-modeset-linux.c
index 1b9148ee7..4c1bd3617 100644
--- a/kernel-dkms/nvidia-modeset/nvidia-modeset-linux.c
+++ b/kernel-dkms/nvidia-modeset/nvidia-modeset-linux.c
@@ -210,11 +212,19 @@ void NVKMS_API_CALL nvkms_usleep(NvU64 usec)
NvU64 NVKMS_API_CALL nvkms_get_usec(void)
{
+#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 0, 0)
struct timeval tv;
do_gettimeofday(&tv);
return (((NvU64)tv.tv_sec) * 1000000) + tv.tv_usec;
+#else
+ struct timespec64 ts;
+
+ ktime_get_real_ts64(&ts);
+
+ return (((NvU64)ts.tv_sec) * 1000000) + ts.tv_nsec/NSEC_PER_USEC;
+#endif
}
int NVKMS_API_CALL nvkms_copyin(void *kptr, NvU64 uaddr, size_t n)
diff --git a/kernel-dkms/nvidia-uvm/uvm_linux.h b/kernel-dkms/nvidia-uvm/uvm_linux.h
index 8707ac070..990cefbd4 100644
--- a/kernel-dkms/nvidia-uvm/uvm_linux.h
+++ b/kernel-dkms/nvidia-uvm/uvm_linux.h
@@ -320,12 +322,21 @@ static inline uint64_t NV_DIV64(uint64_t dividend, uint64_t divisor, uint64_t *r
/* Return a nanosecond-precise value */
static inline NvU64 NV_GETTIME(void)
{
+#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 0, 0)
struct timespec ts = {0};
getrawmonotonic(&ts);
/* Wraps around every 583 years */
return (ts.tv_sec * 1000000000ULL + ts.tv_nsec);
+#else
+ struct timespec64 ts = {0};
+
+ ktime_get_raw_ts64(&ts);
+
+ /* Wraps around every 583 years */
+ return (ts.tv_sec * NSEC_PER_SEC + ts.tv_nsec);
+#endif
}
#else
/* We can only return a microsecond-precise value with the
@@ -334,9 +345,15 @@ static inline NvU64 NV_GETTIME(void)
{
struct timeval tv = {0};
+#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 0, 0)
do_gettimeofday(&tv);
return (tv.tv_sec * 1000000000ULL + tv.tv_usec * 1000ULL);
+#else
+ ktime_get_real_ts64(&tv);
+
+ return (tv.tv_sec * 1000000000ULL + (tv.tv_nsec/NSEC_PER_USEC) * 1000ULL);
+#endif
}
#endif
diff --git a/kernel-dkms/nvidia/nvlink_linux.c b/kernel-dkms/nvidia/nvlink_linux.c
index c13b72515..db691679c 100644
--- a/kernel-dkms/nvidia/nvlink_linux.c
+++ b/kernel-dkms/nvidia/nvlink_linux.c
@@ -500,6 +502,7 @@ void * NVLINK_API_CALL nvlink_memcpy(void *dest, void *src, NvLength size)
return memcpy(dest, src, size);
}
+#if LINUX_VERSION_CODE < KERNEL_VERSION(5,0,0)
static NvBool nv_timer_less_than
(
const struct timeval *a,
@@ -610,6 +613,118 @@ void NVLINK_API_CALL nvlink_sleep(unsigned int ms)
udelay(us);
}
}
+#else
+static NvBool nv_timer_less_than
+(
+ const struct timespec64 *a,
+ const struct timespec64 *b
+)
+{
+ return (a->tv_sec == b->tv_sec) ? (a->tv_nsec < b->tv_nsec)
+ : (a->tv_sec < b->tv_sec);
+}
+
+static void nv_timeradd
+(
+ const struct timespec64 *a,
+ const struct timespec64 *b,
+ struct timespec64 *result
+)
+{
+ result->tv_sec = a->tv_sec + b->tv_sec;
+ result->tv_nsec = a->tv_nsec + b->tv_nsec;
+ while (result->tv_nsec >= NSEC_PER_SEC)
+ {
+ ++result->tv_sec;
+ result->tv_nsec -= NSEC_PER_SEC;
+ }
+}
+
+static void nv_timersub
+(
+ const struct timespec64 *a,
+ const struct timespec64 *b,
+ struct timespec64 *result
+)
+{
+ result->tv_sec = a->tv_sec - b->tv_sec;
+ result->tv_nsec = a->tv_nsec - b->tv_nsec;
+ while (result->tv_nsec < 0)
+ {
+ --(result->tv_sec);
+ result->tv_nsec += NSEC_PER_SEC;
+ }
+}
+
+/*
+ * Sleep for specified milliseconds. Yields the CPU to scheduler.
+ */
+void NVLINK_API_CALL nvlink_sleep(unsigned int ms)
+{
+ unsigned long us;
+ unsigned long jiffies;
+ unsigned long mdelay_safe_msec;
+ struct timespec64 ts_end, ts_aux;
+
+ ktime_get_real_ts64(&ts_aux);
+
+ if (in_irq() && (ms > NV_MAX_ISR_DELAY_MS))
+ {
+ return;
+ }
+
+ if (irqs_disabled() || in_interrupt() || in_atomic())
+ {
+ mdelay(ms);
+ return;
+ }
+
+ us = ms * 1000;
+ ts_end.tv_nsec = us*NSEC_PER_USEC;
+ ts_end.tv_sec = 0;
+ nv_timeradd(&ts_aux, &ts_end, &ts_end);
+
+ /* do we have a full jiffie to wait? */
+ jiffies = NV_USECS_TO_JIFFIES(us);
+
+ if (jiffies)
+ {
+ //
+ // If we have at least one full jiffy to wait, give up
+ // up the CPU; since we may be rescheduled before
+ // the requested timeout has expired, loop until less
+ // than a jiffie of the desired delay remains.
+ //
+ current->state = TASK_INTERRUPTIBLE;
+ do
+ {
+ schedule_timeout(jiffies);
+ ktime_get_real_ts64(&ts_aux);
+ if (nv_timer_less_than(&ts_aux, &ts_end))
+ {
+ nv_timersub(&ts_end, &ts_aux, &ts_aux);
+ us = ts_aux.tv_nsec/NSEC_PER_USEC + ts_aux.tv_sec * USEC_PER_SEC;
+ }
+ else
+ {
+ us = 0;
+ }
+ }
+ while ((jiffies = NV_USECS_TO_JIFFIES(us)) != 0);
+ }
+
+ if (us > 1000)
+ {
+ mdelay_safe_msec = us / USEC_PER_MSEC;
+ mdelay(mdelay_safe_msec);
+ us %= 1000;
+ }
+ if (us)
+ {
+ udelay(us);
+ }
+}
+#endif
void NVLINK_API_CALL nvlink_assert(int cond)
{
diff --git a/kernel-dkms/nvidia/os-interface.c b/kernel-dkms/nvidia/os-interface.c
index d1c889f69..88c57b2da 100644
--- a/kernel-dkms/nvidia/os-interface.c
+++ b/kernel-dkms/nvidia/os-interface.c
@@ -426,6 +428,7 @@ NV_STATUS NV_API_CALL os_get_current_time(
NvU32 *seconds,
NvU32 *useconds
)
+#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 0, 0)
{
struct timeval tm;
@@ -608,6 +611,190 @@ NV_STATUS NV_API_CALL os_delay(NvU32 MilliSeconds)
return NV_OK;
}
+#else
+{
+ struct timespec64 ts;
+
+ ktime_get_real_ts64(&ts);
+
+ *seconds = ts.tv_sec;
+ *useconds = ((uint64_t)(ts.tv_nsec / NSEC_PER_USEC));
+
+ return NV_OK;
+}
+
+#if BITS_PER_LONG >= 64
+
+void NV_API_CALL os_get_current_tick(NvU64 *nseconds)
+{
+ struct timespec64 ts;
+
+ jiffies_to_timespec64(jiffies, &ts);
+
+ *nseconds = ((NvU64)ts.tv_sec * NSEC_PER_SEC + (NvU64)ts.tv_nsec);
+}
+
+#else
+
+void NV_API_CALL os_get_current_tick(NvU64 *nseconds)
+{
+ /*
+ * 'jiffies' overflows regularly on 32-bit builds (unsigned long is 4 bytes
+ * instead of 8 bytes), so it's unwise to build a tick counter on it, since
+ * the rest of the Resman assumes the 'tick' returned from this function is
+ * monotonically increasing and never overflows.
+ *
+ * Instead, use the previous implementation that we've lived with since the
+ * beginning, which uses system clock time to calculate the tick. This is
+ * subject to problems if the system clock time changes dramatically
+ * (more than a second or so) while the Resman is actively tracking a
+ * timeout.
+ */
+ NvU32 seconds, useconds;
+
+ (void) os_get_current_time(&seconds, &useconds);
+
+ *nseconds = ((NvU64)seconds * NSEC_PER_SEC +
+ (NvU64)useconds * NSEC_PER_USEC);
+}
+
+#endif
+
+//---------------------------------------------------------------------------
+//
+// Misc services.
+//
+//---------------------------------------------------------------------------
+
+#define NV_MSECS_PER_JIFFIE (1000 / HZ)
+#define NV_MSECS_TO_JIFFIES(msec) ((msec) * HZ / 1000)
+#define NV_USECS_PER_JIFFIE (1000000 / HZ)
+#define NV_USECS_TO_JIFFIES(usec) ((usec) * HZ / 1000000)
+
+// #define NV_CHECK_DELAY_ACCURACY 1
+
+/*
+ * It is generally a bad idea to use udelay() to wait for more than
+ * a few milliseconds. Since the caller is most likely not aware of
+ * this, we use mdelay() for any full millisecond to be safe.
+ */
+
+NV_STATUS NV_API_CALL os_delay_us(NvU32 MicroSeconds)
+{
+ unsigned long mdelay_safe_msec;
+ unsigned long usec;
+
+#ifdef NV_CHECK_DELAY_ACCURACY
+ struct timespec64 ts1, ts2;
+
+ ktime_get_real_ts64(&ts1);
+#endif
+
+ if (in_irq() && (MicroSeconds > NV_MAX_ISR_DELAY_US))
+ return NV_ERR_GENERIC;
+
+ mdelay_safe_msec = MicroSeconds / 1000;
+ if (mdelay_safe_msec)
+ mdelay(mdelay_safe_msec);
+
+ usec = MicroSeconds % 1000;
+ if (usec)
+ udelay(usec);
+
+#ifdef NV_CHECK_DELAY_ACCURACY
+ ktime_get_real_ts64(&ts2);
+ nv_printf(NV_DBG_ERRORS, "NVRM: osDelayUs %d: 0x%x 0x%x\n",
+ MicroSeconds, ts2.tv_sec - ts1.tv_sec, (ts2.tv_nsec - ts1.tv_nsec) / NSEC_PER_USEC);
+#endif
+
+ return NV_OK;
+}
+
+/*
+ * On Linux, a jiffie represents the time passed in between two timer
+ * interrupts. The number of jiffies per second (HZ) varies across the
+ * supported platforms. On i386, where HZ is 100, a timer interrupt is
+ * generated every 10ms; the resolution is a lot better on ia64, where
+ * HZ is 1024. NV_MSECS_TO_JIFFIES should be accurate independent of
+ * the actual value of HZ; any partial jiffies will be 'floor'ed, the
+ * remainder will be accounted for with mdelay().
+ */
+
+NV_STATUS NV_API_CALL os_delay(NvU32 MilliSeconds)
+{
+ unsigned long MicroSeconds;
+ unsigned long jiffies;
+ unsigned long mdelay_safe_msec;
+ struct timespec64 ts_end, ts_aux;
+#ifdef NV_CHECK_DELAY_ACCURACY
+ struct timespec64 ts_start;
+#endif
+
+ ktime_get_real_ts64(&ts_aux);
+#ifdef NV_CHECK_DELAY_ACCURACY
+ ts_start = ts_aux;
+#endif
+
+ if (in_irq() && (MilliSeconds > NV_MAX_ISR_DELAY_MS))
+ return NV_ERR_GENERIC;
+
+ if (!NV_MAY_SLEEP())
+ {
+ mdelay(MilliSeconds);
+ return NV_OK;
+ }
+
+ MicroSeconds = MilliSeconds * USEC_PER_MSEC;
+ ts_end.tv_nsec = MicroSeconds * NSEC_PER_USEC;
+ ts_end.tv_sec = 0;
+ NV_TIMERADD(&ts_aux, &ts_end, &ts_end);
+
+ /* do we have a full jiffie to wait? */
+ jiffies = NV_USECS_TO_JIFFIES(MicroSeconds);
+
+ if (jiffies)
+ {
+ //
+ // If we have at least one full jiffy to wait, give up
+ // up the CPU; since we may be rescheduled before
+ // the requested timeout has expired, loop until less
+ // than a jiffie of the desired delay remains.
+ //
+ current->state = TASK_INTERRUPTIBLE;
+ do
+ {
+ schedule_timeout(jiffies);
+ ktime_get_real_ts64(&ts_aux);
+ if (NV_TIMERCMP(&ts_aux, &ts_end, <))
+ {
+ NV_TIMERSUB(&ts_end, &ts_aux, &ts_aux);
+ MicroSeconds = ts_aux.tv_nsec/NSEC_PER_USEC + ts_aux.tv_sec * USEC_PER_SEC;
+ }
+ else
+ MicroSeconds = 0;
+ } while ((jiffies = NV_USECS_TO_JIFFIES(MicroSeconds)) != 0);
+ }
+
+ if (MicroSeconds > 1000)
+ {
+ mdelay_safe_msec = MicroSeconds / 1000;
+ mdelay(mdelay_safe_msec);
+ MicroSeconds %= 1000;
+ }
+ if (MicroSeconds)
+ {
+ udelay(MicroSeconds);
+ }
+#ifdef NV_CHECK_DELAY_ACCURACY
+ ktime_get_real_ts64(&ts_aux);
+ timersub(&ts_aux, &ts_start, &ts_aux);
+ nv_printf(NV_DBG_ERRORS, "NVRM: osDelay %dmsec: %d.%06dsec\n",
+ MilliSeconds, ts_aux.tv_sec, ts_aux.tv_nsec/NSEC_PER_USEC);
+#endif
+
+ return NV_OK;
+}
+#endif
NvU64 NV_API_CALL os_get_cpu_frequency(void)
{
@@ -1896,6 +2083,7 @@ static NV_STATUS NV_API_CALL _os_ipmi_receive_resp
nvipmi_resp_t *p_resp
)
{
+#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 0, 0)
struct ipmi_recv_msg *rx_msg;
int err_no;
struct timeval tv;
@@ -1928,6 +2116,40 @@ static NV_STATUS NV_API_CALL _os_ipmi_receive_resp
os_delay(NV_IPMI_SLEEP_MS);
do_gettimeofday(&tv);
} while (NV_TIMEVAL_TO_US(tv) < (start_time + NV_IPMI_READ_TIMEOUT_US));
+#else
+ struct ipmi_recv_msg *rx_msg;
+ int err_no;
+ struct timespec64 ts;
+ NvU64 start_time;
+
+ ktime_get_real_ts64(&ts);
+ start_time = NV_TIMEVAL_TO_US(ts);
+
+ err_no = -EAGAIN;
+ do
+ {
+ unsigned long flags;
+ struct list_head *ent;
+
+ rx_msg = NULL;
+
+ spin_lock_irqsave(&p_priv->msg_lock, flags);
+ if (!list_empty(&p_priv->msgs))
+ {
+ ent = p_priv->msgs.next;
+ rx_msg = list_entry(ent, struct ipmi_recv_msg, link);
+ list_del(ent);
+ spin_unlock_irqrestore(&p_priv->msg_lock, flags);
+
+ err_no = 0;
+ break;
+ }
+
+ spin_unlock_irqrestore(&p_priv->msg_lock, flags);
+ os_delay(NV_IPMI_SLEEP_MS);
+ ktime_get_real_ts64(&ts);
+ } while (NV_TIMEVAL_TO_US(ts) < (start_time + NV_IPMI_READ_TIMEOUT_US));
+#endif
if (rx_msg != NULL)
{

@ -0,0 +1,98 @@
From c2c16eef00915cbe7a7bc58b1f3308705ef2bfc4 Mon Sep 17 00:00:00 2001
From: Tk-Glitch <ti3nou@gmail.com>
Date: Wed, 3 Apr 2019 18:02:22 +0200
Subject: nvidia kernel 5.1 patch (exploded into parts).
Thanks to Robert Gadsdon's findings @ http://rglinuxtech.com
diff --git a/kernel-dkms/nvidia-drm/nvidia-drm-connector.c b/kernel-dkms/nvidia-drm/nvidia-drm-connector.c
index 4dd12d112..44c9d8ed3 100644
--- a/kernel-dkms/nvidia-drm/nvidia-drm-connector.c
+++ b/kernel-dkms/nvidia-drm/nvidia-drm-connector.c
@@ -201,6 +203,12 @@ nv_drm_connector_detect(struct drm_connector *connector, bool force)
return __nv_drm_connector_detect_internal(connector);
}
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 1, 0)
+int drm_helper_probe_single_connector_modes(struct drm_connector
+ *connector, uint32_t maxX,
+ uint32_t maxY);
+#endif
+
static struct drm_connector_funcs nv_connector_funcs = {
#if defined NV_DRM_ATOMIC_HELPER_CONNECTOR_DPMS_PRESENT
.dpms = drm_atomic_helper_connector_dpms,
diff --git a/kernel-dkms/nvidia-drm/nvidia-drm-drv.c b/kernel-dkms/nvidia-drm/nvidia-drm-drv.c
index 58fd2724a..fc9169a96 100644
--- a/kernel-dkms/nvidia-drm/nvidia-drm-drv.c
+++ b/kernel-dkms/nvidia-drm/nvidia-drm-drv.c
@@ -35,6 +37,13 @@
#include "nvidia-drm-gem-nvkms-memory.h"
#include "nvidia-drm-gem-user-memory.h"
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 1, 0)
+void drm_kms_helper_poll_init(struct drm_device *dev);
+void drm_kms_helper_poll_fini(struct drm_device *dev);
+bool drm_helper_hpd_irq_event(struct drm_device *dev);
+void drm_kms_helper_poll_disable(struct drm_device *dev);
+#endif
+
#if defined(NV_DRM_AVAILABLE)
#include "nvidia-drm-ioctl.h"
diff --git a/kernel-dkms/nvidia-drm/nvidia-drm-encoder.c b/kernel-dkms/nvidia-drm/nvidia-drm-encoder.c
index f66bbd7c9..4de87a271 100644
--- a/kernel-dkms/nvidia-drm/nvidia-drm-encoder.c
+++ b/kernel-dkms/nvidia-drm/nvidia-drm-encoder.c
@@ -36,6 +38,10 @@
#include <drm/drm_atomic.h>
#include <drm/drm_atomic_helper.h>
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 1, 0)
+void drm_kms_helper_hotplug_event(struct drm_device *dev);
+#endif
+
static void nv_drm_encoder_destroy(struct drm_encoder *encoder)
{
struct nv_drm_encoder *nv_encoder = to_nv_encoder(encoder);
@@ -152,6 +158,12 @@ nv_drm_encoder_new(struct drm_device *dev,
return &nv_encoder->base;
}
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 1, 0)
+int drm_helper_probe_single_connector_modes(struct drm_connector
+ *connector, uint32_t maxX,
+ uint32_t maxY);
+#endif
+
/*
* Add encoder for given NvKmsKapiDisplay
*/
diff --git a/kernel-dkms/nvidia-uvm/uvm8.c b/kernel-dkms/nvidia-uvm/uvm8.c
index 44467988e..4cba5dc33 100644
--- a/kernel-dkms/nvidia-uvm/uvm8.c
+++ b/kernel-dkms/nvidia-uvm/uvm8.c
@@ -172,7 +172,11 @@ static int uvm_vm_fault_sigbus(struct vm_area_struct *vma, struct vm_fault *vmf)
return VM_FAULT_SIGBUS;
}
+#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 1, 0)
static int uvm_vm_fault_sigbus_wrapper(struct vm_fault *vmf)
+#else
+static vm_fault_t uvm_vm_fault_sigbus_wrapper(struct vm_fault *vmf)
+#endif
{
#if defined(NV_VM_OPS_FAULT_REMOVED_VMA_ARG)
return uvm_vm_fault_sigbus(vmf->vma, vmf);
@@ -507,7 +511,11 @@ convert_error:
}
}
+#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 1, 0)
static int uvm_vm_fault_wrapper(struct vm_fault *vmf)
+#else
+static vm_fault_t uvm_vm_fault_wrapper(struct vm_fault *vmf)
+#endif
{
#if defined(NV_VM_OPS_FAULT_REMOVED_VMA_ARG)
return uvm_vm_fault(vmf->vma, vmf);

@ -0,0 +1,57 @@
From 9b34e3b6b42a826fac66c8ff44e6260a09758c53 Mon Sep 17 00:00:00 2001
From: Tk-Glitch <ti3nou@gmail.com>
Date: Mon, 8 Jul 2019 10:19:45 +0200
Subject: nvidia kernel 5.2 patch
diff --git a/kernel-dkms/nvidia-uvm/uvm8_tools.c b/kernel-dkms/nvidia-uvm/uvm8_tools.c
index 82c890587..cea2eb54c 100644
--- a/kernel-dkms/nvidia-uvm/uvm8_tools.c
+++ b/kernel-dkms/nvidia-uvm/uvm8_tools.c
@@ -206,18 +206,34 @@ static bool tracker_is_counter(uvm_tools_event_tracker_t *event_tracker)
return event_tracker != NULL && !event_tracker->is_queue;
}
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 2, 0)
+static void uvm_put_user_pages_dirty(struct page **pages, NvU64 page_count)
+{
+ NvU64 i;
+
+ for (i = 0; i < page_count; i++) {
+ set_page_dirty(pages[i]);
+ put_page(pages[i]);
+ }
+}
+#else
static void put_user_pages(struct page **pages, NvU64 page_count)
{
NvU64 i;
for (i = 0; i < page_count; i++)
put_page(pages[i]);
}
+#endif
static void unmap_user_pages(struct page **pages, void *addr, NvU64 size)
{
size = DIV_ROUND_UP(size, PAGE_SIZE);
vunmap((NvU8 *)addr);
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 2, 0)
+ uvm_put_user_pages_dirty(pages, size);
+#else
put_user_pages(pages, size);
+#endif
uvm_kvfree(pages);
}
@@ -281,7 +297,11 @@ fail:
uvm_kvfree(vmas);
if (ret > 0)
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 2, 0)
+ uvm_put_user_pages_dirty(*pages, ret);
+#else
put_user_pages(*pages, ret);
+#endif
else if (ret < 0)
status = errno_to_nv_status(ret);

@ -0,0 +1,53 @@
From 635b901ffad338c398a0e2570e990b0df66dd12f Mon Sep 17 00:00:00 2001
From: Tk-Glitch <ti3nou@gmail.com>
Date: Mon, 22 Jul 2019 13:29:48 +0200
Subject: nvidia kernel 5.3 patch
diff --git a/kernel-dkms/common/inc/nv-linux.h b/kernel-dkms/common/inc/nv-linux.h
index 9341e676b..41289217e 100644
--- a/kernel-dkms/common/inc/nv-linux.h
+++ b/kernel-dkms/common/inc/nv-linux.h
@@ -475,7 +475,11 @@ extern int nv_pat_mode;
__cpuc_flush_kern_all();
}
#define CACHE_FLUSH() nv_flush_cache_cpu(NULL)
-#define CACHE_FLUSH_ALL() NV_ON_EACH_CPU(nv_flush_cache_cpu, NULL)
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 3, 0)
+#define CACHE_FLUSH_ALL() on_each_cpu(nv_flush_cache_cpu, NULL, 1)
+#else
+#define CACHE_FLUSH_ALL() NV_ON_EACH_CPU(nv_flush_cache_cpu, NULL)
+#endif
#if defined(NV_OUTER_FLUSH_ALL_PRESENT)
#define OUTER_FLUSH_ALL() outer_flush_all()
#endif
@@ -489,7 +493,11 @@ extern int nv_pat_mode;
flush_cache_all();
}
#define CACHE_FLUSH() nv_flush_cache_cpu(NULL)
-#define CACHE_FLUSH_ALL() NV_ON_EACH_CPU(nv_flush_cache_cpu, NULL)
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 3, 0)
+#define CACHE_FLUSH_ALL() on_each_cpu(nv_flush_cache_cpu, NULL, 1)
+#else
+#define CACHE_FLUSH_ALL() NV_ON_EACH_CPU(nv_flush_cache_cpu, NULL)
+#endif
#define WRITE_COMBINE_FLUSH() mb()
#endif
#elif defined(NVCPU_PPC64LE)
diff --git a/kernel-dkms/nvidia/nv_uvm_interface.c b/kernel-dkms/nvidia/nv_uvm_interface.c
index e96b04e0c..18d80b09f 100644
--- a/kernel-dkms/nvidia/nv_uvm_interface.c
+++ b/kernel-dkms/nvidia/nv_uvm_interface.c
@@ -988,7 +988,11 @@ void nvUvmInterfaceDeRegisterUvmOps(void)
// Note that since we dropped the lock, another set of callbacks could have
// already been registered. That's ok, since we just need to wait for old
// ones to finish.
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 3, 0)
+ on_each_cpu(flush_top_half, NULL, 1);
+#else
NV_ON_EACH_CPU(flush_top_half, NULL);
+#endif
}
EXPORT_SYMBOL(nvUvmInterfaceDeRegisterUvmOps);

@ -0,0 +1,110 @@
diff --git a/kernel-dkms/conftest.sh b/kernel-dkms/conftest.sh
index c9c2db3..a10463d 100755
--- a/kernel-dkms/conftest.sh
+++ b/kernel-dkms/conftest.sh
@@ -130,6 +130,7 @@ test_headers() {
FILES="$FILES linux/sched/signal.h"
FILES="$FILES linux/sched/task.h"
FILES="$FILES linux/sched/task_stack.h"
+ FILES="$FILES linux/reservation.h"
FILES="$FILES xen/ioemu.h"
FILES="$FILES linux/fence.h"
FILES="$FILES soc/tegra/chip-id.h"
@@ -2063,7 +2064,7 @@ compile_test() {
CODE="
#include <drm/drmP.h>
int conftest_drm_driver_has_gem_prime_res_obj(void) {
- return offsetof(struct drm_driver, gem_prime_res_obj);
+ //return offsetof(struct drm_driver, gem_prime_res_obj);
}"
compile_check_conftest "$CODE" "NV_DRM_DRIVER_HAS_GEM_PRIME_RES_OBJ" "" "types"
diff --git a/kernel-dkms/nvidia-drm/nvidia-dma-fence-helper.h b/kernel-dkms/nvidia-drm/nvidia-dma-fence-helper.h
index 0aa5a4f..f289636 100644
--- a/kernel-dkms/nvidia-drm/nvidia-dma-fence-helper.h
+++ b/kernel-dkms/nvidia-drm/nvidia-dma-fence-helper.h
@@ -40,7 +40,9 @@
#include <linux/dma-fence.h>
#endif
+#if defined(NV_LINUX_RESERVATION_H_PRESENT)
#include <linux/reservation.h>
+#endif
#if defined(NV_LINUX_FENCE_H_PRESENT)
typedef struct fence nv_dma_fence_t;
diff --git a/kernel-dkms/nvidia-drm/nvidia-drm-drv.c b/kernel-dkms/nvidia-drm/nvidia-drm-drv.c
index a66d3cc..b79330a 100644
--- a/kernel-dkms/nvidia-drm/nvidia-drm-drv.c
+++ b/kernel-dkms/nvidia-drm/nvidia-drm-drv.c
@@ -681,7 +681,7 @@ static struct drm_driver nv_drm_driver = {
.gem_prime_vunmap = nv_drm_gem_prime_vunmap,
#if defined(NV_DRM_DRIVER_HAS_GEM_PRIME_RES_OBJ)
- .gem_prime_res_obj = nv_drm_gem_prime_res_obj,
+ //.gem_prime_res_obj = nv_drm_gem_prime_res_obj,
#endif
#if defined(NV_DRM_DRIVER_HAS_SET_BUSID)
diff --git a/kernel-dkms/nvidia-drm/nvidia-drm-gem.c b/kernel-dkms/nvidia-drm/nvidia-drm-gem.c
index 7201ade..d58f4f0 100644
--- a/kernel-dkms/nvidia-drm/nvidia-drm-gem.c
+++ b/kernel-dkms/nvidia-drm/nvidia-drm-gem.c
@@ -46,7 +46,7 @@ void nv_drm_gem_free(struct drm_gem_object *gem)
drm_gem_object_release(&nv_gem->base);
#if defined(NV_DRM_DRIVER_HAS_GEM_PRIME_RES_OBJ)
- reservation_object_fini(&nv_gem->resv);
+ dma_resv_fini(&nv_gem->resv);
#endif
nv_gem->ops->free(nv_gem);
@@ -113,12 +113,14 @@ void nv_drm_gem_prime_vunmap(struct drm_gem_object *gem, void *address)
}
#if defined(NV_DRM_DRIVER_HAS_GEM_PRIME_RES_OBJ)
+/*
struct reservation_object* nv_drm_gem_prime_res_obj(struct drm_gem_object *obj)
{
struct nv_drm_gem_object *nv_gem = to_nv_gem_object(obj);
return &nv_gem->resv;
}
+*/
#endif
#endif /* NV_DRM_AVAILABLE */
diff --git a/kernel-dkms/nvidia-drm/nvidia-drm-gem.h b/kernel-dkms/nvidia-drm/nvidia-drm-gem.h
index b621969..e671795 100644
--- a/kernel-dkms/nvidia-drm/nvidia-drm-gem.h
+++ b/kernel-dkms/nvidia-drm/nvidia-drm-gem.h
@@ -56,7 +56,7 @@ struct nv_drm_gem_object {
const struct nv_drm_gem_object_funcs *ops;
#if defined(NV_DRM_DRIVER_HAS_GEM_PRIME_RES_OBJ)
- struct reservation_object resv;
+ struct dma_resv resv;
#endif
};
@@ -127,7 +127,7 @@ void nv_drm_gem_object_init(struct nv_drm_device *nv_dev,
drm_gem_private_object_init(dev, &nv_gem->base, size);
#if defined(NV_DRM_DRIVER_HAS_GEM_PRIME_RES_OBJ)
- reservation_object_init(&nv_gem->resv);
+ dma_resv_init(&nv_gem->resv);
#endif
}
diff --git a/kernel-dkms/nvidia-drm/nvidia-drm-prime-fence.c b/kernel-dkms/nvidia-drm/nvidia-drm-prime-fence.c
index 1f10940..5114965 100644
--- a/kernel-dkms/nvidia-drm/nvidia-drm-prime-fence.c
+++ b/kernel-dkms/nvidia-drm/nvidia-drm-prime-fence.c
@@ -518,7 +518,7 @@ int nv_drm_gem_fence_attach_ioctl(struct drm_device *dev,
goto fence_context_create_fence_failed;
}
- reservation_object_add_excl_fence(&nv_gem->resv, fence);
+ dma_resv_add_excl_fence(&nv_gem->resv, fence);
ret = 0;

@ -0,0 +1,13 @@
diff --git a/kernel-dkms/conftest.sh b/kernel-dkms/conftest.sh
index c00c826..40c54f6 100755
--- a/kernel-dkms/conftest.sh
+++ b/kernel-dkms/conftest.sh
@@ -3585,7 +3585,7 @@ case "$5" in
TAB=' '
if [ -f "$OUTPUT/Module.symvers" ] && \
- grep -e "^[^${TAB}]*${TAB}[^${TAB}]*${TAB}vmlinux" \
+ grep -e "^[^${TAB}]*${TAB}[^${TAB}]*.*${TAB}vmlinux" \
"$OUTPUT/Module.symvers" >/dev/null 2>&1; then
exit 0
fi

@ -0,0 +1,51 @@
diff --git a/kernel-dkms/Kbuild b/kernel-dkms/Kbuild
index 1e79d0b..c587f7e 100644
--- a/kernel-dkms/Kbuild
+++ b/kernel-dkms/Kbuild
@@ -27,10 +27,17 @@
# $(2): The CFLAGS to add for those object files.
#
+ifeq ($(shell [ $(VERSION) -gt 5 ] || [ $(VERSION) -eq 5 -a $(PATCHLEVEL) -gt 3 ]; echo $$? ),0)
+ASSIGN_PER_OBJ_CFLAGS = \
+ $(foreach _cflags_variable, \
+ $(addprefix CFLAGS_,$(1)), \
+ $(eval $(_cflags_variable) += $(2)))
+else
ASSIGN_PER_OBJ_CFLAGS = \
$(foreach _cflags_variable, \
$(addprefix CFLAGS_,$(notdir $(1))), \
$(eval $(_cflags_variable) += $(2)))
+endif
#
diff --git a/kernel-dkms/conftest.sh b/kernel-dkms/conftest.sh
index c00c826..40c54f6 100755
--- a/kernel-dkms/conftest.sh
+++ b/kernel-dkms/conftest.sh
@@ -3585,7 +3585,7 @@ case "$5" in
TAB=' '
if [ -f "$OUTPUT/Module.symvers" ] && \
- grep -e "^[^${TAB}]*${TAB}[^${TAB}]*${TAB}vmlinux" \
+ grep -e "^[^${TAB}]*${TAB}[^${TAB}]*.*${TAB}vmlinux" \
"$OUTPUT/Module.symvers" >/dev/null 2>&1; then
exit 0
fi
diff --git a/kernel-dkms/nvidia-drm/nvidia-drm-drv.c b/kernel-dkms/nvidia-drm/nvidia-drm-drv.c
index bc31de7..7eefe95 100644
--- a/kernel-dkms/nvidia-drm/nvidia-drm-drv.c
+++ b/kernel-dkms/nvidia-drm/nvidia-drm-drv.c
@@ -659,7 +660,11 @@ static const struct drm_ioctl_desc nv_drm_ioctls[] = {
static struct drm_driver nv_drm_driver = {
+#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 4, 0)
.driver_features = DRIVER_GEM | DRIVER_PRIME | DRIVER_RENDER,
+#else
+ .driver_features = DRIVER_GEM | DRIVER_RENDER,
+#endif
.gem_free_object = nv_drm_gem_free,

@ -0,0 +1,380 @@
From 18e69d251b7fd3e19adc8a1dabd883641c585455 Mon Sep 17 00:00:00 2001
From: Tk-Glitch <ti3nou@gmail.com>
Date: Mon, 18 Dec 2019 14:11:36 +0100
Subject: Updated 5.5 patch, from Isaak I. Aleksandrov - https://gitlab.com/snippets/1923197
diff --git a/kernel-dkms/common/inc/nv-drm.h b/kernel-dkms/common/inc/nv-drm.h
new file mode 100644
index 0000000..07e9f3c
--- /dev/null
+++ b/kernel-dkms/common/inc/nv-drm.h
@@ -0,0 +1,36 @@
+#ifndef _NV_DRM_H_
+#define _NV_DRM_H_
+
+#include "conftest.h"
+
+#if defined(NV_DRM_DRMP_H_PRESENT)
+#include <drm/drmP.h>
+#else
+#include <linux/agp_backend.h>
+#include <linux/file.h>
+#include <linux/init.h>
+#include <linux/jiffies.h>
+#include <linux/kernel.h>
+#include <linux/mutex.h>
+#include <linux/slab.h>
+#include <linux/types.h>
+#include <asm/pgalloc.h>
+#include <linux/uaccess.h>
+
+#include <uapi/drm/drm.h>
+#include <uapi/drm/drm_mode.h>
+
+#include <drm/drm_agpsupport.h>
+#include <drm/drm_crtc.h>
+#include <drm/drm_drv.h>
+#include <drm/drm_prime.h>
+#include <drm/drm_pci.h>
+#include <drm/drm_ioctl.h>
+#include <drm/drm_sysfs.h>
+#include <drm/drm_vblank.h>
+#include <drm/drm_device.h>
+
+#include <drm/drm_gem.h>
+#endif
+
+#endif
diff --git a/kernel-dkms/conftest.sh b/kernel-dkms/conftest.sh
index c9c2db3..dd22bb0 100755
--- a/kernel-dkms/conftest.sh
+++ b/kernel-dkms/conftest.sh
@@ -1150,6 +1150,9 @@ compile_test() {
CODE="
#if defined(NV_DRM_DRMP_H_PRESENT)
#include <drm/drmP.h>
+ #else
+ #include <drm/drm_drv.h>
+ #include <drm/drm_prime.h>
#endif
#if !defined(CONFIG_DRM) && !defined(CONFIG_DRM_MODULE)
#error DRM not enabled
@@ -1781,6 +1784,8 @@ compile_test() {
echo "$CONFTEST_PREAMBLE
#if defined(NV_DRM_DRMP_H_PRESENT)
#include <drm/drmP.h>
+ #else
+ #include <drm/drm_drv.h>
#endif
#include <drm/drm_atomic.h>
#if !defined(CONFIG_DRM) && !defined(CONFIG_DRM_MODULE)
@@ -1909,7 +1914,11 @@ compile_test() {
# attached drivers") in v3.14 (2013-12-11)
#
CODE="
+ #if defined(NV_DRM_DRMP_H_PRESENT)
#include <drm/drmP.h>
+ #else
+ #include <drm/drm_drv.h>
+ #endif
int conftest_drm_driver_has_legacy_dev_list(void) {
return offsetof(struct drm_driver, legacy_dev_list);
}"
@@ -1933,7 +1942,11 @@ compile_test() {
# 2017-07-23 e6fc3b68558e4c6d8d160b5daf2511b99afa8814
#
CODE="
+ #if defined(NV_DRM_DRMP_H_PRESENT)
#include <drm/drmP.h>
+ #else
+ #include <drm/drm_crtc.h>
+ #endif
int conftest_drm_crtc_init_with_planes_has_name_arg(void) {
return
@@ -1949,7 +1962,11 @@ compile_test() {
compile_check_conftest "$CODE" "NV_DRM_CRTC_INIT_WITH_PLANES_HAS_NAME_ARG" "" "types"
CODE="
+ #if defined(NV_DRM_DRMP_H_PRESENT)
#include <drm/drmP.h>
+ #else
+ #include <drm/drm_encoder.h>
+ #endif
int conftest_drm_encoder_init_has_name_arg(void) {
return
@@ -1964,7 +1981,11 @@ compile_test() {
compile_check_conftest "$CODE" "NV_DRM_ENCODER_INIT_HAS_NAME_ARG" "" "types"
echo "$CONFTEST_PREAMBLE
+ #if defined(NV_DRM_DRMP_H_PRESENT)
#include <drm/drmP.h>
+ #else
+ #include <drm/drm_plane.h>
+ #endif
int conftest_drm_universal_plane_init_has_format_modifiers_arg(void) {
return
@@ -1991,7 +2012,11 @@ compile_test() {
echo "#undef NV_DRM_UNIVERSAL_PLANE_INIT_HAS_FORMAT_MODIFIERS_ARG" | append_conftest "types"
echo "$CONFTEST_PREAMBLE
+ #if defined(NV_DRM_DRMP_H_PRESENT)
#include <drm/drmP.h>
+ #else
+ #include <drm/drm_plane.h>
+ #endif
int conftest_drm_universal_plane_init_has_name_arg(void) {
return
@@ -3084,7 +3109,9 @@ compile_test() {
# drm_framebuffer_{get,put}()") in v4.12 (2017-02-28).
#
CODE="
+ #if defined(NV_DRM_DRMP_H_PRESENT)
#include <drm/drmP.h>
+ #endif
#if defined(NV_DRM_DRM_FRAMEBUFFER_H_PRESENT)
#include <drm/drm_framebuffer.h>
#endif
@@ -3103,7 +3130,9 @@ compile_test() {
# drm_gem_object_{get,put}()") in v4.12 (2017-02-28).
#
CODE="
+ #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
@@ -3122,7 +3151,9 @@ compile_test() {
# functions") in v4.15 (2017-09-26).
#
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
diff --git a/kernel-dkms/nvidia-drm/nvidia-drm-connector.c b/kernel-dkms/nvidia-drm/nvidia-drm-connector.c
index 1553ebc..f851561 100644
--- a/kernel-dkms/nvidia-drm/nvidia-drm-connector.c
+++ b/kernel-dkms/nvidia-drm/nvidia-drm-connector.c
@@ -71,7 +73,11 @@ static enum drm_connector_status __nv_drm_connector_detect_internal(
struct nv_drm_encoder *nv_detected_encoder = NULL;
struct NvKmsKapiDynamicDisplayParams *pDetectParams = NULL;
+#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 5, 0)
unsigned int i;
+#else
+ struct drm_encoder *encoder = NULL;
+#endif
BUG_ON(!mutex_is_locked(&dev->mode_config.mutex));
@@ -87,11 +93,16 @@ static enum drm_connector_status __nv_drm_connector_detect_internal(
goto done;
}
+#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 5, 0)
for (i = 0;
i < DRM_CONNECTOR_MAX_ENCODER && detected_encoder == NULL; i++) {
struct drm_encoder *encoder;
+#else
+ drm_connector_for_each_possible_encoder(connector, encoder) {
+#endif
struct nv_drm_encoder *nv_encoder;
+#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 5, 0)
if (connector->encoder_ids[i] == 0) {
break;
}
@@ -102,6 +113,7 @@ static enum drm_connector_status __nv_drm_connector_detect_internal(
BUG_ON(encoder != NULL);
continue;
}
+#endif
/*
* DVI-I connectors can drive both digital and analog
@@ -169,6 +181,8 @@ static enum drm_connector_status __nv_drm_connector_detect_internal(
}
detected_encoder = encoder;
+
+ break;
}
}
diff --git a/kernel-dkms/nvidia-drm/nvidia-drm-connector.h b/kernel-dkms/nvidia-drm/nvidia-drm-connector.h
index f74e22c..099390d 100644
--- a/kernel-dkms/nvidia-drm/nvidia-drm-connector.h
+++ b/kernel-dkms/nvidia-drm/nvidia-drm-connector.h
@@ -27,7 +27,7 @@
#if defined(NV_DRM_ATOMIC_MODESET_AVAILABLE)
-#include <drm/drmP.h>
+#include "nv-drm.h"
#include "nvtypes.h"
#include "nvkms-api-types.h"
diff --git a/kernel-dkms/nvidia-drm/nvidia-drm-crtc.h b/kernel-dkms/nvidia-drm/nvidia-drm-crtc.h
index 31ef3b5..5de3a51 100644
--- a/kernel-dkms/nvidia-drm/nvidia-drm-crtc.h
+++ b/kernel-dkms/nvidia-drm/nvidia-drm-crtc.h
@@ -29,7 +29,7 @@
#include "nvidia-drm-helper.h"
-#include <drm/drmP.h>
+#include "nv-drm.h"
#include "nvtypes.h"
#include "nvkms-kapi.h"
diff --git a/kernel-dkms/nvidia-drm/nvidia-drm-drv.c b/kernel-dkms/nvidia-drm/nvidia-drm-drv.c
index a66d3cc..06bf859 100644
--- a/kernel-dkms/nvidia-drm/nvidia-drm-drv.c
+++ b/kernel-dkms/nvidia-drm/nvidia-drm-drv.c
@@ -39,7 +39,7 @@
#include "nvidia-drm-ioctl.h"
-#include <drm/drmP.h>
+#include "nv-drm.h"
/*
* Commit fcd70cd36b9b ("drm: Split out drm_probe_helper.h")
diff --git a/kernel-dkms/nvidia-drm/nvidia-drm-encoder.h b/kernel-dkms/nvidia-drm/nvidia-drm-encoder.h
index bbaf986..af341a8 100644
--- a/kernel-dkms/nvidia-drm/nvidia-drm-encoder.h
+++ b/kernel-dkms/nvidia-drm/nvidia-drm-encoder.h
@@ -32,7 +32,7 @@
#if defined(NV_DRM_DRM_ENCODER_H_PRESENT)
#include <drm/drm_encoder.h>
#else
-#include <drm/drmP.h>
+#include "nv-drm.h"
#endif
#include "nvkms-kapi.h"
diff --git a/kernel-dkms/nvidia-drm/nvidia-drm-fb.h b/kernel-dkms/nvidia-drm/nvidia-drm-fb.h
index 7f292ce..d13bc4c 100644
--- a/kernel-dkms/nvidia-drm/nvidia-drm-fb.h
+++ b/kernel-dkms/nvidia-drm/nvidia-drm-fb.h
@@ -27,7 +27,7 @@
#if defined(NV_DRM_ATOMIC_MODESET_AVAILABLE)
-#include <drm/drmP.h>
+#include "nv-drm.h"
#include "nvidia-drm-gem-nvkms-memory.h"
#include "nvkms-kapi.h"
diff --git a/kernel-dkms/nvidia-drm/nvidia-drm-gem.h b/kernel-dkms/nvidia-drm/nvidia-drm-gem.h
index b621969..326f810 100644
--- a/kernel-dkms/nvidia-drm/nvidia-drm-gem.h
+++ b/kernel-dkms/nvidia-drm/nvidia-drm-gem.h
@@ -29,7 +29,7 @@
#include "nvidia-drm-priv.h"
-#include <drm/drmP.h>
+#include "nv-drm.h"
#include "nvkms-kapi.h"
#if defined(NV_DRM_DRIVER_HAS_GEM_PRIME_RES_OBJ)
diff --git a/kernel-dkms/nvidia-drm/nvidia-drm-helper.c b/kernel-dkms/nvidia-drm/nvidia-drm-helper.c
index da602ac..e5d6daa 100644
--- a/kernel-dkms/nvidia-drm/nvidia-drm-helper.c
+++ b/kernel-dkms/nvidia-drm/nvidia-drm-helper.c
@@ -31,7 +31,7 @@
#if defined(NV_DRM_ATOMIC_MODESET_AVAILABLE)
-#include <drm/drmP.h>
+#include "nv-drm.h"
#if defined(NV_DRM_DRM_ATOMIC_UAPI_H_PRESENT)
#include <drm/drm_atomic_uapi.h>
#endif
diff --git a/kernel-dkms/nvidia-drm/nvidia-drm-helper.h b/kernel-dkms/nvidia-drm/nvidia-drm-helper.h
index 8f050d8..71c4b90 100644
--- a/kernel-dkms/nvidia-drm/nvidia-drm-helper.h
+++ b/kernel-dkms/nvidia-drm/nvidia-drm-helper.h
@@ -27,7 +27,7 @@
#if defined(NV_DRM_AVAILABLE)
-#include <drm/drmP.h>
+#include "nv-drm.h"
/*
* drm_dev_put() is added by commit 9a96f55034e41b4e002b767e9218d55f03bdff7d
diff --git a/kernel-dkms/nvidia-drm/nvidia-drm-modeset.h b/kernel-dkms/nvidia-drm/nvidia-drm-modeset.h
index 06659c5..e9d7b70 100644
--- a/kernel-dkms/nvidia-drm/nvidia-drm-modeset.h
+++ b/kernel-dkms/nvidia-drm/nvidia-drm-modeset.h
@@ -27,7 +27,7 @@
#if defined(NV_DRM_ATOMIC_MODESET_AVAILABLE)
-#include <drm/drmP.h>
+#include "nv-drm.h"
struct drm_atomic_state *nv_drm_atomic_state_alloc(struct drm_device *dev);
void nv_drm_atomic_state_clear(struct drm_atomic_state *state);
diff --git a/kernel-dkms/nvidia-drm/nvidia-drm-os-interface.h b/kernel-dkms/nvidia-drm/nvidia-drm-os-interface.h
index f43f851..7f4ff8b 100644
--- a/kernel-dkms/nvidia-drm/nvidia-drm-os-interface.h
+++ b/kernel-dkms/nvidia-drm/nvidia-drm-os-interface.h
@@ -29,7 +29,7 @@
#if defined(NV_DRM_AVAILABLE)
-#include <drm/drmP.h>
+#include "nv-drm.h"
/* Set to true when the atomic modeset feature is enabled. */
extern bool nv_drm_modeset_module_param;
diff --git a/kernel-dkms/nvidia-drm/nvidia-drm-prime-fence.h b/kernel-dkms/nvidia-drm/nvidia-drm-prime-fence.h
index 20da923..f3cc2b4 100644
--- a/kernel-dkms/nvidia-drm/nvidia-drm-prime-fence.h
+++ b/kernel-dkms/nvidia-drm/nvidia-drm-prime-fence.h
@@ -27,7 +27,7 @@
#if defined(NV_DRM_AVAILABLE)
-#include <drm/drmP.h>
+#include "nv-drm.h"
#if defined(NV_DRM_DRIVER_HAS_GEM_PRIME_RES_OBJ)
diff --git a/kernel-dkms/nvidia-drm/nvidia-drm-priv.h b/kernel-dkms/nvidia-drm/nvidia-drm-priv.h
index 9076835..77a95f3 100644
--- a/kernel-dkms/nvidia-drm/nvidia-drm-priv.h
+++ b/kernel-dkms/nvidia-drm/nvidia-drm-priv.h
@@ -27,7 +27,7 @@
#if defined(NV_DRM_AVAILABLE)
-#include <drm/drmP.h>
+#include "nv-drm.h"
#if defined(NV_DRM_DRM_GEM_H_PRESENT)
#include <drm/drm_gem.h>
diff --git a/kernel-dkms/nvidia-drm/nvidia-drm-utils.h b/kernel-dkms/nvidia-drm/nvidia-drm-utils.h
index 6d24120..95190c4 100644
--- a/kernel-dkms/nvidia-drm/nvidia-drm-utils.h
+++ b/kernel-dkms/nvidia-drm/nvidia-drm-utils.h
@@ -27,7 +27,7 @@
#if defined(NV_DRM_ATOMIC_MODESET_AVAILABLE)
-#include <drm/drmP.h>
+#include "nv-drm.h"
#include "nvkms-kapi.h"
struct NvKmsKapiConnectorInfo*

@ -0,0 +1,405 @@
diff --git a/kernel-dkms/nvidia/nvidia.Kbuild b/kernel-dkms/nvidia/nvidia.Kbuild
index 5ec3e65..2897e31 100644
--- a/kernel-dkms/nvidia/nvidia.Kbuild
+++ b/kernel-dkms/nvidia/nvidia.Kbuild
@@ -150,6 +151,7 @@ NV_CONFTEST_SYMBOL_COMPILE_TESTS += is_export_symbol_present_swiotlb_dma_ops
NV_CONFTEST_TYPE_COMPILE_TESTS += acpi_op_remove
NV_CONFTEST_TYPE_COMPILE_TESTS += outer_flush_all
NV_CONFTEST_TYPE_COMPILE_TESTS += file_operations
+NV_CONFTEST_TYPE_COMPILE_TESTS += proc_ops
NV_CONFTEST_TYPE_COMPILE_TESTS += file_inode
NV_CONFTEST_TYPE_COMPILE_TESTS += kuid_t
NV_CONFTEST_TYPE_COMPILE_TESTS += dma_ops
diff --git a/kernel-dkms/common/inc/nv-procfs.h b/kernel-dkms/common/inc/nv-procfs.h
index 8b53f86..4c5aceb 100644
--- a/kernel-dkms/common/inc/nv-procfs.h
+++ b/kernel-dkms/common/inc/nv-procfs.h
@@ -28,6 +28,18 @@
#define IS_EXERCISE_ERROR_FORWARDING_ENABLED() (EXERCISE_ERROR_FORWARDING)
+#if defined(NV_HAVE_PROC_OPS)
+#define NV_CREATE_PROC_FILE(filename,parent,__name,__data) \
+ ({ \
+ struct proc_dir_entry *__entry; \
+ int mode = (S_IFREG | S_IRUGO); \
+ const struct proc_ops *fops = &nv_procfs_##__name##_fops; \
+ if (fops->proc_write != 0) \
+ mode |= S_IWUSR; \
+ __entry = proc_create_data(filename, mode, parent, fops, __data);\
+ __entry; \
+ })
+#else
#define NV_CREATE_PROC_FILE(filename,parent,__name,__data) \
({ \
struct proc_dir_entry *__entry; \
@@ -38,6 +50,7 @@
__entry = proc_create_data(filename, mode, parent, fops, __data);\
__entry; \
})
+#endif
/*
* proc_mkdir_mode exists in Linux 2.6.9, but isn't exported until Linux 3.0.
@@ -77,6 +90,44 @@
remove_proc_entry(entry->name, entry->parent);
#endif
+#if defined(NV_HAVE_PROC_OPS)
+#define NV_DEFINE_SINGLE_PROCFS_FILE(name, open_callback, close_callback) \
+ static int nv_procfs_open_##name( \
+ struct inode *inode, \
+ struct file *filep \
+ ) \
+ { \
+ int ret; \
+ ret = single_open(filep, nv_procfs_read_##name, \
+ NV_PDE_DATA(inode)); \
+ if (ret < 0) \
+ { \
+ return ret; \
+ } \
+ ret = open_callback(); \
+ if (ret < 0) \
+ { \
+ single_release(inode, filep); \
+ } \
+ return ret; \
+ } \
+ \
+ static int nv_procfs_release_##name( \
+ struct inode *inode, \
+ struct file *filep \
+ ) \
+ { \
+ close_callback(); \
+ return single_release(inode, filep); \
+ } \
+ \
+ static const struct proc_ops nv_procfs_##name##_fops = { \
+ .proc_open = nv_procfs_open_##name, \
+ .proc_read = seq_read, \
+ .proc_lseek = seq_lseek, \
+ .proc_release = nv_procfs_release_##name, \
+ };
+#else
#define NV_DEFINE_SINGLE_PROCFS_FILE(name, open_callback, close_callback) \
static int nv_procfs_open_##name( \
struct inode *inode, \
@@ -114,6 +165,7 @@
.llseek = seq_lseek, \
.release = nv_procfs_release_##name, \
};
+#endif
#endif /* CONFIG_PROC_FS */
diff --git a/kernel-dkms/conftest.sh b/kernel-dkms/conftest.sh
index 57d85a4..4902248 100755
--- a/kernel-dkms/conftest.sh
+++ b/kernel-dkms/conftest.sh
@@ -806,6 +822,16 @@ compile_test() {
compile_check_conftest "$CODE" "NV_FILE_OPERATIONS_HAS_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_alloc_table)
#
# sg_alloc_table_from_pages added by commit efc42bc98058
diff --git a/kernel-dkms/nvidia/nv-procfs.c b/kernel-dkms/nvidia/nv-procfs.c
index 064d727..a7308d3 100644
--- a/kernel-dkms/nvidia/nv-procfs.c
+++ b/kernel-dkms/nvidia/nv-procfs.c
@@ -452,6 +452,15 @@ done:
return ((status < 0) ? status : (int)count);
}
+#if defined(NV_HAVE_PROC_OPS)
+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,
@@ -460,6 +469,7 @@ static struct file_operations nv_procfs_registry_fops = {
.llseek = seq_lseek,
.release = nv_procfs_close_registry,
};
+#endif
#if defined(CONFIG_PM)
static int
@@ -531,6 +541,15 @@ nv_procfs_open_suspend_depth(
return single_open(file, nv_procfs_show_suspend_depth, NULL);
}
+#if defined(NV_HAVE_PROC_OPS)
+static struct proc_ops nv_procfs_suspend_depth_fops = {
+ .proc_open = nv_procfs_open_suspend_depth,
+ .proc_read = seq_read,
+ .proc_write = nv_procfs_write_suspend_depth,
+ .proc_lseek = seq_lseek,
+ .proc_release = single_release
+};
+#else
static struct file_operations nv_procfs_suspend_depth_fops = {
.owner = THIS_MODULE,
.open = nv_procfs_open_suspend_depth,
@@ -539,6 +558,7 @@ static struct file_operations nv_procfs_suspend_depth_fops = {
.llseek = seq_lseek,
.release = single_release
};
+#endif
static int
nv_procfs_show_suspend(
@@ -613,6 +633,15 @@ nv_procfs_open_suspend(
return single_open(file, nv_procfs_show_suspend, NULL);
}
+#if defined(NV_HAVE_PROC_OPS)
+static struct proc_ops nv_procfs_suspend_fops = {
+ .proc_open = nv_procfs_open_suspend,
+ .proc_read = seq_read,
+ .proc_write = nv_procfs_write_suspend,
+ .proc_lseek = seq_lseek,
+ .proc_release = single_release
+};
+#else
static struct file_operations nv_procfs_suspend_fops = {
.owner = THIS_MODULE,
.open = nv_procfs_open_suspend,
@@ -622,6 +651,7 @@ static struct file_operations nv_procfs_suspend_fops = {
.release = single_release
};
#endif
+#endif
/*
* Forwards error to nv_log_error which exposes data to vendor callback
@@ -724,12 +754,20 @@ done:
return status;
}
+#if defined(NV_HAVE_PROC_OPS)
+static struct proc_ops nv_procfs_exercise_error_forwarding_fops = {
+ .proc_open = nv_procfs_open_exercise_error_forwarding,
+ .proc_write = nv_procfs_write_file,
+ .proc_release = nv_procfs_close_exercise_error_forwarding,
+};
+#else
static struct file_operations nv_procfs_exercise_error_forwarding_fops = {
.owner = THIS_MODULE,
.open = nv_procfs_open_exercise_error_forwarding,
.write = nv_procfs_write_file,
.release = nv_procfs_close_exercise_error_forwarding,
};
+#endif
static int
nv_procfs_read_unbind_lock(
@@ -851,6 +889,15 @@ done:
return rc;
}
+#if defined(NV_HAVE_PROC_OPS)
+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,
@@ -859,6 +906,7 @@ static struct file_operations nv_procfs_unbind_lock_fops = {
.llseek = seq_lseek,
.release = nv_procfs_close_unbind_lock,
};
+#endif
static const char*
numa_status_describe(nv_numa_status_t state)
@@ -1187,6 +1235,22 @@ done:
return retval;
}
+#if defined(NV_HAVE_PROC_OPS)
+static const struct proc_ops nv_procfs_numa_status_fops = {
+ .proc_open = nv_procfs_open_numa_status,
+ .proc_read = seq_read,
+ .proc_write = nv_procfs_write_file,
+ .proc_lseek = seq_lseek,
+ .proc_release = nv_procfs_close_numa_status,
+};
+
+static const struct proc_ops nv_procfs_offline_pages_fops = {
+ .proc_open = nv_procfs_open_offline_pages,
+ .proc_read = seq_read,
+ .proc_lseek = seq_lseek,
+ .proc_release = nv_procfs_close_offline_pages,
+};
+#else
static const struct file_operations nv_procfs_numa_status_fops = {
.owner = THIS_MODULE,
.open = nv_procfs_open_numa_status,
@@ -1203,6 +1267,7 @@ static const struct file_operations nv_procfs_offline_pages_fops = {
.llseek = seq_lseek,
.release = nv_procfs_close_offline_pages,
};
+#endif
static int
nv_procfs_read_text_file(
diff --git a/kernel-dkms/nvidia/os-interface.c b/kernel-dkms/nvidia/os-interface.c
index 07f1b77..a8f1d85 100644
--- a/kernel-dkms/nvidia/os-interface.c
+++ b/kernel-dkms/nvidia/os-interface.c
@@ -477,9 +477,15 @@ NV_STATUS NV_API_CALL os_get_current_time(
void NV_API_CALL os_get_current_tick(NvU64 *nseconds)
{
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 6, 0)
+ struct timespec64 ts;
+
+ jiffies_to_timespec64(jiffies, &ts);
+#else
struct timespec ts;
jiffies_to_timespec(jiffies, &ts);
+#endif
*nseconds = ((NvU64)ts.tv_sec * NSEC_PER_SEC + (NvU64)ts.tv_nsec);
}
diff --git a/kernel-dkms/common/inc/56rc3uglyhack.h b/kernel-dkms/common/inc/56rc3uglyhack.h
new file mode 100644
index 0000000..389d02f
--- /dev/null
+++ b/kernel-dkms/common/inc/56rc3uglyhack.h
@@ -0,0 +1,80 @@
+
+typedef __kernel_long_t __kernel_time_t;
+
+#ifndef _STRUCT_TIMESPEC
+#define _STRUCT_TIMESPEC
+struct timespec {
+ __kernel_old_time_t tv_sec; /* seconds */
+ long tv_nsec; /* nanoseconds */
+};
+#endif
+
+struct timeval {
+ __kernel_old_time_t tv_sec; /* seconds */
+ __kernel_suseconds_t tv_usec; /* microseconds */
+};
+
+struct itimerspec {
+ struct timespec it_interval;/* timer period */
+ struct timespec it_value; /* timer expiration */
+};
+
+struct itimerval {
+ struct timeval it_interval;/* timer interval */
+ struct timeval it_value; /* current value */
+};
+
+#if __BITS_PER_LONG == 64
+
+/* timespec64 is defined as timespec here */
+static inline struct timespec timespec64_to_timespec(const struct timespec64 ts64)
+{
+ return *(const struct timespec *)&ts64;
+}
+
+static inline struct timespec64 timespec_to_timespec64(const struct timespec ts)
+{
+ return *(const struct timespec64 *)&ts;
+}
+
+#else
+static inline struct timespec timespec64_to_timespec(const struct timespec64 ts64)
+{
+ struct timespec ret;
+
+ ret.tv_sec = (time_t)ts64.tv_sec;
+ ret.tv_nsec = ts64.tv_nsec;
+ return ret;
+}
+
+static inline struct timespec64 timespec_to_timespec64(const struct timespec ts)
+{
+ struct timespec64 ret;
+
+ ret.tv_sec = ts.tv_sec;
+ ret.tv_nsec = ts.tv_nsec;
+ return ret;
+}
+#endif
+
+static inline void getnstimeofday(struct timespec *ts)
+{
+ struct timespec64 ts64;
+
+ ktime_get_real_ts64(&ts64);
+ *ts = timespec64_to_timespec(ts64);
+}
+
+static inline s64 timespec_to_ns(const struct timespec *ts)
+{
+ return ((s64) ts->tv_sec * NSEC_PER_SEC) + ts->tv_nsec;
+}
+
+static inline void getrawmonotonic(struct timespec *ts)
+{
+ struct timespec64 ts64;
+
+ ktime_get_raw_ts64(&ts64);
+ *ts = timespec64_to_timespec(ts64);
+}
+
diff --git a/kernel-dkms/common/inc/nv-time.h b/kernel-dkms/common/inc/nv-time.h
index 968b873..165f18b 100644
--- a/kernel-dkms/common/inc/nv-time.h
+++ b/kernel-dkms/common/inc/nv-time.h
@@ -27,6 +27,10 @@
#include <linux/ktime.h>
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 6, 0)
+#include "56rc3uglyhack.h"
+#endif
+
static inline void nv_gettimeofday(struct timeval *tv)
{
#ifdef NV_DO_GETTIMEOFDAY_PRESENT
diff --git a/kernel-dkms/nvidia/linux_nvswitch.c b/kernel-dkms/nvidia/linux_nvswitch.c
index 1d2c1bc..388d64f 100644
--- a/kernel-dkms/nvidia/linux_nvswitch.c
+++ b/kernel-dkms/nvidia/linux_nvswitch.c
@@ -26,6 +26,9 @@
#include "conftest.h"
#include "nvmisc.h"
#include "nv-linux.h"
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 6, 0)
+#include "nv-time.h"
+#endif
#include "nv-procfs.h"
#include "nvlink_common.h"
#include "nvlink_errors.h"

@ -0,0 +1,166 @@
diff --git a/kernel-dkms/nvidia-drm/nvidia-drm-gem-nvkms-memory.c b/kernel-dkms/nvidia-drm/nvidia-drm-gem-nvkms-memory.c
index 1db7777..863bb77 100644
--- a/kernel-dkms/nvidia-drm/nvidia-drm-gem-nvkms-memory.c
+++ b/kernel-dkms/nvidia-drm/nvidia-drm-gem-nvkms-memory.c
@@ -20,6 +20,8 @@
* DEALINGS IN THE SOFTWARE.
*/
+#include <linux/version.h>
+
#include "nvidia-drm-conftest.h"
#if defined(NV_DRM_ATOMIC_MODESET_AVAILABLE)
diff --git a/kernel-dkms/nvidia-drm/nvidia-drm-encoder.c b/kernel-dkms/nvidia-drm/nvidia-drm-encoder.c
index f66bbd7c9..4de87a271 100644
--- a/kernel-dkms/nvidia-drm/nvidia-drm-encoder.c
+++ b/kernel-dkms/nvidia-drm/nvidia-drm-encoder.c
@@ -20,6 +20,8 @@
* DEALINGS IN THE SOFTWARE.
*/
+#include <linux/version.h>
+
#include "nvidia-drm-conftest.h" /* NV_DRM_ATOMIC_MODESET_AVAILABLE */
#if defined(NV_DRM_ATOMIC_MODESET_AVAILABLE)
diff --git a/kernel-dkms/nvidia-drm/nvidia-drm-drv.c b/kernel-dkms/nvidia-drm/nvidia-drm-drv.c
index 58fd2724a..fc9169a96 100644
--- a/kernel-dkms/nvidia-drm/nvidia-drm-drv.c
+++ b/kernel-dkms/nvidia-drm/nvidia-drm-drv.c
@@ -20,6 +20,8 @@
* DEALINGS IN THE SOFTWARE.
*/
+#include <linux/version.h>
+
#include "nvidia-drm-conftest.h" /* NV_DRM_AVAILABLE and NV_DRM_DRM_GEM_H_PRESENT */
#include "nvidia-drm-priv.h"
diff --git a/kernel-dkms/nvidia-drm/nvidia-drm-connector.c b/kernel-dkms/nvidia-drm/nvidia-drm-connector.c
index 4dd12d112..44c9d8ed3 100644
--- a/kernel-dkms/nvidia-drm/nvidia-drm-connector.c
+++ b/kernel-dkms/nvidia-drm/nvidia-drm-connector.c
@@ -20,6 +20,8 @@
* DEALINGS IN THE SOFTWARE.
*/
+#include <linux/version.h>
+
#include "nvidia-drm-conftest.h" /* NV_DRM_ATOMIC_MODESET_AVAILABLE */
#if defined(NV_DRM_ATOMIC_MODESET_AVAILABLE)
diff --git a/kernel-dkms/common/inc/nv.h b/kernel-dkms/common/inc/nv.h
index d52c2a1ef..f6dc2dc32 100644
--- a/kernel-dkms/common/inc/nv.h
+++ b/kernel-dkms/common/inc/nv.h
@@ -18,6 +18,8 @@
#include <stdarg.h>
#include <nv-kernel-interface-api.h>
+#include <linux/version.h>
+
#if !defined(NV_MIN)
#define NV_MIN(_a,_b) ((_a) < (_b) ? (_a) : (_b))
#endif
diff --git a/kernel-dkms/nvidia-drm/nvidia-drm-gem.h b/kernel-dkms/nvidia-drm/nvidia-drm-gem.h
index f276588db..7cbdbe632 100644
--- a/kernel-dkms/nvidia-drm/nvidia-drm-gem.h
+++ b/kernel-dkms/nvidia-drm/nvidia-drm-gem.h
@@ -38,6 +38,8 @@
#endif
+#include <linux/version.h>
+
struct nv_drm_gem_object;
struct nv_drm_gem_object_funcs {
diff --git a/kernel-dkms/nvidia-drm/nvidia-drm-helper.c b/kernel-dkms/nvidia-drm/nvidia-drm-helper.c
index 4ccf81929..7fb59bbb3 100644
--- a/kernel-dkms/nvidia-drm/nvidia-drm-helper.c
+++ b/kernel-dkms/nvidia-drm/nvidia-drm-helper.c
@@ -29,6 +29,8 @@
#include "nvidia-drm-helper.h"
+#include <linux/version.h>
+
#if defined(NV_DRM_ATOMIC_MODESET_AVAILABLE)
#include <drm/drmP.h>
diff --git a/kernel-dkms/nvidia-drm/nvidia-drm-linux.c b/kernel-dkms/nvidia-drm/nvidia-drm-linux.c
index 5a2bbc18c..133d8fe64 100644
--- a/kernel-dkms/nvidia-drm/nvidia-drm-linux.c
+++ b/kernel-dkms/nvidia-drm/nvidia-drm-linux.c
@@ -20,6 +20,8 @@
* DEALINGS IN THE SOFTWARE.
*/
+#include <linux/version.h>
+
#include <linux/module.h>
#include <linux/slab.h>
#include <linux/err.h>
diff --git a/kernel-dkms/nvidia-uvm/uvm_linux.h b/kernel-dkms/nvidia-uvm/uvm_linux.h
index 8707ac070..990cefbd4 100644
--- a/kernel-dkms/nvidia-uvm/uvm_linux.h
+++ b/kernel-dkms/nvidia-uvm/uvm_linux.h
@@ -29,6 +29,8 @@
//
//
+#include <linux/version.h>
+
#ifndef _UVM_LINUX_H
#define _UVM_LINUX_H
diff --git a/kernel-dkms/nvidia/nvlink_linux.c b/kernel-dkms/nvidia/nvlink_linux.c
index c13b72515..db691679c 100644
--- a/kernel-dkms/nvidia/nvlink_linux.c
+++ b/kernel-dkms/nvidia/nvlink_linux.c
@@ -37,6 +37,8 @@
#include <linux/string.h>
#include <linux/mutex.h>
+#include <linux/version.h>
+
#define MAX_ERROR_STRING 512
#define NV_MAX_ISR_DELAY_US 20000
diff --git a/kernel-dkms/nvidia/os-interface.c b/kernel-dkms/nvidia/os-interface.c
index d1c889f69..88c57b2da 100644
--- a/kernel-dkms/nvidia/os-interface.c
+++ b/kernel-dkms/nvidia/os-interface.c
@@ -14,6 +14,8 @@
#include "os-interface.h"
#include "nv-linux.h"
+#include <linux/version.h>
+
#define MAX_ERROR_STRING 512
static char nv_error_string[MAX_ERROR_STRING];
nv_spinlock_t nv_error_string_lock;
diff --git a/kernel-dkms/nvidia-modeset/nvidia-modeset-linux.c b/kernel-dkms/nvidia-modeset/nvidia-modeset-linux.c
index 1b9148ee7..4c1bd3617 100644
--- a/kernel-dkms/nvidia-modeset/nvidia-modeset-linux.c
+++ b/kernel-dkms/nvidia-modeset/nvidia-modeset-linux.c
@@ -8,6 +8,8 @@
* _NVRM_COPYRIGHT_END_
*/
+#include <linux/version.h>
+
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/slab.h>

@ -0,0 +1,39 @@
From d42eed1eca8947a3c601a5e21c7820f0bba8550b Mon Sep 17 00:00:00 2001
From: Tk-Glitch <ti3nou@gmail.com>
Date: Wed, 3 Apr 2019 18:41:21 +0200
Subject: nvidia-fix-2
diff --git a/kernel-dkms/common/inc/nv-list-helpers.h b/kernel-dkms/common/inc/nv-list-helpers.h
index 2feaa1afd..0d66f00c8 100644
--- a/kernel-dkms/common/inc/nv-list-helpers.h
+++ b/kernel-dkms/common/inc/nv-list-helpers.h
@@ -23,6 +23,8 @@
#ifndef __NV_LIST_HELPERS_H__
#define __NV_LIST_HELPERS_H__
+#include <linux/version.h>
+
#include <linux/list.h>
#include "conftest.h"
diff --git a/kernel-dkms/nvidia-uvm/uvm8_range_tree.c b/kernel-dkms/nvidia-uvm/uvm8_range_tree.c
index b7170d03c..7d24b01f3 100644
--- a/kernel-dkms/nvidia-uvm/uvm8_range_tree.c
+++ b/kernel-dkms/nvidia-uvm/uvm8_range_tree.c
@@ -31,9 +31,15 @@ static uvm_range_tree_node_t *get_range_node(struct rb_node *rb_node)
uvm_range_tree_node_t *uvm_range_tree_prev(uvm_range_tree_t *tree, uvm_range_tree_node_t *node)
{
+#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 1, 0)
if (list_is_first(&node->list, &tree->head))
return NULL;
return list_prev_entry(node, list);
+#else
+ if (nv_list_is_first(&node->list, &tree->head))
+ return NULL;
+ return list_prev_entry(node, list);
+#endif
}
uvm_range_tree_node_t *uvm_range_tree_next(uvm_range_tree_t *tree, uvm_range_tree_node_t *node)

@ -0,0 +1,15 @@
Section "OutputClass"
Identifier "intel"
MatchDriver "i915"
Driver "modesetting"
EndSection
Section "OutputClass"
Identifier "nvidia"
MatchDriver "nvidia-drm"
Driver "nvidia"
Option "AllowEmptyInitialConfiguration"
Option "PrimaryGPU" "yes"
ModulePath "/usr/lib/nvidia/xorg"
ModulePath "/usr/lib/xorg/modules"
EndSection

@ -0,0 +1,4 @@
Section "Device"
Identifier "Default Nvidia Device"
Option "NoLogo" "True"
EndSection

@ -0,0 +1,20 @@
Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved.
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.

@ -0,0 +1,8 @@
prefix=/usr
datarootdir=${prefix}/share
pkgdatadir=${datarootdir}/wayland-eglstream
Name: wayland-eglstream-protocols
Description: Nvidia Wayland EGLStream XML protocol files
Version: 1.1.2

@ -0,0 +1,12 @@
prefix=/usr
exec_prefix=${prefix}
libdir=${exec_prefix}/lib
includedir=${prefix}/include
Name: wayland-eglstream
Description: Nvidia Wayland EGLStream compositor helper libraries
Version: 1.1.2
Cflags: -I${includedir}
Libs: -L${libdir} -lnvidia-egl-wayland
Requires: eglexternalplatform >= 1.1 eglexternalplatform < 2

@ -0,0 +1,87 @@
<?xml version="1.0" encoding="UTF-8"?>
<protocol name="wl_eglstream_controller">
<copyright>
Copyright (c) 2017-2018, NVIDIA CORPORATION. All rights reserved.
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.
</copyright>
<interface name="wl_eglstream_controller" version="2">
<!-- Present mode types. This enum defines what the present mode given
to a attach_eglstream_consumer_attribs request represents -->
<enum name="present_mode">
<description summary="Stream present mode">
- dont_care: Using this enum will tell the server to make its own
decisions regarding present mode.
- fifo: Tells the server to use a fifo present mode. The decision to
use fifo synchronous is left up to the server.
- mailbox: Tells the server to use a mailbox present mode.
</description>
<entry name="dont_care" value="0" summary="Let the Server decide present mode"/>
<entry name="fifo" value="1" summary="Use a fifo present mode"/>
<entry name="mailbox" value="2" summary="Use a mailbox mode"/>
</enum>
<enum name="attrib">
<description summary="Stream consumer attachment attributes">
- present_mode: Must be one of wl_eglstream_controller_present_mode. Tells the
server the desired present mode that should be used.
- fifo_length: Only valid when the present_mode attrib is provided and its
value is specified as fifo. Tells the server the desired fifo
length to be used when the desired present_mode is fifo.
</description>
<entry name="present_mode" value="0" summary="Tells the server the desired present mode"/>
<entry name="fifo_length" value="1" summary="Tells the server the desired fifo length when the desired presenation_mode is fifo."/>
</enum>
<request name="attach_eglstream_consumer" since="1">
<description summary="Create server stream and attach consumer">
Creates the corresponding server side EGLStream from the given wl_buffer
and attaches a consumer to it.
</description>
<arg name="wl_surface" type="object" interface="wl_surface"
summary="wl_surface corresponds to the client surface associated with
newly created eglstream"/>
<arg name="wl_resource" type="object" interface="wl_buffer"
summary="wl_resource corresponding to an EGLStream"/>
</request>
<request name="attach_eglstream_consumer_attribs" since="2">
<description summary="Create server stream and attach consumer using attributes">
Creates the corresponding server side EGLStream from the given wl_buffer
and attaches a consumer to it using the given attributes.
</description>
<arg name="wl_surface" type="object" interface="wl_surface"
summary="wl_surface corresponds to the client surface associated with
newly created eglstream"/>
<arg name="wl_resource" type="object" interface="wl_buffer"
summary="wl_resource corresponding to an EGLStream"/>
<arg name="attribs" type="array"
summary="Stream consumer attachment attribs">
<description summary="List of attributes with consumer attachment data">
It contains key-value pairs compatible with intptr_t type. A key must
be one of wl_eglstream_controller_attrib enumeration values. What a value
represents is attribute-specific.
</description>
</arg>
</request>
</interface>
</protocol>

@ -0,0 +1,161 @@
<?xml version="1.0" encoding="UTF-8"?>
<protocol name="stream">
<copyright>
Copyright (c) 2014-2016, NVIDIA CORPORATION. All rights reserved.
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.
</copyright>
<!-- wl_eglstream stub interface. Currently, this isn't actually used. Enums
must belong to an interface, and the name of it is prepended to the enum
values. This interface lets us define WL_EGLSTREAM_ERROR_*,
WL_EGLSTREAM_ATTRIB_* and WL_EGLSTREAM_HANDLE_TYPE_* enums -->
<interface name="wl_eglstream" version="1">
<enum name="error">
<entry name="bad_alloc" value="0" summary="Bad allocation error"/>
<entry name="bad_handle" value="1" summary="Bad handle error"/>
<entry name="bad_attribs" value="2" summary="Bad attributes error"/>
<entry name="bad_address" value="3" summary="Bad IP address error"/>
</enum>
<!-- wl_buffer handle types. This enum defines what the handle given to a
create_stream request represents -->
<enum name="handle_type">
<description summary="Stream handle type">
- fd: The given handle represents a file descriptor, and the
EGLStream connection must be done as described in
EGL_KHR_stream_cross_process_fd
- inet: The EGLStream connection must be done using an inet address
and port as described in EGL_NV_stream_socket. The given
handle can be ignored, but both inet address and port must
be given as attributes.
- socket: The given handle represents a unix socket, and the EGLStream
connection must be done as described in EGL_NV_stream_socket.
</description>
<entry name="fd" value="0" summary="File descriptor"/>
<entry name="inet" value="1" summary="Inet connection"/>
<entry name="socket" value="2" summary="Unix socket"/>
</enum>
<!-- EGLStream creation attributes. This enum defines possible attributes to
be passed to a create_stream request -->
<enum name="attrib">
<description summary="Stream creation attributes">
- inet_addr: The given attribute encodes an IPv4 address of a client
socket. Both IPv4 address and port must be set at the same
time.
- inet_port: The given attribute encodes a port of a client socket. Both
IPv4 address and port must be set at the same time.
</description>
<entry name="inet_addr" value="0" summary="Inet IPv4 address"/>
<entry name="inet_port" value="1" summary="IP port"/>
</enum>
</interface>
<!-- EGLStream support. This object is created by the server and published
using the display's global event. It represents the binding between an
EGL display and a wayland display -->
<interface name="wl_eglstream_display" version="1">
<!-- wl_eglstream_display capabilities. This enum defines a series of
capability flags that will be advertised by the server to all its
clients -->
<enum name="cap">
<description summary="wl_eglstream_display capability codes">
This enum values should be used as bit masks.
- stream_fd: The server supports EGLStream connections as described
in EGL_KHR_stream_cross_process_fd
- stream_inet: The server supports EGLStream inet connections as
described in EGL_NV_stream_socket.
- stream_socket: The server supports EGLStream unix socket connections
as described in EGL_NV_stream_socket.
</description>
<entry name="stream_fd" value="1" summary="Stream connection with FD"/>
<entry name="stream_inet" value="2" summary="Stream inet connection"/>
<entry name="stream_socket" value="4" summary="Stream unix connection"/>
</enum>
<!-- Advertise server capabilities as a bit mask. Clients might listen to
this event in order to know what features are supported by the server
-->
<event name="caps">
<description summary="Server capabilities event">
The capabilities event is sent out at wl_eglstream_display binding
time. It allows the server to advertise what features it supports so
clients may know what is safe to be used.
</description>
<arg name="caps" type="int" summary="Capabilities mask"/>
</event>
<event name="swapinterval_override">
<description summary="Server Swap interval override event">
The swapinterval_override event is sent out whenever a client requests
a swapinterval setting through swap_interval() and there is an override
in place that will make such request to be ignored.
The swapinterval_override event will provide the override value so
that the client is made aware of it.
</description>
<arg name="swapinterval" type="int"
summary="Server swap interval override value"/>
<arg name="stream" type="object" interface="wl_buffer"
summary="wl_buffer corresponding to an EGLStream"/>
</event>
<!-- Create a wl_buffer for the given handle. The attributes array may
define additional EGLStream connection data (e.g. inet address/port).
The server can use the wl_buffer to create the actual EGLStream handle
on its side and attach a consumer. -->
<request name="create_stream">
<description summary="Create a wl_buffer from the given handle">
Create a wl_buffer corresponding to given handle. The attributes list
may be used to define additional EGLStream connection data (e.g inet
address/port). The server can create its EGLStream handle using the
information encoded in the wl_buffer.
</description>
<arg name="id" type="new_id" interface="wl_buffer" summary="New ID"/>
<arg name="width" type="int" summary="Stream framebuffer width"/>
<arg name="height" type="int" summary="Stream framebuffer height"/>
<arg name="handle" type="fd" summary="Handle for the stream creation"/>
<arg name="type" type="int" summary="Handle type"/>
<arg name="attribs" type="array" summary="Stream extra connection attribs">
<description summary="List of attributes with extra connection data">
It contains key-value pairs compatible with intptr_t type. A key must
be one of wl_eglstream_display_attrib enumeration values. What a value
represents is attribute-specific.
</description>
</arg>
</request>
<request name="swap_interval">
<description summary="change the swap interval of an EGLStream consumer">
Set the swap interval for the consumer of the given EGLStream. The swap
interval is silently clamped to the valid range on the server side.
</description>
<arg name="stream" type="object" interface="wl_buffer"
summary="wl_buffer corresponding to an EGLStream"/>
<arg name="interval" type="int" summary="new swap interval"/>
</request>
</interface>
</protocol>

@ -0,0 +1,54 @@
_depmod() {
# Update module dependencies for all kernels
local -a _kernels
mapfile -t _kernels < <(find /usr/lib/modules/*/build/version -exec cat {} +)
for _kernel in "${_kernels[@]}"; do
depmod $_kernel
done
}
_rmmod() {
# Try unloading
if lsmod | grep -q nvidia; then
rmmod nvidia
fi
# What?
if [[ $? != 0 ]]; then
# X running?
if pidof Xorg >/dev/null; then
echo ":: Please reboot or exit X first."
fi
fi
}
post_install() {
_depmod
# X running?
if pidof Xorg >/dev/null; then
echo ":: Please reboot or exit X to unload the current module."
fi
echo ""
echo -e "\e[31m###########################################################\e[0m"
echo ""
echo -e "\e[31m It is recommended to run mkinitcpio -P after installation\e[0m"
echo ""
echo -e "\e[31m###########################################################\e[0m"
echo ""
}
post_upgrade() {
_depmod
# Not rebuilding?
if (( $(vercmp $1 $2) != 0 )); then
_rmmod
fi
}
post_remove() {
_depmod
_rmmod
}

@ -0,0 +1,14 @@
post_upgrade() {
echo ":: If CUDA is unavailable, run 'nvidia-modprobe'."
echo ""
echo -e "\e[31m###########################################################\e[0m"
echo ""
echo -e "\e[31m It is recommended to run mkinitcpio -P after installation\e[0m"
echo ""
echo -e "\e[31m###########################################################\e[0m"
echo ""
}
post_install() {
post_upgrade
}

@ -0,0 +1 @@
u nvidia-persistenced 143 'NVIDIA Persistence Daemon'
Loading…
Cancel
Save