Commit 2227a6cc authored by Chaoting Liu's avatar Chaoting Liu
Browse files

nvidia-legacy: update and remove old patches

- nvidia-304xx: update to 304.135
- nvidia-340xx: update to 340.102
parent 5feb681c
......@@ -2,8 +2,8 @@
source ../linux.conf
pkgname=('nvidia-304xx' 'chd-nvidia-304xx')
pkgver=304.132
pkgrel=5
pkgver=304.135
pkgrel=1
arch=('x86_64')
url="http://www.nvidia.com/"
makedepends=("linux-headers=${_kernelver}")
......@@ -11,11 +11,12 @@ license=('custom')
_pkg="NVIDIA-Linux-${arch}-${pkgver}-no-compat32"
source=("https://chakralinux.org/code/chakra-hardware-detection.git/plain/hwdb/nvidia_supported"
"ftp://download.nvidia.com/XFree86/Linux-${arch}/${pkgver}/${_pkg}.run"
'nv-drm.patch' 'disable-mtrr.patch')
'drm-driver-legacy.patch'
'kernel_4.10.patch')
md5sums=('62d0cdb856cfae64753c0f3acf729d47'
'671551de37d7164d3b117c854374dcec'
'79671a27131da619a33eb02ed0c2c031'
'c4becf1145a139cc0121be9ad340bcd8')
'8ee9bd0b020508bca9953181811422fa'
'a5328715e210e36e5d9bbed0f9e55223'
'a8d331a75fbc541f1730e95b95e9ef14')
prepare() {
cd "${srcdir}"
......@@ -23,9 +24,12 @@ prepare() {
sh "${_pkg}.run" --extract-only
cd "${_pkg}"
# patches here
patch -p0 -i "$srcdir/nv-drm.patch"
patch -Np1 --no-backup-if-mismatch -i ../kernel_4.10.patch
# FS#47092
cd kernel
patch -p1 --no-backup-if-mismatch -i "$srcdir"/disable-mtrr.patch
patch -p1 --no-backup-if-mismatch -i "$srcdir"/drm-driver-legacy.patch
}
build() {
......
Author: Luca Boccassi <luca.boccassi@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
Author: Luca Boccassi <luca.boccassi@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,
From d270372bf8abcf45409b30cdb33069280527b0ff Mon Sep 17 00:00:00 2001
From: Alberto Milone <alberto.milone@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
--- kernel/nv-drm.c~ 2014-09-12 00:33:06.000000000 +0200
+++ kernel/nv-drm.c 2014-10-14 11:35:52.854400737 +0200
@@ -18,6 +18,11 @@
#include <drm/drmP.h>
+/* 3.18-rc0+ */
+#ifndef drm_gem_object
+#include <drm/drm_gem.h>
+#endif
+
extern nv_linux_state_t *nv_linux_devices;
struct nv_gem_object {
diff --git a/kernel/nv-drm.c~ b/kernel/nv-drm.c
index ecc982a..60d7aae 100644
--- kernel/nv-drm.c~
+++ kernel/nv-drm.c
@@ -129,6 +129,8 @@ static struct drm_driver nv_drm_driver = {
.gem_prime_vmap = nv_gem_prime_vmap,
.gem_prime_vunmap = nv_gem_prime_vunmap,
+ .set_busid = drm_pci_set_busid,
+
.name = "nvidia-drm",
.desc = "NVIDIA DRM driver",
.date = "20130102",
post_install() {
EXTRAMODULES='extramodules-4.8-CHAKRA'
EXTRAMODULES='extramodules-4.10-CHAKRA'
depmod $(cat /lib/modules/$EXTRAMODULES/version)
echo 'In order to use nvidia module, reboot the system.'
}
post_upgrade() {
EXTRAMODULES='extramodules-4.8-CHAKRA'
EXTRAMODULES='extramodules-4.10-CHAKRA'
depmod $(cat /lib/modules/$EXTRAMODULES/version)
}
post_remove() {
EXTRAMODULES='extramodules-4.8-CHAKRA'
EXTRAMODULES='extramodules-4.10-CHAKRA'
depmod $(cat /lib/modules/$EXTRAMODULES/version)
}
From 983a2ca221a371e08bb5ad11758a729cfa5aa88c Mon Sep 17 00:00:00 2001
From: Alberto Milone <alberto.milone@canonical.com>
Date: Wed, 15 Feb 2017 17:05:55 +0100
Subject: [PATCH 1/1] Add support for Linux 4.10
---
nv-linux.h | 7 +++++++
nv-pat.c | 40 ++++++++++++++++++++++++++++++++++++++++
uvm/nvidia_uvm_lite.c | 4 ++++
3 files changed, 51 insertions(+)
diff --git a/kernel/nv-linux.h b/kernel/nv-linux.h
index e7068e3..2d62492 100644
--- a/kernel/nv-linux.h
+++ b/kernel/nv-linux.h
@@ -2082,6 +2082,8 @@ static inline NvU64 nv_node_end_pfn(int nid)
* 2016 Dec 14:5b56d49fc31dbb0487e14ead790fc81ca9fb2c99
*/
+#include <linux/version.h>
+
#if defined(NV_GET_USER_PAGES_REMOTE_PRESENT)
#if defined(NV_GET_USER_PAGES_HAS_WRITE_AND_FORCE_ARGS)
#define NV_GET_USER_PAGES get_user_pages
@@ -2129,8 +2131,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 a725533..cec6f3f 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
nvidia_cpu_callback(struct notifier_block *nfb, unsigned long action, void *hcpu)
{
@@ -234,6 +235,34 @@ static struct notifier_block nv_hotcpu_nfb = {
.notifier_call = nvidia_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
}
}
diff --git a/kernel/uvm/nvidia_uvm_lite.c b/kernel/uvm/nvidia_uvm_lite.c
index 9627f60..2158b45 100644
--- a/kernel/uvm/nvidia_uvm_lite.c
+++ b/kernel/uvm/nvidia_uvm_lite.c
@@ -820,7 +820,11 @@ done:
#if defined(NV_VM_OPERATIONS_STRUCT_HAS_FAULT)
int _fault(struct vm_area_struct *vma, struct vm_fault *vmf)
{
+#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 10, 0)
unsigned long vaddr = (unsigned long)vmf->virtual_address;
+#else
+ unsigned long vaddr = (unsigned long)vmf->address;
+#endif
struct page *page = NULL;
int retval;
--
2.7.4
......@@ -2,27 +2,29 @@
source ../linux.conf
pkgname=('nvidia-340xx' 'chd-nvidia-340xx')
pkgver=340.98
pkgrel=5
pkgver=340.102
pkgrel=1
arch=('x86_64')
url="http://www.nvidia.com/"
makedepends=("linux-headers=${_kernelver}")
license=('custom')
source=("https://chakralinux.org/code/chakra-hardware-detection.git/plain/hwdb/nvidia_supported"
'nv-drm.patch')
'fs52243.patch' '4.10.0_kernel.patch')
_ARCH='x86_64'
_pkg="NVIDIA-Linux-${_ARCH}-${pkgver}-no-compat32"
source+=("ftp://download.nvidia.com/XFree86/Linux-${_ARCH}/${pkgver}/${_pkg}.run")
md5sums=('62d0cdb856cfae64753c0f3acf729d47'
'79671a27131da619a33eb02ed0c2c031'
'e8d1292d8d002a15e10ea349151fa8f2')
'4b9b61bbcaaea4a99a6abe4a13309016'
'fe306bc9c3798a6a922931d6dea7d0e9'
'81e720487caa2823586b32659da9acc1')
prepare() {
sh "${_pkg}.run" --extract-only
cd "${_pkg}"
# patches here
patch -p0 -i ../nv-drm.patch
patch -Np0 < "${srcdir}"/fs52243.patch
patch -Np1 < "${srcdir}"/4.10.0_kernel.patch
}
build() {
......
--- kernel/nv-drm.c 2016-12-15 12:41:26.000000000 +0100
+++ kernel/nv-drm.c 2016-12-15 12:58:48.000000000 +0100
@@ -115,7 +115,11 @@
};
static struct drm_driver nv_drm_driver = {
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 9, 0)
+ .driver_features = DRIVER_GEM | DRIVER_PRIME | DRIVER_LEGACY,
+#else
.driver_features = DRIVER_GEM | DRIVER_PRIME,
+#endif
.load = nv_drm_load,
.unload = nv_drm_unload,
.fops = &nv_drm_fops,
--- kernel/nv-drm.c~ 2014-09-12 00:33:06.000000000 +0200
+++ kernel/nv-drm.c 2014-10-14 11:35:52.854400737 +0200
@@ -18,6 +18,11 @@
#include <drm/drmP.h>
+/* 3.18-rc0+ */
+#ifndef drm_gem_object
+#include <drm/drm_gem.h>
+#endif
+
extern nv_linux_state_t *nv_linux_devices;
struct nv_gem_object {
diff --git a/kernel/nv-drm.c~ b/kernel/nv-drm.c
index ecc982a..60d7aae 100644
--- kernel/nv-drm.c~
+++ kernel/nv-drm.c
@@ -129,6 +129,8 @@ static struct drm_driver nv_drm_driver = {
.gem_prime_vmap = nv_gem_prime_vmap,
.gem_prime_vunmap = nv_gem_prime_vunmap,
+ .set_busid = drm_pci_set_busid,
+
.name = "nvidia-drm",
.desc = "NVIDIA DRM driver",
.date = "20130102",
post_install() {
EXTRAMODULES='extramodules-4.8-CHAKRA'
EXTRAMODULES='extramodules-4.10-CHAKRA'
depmod $(cat /lib/modules/$EXTRAMODULES/version)
echo 'In order to use nvidia module, reboot the system.'
}
post_upgrade() {
EXTRAMODULES='extramodules-4.8-CHAKRA'
EXTRAMODULES='extramodules-4.10-CHAKRA'
depmod $(cat /lib/modules/$EXTRAMODULES/version)
echo -e '\e[31;46m WARNING'
echo -e '\e[31;46m If your card is from the 7xxx series or earlier, switch to nvidia-304xx'
......@@ -14,7 +14,7 @@ post_upgrade() {
}
post_remove() {
EXTRAMODULES='extramodules-4.8-CHAKRA'
EXTRAMODULES='extramodules-4.10-CHAKRA'
depmod $(cat /lib/modules/$EXTRAMODULES/version)
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment