Instantly share code, notes, and snippets.

Embed
What would you like to do?
nvidia-387.34 patched for Linux 4.15
diff -u -r NVIDIA-Linux-x86_64-387.22/kernel/nvidia-drm/nvidia-drm-connector.c NVIDIA-Linux-x86_64-387.22.patched/kernel/nvidia-drm/nvidia-drm-connector.c
--- a/nvidia-drm/nvidia-drm-connector.c 2017-10-26 09:29:25.000000000 +0200
+++ b/nvidia-drm/nvidia-drm-connector.c 2017-11-16 20:15:35.123121624 +0100
@@ -107,7 +107,7 @@
break;
}
- encoder = drm_encoder_find(dev, id);
+ encoder = drm_encoder_find(dev, NULL, id);
if (encoder == NULL)
{
diff -u -r NVIDIA-Linux-x86_64-387.22/kernel/nvidia-drm/nvidia-drm-crtc.c NVIDIA-Linux-x86_64-387.22.patched/kernel/nvidia-drm/nvidia-drm-crtc.c
--- a/nvidia-drm/nvidia-drm-crtc.c 2017-10-26 09:29:25.000000000 +0200
+++ b/nvidia-drm/nvidia-drm-crtc.c 2017-11-17 01:06:06.298997404 +0100
@@ -434,7 +434,7 @@
goto done;
}
- crtc = drm_crtc_find(dev, params->crtc_id);
+ crtc = drm_crtc_find(dev, NULL, params->crtc_id);
if (!crtc) {
NV_DRM_DEV_LOG_DEBUG(nv_dev, "Unknown CRTC ID %d\n", params->crtc_id);
ret = -ENOENT;
diff -u -r NVIDIA-Linux-x86_64-387.22/kernel/nvidia-drm/nvidia-drm-linux.c NVIDIA-Linux-x86_64-387.22.patched/kernel/nvidia-drm/nvidia-drm-linux.c
--- a/nvidia-drm/nvidia-drm-linux.c 2017-10-26 09:29:26.000000000 +0200
+++ b/nvidia-drm/nvidia-drm-linux.c 2017-11-14 01:47:40.815680166 +0100
@@ -185,7 +185,7 @@
module_exit(nv_linux_drm_exit);
#if defined(MODULE_LICENSE)
- MODULE_LICENSE("MIT");
+ MODULE_LICENSE("GPL");
#endif
#if defined(MODULE_INFO)
MODULE_INFO(supported, "external");
diff -u -r NVIDIA-Linux-x86_64-387.22/kernel/nvidia-drm/nvidia-drm-modeset.c NVIDIA-Linux-x86_64-387.22.patched/kernel/nvidia-drm/nvidia-drm-modeset.c
--- a/nvidia-drm/nvidia-drm-modeset.c 2017-10-26 09:29:25.000000000 +0200
+++ b/nvidia-drm/nvidia-drm-modeset.c 2017-11-17 01:16:51.188958966 +0100
@@ -252,7 +252,7 @@
/* Loops over all crtcs and fill head configuration for changes */
- for_each_crtc_in_state(state, crtc, crtc_state, i)
+ for_each_new_crtc_in_state(state, crtc, crtc_state, i)
{
struct nvidia_drm_crtc *nv_crtc;
struct NvKmsKapiHeadRequestedConfig *head_requested_config;
@@ -303,7 +303,7 @@
head_requested_config->flags.displaysChanged = NV_TRUE;
- for_each_connector_in_state(state, connector, connector_state, j) {
+ for_each_new_connector_in_state(state, connector, connector_state, j) {
if (connector_state->crtc != crtc) {
continue;
}
@@ -324,7 +324,7 @@
/* Loops over all planes and fill plane configuration for changes */
- for_each_plane_in_state(state, plane, plane_state, i)
+ for_each_new_plane_in_state(state, plane, plane_state, i)
{
struct NvKmsKapiHeadRequestedConfig *head_requested_config;
@@ -634,7 +634,7 @@
nvidia_drm_write_combine_flush();
}
- for_each_crtc_in_state(state, crtc, crtc_state, i) {
+ for_each_new_crtc_in_state(state, crtc, crtc_state, i) {
struct nvidia_drm_crtc *nv_crtc = DRM_CRTC_TO_NV_CRTC(crtc);
struct nv_drm_crtc_state *nv_crtc_state = to_nv_crtc_state(crtc->state);
struct nv_drm_flip *nv_flip = nv_crtc_state->nv_flip;
diff -u -r NVIDIA-Linux-x86_64-387.22/kernel/nvidia-uvm/uvm8_va_block.c NVIDIA-Linux-x86_64-387.22.patched/kernel/nvidia-uvm/uvm8_va_block.c
--- a/nvidia-uvm/uvm8_va_block.c 2017-10-26 09:29:23.000000000 +0200
+++ b/nvidia-uvm/uvm8_va_block.c 2017-11-14 01:43:56.176693556 +0100
@@ -36,6 +36,8 @@
#include "uvm8_perf_prefetch.h"
#include "uvm8_mem.h"
+#include <linux/sched/task_stack.h>
+
typedef enum
{
BLOCK_PTE_OP_MAP,
--- a/nvidia/nv.c 2017-11-25 07:14:29.000000000 -0600
+++ b/nvidia/nv.c 2017-11-27 00:09:01.948814571 -0600
@@ -320,7 +320,7 @@
#else
static irqreturn_t nvidia_isr (int, void *);
#endif
-static void nvidia_rc_timer (unsigned long);
+static void nvidia_rc_timer (struct timer_list *t);
static int nvidia_ctl_open (struct inode *, struct file *);
static int nvidia_ctl_close (struct inode *, struct file *);
@@ -2472,10 +2472,10 @@
static void
nvidia_rc_timer(
- unsigned long data
+ struct timer_list *t
)
{
- nv_linux_state_t *nvl = (nv_linux_state_t *) data;
+ nv_linux_state_t *nvl = from_timer(nvl, t, rc_timer);
nv_state_t *nv = NV_STATE_PTR(nvl);
nvidia_stack_t *sp = nvl->sp[NV_DEV_STACK_TIMER];
@@ -3386,9 +3386,7 @@
return -1;
nv_printf(NV_DBG_INFO, "NVRM: initializing rc timer\n");
- init_timer(&nvl->rc_timer);
- nvl->rc_timer.function = nvidia_rc_timer;
- nvl->rc_timer.data = (unsigned long) nvl;
+ timer_setup(&nvl->rc_timer, nvidia_rc_timer, 0);
nv->rc_timer_enabled = 1;
mod_timer(&nvl->rc_timer, jiffies + HZ); /* set our timeout for 1 second */
nv_printf(NV_DBG_INFO, "NVRM: rc timer initialized\n");
--- a/nvidia-modeset/nvidia-modeset-linux.c 2017-11-25 07:14:29.000000000 -0600
+++ b/nvidia-modeset/nvidia-modeset-linux.c 2017-11-27 00:19:36.006798982 -0600
@@ -566,9 +566,9 @@
WARN_ON(!ret);
}
-static void nvkms_timer_callback(unsigned long arg)
+static void nvkms_timer_callback(struct timer_list *t)
{
- struct nvkms_timer_t *timer = (struct nvkms_timer_t *) arg;
+ struct nvkms_timer_t *timer = from_timer(timer, t, kernel_timer);
/* In softirq context, so schedule nvkms_kthread_q_callback(). */
nvkms_queue_work(&nvkms_kthread_q, &timer->nv_kthread_q_item);
@@ -606,10 +606,8 @@
timer->kernel_timer_created = NV_FALSE;
nvkms_queue_work(&nvkms_kthread_q, &timer->nv_kthread_q_item);
} else {
- init_timer(&timer->kernel_timer);
+ timer_setup(&timer->kernel_timer, nvkms_timer_callback, 0);
timer->kernel_timer_created = NV_TRUE;
- timer->kernel_timer.function = nvkms_timer_callback;
- timer->kernel_timer.data = (unsigned long) timer;
mod_timer(&timer->kernel_timer, jiffies + NVKMS_USECS_TO_JIFFIES(usec));
}
spin_unlock_irqrestore(&nvkms_timers.lock, flags);
diff -u -r kernel/nvidia-drm/nvidia-drm-fence.c kernel-patched/nvidia-drm/nvidia-drm-fence.c
--- kernel/nvidia-drm/nvidia-drm-fence.c 2016-08-09 01:43:19.000000000 +0200
+++ kernel-patched/nvidia-drm/nvidia-drm-fence.c 2016-08-25 14:31:34.419655564 +0200
@@ -325,7 +325,7 @@
struct nvidia_drm_gem_object *nv_gem;
};
-static void nvidia_drm_gem_prime_soft_fence_event
+static void NVKMS_KAPI_CALL nvidia_drm_gem_prime_soft_fence_event
(
void *dataPtr,
NvU32 dataU32
# $Id$
# Maintainer: Sven-Hendrik Haase <sh@lutzhaase.com>
# Maintainer: Felix Yan <felixonmars@archlinux.org>
# Contributor: Thomas Baechler <thomas@archlinux.org>
pkgbase=nvidia
pkgname=(nvidia nvidia-dkms)
pkgver=387.34
_extramodules=extramodules-4.15-ARCH
pkgrel=23
pkgdesc="NVIDIA drivers for linux"
arch=('x86_64')
url="http://www.nvidia.com/"
makedepends=('nvidia-libgl' "nvidia-utils=${pkgver}" 'linux' 'linux-headers>=4.15' 'linux-headers<4.16')
license=('custom')
options=('!strip')
source=("http://us.download.nvidia.com/XFree86/Linux-x86_64/${pkgver}/NVIDIA-Linux-x86_64-${pkgver}-no-compat32.run"
'https://gist.githubusercontent.com/gavinhungry/f02cb60acc971b6709c462b334c01c38/raw/buildfix_kernel_4.15.patch.txt')
sha256sums=('d540908e76aeecb1f4a2812acf5ad37346934a6b7c8043c8b3ce230a48ceb440'
'1b30c568e67102185e5366df5f16fcb2b8cd8ce2f9109ddf393aae00f273d82d')
_pkg="NVIDIA-Linux-x86_64-${pkgver}-no-compat32"
prepare() {
sh "${_pkg}.run" --extract-only
cd "${_pkg}"/kernel
patch -p1 < "${srcdir}"/buildfix_kernel_4.15.patch.txt
cd "${srcdir}/${_pkg}"
cp -a kernel kernel-dkms
cd kernel-dkms
sed -i "s/__VERSION_STRING/${pkgver}/" dkms.conf
sed -i 's/__JOBS/`nproc`/' dkms.conf
sed -i 's/__DKMS_MODULES//' dkms.conf
sed -i '$iBUILT_MODULE_NAME[0]="nvidia"\
DEST_MODULE_LOCATION[0]="/kernel/drivers/video"\
BUILT_MODULE_NAME[1]="nvidia-uvm"\
DEST_MODULE_LOCATION[1]="/kernel/drivers/video"\
BUILT_MODULE_NAME[2]="nvidia-modeset"\
DEST_MODULE_LOCATION[2]="/kernel/drivers/video"\
BUILT_MODULE_NAME[3]="nvidia-drm"\
DEST_MODULE_LOCATION[3]="/kernel/drivers/video"' dkms.conf
# Gift for linux-rt guys
sed -i 's/NV_EXCLUDE_BUILD_MODULES/IGNORE_PREEMPT_RT_PRESENCE=1 NV_EXCLUDE_BUILD_MODULES/' dkms.conf
}
build() {
_kernver="$(cat /usr/lib/modules/${_extramodules}/version)"
cd "${_pkg}"/kernel
make SYSSRC=/usr/lib/modules/"${_kernver}/build" module
}
package_nvidia() {
pkgdesc="NVIDIA drivers for linux"
depends=('linux>=4.15' 'linux<4.16' "nvidia-utils=${pkgver}" 'libgl')
install -Dt "${pkgdir}/usr/lib/modules/${_extramodules}" -m644 \
"${srcdir}/${_pkg}/kernel"/nvidia{,-modeset,-drm,-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-dkms() {
pkgdesc="NVIDIA driver sources for linux"
depends=('dkms' "nvidia-utils=$pkgver" 'libgl')
optdepends=('linux-headers: Build the module for Arch kernel'
'linux-lts-headers: Build the module for LTS Arch kernel')
conflicts+=('nvidia')
cd ${_pkg}
install -dm 755 "${pkgdir}"/usr/src
cp -dr --no-preserve='ownership' kernel-dkms "${pkgdir}/usr/src/nvidia-${pkgver}"
echo "blacklist nouveau" |
install -Dm644 /dev/stdin "${pkgdir}/usr/lib/modprobe.d/nvidia.conf"
install -Dt "${pkgdir}/usr/share/licenses/${pkgname}" -m644 "${srcdir}/${_pkg}/LICENSE"
}
@gavinhungry

This comment has been minimized.

@gavinhungry

This comment has been minimized.

Owner

gavinhungry commented Feb 7, 2018

Diff from 390.25-4 PKGBUILD (the LICENSE removal was due to nvidia-utils previously handling the nvidia license - it could have been based on the 387.34-21 PKGBUILD instead):

--- PKGBUILD-390.25-4	2018-02-07 01:20:32.668743220 -0800
+++ PKGBUILD-387.34-23	2018-02-07 01:20:04.439379133 -0800
@@ -5,23 +5,27 @@
 
 pkgbase=nvidia
 pkgname=(nvidia nvidia-dkms)
-pkgver=390.25
+pkgver=387.34
 _extramodules=extramodules-4.15-ARCH
-pkgrel=4
+pkgrel=23
 pkgdesc="NVIDIA drivers for linux"
 arch=('x86_64')
 url="http://www.nvidia.com/"
 makedepends=('nvidia-libgl' "nvidia-utils=${pkgver}" 'linux' 'linux-headers>=4.15' 'linux-headers<4.16')
 license=('custom')
 options=('!strip')
-source=("http://us.download.nvidia.com/XFree86/Linux-x86_64/${pkgver}/NVIDIA-Linux-x86_64-${pkgver}-no-compat32.run")
-sha256sums=('02263bc81b66e68fc8224447b249f4f0ca4ae201c467e236d917be2fe187f3d6')
+source=("http://us.download.nvidia.com/XFree86/Linux-x86_64/${pkgver}/NVIDIA-Linux-x86_64-${pkgver}-no-compat32.run"
+        'https://gist.githubusercontent.com/gavinhungry/f02cb60acc971b6709c462b334c01c38/raw/buildfix_kernel_4.15.patch.txt')
+sha256sums=('d540908e76aeecb1f4a2812acf5ad37346934a6b7c8043c8b3ce230a48ceb440'
+            '1b30c568e67102185e5366df5f16fcb2b8cd8ce2f9109ddf393aae00f273d82d')
 
 _pkg="NVIDIA-Linux-x86_64-${pkgver}-no-compat32"
 
 prepare() {
     sh "${_pkg}.run" --extract-only
-    cd "${_pkg}"
+    cd "${_pkg}"/kernel
+    patch -p1 < "${srcdir}"/buildfix_kernel_4.15.patch.txt
+    cd "${srcdir}/${_pkg}"
 
     cp -a kernel kernel-dkms
     cd kernel-dkms
@@ -58,8 +62,6 @@
 
     echo "blacklist nouveau" |
     install -Dm644 /dev/stdin "${pkgdir}/usr/lib/modprobe.d/${pkgname}.conf"
-
-    install -Dt "${pkgdir}/usr/share/licenses/${pkgname}" -m644 "${srcdir}/${_pkg}/LICENSE"
 }
 
 package_nvidia-dkms() {
@gavinhungry

This comment has been minimized.

Owner

gavinhungry commented Feb 7, 2018

git clone https://gist.github.com/gavinhungry/f02cb60acc971b6709c462b334c01c38 nvidia-387.34
cd nvidia-387.34

curl -O https://archive.archlinux.org/packages/n/nvidia-utils/nvidia-utils-387.34-5-x86_64.pkg.tar.xz
extra-x86_64-build -c -- -I nvidia-utils-387.34-5-x86_64.pkg.tar.xz
@beac0n

This comment has been minimized.

beac0n commented Feb 10, 2018

script to build the patched package and install it:

taken from https://bbs.archlinux.org/viewtopic.php?pid=1766195#p1766195
and https://bbs.archlinux.org/viewtopic.php?pid=1766374#p1766374

@gavinhungry thank you very very much :)

git clone https://gist.github.com/gavinhungry/f02cb60acc971b6709c462b334c01c38 nvidia-387.34
cd nvidia-387.34

curl -O https://archive.archlinux.org/packages/n/nvidia-utils/nvidia-utils-387.34-5-x86_64.pkg.tar.xz
extra-x86_64-build -c -- -I nvidia-utils-387.34-5-x86_64.pkg.tar.xz

sudo pacman -U ./nvidia-387.34-23-x86_64.pkg.tar.xz nvidia-utils-387.34-5-x86_64.pkg.tar.xz

taken from https://bbs.archlinux.org/viewtopic.php?pid=1766160#p1766160

Modify "IgnorePkg" in "/etc/pacman.conf":

IgnorePkg = nvidia-utils nvidia
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment