summarylogtreecommitdiffstats
path: root/linux-4.10.patch
blob: f22663d763ae0bd238ae07c47f5713b4d70ca868 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
diff -Naur nv.orig/nv.c nv/nv.c
--- nv.orig/nv.c	2017-03-31 10:49:58.133349000 +0200
+++ nv/nv.c	2017-03-31 10:54:51.852724105 +0200
@@ -1150,6 +1150,7 @@
 }
 
 #if defined(NV_ENABLE_PAT_SUPPORT) && defined(CONFIG_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)
 {
@@ -1181,6 +1182,34 @@
     .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
 
 
@@ -1418,7 +1447,14 @@
 #if defined(NV_ENABLE_PAT_SUPPORT) && defined(CONFIG_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();
                 rc = -EIO;
@@ -1565,7 +1601,11 @@
     {
         __nv_disable_pat_support();
 #if defined(NV_ENABLE_PAT_SUPPORT) && defined(CONFIG_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
     }