commit 8f87cf4b30ae1fa4dabf48909fc5ecc5ccda9dc9
Author: Vitaly Zaitsev <vitaly(a)easycoding.org>
Date: Sat May 20 11:28:11 2023 +0200
Added patch for the Linux kernel 6.3 support.
nvidia-470xx-kmod.spec | 8 ++-
nvidia-470xx-linux-6.3-build-fixes.patch | 117 +++++++++++++++++++++++++++++++
2 files changed, 124 insertions(+), 1 deletion(-)
---
diff --git a/nvidia-470xx-kmod.spec b/nvidia-470xx-kmod.spec
index bd63ddd..197b9a9 100644
--- a/nvidia-470xx-kmod.spec
+++ b/nvidia-470xx-kmod.spec
@@ -12,7 +12,7 @@ Name: nvidia-470xx-kmod
Epoch: 3
Version: 470.182.03
# Taken over by kmodtool
-Release: 1%{?dist}
+Release: 2%{?dist}
License: Redistributable, no modification permitted
Summary: NVIDIA 470xx display driver kernel module
@@ -20,6 +20,8 @@ URL:
https://www.nvidia.com/
Source11: nvidia-470xx-kmodtool-excludekernel-filterfile
+Patch20: nvidia-470xx-linux-6.3-build-fixes.patch
+
# needed for plague to make sure it builds for i586 and i686
ExclusiveArch: x86_64
@@ -42,6 +44,7 @@ kmodtool --target %{_target_cpu} --repo rpmfusion --kmodname %{name}
--filterf
%setup -T -c
tar --use-compress-program xz -xf
%{_datadir}/%{name}-%{version}/%{name}-%{version}-%{_target_cpu}.tar.xz
# patch loop
+%patch20 -p1
for kernel_version in %{?kernel_versions} ; do
cp -a kernel _kmod_build_${kernel_version%%___*}
@@ -73,6 +76,9 @@ done
%{?akmod_install}
%changelog
+* Sat May 20 2023 Vitaly Zaitsev <vitaly(a)easycoding.org> - 3:470.182.03-2
+- Added patch for the Linux kernel 6.3 support.
+
* Fri Mar 31 2023 Vitaly Zaitsev <vitaly(a)easycoding.org> - 3:470.182.03-1
- Updated to version 470.182.03.
diff --git a/nvidia-470xx-linux-6.3-build-fixes.patch
b/nvidia-470xx-linux-6.3-build-fixes.patch
new file mode 100644
index 0000000..33d9cf8
--- /dev/null
+++ b/nvidia-470xx-linux-6.3-build-fixes.patch
@@ -0,0 +1,117 @@
+From a77f2da778f4a62695a6c7d26bba674d59ad9170 Mon Sep 17 00:00:00 2001
+From: Joan Bruguera <joanbrugueram(a)gmail.com>
+Date: Sat, 25 Feb 2023 10:57:09 +0000
+Subject: [PATCH] Tentative fix for NVIDIA 470.161.03 driver for Linux 6.3-rc1
+
+---
+ kernel/common/inc/nv-linux.h | 13 +++++++++++++
+ kernel/nvidia-drm/nvidia-drm-gem-user-memory.c | 7 ++++---
+ kernel/nvidia-uvm/uvm.c | 2 +-
+ kernel/nvidia/nv-mmap.c | 12 ++++++------
+ 4 files changed, 24 insertions(+), 10 deletions(-)
+
+diff --git a/kernel/common/inc/nv-linux.h b/kernel/common/inc/nv-linux.h
+index f8df9e3..5b22cf1 100644
+--- a/kernel/common/inc/nv-linux.h
++++ b/kernel/common/inc/nv-linux.h
+@@ -1988,4 +1988,17 @@ static inline void nv_mutex_destroy(struct mutex *lock)
+
+ }
+
++#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 3, 0)
++// Rel. commit "mm: introduce vma->vm_flags wrapper functions" (Suren
Baghdasaryan, 26 Jan 2023)
++static inline void vm_flags_set(struct vm_area_struct *vma, vm_flags_t flags)
++{
++ vma->vm_flags |= flags;
++}
++
++static inline void vm_flags_clear(struct vm_area_struct *vma, vm_flags_t flags)
++{
++ vma->vm_flags &= ~flags;
++}
++#endif
++
+ #endif /* _NV_LINUX_H_ */
+diff --git a/kernel/nvidia-drm/nvidia-drm-gem-user-memory.c
b/kernel/nvidia-drm/nvidia-drm-gem-user-memory.c
+index 8824daa..3ea9099 100644
+--- a/kernel/nvidia-drm/nvidia-drm-gem-user-memory.c
++++ b/kernel/nvidia-drm/nvidia-drm-gem-user-memory.c
+@@ -35,6 +35,7 @@
+ #include "linux/dma-buf.h"
+ #include "linux/mm.h"
+ #include "nv-mm.h"
++#include "nv-linux.h"
+
+ static inline
+ void __nv_drm_gem_user_memory_free(struct nv_drm_gem_object *nv_gem)
+@@ -92,9 +93,9 @@ static int __nv_drm_gem_user_memory_mmap(struct nv_drm_gem_object
*nv_gem,
+ return -EINVAL;
+ }
+
+- vma->vm_flags &= ~VM_PFNMAP;
+- vma->vm_flags &= ~VM_IO;
+- vma->vm_flags |= VM_MIXEDMAP;
++ vm_flags_clear(vma, VM_PFNMAP);
++ vm_flags_clear(vma, VM_IO);
++ vm_flags_set(vma, VM_MIXEDMAP);
+
+ return 0;
+ }
+diff --git a/kernel/nvidia-uvm/uvm.c b/kernel/nvidia-uvm/uvm.c
+index 3e7318d..7eddff7 100644
+--- a/kernel/nvidia-uvm/uvm.c
++++ b/kernel/nvidia-uvm/uvm.c
+@@ -812,7 +812,7 @@ static int uvm_mmap(struct file *filp, struct vm_area_struct *vma)
+ // Using VM_DONTCOPY would be nice, but madvise(MADV_DOFORK) can reset that
+ // so we have to handle vm_open on fork anyway. We could disable MADV_DOFORK
+ // with VM_IO, but that causes other mapping issues.
+- vma->vm_flags |= VM_MIXEDMAP | VM_DONTEXPAND;
++ vm_flags_set(vma, VM_MIXEDMAP | VM_DONTEXPAND);
+
+ vma->vm_ops = &uvm_vm_ops_managed;
+
+diff --git a/kernel/nvidia/nv-mmap.c b/kernel/nvidia/nv-mmap.c
+index df514c9..8f85ff6 100644
+--- a/kernel/nvidia/nv-mmap.c
++++ b/kernel/nvidia/nv-mmap.c
+@@ -447,7 +447,7 @@ static int nvidia_mmap_numa(
+ }
+
+ // Needed for the linux kernel for mapping compound pages
+- vma->vm_flags |= VM_MIXEDMAP;
++ vm_flags_set(vma, VM_MIXEDMAP);
+
+ for (i = 0, addr = mmap_context->page_array[0]; i < pages;
+ addr = mmap_context->page_array[++i], start += PAGE_SIZE)
+@@ -596,7 +596,7 @@ int nvidia_mmap_helper(
+ }
+ up(&nvl->mmap_lock);
+
+- vma->vm_flags |= VM_IO | VM_PFNMAP | VM_DONTEXPAND;
++ vm_flags_set(vma, VM_IO | VM_PFNMAP | VM_DONTEXPAND);
+ }
+ else
+ {
+@@ -663,15 +663,15 @@ int nvidia_mmap_helper(
+
+ NV_PRINT_AT(NV_DBG_MEMINFO, at);
+
+- vma->vm_flags |= (VM_IO | VM_LOCKED | VM_RESERVED);
+- vma->vm_flags |= (VM_DONTEXPAND | VM_DONTDUMP);
++ vm_flags_set(vma, VM_IO | VM_LOCKED | VM_RESERVED);
++ vm_flags_set(vma, VM_DONTEXPAND | VM_DONTDUMP);
+ }
+
+ if ((prot & NV_PROTECT_WRITEABLE) == 0)
+ {
+ vma->vm_page_prot = NV_PGPROT_READ_ONLY(vma->vm_page_prot);
+- vma->vm_flags &= ~VM_WRITE;
+- vma->vm_flags &= ~VM_MAYWRITE;
++ vm_flags_clear(vma, VM_WRITE);
++ vm_flags_clear(vma, VM_MAYWRITE);
+ }
+
+ vma->vm_ops = &nv_vm_ops;
+--
+2.39.2
+