Date: Wednesday, June 14, 2017 @ 17:08:50 Author: tpowa Revision: 298829
archrelease: copy trunk to testing-i686, testing-x86_64 Added: nvidia-304xx/repos/testing-i686/ nvidia-304xx/repos/testing-i686/PKGBUILD (from rev 298828, nvidia-304xx/trunk/PKGBUILD) nvidia-304xx/repos/testing-i686/disable-mtrr.patch (from rev 298828, nvidia-304xx/trunk/disable-mtrr.patch) nvidia-304xx/repos/testing-i686/drm-driver-legacy.patch (from rev 298828, nvidia-304xx/trunk/drm-driver-legacy.patch) nvidia-304xx/repos/testing-i686/kernel_4.10.patch (from rev 298828, nvidia-304xx/trunk/kernel_4.10.patch) nvidia-304xx/repos/testing-i686/kernel_4.11.patch (from rev 298828, nvidia-304xx/trunk/kernel_4.11.patch) nvidia-304xx/repos/testing-i686/nvidia-304xx.install (from rev 298828, nvidia-304xx/trunk/nvidia-304xx.install) nvidia-304xx/repos/testing-x86_64/ nvidia-304xx/repos/testing-x86_64/PKGBUILD (from rev 298828, nvidia-304xx/trunk/PKGBUILD) nvidia-304xx/repos/testing-x86_64/disable-mtrr.patch (from rev 298828, nvidia-304xx/trunk/disable-mtrr.patch) nvidia-304xx/repos/testing-x86_64/drm-driver-legacy.patch (from rev 298828, nvidia-304xx/trunk/drm-driver-legacy.patch) nvidia-304xx/repos/testing-x86_64/kernel_4.10.patch (from rev 298828, nvidia-304xx/trunk/kernel_4.10.patch) nvidia-304xx/repos/testing-x86_64/kernel_4.11.patch (from rev 298828, nvidia-304xx/trunk/kernel_4.11.patch) nvidia-304xx/repos/testing-x86_64/nvidia-304xx.install (from rev 298828, nvidia-304xx/trunk/nvidia-304xx.install) ----------------------------------------+ testing-i686/PKGBUILD | 81 +++++++++++++++++++++++ testing-i686/disable-mtrr.patch | 24 +++++++ testing-i686/drm-driver-legacy.patch | 20 +++++ testing-i686/kernel_4.10.patch | 105 +++++++++++++++++++++++++++++++ testing-i686/kernel_4.11.patch | 44 ++++++++++++ testing-i686/nvidia-304xx.install | 13 +++ testing-x86_64/PKGBUILD | 81 +++++++++++++++++++++++ testing-x86_64/disable-mtrr.patch | 24 +++++++ testing-x86_64/drm-driver-legacy.patch | 20 +++++ testing-x86_64/kernel_4.10.patch | 105 +++++++++++++++++++++++++++++++ testing-x86_64/kernel_4.11.patch | 44 ++++++++++++ testing-x86_64/nvidia-304xx.install | 13 +++ 12 files changed, 574 insertions(+) Copied: nvidia-304xx/repos/testing-i686/PKGBUILD (from rev 298828, nvidia-304xx/trunk/PKGBUILD) =================================================================== --- testing-i686/PKGBUILD (rev 0) +++ testing-i686/PKGBUILD 2017-06-14 17:08:50 UTC (rev 298829) @@ -0,0 +1,81 @@ +# $Id$ +# Maintainer: Felix Yan <felixonm...@archlinux.org> +# Contributor: Thomas Baechler <tho...@archlinux.org> + +pkgbase=nvidia-304xx +pkgname=(nvidia-304xx nvidia-304xx-dkms) +pkgver=304.135 +_extramodules=extramodules-4.11-ARCH +pkgrel=6 +arch=('i686' 'x86_64') +url="http://www.nvidia.com/" +makedepends=('linux' 'linux-headers>=4.11' 'linux-headers<4.12') +conflicts=('nvidia') +license=('custom') +options=('!strip') +source=('disable-mtrr.patch' + 'drm-driver-legacy.patch' + 'kernel_4.10.patch' + 'kernel_4.11.patch') +source_i686+=("http://us.download.nvidia.com/XFree86/Linux-x86/${pkgver}/NVIDIA-Linux-x86-${pkgver}.run") +source_x86_64+=("http://us.download.nvidia.com/XFree86/Linux-x86_64/${pkgver}/NVIDIA-Linux-x86_64-${pkgver}-no-compat32.run") +sha512sums=('54e8825e523f11706890e09e476498f3a30f75ce4e350ff2ff8a1e1c3af574d9ccfb8903543766b6863d94cdfbf46e68cd3d33380867dd976cafc8dd2dd78774' + 'fa39dee5c9f1ea98286c87165f683ee194b2cb4056aa6b556e822b9ee760dcf3683ea001c3704e79b9ac9712314d7df5690dc7f68440cda7a96791f94425455d' + '68dabbf6ad889c46bd0c01ebb697b80f4aa526ef1cdc53de008343a243adefc6ce7f2778be7005f2d79f3d23c0a3ff69f67ecdb9f97c0feb0ec99405a0c1046a' + 'da3d1698af8b97e8fc3b6d3c690925e0258f8b6ad26a24f8d32c04a5a82701655208021f9f5af0ce44cb397a7422e2776a05193204bc7e4ac2b98f6e173984ea') +sha512sums_i686=('c2645cc9a6f23641d8b6da51e72e203980068c05e365fcc73b32322a6875ce95e81f4e0d893276e14e84e93464488539c16db6b3be04f5324cf7d7a12bb557f8') +sha512sums_x86_64=('a5aa48baa75eb267bd193e59328aa5fbc15d41045bb7e97aa1b96b918b9e68a1c1bf95624d9d494336256e0af2c41e188d30fe91be4967084de3387f50d3805c') + +[[ "$CARCH" = "i686" ]] && _pkg="NVIDIA-Linux-x86-${pkgver}" +[[ "$CARCH" = "x86_64" ]] && _pkg="NVIDIA-Linux-x86_64-${pkgver}-no-compat32" + +prepare() { + cd "${srcdir}" + sh "${_pkg}.run" --extract-only + cd "${_pkg}" + # patches here + patch -Np1 --no-backup-if-mismatch -i ../kernel_4.10.patch + patch -Np1 --no-backup-if-mismatch -i ../kernel_4.11.patch + + # FS#47092 + #(cd kernel; patch -p1 --no-backup-if-mismatch -i "$srcdir"/disable-mtrr.patch) + (cd kernel; patch -p1 --no-backup-if-mismatch -i "$srcdir"/drm-driver-legacy.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 +} + +package_nvidia-304xx() { + pkgdesc="NVIDIA drivers for linux, 304xx legacy branch" + depends=('linux>=4.11' 'linux<4.12' 'libgl' "nvidia-304xx-utils=${pkgver}") + conflicts+=('nvidia-304xx-dkms') + install=nvidia-304xx.install + + install -D -m644 "${srcdir}/${_pkg}/kernel/nvidia.ko" \ + "${pkgdir}/usr/lib/modules/${_extramodules}/nvidia.ko" + install -d -m755 "${pkgdir}/usr/lib/modprobe.d" + echo "blacklist nouveau" >> "${pkgdir}/usr/lib/modprobe.d/nvidia.conf" + sed -i -e "s/EXTRAMODULES='.*'/EXTRAMODULES='${_extramodules}'/" "${startdir}/${pkgname}.install" + gzip "${pkgdir}/usr/lib/modules/${_extramodules}/nvidia.ko" + + # the license file is part of nvidia-304xx-utils - the module depends on it, so we don't ship it another time. +} + +package_nvidia-304xx-dkms() { + pkgdesc="NVIDIA driver sources for linux, 304xx legacy branch" + depends=('dkms' "nvidia-304xx-utils=$pkgver") + optdepends=('linux-headers: Build the module for Arch kernel' + 'linux-lts-headers: Build the module for LTS Arch kernel') + conflicts+=('nvidia-304xx') + + cd ${_pkg} + make -C kernel clean + install -dm 755 "${pkgdir}"/usr/{lib/modprobe.d,src} + cp -dr --no-preserve='ownership' kernel-dkms "${pkgdir}"/usr/src/nvidia-${pkgver} + echo 'blacklist nouveau' > "${pkgdir}"/usr/lib/modprobe.d/nvidia.conf +} Copied: nvidia-304xx/repos/testing-i686/disable-mtrr.patch (from rev 298828, nvidia-304xx/trunk/disable-mtrr.patch) =================================================================== --- testing-i686/disable-mtrr.patch (rev 0) +++ testing-i686/disable-mtrr.patch 2017-06-14 17:08:50 UTC (rev 298829) @@ -0,0 +1,24 @@ +Author: Luca Boccassi <luca.bocca...@gmail.com> +Description: Disable MTRR on kernel >= 4.3 + From kernel 4.3 and newer (commit 2baa891e42d84) mtrr_add and mtrr_del are no + longer exported. The Nvidia kernel shim still uses it as of 304.131, causing + the module to error out when loading. Disable MTRR if running on 4.3 or greater + until upstream fixes it. +--- a/nv-linux.h ++++ b/nv-linux.h +@@ -256,6 +256,15 @@ + #include <linux/seq_file.h> + #endif + ++/* ++ * As of version 304.131, os-agp.c and os-mtrr.c still use deprecated ++ * kernel APIs for mtrr which are no longer exported since 4.3, causing ++ * the module to error out when loaded. ++ */ ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,3,0) ++#undef CONFIG_MTRR ++#endif ++ + #if !defined(NV_VMWARE) && defined(CONFIG_MTRR) + #include <asm/mtrr.h> + #endif Copied: nvidia-304xx/repos/testing-i686/drm-driver-legacy.patch (from rev 298828, nvidia-304xx/trunk/drm-driver-legacy.patch) =================================================================== --- testing-i686/drm-driver-legacy.patch (rev 0) +++ testing-i686/drm-driver-legacy.patch 2017-06-14 17:08:50 UTC (rev 298829) @@ -0,0 +1,20 @@ +Author: Luca Boccassi <luca.bocca...@gmail.com> +Description: Fix kernel module load on 4.9 and greater + From kernel 4.9 and newer (commit fa5386459f06) non-modesetting drivers have + to use the DRM flag DRIVER_LEGACY. Without this flag the kernel module does + not load correctly. + +--- a/nv-drm.c ++++ b/nv-drm.c +@@ -71,7 +71,11 @@ + }; + + static struct drm_driver nv_drm_driver = { ++#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 9, 0) + .driver_features = 0, ++#else ++ .driver_features = DRIVER_LEGACY, ++#endif + .load = nv_drm_load, + .unload = nv_drm_unload, + .fops = &nv_drm_fops, Copied: nvidia-304xx/repos/testing-i686/kernel_4.10.patch (from rev 298828, nvidia-304xx/trunk/kernel_4.10.patch) =================================================================== --- testing-i686/kernel_4.10.patch (rev 0) +++ testing-i686/kernel_4.10.patch 2017-06-14 17:08:50 UTC (rev 298829) @@ -0,0 +1,105 @@ +From d270372bf8abcf45409b30cdb33069280527b0ff Mon Sep 17 00:00:00 2001 +From: Alberto Milone <alberto.mil...@canonical.com> +Date: Wed, 15 Feb 2017 18:01:02 +0100 +Subject: [PATCH 1/1] Add support for Linux 4.10 + +--- + nv-linux.h | 5 +++++ + nv-pat.c | 40 ++++++++++++++++++++++++++++++++++++++++ + 2 files changed, 45 insertions(+) + +diff --git a/kernel/nv-linux.h b/kernel/nv-linux.h +index b46e71f..3081c06 100644 +--- a/kernel/nv-linux.h ++++ b/kernel/nv-linux.h +@@ -1895,8 +1895,13 @@ static inline NvU64 nv_node_end_pfn(int nid) + + #else + ++#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 10, 0) + return get_user_pages_remote(tsk, mm, start, nr_pages, flags, + pages, vmas); ++#else ++ return get_user_pages_remote(tsk, mm, start, nr_pages, flags, ++ pages, vmas, NULL); ++#endif + + #endif + +diff --git a/kernel/nv-pat.c b/kernel/nv-pat.c +index e71e81c..d742789 100644 +--- a/kernel/nv-pat.c ++++ b/kernel/nv-pat.c +@@ -203,6 +203,7 @@ void nv_disable_pat_support(void) + } + + #if defined(NV_ENABLE_PAT_SUPPORT) && defined(NV_ENABLE_HOTPLUG_CPU) ++#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 10, 0) + static int + nv_kern_cpu_callback(struct notifier_block *nfb, unsigned long action, void *hcpu) + { +@@ -234,6 +235,34 @@ static struct notifier_block nv_hotcpu_nfb = { + .notifier_call = nv_kern_cpu_callback, + .priority = 0 + }; ++#else ++static int nvidia_cpu_online(unsigned int hcpu) ++{ ++ unsigned int cpu = get_cpu(); ++ if (cpu == hcpu) ++ nv_setup_pat_entries(NULL); ++ else ++ NV_SMP_CALL_FUNCTION(nv_setup_pat_entries, (void *)(long int)hcpu, 1); ++ ++ put_cpu(); ++ ++ return 0; ++} ++ ++static int nvidia_cpu_down_prep(unsigned int hcpu) ++{ ++ unsigned int cpu = get_cpu(); ++ if (cpu == hcpu) ++ nv_restore_pat_entries(NULL); ++ else ++ NV_SMP_CALL_FUNCTION(nv_restore_pat_entries, (void *)(long int)hcpu, 1); ++ ++ put_cpu(); ++ ++ return 0; ++} ++#endif ++ + #endif + + int nv_init_pat_support(nv_stack_t *sp) +@@ -255,7 +284,14 @@ int nv_init_pat_support(nv_stack_t *sp) + #if defined(NV_ENABLE_PAT_SUPPORT) && defined(NV_ENABLE_HOTPLUG_CPU) + if (nv_pat_mode == NV_PAT_MODE_BUILTIN) + { ++#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 10, 0) + if (register_hotcpu_notifier(&nv_hotcpu_nfb) != 0) ++#else ++ if (cpuhp_setup_state(CPUHP_AP_ONLINE_DYN, ++ "gpu/nvidia:online", ++ nvidia_cpu_online, ++ nvidia_cpu_down_prep) != 0) ++#endif + { + nv_disable_pat_support(); + nv_printf(NV_DBG_ERRORS, +@@ -280,7 +316,11 @@ void nv_teardown_pat_support(void) + { + nv_disable_pat_support(); + #if defined(NV_ENABLE_PAT_SUPPORT) && defined(NV_ENABLE_HOTPLUG_CPU) ++#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 10, 0) + unregister_hotcpu_notifier(&nv_hotcpu_nfb); ++#else ++ cpuhp_remove_state_nocalls(CPUHP_AP_ONLINE_DYN); ++#endif + #endif + } + } +-- +2.7.4 + Copied: nvidia-304xx/repos/testing-i686/kernel_4.11.patch (from rev 298828, nvidia-304xx/trunk/kernel_4.11.patch) =================================================================== --- testing-i686/kernel_4.11.patch (rev 0) +++ testing-i686/kernel_4.11.patch 2017-06-14 17:08:50 UTC (rev 298829) @@ -0,0 +1,44 @@ +--- a/kernel/nv-drm.c ++++ b/kernel/nv-drm.c +@@ -22,6 +22,8 @@ + #include <drm/drm_gem.h> + #endif + ++#include <linux/version.h> ++ + extern nv_linux_state_t *nv_linux_devices; + + static int nv_drm_load( +@@ -42,7 +44,11 @@ + return -ENODEV; + } + ++#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 11, 0) + static int nv_drm_unload( ++#else ++static void nv_drm_unload( ++#endif + struct drm_device *dev + ) + { +@@ -52,11 +58,19 @@ + { + if (nvl->dev == dev->pdev) + { ++#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 11, 0) + return 0; ++#else ++ return; ++#endif + } + } + ++#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 11, 0) + return -ENODEV; ++#else ++ return; ++#endif + } + + static const struct file_operations nv_drm_fops = { + Copied: nvidia-304xx/repos/testing-i686/nvidia-304xx.install (from rev 298828, nvidia-304xx/trunk/nvidia-304xx.install) =================================================================== --- testing-i686/nvidia-304xx.install (rev 0) +++ testing-i686/nvidia-304xx.install 2017-06-14 17:08:50 UTC (rev 298829) @@ -0,0 +1,13 @@ +post_install() { + EXTRAMODULES='extramodules-4.11-ARCH' + depmod $(cat /usr/lib/modules/$EXTRAMODULES/version) + echo 'In order to use nvidia module, reboot the system.' +} + +post_upgrade() { + post_install +} + +post_remove() { + post_install +} Copied: nvidia-304xx/repos/testing-x86_64/PKGBUILD (from rev 298828, nvidia-304xx/trunk/PKGBUILD) =================================================================== --- testing-x86_64/PKGBUILD (rev 0) +++ testing-x86_64/PKGBUILD 2017-06-14 17:08:50 UTC (rev 298829) @@ -0,0 +1,81 @@ +# $Id$ +# Maintainer: Felix Yan <felixonm...@archlinux.org> +# Contributor: Thomas Baechler <tho...@archlinux.org> + +pkgbase=nvidia-304xx +pkgname=(nvidia-304xx nvidia-304xx-dkms) +pkgver=304.135 +_extramodules=extramodules-4.11-ARCH +pkgrel=6 +arch=('i686' 'x86_64') +url="http://www.nvidia.com/" +makedepends=('linux' 'linux-headers>=4.11' 'linux-headers<4.12') +conflicts=('nvidia') +license=('custom') +options=('!strip') +source=('disable-mtrr.patch' + 'drm-driver-legacy.patch' + 'kernel_4.10.patch' + 'kernel_4.11.patch') +source_i686+=("http://us.download.nvidia.com/XFree86/Linux-x86/${pkgver}/NVIDIA-Linux-x86-${pkgver}.run") +source_x86_64+=("http://us.download.nvidia.com/XFree86/Linux-x86_64/${pkgver}/NVIDIA-Linux-x86_64-${pkgver}-no-compat32.run") +sha512sums=('54e8825e523f11706890e09e476498f3a30f75ce4e350ff2ff8a1e1c3af574d9ccfb8903543766b6863d94cdfbf46e68cd3d33380867dd976cafc8dd2dd78774' + 'fa39dee5c9f1ea98286c87165f683ee194b2cb4056aa6b556e822b9ee760dcf3683ea001c3704e79b9ac9712314d7df5690dc7f68440cda7a96791f94425455d' + '68dabbf6ad889c46bd0c01ebb697b80f4aa526ef1cdc53de008343a243adefc6ce7f2778be7005f2d79f3d23c0a3ff69f67ecdb9f97c0feb0ec99405a0c1046a' + 'da3d1698af8b97e8fc3b6d3c690925e0258f8b6ad26a24f8d32c04a5a82701655208021f9f5af0ce44cb397a7422e2776a05193204bc7e4ac2b98f6e173984ea') +sha512sums_i686=('c2645cc9a6f23641d8b6da51e72e203980068c05e365fcc73b32322a6875ce95e81f4e0d893276e14e84e93464488539c16db6b3be04f5324cf7d7a12bb557f8') +sha512sums_x86_64=('a5aa48baa75eb267bd193e59328aa5fbc15d41045bb7e97aa1b96b918b9e68a1c1bf95624d9d494336256e0af2c41e188d30fe91be4967084de3387f50d3805c') + +[[ "$CARCH" = "i686" ]] && _pkg="NVIDIA-Linux-x86-${pkgver}" +[[ "$CARCH" = "x86_64" ]] && _pkg="NVIDIA-Linux-x86_64-${pkgver}-no-compat32" + +prepare() { + cd "${srcdir}" + sh "${_pkg}.run" --extract-only + cd "${_pkg}" + # patches here + patch -Np1 --no-backup-if-mismatch -i ../kernel_4.10.patch + patch -Np1 --no-backup-if-mismatch -i ../kernel_4.11.patch + + # FS#47092 + #(cd kernel; patch -p1 --no-backup-if-mismatch -i "$srcdir"/disable-mtrr.patch) + (cd kernel; patch -p1 --no-backup-if-mismatch -i "$srcdir"/drm-driver-legacy.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 +} + +package_nvidia-304xx() { + pkgdesc="NVIDIA drivers for linux, 304xx legacy branch" + depends=('linux>=4.11' 'linux<4.12' 'libgl' "nvidia-304xx-utils=${pkgver}") + conflicts+=('nvidia-304xx-dkms') + install=nvidia-304xx.install + + install -D -m644 "${srcdir}/${_pkg}/kernel/nvidia.ko" \ + "${pkgdir}/usr/lib/modules/${_extramodules}/nvidia.ko" + install -d -m755 "${pkgdir}/usr/lib/modprobe.d" + echo "blacklist nouveau" >> "${pkgdir}/usr/lib/modprobe.d/nvidia.conf" + sed -i -e "s/EXTRAMODULES='.*'/EXTRAMODULES='${_extramodules}'/" "${startdir}/${pkgname}.install" + gzip "${pkgdir}/usr/lib/modules/${_extramodules}/nvidia.ko" + + # the license file is part of nvidia-304xx-utils - the module depends on it, so we don't ship it another time. +} + +package_nvidia-304xx-dkms() { + pkgdesc="NVIDIA driver sources for linux, 304xx legacy branch" + depends=('dkms' "nvidia-304xx-utils=$pkgver") + optdepends=('linux-headers: Build the module for Arch kernel' + 'linux-lts-headers: Build the module for LTS Arch kernel') + conflicts+=('nvidia-304xx') + + cd ${_pkg} + make -C kernel clean + install -dm 755 "${pkgdir}"/usr/{lib/modprobe.d,src} + cp -dr --no-preserve='ownership' kernel-dkms "${pkgdir}"/usr/src/nvidia-${pkgver} + echo 'blacklist nouveau' > "${pkgdir}"/usr/lib/modprobe.d/nvidia.conf +} Copied: nvidia-304xx/repos/testing-x86_64/disable-mtrr.patch (from rev 298828, nvidia-304xx/trunk/disable-mtrr.patch) =================================================================== --- testing-x86_64/disable-mtrr.patch (rev 0) +++ testing-x86_64/disable-mtrr.patch 2017-06-14 17:08:50 UTC (rev 298829) @@ -0,0 +1,24 @@ +Author: Luca Boccassi <luca.bocca...@gmail.com> +Description: Disable MTRR on kernel >= 4.3 + From kernel 4.3 and newer (commit 2baa891e42d84) mtrr_add and mtrr_del are no + longer exported. The Nvidia kernel shim still uses it as of 304.131, causing + the module to error out when loading. Disable MTRR if running on 4.3 or greater + until upstream fixes it. +--- a/nv-linux.h ++++ b/nv-linux.h +@@ -256,6 +256,15 @@ + #include <linux/seq_file.h> + #endif + ++/* ++ * As of version 304.131, os-agp.c and os-mtrr.c still use deprecated ++ * kernel APIs for mtrr which are no longer exported since 4.3, causing ++ * the module to error out when loaded. ++ */ ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,3,0) ++#undef CONFIG_MTRR ++#endif ++ + #if !defined(NV_VMWARE) && defined(CONFIG_MTRR) + #include <asm/mtrr.h> + #endif Copied: nvidia-304xx/repos/testing-x86_64/drm-driver-legacy.patch (from rev 298828, nvidia-304xx/trunk/drm-driver-legacy.patch) =================================================================== --- testing-x86_64/drm-driver-legacy.patch (rev 0) +++ testing-x86_64/drm-driver-legacy.patch 2017-06-14 17:08:50 UTC (rev 298829) @@ -0,0 +1,20 @@ +Author: Luca Boccassi <luca.bocca...@gmail.com> +Description: Fix kernel module load on 4.9 and greater + From kernel 4.9 and newer (commit fa5386459f06) non-modesetting drivers have + to use the DRM flag DRIVER_LEGACY. Without this flag the kernel module does + not load correctly. + +--- a/nv-drm.c ++++ b/nv-drm.c +@@ -71,7 +71,11 @@ + }; + + static struct drm_driver nv_drm_driver = { ++#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 9, 0) + .driver_features = 0, ++#else ++ .driver_features = DRIVER_LEGACY, ++#endif + .load = nv_drm_load, + .unload = nv_drm_unload, + .fops = &nv_drm_fops, Copied: nvidia-304xx/repos/testing-x86_64/kernel_4.10.patch (from rev 298828, nvidia-304xx/trunk/kernel_4.10.patch) =================================================================== --- testing-x86_64/kernel_4.10.patch (rev 0) +++ testing-x86_64/kernel_4.10.patch 2017-06-14 17:08:50 UTC (rev 298829) @@ -0,0 +1,105 @@ +From d270372bf8abcf45409b30cdb33069280527b0ff Mon Sep 17 00:00:00 2001 +From: Alberto Milone <alberto.mil...@canonical.com> +Date: Wed, 15 Feb 2017 18:01:02 +0100 +Subject: [PATCH 1/1] Add support for Linux 4.10 + +--- + nv-linux.h | 5 +++++ + nv-pat.c | 40 ++++++++++++++++++++++++++++++++++++++++ + 2 files changed, 45 insertions(+) + +diff --git a/kernel/nv-linux.h b/kernel/nv-linux.h +index b46e71f..3081c06 100644 +--- a/kernel/nv-linux.h ++++ b/kernel/nv-linux.h +@@ -1895,8 +1895,13 @@ static inline NvU64 nv_node_end_pfn(int nid) + + #else + ++#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 10, 0) + return get_user_pages_remote(tsk, mm, start, nr_pages, flags, + pages, vmas); ++#else ++ return get_user_pages_remote(tsk, mm, start, nr_pages, flags, ++ pages, vmas, NULL); ++#endif + + #endif + +diff --git a/kernel/nv-pat.c b/kernel/nv-pat.c +index e71e81c..d742789 100644 +--- a/kernel/nv-pat.c ++++ b/kernel/nv-pat.c +@@ -203,6 +203,7 @@ void nv_disable_pat_support(void) + } + + #if defined(NV_ENABLE_PAT_SUPPORT) && defined(NV_ENABLE_HOTPLUG_CPU) ++#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 10, 0) + static int + nv_kern_cpu_callback(struct notifier_block *nfb, unsigned long action, void *hcpu) + { +@@ -234,6 +235,34 @@ static struct notifier_block nv_hotcpu_nfb = { + .notifier_call = nv_kern_cpu_callback, + .priority = 0 + }; ++#else ++static int nvidia_cpu_online(unsigned int hcpu) ++{ ++ unsigned int cpu = get_cpu(); ++ if (cpu == hcpu) ++ nv_setup_pat_entries(NULL); ++ else ++ NV_SMP_CALL_FUNCTION(nv_setup_pat_entries, (void *)(long int)hcpu, 1); ++ ++ put_cpu(); ++ ++ return 0; ++} ++ ++static int nvidia_cpu_down_prep(unsigned int hcpu) ++{ ++ unsigned int cpu = get_cpu(); ++ if (cpu == hcpu) ++ nv_restore_pat_entries(NULL); ++ else ++ NV_SMP_CALL_FUNCTION(nv_restore_pat_entries, (void *)(long int)hcpu, 1); ++ ++ put_cpu(); ++ ++ return 0; ++} ++#endif ++ + #endif + + int nv_init_pat_support(nv_stack_t *sp) +@@ -255,7 +284,14 @@ int nv_init_pat_support(nv_stack_t *sp) + #if defined(NV_ENABLE_PAT_SUPPORT) && defined(NV_ENABLE_HOTPLUG_CPU) + if (nv_pat_mode == NV_PAT_MODE_BUILTIN) + { ++#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 10, 0) + if (register_hotcpu_notifier(&nv_hotcpu_nfb) != 0) ++#else ++ if (cpuhp_setup_state(CPUHP_AP_ONLINE_DYN, ++ "gpu/nvidia:online", ++ nvidia_cpu_online, ++ nvidia_cpu_down_prep) != 0) ++#endif + { + nv_disable_pat_support(); + nv_printf(NV_DBG_ERRORS, +@@ -280,7 +316,11 @@ void nv_teardown_pat_support(void) + { + nv_disable_pat_support(); + #if defined(NV_ENABLE_PAT_SUPPORT) && defined(NV_ENABLE_HOTPLUG_CPU) ++#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 10, 0) + unregister_hotcpu_notifier(&nv_hotcpu_nfb); ++#else ++ cpuhp_remove_state_nocalls(CPUHP_AP_ONLINE_DYN); ++#endif + #endif + } + } +-- +2.7.4 + Copied: nvidia-304xx/repos/testing-x86_64/kernel_4.11.patch (from rev 298828, nvidia-304xx/trunk/kernel_4.11.patch) =================================================================== --- testing-x86_64/kernel_4.11.patch (rev 0) +++ testing-x86_64/kernel_4.11.patch 2017-06-14 17:08:50 UTC (rev 298829) @@ -0,0 +1,44 @@ +--- a/kernel/nv-drm.c ++++ b/kernel/nv-drm.c +@@ -22,6 +22,8 @@ + #include <drm/drm_gem.h> + #endif + ++#include <linux/version.h> ++ + extern nv_linux_state_t *nv_linux_devices; + + static int nv_drm_load( +@@ -42,7 +44,11 @@ + return -ENODEV; + } + ++#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 11, 0) + static int nv_drm_unload( ++#else ++static void nv_drm_unload( ++#endif + struct drm_device *dev + ) + { +@@ -52,11 +58,19 @@ + { + if (nvl->dev == dev->pdev) + { ++#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 11, 0) + return 0; ++#else ++ return; ++#endif + } + } + ++#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 11, 0) + return -ENODEV; ++#else ++ return; ++#endif + } + + static const struct file_operations nv_drm_fops = { + Copied: nvidia-304xx/repos/testing-x86_64/nvidia-304xx.install (from rev 298828, nvidia-304xx/trunk/nvidia-304xx.install) =================================================================== --- testing-x86_64/nvidia-304xx.install (rev 0) +++ testing-x86_64/nvidia-304xx.install 2017-06-14 17:08:50 UTC (rev 298829) @@ -0,0 +1,13 @@ +post_install() { + EXTRAMODULES='extramodules-4.11-ARCH' + depmod $(cat /usr/lib/modules/$EXTRAMODULES/version) + echo 'In order to use nvidia module, reboot the system.' +} + +post_upgrade() { + post_install +} + +post_remove() { + post_install +}