summaryrefslogtreecommitdiff
path: root/x11-drivers/nvidia-drivers
diff options
context:
space:
mode:
authorV3n3RiX <venerix@koprulu.sector>2024-09-15 12:43:19 +0100
committerV3n3RiX <venerix@koprulu.sector>2024-09-15 12:43:19 +0100
commitf9b4edae85ab8d924dc0c537962502f188e95ea9 (patch)
tree1304dc6757e63e6117bde0082d29e693c9f3ded0 /x11-drivers/nvidia-drivers
parent9484dba70d365375550e69d84f180d68b2a8a08d (diff)
x11-drivers/nvidia-drivers : use PreserveVideoMemoryAllocations=1
* https://gitweb.gentoo.org/repo/gentoo.git/commit/x11-drivers/nvidia-drivers?id=a0f953fc4720a191288b7e28c1df4ab50eb9a598 * https://bugs.gentoo.org/693384 * https://bugs.gentoo.org/873160 * https://github.com/gentoo/gentoo/pull/38482
Diffstat (limited to 'x11-drivers/nvidia-drivers')
-rw-r--r--x11-drivers/nvidia-drivers/files/nvidia-470.conf8
-rw-r--r--x11-drivers/nvidia-drivers/files/nvidia-545.conf8
-rw-r--r--x11-drivers/nvidia-drivers/files/system-sleep.elogind7
-rw-r--r--x11-drivers/nvidia-drivers/nvidia-drivers-470.256.02-r2.ebuild (renamed from x11-drivers/nvidia-drivers/nvidia-drivers-470.256.02-r1.ebuild)56
-rw-r--r--x11-drivers/nvidia-drivers/nvidia-drivers-550.107.02-r2.ebuild (renamed from x11-drivers/nvidia-drivers/nvidia-drivers-550.107.02-r1.ebuild)56
5 files changed, 129 insertions, 6 deletions
diff --git a/x11-drivers/nvidia-drivers/files/nvidia-470.conf b/x11-drivers/nvidia-drivers/files/nvidia-470.conf
index a20f2a19..1ba489dd 100644
--- a/x11-drivers/nvidia-drivers/files/nvidia-470.conf
+++ b/x11-drivers/nvidia-drivers/files/nvidia-470.conf
@@ -11,10 +11,12 @@ alias nouveau off
# Enabling may possibly cause issues with SLI and Reverse PRIME.
#options nvidia-drm modeset=1
-# Suspend options. Allocations=0 recommended over =1 unless enable nvidia's
-# systemd sleep services (nvidia-hibernate, nvidia-resume, nvidia-suspend).
+# Suspend options. Note that Allocations=1 requires suspend hooks currently
+# only used when either systemd or elogind is used to suspend. If using
+# neither or have issues, try Allocations=0 (revert if it does not help
+# as =0 is not recommended).
options nvidia \
- NVreg_PreserveVideoMemoryAllocations=0 \
+ NVreg_PreserveVideoMemoryAllocations=1 \
NVreg_TemporaryFilePath=/var/tmp
# !!! Security Warning !!!
diff --git a/x11-drivers/nvidia-drivers/files/nvidia-545.conf b/x11-drivers/nvidia-drivers/files/nvidia-545.conf
index ecb549e1..e8ca7805 100644
--- a/x11-drivers/nvidia-drivers/files/nvidia-545.conf
+++ b/x11-drivers/nvidia-drivers/files/nvidia-545.conf
@@ -16,10 +16,12 @@ alias nouveau off
# experimental, "may" cause issues X mode switching, sleep, or more).
#options nvidia-drm fbdev=1
-# Suspend options. Allocations=0 recommended over =1 unless enable nvidia's
-# systemd sleep services (nvidia-hibernate, nvidia-resume, nvidia-suspend).
+# Suspend options. Note that Allocations=1 requires suspend hooks currently
+# only used when either systemd or elogind is used to suspend. If using
+# neither or have issues, try Allocations=0 (revert if it does not help
+# as =0 is not recommended).
options nvidia \
- NVreg_PreserveVideoMemoryAllocations=0 \
+ NVreg_PreserveVideoMemoryAllocations=1 \
NVreg_TemporaryFilePath=/var/tmp
# !!! Security Warning !!!
diff --git a/x11-drivers/nvidia-drivers/files/system-sleep.elogind b/x11-drivers/nvidia-drivers/files/system-sleep.elogind
new file mode 100644
index 00000000..d36e2697
--- /dev/null
+++ b/x11-drivers/nvidia-drivers/files/system-sleep.elogind
@@ -0,0 +1,7 @@
+#!/bin/sh
+case ${1-} in
+ pre) nvidia-sleep.sh suspend;;
+ # run in background given resume is flaky if elogind did not finish
+ post) nvidia-sleep.sh resume &;;
+ *) exit 1;;
+esac
diff --git a/x11-drivers/nvidia-drivers/nvidia-drivers-470.256.02-r1.ebuild b/x11-drivers/nvidia-drivers/nvidia-drivers-470.256.02-r2.ebuild
index 6f731093..ff22d171 100644
--- a/x11-drivers/nvidia-drivers/nvidia-drivers-470.256.02-r1.ebuild
+++ b/x11-drivers/nvidia-drivers/nvidia-drivers-470.256.02-r2.ebuild
@@ -273,6 +273,22 @@ documentation that is installed alongside this README."
dobin nvidia-bug-report.sh
+ # enabling is needed for sleep to work properly and little reason not to do
+ # it unconditionally for a better user experience
+ : "$(systemd_get_systemunitdir)"
+ local unitdir=${_#"${EPREFIX}"}
+ # not using relative symlinks to match systemd's own links
+ dosym {"${unitdir}",/etc/systemd/system/systemd-hibernate.service.wants}/nvidia-hibernate.service
+ dosym {"${unitdir}",/etc/systemd/system/systemd-hibernate.service.wants}/nvidia-resume.service
+ dosym {"${unitdir}",/etc/systemd/system/systemd-suspend.service.wants}/nvidia-suspend.service
+ dosym {"${unitdir}",/etc/systemd/system/systemd-suspend.service.wants}/nvidia-resume.service
+ # also add a custom elogind hook to do the equivalent of the above
+ exeinto /usr/lib/elogind/system-sleep
+ newexe "${FILESDIR}"/system-sleep.elogind nvidia
+ # <elogind-255.5 used a different path (bug #939216), keep a compat symlink
+ # TODO: cleanup after 255.5 been stable for a few months
+ dosym {/usr/lib,/"${libdir}"}/elogind/system-sleep/nvidia
+
# symlink non-versioned so nvidia-settings can use it even if misdetected
dosym nvidia-application-profiles-${PV}-key-documentation \
${paths[APPLICATION_PROFILE]}/nvidia-application-profiles-key-documentation
@@ -313,6 +329,46 @@ pkg_postinst() {
ewarn "this may lead to system instability/freezes with this version of"
ewarn "${PN}. Bug: https://bugs.gentoo.org/796329"
fi
+
+ # these can be removed after some time, only to help the transition
+ # given users are unlikely to do further custom solutions if it works
+ # (see also https://github.com/elogind/elogind/issues/272)
+ if grep -riq "^[^#]*HandleNvidiaSleep=yes" "${EROOT}"/etc/elogind/sleep.conf.d/ 2>/dev/null
+ then
+ ewarn
+ ewarn "!!! WARNING !!!"
+ ewarn "Detected HandleNvidiaSleep=yes in ${EROOT}/etc/elogind/sleep.conf.d/."
+ ewarn "This 'could' cause issues if used in combination with the new hook"
+ ewarn "installed by the ebuild to handle sleep using the official upstream"
+ ewarn "script. It is recommended to disable the option."
+ fi
+ if [[ $(realpath "${EROOT}"{/etc,{/usr,}/lib*}/elogind/system-sleep | sort | uniq | \
+ xargs -d'\n' grep -Ril nvidia 2>/dev/null | wc -l) -gt 2 ]]
+ then
+ ewarn
+ ewarn "!!! WARNING !!!"
+ ewarn "Detected a custom script at ${EROOT}{/etc,{/usr,}/lib*}/elogind/system-sleep"
+ ewarn "referencing NVIDIA. This version of ${PN} has installed its own"
+ ewarn "hook at ${EROOT}/usr/lib/elogind/system-sleep/nvidia and it is recommended"
+ ewarn "to remove the custom one to avoid potential issues."
+ ewarn
+ ewarn "Feel free to ignore this warning if you know the other NVIDIA-related"
+ ewarn "scripts can be used together. The warning will be removed in the future."
+ fi
+ if [[ ${REPLACING_VERSIONS##* } ]] &&
+ ver_test ${REPLACING_VERSIONS##* } -lt 470.256.02-r1 # may get repeated
+ then
+ elog
+ elog "For suspend/sleep, 'NVreg_PreserveVideoMemoryAllocations=1' is now default"
+ elog "with this version of ${PN}. This is recommended (or required) by"
+ elog "major DEs especially with wayland but, *if* experience regressions with"
+ elog "suspend, try reverting to =0 in '${EROOT}/etc/modprobe.d/nvidia.conf'."
+ elog
+ elog "May notably be an issue when using neither systemd nor elogind to suspend."
+ elog
+ elog "Also, the systemd suspend/hibernate/resume services are now enabled by"
+ elog "default, and for openrc+elogind a similar hook has been installed."
+ fi
}
pkg_postrm() {
diff --git a/x11-drivers/nvidia-drivers/nvidia-drivers-550.107.02-r1.ebuild b/x11-drivers/nvidia-drivers/nvidia-drivers-550.107.02-r2.ebuild
index a17310c0..bad49990 100644
--- a/x11-drivers/nvidia-drivers/nvidia-drivers-550.107.02-r1.ebuild
+++ b/x11-drivers/nvidia-drivers/nvidia-drivers-550.107.02-r2.ebuild
@@ -293,6 +293,22 @@ documentation that is installed alongside this README."
doins nvidia-dbus.conf
fi
+ # enabling is needed for sleep to work properly and little reason not to do
+ # it unconditionally for a better user experience
+ : "$(systemd_get_systemunitdir)"
+ local unitdir=${_#"${EPREFIX}"}
+ # not using relative symlinks to match systemd's own links
+ dosym {"${unitdir}",/etc/systemd/system/systemd-hibernate.service.wants}/nvidia-hibernate.service
+ dosym {"${unitdir}",/etc/systemd/system/systemd-hibernate.service.wants}/nvidia-resume.service
+ dosym {"${unitdir}",/etc/systemd/system/systemd-suspend.service.wants}/nvidia-suspend.service
+ dosym {"${unitdir}",/etc/systemd/system/systemd-suspend.service.wants}/nvidia-resume.service
+ # also add a custom elogind hook to do the equivalent of the above
+ exeinto /usr/lib/elogind/system-sleep
+ newexe "${FILESDIR}"/system-sleep.elogind nvidia
+ # <elogind-255.5 used a different path (bug #939216), keep a compat symlink
+ # TODO: cleanup after 255.5 been stable for a few months
+ dosym {/usr/lib,/"${libdir}"}/elogind/system-sleep/nvidia
+
# symlink non-versioned so nvidia-settings can use it even if misdetected
dosym nvidia-application-profiles-${PV}-key-documentation \
${paths[APPLICATION_PROFILE]}/nvidia-application-profiles-key-documentation
@@ -333,6 +349,46 @@ pkg_postinst() {
ewarn "this may lead to system instability/freezes with this version of"
ewarn "${PN}. Bug: https://bugs.gentoo.org/796329"
fi
+
+ # these can be removed after some time, only to help the transition
+ # given users are unlikely to do further custom solutions if it works
+ # (see also https://github.com/elogind/elogind/issues/272)
+ if grep -riq "^[^#]*HandleNvidiaSleep=yes" "${EROOT}"/etc/elogind/sleep.conf.d/ 2>/dev/null
+ then
+ ewarn
+ ewarn "!!! WARNING !!!"
+ ewarn "Detected HandleNvidiaSleep=yes in ${EROOT}/etc/elogind/sleep.conf.d/."
+ ewarn "This 'could' cause issues if used in combination with the new hook"
+ ewarn "installed by the ebuild to handle sleep using the official upstream"
+ ewarn "script. It is recommended to disable the option."
+ fi
+ if [[ $(realpath "${EROOT}"{/etc,{/usr,}/lib*}/elogind/system-sleep | sort | uniq | \
+ xargs -d'\n' grep -Ril nvidia 2>/dev/null | wc -l) -gt 2 ]]
+ then
+ ewarn
+ ewarn "!!! WARNING !!!"
+ ewarn "Detected a custom script at ${EROOT}{/etc,{/usr,}/lib*}/elogind/system-sleep"
+ ewarn "referencing NVIDIA. This version of ${PN} has installed its own"
+ ewarn "hook at ${EROOT}/usr/lib/elogind/system-sleep/nvidia and it is recommended"
+ ewarn "to remove the custom one to avoid potential issues."
+ ewarn
+ ewarn "Feel free to ignore this warning if you know the other NVIDIA-related"
+ ewarn "scripts can be used together. The warning will be removed in the future."
+ fi
+ if [[ ${REPLACING_VERSIONS##* } ]] &&
+ ver_test ${REPLACING_VERSIONS##* } -lt 470.256.02-r1 # may get repeated
+ then
+ elog
+ elog "For suspend/sleep, 'NVreg_PreserveVideoMemoryAllocations=1' is now default"
+ elog "with this version of ${PN}. This is recommended (or required) by"
+ elog "major DEs especially with wayland but, *if* experience regressions with"
+ elog "suspend, try reverting to =0 in '${EROOT}/etc/modprobe.d/nvidia.conf'."
+ elog
+ elog "May notably be an issue when using neither systemd nor elogind to suspend."
+ elog
+ elog "Also, the systemd suspend/hibernate/resume services are now enabled by"
+ elog "default, and for openrc+elogind a similar hook has been installed."
+ fi
}
pkg_postrm() {