--- /dev/null
+--- NVIDIA-Linux-x86_64-340.107-no-compat32/kernel/nv-drm.c~ 2018-05-25 06:16:20.000000000 +0200
++++ NVIDIA-Linux-x86_64-340.107-no-compat32/kernel/nv-drm.c 2019-03-10 19:24:36.332454128 +0100
+@@ -252,7 +252,11 @@
+ goto done;
+ }
+
++#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 0, 0)
+ drm_gem_object_unreference_unlocked(&nv_obj->base);
++#else
++ drm_gem_object_put_unlocked(&nv_obj->base);
++#endif
+
+ status = RM_OK;
+
+--- NVIDIA-Linux-x86_64-340.107-no-compat32/kernel/os-interface.c~ 2018-05-25 06:16:20.000000000 +0200
++++ NVIDIA-Linux-x86_64-340.107-no-compat32/kernel/os-interface.c 2019-03-10 19:27:08.183087615 +0100
+@@ -13,6 +13,7 @@
+
+ #include "os-interface.h"
+ #include "nv-linux.h"
++#include <linux/ktime.h>
+
+ RM_STATUS NV_API_CALL os_disable_console_access(void)
+ {
+@@ -433,6 +433,21 @@
+ * Name: osGetCurrentTime
+ *
+ *****************************************************************************/
++static inline void nv_gettimeofday(struct timeval *tv)
++{
++#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 0, 0)
++ do_gettimeofday(tv);
++#else
++ struct timespec64 now;
++
++ ktime_get_real_ts64(&now);
++
++ *tv = (struct timeval) {
++ .tv_sec = now.tv_sec,
++ .tv_usec = now.tv_nsec/1000,
++ };
++#endif
++}
+
+ RM_STATUS NV_API_CALL os_get_current_time(
+ NvU32 *seconds,
+@@ -441,7 +456,7 @@
+ {
+ struct timeval tm;
+
+- do_gettimeofday(&tm);
++ nv_gettimeofday(&tm);
+
+ *seconds = tm.tv_sec;
+ *useconds = tm.tv_usec;
+@@ -485,7 +491,7 @@
+ #ifdef NV_CHECK_DELAY_ACCURACY
+ struct timeval tm1, tm2;
+
+- do_gettimeofday(&tm1);
++ nv_gettimeofday(&tm1);
+ #endif
+
+ if (in_irq() && (MicroSeconds > NV_MAX_ISR_DELAY_US))
+@@ -500,7 +506,7 @@
+ udelay(usec);
+
+ #ifdef NV_CHECK_DELAY_ACCURACY
+- do_gettimeofday(&tm2);
++ nv_gettimeofday(&tm2);
+ nv_printf(NV_DBG_ERRORS, "NVRM: osDelayUs %d: 0x%x 0x%x\n",
+ MicroSeconds, tm2.tv_sec - tm1.tv_sec, tm2.tv_usec - tm1.tv_usec);
+ #endif
+@@ -528,7 +534,7 @@
+ struct timeval tm_start;
+ #endif
+
+- do_gettimeofday(&tm_aux);
++ nv_gettimeofday(&tm_aux);
+ #ifdef NV_CHECK_DELAY_ACCURACY
+ tm_start = tm_aux;
+ #endif
+@@ -562,7 +568,7 @@
+ do
+ {
+ schedule_timeout(jiffies);
+- do_gettimeofday(&tm_aux);
++ nv_gettimeofday(&tm_aux);
+ if (NV_TIMERCMP(&tm_aux, &tm_end, <))
+ {
+ NV_TIMERSUB(&tm_end, &tm_aux, &tm_aux);
+@@ -584,7 +590,7 @@
+ udelay(MicroSeconds);
+ }
+ #ifdef NV_CHECK_DELAY_ACCURACY
+- do_gettimeofday(&tm_aux);
++ nv_gettimeofday(&tm_aux);
+ timersub(&tm_aux, &tm_start, &tm_aux);
+ nv_printf(NV_DBG_ERRORS, "NVRM: osDelay %dmsec: %d.%06dsec\n",
+ MilliSeconds, tm_aux.tv_sec, tm_aux.tv_usec);