340.107-90

This commit is contained in:
JerryXiao 2019-06-07 18:24:37 +08:00
commit 5a001f4f1d
Signed by: Jerry
GPG key ID: 9D9CE43650FF2BAA
5 changed files with 247 additions and 0 deletions

38
.SRCINFO Normal file
View file

@ -0,0 +1,38 @@
pkgbase = nvidia-340xx
pkgdesc = NVIDIA drivers for linux, 340xx legacy branch
pkgver = 340.107
pkgrel = 90
url = http://www.nvidia.com/
arch = x86_64
license = custom
makedepends = nvidia-340xx-utils=340.107
makedepends = linux
makedepends = linux-headers
conflicts = nvidia
options = !strip
source = http://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-5.0.patch
source = kernel-5.1.patch
sha512sums = 0de6f182d67bd322df7ae04e74c0cde6973c55bfea47a8f2503a29f8a899cd1b801ae4b52d066628df4a4f9c84e5e7547465bdc37d1b87df47af43fdab23466f
sha512sums = c25d90499e1deb26129a67dd7e953be8c1e31c5770e2b8b64d03af54cf1afec1a52636e74900f8ac468692207ab8a3765a12edd581142c4d2cfd2d6e66ac7ac2
sha512sums = ad60f9d09b6e8d5038375f9ddaab93341958f9400f40f5175857e44c7f7002d481121dc5d677703551c3cdf24069939ac6a1861920a455acf40e637f24234a56
sha512sums = 4bde7d15d68d21a8254e82cb41b07e55b3fd04054251919159dc440bf3253de76d7066e69b21c33d00d5ba61f88589b5444c2b5765c54cd1c0bcd7300971d499
pkgname = nvidia-340xx
pkgdesc = NVIDIA drivers for linux, 340xx legacy branch
depends = linux
depends = nvidia-340xx-utils=340.107
depends = libgl
pkgname = nvidia-340xx-dkms
pkgdesc = NVIDIA driver sources for linux, 340xx legacy branch
depends = dkms
depends = nvidia-340xx-utils=340.107
depends = libgl
optdepends = linux-headers: Build the module for Arch kernel
optdepends = linux-lts-headers: Build the module for LTS Arch kernel
provides = nvidia-340xx=340.107
conflicts = nvidia
conflicts = nvidia-340xx

76
PKGBUILD Normal file
View file

@ -0,0 +1,76 @@
# Maintainer: Giancarlo Razzolini <grazzolini@archlinux.org>
# Contributor: Felix Yan <felixonmars@archlinux.org>
# Contributor: Thomas Baechler <thomas@archlinux.org>
pkgbase=nvidia-340xx
pkgname=(nvidia-340xx nvidia-340xx-dkms)
pkgver=340.107
_extramodules=extramodules-ARCH
pkgrel=90
pkgdesc="NVIDIA drivers for linux, 340xx legacy branch"
arch=('x86_64')
url="http://www.nvidia.com/"
makedepends=("nvidia-340xx-utils=${pkgver}" 'linux' 'linux-headers')
conflicts=('nvidia')
license=('custom')
options=('!strip')
source=("http://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')
sha512sums=('0de6f182d67bd322df7ae04e74c0cde6973c55bfea47a8f2503a29f8a899cd1b801ae4b52d066628df4a4f9c84e5e7547465bdc37d1b87df47af43fdab23466f'
'c25d90499e1deb26129a67dd7e953be8c1e31c5770e2b8b64d03af54cf1afec1a52636e74900f8ac468692207ab8a3765a12edd581142c4d2cfd2d6e66ac7ac2'
'ad60f9d09b6e8d5038375f9ddaab93341958f9400f40f5175857e44c7f7002d481121dc5d677703551c3cdf24069939ac6a1861920a455acf40e637f24234a56'
'4bde7d15d68d21a8254e82cb41b07e55b3fd04054251919159dc440bf3253de76d7066e69b21c33d00d5ba61f88589b5444c2b5765c54cd1c0bcd7300971d499')
_pkg="NVIDIA-Linux-x86_64-${pkgver}-no-compat32"
prepare() {
sh "${_pkg}.run" --extract-only
cd "${_pkg}"
# patches here
patch -Np0 < "${srcdir}/kernel-4.11.patch"
patch -Np0 < "${srcdir}/kernel-5.0.patch"
patch -Np0 < "${srcdir}/kernel-5.1.patch"
cp -a kernel kernel-dkms
}
build() {
_kernver="$(cat /usr/lib/modules/${_extramodules}/version)"
cd "${_pkg}"/kernel
make SYSSRC=/usr/lib/modules/"${_kernver}/build" module
cd uvm
make SYSSRC=/usr/lib/modules/"${_kernver}/build" module
}
package_nvidia-340xx() {
pkgdesc="NVIDIA drivers for linux, 340xx legacy branch"
depends=('linux' "nvidia-340xx-utils=${pkgver}" 'libgl')
install -Dt "${pkgdir}/usr/lib/modules/${_extramodules}" -m644 \
"${srcdir}/${_pkg}/kernel"/{nvidia,uvm/nvidia-uvm}.ko
find "${pkgdir}" -name '*.ko' -exec gzip -n {} +
echo "blacklist nouveau" |
install -Dm644 /dev/stdin "${pkgdir}/usr/lib/modprobe.d/${pkgname}.conf"
}
package_nvidia-340xx-dkms() {
pkgdesc="NVIDIA driver sources for linux, 340xx legacy branch"
depends=('dkms' "nvidia-340xx-utils=$pkgver" 'libgl')
optdepends=('linux-headers: Build the module for Arch kernel'
'linux-lts-headers: Build the module for LTS Arch kernel')
provides=("nvidia-340xx=$pkgver")
conflicts+=('nvidia-340xx')
cd ${_pkg}
install -dm 755 "${pkgdir}"/usr/src
cp -dr --no-preserve='ownership' kernel-dkms "${pkgdir}/usr/src/nvidia-${pkgver}"
cat "${pkgdir}"/usr/src/nvidia-${pkgver}/uvm/dkms.conf.fragment >> "${pkgdir}"/usr/src/nvidia-${pkgver}/dkms.conf
echo "blacklist nouveau" |
install -Dm644 /dev/stdin "${pkgdir}/usr/lib/modprobe.d/${pkgname}.conf"
}

38
kernel-4.11.patch Normal file
View file

@ -0,0 +1,38 @@
--- kernel/uvm/nvidia_uvm_lite.c 2017-09-27 13:50:46.334075042 +0200
+++ kernel/uvm/nvidia_uvm_lite.c 2017-09-27 13:56:06.358041280 +0200
@@ -818,7 +818,11 @@
}
#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)
+#endif
{
#if defined(NV_VM_FAULT_HAS_ADDRESS)
unsigned long vaddr = vmf->address;
@@ -828,7 +832,11 @@
struct page *page = NULL;
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).
//
#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
+int _sigbus_fault(struct vm_fault *vmf)
+#endif
{
vmf->page = NULL;
return VM_FAULT_SIGBUS;

52
kernel-5.0.patch Normal file
View file

@ -0,0 +1,52 @@
--- kernel/nv-drm.c 2018-05-25 04:16:20.000000000 +0000
+++ kernel/nv-drm.c 2019-03-04 20:57:40.065280734 +0000
@@ -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;
--- kernel/os-interface.c 2018-05-25 04:16:20.000000000 +0000
+++ kernel/os-interface.c 2019-03-04 21:03:03.815854982 +0000
@@ -14,6 +14,16 @@
#include "os-interface.h"
#include "nv-linux.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)
{
NV_ACQUIRE_CONSOLE_SEM();
--- 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
@@ -30,6 +30,16 @@
#include "nvidia_uvm_lite_counters.h"
#include "ctrl2080mc.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
+
//
// nvidia_uvm_lite.c
// This file contains code that is specific to the UVM-Lite mode of operation.

43
kernel-5.1.patch Normal file
View file

@ -0,0 +1,43 @@
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,