Update to 340.107-94

This commit is contained in:
graysky 2019-12-03 14:53:58 -05:00
parent 616f549201
commit 3a9e967aea
8 changed files with 498 additions and 123 deletions

View file

@ -1,25 +1,27 @@
pkgbase = nvidia-340xx pkgbase = nvidia-340xx
pkgdesc = NVIDIA drivers for linux, 340xx legacy branch pkgdesc = NVIDIA drivers for linux, 340xx legacy branch
pkgver = 340.107 pkgver = 340.107
pkgrel = 93 pkgrel = 94
url = https://www.nvidia.com/ url = https://www.nvidia.com/
arch = x86_64 arch = x86_64
license = custom license = custom
makedepends = nvidia-340xx-utils=340.107 makedepends = nvidia-340xx-utils=340.107
makedepends = linux>=5.3.6 makedepends = linux>=5.4
makedepends = linux-headers>=5.3.6 makedepends = linux-headers>=5.4
conflicts = nvidia conflicts = nvidia
options = !strip options = !strip
source = https://us.download.nvidia.com/XFree86/Linux-x86_64/340.107/NVIDIA-Linux-x86_64-340.107-no-compat32.run source = https://us.download.nvidia.com/XFree86/Linux-x86_64/340.107/NVIDIA-Linux-x86_64-340.107-no-compat32.run
source = kernel-4.11.patch source = kernel-4.11.patch
source = kernel-5.0.patch source = kernel-5.0.patch
source = kernel-5.1.patch source = kernel-5.2.patch
source = kernel-5.3.patch source = kernel-5.3.patch
source = kernel-5.4.patch
sha256sums = 6dc6f183c69c414670d8adef0286a2362eedd6e16ec6dfae811e48ea4a4505dc sha256sums = 6dc6f183c69c414670d8adef0286a2362eedd6e16ec6dfae811e48ea4a4505dc
sha256sums = 5ba7e6d5e502882c3534d1d8578f7fd29fdf3d2aeb49206efa7b3514a7e3e821 sha256sums = 8bbb99a5be38520793b9898f7a82116595260bfe667708957fb0bdabaa570dfb
sha256sums = 236a1d1dc9adc1cafec828f0650d5a15f1f6d0fa27905dab58ca072a46f159fa sha256sums = b1e539b507dfbffda831de2c7145b62f9fc28e9df2c39cb7c22754e74057886e
sha256sums = 2b0e69814bfaee6b227bbf15d89d056ab27d84bd325248614e27cb5fa33a63a1 sha256sums = f5f28225a621484286b2830c777db82065ff299536e6c2c851e68c326d2d0b73
sha256sums = 4b1146a46b21c67cc70ade6aadd7292f1d1d838875e8be9f92dc656768db636c sha256sums = 5ebfdad300029d41c5bc2b8cca4d661abf8f0aa1de8c0f9e7e03de1580e6395e
sha256sums = 6bb80349d980b48a7fc62cec4d6f36b408b51263d461b4b9935fac729dd701b6
pkgname = nvidia-340xx pkgname = nvidia-340xx
pkgdesc = NVIDIA drivers for linux, 340xx legacy branch pkgdesc = NVIDIA drivers for linux, 340xx legacy branch

View file

@ -6,22 +6,25 @@
pkgbase=nvidia-340xx pkgbase=nvidia-340xx
pkgname=(nvidia-340xx nvidia-340xx-dkms) pkgname=(nvidia-340xx nvidia-340xx-dkms)
pkgver=340.107 pkgver=340.107
pkgrel=93 pkgrel=94
pkgdesc="NVIDIA drivers for linux, 340xx legacy branch" pkgdesc="NVIDIA drivers for linux, 340xx legacy branch"
arch=('x86_64') arch=('x86_64')
url="https://www.nvidia.com/" url="https://www.nvidia.com/"
makedepends=("nvidia-340xx-utils=${pkgver}" 'linux>=5.3.6' 'linux-headers>=5.3.6') makedepends=("nvidia-340xx-utils=${pkgver}" 'linux>=5.4' 'linux-headers>=5.4')
conflicts=('nvidia') conflicts=('nvidia')
license=('custom') license=('custom')
options=(!strip) options=(!strip)
# seems manjaro is keeping this current
# https://gitlab.manjaro.org/packages?utf8=%E2%9C%93&filter=nvidia-340xx
source=("https://us.download.nvidia.com/XFree86/Linux-x86_64/${pkgver}/NVIDIA-Linux-x86_64-${pkgver}-no-compat32.run" source=("https://us.download.nvidia.com/XFree86/Linux-x86_64/${pkgver}/NVIDIA-Linux-x86_64-${pkgver}-no-compat32.run"
'kernel-4.11.patch' 'kernel-5.0.patch' 'kernel-5.1.patch' 'kernel-5.3.patch' 'kernel-4.11.patch' 'kernel-5.0.patch' 'kernel-5.2.patch' 'kernel-5.3.patch' 'kernel-5.4.patch'
) )
sha256sums=('6dc6f183c69c414670d8adef0286a2362eedd6e16ec6dfae811e48ea4a4505dc' sha256sums=('6dc6f183c69c414670d8adef0286a2362eedd6e16ec6dfae811e48ea4a4505dc'
'5ba7e6d5e502882c3534d1d8578f7fd29fdf3d2aeb49206efa7b3514a7e3e821' '8bbb99a5be38520793b9898f7a82116595260bfe667708957fb0bdabaa570dfb'
'236a1d1dc9adc1cafec828f0650d5a15f1f6d0fa27905dab58ca072a46f159fa' 'b1e539b507dfbffda831de2c7145b62f9fc28e9df2c39cb7c22754e74057886e'
'2b0e69814bfaee6b227bbf15d89d056ab27d84bd325248614e27cb5fa33a63a1' 'f5f28225a621484286b2830c777db82065ff299536e6c2c851e68c326d2d0b73'
'4b1146a46b21c67cc70ade6aadd7292f1d1d838875e8be9f92dc656768db636c') '5ebfdad300029d41c5bc2b8cca4d661abf8f0aa1de8c0f9e7e03de1580e6395e'
'6bb80349d980b48a7fc62cec4d6f36b408b51263d461b4b9935fac729dd701b6')
_pkg="NVIDIA-Linux-x86_64-${pkgver}-no-compat32" _pkg="NVIDIA-Linux-x86_64-${pkgver}-no-compat32"
# default is 'linux' substitute custom name here # default is 'linux' substitute custom name here
@ -34,10 +37,13 @@ prepare() {
cd "${_pkg}" cd "${_pkg}"
# patches here # patches here
patch -Np0 < "${srcdir}/kernel-4.11.patch" local src
patch -Np0 < "${srcdir}/kernel-5.0.patch" for src in "${source[@]}"; do
patch -Np0 < "${srcdir}/kernel-5.1.patch" src="${src%%::*}"
patch -Np0 < "${srcdir}/kernel-5.3.patch" src="${src##*/}"
[[ $src = *.patch ]] || continue
(cd kernel ; patch -p1 --no-backup-if-mismatch -i "../../$src")
done
cp -a kernel kernel-dkms cp -a kernel kernel-dkms
} }

View file

@ -1,6 +1,18 @@
--- kernel/uvm/nvidia_uvm_lite.c 2017-09-27 13:50:46.334075042 +0200 From 53d65b3781b7b2cf25368efd5382ed5bbda19bd9 Mon Sep 17 00:00:00 2001
+++ kernel/uvm/nvidia_uvm_lite.c 2017-09-27 13:56:06.358041280 +0200 From: Alberto Milone <alberto.milone@canonical.com>
@@ -818,7 +818,11 @@ Date: Thu, 21 Sep 2017 15:16:41 +0200
Subject: [PATCH 1/1] Add support for Linux 4.11
This only contains the last few bits that didn't make it into
the 340 driver.
Credit goes to Michael Marley for spotting the problem.
---
uvm/nvidia_uvm_lite.c | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/uvm/nvidia_uvm_lite.c b/uvm/nvidia_uvm_lite.c
index 246ed04..119c93a 100644
--- a/uvm/nvidia_uvm_lite.c
+++ b/uvm/nvidia_uvm_lite.c
@@ -818,8 +818,15 @@ done:
} }
#if defined(NV_VM_OPERATIONS_STRUCT_HAS_FAULT) #if defined(NV_VM_OPERATIONS_STRUCT_HAS_FAULT)
@ -10,21 +22,13 @@
+int _fault(struct vm_fault *vmf) +int _fault(struct vm_fault *vmf)
+#endif +#endif
{ {
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0)
+ struct vm_area_struct *vma = vmf->vma;
+#endif
#if defined(NV_VM_FAULT_HAS_ADDRESS) #if defined(NV_VM_FAULT_HAS_ADDRESS)
unsigned long vaddr = vmf->address; unsigned long vaddr = vmf->address;
@@ -828,7 +832,11 @@ #else
struct page *page = NULL; @@ -866,7 +873,11 @@ static struct vm_operations_struct uvmlite_vma_ops =
int retval;
+#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 11, 0)
retval = _fault_common(vma, vaddr, &page, vmf->flags);
+#else
+ retval = _fault_common(NULL, vaddr, &page, vmf->flags);
+#endif
vmf->page = page;
@@ -866,7 +874,11 @@
// it's dealing with anonymous mapping (see handle_pte_fault). // it's dealing with anonymous mapping (see handle_pte_fault).
// //
#if defined(NV_VM_OPERATIONS_STRUCT_HAS_FAULT) #if defined(NV_VM_OPERATIONS_STRUCT_HAS_FAULT)
@ -36,3 +40,6 @@
{ {
vmf->page = NULL; vmf->page = NULL;
return VM_FAULT_SIGBUS; return VM_FAULT_SIGBUS;
--
2.7.4

View file

@ -1,52 +1,256 @@
--- kernel/nv-drm.c 2018-05-25 04:16:20.000000000 +0000 From 0b4e74ba61c50aefa16a4bafac3a60799eab7a20 Mon Sep 17 00:00:00 2001
+++ kernel/nv-drm.c 2019-03-04 20:57:40.065280734 +0000 From: Alberto Milone <alberto.milone@canonical.com>
@@ -252,7 +252,11 @@ Date: Fri, 15 Feb 2019 14:43:21 +0100
Subject: [PATCH 1/1] Add support for Linux 5.0
---
Makefile | 2 ++
conftest.sh | 33 +++++++++++++++++++++++++++++++++
nv-drm.c | 12 +++++++++++-
nv-time.h | 24 ++++++++++++++++++++++++
os-interface.c | 13 +++++++------
uvm/Makefile | 1 +
uvm/nvidia_uvm_linux.h | 1 +
uvm/nvidia_uvm_lite.c | 4 ++--
8 files changed, 81 insertions(+), 9 deletions(-)
create mode 100644 nv-time.h
diff --git a/Makefile b/Makefile
index 8ac3c1a..1959dce 100644
--- a/Makefile
+++ b/Makefile
@@ -147,6 +147,8 @@ COMPILE_TESTS = \
vm_fault_present \
vm_fault_has_address \
drm_driver_unload_has_int_return_type \
+ drm_gem_object_get \
+ do_gettimeofday \
drm_legacy_pci_init \
timer_setup
#
diff --git a/conftest.sh b/conftest.sh
index 64d75a1..fb0bf60 100755
--- a/conftest.sh
+++ b/conftest.sh
@@ -168,6 +168,7 @@ test_headers() {
FILES="$FILES linux/sched/task.h"
FILES="$FILES xen/ioemu.h"
FILES="$FILES linux/fence.h"
+ FILES="$FILES linux/ktime.h"
FILES_ARCH="$FILES_ARCH asm/set_memory.h"
@@ -1971,6 +1972,38 @@ compile_test() {
compile_check_conftest "$CODE" "NV_DRM_DRIVER_UNLOAD_HAS_INT_RETURN_TYPE" "" "types"
;;
+ drm_gem_object_get)
+ #
+ # Determine if the function drm_gem_object_get() is present.
+ #
+ CODE="
+ #include <drm/drmP.h>
+ #if defined(NV_DRM_DRM_GEM_H_PRESENT)
+ #include <drm/drm_gem.h>
+ #endif
+ void conftest_drm_gem_object_get(void) {
+ drm_gem_object_get();
+ }"
+
+ compile_check_conftest "$CODE" "NV_DRM_GEM_OBJECT_GET_PRESENT" "" "functions"
+ ;;
+
+ do_gettimeofday)
+ #
+ # Determine if the function do_gettimeofday() is present.
+ #
+ CODE="
+ #include <linux/time.h>
+ #if defined(NV_LINUX_KTIME_H_PRESENT)
+ #include <linux/ktime.h>
+ #endif
+ void conftest_do_gettimeofday(void) {
+ do_gettimeofday();
+ }"
+
+ compile_check_conftest "$CODE" "NV_DO_GETTIMEOFDAY_PRESENT" "" "functions"
+ ;;
+
drm_legacy_pci_init)
#
# Determine if drm_legacy_pci_init() is present. drm_pci_init() was
diff --git a/nv-drm.c b/nv-drm.c
index 0eb72e4..1c968de 100644
--- a/nv-drm.c
+++ b/nv-drm.c
@@ -37,6 +37,16 @@ struct nv_gem_object {
struct page **pages;
};
+static inline void
+nv_drm_gem_object_unreference_unlocked(struct nv_gem_object *nv_gem)
+{
+#if defined(NV_DRM_GEM_OBJECT_GET_PRESENT)
+ drm_gem_object_put_unlocked(&nv_gem->base);
+#else
+ drm_gem_object_unreference_unlocked(&nv_gem->base);
+#endif
+}
+
static int nv_drm_load(
struct drm_device *dev,
unsigned long flags
@@ -252,7 +262,7 @@ RM_STATUS NV_API_CALL nv_alloc_os_descriptor_handle(
goto done; goto done;
} }
+#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 0, 0) - drm_gem_object_unreference_unlocked(&nv_obj->base);
drm_gem_object_unreference_unlocked(&nv_obj->base); + nv_drm_gem_object_unreference_unlocked(nv_obj);
+#else
+ drm_gem_object_put_unlocked(&nv_obj->base);
+#endif
status = RM_OK; status = RM_OK;
--- kernel/os-interface.c 2018-05-25 04:16:20.000000000 +0000 diff --git a/nv-time.h b/nv-time.h
+++ kernel/os-interface.c 2019-03-04 21:03:03.815854982 +0000 new file mode 100644
@@ -14,6 +14,16 @@ index 0000000..cc828aa
--- /dev/null
+++ b/nv-time.h
@@ -0,0 +1,24 @@
+#ifndef __NV_TIME_H__
+#define __NV_TIME_H__
+
+#include "conftest.h"
+#include <linux/time.h>
+
+#if defined(NV_LINUX_KTIME_H_PRESENT)
+#include <linux/ktime.h>
+#endif
+
+static inline void nv_gettimeofday(struct timeval *tv)
+{
+#ifdef NV_DO_GETTIMEOFDAY_PRESENT
+ do_gettimeofday(tv);
+#else
+ struct timespec64 now;
+
+ ktime_get_real_ts64(&now);
+ tv->tv_sec = now.tv_sec;
+ tv->tv_usec = now.tv_nsec/1000;
+#endif
+}
+
+#endif
diff --git a/os-interface.c b/os-interface.c
index 7e3d362..7190b26 100644
--- a/os-interface.c
+++ b/os-interface.c
@@ -13,6 +13,7 @@
#include "os-interface.h" #include "os-interface.h"
#include "nv-linux.h" #include "nv-linux.h"
+#include "nv-time.h"
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 0, 0)
+static inline void do_gettimeofday(struct timeval *tv)
+{
+ struct timespec64 now;
+ ktime_get_real_ts64(&now);
+ tv->tv_sec = now.tv_sec;
+ tv->tv_usec = now.tv_nsec/1000;
+}
+#endif
+
RM_STATUS NV_API_CALL os_disable_console_access(void) RM_STATUS NV_API_CALL os_disable_console_access(void)
{ {
NV_ACQUIRE_CONSOLE_SEM(); @@ -440,7 +441,7 @@ RM_STATUS NV_API_CALL os_get_current_time(
--- kernel/uvm/nvidia_uvm_lite.c 2019-03-04 20:57:25.815255511 +0000 {
+++ kernel/uvm/nvidia_uvm_lite.c 2019-03-04 21:04:25.239333050 +0000 struct timeval tm;
@@ -30,6 +30,16 @@
#include "nvidia_uvm_lite_counters.h"
#include "ctrl2080mc.h"
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 0, 0) - do_gettimeofday(&tm);
+static inline void do_gettimeofday(struct timeval *tv) + nv_gettimeofday(&tm);
+{
+ struct timespec64 now; *seconds = tm.tv_sec;
+ ktime_get_real_ts64(&now); *useconds = tm.tv_usec;
+ tv->tv_sec = now.tv_sec; @@ -475,7 +476,7 @@ RM_STATUS NV_API_CALL os_delay_us(NvU32 MicroSeconds)
+ tv->tv_usec = now.tv_nsec/1000; #ifdef NV_CHECK_DELAY_ACCURACY
+} struct timeval tm1, tm2;
+#endif
+ - do_gettimeofday(&tm1);
+ nv_gettimeofday(&tm1);
#endif
if (in_irq() && (MicroSeconds > NV_MAX_ISR_DELAY_US))
@@ -490,7 +491,7 @@ RM_STATUS NV_API_CALL os_delay_us(NvU32 MicroSeconds)
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
@@ -518,7 +519,7 @@ RM_STATUS NV_API_CALL os_delay(NvU32 MilliSeconds)
struct timeval tm_start;
#endif
- do_gettimeofday(&tm_aux);
+ nv_gettimeofday(&tm_aux);
#ifdef NV_CHECK_DELAY_ACCURACY
tm_start = tm_aux;
#endif
@@ -552,7 +553,7 @@ RM_STATUS NV_API_CALL os_delay(NvU32 MilliSeconds)
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);
@@ -574,7 +575,7 @@ RM_STATUS NV_API_CALL os_delay(NvU32 MilliSeconds)
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);
diff --git a/uvm/Makefile b/uvm/Makefile
index 42ad927..5c7b466 100644
--- a/uvm/Makefile
+++ b/uvm/Makefile
@@ -171,6 +171,7 @@ COMPILE_TESTS = \
kbasename \
fatal_signal_pending \
kuid_t \
+ do_gettimeofday \
vm_fault_has_address
MODULE_NAME:= nvidia-uvm
diff --git a/uvm/nvidia_uvm_linux.h b/uvm/nvidia_uvm_linux.h
index 1625209..1edb620 100644
--- a/uvm/nvidia_uvm_linux.h
+++ b/uvm/nvidia_uvm_linux.h
@@ -146,6 +146,7 @@
#include <linux/interrupt.h> /* tasklets, interrupt helpers */
#include <linux/timer.h>
#include <linux/time.h> /* do_gettimeofday()*/
+#include "nv-time.h"
#include <asm/div64.h> /* do_div() */
#if defined(NV_ASM_SYSTEM_H_PRESENT)
diff --git a/uvm/nvidia_uvm_lite.c b/uvm/nvidia_uvm_lite.c
index 119c93a..33b8d4b 100644
--- a/uvm/nvidia_uvm_lite.c
+++ b/uvm/nvidia_uvm_lite.c
@@ -2019,7 +2019,7 @@ static RM_STATUS _check_ecc_errors(UvmGpuMigrationTracking *pMigTracker,
{
if (!!(rmInterruptSet) && !bEccIncomingError)
{
- do_gettimeofday(&eccErrorStartTime);
+ nv_gettimeofday(&eccErrorStartTime);
_set_timeout_in_usec(&eccErrorStartTime, &eccTimeout,
UVM_ECC_ERR_TIMEOUT_USEC);
@@ -2051,7 +2051,7 @@ static RM_STATUS _check_ecc_errors(UvmGpuMigrationTracking *pMigTracker,
// //
// nvidia_uvm_lite.c if (!!(rmInterruptSet) && (eccErrorStartTime.tv_usec != 0))
// This file contains code that is specific to the UVM-Lite mode of operation. {
- do_gettimeofday(&eccErrorCurrentTime);
+ nv_gettimeofday(&eccErrorCurrentTime);
if ((eccErrorCurrentTime.tv_sec > eccTimeout.tv_sec) ||
((eccErrorCurrentTime.tv_sec == eccTimeout.tv_sec) &&
(eccErrorCurrentTime.tv_usec >= eccTimeout.tv_usec)))
--
2.19.1

View file

@ -1,43 +0,0 @@
diff --git kernel/uvm/nvidia_uvm_lite.c kernel/uvm/nvidia_uvm_lite.c
index 65b9a4d..f5ea5d7 100644
--- kernel/uvm/nvidia_uvm_lite.c
+++ kernel/uvm/nvidia_uvm_lite.c
@@ -830,8 +830,10 @@ done:
#if defined(NV_VM_OPERATIONS_STRUCT_HAS_FAULT)
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 11, 0)
int _fault(struct vm_area_struct *vma, struct vm_fault *vmf)
-#else
-int _fault(struct vm_fault *vmf)
+#elif LINUX_VERSION_CODE < KERNEL_VERSION(5, 1, 0)
+int _fault(struct vm_fault *vmf)
+#else
+vm_fault_t _fault(struct vm_fault *vmf)
#endif
{
#if defined(NV_VM_FAULT_HAS_ADDRESS)
@@ -886,8 +888,10 @@ static struct vm_operations_struct uvmlite_vma_ops =
#if defined(NV_VM_OPERATIONS_STRUCT_HAS_FAULT)
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 11, 0)
int _sigbus_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
-#else
+#elif LINUX_VERSION_CODE < KERNEL_VERSION(5, 1, 0)
int _sigbus_fault(struct vm_fault *vmf)
+#else
+vm_fault_t _sigbus_fault(struct vm_fault *vmf)
#endif
{
vmf->page = NULL;
diff --git kernel/nv-drm.c kernel/nv-drm.c
index 122ba7d..1be5733 100644
--- kernel/nv-drm.c
+++ kernel/nv-drm.c
@@ -146,7 +146,7 @@ static const struct file_operations nv_drm_fops = {
};
static struct drm_driver nv_drm_driver = {
-#if defined(DRIVER_LEGACY)
+#if defined(DRIVER_LEGACY) || LINUX_VERSION_CODE >= KERNEL_VERSION(5, 1, 0)
.driver_features = DRIVER_GEM | DRIVER_PRIME | DRIVER_LEGACY,
#else
.driver_features = DRIVER_GEM | DRIVER_PRIME,

77
kernel-5.2.patch Normal file
View file

@ -0,0 +1,77 @@
From d48c28c8f690cd1b7f1a252f3a33c9b536096054 Mon Sep 17 00:00:00 2001
From: Alberto Milone <alberto.milone@canonical.com>
Date: Mon, 10 Jun 2019 13:08:10 +0200
Subject: [PATCH 1/1] Add support for Linux 5.2
V2: make sure to force DRIVER_LEGACY for Linux >= 5.1
---
nv-drm.c | 2 +-
uvm/nvidia_uvm_lite.c | 20 ++++++++++++++++++++
2 files changed, 21 insertions(+), 1 deletion(-)
diff --git a/nv-drm.c b/nv-drm.c
index 1c968de..76719bb 100644
--- a/nv-drm.c
+++ b/nv-drm.c
@@ -156,7 +156,7 @@ static const struct file_operations nv_drm_fops = {
};
static struct drm_driver nv_drm_driver = {
-#if defined(DRIVER_LEGACY)
+#if defined(DRIVER_LEGACY) || LINUX_VERSION_CODE >= KERNEL_VERSION(5, 1, 0)
.driver_features = DRIVER_GEM | DRIVER_PRIME | DRIVER_LEGACY,
#else
.driver_features = DRIVER_GEM | DRIVER_PRIME,
diff --git a/uvm/nvidia_uvm_lite.c b/uvm/nvidia_uvm_lite.c
index 33b8d4b..8dbe050 100644
--- a/uvm/nvidia_uvm_lite.c
+++ b/uvm/nvidia_uvm_lite.c
@@ -689,7 +689,11 @@ static UvmGpuMigrationTracking * _get_mig_tracker(UvmCommitRecord * pRecord)
// return SIGBUS.
// 3. Otherwise, map in a page from the cache, and allow access.
//
+#ifdef VM_FAULT_OOM
int _fault_common(struct vm_area_struct *vma, unsigned long vaddr,
+#else
+unsigned int _fault_common(struct vm_area_struct *vma, unsigned long vaddr,
+#endif
struct page **ppage, unsigned vmfFlags)
{
int retValue = VM_FAULT_SIGBUS;
@@ -819,9 +823,17 @@ done:
#if defined(NV_VM_OPERATIONS_STRUCT_HAS_FAULT)
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 11, 0)
+#ifdef VM_FAULT_OOM
int _fault(struct vm_area_struct *vma, struct vm_fault *vmf)
#else
+unsigned int _fault(struct vm_area_struct *vma, struct vm_fault *vmf)
+#endif
+#else
+#ifdef VM_FAULT_OOM
int _fault(struct vm_fault *vmf)
+#else
+unsigned int _fault(struct vm_fault *vmf)
+#endif
#endif
{
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0)
@@ -874,9 +886,17 @@ static struct vm_operations_struct uvmlite_vma_ops =
//
#if defined(NV_VM_OPERATIONS_STRUCT_HAS_FAULT)
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 11, 0)
+#ifdef VM_FAULT_OOM
int _sigbus_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
#else
+unsigned int _sigbus_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
+#endif
+#else
+#ifdef VM_FAULT_OOM
int _sigbus_fault(struct vm_fault *vmf)
+#else
+unsigned int _sigbus_fault(struct vm_fault *vmf)
+#endif
#endif
{
vmf->page = NULL;
--
2.20.1

View file

@ -1,7 +1,16 @@
diff --git kernel/nv-linux.h kernel/nv-linux.h From df6b6227e19b46cf23abca790570804872cbf87c Mon Sep 17 00:00:00 2001
From: Alberto Milone <alberto.milone@canonical.com>
Date: Tue, 13 Aug 2019 11:20:39 +0200
Subject: [PATCH 1/1] Add support for Linux 5.3
smp_call_function() and on_each_cpu() no longer have return values
as per commit caa759323c73676b3e48c8d9c86093c88b4aba97
---
nv-linux.h | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
diff --git a/nv-linux.h b/nv-linux.h
index 4043bf1..62f0874 100644 index 4043bf1..62f0874 100644
--- kernel/nv-linux.h --- a/nv-linux.h
+++ kernel/nv-linux.h +++ b/nv-linux.h
@@ -877,12 +877,21 @@ extern void *nv_stack_t_cache; @@ -877,12 +877,21 @@ extern void *nv_stack_t_cache;
__ret; \ __ret; \
}) })
@ -46,4 +55,6 @@ index 4043bf1..62f0874 100644
#error "NV_ON_EACH_CPU_ARGUMENT_COUNT value unrecognized!" #error "NV_ON_EACH_CPU_ARGUMENT_COUNT value unrecognized!"
#endif #endif
#elif defined(CONFIG_SMP) #elif defined(CONFIG_SMP)
--
2.20.1

111
kernel-5.4.patch Normal file
View file

@ -0,0 +1,111 @@
From f90c388c755a6bd9b72cb51c712a0ae686e0b377 Mon Sep 17 00:00:00 2001
From: Alberto Milone <alberto.milone@canonical.com>
Date: Wed, 27 Nov 2019 13:01:18 +0100
Subject: [PATCH 1/1] Add support for Linux 5.4
---
conftest.sh | 46 ++++++++++++++++++++++++++++++++++++++++
nv-drm.c | 9 +++++---
nvidia-modules-common.mk | 2 +-
3 files changed, 53 insertions(+), 4 deletions(-)
diff --git a/conftest.sh b/conftest.sh
index fb0bf60..babbb50 100755
--- a/conftest.sh
+++ b/conftest.sh
@@ -265,6 +265,23 @@ build_cflags() {
if [ -n "$BUILD_PARAMS" ]; then
CFLAGS="$CFLAGS -D$BUILD_PARAMS"
fi
+
+ # Check if gcc supports asm goto and set CC_HAVE_ASM_GOTO if it does.
+ # Older kernels perform this check and set this flag in Kbuild, and since
+ # conftest.sh runs outside of Kbuild it ends up building without this flag.
+ # Starting with commit e9666d10a5677a494260d60d1fa0b73cc7646eb3 this test
+ # is done within Kconfig, and the preprocessor flag is no longer needed.
+
+ GCC_GOTO_SH="$SOURCES/build/gcc-goto.sh"
+
+ if [ -f "$GCC_GOTO_SH" ]; then
+ # Newer versions of gcc-goto.sh don't print anything on success, but
+ # this is okay, since it's no longer necessary to set CC_HAVE_ASM_GOTO
+ # based on the output of those versions of gcc-goto.sh.
+ if [ `/bin/sh "$GCC_GOTO_SH" "$CC"` = "y" ]; then
+ CFLAGS="$CFLAGS -DCC_HAVE_ASM_GOTO"
+ fi
+ fi
}
CONFTEST_PREAMBLE="#include \"conftest.h\"
@@ -1521,6 +1538,35 @@ compile_test() {
compile_check_conftest "$CODE" "NV_DRM_AVAILABLE" "" "generic"
;;
+ drm_driver_prime_flag_present)
+ #
+ # Determine whether driver feature flag DRIVER_PRIME is present.
+ #
+ # The DRIVER_PRIME flag was added by commit 3248877ea179 (drm:
+ # base prime/dma-buf support (v5)) in v3.4 (2011-11-25) and is
+ # removed by commit 0424fdaf883a (drm/prime: Actually remove
+ # DRIVER_PRIME everywhere) on 2019-06-17.
+ #
+ # DRIVER_PRIME definition moved from drmP.h to drm_drv.h by
+ # commit 85e634bce01a (drm: Extract drm_drv.h) in v4.10
+ # (2016-11-14).
+ #
+ # DRIVER_PRIME define is changed to enum value by commit
+ # 0e2a933b02c9 (drm: Switch DRIVER_ flags to an enum) in v5.1
+ # (2019-01-29).
+ #
+ CODE="
+ #include <drm/drmP.h>
+ #if defined(NV_DRM_DRM_DRV_H_PRESENT)
+ #include <drm/drm_drv.h>
+ #endif
+ unsigned int drm_driver_prime_flag_present_conftest(void) {
+ return DRIVER_PRIME;
+ }"
+
+ compile_check_conftest "$CODE" "NV_DRM_DRIVER_PRIME_FLAG_PRESENT" "" "types"
+ ;;
+
proc_create_data)
#
# Determine if the proc_create_data() function is present.
diff --git a/nv-drm.c b/nv-drm.c
index 76719bb..12f7029 100644
--- a/nv-drm.c
+++ b/nv-drm.c
@@ -156,11 +156,14 @@ static const struct file_operations nv_drm_fops = {
};
static struct drm_driver nv_drm_driver = {
+ .driver_features =
+#if defined(NV_DRM_DRIVER_PRIME_FLAG_PRESENT)
+ DRIVER_PRIME |
+#endif
#if defined(DRIVER_LEGACY) || LINUX_VERSION_CODE >= KERNEL_VERSION(5, 1, 0)
- .driver_features = DRIVER_GEM | DRIVER_PRIME | DRIVER_LEGACY,
-#else
- .driver_features = DRIVER_GEM | DRIVER_PRIME,
+ DRIVER_LEGACY |
#endif
+ DRIVER_GEM,
.load = nv_drm_load,
.unload = nv_drm_unload,
.fops = &nv_drm_fops,
diff --git a/nvidia-modules-common.mk b/nvidia-modules-common.mk
index 8ac7058..7418005 100644
--- a/nvidia-modules-common.mk
+++ b/nvidia-modules-common.mk
@@ -180,7 +180,7 @@ ifndef NV_VERBOSE
endif
KBUILD_PARAMS += KBUILD_VERBOSE=$(NV_VERBOSE)
-KBUILD_PARAMS += -C $(KERNEL_SOURCES) SUBDIRS=$(PWD)
+KBUILD_PARAMS += -C $(KERNEL_SOURCES) M=$(PWD)
KBUILD_PARAMS += ARCH=$(ARCH)
#
--
2.20.1