system/nvidia-open-kernel: Add patch for 6.x kernels.

Signed-off-by: Willy Sudiarto Raharjo <willysr@slackbuilds.org>
This commit is contained in:
Lenard Spencer 2024-02-07 06:33:44 +07:00 committed by Willy Sudiarto Raharjo
parent 8b33a40697
commit 6c9b208ad7
No known key found for this signature in database
GPG Key ID: 3F617144D7238786
2 changed files with 49 additions and 1 deletions

View File

@ -28,7 +28,7 @@ cd $(dirname $0) ; CWD=$(pwd)
PRGNAM=nvidia-open-kernel
VERSION=${VERSION:-535.154.05}
BUILD=${BUILD:-1}
BUILD=${BUILD:-2}
TAG=${TAG:-_SBo}
PKGTYPE=${PKGTYPE:-tgz}
@ -83,6 +83,9 @@ find -L . \
\( -perm 666 -o -perm 664 -o -perm 640 -o -perm 600 -o -perm 444 \
-o -perm 440 -o -perm 400 \) -exec chmod 644 {} \;
# Patch for latest 6.x kernels:
patch -p1 < $CWD/nvidia-open-rcu_read_lock-unlock.patch
# CC=${CC:-gcc} suppresses an otherwise harmless "compiler mismatch"
# message. If you custom-build your kernel with clang,
# then pass CC=clang to this script.

View File

@ -0,0 +1,45 @@
--- a/kernel-open/common/inc/nv-linux.h
+++ b/kernel-open/common/inc/nv-linux.h
@@ -1990,2 +1990,23 @@
+#if defined(CONFIG_HAVE_ARCH_PFN_VALID) || LINUX_VERSION_CODE < KERNEL_VERSION(6,1,76)
+# define nv_pfn_valid pfn_valid
+#else
+/* pre-6.1.76 kernel pfn_valid version without GPL rcu_read_lock/unlock() */
+static inline int nv_pfn_valid(unsigned long pfn)
+{
+ struct mem_section *ms;
+
+ if (PHYS_PFN(PFN_PHYS(pfn)) != pfn)
+ return 0;
+
+ if (pfn_to_section_nr(pfn) >= NR_MEM_SECTIONS)
+ return 0;
+
+ ms = __pfn_to_section(pfn);
+ if (!valid_section(ms))
+ return 0;
+
+ return early_section(ms) || pfn_section_valid(ms, pfn);
+}
+#endif
#endif /* _NV_LINUX_H_ */
--- a/kernel-open/nvidia/nv-mmap.c
+++ b/kernel-open/nvidia/nv-mmap.c
@@ -576,3 +576,3 @@
if (!IS_REG_OFFSET(nv, access_start, access_len) &&
- (pfn_valid(PFN_DOWN(mmap_start))))
+ (nv_pfn_valid(PFN_DOWN(mmap_start))))
{
--- a/kernel-open/nvidia/os-mlock.c
+++ b/kernel-open/nvidia/os-mlock.c
@@ -102,3 +102,3 @@
if ((nv_follow_pfn(vma, (start + (i * PAGE_SIZE)), &pfn) < 0) ||
- (!pfn_valid(pfn)))
+ (!nv_pfn_valid(pfn)))
{
@@ -176,3 +176,3 @@
- if (pfn_valid(pfn))
+ if (nv_pfn_valid(pfn))
{