]>
Commit | Line | Data |
---|---|---|
47227e12 JR |
1 | diff --git a/kernel/common/inc/nv-linux.h b/kernel/common/inc/nv-linux.h |
2 | index 85041c2..ac5bb95 100644 | |
3 | --- a/kernel/common/inc/nv-linux.h | |
4 | +++ b/kernel/common/inc/nv-linux.h | |
5 | @@ -553,7 +553,11 @@ static inline void *nv_ioremap(NvU64 phys, NvU64 size) | |
6 | ||
7 | static inline void *nv_ioremap_nocache(NvU64 phys, NvU64 size) | |
8 | { | |
9 | +#if defined(NV_IOREMAP_NOCACHE_PRESENT) | |
10 | void *ptr = ioremap_nocache(phys, size); | |
11 | +#else | |
12 | + void *ptr = ioremap(phys, size); | |
13 | +#endif | |
14 | if (ptr) | |
15 | NV_MEMDBG_ADD(ptr, size); | |
16 | return ptr; | |
17 | diff --git a/kernel/common/inc/nv-procfs.h b/kernel/common/inc/nv-procfs.h | |
18 | index 3c812ea..e57c4f9 100644 | |
19 | --- a/kernel/common/inc/nv-procfs.h | |
20 | +++ b/kernel/common/inc/nv-procfs.h | |
21 | @@ -52,6 +52,19 @@ | |
22 | }) | |
23 | #endif | |
24 | ||
25 | +#if defined(NV_HAVE_PROC_OPS) | |
26 | +#define NV_CREATE_PROC_FILE(filename,parent,__name,__data) \ | |
27 | + ({ \ | |
28 | + struct proc_dir_entry *__entry; \ | |
29 | + int mode = (S_IFREG | S_IRUGO); \ | |
30 | + const struct proc_ops *fops = &nv_procfs_##__name##_fops; \ | |
31 | + if (fops->proc_write != 0) \ | |
32 | + mode |= S_IWUSR; \ | |
33 | + __entry = NV_CREATE_PROC_ENTRY(filename, mode, parent, fops, \ | |
34 | + __data); \ | |
35 | + __entry; \ | |
36 | + }) | |
37 | +#else | |
38 | #define NV_CREATE_PROC_FILE(filename,parent,__name,__data) \ | |
39 | ({ \ | |
40 | struct proc_dir_entry *__entry; \ | |
41 | @@ -63,6 +76,7 @@ | |
42 | __data); \ | |
43 | __entry; \ | |
44 | }) | |
45 | +#endif | |
46 | ||
47 | /* | |
48 | * proc_mkdir_mode exists in Linux 2.6.9, but isn't exported until Linux 3.0. | |
49 | @@ -104,6 +118,24 @@ | |
50 | remove_proc_entry(entry->name, entry->parent); | |
51 | #endif | |
52 | ||
53 | +#if defined(NV_HAVE_PROC_OPS) | |
54 | +#define NV_DEFINE_PROCFS_SINGLE_FILE(__name) \ | |
55 | + static int nv_procfs_open_##__name( \ | |
56 | + struct inode *inode, \ | |
57 | + struct file *filep \ | |
58 | + ) \ | |
59 | + { \ | |
60 | + return single_open(filep, nv_procfs_read_##__name, \ | |
61 | + NV_PDE_DATA(inode)); \ | |
62 | + } \ | |
63 | + \ | |
64 | + static const struct proc_ops nv_procfs_##__name##_fops = { \ | |
65 | + .proc_open = nv_procfs_open_##__name, \ | |
66 | + .proc_read = seq_read, \ | |
67 | + .proc_lseek = seq_lseek, \ | |
68 | + .proc_release = single_release, \ | |
69 | + }; | |
70 | +#else | |
71 | #define NV_DEFINE_PROCFS_SINGLE_FILE(__name) \ | |
72 | static int nv_procfs_open_##__name( \ | |
73 | struct inode *inode, \ | |
74 | @@ -121,6 +153,7 @@ | |
75 | .llseek = seq_lseek, \ | |
76 | .release = single_release, \ | |
77 | }; | |
78 | +#endif | |
79 | ||
80 | #endif /* CONFIG_PROC_FS */ | |
81 | ||
82 | diff --git a/kernel/common/inc/nv-time.h b/kernel/common/inc/nv-time.h | |
83 | index 2c799c9..0206062 100644 | |
84 | --- a/kernel/common/inc/nv-time.h | |
85 | +++ b/kernel/common/inc/nv-time.h | |
0d7fb07c | 86 | @@ -30,7 +30,17 @@ |
47227e12 JR |
87 | #include <linux/ktime.h> |
88 | #endif | |
89 | ||
90 | -static inline void nv_gettimeofday(struct timeval *tv) | |
0d7fb07c JR |
91 | +#include <linux/version.h> |
92 | +#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 6, 0) | |
93 | +#define nv_timeval timeval | |
94 | +#else | |
47227e12 JR |
95 | +struct nv_timeval { |
96 | + __kernel_long_t tv_sec; | |
97 | + __kernel_suseconds_t tv_usec; | |
98 | +}; | |
0d7fb07c | 99 | +#endif |
47227e12 JR |
100 | + |
101 | +static inline void nv_gettimeofday(struct nv_timeval *tv) | |
102 | { | |
103 | #ifdef NV_DO_GETTIMEOFDAY_PRESENT | |
104 | do_gettimeofday(tv); | |
105 | @@ -39,7 +44,7 @@ static inline void nv_gettimeofday(struct timeval *tv) | |
106 | ||
107 | ktime_get_real_ts64(&now); | |
108 | ||
109 | - *tv = (struct timeval) { | |
110 | + *tv = (struct nv_timeval) { | |
111 | .tv_sec = now.tv_sec, | |
112 | .tv_usec = now.tv_nsec/1000, | |
113 | }; | |
114 | diff --git a/kernel/conftest.sh b/kernel/conftest.sh | |
115 | index ec9e093..463a464 100755 | |
116 | --- a/kernel/conftest.sh | |
117 | +++ b/kernel/conftest.sh | |
118 | @@ -1197,6 +1197,22 @@ compile_test() { | |
119 | compile_check_conftest "$CODE" "NV_IOREMAP_CACHE_PRESENT" "" "functions" | |
120 | ;; | |
121 | ||
122 | + ioremap_nocache) | |
123 | + # | |
124 | + # Determine if the ioremap_nocache() function is present. | |
125 | + # | |
126 | + # Removed by commit 4bdc0d676a64 ("remove ioremap_nocache and | |
127 | + # devm_ioremap_nocache") in v5.6 (2020-01-06) | |
128 | + # | |
129 | + CODE=" | |
130 | + #include <asm/io.h> | |
131 | + void conftest_ioremap_nocache(void) { | |
132 | + ioremap_nocache(); | |
133 | + }" | |
134 | + | |
135 | + compile_check_conftest "$CODE" "NV_IOREMAP_NOCACHE_PRESENT" "" "functions" | |
136 | + ;; | |
137 | + | |
138 | ioremap_wc) | |
139 | # | |
140 | # Determine if the ioremap_wc() function is present. | |
141 | @@ -1430,6 +1446,31 @@ compile_test() { | |
142 | compile_check_conftest "$CODE" "NV_SG_ALLOC_TABLE_FROM_PAGES_PRESENT" "" "functions" | |
143 | ;; | |
144 | ||
145 | + proc_ops) | |
146 | + CODE=" | |
147 | + #include <linux/proc_fs.h> | |
148 | + int conftest_proc_ops(void) { | |
149 | + return offsetof(struct proc_ops, proc_open); | |
150 | + }" | |
151 | + | |
152 | + compile_check_conftest "$CODE" "NV_HAVE_PROC_OPS" "" "types" | |
153 | + ;; | |
154 | + | |
155 | + ktime_get_raw_ts64) | |
156 | + # | |
157 | + # Determine if the ktime_get_raw_ts64() function is present. | |
158 | + # | |
159 | + CODE=" | |
160 | + #include <linux/ktime.h> | |
161 | + int conftest_ktime_get_raw_ts64(void) { | |
162 | + struct timespec64 ts = {0}; | |
163 | + | |
0d7fb07c | 164 | + ktime_get_raw_ts64(&ts); |
47227e12 JR |
165 | + }" |
166 | + | |
0d7fb07c | 167 | + compile_check_conftest "$CODE" "NV_KTIME_GET_RAW_TS64_PRESENT" "" "types" |
47227e12 JR |
168 | + ;; |
169 | + | |
170 | efi_enabled) | |
171 | # | |
172 | # Determine if the efi_enabled symbol is present, or if | |
173 | diff --git a/kernel/nvidia-modeset/nvidia-modeset-linux.c b/kernel/nvidia-modeset/nvidia-modeset-linux.c | |
174 | index d42aabb..f0404fb 100644 | |
175 | --- a/kernel/nvidia-modeset/nvidia-modeset-linux.c | |
176 | +++ b/kernel/nvidia-modeset/nvidia-modeset-linux.c | |
177 | @@ -216,7 +216,7 @@ void NVKMS_API_CALL nvkms_usleep(NvU64 usec) | |
178 | ||
179 | NvU64 NVKMS_API_CALL nvkms_get_usec(void) | |
180 | { | |
181 | - struct timeval tv; | |
182 | + struct nv_timeval tv; | |
183 | ||
184 | nv_gettimeofday(&tv); | |
185 | ||
186 | diff --git a/kernel/nvidia-uvm/uvm_linux.h b/kernel/nvidia-uvm/uvm_linux.h | |
187 | index 8784a82..c256cdb 100644 | |
188 | --- a/kernel/nvidia-uvm/uvm_linux.h | |
189 | +++ b/kernel/nvidia-uvm/uvm_linux.h | |
190 | @@ -329,7 +329,16 @@ static inline uint64_t NV_DIV64(uint64_t dividend, uint64_t divisor, uint64_t *r | |
191 | } | |
192 | #endif | |
193 | ||
194 | -#if defined(CLOCK_MONOTONIC_RAW) | |
195 | +#if defined(NV_KTIME_GET_RAW_TS64_PRESENT) | |
196 | +static inline NvU64 NV_GETTIME(void) | |
197 | +{ | |
198 | + struct timespec64 ts64 = {0}; | |
199 | + | |
200 | + ktime_get_raw_ts64(&ts64); | |
201 | + | |
202 | + return (ts64.tv_sec * 1000000000ULL + ts64.tv_nsec); | |
203 | +} | |
204 | +#elif defined(CLOCK_MONOTONIC_RAW) | |
205 | /* Return a nanosecond-precise value */ | |
206 | static inline NvU64 NV_GETTIME(void) | |
207 | { | |
208 | @@ -345,7 +354,7 @@ static inline NvU64 NV_GETTIME(void) | |
209 | * available non-GPL symbols. */ | |
210 | static inline NvU64 NV_GETTIME(void) | |
211 | { | |
212 | - struct timeval tv = {0}; | |
213 | + struct nv_timeval tv = {0}; | |
214 | ||
215 | nv_gettimeofday(&tv); | |
216 | ||
217 | diff --git a/kernel/nvidia/nv-procfs.c b/kernel/nvidia/nv-procfs.c | |
218 | index 5808a88..bc60a08 100644 | |
219 | --- a/kernel/nvidia/nv-procfs.c | |
220 | +++ b/kernel/nvidia/nv-procfs.c | |
221 | @@ -414,6 +414,15 @@ done: | |
222 | return ((status < 0) ? status : (int)count); | |
223 | } | |
224 | ||
225 | +#if defined(NV_HAVE_PROC_OPS) | |
226 | +static struct proc_ops nv_procfs_registry_fops = { | |
227 | + .proc_open = nv_procfs_open_registry, | |
228 | + .proc_read = seq_read, | |
229 | + .proc_write = nv_procfs_write_file, | |
230 | + .proc_lseek = seq_lseek, | |
231 | + .proc_release = nv_procfs_close_registry, | |
232 | +}; | |
233 | +#else | |
234 | static struct file_operations nv_procfs_registry_fops = { | |
235 | .owner = THIS_MODULE, | |
236 | .open = nv_procfs_open_registry, | |
237 | @@ -422,6 +431,7 @@ static struct file_operations nv_procfs_registry_fops = { | |
238 | .llseek = seq_lseek, | |
239 | .release = nv_procfs_close_registry, | |
240 | }; | |
241 | +#endif | |
242 | ||
243 | /* | |
244 | * Forwards error to nv_log_error which exposes data to vendor callback | |
245 | @@ -517,12 +527,20 @@ done: | |
246 | return status; | |
247 | } | |
248 | ||
249 | +#if defined(NV_HAVE_PROC_OPS) | |
250 | +static struct proc_ops nv_procfs_exercise_error_forwarding_fops = { | |
251 | + .proc_open = nv_procfs_open_exercise_error_forwarding, | |
252 | + .proc_write = nv_procfs_write_file, | |
253 | + .proc_release = nv_procfs_close_exercise_error_forwarding, | |
254 | +}; | |
255 | +#else | |
256 | static struct file_operations nv_procfs_exercise_error_forwarding_fops = { | |
257 | .owner = THIS_MODULE, | |
258 | .open = nv_procfs_open_exercise_error_forwarding, | |
259 | .write = nv_procfs_write_file, | |
260 | .release = nv_procfs_close_exercise_error_forwarding, | |
261 | }; | |
262 | +#endif | |
263 | ||
264 | static int | |
265 | nv_procfs_read_unbind_lock( | |
266 | @@ -650,6 +668,15 @@ done: | |
267 | return rc; | |
268 | } | |
269 | ||
270 | +#if defined(NV_HAVE_PROC_OPS) | |
271 | +static struct proc_ops nv_procfs_unbind_lock_fops = { | |
272 | + .proc_open = nv_procfs_open_unbind_lock, | |
273 | + .proc_read = seq_read, | |
274 | + .proc_write = nv_procfs_write_file, | |
275 | + .proc_lseek = seq_lseek, | |
276 | + .proc_release = nv_procfs_close_unbind_lock, | |
277 | +}; | |
278 | +#else | |
279 | static struct file_operations nv_procfs_unbind_lock_fops = { | |
280 | .owner = THIS_MODULE, | |
281 | .open = nv_procfs_open_unbind_lock, | |
282 | @@ -658,6 +685,7 @@ static struct file_operations nv_procfs_unbind_lock_fops = { | |
283 | .llseek = seq_lseek, | |
284 | .release = nv_procfs_close_unbind_lock, | |
285 | }; | |
286 | +#endif | |
287 | ||
288 | static int | |
289 | nv_procfs_read_text_file( | |
290 | diff --git a/kernel/nvidia/nvidia.Kbuild b/kernel/nvidia/nvidia.Kbuild | |
291 | index 8ae1016..da7f135 100644 | |
292 | --- a/kernel/nvidia/nvidia.Kbuild | |
293 | +++ b/kernel/nvidia/nvidia.Kbuild | |
294 | @@ -117,6 +117,7 @@ NV_CONFTEST_FUNCTION_COMPILE_TESTS += on_each_cpu | |
295 | NV_CONFTEST_FUNCTION_COMPILE_TESTS += smp_call_function | |
296 | NV_CONFTEST_FUNCTION_COMPILE_TESTS += acpi_evaluate_integer | |
297 | NV_CONFTEST_FUNCTION_COMPILE_TESTS += ioremap_cache | |
298 | +NV_CONFTEST_FUNCTION_COMPILE_TESTS += ioremap_nocache | |
299 | NV_CONFTEST_FUNCTION_COMPILE_TESTS += ioremap_wc | |
300 | NV_CONFTEST_FUNCTION_COMPILE_TESTS += acpi_walk_namespace | |
301 | NV_CONFTEST_FUNCTION_COMPILE_TESTS += pci_domain_nr | |
302 | @@ -169,7 +170,9 @@ NV_CONFTEST_TYPE_COMPILE_TESTS += outer_flush_all | |
303 | NV_CONFTEST_TYPE_COMPILE_TESTS += proc_dir_entry | |
304 | NV_CONFTEST_TYPE_COMPILE_TESTS += scatterlist | |
305 | NV_CONFTEST_TYPE_COMPILE_TESTS += sg_table | |
306 | +NV_CONFTEST_TYPE_COMPILE_TESTS += proc_ops | |
307 | NV_CONFTEST_TYPE_COMPILE_TESTS += file_operations | |
308 | +NV_CONFTEST_TYPE_COMPILE_TESTS += ktime_get_raw_ts64 | |
309 | NV_CONFTEST_TYPE_COMPILE_TESTS += vm_operations_struct | |
310 | NV_CONFTEST_TYPE_COMPILE_TESTS += atomic_long_type | |
311 | NV_CONFTEST_TYPE_COMPILE_TESTS += pci_save_state | |
312 | diff --git a/kernel/nvidia/nvlink_linux.c b/kernel/nvidia/nvlink_linux.c | |
313 | index 0014280..537b257 100644 | |
314 | --- a/kernel/nvidia/nvlink_linux.c | |
315 | +++ b/kernel/nvidia/nvlink_linux.c | |
316 | @@ -518,8 +518,8 @@ void * NVLINK_API_CALL nvlink_memcpy(void *dest, void *src, NvLength size) | |
317 | ||
318 | static NvBool nv_timer_less_than | |
319 | ( | |
320 | - const struct timeval *a, | |
321 | - const struct timeval *b | |
322 | + const struct nv_timeval *a, | |
323 | + const struct nv_timeval *b | |
324 | ) | |
325 | { | |
326 | return (a->tv_sec == b->tv_sec) ? (a->tv_usec < b->tv_usec) | |
327 | @@ -528,9 +528,9 @@ static NvBool nv_timer_less_than | |
328 | ||
329 | static void nv_timeradd | |
330 | ( | |
331 | - const struct timeval *a, | |
332 | - const struct timeval *b, | |
333 | - struct timeval *result | |
334 | + const struct nv_timeval *a, | |
335 | + const struct nv_timeval *b, | |
336 | + struct nv_timeval *result | |
337 | ) | |
338 | { | |
339 | result->tv_sec = a->tv_sec + b->tv_sec; | |
340 | @@ -544,9 +544,9 @@ static void nv_timeradd | |
341 | ||
342 | static void nv_timersub | |
343 | ( | |
344 | - const struct timeval *a, | |
345 | - const struct timeval *b, | |
346 | - struct timeval *result | |
347 | + const struct nv_timeval *a, | |
348 | + const struct nv_timeval *b, | |
349 | + struct nv_timeval *result | |
350 | ) | |
351 | { | |
352 | result->tv_sec = a->tv_sec - b->tv_sec; | |
353 | @@ -566,7 +566,7 @@ void NVLINK_API_CALL nvlink_sleep(unsigned int ms) | |
354 | unsigned long us; | |
355 | unsigned long jiffies; | |
356 | unsigned long mdelay_safe_msec; | |
357 | - struct timeval tm_end, tm_aux; | |
358 | + struct nv_timeval tm_end, tm_aux; | |
359 | ||
360 | nv_gettimeofday(&tm_aux); | |
361 | ||
362 | diff --git a/kernel/nvidia/os-interface.c b/kernel/nvidia/os-interface.c | |
363 | index 344daa8..39d0a19 100644 | |
364 | --- a/kernel/nvidia/os-interface.c | |
365 | +++ b/kernel/nvidia/os-interface.c | |
366 | @@ -430,7 +430,7 @@ NV_STATUS NV_API_CALL os_get_current_time( | |
367 | NvU32 *useconds | |
368 | ) | |
369 | { | |
370 | - struct timeval tm; | |
371 | + struct nv_timeval tm; | |
372 | ||
373 | nv_gettimeofday(&tm); | |
374 | ||
375 | @@ -444,9 +444,15 @@ NV_STATUS NV_API_CALL os_get_current_time( | |
376 | ||
377 | void NV_API_CALL os_get_current_tick(NvU64 *nseconds) | |
378 | { | |
379 | +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 5, 0) | |
380 | + struct timespec64 ts; | |
381 | + | |
382 | + jiffies_to_timespec64(jiffies, &ts); | |
383 | +#else | |
384 | struct timespec ts; | |
385 | ||
386 | jiffies_to_timespec(jiffies, &ts); | |
387 | +#endif | |
388 | ||
389 | *nseconds = ((NvU64)ts.tv_sec * NSEC_PER_SEC + (NvU64)ts.tv_nsec); | |
390 | } | |
391 | @@ -502,7 +508,7 @@ NV_STATUS NV_API_CALL os_delay_us(NvU32 MicroSeconds) | |
392 | unsigned long usec; | |
393 | ||
394 | #ifdef NV_CHECK_DELAY_ACCURACY | |
395 | - struct timeval tm1, tm2; | |
396 | + struct nv_timeval tm1, tm2; | |
397 | ||
398 | nv_gettimeofday(&tm1); | |
399 | #endif | |
400 | @@ -542,9 +548,9 @@ NV_STATUS NV_API_CALL os_delay(NvU32 MilliSeconds) | |
401 | unsigned long MicroSeconds; | |
402 | unsigned long jiffies; | |
403 | unsigned long mdelay_safe_msec; | |
404 | - struct timeval tm_end, tm_aux; | |
405 | + struct nv_timeval tm_end, tm_aux; | |
406 | #ifdef NV_CHECK_DELAY_ACCURACY | |
407 | - struct timeval tm_start; | |
408 | + struct nv_timeval tm_start; | |
409 | #endif | |
410 | ||
411 | nv_gettimeofday(&tm_aux); | |
412 | @@ -1926,7 +1932,7 @@ static NV_STATUS NV_API_CALL _os_ipmi_receive_resp | |
413 | { | |
414 | struct ipmi_recv_msg *rx_msg; | |
415 | int err_no; | |
416 | - struct timeval tv; | |
417 | + struct nv_timeval tv; | |
418 | NvU64 start_time; | |
419 | ||
420 | nv_gettimeofday(&tv); |