Skip to content

Commit

Permalink
nvidia: Replace hacky 6.12 fix with official patch from NVIDIA (#418)
Browse files Browse the repository at this point in the history
  • Loading branch information
1Naim authored Nov 14, 2024
1 parent 7832c72 commit 72ecfaf
Show file tree
Hide file tree
Showing 8 changed files with 125 additions and 151 deletions.
18 changes: 9 additions & 9 deletions nvidia/nvidia-utils/.SRCINFO
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
pkgbase = nvidia-utils
pkgver = 565.57.01
pkgrel = 2
pkgrel = 3
url = http://www.nvidia.com/
arch = x86_64
license = custom
Expand All @@ -17,9 +17,9 @@ pkgbase = nvidia-utils
source = 0001-Make-modeset-and-fbdev-default-enabled.patch
source = 0002-Do-not-error-on-unkown-CPU-Type-and-add-Zen5-support.patch
source = 0003-Add-IBT-support.patch
source = 0004-Fix-for-6.12.0-rc1-drm_mode_config_funcs.output_poll.patch
source = 0006-silence-event-assert-until-570.patch
source = 0009-fix-hdmi-names.patch
source = 0004-silence-event-assert-until-570.patch
source = 0005-nvkms-Sanitize-trim-ELD-product-name-strings.patch
source = 0006-nvidia-drm-Set-FOP_UNSIGNED_OFFSET-for-nv_drm_fops.f.patch
source = limit-vram-buffer
sha512sums = de7116c09f282a27920a1382df84aa86f559e537664bb30689605177ce37dc5067748acf9afd66a3269a6e323461356592fdfc624c86523bf105ff8fe47d3770
sha512sums = 4b3ad73f5076ba90fe0b3a2e712ac9cde76f469cd8070280f960c3ce7dc502d1927f525ae18d008075c8f08ea432f7be0a6c3a7a6b49c361126dcf42f97ec499
Expand All @@ -30,11 +30,11 @@ pkgbase = nvidia-utils
sha512sums = 8f5c0f06e13cf84042c9ad1d628ef3fd5aaffb116f1716b099e6ededb125e973a4a2c511bb6201e3a39d7710b2850c3418bdbeac792036b7524c5a5fc8746f52
sha512sums = 193755b00a5baa4b879b8b190c70c46ed3d48e6cee9b10e81218f85b3ab00cad7f38559f217d297e2478296e3fbc780d7ae47019ff9549ee1b55c15b52db744a
sha512sums = ca65143749f209c553ca5ba1a585d235d54840735958bd0d44b44a77263bbe5a1b9fb8e7e1d79425928d29b2e6af3437bf0d1cc16d3901aa4201b4f1430870cc
sha512sums = 5da26e5e109b0bef3db6625d8f8242fec515a780babebeb63930cf2200660013228d4f4352c72f605e6a4d536370c7384158c1c12e8c5c4fcd613e3ba543b5b4
sha512sums = c76cf956d6f1b67241eedc817610db95369d256c419a07cb0ddc0369360a5f90f62aba0f9a9dfb827212dc8a247ff97ec3690eca28afafb822b4b58873fd97f6
sha512sums = 7b2435b31ed733c00ff48dbb58b7b7885264308eabf21f3e04da9f00e819f1a162345e9c660628fa995989db7b7874bec40f2c2bbc36c2c9ee74a199cdb1503d
sha512sums = 587a6636561a1686f43bb1b85121a93d0dde5aca3aad848655149bdb8170a70f3262b4e38ef811badc68b0ca79ddded8f11a185182bc6899bbaf6ab4edf00fb4
sha512sums = a3c4d2c7136735a17cdd0763b87af5cce6f913fd7072c330b85a9a45718690a064ef9752e6eae571384af559eda48fe7ef7387bc87869c1b542d5ec8355a2a89
sha512sums = a32f4f9eb15ff24d8830af45700f49189b6e5804f6231dc094b1bf33227aa10f748b017b018ae20e313468ae984cfb828601b3877acd2376703a2f052f51e17f
sha512sums = 42f621179d4fd9bf608f0d84b9019f5a5fdf5d92d68d22ce9b9a9add1cad1c90dcb3764db68e0b9bc7e902bb6b955c59563ea6d4f39f2e39a340387e4d5deb82
sha512sums = 8aa049884011d6664be04fa9f70856f56342e0e4e931858a88b96b9f628157fad3105d67626e6c71aa4ed35cf46eaf5d9020d90de508dd69761a8b559bd7c25e
sha512sums = 73f9d230142d9501ccf3efd8d40ea3b08b69fdbbdbac583df638d25efe4d8c320af3bb809ee408872c9737e123541dc3dc4e59fbeedb199e091876ef31f2a0aa
sha512sums = a6cea65587c10408fd4c1b94fd233795faa0c2aa26e6245704d13b03cbce5392f9d159ba9494817e103a1c10dd1be8c1bb9f0bbfb790a80455139dbb53671aaf
sha512sums = 7f578c4bc6ebf4694c0bd81f30aee3510910088f9eea2c49128c9b3039b4d2ce69453f1b2baf2e1639ad0c51452af744c4767fb4cc1706f072b7e09d7ac6c735

pkgname = nvidia-utils
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
From 0638bf38e24b9fd304805686b4b8b4d8d127d21d Mon Sep 17 00:00:00 2001
From c0bf5aa9ab8205c5cf74356c3af6cbeb016765e6 Mon Sep 17 00:00:00 2001
From: Peter Jung <[email protected]>
Date: Fri, 18 Oct 2024 22:40:38 +0200
Subject: [PATCH 2/6] Do not error on unkown CPU Type and add Zen5 support
Expand Down
2 changes: 1 addition & 1 deletion nvidia/nvidia-utils/0003-Add-IBT-support.patch
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
From ca61ee8197185b9db1d1f1d61460c60a0933eeb3 Mon Sep 17 00:00:00 2001
From 1484c9ee0a60468dfd88954011fae0e28c0f73de Mon Sep 17 00:00:00 2001
From: Peter Jung <[email protected]>
Date: Fri, 18 Oct 2024 22:40:58 +0200
Subject: [PATCH 3/6] Add IBT support
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
From 348ca7e5e83bc36101172993f3aa60ae8ae5a2c7 Mon Sep 17 00:00:00 2001
From bc3a3a9b9617c85b259fd1aa2c5ce46f17fb1694 Mon Sep 17 00:00:00 2001
From: Peter Jung <[email protected]>
Date: Fri, 18 Oct 2024 22:44:33 +0200
Subject: [PATCH 6/6] silence-event-assert-until-570
Subject: [PATCH 4/6] silence-event-assert-until-570

Currently, when playing CS2 it reports a massive spam in the dmesg log. This will be fixed in the 570 driver.
Silence it for now.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
From 5dc6c82dbf58d7c9a801d0332f1eede5495bd7cb Mon Sep 17 00:00:00 2001
From e9df998a8915c45aff2f17f80a2711584fba9d5d Mon Sep 17 00:00:00 2001
From: Peter Jung <[email protected]>
Date: Fri, 18 Oct 2024 22:44:59 +0200
Subject: [PATCH 7/7] nvkms: Sanitize & trim ELD product name strings
Subject: [PATCH 5/6] nvkms: Sanitize & trim ELD product name strings

Signed-off-by: Peter Jung <[email protected]>
---
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
From b03fe816d7b2675afdb4c1d10fe7658a5f2b2f82 Mon Sep 17 00:00:00 2001
From: Rahul Rameshbabu <[email protected]>
Date: Tue, 12 Nov 2024 15:01:16 -0800
Subject: [PATCH 6/6] nvidia-drm: Set FOP_UNSIGNED_OFFSET for
nv_drm_fops.fop_flags if present

Linux kernel commit 641bb4394f40 ("fs: move FMODE_UNSIGNED_OFFSET to
fop_flags") introduced a new .fop_flags define, FOP_UNSIGNED_OFFSET, for
struct file_operations. A check in drm_open_helper was added to ensure DRM
device drivers mark that all file offsets passed for working with DRM fs
nodes are unsigned values. If a DRM device driver fails to set this static
member, opening DRM device nodes (/dev/dri/card*) will fail. This commit
will land in Linux kernel v6.12.

To ensure DRM clients will continue to function with kernel v6.12 and
above, set FOP_UNSIGNED_OFFSET for nv_drm_fops.fop_flags if
FOP_UNSIGNED_OFFSET is present in the linux kernel headers being built
against. Without doing so, userspace DRM clients will fail to function. An
example is being unable to launch Wayland compositors.

KWin logs without this change:
kwin_core: Failed to open /dev/dri/card1 device (Invalid argument)
kwin_wayland_drm: failed to open drm device at "/dev/dri/card1"
kwin_core: Failed to open /dev/dri/card0 device (Invalid argument)
kwin_wayland_drm: failed to open drm device at "/dev/dri/card0"
kwin_wayland_drm: No suitable DRM devices have been found

Linux kernel warning generated without this change:
[Oct 2 02:15] ------------[ cut here ]------------
[ +0.000009] WARNING: CPU: 2 PID: 464 at drivers/gpu/drm/drm_file.c:312 drm_open_helper+0x134/0x150
<snip>
[ +0.000108] Unloaded tainted modules: nvidia(OE):1 nvidia_modeset(OE):1 nvidia_drm(OE):1 [last unloaded: ttm]
[ +0.000024] CPU: 2 UID: 0 PID: 464 Comm: systemd-logind Tainted: G OE 6.12.0-rc1-next-20241001-sound+ #10 c8090f98b0209abebde89ba1e4c08c75331eef4d
[ +0.000016] Tainted: [O]=OOT_MODULE, [E]=UNSIGNED_MODULE
[ +0.000004] Hardware name: System manufacturer PRIME Z390-A/PRIME Z390-A, BIOS 0224 08/14/2018
[ +0.000005] RIP: 0010:drm_open_helper+0x134/0x150
<snip>
[ +0.000005] Call Trace:
[ +0.000006] <TASK>
[ +0.000004] ? drm_open_helper+0x134/0x150
[ +0.000008] ? __warn.cold+0x93/0xf6
[ +0.000011] ? drm_open_helper+0x134/0x150
[ +0.000009] ? report_bug+0xff/0x140
[ +0.000009] ? handle_bug+0x58/0x90
[ +0.000010] ? exc_invalid_op+0x17/0x70
[ +0.000010] ? asm_exc_invalid_op+0x1a/0x20
[ +0.000018] ? drm_open_helper+0x134/0x150
[ +0.000008] drm_open+0x73/0x110
[ +0.000007] drm_stub_open+0x9b/0xd0
[ +0.000009] chrdev_open+0xb0/0x230
[ +0.000014] ? __pfx_chrdev_open+0x10/0x10
[ +0.000011] do_dentry_open+0x14c/0x4a0
[ +0.000013] vfs_open+0x2e/0xe0
[ +0.000009] path_openat+0x82f/0x13f0
[ +0.000016] do_filp_open+0xc4/0x170
[ +0.000020] do_sys_openat2+0xae/0xe0
[ +0.000010] __x64_sys_openat+0x55/0xa0
[ +0.000009] do_syscall_64+0x82/0x190
[ +0.000008] ? do_readlinkat+0xc5/0x180
[ +0.000008] ? syscall_exit_to_user_mode+0x37/0x1c0
[ +0.000010] ? do_syscall_64+0x8e/0x190
[ +0.000007] ? do_sys_openat2+0x9c/0xe0
[ +0.000009] ? syscall_exit_to_user_mode+0x37/0x1c0
[ +0.000008] ? do_syscall_64+0x8e/0x190
[ +0.000007] ? syscall_exit_to_user_mode+0x37/0x1c0
[ +0.000007] ? do_syscall_64+0x8e/0x190
[ +0.000006] ? do_syscall_64+0x8e/0x190
[ +0.000007] entry_SYSCALL_64_after_hwframe+0x76/0x7e
[ +0.000012] RIP: 0033:0x7f90c1cec2e3
<snip>
[ +0.000004] ---[ end trace 0000000000000000 ]---

Signed-off-by: Rahul Rameshbabu <[email protected]>
---
kernel-open/nvidia-drm/nvidia-drm-drv.c | 4 ++++
1 file changed, 4 insertions(+)

diff --git a/kernel-open/nvidia-drm/nvidia-drm-drv.c b/kernel-open/nvidia-drm/nvidia-drm-drv.c
index 8cb94219..16f0d13e 100644
--- a/kernel-open/nvidia-drm/nvidia-drm-drv.c
+++ b/kernel-open/nvidia-drm/nvidia-drm-drv.c
@@ -1711,6 +1711,10 @@ static const struct file_operations nv_drm_fops = {
.read = drm_read,

.llseek = noop_llseek,
+
+#if defined(FOP_UNSIGNED_OFFSET)
+ .fop_flags = FOP_UNSIGNED_OFFSET,
+#endif
};

static const struct drm_ioctl_desc nv_drm_ioctls[] = {
--
2.47.0

30 changes: 15 additions & 15 deletions nvidia/nvidia-utils/PKGBUILD
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
pkgbase=nvidia-utils
pkgname=('nvidia-utils' 'opencl-nvidia' 'nvidia-dkms' 'nvidia-open-dkms')
pkgver=565.57.01
pkgrel=2
pkgrel=3
arch=('x86_64')
url="http://www.nvidia.com/"
license=('custom')
Expand All @@ -25,9 +25,9 @@ source=('nvidia-drm-outputclass.conf'
0001-Make-modeset-and-fbdev-default-enabled.patch
0002-Do-not-error-on-unkown-CPU-Type-and-add-Zen5-support.patch
0003-Add-IBT-support.patch
0004-Fix-for-6.12.0-rc1-drm_mode_config_funcs.output_poll.patch
0006-silence-event-assert-until-570.patch
0009-fix-hdmi-names.patch
0004-silence-event-assert-until-570.patch
0005-nvkms-Sanitize-trim-ELD-product-name-strings.patch
0006-nvidia-drm-Set-FOP_UNSIGNED_OFFSET-for-nv_drm_fops.f.patch
limit-vram-buffer)
sha512sums=('de7116c09f282a27920a1382df84aa86f559e537664bb30689605177ce37dc5067748acf9afd66a3269a6e323461356592fdfc624c86523bf105ff8fe47d3770'
'4b3ad73f5076ba90fe0b3a2e712ac9cde76f469cd8070280f960c3ce7dc502d1927f525ae18d008075c8f08ea432f7be0a6c3a7a6b49c361126dcf42f97ec499'
Expand All @@ -38,11 +38,11 @@ sha512sums=('de7116c09f282a27920a1382df84aa86f559e537664bb30689605177ce37dc50677
'8f5c0f06e13cf84042c9ad1d628ef3fd5aaffb116f1716b099e6ededb125e973a4a2c511bb6201e3a39d7710b2850c3418bdbeac792036b7524c5a5fc8746f52'
'193755b00a5baa4b879b8b190c70c46ed3d48e6cee9b10e81218f85b3ab00cad7f38559f217d297e2478296e3fbc780d7ae47019ff9549ee1b55c15b52db744a'
'ca65143749f209c553ca5ba1a585d235d54840735958bd0d44b44a77263bbe5a1b9fb8e7e1d79425928d29b2e6af3437bf0d1cc16d3901aa4201b4f1430870cc'
'5da26e5e109b0bef3db6625d8f8242fec515a780babebeb63930cf2200660013228d4f4352c72f605e6a4d536370c7384158c1c12e8c5c4fcd613e3ba543b5b4'
'c76cf956d6f1b67241eedc817610db95369d256c419a07cb0ddc0369360a5f90f62aba0f9a9dfb827212dc8a247ff97ec3690eca28afafb822b4b58873fd97f6'
'7b2435b31ed733c00ff48dbb58b7b7885264308eabf21f3e04da9f00e819f1a162345e9c660628fa995989db7b7874bec40f2c2bbc36c2c9ee74a199cdb1503d'
'587a6636561a1686f43bb1b85121a93d0dde5aca3aad848655149bdb8170a70f3262b4e38ef811badc68b0ca79ddded8f11a185182bc6899bbaf6ab4edf00fb4'
'a3c4d2c7136735a17cdd0763b87af5cce6f913fd7072c330b85a9a45718690a064ef9752e6eae571384af559eda48fe7ef7387bc87869c1b542d5ec8355a2a89'
'a32f4f9eb15ff24d8830af45700f49189b6e5804f6231dc094b1bf33227aa10f748b017b018ae20e313468ae984cfb828601b3877acd2376703a2f052f51e17f'
'42f621179d4fd9bf608f0d84b9019f5a5fdf5d92d68d22ce9b9a9add1cad1c90dcb3764db68e0b9bc7e902bb6b955c59563ea6d4f39f2e39a340387e4d5deb82'
'8aa049884011d6664be04fa9f70856f56342e0e4e931858a88b96b9f628157fad3105d67626e6c71aa4ed35cf46eaf5d9020d90de508dd69761a8b559bd7c25e'
'73f9d230142d9501ccf3efd8d40ea3b08b69fdbbdbac583df638d25efe4d8c320af3bb809ee408872c9737e123541dc3dc4e59fbeedb199e091876ef31f2a0aa'
'a6cea65587c10408fd4c1b94fd233795faa0c2aa26e6245704d13b03cbce5392f9d159ba9494817e103a1c10dd1be8c1bb9f0bbfb790a80455139dbb53671aaf'
'7f578c4bc6ebf4694c0bd81f30aee3510910088f9eea2c49128c9b3039b4d2ce69453f1b2baf2e1639ad0c51452af744c4767fb4cc1706f072b7e09d7ac6c735')


Expand All @@ -68,7 +68,7 @@ prepare() {
patch -Np1 < "$srcdir"/0001-Make-modeset-and-fbdev-default-enabled.patch -d "${srcdir}/${_pkg}/kernel"

# Add fix for 6.12 Kernel
patch -Np2 -i $srcdir/0004-Fix-for-6.12.0-rc1-drm_mode_config_funcs.output_poll.patch -d kernel/
patch -Np2 -i $srcdir/0006-nvidia-drm-Set-FOP_UNSIGNED_OFFSET-for-nv_drm_fops.f.patch -d kernel/

# echo "Applying nvidia-patch..."

Expand Down Expand Up @@ -110,17 +110,17 @@ DEST_MODULE_LOCATION[4]="/kernel/drivers/video"' dkms.conf
# Fix for https://bugs.archlinux.org/task/74886
patch -Np1 --no-backup-if-mismatch -i "$srcdir"/0003-Add-IBT-support.patch

# Fix for 6.12 Kernel
patch -Np1 --no-backup-if-mismatch -i "$srcdir"/0004-Fix-for-6.12.0-rc1-drm_mode_config_funcs.output_poll.patch

# Patch by Nvidia to silence error messages until a real fix drops in 570.xx
# https://github.com/NVIDIA/open-gpu-kernel-modules/issues/716#issuecomment-2391898884
patch -Np1 --no-backup-if-mismatch -i "$srcdir"/0006-silence-event-assert-until-570.patch
patch -Np1 --no-backup-if-mismatch -i "$srcdir"/0004-silence-event-assert-until-570.patch

# Patch by Nvidia to fix HDMI names which are otherwise broken in the /proc/asound/NVidia/* ELD files
# Should hopefully ship with 570.xx
# https://github.com/NVIDIA/open-gpu-kernel-modules/pull/715
patch -Np1 --no-backup-if-mismatch -i "$srcdir"/0009-fix-hdmi-names.patch
patch -Np1 --no-backup-if-mismatch -i "$srcdir"/0005-nvkms-Sanitize-trim-ELD-product-name-strings.patch

# Fix for 6.12 Kernel
patch -Np1 --no-backup-if-mismatch -i "$srcdir"/0006-nvidia-drm-Set-FOP_UNSIGNED_OFFSET-for-nv_drm_fops.f.patch

# Attempt to make this reproducible
sed -i "s/^HOSTNAME.*/HOSTNAME = echo cachyos"/ utils.mk
Expand Down

0 comments on commit 72ecfaf

Please sign in to comment.