]> git.pld-linux.org Git - packages/xorg-driver-video-nvidia-legacy-340xx.git/blame - kernel-5.6.patch
- updated hardware list
[packages/xorg-driver-video-nvidia-legacy-340xx.git] / kernel-5.6.patch
CommitLineData
02d0141d
JR
1diff --git a/kernel/Makefile b/kernel/Makefile
2index 125a690..a36cc63 100644
3--- a/kernel/Makefile
4+++ b/kernel/Makefile
5@@ -108,12 +108,14 @@ COMPILE_TESTS = \
6 acquire_console_sem \
7 console_lock \
8 kmem_cache_create \
9+ kmem_cache_create_usercopy \
10 outer_flush_all \
11 on_each_cpu \
12 smp_call_function \
13 nvmap_support \
14 acpi_evaluate_integer \
15 ioremap_cache \
16+ ioremap_nocache \
17 ioremap_wc \
18 proc_dir_entry \
19 INIT_WORK \
20@@ -122,6 +124,7 @@ COMPILE_TESTS = \
21 pci_domain_nr \
22 pci_dma_mapping_error \
23 file_operations \
24+ proc_ops \
25 sg_alloc_table \
26 sg_init_table \
27 pci_get_domain_bus_and_slot \
28diff --git a/kernel/conftest.sh b/kernel/conftest.sh
29index b7a85f0..83700ad 100755
30--- a/kernel/conftest.sh
31+++ b/kernel/conftest.sh
32@@ -914,6 +914,21 @@ compile_test() {
33 fi
34 ;;
35
36+ kmem_cache_create_usercopy)
37+ #
38+ # Determine if the kmem_cache_create_usercopy function exists.
39+ #
40+ # This function was added by:
41+ # 2017-06-10 8eb8284b412906181357c2b0110d879d5af95e52
42+ CODE="
43+ #include <linux/slab.h>
44+ void kmem_cache_create_usercopy(void) {
45+ kmem_cache_create_usercopy();
46+ }"
47+
48+ compile_check_conftest "$CODE" "NV_KMEM_CACHE_CREATE_USERCOPY_PRESENT" "" "functions"
49+ ;;
50+
51 smp_call_function)
52 #
53 # Determine if the smp_call_function() function is
54@@ -1188,6 +1203,22 @@ compile_test() {
55 compile_check_conftest "$CODE" "NV_IOREMAP_CACHE_PRESENT" "" "functions"
56 ;;
57
58+ ioremap_nocache)
59+ #
60+ # Determine if the ioremap_nocache() function is present.
61+ #
62+ # Removed by commit 4bdc0d676a64 ("remove ioremap_nocache and
63+ # devm_ioremap_nocache") in v5.6 (2020-01-06)
64+ #
65+ CODE="
66+ #include <asm/io.h>
67+ void conftest_ioremap_nocache(void) {
68+ ioremap_nocache();
69+ }"
70+
71+ compile_check_conftest "$CODE" "NV_IOREMAP_NOCACHE_PRESENT" "" "functions"
72+ ;;
73+
74 ioremap_wc)
75 #
76 # Determine if the ioremap_wc() function is present.
77@@ -1371,6 +1402,16 @@ compile_test() {
78 compile_check_conftest "$CODE" "NV_FILE_OPERATIONS_HAS_COMPAT_IOCTL" "" "types"
79 ;;
80
81+ proc_ops)
82+ CODE="
83+ #include <linux/proc_fs.h>
84+ int conftest_proc_ops(void) {
85+ return offsetof(struct proc_ops, proc_open);
86+ }"
87+
88+ compile_check_conftest "$CODE" "NV_HAVE_PROC_OPS" "" "types"
89+ ;;
90+
91 sg_init_table)
92 #
93 # Determine if the sg_init_table() function is present.
94diff --git a/kernel/dkms.conf b/kernel/dkms.conf
95index 79a02ae..3140f03 100644
96--- a/kernel/dkms.conf
97+++ b/kernel/dkms.conf
98@@ -1,7 +1,13 @@
99+if [ -x /usr/bin/nproc ]; then
100+ num_cpu_cores=$(nproc)
101+else
102+ num_cpu_cores=1
103+fi
104+
105 PACKAGE_NAME="nvidia"
106 PACKAGE_VERSION="340.108"
107 BUILT_MODULE_NAME[0]="$PACKAGE_NAME"
108 DEST_MODULE_LOCATION[0]="/kernel/drivers/video"
109-MAKE[0]="make module KERNEL_UNAME=${kernelver}"
110+MAKE[0]="make -j$num_cpu_cores module KERNEL_UNAME=${kernelver}"
111 CLEAN="make clean"
112 AUTOINSTALL="yes"
113diff --git a/kernel/nv-drm.c b/kernel/nv-drm.c
114index 0d1cdbf..2e4b867 100644
115--- a/kernel/nv-drm.c
116+++ b/kernel/nv-drm.c
117@@ -50,6 +50,60 @@
118 #if defined(NV_DRM_LEGACY_PCI_INIT_PRESENT)
119 #define nv_drm_pci_init drm_legacy_pci_init
120 #define nv_drm_pci_exit drm_legacy_pci_exit
121+#elif LINUX_VERSION_CODE >= KERNEL_VERSION(5, 6, 0)
122+int nv_drm_pci_init(struct drm_driver *driver, struct pci_driver *pdriver)
123+{
124+ struct pci_dev *pdev = NULL;
125+ const struct pci_device_id *pid;
126+ int i;
127+
128+ DRM_DEBUG("\n");
129+
130+ if (WARN_ON(!(driver->driver_features & DRIVER_LEGACY)))
131+ return -EINVAL;
132+
133+ /* If not using KMS, fall back to stealth mode manual scanning. */
134+ INIT_LIST_HEAD(&driver->legacy_dev_list);
135+ for (i = 0; pdriver->id_table[i].vendor != 0; i++) {
136+ pid = &pdriver->id_table[i];
137+
138+ /* Loop around setting up a DRM device for each PCI device
139+ * matching our ID and device class. If we had the internal
140+ * function that pci_get_subsys and pci_get_class used, we'd
141+ * be able to just pass pid in instead of doing a two-stage
142+ * thing.
143+ */
144+ pdev = NULL;
145+ while ((pdev =
146+ pci_get_subsys(pid->vendor, pid->device, pid->subvendor,
147+ pid->subdevice, pdev)) != NULL) {
148+ if ((pdev->class & pid->class_mask) != pid->class)
149+ continue;
150+
151+ /* stealth mode requires a manual probe */
152+ pci_dev_get(pdev);
153+ drm_get_pci_dev(pdev, pid, driver);
154+ }
155+ }
156+ return 0;
157+}
158+
159+void nv_drm_pci_exit(struct drm_driver *driver, struct pci_driver *pdriver)
160+{
161+ struct drm_device *dev, *tmp;
162+ DRM_DEBUG("\n");
163+
164+ if (!(driver->driver_features & DRIVER_LEGACY)) {
165+ WARN_ON(1);
166+ } else {
167+ list_for_each_entry_safe(dev, tmp, &driver->legacy_dev_list,
168+ legacy_dev_list) {
169+ list_del(&dev->legacy_dev_list);
170+ drm_put_dev(dev);
171+ }
172+ }
173+ DRM_INFO("Module unloaded\n");
174+}
175 #else
176 #define nv_drm_pci_init drm_pci_init
177 #define nv_drm_pci_exit drm_pci_exit
178diff --git a/kernel/nv-linux.h b/kernel/nv-linux.h
179index a1d2c68..83e6433 100644
180--- a/kernel/nv-linux.h
181+++ b/kernel/nv-linux.h
182@@ -688,11 +688,16 @@ extern nv_spinlock_t km_lock;
183 VM_ALLOC_RECORD(ptr, size, "vm_ioremap"); \
184 }
185
186+#if defined(NV_IOREMAP_NOCACHE_PRESENT)
187 #define NV_IOREMAP_NOCACHE(ptr, physaddr, size) \
188 { \
189 (ptr) = ioremap_nocache(physaddr, size); \
190 VM_ALLOC_RECORD(ptr, size, "vm_ioremap_nocache"); \
191 }
192+#else
193+#define NV_IOREMAP_NOCACHE(ptr, physaddr, size) \
194+ NV_IOREMAP(ptr, physaddr, size)
195+#endif
196
197 #if defined(NV_IOREMAP_CACHE_PRESENT)
198 #define NV_IOREMAP_CACHE(ptr, physaddr, size) \
199@@ -774,6 +779,17 @@ extern nv_spinlock_t km_lock;
200 #error "NV_KMEM_CACHE_CREATE() undefined (kmem_cache_create() unavailable)!"
201 #endif
202
203+#if defined(NV_KMEM_CACHE_CREATE_USERCOPY_PRESENT)
204+#define NV_KMEM_CACHE_CREATE_USERCOPY(kmem_cache, name, type) \
205+ { \
206+ kmem_cache = kmem_cache_create_usercopy(name, sizeof(type), \
207+ 0, 0, 0, sizeof(type), NULL); \
208+ }
209+#else
210+#define NV_KMEM_CACHE_CREATE_USERCOPY(kmem_cache, name, type) \
211+ NV_KMEM_CACHE_CREATE(kmem_cache, name, type)
212+#endif
213+
214 #define NV_KMEM_CACHE_ALLOC(ptr, kmem_cache, type) \
215 { \
216 (ptr) = kmem_cache_alloc(kmem_cache, GFP_KERNEL); \
217@@ -1971,6 +1987,19 @@ extern NvU32 nv_assign_gpu_count;
218 })
219 #endif
220
221+#if defined(NV_HAVE_PROC_OPS)
222+#define NV_CREATE_PROC_FILE(filename,parent,__name,__data) \
223+ ({ \
224+ struct proc_dir_entry *__entry; \
225+ int mode = (S_IFREG | S_IRUGO); \
226+ const struct proc_ops *fops = &nv_procfs_##__name##_fops; \
227+ if (fops->proc_write != 0) \
228+ mode |= S_IWUSR; \
229+ __entry = NV_CREATE_PROC_ENTRY(filename, mode, parent, fops, \
230+ __data); \
231+ __entry; \
232+ })
233+#else
234 #define NV_CREATE_PROC_FILE(filename,parent,__name,__data) \
235 ({ \
236 struct proc_dir_entry *__entry; \
237@@ -1982,6 +2011,7 @@ extern NvU32 nv_assign_gpu_count;
238 __data); \
239 __entry; \
240 })
241+#endif
242
243 /*
244 * proc_mkdir_mode exists in Linux 2.6.9, but isn't exported until Linux 3.0.
245@@ -2023,6 +2053,24 @@ extern NvU32 nv_assign_gpu_count;
246 remove_proc_entry(entry->name, entry->parent);
247 #endif
248
249+#if defined(NV_HAVE_PROC_OPS)
250+#define NV_DEFINE_PROCFS_SINGLE_FILE(__name) \
251+ static int nv_procfs_open_##__name( \
252+ struct inode *inode, \
253+ struct file *filep \
254+ ) \
255+ { \
256+ return single_open(filep, nv_procfs_read_##__name, \
257+ NV_PDE_DATA(inode)); \
258+ } \
259+ \
260+ static const struct proc_ops nv_procfs_##__name##_fops = { \
261+ .proc_open = nv_procfs_open_##__name, \
262+ .proc_read = seq_read, \
263+ .proc_lseek = seq_lseek, \
264+ .proc_release = single_release, \
265+ };
266+#else
267 #define NV_DEFINE_PROCFS_SINGLE_FILE(__name) \
268 static int nv_procfs_open_##__name( \
269 struct inode *inode, \
270@@ -2040,6 +2088,7 @@ extern NvU32 nv_assign_gpu_count;
271 .llseek = seq_lseek, \
272 .release = single_release, \
273 };
274+#endif
275
276 #endif /* CONFIG_PROC_FS */
277
278diff --git a/kernel/nv-procfs.c b/kernel/nv-procfs.c
279index ebca3e8..9365c3c 100644
280--- a/kernel/nv-procfs.c
281+++ b/kernel/nv-procfs.c
282@@ -409,6 +409,15 @@ done:
283 return ((status < 0) ? status : (int)count);
284 }
285
286+#if defined(NV_HAVE_PROC_OPS)
287+static struct proc_ops nv_procfs_registry_fops = {
288+ .proc_open = nv_procfs_open_registry,
289+ .proc_read = seq_read,
290+ .proc_write = nv_procfs_write_file,
291+ .proc_lseek = seq_lseek,
292+ .proc_release = nv_procfs_close_registry,
293+};
294+#else
295 static struct file_operations nv_procfs_registry_fops = {
296 .owner = THIS_MODULE,
297 .open = nv_procfs_open_registry,
298@@ -417,6 +426,7 @@ static struct file_operations nv_procfs_registry_fops = {
299 .llseek = seq_lseek,
300 .release = nv_procfs_close_registry,
301 };
302+#endif
303
304 static int
305 nv_procfs_read_unbind_lock(
306@@ -538,6 +548,15 @@ done:
307 return rc;
308 }
309
310+#if defined(NV_HAVE_PROC_OPS)
311+static struct proc_ops nv_procfs_unbind_lock_fops = {
312+ .proc_open = nv_procfs_open_unbind_lock,
313+ .proc_read = seq_read,
314+ .proc_write = nv_procfs_write_file,
315+ .proc_lseek = seq_lseek,
316+ .proc_release = nv_procfs_close_unbind_lock,
317+};
318+#else
319 static struct file_operations nv_procfs_unbind_lock_fops = {
320 .owner = THIS_MODULE,
321 .open = nv_procfs_open_unbind_lock,
322@@ -546,6 +565,7 @@ static struct file_operations nv_procfs_unbind_lock_fops = {
323 .llseek = seq_lseek,
324 .release = nv_procfs_close_unbind_lock,
325 };
326+#endif
327
328 static int
329 nv_procfs_read_text_file(
330diff --git a/kernel/nv-time.h b/kernel/nv-time.h
331index a34ceb2..780f8bc 100644
332--- a/kernel/nv-time.h
333+++ b/kernel/nv-time.h
1ad679c0 334@@ -28,7 +28,16 @@
02d0141d
JR
335 #include <linux/ktime.h>
336 #endif
337
338-static inline void nv_gettimeofday(struct timeval *tv)
1ad679c0
JR
339+#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 6, 0)
340+#define nv_timeval timeval
341+#else
02d0141d
JR
342+struct nv_timeval {
343+ __kernel_long_t tv_sec;
344+ __kernel_suseconds_t tv_usec;
345+};
1ad679c0 346+#endif
02d0141d
JR
347+
348+static inline void nv_gettimeofday(struct nv_timeval *tv)
349 {
350 #ifdef NV_DO_GETTIMEOFDAY_PRESENT
351 do_gettimeofday(tv);
352@@ -37,7 +42,7 @@ static inline void nv_gettimeofday(struct timeval *tv)
353
354 ktime_get_real_ts64(&now);
355
356- *tv = (struct timeval) {
357+ *tv = (struct nv_timeval) {
358 .tv_sec = now.tv_sec,
359 .tv_usec = now.tv_nsec/1000,
360 };
361diff --git a/kernel/nv.c b/kernel/nv.c
362index a167be9..a218f83 100644
363--- a/kernel/nv.c
364+++ b/kernel/nv.c
365@@ -752,7 +752,7 @@ int __init nvidia_init_module(void)
366 NV_SPIN_LOCK_INIT(&km_lock);
367 #endif
368
369- NV_KMEM_CACHE_CREATE(nv_stack_t_cache, NV_STACK_CACHE_STR, nv_stack_t);
370+ NV_KMEM_CACHE_CREATE_USERCOPY(nv_stack_t_cache, NV_STACK_CACHE_STR, nv_stack_t);
371 if (nv_stack_t_cache == NULL)
372 {
373 nv_printf(NV_DBG_ERRORS, "NVRM: stack cache allocation failed!\n");
374diff --git a/kernel/os-interface.c b/kernel/os-interface.c
375index 7190b26..0c0dc05 100644
376--- a/kernel/os-interface.c
377+++ b/kernel/os-interface.c
378@@ -439,7 +439,7 @@ RM_STATUS NV_API_CALL os_get_current_time(
379 NvU32 *useconds
380 )
381 {
382- struct timeval tm;
383+ struct nv_timeval tm;
384
385 nv_gettimeofday(&tm);
386
387@@ -474,7 +474,7 @@ RM_STATUS NV_API_CALL os_delay_us(NvU32 MicroSeconds)
388 unsigned long usec;
389
390 #ifdef NV_CHECK_DELAY_ACCURACY
391- struct timeval tm1, tm2;
392+ struct nv_timeval tm1, tm2;
393
394 nv_gettimeofday(&tm1);
395 #endif
396@@ -514,9 +514,9 @@ RM_STATUS NV_API_CALL os_delay(NvU32 MilliSeconds)
397 unsigned long MicroSeconds;
398 unsigned long jiffies;
399 unsigned long mdelay_safe_msec;
400- struct timeval tm_end, tm_aux;
401+ struct nv_timeval tm_end, tm_aux;
402 #ifdef NV_CHECK_DELAY_ACCURACY
403- struct timeval tm_start;
404+ struct nv_timeval tm_start;
405 #endif
406
407 nv_gettimeofday(&tm_aux);
408diff --git a/kernel/uvm/Makefile b/kernel/uvm/Makefile
409index 0cad8ff..043a08d 100644
410--- a/kernel/uvm/Makefile
411+++ b/kernel/uvm/Makefile
412@@ -207,6 +207,7 @@ ccflags-y += $(EXTRA_CFLAGS)
413
414 RM_MODULE_SYMVERS:= $(RM_OUT_DIR)/Module.symvers
415 UVM_MODULE_SYMVERS:= $(obj)/Module.symvers
416+KBUILD_EXTRA_SYMBOLS:= $(UVM_MODULE_SYMVERS)
417
418 module $(MODULE_NAME).ko: $(UVM_MODULE_SYMVERS) debug_diagnostics_printing
419
420diff --git a/kernel/uvm/nvidia_uvm_lite.c b/kernel/uvm/nvidia_uvm_lite.c
421index 6943e7c..9a7e3b6 100644
422--- a/kernel/uvm/nvidia_uvm_lite.c
423+++ b/kernel/uvm/nvidia_uvm_lite.c
424@@ -131,8 +131,8 @@ static
425 RM_STATUS _preexisting_error_on_channel(UvmGpuMigrationTracking *pMigTracker,
426 UvmCommitRecord *pRecord);
427
428-static void _set_timeout_in_usec(struct timeval *src,
429- struct timeval *result,
430+static void _set_timeout_in_usec(struct nv_timeval *src,
431+ struct nv_timeval *result,
432 unsigned long timeoutInUsec)
433 {
434 if (!src || !result)
435@@ -820,7 +820,13 @@ done:
436 }
437
438 #if defined(NV_VM_OPERATIONS_STRUCT_HAS_FAULT)
439+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 17, 0)
440+vm_fault_t _fault(struct vm_fault *vmf)
441+#elif LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0)
442+int _fault(struct vm_fault *vmf)
443+#else
444 int _fault(struct vm_area_struct *vma, struct vm_fault *vmf)
445+#endif
446 {
447 #if defined(NV_VM_FAULT_HAS_ADDRESS)
448 unsigned long vaddr = vmf->address;
449@@ -828,8 +834,15 @@ int _fault(struct vm_area_struct *vma, struct vm_fault *vmf)
450 unsigned long vaddr = (unsigned long)vmf->virtual_address;
451 #endif
452 struct page *page = NULL;
453+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 17, 0)
454+ vm_fault_t retval;
455+#else
456 int retval;
457
458+#endif
459+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0)
460+ struct vm_area_struct *vma = vmf->vma;
461+#endif
462 retval = _fault_common(vma, vaddr, &page, vmf->flags);
463
464 vmf->page = page;
465@@ -868,7 +881,13 @@ static struct vm_operations_struct uvmlite_vma_ops =
466 // it's dealing with anonymous mapping (see handle_pte_fault).
467 //
468 #if defined(NV_VM_OPERATIONS_STRUCT_HAS_FAULT)
469+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 17, 0)
470+vm_fault_t _sigbus_fault(struct vm_fault *vmf)
471+#elif LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0)
472+int _sigbus_fault(struct vm_fault *vmf)
473+#else
474 int _sigbus_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
475+#endif
476 {
477 vmf->page = NULL;
478 return VM_FAULT_SIGBUS;
479@@ -1992,9 +2011,9 @@ void umvlite_destroy_per_process_gpu_resources(UvmGpuUuid *gpuUuidStruct)
480 static RM_STATUS _check_ecc_errors(UvmGpuMigrationTracking *pMigTracker,
481 NvBool *pIsEccErrorSet)
482 {
483- struct timeval eccErrorStartTime = {0};
484- struct timeval eccErrorCurrentTime = {0};
485- struct timeval eccTimeout = {0};
486+ struct nv_timeval eccErrorStartTime = {0};
487+ struct nv_timeval eccErrorCurrentTime = {0};
488+ struct nv_timeval eccTimeout = {0};
489 NvBool bEccErrorTimeout = NV_FALSE;
490 NvBool bEccIncomingError = NV_FALSE;
491 unsigned rmInterruptSet = 0;
This page took 0.081381 seconds and 4 git commands to generate.