summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIonen Wolkens <ionen@gentoo.org>2021-07-19 16:40:07 -0400
committerIonen Wolkens <ionen@gentoo.org>2021-07-19 21:20:45 -0400
commit5bacb36e4a3d08961a9446fd82d3429062bb7443 (patch)
tree5dd641ca24513a77185690f8441b031d36b29fc2 /x11-drivers/nvidia-drivers
parentgui-libs/egl-wayland: adjust nvidia-drivers blocker (diff)
downloadgentoo-5bacb36e4a3d08961a9446fd82d3429062bb7443.tar.gz
gentoo-5bacb36e4a3d08961a9446fd82d3429062bb7443.tar.bz2
gentoo-5bacb36e4a3d08961a9446fd82d3429062bb7443.zip
x11-drivers/nvidia-drivers: add IUSE=wayland, revamp nvidia.conf
In order use wayland features with nvidia-drivers, there's currently a need to both emerge egl-wayland (optfeature), and set nvidia-drm.modeset=1 manually. To provide a more reliable out-of-the-box experience with global USE=wayland, perform these actions if the flag is set. Should notably be useful for gnome profiles. To better handle such module settings, creating a new nvidia-470.conf that combines nvidia-{460,rmmod,blacklist-nouveau}.conf and the nvidia-drm.conf formerly suggested by the egl-wayland package. Signed-off-by: Ionen Wolkens <ionen@gentoo.org>
Diffstat (limited to 'x11-drivers/nvidia-drivers')
-rw-r--r--x11-drivers/nvidia-drivers/files/nvidia-470.conf31
-rw-r--r--x11-drivers/nvidia-drivers/nvidia-drivers-470.57.02.ebuild56
2 files changed, 69 insertions, 18 deletions
diff --git a/x11-drivers/nvidia-drivers/files/nvidia-470.conf b/x11-drivers/nvidia-drivers/files/nvidia-470.conf
new file mode 100644
index 000000000000..4e363d2b2780
--- /dev/null
+++ b/x11-drivers/nvidia-drivers/files/nvidia-470.conf
@@ -0,0 +1,31 @@
+# NVIDIA modules options
+# See /usr/share/doc/nvidia-drivers-*/README.txt* for more information.
+
+# nvidia-drivers and nouveau cannot be used at same time.
+# Comment out the following line if you wish to allow nouveau.
+blacklist nouveau
+
+# Kernel Mode Setting (needed for PRIME offloading, and EGLStream/Wayland)
+# This may need to be disabled if using SLI (Scalable Link Interface).
+#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).
+options nvidia \
+ NVreg_PreserveVideoMemoryAllocations=0 \
+ NVreg_TemporaryFilePath=/var/tmp
+
+# !!! Security Warning !!!
+# Do not change the DeviceFile options unless you know what you are doing.
+# Only add trusted users to the 'video' group, these users may be able to
+# crash, compromise, or irreparably damage the machine.
+options nvidia \
+ NVreg_DeviceFileGID=@VIDEOGID@ \
+ NVreg_DeviceFileMode=432 \
+ NVreg_DeviceFileUID=0 \
+ NVreg_ModifyDeviceFiles=1
+
+# Should be no need to touch anything below.
+alias char-major-195 nvidia
+alias /dev/nvidiactl char-major-195
+remove nvidia modprobe -r --ignore-remove nvidia-drm nvidia-modeset nvidia-uvm nvidia
diff --git a/x11-drivers/nvidia-drivers/nvidia-drivers-470.57.02.ebuild b/x11-drivers/nvidia-drivers/nvidia-drivers-470.57.02.ebuild
index e93f07b1e500..ea8905ecfe09 100644
--- a/x11-drivers/nvidia-drivers/nvidia-drivers-470.57.02.ebuild
+++ b/x11-drivers/nvidia-drivers/nvidia-drivers-470.57.02.ebuild
@@ -4,7 +4,7 @@
EAPI=7
MODULES_OPTIONAL_USE="driver"
-inherit desktop linux-info linux-mod multilib-build optfeature \
+inherit desktop linux-info linux-mod multilib-build \
readme.gentoo-r1 systemd toolchain-funcs unpacker
NV_KERNEL_MAX="5.13"
@@ -26,7 +26,7 @@ S="${WORKDIR}"
LICENSE="GPL-2 MIT NVIDIA-r2 ZLIB"
SLOT="0/${PV%%.*}"
KEYWORDS="-* ~amd64"
-IUSE="+X +driver static-libs +tools"
+IUSE="+X +driver static-libs +tools wayland"
COMMON_DEPEND="
acct-group/video
@@ -50,7 +50,8 @@ RDEPEND="
media-libs/libglvnd[X,${MULTILIB_USEDEP}]
x11-libs/libX11[${MULTILIB_USEDEP}]
x11-libs/libXext[${MULTILIB_USEDEP}]
- )"
+ )
+ wayland? ( >=gui-libs/egl-wayland-1.1.7-r1 )"
DEPEND="
${COMMON_DEPEND}
static-libs? (
@@ -74,19 +75,13 @@ QA_PREBUILT="lib/firmware/* opt/bin/* usr/lib*"
PATCHES=(
"${FILESDIR}"/nvidia-modprobe-390.141-uvm-perms.patch
)
+
DOCS=(
README.txt NVIDIA_Changelog supported-gpus/supported-gpus.json
nvidia-settings/doc/{FRAMELOCK,NV-CONTROL-API}.txt
)
HTML_DOCS=( html/. )
-DISABLE_AUTOFORMATTING="yes"
-DOC_CONTENTS="Users should be in the 'video' group to use NVIDIA devices.
-You can add yourself by using: gpasswd -a my-user video
-
-For general information on using nvidia-drivers, please see:
-https://wiki.gentoo.org/wiki/NVIDIA/nvidia-drivers"
-
pkg_setup() {
use driver || return
@@ -166,6 +161,12 @@ src_prepare() {
nvidia-persistenced/init/systemd/nvidia-persistenced.service.template \
> nvidia-persistenced.service || die
+ # enable nvidia-drm.modeset=1 by default with USE=wayland
+ cp "${FILESDIR}"/nvidia-470.conf "${T}"/nvidia.conf || die
+ if use wayland; then
+ sed -i '/^#.*modeset=1$/s/^#//' "${T}"/nvidia.conf || die
+ fi
+
gzip -d nvidia-{cuda-mps-control,smi}.1.gz || die
}
@@ -274,9 +275,7 @@ src_install() {
linux-mod_src_install
insinto /etc/modprobe.d
- newins "${FILESDIR}"/nvidia-460.conf nvidia.conf
- doins "${FILESDIR}"/nvidia-blacklist-nouveau.conf
- doins "${FILESDIR}"/nvidia-rmmod.conf
+ doins "${T}"/nvidia.conf
insinto /lib/firmware/nvidia/${PV}
doins firmware/gsp.bin
@@ -370,8 +369,19 @@ src_install() {
dobin systemd/nvidia-sleep.sh
systemd_dounit systemd/system/nvidia-{hibernate,resume,suspend}.service
- einstalldocs
+ # create README.gentoo
+ local DISABLE_AUTOFORMATTING="yes"
+ local DOC_CONTENTS=\
+"Trusted users should be in the 'video' group to use NVIDIA devices.
+You can add yourself by using: gpasswd -a my-user video
+
+See '${EPREFIX}/etc/modprobe.d/nvidia.conf' for modules options.
+
+For general information on using nvidia-drivers, please see:
+https://wiki.gentoo.org/wiki/NVIDIA/nvidia-drivers"
readme.gentoo_create_doc
+
+ einstalldocs
}
pkg_preinst() {
@@ -381,8 +391,7 @@ pkg_preinst() {
# set video group id based on live system (bug #491414)
local g=$(getent group video | cut -d: -f3)
[[ ${g} ]] || die "Failed to determine video group id"
- sed "s/PACKAGE/${PF}/;s/VIDEOGID/${g}/" \
- -i "${ED}"/etc/modprobe.d/nvidia.conf || die
+ sed -i "s/@VIDEOGID@/${g}/" "${ED}"/etc/modprobe.d/nvidia.conf || die
# try to find driver mismatches using temporary supported-gpus.json
for g in $(grep -l 0x10de /sys/bus/pci/devices/*/vendor 2>/dev/null); do
@@ -397,6 +406,8 @@ pkg_preinst() {
fi
done
rm "${ED}"/usr/share/nvidia/supported-gpus.json || die
+
+ has_version "x11-drivers/nvidia-drivers[wayland]" && NV_HAD_WAYLAND=1
}
pkg_postinst() {
@@ -404,8 +415,6 @@ pkg_postinst() {
readme.gentoo_print_elog
- optfeature "wayland EGLStream with nvidia-drm.modeset=1" gui-libs/egl-wayland
-
if [[ -r /proc/driver/nvidia/version &&
$(grep -o ' [0-9.]* ' /proc/driver/nvidia/version) != " ${PV} " ]]; then
ewarn "Currently loaded NVIDIA modules do not match the newly installed"
@@ -425,6 +434,17 @@ pkg_postinst() {
ewarn "https://www.nvidia.com/object/IO_32667.html"
fi
+ if use wayland && use driver && [[ ! ${NV_HAD_WAYLAND} ]]; then
+ elog
+ elog "With USE=wayland, this version of ${PN} sets nvidia-drm.modeset=1"
+ elog "in '${EROOT}/etc/modprobe.d/nvidia.conf'. This feature is considered"
+ elog "experimental but is required for EGLStream (used for wayland acceleration"
+ elog "in compositors that support it) and PRIME offloading."
+ elog
+ elog "If you experience issues, please comment out the option from nvidia.conf."
+ elog "It is notably known to cause problems with SLI (Scalable Link Interface)."
+ fi
+
# Try to show this message only to users that may really need it
# given the workaround is discouraged and usage isn't widespread.
if use X && [[ ${REPLACING_VERSIONS} ]] &&