aboutsummaryrefslogtreecommitdiff
path: root/system/nvidia-legacy390-kernel/patches/kernel-5.10.patch
blob: 6fa40d0f946c5a47653e3d87d2e0b5037f790956 (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
From a7b47c7adad039c65e75cfc31e0ca77d29b915f7 Mon Sep 17 00:00:00 2001
From: BlackEagle <ike.devolder@gmail.com>
Date: Sat, 19 Dec 2020 14:50:07 +0100
Subject: [PATCH] kernel-5.10

based on: https://gist.github.com/xtrymind/70919c82347670e788d4787dc321b72f

Signed-off-by: BlackEagle <ike.devolder@gmail.com>
---
 kernel/common/inc/nv-linux.h                  |  3 ++
 kernel/conftest.sh                            | 29 +++++++++++++++++--
 .../nvidia-drm/nvidia-drm-gem-user-memory.c   | 10 +++++--
 3 files changed, 38 insertions(+), 4 deletions(-)

diff --git a/kernel/common/inc/nv-linux.h b/kernel/common/inc/nv-linux.h
index 30afd4a..c9e5af7 100644
--- a/kernel/common/inc/nv-linux.h
+++ b/kernel/common/inc/nv-linux.h
@@ -179,6 +179,9 @@ static inline uid_t __kuid_val(kuid_t uid)
 #include <linux/dma-mapping.h>
 #else
 #include <linux/dma-direct.h>
+#if defined(NV_LINUX_DMA_MAP_OPS_H_PRESENT)
+#include <linux/dma-map-ops.h>
+#endif
 #endif
 #endif
 
diff --git a/kernel/conftest.sh b/kernel/conftest.sh
index 9612796..1c1eb30 100755
--- a/kernel/conftest.sh
+++ b/kernel/conftest.sh
@@ -134,6 +134,7 @@ test_headers() {
     FILES="$FILES linux/fence.h"
     FILES="$FILES linux/ktime.h"
     FILES="$FILES linux/dma-resv.h"
+    FILES="$FILES linux/dma-map-ops.h"
 
     # Arch specific headers which need testing
     FILES_ARCH="asm/book3s/64/hash-64k.h"
@@ -2050,6 +2051,9 @@ compile_test() {
             #include <linux/dma-mapping.h>
 #else
             #include <linux/dma-direct.h>
+#if defined(NV_LINUX_DMA_MAP_OPS_H_PRESENT)
+            #include <linux/dma-map-ops.h>
+#endif
 #endif
             void conftest_phys_to_dma(void) {
                 phys_to_dma();
@@ -2064,6 +2068,9 @@ compile_test() {
             #
             CODE="
             #include <linux/dma-mapping.h>
+#if defined(NV_LINUX_DMA_MAP_OPS_H_PRESENT)
+            #include <linux/dma-map-ops.h>
+#endif
             void conftest_dma_ops(void) {
                 (void)dma_ops;
             }"
@@ -2078,6 +2085,9 @@ compile_test() {
             #
             CODE="
             #include <linux/dma-mapping.h>
+#if defined(NV_LINUX_DMA_MAP_OPS_H_PRESENT)
+            #include <linux/dma-map-ops.h>
+#endif
             void conftest_dma_ops(void) {
                 (void)swiotlb_dma_ops;
             }"
@@ -2088,22 +2098,28 @@ compile_test() {
         dma_map_ops)
             #
             # Determine if the 'struct dma_map_ops' type is present.
-            # 
+            #
             CODE="
             #include <linux/dma-mapping.h>
+#if defined(NV_LINUX_DMA_MAP_OPS_H_PRESENT)
+            #include <linux/dma-map-ops.h>
+#endif
             void conftest_dma_map_ops(void) {
                 struct dma_map_ops ops;
             }"
 
             compile_check_conftest "$CODE" "NV_DMA_MAP_OPS_PRESENT" "" "types"
         ;;
- 
+
         get_dma_ops)
             #
             # Determine if the get_dma_ops() function is present.
             #
             CODE="
             #include <linux/dma-mapping.h>
+#if defined(NV_LINUX_DMA_MAP_OPS_H_PRESENT)
+            #include <linux/dma-map-ops.h>
+#endif
             void conftest_get_dma_ops(void) {
                 get_dma_ops();
             }"
@@ -2117,6 +2133,9 @@ compile_test() {
             #
             CODE="
             #include <linux/dma-mapping.h>
+#if defined(NV_LINUX_DMA_MAP_OPS_H_PRESENT)
+            #include <linux/dma-map-ops.h>
+#endif
             void conftest_noncoherent_swiotlb_dma_ops(void) {
                 (void)noncoherent_swiotlb_dma_ops;
             }"
@@ -2133,6 +2152,9 @@ compile_test() {
             #
             CODE="
             #include <linux/dma-mapping.h>
+#if defined(NV_LINUX_DMA_MAP_OPS_H_PRESENT)
+            #include <linux/dma-map-ops.h>
+#endif
             void conftest_dma_map_resource(void) {
                 dma_map_resource();
             }"
@@ -3961,6 +3983,9 @@ compile_test() {
             #
             CODE="
             #include <linux/dma-mapping.h>
+#if defined(NV_LINUX_DMA_MAP_OPS_H_PRESENT)
+            #include <linux/dma-map-ops.h>
+#endif
             void conftest_dma_is_direct(void) {
                 dma_is_direct();
             }"
diff --git a/kernel/nvidia-drm/nvidia-drm-gem-user-memory.c b/kernel/nvidia-drm/nvidia-drm-gem-user-memory.c
index 76dedba..92a5192 100644
--- a/kernel/nvidia-drm/nvidia-drm-gem-user-memory.c
+++ b/kernel/nvidia-drm/nvidia-drm-gem-user-memory.c
@@ -20,6 +20,7 @@
  * DEALINGS IN THE SOFTWARE.
  */
 
+#include <linux/version.h>
 #include "nvidia-drm-conftest.h"
 
 #if defined(NV_DRM_AVAILABLE)
@@ -47,8 +48,13 @@ static struct sg_table *__nv_drm_gem_user_memory_prime_get_sg_table(
 {
     struct nv_drm_gem_user_memory *nv_user_memory = to_nv_user_memory(nv_gem);
 
-    return drm_prime_pages_to_sg(nv_user_memory->pages,
-                                 nv_user_memory->pages_count);
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 10, 0))
+    return drm_prime_pages_to_sg(nv_gem->nv_dev->dev, nv_user_memory->pages,
+                                  nv_user_memory->pages_count);
+#else
+     return drm_prime_pages_to_sg(nv_user_memory->pages,
+                                  nv_user_memory->pages_count);
+#endif
 }
 
 static void *__nv_drm_gem_user_memory_prime_vmap(
-- 
2.29.2