aboutsummaryrefslogtreecommitdiff
path: root/system/nvidia-legacy340-kernel/patches/0005-kernel-5.11.patch
blob: 382d7d3b5a26ec3de07e93fc388e6a6da03b0283 (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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
diff -Naur NVIDIA-Linux-x86_64-340.108-old/kernel/conftest.sh NVIDIA-Linux-x86_64-340.108-new/kernel/conftest.sh
--- NVIDIA-Linux-x86_64-340.108-old/kernel/conftest.sh	2021-05-24 20:08:18.743742335 +0200
+++ NVIDIA-Linux-x86_64-340.108-new/kernel/conftest.sh	2021-05-24 20:13:18.019314390 +0200
@@ -1578,21 +1578,21 @@
             #include <drm/drm_drv.h>
             #endif
 
-            #if defined(NV_DRM_DRM_PRIME_H_PRESENT)
-            #include <drm/drm_prime.h>
-            #endif
-
             #if !defined(CONFIG_DRM) && !defined(CONFIG_DRM_MODULE)
             #error DRM not enabled
             #endif
+
             void conftest_drm_available(void) {
                 struct drm_driver drv;
-                drv.gem_prime_pin = 0;
-                drv.gem_prime_get_sg_table = 0;
-                drv.gem_prime_vmap = 0;
-                drv.gem_prime_vunmap = 0;
-                (void)drm_gem_prime_import;
-                (void)drm_gem_prime_export;
+
+                /* 2013-10-02 1bb72532ac260a2d3982b40bdd4c936d779d0d16 */
+                (void)drm_dev_alloc;
+
+                /* 2013-10-02 c22f0ace1926da399d9a16dfaf09174c1b03594c */
+                (void)drm_dev_register;
+
+                /* 2013-10-02 c3a49737ef7db0bdd4fcf6cf0b7140a883e32b2a */
+                (void)drm_dev_unregister;
             }"
 
             compile_check_conftest "$CODE" "NV_DRM_AVAILABLE" "" "generic"
diff -Naur NVIDIA-Linux-x86_64-340.108-old/kernel/nv-drm.c NVIDIA-Linux-x86_64-340.108-new/kernel/nv-drm.c
--- NVIDIA-Linux-x86_64-340.108-old/kernel/nv-drm.c	2021-05-24 20:08:18.779739237 +0200
+++ NVIDIA-Linux-x86_64-340.108-new/kernel/nv-drm.c	2021-05-24 20:42:13.443288819 +0200
@@ -60,6 +60,8 @@
 #else
 #include <drm/drm_agpsupport.h>
 
+#include "linux/dma-buf.h"
+
 struct nv_drm_agp_head {
     struct agp_kern_info agp_info;
     struct list_head memory;
@@ -210,8 +212,10 @@
 
     /* No locking needed since shadow-attach is single-threaded since it may
      * only be called from the per-driver module init hook. */
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(5, 10, 0)
     if (drm_core_check_feature(dev, DRIVER_LEGACY))
         list_add_tail(&dev->legacy_dev_list, &driver->legacy_dev_list);
+#endif
 
     return 0;
 
@@ -239,8 +243,10 @@
     if (WARN_ON(!(driver->driver_features & DRIVER_LEGACY)))
         return -EINVAL;
 
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(5, 10, 0)
     /* If not using KMS, fall back to stealth mode manual scanning. */
     INIT_LIST_HEAD(&driver->legacy_dev_list);
+#endif
     for (i = 0; pdriver->id_table[i].vendor != 0; i++) {
         pid = &pdriver->id_table[i];
 
@@ -273,11 +279,13 @@
     if (!(driver->driver_features & DRIVER_LEGACY)) {
         WARN_ON(1);
     } else {
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(5, 10, 0)
         list_for_each_entry_safe(dev, tmp, &driver->legacy_dev_list,
                      legacy_dev_list) {
             list_del(&dev->legacy_dev_list);
             drm_put_dev(dev);
         }
+#endif
     }
     DRM_INFO("Module unloaded\n");
 }
@@ -402,6 +410,39 @@
     .llseek = noop_llseek,
 };
 
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 11, 0)
+struct sg_table *nv_drm_gem_prime_get_sg_table(struct drm_gem_object *gem)
+{
+    return nv_gem_prime_get_sg_table(gem);
+}
+
+static int nv_drm_gem_vmap(struct drm_gem_object *gem,
+                           struct dma_buf_map *map)
+{
+    map->vaddr = nv_gem_prime_vmap(gem);
+    if (map->vaddr == NULL) {
+        return -ENOMEM;
+    }
+    map->is_iomem = true;
+    return 0;
+}
+
+static void nv_drm_gem_vunmap(struct drm_gem_object *gem,
+                              struct dma_buf_map *map)
+{
+    nv_gem_prime_vunmap(gem, map->vaddr);
+    map->vaddr = NULL;
+}
+
+static struct drm_gem_object_funcs nv_drm_gem_object_funcs = {
+  .free = nv_gem_free,
+  .export = drm_gem_prime_export,
+  .get_sg_table = nv_drm_gem_prime_get_sg_table,
+  .vmap = nv_drm_gem_vmap,
+  .vunmap = nv_drm_gem_vunmap,
+};
+#endif
+
 static struct drm_driver nv_drm_driver = {
 
     .driver_features = DRIVER_GEM
@@ -420,17 +461,19 @@
     .set_busid = drm_pci_set_busid,
 #endif
 
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 9, 0)
-    .gem_free_object_unlocked = nv_gem_free,
-#else
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(5, 8, 0)
     .gem_free_object = nv_gem_free,
+#elif LINUX_VERSION_CODE <= KERNEL_VERSION(5, 10, 0)
+    .gem_free_object_unlocked = nv_gem_free,
 #endif
 
     .prime_handle_to_fd = drm_gem_prime_handle_to_fd,
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(5, 10, 0)
     .gem_prime_export = drm_gem_prime_export,
     .gem_prime_get_sg_table = nv_gem_prime_get_sg_table,
     .gem_prime_vmap = nv_gem_prime_vmap,
     .gem_prime_vunmap = nv_gem_prime_vunmap,
+#endif
 
     .name = "nvidia-drm",
     .desc = "NVIDIA DRM driver",
diff -Naur NVIDIA-Linux-x86_64-340.108-old/kernel/nv-linux.h NVIDIA-Linux-x86_64-340.108-new/kernel/nv-linux.h
--- NVIDIA-Linux-x86_64-340.108-old/kernel/nv-linux.h	2021-05-24 20:08:18.775739581 +0200
+++ NVIDIA-Linux-x86_64-340.108-new/kernel/nv-linux.h	2021-05-24 20:09:18.748287771 +0200
@@ -119,7 +119,9 @@
 #include <asm/tlbflush.h>           /* flush_tlb(), flush_tlb_all()     */
 #include <linux/cpu.h>              /* CPU hotplug support              */
 #endif
-#include <asm/kmap_types.h>         /* page table entry lookup          */
+#if LINUX_VERSION_CODE	< KERNEL_VERSION(5, 11,	0)
+	#include <asm/kmap_types.h>         /* page table entry lookup          */
+#endif
 
 #include <linux/pci.h>              /* pci_find_class, etc              */
 #include <linux/interrupt.h>        /* tasklets, interrupt helpers      */
diff -Naur NVIDIA-Linux-x86_64-340.108-old/kernel/uvm/nvidia_uvm_linux.h NVIDIA-Linux-x86_64-340.108-new/kernel/uvm/nvidia_uvm_linux.h
--- NVIDIA-Linux-x86_64-340.108-old/kernel/uvm/nvidia_uvm_linux.h	2021-05-24 20:08:18.775739581 +0200
+++ NVIDIA-Linux-x86_64-340.108-new/kernel/uvm/nvidia_uvm_linux.h	2021-05-24 20:09:18.749287739 +0200
@@ -141,7 +141,9 @@
 #if !defined(NV_VMWARE)
 #include <asm/tlbflush.h>           /* flush_tlb(), flush_tlb_all()     */
 #endif
-#include <asm/kmap_types.h>         /* page table entry lookup          */
+#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 11, 0)
+	#include <asm/kmap_types.h>         /* page table entry lookup          */
+#endif
 
 #include <linux/interrupt.h>        /* tasklets, interrupt helpers      */
 #include <linux/timer.h>