From 017ee6d79db1626927234f2b030839bc908bf9aa Mon Sep 17 00:00:00 2001
From: Matt Housh <jaeger@crux.nu>
Date: Fri, 13 Feb 2015 14:31:36 -0600
Subject: [PATCH] nvidia: added set_busid fix for kernels 3.18+, fixes FS#1139

---
 nvidia/.md5sum           |  1 +
 nvidia/Pkgfile           |  6 ++++--
 nvidia/nvidia-3.18.patch | 14 ++++++++++++++
 3 files changed, 19 insertions(+), 2 deletions(-)
 create mode 100644 nvidia/nvidia-3.18.patch

diff --git a/nvidia/.md5sum b/nvidia/.md5sum
index 9b91c57e8..12dfbe280 100644
--- a/nvidia/.md5sum
+++ b/nvidia/.md5sum
@@ -1,2 +1,3 @@
 4511024cc556d0c6e7c467b6789524e2  90-nvidia-uvm.rules
 9ca9f07f91361362f304ca8317ddd453  NVIDIA-Linux-x86_64-346.35-no-compat32.run
+07e8f8a60f3be17700de4451a2737ede  nvidia-3.18.patch
diff --git a/nvidia/Pkgfile b/nvidia/Pkgfile
index cbf635a46..1161b60f6 100644
--- a/nvidia/Pkgfile
+++ b/nvidia/Pkgfile
@@ -5,14 +5,16 @@
 
 name=nvidia
 version=346.35
-release=1
+release=2
 source=(http://us.download.nvidia.com/XFree86/Linux-x86_64/$version/NVIDIA-Linux-x86_64-$version-no-compat32.run \
-    90-nvidia-uvm.rules)
+    90-nvidia-uvm.rules $name-3.18.patch)
 
 build() {
     sh NVIDIA-Linux-x86_64-$version-no-compat32.run --extract-only
     cd NVIDIA-Linux-x86_64-$version-no-compat32
 
+    patch -p1 -i $SRC/$name-3.18.patch
+
     # libraries
     install -d $PKG/usr/lib/{tls,vdpau}
     install -m 0755 libGL.so.$version              $PKG/usr/lib
diff --git a/nvidia/nvidia-3.18.patch b/nvidia/nvidia-3.18.patch
new file mode 100644
index 000000000..814e86554
--- /dev/null
+++ b/nvidia/nvidia-3.18.patch
@@ -0,0 +1,14 @@
+diff -urN NVIDIA-Linux-x86_64-346.35-no-compat32.orig/kernel/nv-drm.c NVIDIA-Linux-x86_64-346.35-no-compat32/kernel/nv-drm.c
+--- NVIDIA-Linux-x86_64-346.35-no-compat32.orig/kernel/nv-drm.c	2015-01-10 22:30:46.000000000 -0600
++++ NVIDIA-Linux-x86_64-346.35-no-compat32/kernel/nv-drm.c	2015-02-13 14:26:12.880988829 -0600
+@@ -128,6 +128,10 @@
+     .gem_prime_vmap = nv_gem_prime_vmap,
+     .gem_prime_vunmap = nv_gem_prime_vunmap,
+ 
++    #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0)
++        .set_busid = drm_pci_set_busid,
++    #endif
++
+     .name = "nvidia-drm",
+     .desc = "NVIDIA DRM driver",
+     .date = "20130102",