Tk-Glitch 2023-05-12 23:53:43 +02:00
parent 4b020d30d1
commit f01f9741f3
2 changed files with 147 additions and 4 deletions

View File

@ -48,7 +48,7 @@ if [ -z "$_driver_version" ] || [ "$_driver_version" = "latest" ] || [ -z "$_dri
fi
fi
if [[ -z $CONDITION ]]; then
read -p " What driver version do you want?`echo $'\n > 1.Vulkan dev: 525.47.22\n 2.530 series: 530.41.03\n 3.525 series: 525.116.03\n 4.520 series: 520.56.06\n 5.515 series: 515.86.01\n 6.510 series: 510.85.02\n 7.495 series: 495.46\n 8.470 series: 470.161.03\n 9.Older series\n 10.Custom version (396.xx series or higher)\n choice[1-9?]: '`" CONDITION;
read -p " What driver version do you want?`echo $'\n > 1.Vulkan dev: 525.47.22\n 2.530 series: 530.41.03\n 3.525 series: 525.116.03\n 4.520 series: 520.56.06\n 5.515 series: 515.86.01\n 6.510 series: 510.85.02\n 7.495 series: 495.46\n 8.470 series: 470.182.03\n 9.Older series\n 10.Custom version (396.xx series or higher)\n choice[1-9?]: '`" CONDITION;
fi
# This will be treated as the latest regular driver.
if [ "$CONDITION" = "2" ]; then
@ -76,8 +76,8 @@ if [ -z "$_driver_version" ] || [ "$_driver_version" = "latest" ] || [ -z "$_dri
echo '_md5sum=db1d6b0f9e590249bbf940a99825f000' >> options
echo '_driver_branch=regular' >> options
elif [ "$CONDITION" = "8" ]; then
echo '_driver_version=470.161.03' > options
echo '_md5sum=0652fff030ee29664ad728dd86e9f5d6' >> options
echo '_driver_version=470.182.03' > options
echo '_md5sum=33e5a97d5f05fcf3474b69a95a2ade5d' >> options
echo '_driver_branch=regular' >> options
elif [ "$CONDITION" = "9" ]; then
read -p " Which legacy driver version do you want?`echo $'\n > 1.465 series: 465.31\n 2.460 series: 460.91.03\n 3.455 series: 455.45.01\n 4.450 series: 450.119.03\n 5.440 series: 440.100 (kernel 5.8 or lower)\n 6.435 series: 435.21 (kernel 5.6 or lower)\n 7.430 series: 430.64 (kernel 5.5 or lower)\n 8.418 series: 418.113 (kernel 5.5 or lower)\n 9.415 series: 415.27 (kernel 5.4 or lower)\n 10.410 series: 410.104 (kernel 5.5 or lower)\n 11.396 series: 396.54 (kernel 5.3 or lower, 5.1 or lower recommended)\n choice[1-11?]: '`" CONDITION;
@ -350,6 +350,7 @@ source=($_source_name
'kernel-6.0.patch'
'kernel-6.0-470.patch' # acpi backports from 515.x for 470.x
'kernel-6.2.patch'
'kernel-6.3.patch'
)
msg2 "Selected driver integrity check behavior (md5sum or SKIP): $_md5sum" # If the driver is "known", return md5sum. If it isn't, return SKIP
@ -393,7 +394,8 @@ md5sums=("$_md5sum"
'a70bc9cbbc7e8563b48985864a11de71'
'31128900574dec9ebdb753db50ef4f16'
'0b9b855d9be313153a5903e46e774a30'
'5d573b1aa0712b9bd2000c9fefdf84c2')
'5d573b1aa0712b9bd2000c9fefdf84c2'
'a6acbba08173769399658914eb86a212')
if [ "$_open_source_modules" = "true" ]; then
source+=("$pkgname-$pkgver.tar.gz::https://github.com/NVIDIA/open-gpu-kernel-modules/archive/refs/tags/${pkgver}.tar.gz")
@ -793,6 +795,12 @@ DEST_MODULE_LOCATION[3]="/kernel/drivers/video"' dkms.conf
_whitelist62=( 525.5* 525.6* 525.7* )
fi
# 6.3
if (( $(vercmp "$_kernel" "6.3") >= 0 )); then
_kernel63="1"
_whitelist63=( 470* )
fi
# Loop patches (linux-4.15.patch, lol.patch, ...)
for _p in $(printf -- '%s\n' ${source[@]} | grep .patch); do # https://stackoverflow.com/a/21058239/1821548
# Patch version (4.15, "", ...)
@ -861,6 +869,9 @@ DEST_MODULE_LOCATION[3]="/kernel/drivers/video"' dkms.conf
if [ "$_patch" = "6.2" ]; then
_whitelist=(${_whitelist62[@]})
fi
if [ "$_patch" = "6.3" ]; then
_whitelist=(${_whitelist63[@]})
fi
patchy=0
if (( $(vercmp "$_kernel" "$_patch") >= 0 )); then
@ -1227,6 +1238,20 @@ DEST_MODULE_LOCATION[3]="/kernel/drivers/video"' dkms.conf
fi
fi
# 6.3
if [ "$_kernel63" = "1" ]; then
patchy=0
for yup in "${_whitelist63[@]}"; do
[[ $pkgver = $yup ]] && patchy=1
done
if [ "$patchy" = "1" ]; then
msg2 "Applying kernel-6.3.patch for dkms..."
patch -Np1 -i "$srcdir"/kernel-6.3.patch
else
msg2 "Skipping kernel-6.3.patch as it doesn't apply to this driver version..."
fi
fi
# Legacy quirks
if [ "$_oldstuff" = "1" ]; then
msg2 "Applying 01-ipmi-vm.diff for dkms..."

118
patches/kernel-6.3.patch Normal file
View File

@ -0,0 +1,118 @@
From a77f2da778f4a62695a6c7d26bba674d59ad9170 Mon Sep 17 00:00:00 2001
From: Joan Bruguera <joanbrugueram@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
---
common/inc/nv-linux.h | 13 +++++++++++++
nvidia-drm/nvidia-drm-gem-user-memory.c | 7 ++++---
nvidia-uvm/uvm.c | 2 +-
nvidia/nv-mmap.c | 12 ++++++------
4 files changed, 24 insertions(+), 10 deletions(-)
diff --git a/kernel-dkms/common/inc/nv-linux.h b/kernel-dkms/common/inc/nv-linux.h
index f8df9e3..5b22cf1 100644
--- a/kernel-dkms/common/inc/nv-linux.h
+++ b/kernel-dkms/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-dkms/nvidia-drm/nvidia-drm-gem-user-memory.c b/kernel-dkms/nvidia-drm/nvidia-drm-gem-user-memory.c
index 8824daa..3ea9099 100644
--- a/kernel-dkms/nvidia-drm/nvidia-drm-gem-user-memory.c
+++ b/kernel-dkms/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-dkms/nvidia-uvm/uvm.c b/kernel-dkms/nvidia-uvm/uvm.c
index 3e7318d..7eddff7 100644
--- a/kernel-dkms/nvidia-uvm/uvm.c
+++ b/kernel-dkms/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-dkms/nvidia/nv-mmap.c b/kernel-dkms/nvidia/nv-mmap.c
index df514c9..8f85ff6 100644
--- a/kernel-dkms/nvidia/nv-mmap.c
+++ b/kernel-dkms/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