From 3cd89c766ab34addb355f2d9fecdadf2d9a4456f Mon Sep 17 00:00:00 2001 From: Tk-Glitch Date: Sun, 1 Dec 2024 23:50:11 +0100 Subject: [PATCH] kernel-open: Conditionally apply make-modeset-fbdev-default, silence-event-assert-until-570, fix-hdmi-names and kernel-6.12 patches silence-event-assert-until-570 - https://github.com/NVIDIA/open-gpu-kernel-modules/issues/716#issuecomment-2391898884 fix-hdmi-names - https://github.com/NVIDIA/open-gpu-kernel-modules/pull/715 Hopefully will fix kernel-open 565 on 6.12. Fixes https://github.com/Frogging-Family/nvidia-all/issues/276 --- PKGBUILD | 41 +++++++++++++++++- patches/fix-hdmi-names.diff | 47 +++++++++++++++++++++ patches/silence-event-assert-until-570.diff | 18 ++++++++ 3 files changed, 104 insertions(+), 2 deletions(-) create mode 100644 patches/fix-hdmi-names.diff create mode 100644 patches/silence-event-assert-until-570.diff diff --git a/PKGBUILD b/PKGBUILD index 4614141..8aebc8f 100644 --- a/PKGBUILD +++ b/PKGBUILD @@ -308,7 +308,7 @@ fi pkgname=("${_pkgname_array[@]}") pkgver=$_driver_version -pkgrel=262 +pkgrel=263 arch=('x86_64') url="http://www.nvidia.com/" license=('custom:NVIDIA') @@ -388,6 +388,8 @@ source=($_source_name '6.11-fbdev.diff' 'nvidia-sleep.conf' 'kernel-6.12.patch' + 'silence-event-assert-until-570.diff' + 'fix-hdmi-names.diff' ) msg2 "Selected driver integrity check behavior (md5sum or SKIP): $_md5sum" # If the driver is "known", return md5sum. If it isn't, return SKIP @@ -446,7 +448,9 @@ md5sums=("$_md5sum" 'c691df97015eee42d51b34b147dd5236' 'adfcf56ea4a4a420d9ef07b9d4b451dc' '2b5b62c1265b3b6b18022a0a716e5fcd' - '676d7039ff5b5e2bdd03db08fd1cba4e') + '676d7039ff5b5e2bdd03db08fd1cba4e' + '0e54e7d932e520c403181e3348d4d42b' + '6904323d3a4ad04a708c927e930efc34') if [ "$_open_source_modules" = "true" ]; then if [[ "$_srcbase" == "NVIDIA-kernel-module-source" ]]; then @@ -521,6 +525,39 @@ prepare() { patch -Np1 --no-backup-if-mismatch -i "$srcdir"/nvidia-open-gcc-ibt-sls.diff fi + # Enable modeset and fbdev as default + # This avoids various issue, when Simplefb is used + # https://gitlab.archlinux.org/archlinux/packaging/packages/nvidia-utils/-/issues/14 + # https://github.com/rpmfusion/nvidia-kmod/blob/master/make_modeset_default.patch + if (( ${pkgver%%.*} < 565 )); then + msg2 "Applying make-modeset-fbdev-default.diff for kernel-open..." + ( cd "$srcdir"/"$_pkg"/kernel-open && patch -Np2 -i "$srcdir"/make-modeset-fbdev-default.diff ) + fi + + if (( ${pkgver%%.*} == 565 )); then + # Enable modeset and fbdev as default + # This avoids various issue, when Simplefb is used + # https://gitlab.archlinux.org/archlinux/packaging/packages/nvidia-utils/-/issues/14 + # https://github.com/rpmfusion/nvidia-kmod/blob/master/make_modeset_default.patch + msg2 "Applying make-modeset-fbdev-default-565.diff for kernel-open..." + ( cd "$srcdir"/"$_pkg"/kernel-open && patch -Np2 -i "$srcdir"/make-modeset-fbdev-default-565.diff ) + + # 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 + msg2 "Applying silence-event-assert-until-570.diff for kernel-open..." + patch -Np1 -i "$srcdir"/silence-event-assert-until-570.diff + + # 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 + msg2 "Applying fix-hdmi-names.diff for kernel-open..." + patch -Np1 -i "$srcdir"/fix-hdmi-names.diff + + # 6.12 - https://forums.developer.nvidia.com/t/patch-for-565-57-01-linux-kernel-6-12/313260 + msg2 "Applying kernel-6.12.patch for kernel-open..." + ( cd "$srcdir"/"$_pkg"/kernel-open && patch -Np2 -i "$srcdir"/kernel-6.12.patch ) + fi + # Attempt to make this reproducible sed -i "s/^HOSTNAME.*/HOSTNAME = echo archlinux"/ utils.mk sed -i "s/^WHOAMI.*/WHOAMI = echo archlinux-builder"/ utils.mk diff --git a/patches/fix-hdmi-names.diff b/patches/fix-hdmi-names.diff new file mode 100644 index 0000000..ec1cd13 --- /dev/null +++ b/patches/fix-hdmi-names.diff @@ -0,0 +1,47 @@ +From 2585511f4d92c57a77f3c144c86ba30017df338c Mon Sep 17 00:00:00 2001 +From: Aaron Plattner +Date: Fri, 4 Oct 2024 16:01:54 -0700 +Subject: [PATCH] nvkms: Sanitize & trim ELD product name strings + +--- + src/nvidia-modeset/src/nvkms-hdmi.c | 26 ++++++-------------------- + 1 file changed, 6 insertions(+), 20 deletions(-) + +diff --git a/src/nvidia-modeset/src/nvkms-hdmi.c b/src/nvidia-modeset/src/nvkms-hdmi.c +index 1dbc6c482..963c47f6f 100644 +--- a/src/nvidia-modeset/src/nvkms-hdmi.c ++++ b/src/nvidia-modeset/src/nvkms-hdmi.c +@@ -1030,27 +1030,13 @@ static NvBool FillELDBuffer(const NVDpyEvoRec *pDpyEvo, + + if (status == NVT_STATUS_SUCCESS) { + /* +- * NvTiming_GetProductName() returns a nul-terminated string, but the +- * string in the EDID is terminated with 0x0A and padded with 0x20. +- * Put back these special characters. ++ * NvTiming_GetProductName returns a nul-terminated string. Figure out ++ * how long it is and copy the bytes up to, but not including, the nul ++ * terminator. + */ +- NvBool pastTerminator = FALSE; +- NvU32 i; +- +- for (i = 0; i < NVT_EDID_LDD_PAYLOAD_SIZE; i++) { +- if (pastTerminator) { +- name[i] = 0x20; +- } +- if (name[i] == '\0') { +- name[i] = 0x0A; +- pastTerminator = TRUE; +- } +- } +- +- monitorNameLen = NVT_EDID_LDD_PAYLOAD_SIZE; +- pEld->buffer[4] |= NVT_EDID_LDD_PAYLOAD_SIZE; +- nvkms_memcpy(&pEld->buffer[20], name, +- NVT_EDID_LDD_PAYLOAD_SIZE); ++ monitorNameLen = nvkms_strlen((char *)name); ++ pEld->buffer[4] |= monitorNameLen; ++ nvkms_memcpy(&pEld->buffer[20], name, monitorNameLen); + } + + /* offset 20 + MNL ~ 20 + MNL + (3 * SAD_Count) - 1 : CEA_SADs */ diff --git a/patches/silence-event-assert-until-570.diff b/patches/silence-event-assert-until-570.diff new file mode 100644 index 0000000..0dc0b0b --- /dev/null +++ b/patches/silence-event-assert-until-570.diff @@ -0,0 +1,18 @@ +diff --git a/src/nvidia/src/kernel/rmapi/event_notification.c b/src/nvidia/src/kernel/rmapi/event_notification.c +index cf78eadd..d6937cac 100644 +--- a/src/nvidia/src/kernel/rmapi/event_notification.c ++++ b/src/nvidia/src/kernel/rmapi/event_notification.c +@@ -286,11 +286,11 @@ static NV_STATUS _gpuEngineEventNotificationListNotify + portSyncSpinlockAcquire(pEventNotificationList->pSpinlock); + { + // We don't expect this to be called multiple times in parallel +- NV_ASSERT_OR_ELSE(pEventNotificationList->pendingEventNotifyCount == 0, ++ if (pEventNotificationList->pendingEventNotifyCount != 0) + { + portSyncSpinlockRelease(pEventNotificationList->pSpinlock); + return NV_ERR_INVALID_STATE; +- }); ++ } + + EngineEventNotificationListIter it = + listIterAll(&pEventNotificationList->eventNotificationList);