mirror of
https://github.com/LibreELEC/LibreELEC.tv.git
synced 2025-08-02 07:27:49 +00:00
xf86-video-nvidia-legacy: update kernel 4.10 support
Source: https://devtalk.nvidia.com/default/topic/1005209/linux/fully-working-patch-for-nvidia-driver-340-102-compiler-installer-file-and-linux-kernel-4-11/
This commit is contained in:
parent
b2e1bc29b7
commit
a47e6960cc
@ -1,33 +1,114 @@
|
||||
diff --git a/kernel/nv-linux.h b/kernel/nv-linux.h
|
||||
index e7068e3..3ac3c0b 100644
|
||||
diff -Naur a/kernel/nv-linux.h b/kernel/nv-linux.h
|
||||
--- a/kernel/nv-linux.h
|
||||
+++ b/kernel/nv-linux.h
|
||||
@@ -270,7 +270,7 @@ RM_STATUS nvos_forward_error_to_cray(struct pci_dev *, NvU32,
|
||||
@@ -2082,6 +2082,8 @@ static inline NvU64 nv_node_end_pfn(int nid)
|
||||
* 2016 Dec 14:5b56d49fc31dbb0487e14ead790fc81ca9fb2c99
|
||||
*/
|
||||
|
||||
extern int nv_pat_mode;
|
||||
+#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)
|
||||
|
||||
-#if !defined(NV_VMWARE) && defined(CONFIG_HOTPLUG_CPU)
|
||||
+#if 0
|
||||
#define NV_ENABLE_HOTPLUG_CPU
|
||||
#include <linux/cpu.h> /* CPU hotplug support */
|
||||
#include <linux/notifier.h> /* struct notifier_block, etc */
|
||||
diff --git a/kernel/nv-pat.c b/kernel/nv-pat.c
|
||||
index a725533..91070e0 100644
|
||||
#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 -Naur a/kernel/nv-pat.c b/kernel/nv-pat.c
|
||||
--- a/kernel/nv-pat.c
|
||||
+++ b/kernel/nv-pat.c
|
||||
@@ -210,14 +210,13 @@ nvidia_cpu_callback(struct notifier_block *nfb, unsigned long action, void *hcpu
|
||||
@@ -203,6 +203,7 @@ void nv_disable_pat_support(void)
|
||||
}
|
||||
|
||||
switch (action)
|
||||
#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)
|
||||
{
|
||||
- case CPU_DOWN_FAILED:
|
||||
case CPU_ONLINE:
|
||||
if (cpu == (NvUPtr)hcpu)
|
||||
nv_setup_pat_entries(NULL);
|
||||
else
|
||||
NV_SMP_CALL_FUNCTION(nv_setup_pat_entries, hcpu, 1);
|
||||
break;
|
||||
- case CPU_DOWN_PREPARE:
|
||||
+ case CPU_DOWN_PREPARE_FROZEN:
|
||||
if (cpu == (NvUPtr)hcpu)
|
||||
nv_restore_pat_entries(NULL);
|
||||
else
|
||||
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 -Naur a/kernel/uvm/nvidia_uvm_lite.c b/kernel/uvm/nvidia_uvm_lite.c
|
||||
--- 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;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user