[vlc] Update to 3.0.12
by Nicolas Chauvet
commit d0ad4ca8bfd27ee0ff61e398b27891705696ff79
Author: Nicolas Chauvet <kwizart(a)gmail.com>
Date: Wed Dec 16 10:10:49 2020 +0100
Update to 3.0.12
vlc.spec | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
---
diff --git a/vlc.spec b/vlc.spec
index c511876..3001a0c 100644
--- a/vlc.spec
+++ b/vlc.spec
@@ -51,7 +51,7 @@ Summary: The cross-platform open-source multimedia framework, player and server
Epoch: 1
Name: vlc
Version: 3.0.12
-Release: 0.4%{?dist}
+Release: 1%{?dist}
License: GPLv2+
URL: https://www.videolan.org
%if 0%{?commit0:1}
@@ -622,6 +622,9 @@ fi || :
%changelog
+* Wed Dec 16 2020 Nicolas Chauvet <kwizart(a)gmail.com> - 1:3.0.12-1
+- Update to 3.0.12
+
* Mon Dec 14 2020 Robert-André Mauchin <zebob.m(a)gmail.com> - 1:3.0.12-0.4
- Rebuild for dav1d SONAME bump
- Add patch to build with GCC 11.0.0
3 years, 11 months
[nvidia-390xx-kmod] Really fixup ARM build
by Henrik Nordström
commit 9bda08a8dc68836f36fa04297cc10cf5fcb8b878
Author: Henrik Nordström <henrik(a)hno.se>
Date: Mon Dec 14 23:40:18 2020 +0100
Really fixup ARM build
nvidia-390xx-kmod.spec | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
---
diff --git a/nvidia-390xx-kmod.spec b/nvidia-390xx-kmod.spec
index d48ab6f..44025f5 100644
--- a/nvidia-390xx-kmod.spec
+++ b/nvidia-390xx-kmod.spec
@@ -78,10 +78,10 @@ tar --use-compress-program xz -xf %{_datadir}/%{name}-%{version}/%{name}-%{versi
%patch11 -p1 -d kernel
%patch12 -p1 -d kernel
%patch13 -p1 -d kernel
-%patch14 -p1 -d kernel
%ifarch i686 x86_64
-%patch15 -p1 -d kernel
+%patch14 -p1 -d kernel
%endif
+%patch15 -p1 -d kernel
%patch16 -p1 -d kernel
%patch17 -p1 -d kernel
%patch18 -p1 -d kernel
3 years, 11 months
[nvidia-390xx-kmod] Fixup ARM build
by Henrik Nordström
commit 2f4921032cf6bd49b3515ee78218e468af97194b
Author: Henrik Nordström <henrik(a)hno.se>
Date: Mon Dec 14 23:31:49 2020 +0100
Fixup ARM build
nvidia-390xx-kmod.spec | 2 ++
1 file changed, 2 insertions(+)
---
diff --git a/nvidia-390xx-kmod.spec b/nvidia-390xx-kmod.spec
index a3e753c..d48ab6f 100644
--- a/nvidia-390xx-kmod.spec
+++ b/nvidia-390xx-kmod.spec
@@ -79,7 +79,9 @@ tar --use-compress-program xz -xf %{_datadir}/%{name}-%{version}/%{name}-%{versi
%patch12 -p1 -d kernel
%patch13 -p1 -d kernel
%patch14 -p1 -d kernel
+%ifarch i686 x86_64
%patch15 -p1 -d kernel
+%endif
%patch16 -p1 -d kernel
%patch17 -p1 -d kernel
%patch18 -p1 -d kernel
3 years, 11 months
[nvidia-390xx-kmod] Sync patches with Debian, including kernel-5.9 support.
by Henrik Nordström
commit f6f8c10901c2e5e7094e10c6c06bd09a870ce8f5
Author: Henrik Nordström <henrik(a)hno.se>
Date: Mon Dec 14 23:06:54 2020 +0100
Sync patches with Debian, including kernel-5.9 support.
this replaces all the Fedora maintained patches with equivalent Debian versions
..._user_pages_remote-changes-from-455.23.04.patch | 176 +++++++++++++++++++++
0001-backport-nv_vmalloc-changes-from-450.57.patch | 73 +++++++++
...ackport-vga_tryget-changes-from-455.23.04.patch | 67 ++++++++
0002-work-around-mmap_-sem-lock-rename.patch | 78 +++++++++
...as_gem_free_object-changes-from-455.23.04.patch | 73 +++++++++
...ork-around-mmap_-sem-lock-rename-uvm-part.patch | 24 +++
..._mode_has_vrefresh-changes-from-455.23.04.patch | 81 ++++++++++
...as_int_return_type-changes-from-455.23.04.patch | 98 ++++++++++++
...bject_put_unlocked-changes-from-455.23.04.patch | 82 ++++++++++
arm-outer-sync.patch | 46 ++++++
cc_version_check-gcc5.patch | 16 ++
conftest-verbose.patch | 51 ++++++
disable-module-nvidia-uvm.patch | 19 +++
do-div-cast.patch | 23 +++
ignore_xen_on_arm.patch | 47 ++++++
include-swiotlb-header-on-arm.patch | 17 ++
kernel-5.7.0-set-memory-array.patch | 83 ++++++++++
kernel-5.8.patch | 96 -----------
linux-5.9.patch | 34 ++++
nv-linux-arm.patch | 12 --
nv-linux-arm2.patch | 11 --
nvidia-390xx-kmod.spec | 68 ++++++--
nvidia-drm-arm-cflags.patch | 20 +++
nvidia-modeset-use-ARCH.o_binary.patch | 18 +++
nvidia-use-ARCH.o_binary.patch | 22 +++
use-kbuild-compiler.patch | 20 +++
use-kbuild-flags.patch | 48 ++++++
use-kbuild-gcc-plugins.patch | 15 ++
28 files changed, 1290 insertions(+), 128 deletions(-)
---
diff --git a/0001-backport-get_user_pages_remote-changes-from-455.23.04.patch b/0001-backport-get_user_pages_remote-changes-from-455.23.04.patch
new file mode 100644
index 0000000..bd33afe
--- /dev/null
+++ b/0001-backport-get_user_pages_remote-changes-from-455.23.04.patch
@@ -0,0 +1,176 @@
+From a6d5a2ab1f8b26fd5ba9ff8cd3c7c756a45714bb Mon Sep 17 00:00:00 2001
+From: Andreas Beckmann <anbe(a)debian.org>
+Date: Thu, 1 Oct 2020 23:58:28 +0200
+Subject: [PATCH 1/3] backport get_user_pages_remote changes from 455.23.04
+
+---
+ common/inc/nv-mm.h | 37 ++++++++++++++++++++++++++-----------
+ conftest.sh | 46 ++++++++++++++++++++++++++++++++++++++++++----
+ 2 files changed, 68 insertions(+), 15 deletions(-)
+
+diff --git a/common/inc/nv-mm.h b/common/inc/nv-mm.h
+index d306d61..aec55b0 100644
+--- a/common/inc/nv-mm.h
++++ b/common/inc/nv-mm.h
+@@ -98,11 +98,12 @@ typedef int vm_fault_t;
+ #endif
+ #endif
+
+-/* get_user_pages_remote() was added by:
+- * 2016 Feb 12: 1e9877902dc7e11d2be038371c6fbf2dfcd469d7
++/*
++ * get_user_pages_remote() was added by commit 1e9877902dc7
++ * ("mm/gup: Introduce get_user_pages_remote()") in v4.6 (2016-02-12).
+ *
+- * The very next commit (cde70140fed8429acf7a14e2e2cbd3e329036653)
+- * deprecated the 8-argument version of get_user_pages for the
++ * The very next commit cde70140fed8 ("mm/gup: Overload get_user_pages()
++ * functions") deprecated the 8-argument version of get_user_pages for the
+ * non-remote case (calling get_user_pages with current and current->mm).
+ *
+ * The guidelines are: call NV_GET_USER_PAGES_REMOTE if you need the 8-argument
+@@ -110,13 +111,23 @@ typedef int vm_fault_t;
+ * NV_GET_USER_PAGES if you are refering to current and current->mm.
+ *
+ * Note that get_user_pages_remote() requires the caller to hold a reference on
+- * the task_struct (if non-NULL) and the mm_struct. This will always be true
+- * when using current and current->mm. If the kernel passes the driver a vma
+- * via driver callback, the kernel holds a reference on vma->vm_mm over that
+- * callback.
++ * the task_struct (if non-NULL and if this API has tsk argument) and the mm_struct.
++ * This will always be true when using current and current->mm. If the kernel passes
++ * the driver a vma via driver callback, the kernel holds a reference on vma->vm_mm
++ * over that callback.
++ *
++ * get_user_pages_remote() write/force parameters were replaced
++ * with gup_flags by commit 9beae1ea8930 ("mm: replace get_user_pages_remote()
++ * write/force parameters with gup_flags") in v4.9 (2016-10-13).
++ *
++ * get_user_pages_remote() added 'locked' parameter by commit 5b56d49fc31d
++ * ("mm: add locked parameter to get_user_pages_remote()") in
++ * v4.10 (2016-12-14).
++ *
++ * get_user_pages_remote() removed 'tsk' parameter by
++ * commit 64019a2e467a ("mm/gup: remove task_struct pointer for
++ * all gup code") in v5.9-rc1 (2020-08-11).
+ *
+- * get_user_pages_remote() added 'locked' parameter
+- * 2016 Dec 14:5b56d49fc31dbb0487e14ead790fc81ca9fb2c99
+ */
+
+ #if defined(NV_GET_USER_PAGES_REMOTE_PRESENT)
+@@ -140,9 +151,13 @@ typedef int vm_fault_t;
+ flags |= FOLL_FORCE;
+
+ #if defined(NV_GET_USER_PAGES_REMOTE_HAS_LOCKED_ARG)
+-
++ #if defined (NV_GET_USER_PAGES_REMOTE_HAS_TSK_ARG)
+ return get_user_pages_remote(tsk, mm, start, nr_pages, flags,
+ pages, vmas, NULL);
++ #else
++ return get_user_pages_remote(mm, start, nr_pages, flags,
++ pages, vmas, NULL);
++ #endif
+
+ #else
+
+diff --git a/conftest.sh b/conftest.sh
+index b23e545..a9feaa0 100755
+--- a/conftest.sh
++++ b/conftest.sh
+@@ -3010,7 +3010,7 @@ compile_test() {
+ get_user_pages_remote)
+ #
+ # Determine if the function get_user_pages_remote() is
+- # present and has write/force parameters.
++ # present and has write/force/locked/tsk parameters.
+ #
+ # get_user_pages_remote() was added by:
+ # 2016 Feb 12: 1e9877902dc7e11d2be038371c6fbf2dfcd469d7
+@@ -3023,6 +3023,10 @@ compile_test() {
+ # get_user_pages_remote() added 'locked' parameter
+ # 2016 Dec 14:5b56d49fc31dbb0487e14ead790fc81ca9fb2c99
+ #
++ # get_user_pages_remote() removed 'tsk' parameter by
++ # commit 64019a2e467a ("mm/gup: remove task_struct pointer for
++ # all gup code") in v5.9-rc1 (2020-08-11).
++ #
+ # conftest #1: check if get_user_pages_remote() is available
+ # return if not available.
+ # Fall through to conftest #2 if it is present
+@@ -3038,6 +3042,7 @@ compile_test() {
+
+ if [ -f conftest$$.o ]; then
+ echo "#undef NV_GET_USER_PAGES_REMOTE_PRESENT" | append_conftest "functions"
++ echo "#undef NV_GET_USER_PAGES_REMOTE_HAS_TSK_ARG" | append_conftest "functions"
+ echo "#undef NV_GET_USER_PAGES_REMOTE_HAS_WRITE_AND_FORCE_ARGS" | append_conftest "functions"
+ echo "#undef NV_GET_USER_PAGES_REMOTE_HAS_LOCKED_ARG" | append_conftest "functions"
+ rm -f conftest$$.o
+@@ -3065,14 +3070,20 @@ compile_test() {
+ rm -f conftest$$.c
+
+ if [ -f conftest$$.o ]; then
++ echo "#define NV_GET_USER_PAGES_REMOTE_HAS_TSK_ARG" | append_conftest "functions"
+ echo "#define NV_GET_USER_PAGES_REMOTE_HAS_WRITE_AND_FORCE_ARGS" | append_conftest "functions"
+ echo "#undef NV_GET_USER_PAGES_REMOTE_HAS_LOCKED_ARG" | append_conftest "functions"
+ rm -f conftest$$.o
+ return
+ fi
+
++ echo "#undef NV_GET_USER_PAGES_REMOTE_HAS_WRITE_AND_FORCE_ARGS" | append_conftest "functions"
++
++ #
+ # conftest #3: check if get_user_pages_remote() has locked argument
+-
++ # Return if these arguments are present. Fall through to conftest #4
++ # if these args are absent.
++ #
+ echo "$CONFTEST_PREAMBLE
+ #include <linux/mm.h>
+ long get_user_pages_remote(struct task_struct *tsk,
+@@ -3090,13 +3101,40 @@ compile_test() {
+ rm -f conftest$$.c
+
+ if [ -f conftest$$.o ]; then
++ echo "#define NV_GET_USER_PAGES_REMOTE_HAS_TSK_ARG" | append_conftest "functions"
++ echo "#define NV_GET_USER_PAGES_REMOTE_HAS_LOCKED_ARG" | append_conftest "functions"
++ rm -f conftest$$.o
++ return
++ fi
++
++ #
++ # conftest #4: check if get_user_pages_remote() does not take
++ # tsk argument.
++ #
++ echo "$CONFTEST_PREAMBLE
++ #include <linux/mm.h>
++ long get_user_pages_remote(struct mm_struct *mm,
++ unsigned long start,
++ unsigned long nr_pages,
++ unsigned int gup_flags,
++ struct page **pages,
++ struct vm_area_struct **vmas,
++ int *locked) {
++ return 0;
++ }" > conftest$$.c
++
++ $CC $CFLAGS -c conftest$$.c > /dev/null 2>&1
++ rm -f conftest$$.c
++
++ if [ -f conftest$$.o ]; then
++ echo "#undef NV_GET_USER_PAGES_REMOTE_HAS_TSK_ARG" | append_conftest "functions"
+ echo "#define NV_GET_USER_PAGES_REMOTE_HAS_LOCKED_ARG" | append_conftest "functions"
+ rm -f conftest$$.o
+ else
++
++ echo "#define NV_GET_USER_PAGES_REMOTE_HAS_TSK_ARG" | append_conftest "functions"
+ echo "#undef NV_GET_USER_PAGES_REMOTE_HAS_LOCKED_ARG" | append_conftest "functions"
+ fi
+- echo "#undef NV_GET_USER_PAGES_REMOTE_HAS_WRITE_AND_FORCE_ARGS" | append_conftest "functions"
+-
+ ;;
+
+ usleep_range)
+--
+2.20.1
+
diff --git a/0001-backport-nv_vmalloc-changes-from-450.57.patch b/0001-backport-nv_vmalloc-changes-from-450.57.patch
new file mode 100644
index 0000000..3482b36
--- /dev/null
+++ b/0001-backport-nv_vmalloc-changes-from-450.57.patch
@@ -0,0 +1,73 @@
+From e3ef8f01a276d5c44d5b867bd793cd9d2c9a8a8d Mon Sep 17 00:00:00 2001
+From: Andreas Beckmann <anbe(a)debian.org>
+Date: Wed, 26 Aug 2020 18:51:52 +0200
+Subject: [PATCH 1/3] backport nv_vmalloc changes from 450.57
+
+---
+ common/inc/nv-linux.h | 4 ++++
+ conftest.sh | 20 ++++++++++++++++++++
+ nvidia/nvidia.Kbuild | 1 +
+ 3 files changed, 25 insertions(+)
+
+diff --git a/common/inc/nv-linux.h b/common/inc/nv-linux.h
+index ac5bb95..3d2f0b7 100644
+--- a/common/inc/nv-linux.h
++++ b/common/inc/nv-linux.h
+@@ -531,7 +531,11 @@ extern int nv_pat_mode;
+
+ static inline void *nv_vmalloc(unsigned long size)
+ {
++#if defined(NV_VMALLOC_HAS_PGPROT_T_ARG)
+ void *ptr = __vmalloc(size, GFP_KERNEL, PAGE_KERNEL);
++#else
++ void *ptr = __vmalloc(size, GFP_KERNEL);
++#endif
+ if (ptr)
+ NV_MEMDBG_ADD(ptr, size);
+ return ptr;
+diff --git a/conftest.sh b/conftest.sh
+index 7da7505..76f1da2 100755
+--- a/conftest.sh
++++ b/conftest.sh
+@@ -4088,6 +4088,26 @@ compile_test() {
+ compile_check_conftest "$CODE" "NV_PCI_DEV_HAS_SKIP_BUS_PM" "" "types"
+ ;;
+
++ vmalloc_has_pgprot_t_arg)
++ #
++ # Determine if __vmalloc has the 'pgprot' argument.
++ #
++ # The third argument to __vmalloc, page protection
++ # 'pgprot_t prot', was removed by commit 88dca4ca5a93
++ # (mm: remove the pgprot argument to __vmalloc)
++ # in v5.8-rc1 (2020-06-01).
++ CODE="
++ #include <linux/vmalloc.h>
++
++ void conftest_vmalloc_has_pgprot_t_arg(void) {
++ pgprot_t prot;
++ (void)__vmalloc(0, 0, prot);
++ }"
++
++ compile_check_conftest "$CODE" "NV_VMALLOC_HAS_PGPROT_T_ARG" "" "types"
++
++ ;;
++
+ esac
+ }
+
+diff --git a/nvidia/nvidia.Kbuild b/nvidia/nvidia.Kbuild
+index 63e369f..c4559aa 100644
+--- a/nvidia/nvidia.Kbuild
++++ b/nvidia/nvidia.Kbuild
+@@ -192,6 +192,7 @@ NV_CONFTEST_TYPE_COMPILE_TESTS += iterate_dir
+ NV_CONFTEST_TYPE_COMPILE_TESTS += kstrtoull
+ NV_CONFTEST_TYPE_COMPILE_TESTS += backlight_properties_type
+ NV_CONFTEST_TYPE_COMPILE_TESTS += proc_ops
++NV_CONFTEST_TYPE_COMPILE_TESTS += vmalloc_has_pgprot_t_arg
+ NV_CONFTEST_TYPE_COMPILE_TESTS += timeval
+ NV_CONFTEST_TYPE_COMPILE_TESTS += kmem_cache_has_kobj_remove_work
+ NV_CONFTEST_TYPE_COMPILE_TESTS += sysfs_slab_unlink
+--
+2.20.1
+
diff --git a/0002-backport-vga_tryget-changes-from-455.23.04.patch b/0002-backport-vga_tryget-changes-from-455.23.04.patch
new file mode 100644
index 0000000..179c73d
--- /dev/null
+++ b/0002-backport-vga_tryget-changes-from-455.23.04.patch
@@ -0,0 +1,67 @@
+From 29dbbbef2ef722431e73cdf5224b7d3a75bc6012 Mon Sep 17 00:00:00 2001
+From: Andreas Beckmann <anbe(a)debian.org>
+Date: Fri, 2 Oct 2020 00:03:05 +0200
+Subject: [PATCH 2/3] backport vga_tryget changes from 455.23.04
+
+---
+ conftest.sh | 16 ++++++++++++++++
+ nvidia/nv.c | 2 ++
+ nvidia/nvidia.Kbuild | 1 +
+ 3 files changed, 19 insertions(+)
+
+diff --git a/conftest.sh b/conftest.sh
+index a9feaa0..c323341 100755
+--- a/conftest.sh
++++ b/conftest.sh
+@@ -4164,6 +4164,22 @@ compile_test() {
+
+ ;;
+
++ vga_tryget)
++ #
++ # Determine if vga_tryget() is present
++ #
++ # vga_tryget() was removed by commit f369bc3f9096 ("vgaarb: mark
++ # vga_tryget static") in v5.9-rc1 (2020-08-01).
++ #
++ CODE="
++ #include <linux/vgaarb.h>
++ void conftest_vga_tryget(void) {
++ vga_tryget();
++ }"
++
++ compile_check_conftest "$CODE" "NV_VGA_TRYGET_PRESENT" "" "functions"
++ ;;
++
+ esac
+ }
+
+diff --git a/nvidia/nv.c b/nvidia/nv.c
+index 15983f6..cfb2375 100644
+--- a/nvidia/nv.c
++++ b/nvidia/nv.c
+@@ -3872,7 +3872,9 @@ nvidia_probe
+
+ #if defined(CONFIG_VGA_ARB) && !defined(NVCPU_PPC64LE)
+ #if defined(VGA_DEFAULT_DEVICE)
++#if defined(NV_VGA_TRYGET_PRESENT)
+ vga_tryget(VGA_DEFAULT_DEVICE, VGA_RSRC_LEGACY_MASK);
++#endif
+ #endif
+ vga_set_legacy_decoding(dev, VGA_RSRC_NONE);
+ #endif
+diff --git a/nvidia/nvidia.Kbuild b/nvidia/nvidia.Kbuild
+index 656db7b..6ca49ef 100644
+--- a/nvidia/nvidia.Kbuild
++++ b/nvidia/nvidia.Kbuild
+@@ -158,6 +158,7 @@ NV_CONFTEST_FUNCTION_COMPILE_TESTS += jiffies_to_timespec
+ NV_CONFTEST_FUNCTION_COMPILE_TESTS += ktime_get_raw_ts64
+ NV_CONFTEST_FUNCTION_COMPILE_TESTS += ktime_get_real_ts64
+ NV_CONFTEST_FUNCTION_COMPILE_TESTS += ioremap_nocache
++NV_CONFTEST_FUNCTION_COMPILE_TESTS += vga_tryget
+
+ NV_CONFTEST_SYMBOL_COMPILE_TESTS += is_export_symbol_gpl_of_node_to_nid
+ NV_CONFTEST_SYMBOL_COMPILE_TESTS += is_export_symbol_present_swiotlb_map_sg_attrs
+--
+2.20.1
+
diff --git a/0002-work-around-mmap_-sem-lock-rename.patch b/0002-work-around-mmap_-sem-lock-rename.patch
new file mode 100644
index 0000000..2d052e4
--- /dev/null
+++ b/0002-work-around-mmap_-sem-lock-rename.patch
@@ -0,0 +1,78 @@
+From f513e87a969f04b55a41b814e1025abcf6b6f3a6 Mon Sep 17 00:00:00 2001
+From: Andreas Beckmann <anbe(a)debian.org>
+Date: Sat, 29 Aug 2020 00:23:41 +0200
+Subject: [PATCH 2/3] work around mmap_{sem=>lock} rename
+
+---
+ common/inc/nv-mm.h | 4 ++++
+ conftest.sh | 18 ++++++++++++++++++
+ nvidia-drm/nvidia-drm.Kbuild | 1 +
+ nvidia/nvidia.Kbuild | 1 +
+ 4 files changed, 24 insertions(+)
+
+diff --git a/common/inc/nv-mm.h b/common/inc/nv-mm.h
+index 1270bf3..2067b1d 100644
+--- a/common/inc/nv-mm.h
++++ b/common/inc/nv-mm.h
+@@ -213,4 +213,8 @@ typedef int vm_fault_t;
+ }
+ #endif // NV_VM_FAULT_PRESENT
+
++#if defined(NV_MM_HAS_MMAP_LOCK)
++#define mmap_sem mmap_lock
++#endif
++
+ #endif // __NV_MM_H__
+diff --git a/conftest.sh b/conftest.sh
+index 76f1da2..b23e545 100755
+--- a/conftest.sh
++++ b/conftest.sh
+@@ -4108,6 +4108,24 @@ compile_test() {
+
+ ;;
+
++ mm_has_mmap_lock)
++ #
++ # Determine if the 'mm_struct' structure has a 'mmap_lock' field.
++ #
++ # Kernel commit da1c55f1b272 ("mmap locking API: rename mmap_sem
++ # to mmap_lock") replaced the field 'mmap_sem' by 'mmap_lock'
++ # in v5.8-rc1 (2020-06-08).
++ CODE="
++ #include <linux/mm_types.h>
++
++ int conftest_mm_has_mmap_lock(void) {
++ return offsetof(struct mm_struct, mmap_lock);
++ }"
++
++ compile_check_conftest "$CODE" "NV_MM_HAS_MMAP_LOCK" "" "types"
++
++ ;;
++
+ esac
+ }
+
+diff --git a/nvidia-drm/nvidia-drm.Kbuild b/nvidia-drm/nvidia-drm.Kbuild
+index 4cfbbbc..2254bfe 100644
+--- a/nvidia-drm/nvidia-drm.Kbuild
++++ b/nvidia-drm/nvidia-drm.Kbuild
+@@ -92,3 +92,4 @@ NV_CONFTEST_TYPE_COMPILE_TESTS += drm_driver_prime_flag_present
+ NV_CONFTEST_TYPE_COMPILE_TESTS += drm_gem_prime_export_has_dev_arg
+ NV_CONFTEST_TYPE_COMPILE_TESTS += vm_fault_t
+ NV_CONFTEST_TYPE_COMPILE_TESTS += drm_gem_object_has_resv
++NV_CONFTEST_TYPE_COMPILE_TESTS += mm_has_mmap_lock
+diff --git a/nvidia/nvidia.Kbuild b/nvidia/nvidia.Kbuild
+index c4559aa..656db7b 100644
+--- a/nvidia/nvidia.Kbuild
++++ b/nvidia/nvidia.Kbuild
+@@ -194,6 +194,7 @@ NV_CONFTEST_TYPE_COMPILE_TESTS += backlight_properties_type
+ NV_CONFTEST_TYPE_COMPILE_TESTS += proc_ops
+ NV_CONFTEST_TYPE_COMPILE_TESTS += vmalloc_has_pgprot_t_arg
+ NV_CONFTEST_TYPE_COMPILE_TESTS += timeval
++NV_CONFTEST_TYPE_COMPILE_TESTS += mm_has_mmap_lock
+ NV_CONFTEST_TYPE_COMPILE_TESTS += kmem_cache_has_kobj_remove_work
+ NV_CONFTEST_TYPE_COMPILE_TESTS += sysfs_slab_unlink
+ NV_CONFTEST_TYPE_COMPILE_TESTS += pci_dev_has_skip_bus_pm
+--
+2.20.1
+
diff --git a/0003-backport-drm_driver_has_gem_free_object-changes-from-455.23.04.patch b/0003-backport-drm_driver_has_gem_free_object-changes-from-455.23.04.patch
new file mode 100644
index 0000000..9931f3d
--- /dev/null
+++ b/0003-backport-drm_driver_has_gem_free_object-changes-from-455.23.04.patch
@@ -0,0 +1,73 @@
+From 93b30cddc79bce670fc91d92f0c8ebba171428aa Mon Sep 17 00:00:00 2001
+From: Andreas Beckmann <anbe(a)debian.org>
+Date: Sat, 3 Oct 2020 00:58:27 +0200
+Subject: [PATCH 3/3] backport drm_driver_has_gem_free_object changes from
+ 455.23.04
+
+---
+ conftest.sh | 24 ++++++++++++++++++++++++
+ nvidia-drm/nvidia-drm-drv.c | 2 ++
+ nvidia-drm/nvidia-drm.Kbuild | 1 +
+ 3 files changed, 27 insertions(+)
+
+diff --git a/conftest.sh b/conftest.sh
+index c323341..a8b735d 100755
+--- a/conftest.sh
++++ b/conftest.sh
+@@ -4164,6 +4164,30 @@ compile_test() {
+
+ ;;
+
++ drm_driver_has_gem_free_object)
++ #
++ # Determine if the 'drm_driver' structure has a 'gem_free_object'
++ # function pointer.
++ #
++ # drm_driver::gem_free_object is removed by commit 1a9458aeb8eb
++ # ("drm: remove drm_driver::gem_free_object") in v5.9-rc1.
++ #
++ CODE="
++ #if defined(NV_DRM_DRMP_H_PRESENT)
++ #include <drm/drmP.h>
++ #endif
++
++ #if defined(NV_DRM_DRM_DRV_H_PRESENT)
++ #include <drm/drm_drv.h>
++ #endif
++
++ int conftest_drm_driver_has_gem_free_object(void) {
++ return offsetof(struct drm_driver, gem_free_object);
++ }"
++
++ compile_check_conftest "$CODE" "NV_DRM_DRIVER_HAS_GEM_FREE_OBJECT" "" "types"
++ ;;
++
+ vga_tryget)
+ #
+ # Determine if vga_tryget() is present
+diff --git a/nvidia-drm/nvidia-drm-drv.c b/nvidia-drm/nvidia-drm-drv.c
+index 17e377d..027cf80 100644
+--- a/nvidia-drm/nvidia-drm-drv.c
++++ b/nvidia-drm/nvidia-drm-drv.c
+@@ -677,7 +677,9 @@ static struct drm_driver nv_drm_driver = {
+ #endif
+ DRIVER_GEM | DRIVER_RENDER,
+
++#if defined(NV_DRM_DRIVER_HAS_GEM_FREE_OBJECT)
+ .gem_free_object = nv_drm_gem_free,
++#endif
+
+ .ioctls = nv_drm_ioctls,
+ .num_ioctls = ARRAY_SIZE(nv_drm_ioctls),
+diff --git a/nvidia-drm/nvidia-drm.Kbuild b/nvidia-drm/nvidia-drm.Kbuild
+index 2254bfe..43a3c9f 100644
+--- a/nvidia-drm/nvidia-drm.Kbuild
++++ b/nvidia-drm/nvidia-drm.Kbuild
+@@ -93,3 +93,4 @@ NV_CONFTEST_TYPE_COMPILE_TESTS += drm_gem_prime_export_has_dev_arg
+ NV_CONFTEST_TYPE_COMPILE_TESTS += vm_fault_t
+ NV_CONFTEST_TYPE_COMPILE_TESTS += drm_gem_object_has_resv
+ NV_CONFTEST_TYPE_COMPILE_TESTS += mm_has_mmap_lock
++NV_CONFTEST_TYPE_COMPILE_TESTS += drm_driver_has_gem_free_object
+--
+2.20.1
+
diff --git a/0003-work-around-mmap_-sem-lock-rename-uvm-part.patch b/0003-work-around-mmap_-sem-lock-rename-uvm-part.patch
new file mode 100644
index 0000000..84996e2
--- /dev/null
+++ b/0003-work-around-mmap_-sem-lock-rename-uvm-part.patch
@@ -0,0 +1,24 @@
+From cac9d5a9b336a4c75712107ec8a114a96ccbaca5 Mon Sep 17 00:00:00 2001
+From: Andreas Beckmann <anbe(a)debian.org>
+Date: Sat, 29 Aug 2020 22:53:56 +0200
+Subject: [PATCH 3/3] work around mmap_{sem=>lock} rename, uvm part
+
+---
+ nvidia-uvm/nvidia-uvm.Kbuild | 1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/nvidia-uvm/nvidia-uvm.Kbuild b/nvidia-uvm/nvidia-uvm.Kbuild
+index 650c922..d447e23 100644
+--- a/nvidia-uvm/nvidia-uvm.Kbuild
++++ b/nvidia-uvm/nvidia-uvm.Kbuild
+@@ -131,6 +131,7 @@ NV_CONFTEST_TYPE_COMPILE_TESTS += vm_ops_fault_removed_vma_arg
+ NV_CONFTEST_TYPE_COMPILE_TESTS += vm_fault_t
+ NV_CONFTEST_TYPE_COMPILE_TESTS += proc_ops
+ NV_CONFTEST_TYPE_COMPILE_TESTS += timeval
++NV_CONFTEST_TYPE_COMPILE_TESTS += mm_has_mmap_lock
+ NV_CONFTEST_TYPE_COMPILE_TESTS += pnv_npu2_init_context
+ NV_CONFTEST_TYPE_COMPILE_TESTS += kmem_cache_has_kobj_remove_work
+ NV_CONFTEST_TYPE_COMPILE_TESTS += sysfs_slab_unlink
+--
+2.20.1
+
diff --git a/0004-backport-drm_display_mode_has_vrefresh-changes-from-455.23.04.patch b/0004-backport-drm_display_mode_has_vrefresh-changes-from-455.23.04.patch
new file mode 100644
index 0000000..dda15e0
--- /dev/null
+++ b/0004-backport-drm_display_mode_has_vrefresh-changes-from-455.23.04.patch
@@ -0,0 +1,81 @@
+From fcbd642257fb272c1ced87bd07a33aaa6e518d76 Mon Sep 17 00:00:00 2001
+From: Andreas Beckmann <anbe(a)debian.org>
+Date: Fri, 16 Oct 2020 23:36:40 +0200
+Subject: [PATCH 4/4] backport drm_display_mode_has_vrefresh changes from
+ 455.23.04
+
+---
+ conftest.sh | 19 +++++++++++++++++++
+ nvidia-drm/nvidia-drm-utils.c | 6 ++++++
+ nvidia-drm/nvidia-drm.Kbuild | 1 +
+ 3 files changed, 26 insertions(+)
+
+diff --git a/conftest.sh b/conftest.sh
+index a8b735d..e0347a8 100755
+--- a/conftest.sh
++++ b/conftest.sh
+@@ -4164,6 +4164,25 @@ compile_test() {
+
+ ;;
+
++ drm_display_mode_has_vrefresh)
++ #
++ # Determine if the 'drm_display_mode' structure has a 'vrefresh'
++ # field.
++ #
++ # Removed by commit 0425662fdf05 ("drm: Nuke mode->vrefresh") in
++ # v5.9-rc1.
++ #
++ CODE="
++ #include <drm/drm_modes.h>
++
++ int conftest_drm_display_mode_has_vrefresh(void) {
++ return offsetof(struct drm_display_mode, vrefresh);
++ }"
++
++ compile_check_conftest "$CODE" "NV_DRM_DISPLAY_MODE_HAS_VREFRESH" "types"
++
++ ;;
++
+ drm_driver_has_gem_free_object)
+ #
+ # Determine if the 'drm_driver' structure has a 'gem_free_object'
+diff --git a/nvidia-drm/nvidia-drm-utils.c b/nvidia-drm/nvidia-drm-utils.c
+index 8cb2d5e..e30b2b6 100644
+--- a/nvidia-drm/nvidia-drm-utils.c
++++ b/nvidia-drm/nvidia-drm-utils.c
+@@ -103,7 +103,9 @@ void
+ nvkms_display_mode_to_drm_mode(const struct NvKmsKapiDisplayMode *displayMode,
+ struct drm_display_mode *mode)
+ {
++#if defined(NV_DRM_DISPLAY_MODE_HAS_VREFRESH)
+ mode->vrefresh = (displayMode->timings.refreshRate + 500) / 1000; /* In Hz */
++#endif
+
+ mode->clock = (displayMode->timings.pixelClockHz + 500) / 1000; /* In Hz */
+
+@@ -189,7 +191,11 @@ bool drm_format_to_nvkms_format(u32 format,
+ void drm_mode_to_nvkms_display_mode(const struct drm_display_mode *src,
+ struct NvKmsKapiDisplayMode *dst)
+ {
++#if defined(NV_DRM_DISPLAY_MODE_HAS_VREFRESH)
+ dst->timings.refreshRate = src->vrefresh * 1000;
++#else
++ dst->timings.refreshRate = drm_mode_vrefresh(src) * 1000;
++#endif
+
+ dst->timings.pixelClockHz = src->clock * 1000; /* In Hz */
+
+diff --git a/nvidia-drm/nvidia-drm.Kbuild b/nvidia-drm/nvidia-drm.Kbuild
+index 43a3c9f..32ed5c9 100644
+--- a/nvidia-drm/nvidia-drm.Kbuild
++++ b/nvidia-drm/nvidia-drm.Kbuild
+@@ -93,4 +93,5 @@ NV_CONFTEST_TYPE_COMPILE_TESTS += drm_gem_prime_export_has_dev_arg
+ NV_CONFTEST_TYPE_COMPILE_TESTS += vm_fault_t
+ NV_CONFTEST_TYPE_COMPILE_TESTS += drm_gem_object_has_resv
+ NV_CONFTEST_TYPE_COMPILE_TESTS += mm_has_mmap_lock
++NV_CONFTEST_TYPE_COMPILE_TESTS += drm_display_mode_has_vrefresh
+ NV_CONFTEST_TYPE_COMPILE_TESTS += drm_driver_has_gem_free_object
+--
+2.20.1
+
diff --git a/0005-backport-drm_driver_master_set_has_int_return_type-changes-from-455.23.04.patch b/0005-backport-drm_driver_master_set_has_int_return_type-changes-from-455.23.04.patch
new file mode 100644
index 0000000..4fe6ee2
--- /dev/null
+++ b/0005-backport-drm_driver_master_set_has_int_return_type-changes-from-455.23.04.patch
@@ -0,0 +1,98 @@
+From 0f5cebb7340ae262c1485bfee1fbcd3e12aee4c1 Mon Sep 17 00:00:00 2001
+From: Andreas Beckmann <anbe(a)debian.org>
+Date: Fri, 16 Oct 2020 23:58:27 +0200
+Subject: [PATCH 5/5] backport drm_driver_master_set_has_int_return_type
+ changes from 455.23.04
+
+---
+ conftest.sh | 25 +++++++++++++++++++++++++
+ nvidia-drm/nvidia-drm-drv.c | 19 +++++++++++++++++--
+ nvidia-drm/nvidia-drm.Kbuild | 1 +
+ 3 files changed, 43 insertions(+), 2 deletions(-)
+
+diff --git a/conftest.sh b/conftest.sh
+index e0347a8..37c40eb 100755
+--- a/conftest.sh
++++ b/conftest.sh
+@@ -4183,6 +4183,31 @@ compile_test() {
+
+ ;;
+
++ drm_driver_master_set_has_int_return_type)
++ #
++ # Determine if drm_driver::master_set() returns integer value
++ #
++ # Changed to void by commit 907f53200f98 ("drm: vmwgfx: remove
++ # drm_driver::master_set() return type") in v5.9-rc1.
++ #
++ CODE="
++ #if defined(NV_DRM_DRMP_H_PRESENT)
++ #include <drm/drmP.h>
++ #endif
++
++ #if defined(NV_DRM_DRM_DRV_H_PRESENT)
++ #include <drm/drm_drv.h>
++ #endif
++
++ int conftest_drm_driver_master_set_has_int_return_type(struct drm_driver *drv,
++ struct drm_device *dev, struct drm_file *file_priv, bool from_open) {
++
++ return drv->master_set(dev, file_priv, from_open);
++ }"
++
++ compile_check_conftest "$CODE" "NV_DRM_DRIVER_SET_MASTER_HAS_INT_RETURN_TYPE" "" "types"
++ ;;
++
+ drm_driver_has_gem_free_object)
+ #
+ # Determine if the 'drm_driver' structure has a 'gem_free_object'
+diff --git a/nvidia-drm/nvidia-drm-drv.c b/nvidia-drm/nvidia-drm-drv.c
+index 027cf80..1b4cc6d 100644
+--- a/nvidia-drm/nvidia-drm-drv.c
++++ b/nvidia-drm/nvidia-drm-drv.c
+@@ -466,8 +466,8 @@ static void nv_drm_unload(struct drm_device *dev)
+
+ #if defined(NV_DRM_ATOMIC_MODESET_AVAILABLE)
+
+-static int nv_drm_master_set(struct drm_device *dev,
+- struct drm_file *file_priv, bool from_open)
++static int __nv_drm_master_set(struct drm_device *dev,
++ struct drm_file *file_priv, bool from_open)
+ {
+ struct nv_drm_device *nv_dev = to_nv_device(dev);
+
+@@ -478,6 +478,21 @@ static int nv_drm_master_set(struct drm_device *dev,
+ return 0;
+ }
+
++#if defined(NV_DRM_DRIVER_SET_MASTER_HAS_INT_RETURN_TYPE)
++static int nv_drm_master_set(struct drm_device *dev,
++ struct drm_file *file_priv, bool from_open)
++{
++ return __nv_drm_master_set(dev, file_priv, from_open);
++}
++#else
++static void nv_drm_master_set(struct drm_device *dev,
++ struct drm_file *file_priv, bool from_open)
++{
++ WARN_ON(__nv_drm_master_set(dev, file_priv, from_open) != 0);
++}
++#endif
++
++
+ #if defined(NV_DRM_MASTER_DROP_HAS_FROM_RELEASE_ARG)
+ static
+ void nv_drm_master_drop(struct drm_device *dev,
+diff --git a/nvidia-drm/nvidia-drm.Kbuild b/nvidia-drm/nvidia-drm.Kbuild
+index 32ed5c9..9eb6686 100644
+--- a/nvidia-drm/nvidia-drm.Kbuild
++++ b/nvidia-drm/nvidia-drm.Kbuild
+@@ -94,4 +94,5 @@ NV_CONFTEST_TYPE_COMPILE_TESTS += vm_fault_t
+ NV_CONFTEST_TYPE_COMPILE_TESTS += drm_gem_object_has_resv
+ NV_CONFTEST_TYPE_COMPILE_TESTS += mm_has_mmap_lock
+ NV_CONFTEST_TYPE_COMPILE_TESTS += drm_display_mode_has_vrefresh
++NV_CONFTEST_TYPE_COMPILE_TESTS += drm_driver_master_set_has_int_return_type
+ NV_CONFTEST_TYPE_COMPILE_TESTS += drm_driver_has_gem_free_object
+--
+2.20.1
+
diff --git a/0006-backport-drm_gem_object_put_unlocked-changes-from-455.23.04.patch b/0006-backport-drm_gem_object_put_unlocked-changes-from-455.23.04.patch
new file mode 100644
index 0000000..c4c7979
--- /dev/null
+++ b/0006-backport-drm_gem_object_put_unlocked-changes-from-455.23.04.patch
@@ -0,0 +1,82 @@
+From 188c02a4b282b1cf91c0b0b8038eed8d13410a0f Mon Sep 17 00:00:00 2001
+From: Andreas Beckmann <anbe(a)debian.org>
+Date: Sat, 17 Oct 2020 00:09:36 +0200
+Subject: [PATCH 6/6] backport drm_gem_object_put_unlocked changes from
+ 455.23.04
+
+---
+ conftest.sh | 26 ++++++++++++++++++++++++++
+ nvidia-drm/nvidia-drm-gem.h | 6 ++++++
+ nvidia-drm/nvidia-drm.Kbuild | 1 +
+ 3 files changed, 33 insertions(+)
+
+diff --git a/conftest.sh b/conftest.sh
+index 37c40eb..afbf832 100755
+--- a/conftest.sh
++++ b/conftest.sh
+@@ -4164,6 +4164,32 @@ compile_test() {
+
+ ;;
+
++ drm_gem_object_put_unlocked)
++ #
++ # Determine if the function drm_gem_object_put_unlocked() is present.
++ #
++ # In v5.9-rc1, commit 2f4dd13d4bb8 ("drm/gem: add
++ # drm_gem_object_put helper") removes drm_gem_object_put_unlocked()
++ # function and replace its definition by transient macro. Commit
++ # ab15d56e27be ("drm: remove transient
++ # drm_gem_object_put_unlocked()") finally removes
++ # drm_gem_object_put_unlocked() macro.
++ #
++ CODE="
++ #if defined(NV_DRM_DRMP_H_PRESENT)
++ #include <drm/drmP.h>
++ #endif
++
++ #if defined(NV_DRM_DRM_GEM_H_PRESENT)
++ #include <drm/drm_gem.h>
++ #endif
++ void conftest_drm_gem_object_put_unlocked(void) {
++ drm_gem_object_put_unlocked();
++ }"
++
++ compile_check_conftest "$CODE" "NV_DRM_GEM_OBJECT_PUT_UNLOCK_PRESENT" "" "functions"
++ ;;
++
+ drm_display_mode_has_vrefresh)
+ #
+ # Determine if the 'drm_display_mode' structure has a 'vrefresh'
+diff --git a/nvidia-drm/nvidia-drm-gem.h b/nvidia-drm/nvidia-drm-gem.h
+index 5691a7a..18c50ca 100644
+--- a/nvidia-drm/nvidia-drm-gem.h
++++ b/nvidia-drm/nvidia-drm-gem.h
+@@ -87,7 +87,13 @@ static inline void
+ nv_drm_gem_object_unreference_unlocked(struct nv_drm_gem_object *nv_gem)
+ {
+ #if defined(NV_DRM_GEM_OBJECT_GET_PRESENT)
++
++#if defined(NV_DRM_GEM_OBJECT_PUT_UNLOCK_PRESENT)
+ drm_gem_object_put_unlocked(&nv_gem->base);
++#else
++ drm_gem_object_put(&nv_gem->base);
++#endif
++
+ #else
+ drm_gem_object_unreference_unlocked(&nv_gem->base);
+ #endif
+diff --git a/nvidia-drm/nvidia-drm.Kbuild b/nvidia-drm/nvidia-drm.Kbuild
+index 9eb6686..66f8545 100644
+--- a/nvidia-drm/nvidia-drm.Kbuild
++++ b/nvidia-drm/nvidia-drm.Kbuild
+@@ -66,6 +66,7 @@ NV_CONFTEST_FUNCTION_COMPILE_TESTS += drm_framebuffer_get
+ NV_CONFTEST_FUNCTION_COMPILE_TESTS += drm_gem_object_get
+ NV_CONFTEST_FUNCTION_COMPILE_TESTS += drm_dev_put
+ NV_CONFTEST_FUNCTION_COMPILE_TESTS += drm_connector_for_each_possible_encoder
++NV_CONFTEST_FUNCTION_COMPILE_TESTS += drm_gem_object_put_unlocked
+
+ NV_CONFTEST_TYPE_COMPILE_TESTS += drm_bus_present
+ NV_CONFTEST_TYPE_COMPILE_TESTS += drm_bus_has_bus_type
+--
+2.20.1
+
diff --git a/arm-outer-sync.patch b/arm-outer-sync.patch
new file mode 100644
index 0000000..c8c146a
--- /dev/null
+++ b/arm-outer-sync.patch
@@ -0,0 +1,46 @@
+Author: Luca Boccassi <luca.boccassi(a)gmail.com>
+Description: Redefine WRITE_COMBINE_FLUSH on ARM on kernel >= 4.3
+ From kernel 4.3 and newer (commit f81309067ff2) ARM function outer_sync is
+ no longer present. Instead, behind a CONFIG_ARM_HEAVY_MB flag, arm_heavy_mb
+ is defined. Fall back to no memory barrier at all if that is not configured.
+--- a/common/inc/nv-linux.h
++++ b/common/inc/nv-linux.h
+@@ -466,7 +466,13 @@ extern int nv_pat_mode;
+ #if defined(CONFIG_OUTER_CACHE)
+ #define OUTER_FLUSH_RANGE(start, end) outer_flush_range((start),(end))
+ #endif
++#if LINUX_VERSION_CODE < KERNEL_VERSION(4,3,0)
+ #define WRITE_COMBINE_FLUSH() { dsb(); outer_sync(); }
++#elif defined(CONFIG_ARM_HEAVY_MB)
++#define WRITE_COMBINE_FLUSH() { dsb(); arm_heavy_mb(); }
++#else
++#define WRITE_COMBINE_FLUSH() { dsb(); }
++#endif
+ #elif defined(NVCPU_AARCH64)
+ static inline void nv_flush_cache_cpu(void *info)
+ {
+--- a/nvidia-drm/nvidia-drm-linux.c
++++ b/nvidia-drm/nvidia-drm-linux.c
+@@ -23,6 +23,7 @@
+ #include <linux/module.h>
+ #include <linux/slab.h>
+ #include <linux/err.h>
++#include <linux/version.h>
+
+ #include "nvidia-drm-os-interface.h"
+ #include "nvidia-drm.h"
+@@ -75,7 +76,13 @@ char *nv_drm_asprintf(const char *fmt, .
+ #define WRITE_COMBINE_FLUSH() asm volatile("sfence":::"memory")
+ #elif defined(NVCPU_FAMILY_ARM)
+ #if defined(NVCPU_ARM)
+- #define WRITE_COMBINE_FLUSH() { dsb(); outer_sync(); }
++ #if LINUX_VERSION_CODE < KERNEL_VERSION(4,3,0)
++ #define WRITE_COMBINE_FLUSH() { dsb(); outer_sync(); }
++ #elif defined(CONFIG_ARM_HEAVY_MB)
++ #define WRITE_COMBINE_FLUSH() { dsb(); arm_heavy_mb(); }
++ #else
++ #define WRITE_COMBINE_FLUSH() { dsb(); }
++ #endif
+ #elif defined(NVCPU_AARCH64)
+ #define WRITE_COMBINE_FLUSH() mb()
+ #endif
diff --git a/cc_version_check-gcc5.patch b/cc_version_check-gcc5.patch
new file mode 100644
index 0000000..d7edbe7
--- /dev/null
+++ b/cc_version_check-gcc5.patch
@@ -0,0 +1,16 @@
+Author: Andreas Beckmann <anbe(a)debian.org>
+Description: ignore __GNUC_MINOR__ from GCC 5 onwards
+ starting with GCC 5, the major version will be bumped for each release
+ and __GNUC_MINOR__ will only denote bugfix releases
+
+--- a/conftest.sh
++++ b/conftest.sh
+@@ -4176,7 +4176,7 @@ case "$6" in
+ kernel_cc_minor=`echo ${kernel_cc_version} | cut -d '.' -f 2`
+
+ echo "
+- #if (__GNUC__ != ${kernel_cc_major}) || (__GNUC_MINOR__ != ${kernel_cc_minor})
++ #if (__GNUC__ != ${kernel_cc_major}) || ((__GNUC__ < 5) && (__GNUC_MINOR__ != ${kernel_cc_minor}))
+ #error \"cc version mismatch\"
+ #endif
+ " > conftest$$.c
diff --git a/conftest-verbose.patch b/conftest-verbose.patch
new file mode 100644
index 0000000..4fae8ce
--- /dev/null
+++ b/conftest-verbose.patch
@@ -0,0 +1,51 @@
+Author: Andreas Beckmann <anbe(a)debian.org>
+Description: dump the generated conftest headers
+
+--- a/Kbuild
++++ b/Kbuild
+@@ -117,6 +117,16 @@ NV_CONFTEST_HEADERS += $(obj)/conftest/h
+ NV_CONFTEST_HEADERS += $(NV_CONFTEST_COMPILE_TEST_HEADERS)
+
+
++.PHONY: conftest-verbose
++conftest-verbose:
++ @echo 'NV_CONFTEST_CMD=$(NV_CONFTEST_CMD)'
++ @echo 'NV_CONFTEST_CFLAGS=$(NV_CONFTEST_CFLAGS)'
++ @echo 'KBUILD_CFLAGS=$(KBUILD_CFLAGS)'
++ @echo 'LINUXINCLUDE=$(LINUXINCLUDE)'
++ @echo 'LDFLAGS=$(LDFLAGS)'
++ @echo 'KBUILD_LDFLAGS=$(KBUILD_LDFLAGS)'
++ @echo 'ARCH=$(ARCH)'
++
+ #
+ # Generate a header file for a single conftest compile test. Each compile test
+ # header depends on conftest.sh, as well as the generated conftest/headers.h
+@@ -141,6 +151,8 @@ define NV_GENERATE_COMPILE_TEST_HEADER
+ @mkdir -p $(obj)/conftest
+ @# concatenate /dev/null to prevent cat from hanging when $$^ is empty
+ @cat $$^ /dev/null > $$@
++ @echo " CONFTEST $$(notdir $$@):"
++ @cat $$@
+ endef
+
+ #
+@@ -160,13 +172,17 @@ $(eval $(call NV_GENERATE_COMPILE_TEST_H
+ $(eval $(call NV_GENERATE_COMPILE_TEST_HEADER,symbols,$(NV_CONFTEST_SYMBOL_COMPILE_TESTS)))
+ $(eval $(call NV_GENERATE_COMPILE_TEST_HEADER,types,$(NV_CONFTEST_TYPE_COMPILE_TESTS)))
+
+-$(obj)/conftest/patches.h: $(NV_CONFTEST_SCRIPT)
++$(obj)/conftest/patches.h: $(NV_CONFTEST_SCRIPT) conftest-verbose
+ @mkdir -p $(obj)/conftest
+ @$(NV_CONFTEST_CMD) patch_check > $@
++ @echo " CONFTEST $(notdir $@):"
++ @cat $@
+
+-$(obj)/conftest/headers.h: $(NV_CONFTEST_SCRIPT)
++$(obj)/conftest/headers.h: $(NV_CONFTEST_SCRIPT) conftest-verbose
+ @mkdir -p $(obj)/conftest
+ @$(NV_CONFTEST_CMD) test_kernel_headers > $@
++ @echo " CONFTEST $(notdir $@):"
++ @cat $@
+
+ clean-dirs := $(obj)/conftest
+
diff --git a/disable-module-nvidia-uvm.patch b/disable-module-nvidia-uvm.patch
new file mode 100644
index 0000000..8406b6e
--- /dev/null
+++ b/disable-module-nvidia-uvm.patch
@@ -0,0 +1,19 @@
+Author: Andreas Beckmann <anbe(a)debian.org>
+Description: HACK! disable building the nvidia-uvm module
+ FTBFS in Linux 5.8 with
+ FATAL: modpost: GPL-incompatible module nvidia-uvm.ko uses GPL-only symbol 'radix_tree_preloads'
+ 415.18 fixed this by switching the module license to "Dual MIT/GPL"
+Bug-Debian: https://bugs.debian.org/969085
+Forwarded: not-needed
+
+--- a/Makefile
++++ b/Makefile
+@@ -19,6 +19,8 @@ ifneq ($(KERNELRELEASE),)
+ include $(src)/Kbuild
+ else
+
++ NV_EXCLUDE_KERNEL_MODULES += nvidia-uvm
++
+ # Determine the location of the Linux kernel source tree, and of the
+ # kernel's output tree. Use this to invoke Kbuild, and pass the paths
+ # to the source and output trees to NVIDIA's Kbuild file via
diff --git a/do-div-cast.patch b/do-div-cast.patch
new file mode 100644
index 0000000..e7e19de
--- /dev/null
+++ b/do-div-cast.patch
@@ -0,0 +1,23 @@
+Author: Luca Boccassi <luca.boccassi(a)gmail.com>
+Description: Change NVKMS_USECS_TO_JIFFIES to pass unsigned long long to do_div
+ In kernel builds from 4.6 the compiler flags are more restrictive, and now
+ Werror=incompatible-pointer-types is passed, which causes the build to fail on
+ 32bit. do_div expects a 64 bit unsigned integer, but the NVKMS_USECS_TO_JIFFIES
+ macro passes an unsigned long. Use unsigned long long instead, and cast down
+ the result before returning. This macro is passed to time_mod which takes an
+ unsigned long as a parameter, so casting down is fine.
+
+--- a/nvidia-modeset/nvidia-modeset-linux.c
++++ b/nvidia-modeset/nvidia-modeset-linux.c
+@@ -68,9 +68,9 @@
+ */
+ static inline unsigned long NVKMS_USECS_TO_JIFFIES(NvU64 usec)
+ {
+- unsigned long result = usec * HZ;
++ unsigned long long result = usec * HZ;
+ do_div(result, 1000000);
+- return result;
++ return (unsigned long)result;
+ }
+
+
diff --git a/ignore_xen_on_arm.patch b/ignore_xen_on_arm.patch
new file mode 100644
index 0000000..48e29fe
--- /dev/null
+++ b/ignore_xen_on_arm.patch
@@ -0,0 +1,47 @@
+Author: Luca Boccassi <luca.boccassi(a)gmail.com>
+Description: Undef CONFIG_XEN and CONFIG_XEN_DOM0 if building on ARM
+ Currently armmp kernel headers (3.16, 4.0, 4.1) have CONFIG_XEN enabled and
+ CONFIG_PARAVIRT disabled. This causes a build failure of the armhf dkms modules
+ in all current versions of the Nvidia driver.
+ Since running this driver on Xen is currently not supported anyway on Debian,
+ this patch undefines CONFIG_XEN and CONFIG_XEN_DOM0 if building on ARM, and
+ avoid including asm/maddr.h and xen/interface/memory.h.
+ Note that this has been tested only on qemu.
+ It is recommended to build an armmp kernel with CONFIG_XEN disabled (or with
+ CONFIG_XEN_PARAVIRT enabled) to use the Nvidia drivers.
+
+--- a/common/inc/nv-linux.h
++++ b/common/inc/nv-linux.h
+@@ -43,6 +43,11 @@
+ #include <linux/version.h>
+ #include <linux/utsname.h>
+
++#if defined(NVCPU_ARM) && LINUX_VERSION_CODE < KERNEL_VERSION(3,17,0)
++#undef CONFIG_XEN
++#undef CONFIG_XEN_DOM0
++#endif
++
+ #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 9)
+ #error "This driver does not support kernels older than 2.6.9!"
+ #elif LINUX_VERSION_CODE < KERNEL_VERSION(2, 7, 0)
+@@ -281,7 +286,7 @@ NV_STATUS nvos_forward_error_to_cray(str
+ * NVIDIA graphics driver has no way of knowing and is unlikely
+ * to work correctly.
+ */
+-#if defined(CONFIG_XEN) && !defined(CONFIG_PARAVIRT)
++#if defined(CONFIG_XEN) && !defined(CONFIG_PARAVIRT) && !defined(NVCPU_ARM)
+ #include <asm/maddr.h>
+ #include <xen/interface/memory.h>
+ #define NV_XEN_SUPPORT_FULLY_VIRTUALIZED_KERNEL
+--- a/conftest.sh
++++ b/conftest.sh
+@@ -48,7 +48,8 @@ test_xen() {
+ # CONFIG_XEN and CONFIG_PARAVIRT are present, text_xen() treats
+ # the kernel as a stand-alone kernel.
+ #
+- if ! test_configuration_option CONFIG_XEN ||
++ if [ "$ARCH" = "arm" ] ||
++ ! test_configuration_option CONFIG_XEN ||
+ test_configuration_option CONFIG_PARAVIRT; then
+ XEN_PRESENT=0
+ fi
diff --git a/include-swiotlb-header-on-arm.patch b/include-swiotlb-header-on-arm.patch
new file mode 100644
index 0000000..6c5449e
--- /dev/null
+++ b/include-swiotlb-header-on-arm.patch
@@ -0,0 +1,17 @@
+Author: Luca Boccassi <luca.boccassi(a)gmail.com>
+Description: Include linux/swiotlb.h if CONFIG_ARM is defined
+ swiotlb.h is needed by ARM to use dma_ops and family, but nv-linux.h only
+ includes it if CONFIG_ARM64 is set. Patch nv-linux.h to also include it if
+ CONFIG_ARM is set.
+
+--- a/common/inc/nv-linux.h
++++ b/common/inc/nv-linux.h
+@@ -178,7 +178,7 @@ static inline uid_t __kuid_val(kuid_t ui
+ #include <linux/dma-mapping.h>
+ #endif
+
+-#if defined(CONFIG_SWIOTLB) && defined(NVCPU_AARCH64)
++#if defined(CONFIG_SWIOTLB) && (defined(NVCPU_AARCH64) || defined(NVCPU_ARM))
+ #include <linux/swiotlb.h>
+ #endif
+
diff --git a/kernel-5.7.0-set-memory-array.patch b/kernel-5.7.0-set-memory-array.patch
new file mode 100644
index 0000000..28c9869
--- /dev/null
+++ b/kernel-5.7.0-set-memory-array.patch
@@ -0,0 +1,83 @@
+Author: Jiri Palecek <jpalecek(a)web.de>
+Description: fix module build failure for Linux 5.7
+ I was trying to test nvidia drivers with the new kernel in experimental
+ 5.7.0-rc5-686-pae. In the build log, I noticed it failed due to missing
+ functions set_memory_array_wb and friends. However, the code seemed to
+ be prepared for that possibility, so the problem must be the conftest.
+ .
+ I checked the output from the compilation checks and found some are
+ failing for the wrong reason, which causes some functions to be wrongly
+ detected as present (!) and some wrongly detected as missing. This would
+ probably apply to the other branches of nvidia drivers as well. I
+ prepared a patch for this, some comments:
+ .
+ - asm/page.h and asm/pgtable.h are needed for the pgprop_t type. Some
+ arches have here, some have it there. Otherwise the compilation
+ wrongly fails and detects the functions as present
+ .
+ - atomic_long_t is pulled by including linux/atomic.h, not
+ asm/atomic.h. Otherwise it's detected wrongly as absent
+ .
+ - linux/acpi.h is needed for acpi_status type
+ .
+ I checked that these files were present in the linux kernel since
+ 2.6.39, but haven't tested compilation with such old kernels. It should,
+ however, work.
+Bug-Debian: https://bugs.debian.org/960735
+
+--- a/conftest.sh
++++ b/conftest.sh
+@@ -405,6 +405,8 @@ compile_test() {
+ # Determine if the set_memory_uc() function is present.
+ #
+ CODE="
++ #include <asm/page.h>
++ #include <asm/pgtable.h>
+ #if defined(NV_ASM_SET_MEMORY_H_PRESENT)
+ #if defined(NV_ASM_PGTABLE_TYPES_H_PRESENT)
+ #include <asm/pgtable_types.h>
+@@ -425,6 +427,8 @@ compile_test() {
+ # Determine if the set_memory_array_uc() function is present.
+ #
+ CODE="
++ #include <asm/page.h>
++ #include <asm/pgtable.h>
+ #if defined(NV_ASM_SET_MEMORY_H_PRESENT)
+ #if defined(NV_ASM_PGTABLE_TYPES_H_PRESENT)
+ #include <asm/pgtable_types.h>
+@@ -480,6 +484,8 @@ compile_test() {
+ # Determine if the set_pages_uc() function is present.
+ #
+ CODE="
++ #include <asm/page.h>
++ #include <asm/pgtable.h>
+ #if defined(NV_ASM_SET_MEMORY_H_PRESENT)
+ #if defined(NV_ASM_PGTABLE_TYPES_H_PRESENT)
+ #include <asm/pgtable_types.h>
+@@ -1858,7 +1864,7 @@ compile_test() {
+ # Determine if atomic_long_t and associated functions are defined
+ # Added in 2.6.16 2006-01-06 d3cb487149bd706aa6aeb02042332a450978dc1c
+ CODE="
+- #include <asm/atomic.h>
++ #include <linux/atomic.h>
+ void conftest_atomic_long(void) {
+ atomic_long_t data;
+ atomic_long_read(&data);
+@@ -1872,7 +1878,7 @@ compile_test() {
+ atomic64_type)
+ # Determine if atomic64_t and associated functions are defined
+ CODE="
+- #include <asm/atomic.h>
++ #include <linux/atomic.h>
+ void conftest_atomic64(void) {
+ atomic64_t data;
+ atomic64_read(&data);
+@@ -3508,7 +3514,7 @@ compile_test() {
+ # 2008-01-25 9ee85241fdaab358dff1d8647f20a478cfa512a1
+ #
+ CODE="
+- #include <acpi/acpi_bus.h>
++ #include <linux/acpi.h>
+ int conftest_register_acpi_notifier(void) {
+ return register_acpi_notifier();
+ }"
diff --git a/linux-5.9.patch b/linux-5.9.patch
new file mode 100644
index 0000000..f0a2ae5
--- /dev/null
+++ b/linux-5.9.patch
@@ -0,0 +1,34 @@
+Author: Andreas Beckmann <anbe(a)debian.org>
+Description: linux/ioctl32.h is gone since 2.6.22
+
+diff --git a/common/inc/nv-linux.h b/common/inc/nv-linux.h
+index 3d2f0b7..5d0d2d2 100644
+--- a/common/inc/nv-linux.h
++++ b/common/inc/nv-linux.h
+@@ -161,7 +161,8 @@ static inline uid_t __kuid_val(kuid_t uid)
+
+ #if defined(NVCPU_X86_64) && !defined(HAVE_COMPAT_IOCTL)
+ #include <linux/syscalls.h> /* sys_ioctl() */
+-#include <linux/ioctl32.h> /* register_ioctl32_conversion() */
++// gone since 2.6.22
++//#include <linux/ioctl32.h> /* register_ioctl32_conversion() */
+ #endif
+
+ #if !defined(NV_FILE_OPERATIONS_HAS_IOCTL) && \
+diff --git a/nvidia-modeset/nvidia-modeset-linux.c b/nvidia-modeset/nvidia-modeset-linux.c
+index f7f1def..fab8bcf 100644
+--- a/nvidia-modeset/nvidia-modeset-linux.c
++++ b/nvidia-modeset/nvidia-modeset-linux.c
+@@ -51,7 +51,8 @@
+
+ #if NV_NEEDS_COMPAT_IOCTL_REGISTRATION
+ #include <linux/syscalls.h> /* sys_ioctl() */
+-#include <linux/ioctl32.h> /* register_ioctl32_conversion() */
++// gone since 2.6.22
++//#include <linux/ioctl32.h> /* register_ioctl32_conversion() */
+ #endif
+
+ #define NVKMS_MAJOR_DEVICE_NUMBER 195
+--
+2.20.1
+
diff --git a/nvidia-390xx-kmod.spec b/nvidia-390xx-kmod.spec
index 3d67dc3..a3e753c 100644
--- a/nvidia-390xx-kmod.spec
+++ b/nvidia-390xx-kmod.spec
@@ -12,16 +12,45 @@ Name: nvidia-390xx-kmod
Epoch: 3
Version: 390.138
# Taken over by kmodtool
-Release: 3%{?dist}
+Release: 4%{?dist}
Summary: NVIDIA 390xx display driver kernel module
Group: System Environment/Kernel
License: Redistributable, no modification permitted
URL: http://www.nvidia.com/
Source11: nvidia-390xx-kmodtool-excludekernel-filterfile
-Patch0: nv-linux-arm.patch
-Patch1: nv-linux-arm2.patch
-Patch2: kernel-5.8.patch
+
+# Patches from Debian https://salsa.debian.org/nvidia-team/nvidia-graphics-drivers/-/tree/390xx...
+# kernel support
+Patch10: do-div-cast.patch
+Patch11: kernel-5.7.0-set-memory-array.patch
+Patch12: 0001-backport-nv_vmalloc-changes-from-450.57.patch
+Patch13: 0002-work-around-mmap_-sem-lock-rename.patch
+Patch14: 0003-work-around-mmap_-sem-lock-rename-uvm-part.patch
+Patch15: disable-module-nvidia-uvm.patch
+Patch16: linux-5.9.patch
+Patch17: 0001-backport-get_user_pages_remote-changes-from-455.23.04.patch
+Patch18: 0002-backport-vga_tryget-changes-from-455.23.04.patch
+Patch19: 0003-backport-drm_driver_has_gem_free_object-changes-from-455.23.04.patch
+Patch20: 0004-backport-drm_display_mode_has_vrefresh-changes-from-455.23.04.patch
+Patch21: 0005-backport-drm_driver_master_set_has_int_return_type-changes-from-455.23.04.patch
+Patch22: 0006-backport-drm_gem_object_put_unlocked-changes-from-455.23.04.patch
+
+# build system updates
+Patch30: use-kbuild-compiler.patch
+Patch31: use-kbuild-flags.patch
+Patch32: use-kbuild-gcc-plugins.patch
+Patch33: conftest-verbose.patch
+Patch34: cc_version_check-gcc5.patch
+#These are Debian specific. Dones not apply to Fedora
+#Patch35: nvidia-use-ARCH.o_binary.patch
+#Patch36: nvidia-modeset-use-ARCH.o_binary.patch
+
+# armhf support
+Patch40: include-swiotlb-header-on-arm.patch
+Patch41: ignore_xen_on_arm.patch
+Patch42: arm-outer-sync.patch
+Patch43: nvidia-drm-arm-cflags.patch
# needed for plague to make sure it builds for i586 and i686
ExclusiveArch: i686 x86_64 armv7hl
@@ -44,11 +73,29 @@ The nvidia 390xx %{version} display driver kernel module for kernel %{kversion}.
kmodtool --target %{_target_cpu} --repo rpmfusion --kmodname %{name} --filterfile %{SOURCE11} %{?buildforkernels:--%{buildforkernels}} %{?kernels:--for-kernels "%{?kernels}"} 2>/dev/null
%setup -T -c
tar --use-compress-program xz -xf %{_datadir}/%{name}-%{version}/%{name}-%{version}-%{_target_cpu}.tar.xz
-# patch loop
-%patch0 -p1
-%patch1 -p1
-%patch2 -p1
-
+# Apply patches
+%patch10 -p1 -d kernel
+%patch11 -p1 -d kernel
+%patch12 -p1 -d kernel
+%patch13 -p1 -d kernel
+%patch14 -p1 -d kernel
+%patch15 -p1 -d kernel
+%patch16 -p1 -d kernel
+%patch17 -p1 -d kernel
+%patch18 -p1 -d kernel
+%patch19 -p1 -d kernel
+%patch20 -p1 -d kernel
+%patch21 -p1 -d kernel
+%patch22 -p1 -d kernel
+%patch30 -p1 -d kernel
+%patch31 -p1 -d kernel
+%patch32 -p1 -d kernel
+%patch33 -p1 -d kernel
+%patch34 -p1 -d kernel
+%patch40 -p1 -d kernel
+%patch41 -p1 -d kernel
+%patch42 -p1 -d kernel
+%patch43 -p1 -d kernel
for kernel_version in %{?kernel_versions} ; do
cp -a kernel _kmod_build_${kernel_version%%___*}
@@ -77,6 +124,9 @@ done
%changelog
+* Mon Dec 14 2020 Henrik Nordstrom <henrik(a)henriknordstrom.net> - 3:390.138-4
+- Import patches from Debian, including kernel 5.9 support
+
* Thu Aug 27 2020 Leigh Scott <leigh123linux(a)gmail.com> - 3:390.138-3
- Patch for kernel 5.8
- Exclude nvidia-uvm due to GPL-only symbol 'radix_tree_preloads'
diff --git a/nvidia-drm-arm-cflags.patch b/nvidia-drm-arm-cflags.patch
new file mode 100644
index 0000000..6b033ad
--- /dev/null
+++ b/nvidia-drm-arm-cflags.patch
@@ -0,0 +1,20 @@
+Author: Luca Boccassi <luca.boccassi(a)gmail.com>
+Description: Add -Wa,-mimplicit-it=thumb to CFLAGS if building on ARM
+ The build of the nvidia-drm kernel module fails on kernel 4.5+ on armhf. The
+ following error is reported:
+ /tmp/ccy8zHSc.s: Assembler messages:
+ /tmp/ccy8zHSc.s:97: Error: thumb conditional instruction should be in IT
+ block -- `movne r0,#1'
+ As a workaround, add -Wa,-mimplicit-it=thumb to the CFLAGS if building on arm.
+
+--- a/conftest.sh
++++ b/conftest.sh
+@@ -193,7 +193,7 @@ build_cflags() {
+ done
+
+ if [ "$ARCH" = "arm" ]; then
+- MACH_CFLAGS="$MACH_CFLAGS -D__LINUX_ARM_ARCH__=7"
++ MACH_CFLAGS="$MACH_CFLAGS -D__LINUX_ARM_ARCH__=7 -Wa,-mimplicit-it=thumb"
+ fi
+
+ # Add the mach-default includes (only found on x86/older kernels)
diff --git a/nvidia-modeset-use-ARCH.o_binary.patch b/nvidia-modeset-use-ARCH.o_binary.patch
new file mode 100644
index 0000000..b15caad
--- /dev/null
+++ b/nvidia-modeset-use-ARCH.o_binary.patch
@@ -0,0 +1,18 @@
+Author: Andreas Beckmann <anbe(a)debian.org>
+Description: select the correct nv-modeset-kernel.o blob for the target architecture
+
+--- a/nvidia-modeset/nvidia-modeset.Kbuild
++++ b/nvidia-modeset/nvidia-modeset.Kbuild
+@@ -35,7 +35,11 @@ NV_KERNEL_MODULE_TARGETS += $(NVIDIA_MOD
+ # But, the target for the symlink rule should be prepended with $(obj).
+ #
+
+-NVIDIA_MODESET_BINARY_OBJECT := $(src)/nvidia-modeset/nv-modeset-kernel.o_binary
++NVIDIA_MODESET_BINARY_OBJECT-$(CONFIG_X86_32) += nv-modeset-kernel-i386.o_binary
++NVIDIA_MODESET_BINARY_OBJECT-$(CONFIG_X86_64) += nv-modeset-kernel-amd64.o_binary
++NVIDIA_MODESET_BINARY_OBJECT-$(CONFIG_ARM) += nv-modeset-kernel-armhf.o_binary
++NVIDIA_MODESET_BINARY_OBJECT-$(CONFIG_PPC64) += nv-modeset-kernel-ppc64el.o_binary
++NVIDIA_MODESET_BINARY_OBJECT := $(src)/nvidia-modeset/$(NVIDIA_MODESET_BINARY_OBJECT-y)
+ NVIDIA_MODESET_BINARY_OBJECT_O := nvidia-modeset/nv-modeset-kernel.o
+
+ quiet_cmd_symlink = SYMLINK $@
diff --git a/nvidia-use-ARCH.o_binary.patch b/nvidia-use-ARCH.o_binary.patch
new file mode 100644
index 0000000..ae5c08b
--- /dev/null
+++ b/nvidia-use-ARCH.o_binary.patch
@@ -0,0 +1,22 @@
+Author: Andreas Beckmann <anbe(a)debian.org>
+Description: Select the correct nv-kernel.o blob for the target architecture
+ The Debian nvidia-kernel-source package supports building for both i386 and
+ amd64 kernels (on i386) from one source by including both binary objects.
+ This patch makes the build system select the correct one depending on the
+ kernel architecture the module is built for.
+
+--- a/nvidia/nvidia.Kbuild
++++ b/nvidia/nvidia.Kbuild
+@@ -37,7 +37,11 @@ NVIDIA_KO = nvidia/nvidia.ko
+ # and needs to be re-executed.
+ #
+
+-NVIDIA_BINARY_OBJECT := $(src)/nvidia/nv-kernel.o_binary
++NVIDIA_BINARY_OBJECT-$(CONFIG_X86_32) += nv-kernel-i386.o_binary
++NVIDIA_BINARY_OBJECT-$(CONFIG_X86_64) += nv-kernel-amd64.o_binary
++NVIDIA_BINARY_OBJECT-$(CONFIG_ARM) += nv-kernel-armhf.o_binary
++NVIDIA_BINARY_OBJECT-$(CONFIG_PPC64) += nv-kernel-ppc64el.o_binary
++NVIDIA_BINARY_OBJECT := $(src)/nvidia/$(NVIDIA_BINARY_OBJECT-y)
+ NVIDIA_BINARY_OBJECT_O := nvidia/nv-kernel.o
+
+ quiet_cmd_symlink = SYMLINK $@
diff --git a/use-kbuild-compiler.patch b/use-kbuild-compiler.patch
new file mode 100644
index 0000000..6f13e7a
--- /dev/null
+++ b/use-kbuild-compiler.patch
@@ -0,0 +1,20 @@
+Author: Luca Boccassi <luca.boccassi(a)gmail.com>
+Description: let Kbuild set the compiler version
+ If CC=cc is passed to make, the default system compiler will be used. But we
+ want to build the kernel modules with the same compiler version used to build
+ the kernel itself. Remove the CC parameter from upstream's Makefile's make
+ invocation.
+
+--- a/Makefile
++++ b/Makefile
+@@ -78,8 +78,8 @@ else
+
+ .PHONY: modules module clean clean_conftest modules_install
+ modules clean modules_install:
+- @$(MAKE) "CC=$(CC)" $(KBUILD_PARAMS) $@
+- @if [ "$@" = "modules" ]; then \
++ $(MAKE) $(KBUILD_PARAMS) $@
++ @set -x; if [ "$@" = "modules" ]; then \
+ for module in $(NV_KERNEL_MODULES); do \
+ if [ -x split-object-file.sh ]; then \
+ ./split-object-file.sh $$module.ko; \
diff --git a/use-kbuild-flags.patch b/use-kbuild-flags.patch
new file mode 100644
index 0000000..3d15f72
--- /dev/null
+++ b/use-kbuild-flags.patch
@@ -0,0 +1,48 @@
+Author: Andreas Beckmann <anbe(a)debian.org>
+Description: use KBUILD_CFLAGS and (KBUILD_)LDFLAGS
+ allows building a amd64 kernel module with i386 user space
+ skip -Werror=* since that breaks how conftest.sh detects stuff
+
+--- a/Kbuild
++++ b/Kbuild
+@@ -104,6 +104,7 @@ NV_CONFTEST_CMD := /bin/sh $(NV_CONFTEST
+ "$(CC)" "$(HOST_CC)" $(ARCH) $(NV_KERNEL_SOURCES) $(NV_KERNEL_OUTPUT)
+
+ NV_CONFTEST_CFLAGS := $(shell $(NV_CONFTEST_CMD) build_cflags)
++NV_CONFTEST_CFLAGS += $(filter-out -Werror%,$(KBUILD_CFLAGS))
+
+ NV_CONFTEST_COMPILE_TEST_HEADERS := $(obj)/conftest/macros.h
+ NV_CONFTEST_COMPILE_TEST_HEADERS += $(obj)/conftest/functions.h
+--- a/nvidia/nvidia.Kbuild
++++ b/nvidia/nvidia.Kbuild
+@@ -88,7 +88,7 @@ NVIDIA_INTERFACE := nvidia/nv-interface.
+ always += $(NVIDIA_INTERFACE)
+
+ $(obj)/$(NVIDIA_INTERFACE): $(addprefix $(obj)/,$(NVIDIA_OBJECTS))
+- $(LD) -r -o $@ $^
++ $(LD) $(or $(KBUILD_LDFLAGS),$(LDFLAGS)) -r -o $@ $^
+
+
+ #
+--- a/Makefile
++++ b/Makefile
+@@ -111,7 +111,7 @@ else
+ # cannot be defined in the *Kbuild files, which are only used during stage 1.
+
+ %-linux.o: modules
+- $(LD) $(NV_MODULE_COMMON_SCRIPT) -r -o $@ \
++ $(LD) $(or $(KBUILD_LDFLAGS),$(LDFLAGS)) $(NV_MODULE_COMMON_SCRIPT) -r -o $@ \
+ $(subst nv,nvidia,$*).mod.o $(subst nv,nvidia,$*)/$*-interface.o
+
+ # Kbuild's "clean" rule won't clean up the conftest headers on its own, and
+--- a/nvidia-modeset/nvidia-modeset.Kbuild
++++ b/nvidia-modeset/nvidia-modeset.Kbuild
+@@ -70,7 +70,7 @@ NVIDIA_MODESET_INTERFACE := nvidia-modes
+ always += $(NVIDIA_MODESET_INTERFACE)
+
+ $(obj)/$(NVIDIA_MODESET_INTERFACE): $(addprefix $(obj)/,$(NVIDIA_MODESET_OBJECTS))
+- $(LD) -r -o $@ $^
++ $(LD) $(or $(KBUILD_LDFLAGS),$(LDFLAGS)) -r -o $@ $^
+
+ #
+ # Register the conftests needed by nvidia-modeset.ko
diff --git a/use-kbuild-gcc-plugins.patch b/use-kbuild-gcc-plugins.patch
new file mode 100644
index 0000000..65e18e1
--- /dev/null
+++ b/use-kbuild-gcc-plugins.patch
@@ -0,0 +1,15 @@
+Author: Tomas Janousek <tomi(a)nomi.cz>
+Description: ignore GCC plugins
+ fixes build failure when a kernel is built with CONFIG_GCC_PLUGINS,
+ CONFIG_GCC_PLUGIN_STRUCTLEAK and CONFIG_GCC_PLUGIN_RANDSTRUCT.
+--- a/Kbuild
++++ b/Kbuild
+@@ -104,7 +104,7 @@ NV_CONFTEST_CMD := /bin/sh $(NV_CONFTEST
+ "$(CC)" "$(HOST_CC)" $(ARCH) $(NV_KERNEL_SOURCES) $(NV_KERNEL_OUTPUT)
+
+ NV_CONFTEST_CFLAGS := $(shell $(NV_CONFTEST_CMD) build_cflags)
+-NV_CONFTEST_CFLAGS += $(filter-out -Werror%,$(KBUILD_CFLAGS))
++NV_CONFTEST_CFLAGS += $(filter-out -Werror% $(GCC_PLUGINS_CFLAGS),$(KBUILD_CFLAGS))
+
+ NV_CONFTEST_COMPILE_TEST_HEADERS := $(obj)/conftest/macros.h
+ NV_CONFTEST_COMPILE_TEST_HEADERS += $(obj)/conftest/functions.h
3 years, 11 months