From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id A1937139349 for ; Tue, 20 Jul 2021 01:23:50 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id B83C2E0BAA; Tue, 20 Jul 2021 01:23:49 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 90C7EE0BAA for ; Tue, 20 Jul 2021 01:23:49 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 944FE342AED for ; Tue, 20 Jul 2021 01:23:48 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id A5CCF7E3 for ; Tue, 20 Jul 2021 01:23:45 +0000 (UTC) From: "Ionen Wolkens" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Ionen Wolkens" Message-ID: <1626744045.5bacb36e4a3d08961a9446fd82d3429062bb7443.ionen@gentoo> Subject: [gentoo-commits] repo/gentoo:master commit in: x11-drivers/nvidia-drivers/files/, x11-drivers/nvidia-drivers/ X-VCS-Repository: repo/gentoo X-VCS-Files: x11-drivers/nvidia-drivers/files/nvidia-470.conf x11-drivers/nvidia-drivers/nvidia-drivers-470.57.02.ebuild X-VCS-Directories: x11-drivers/nvidia-drivers/ x11-drivers/nvidia-drivers/files/ X-VCS-Committer: ionen X-VCS-Committer-Name: Ionen Wolkens X-VCS-Revision: 5bacb36e4a3d08961a9446fd82d3429062bb7443 X-VCS-Branch: master Date: Tue, 20 Jul 2021 01:23:45 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: 0b83b09b-5b56-48b1-b666-e7604201e8c2 X-Archives-Hash: 88281e2b707f3f1b2705ea2454b26b5e commit: 5bacb36e4a3d08961a9446fd82d3429062bb7443 Author: Ionen Wolkens gentoo org> AuthorDate: Mon Jul 19 20:40:07 2021 +0000 Commit: Ionen Wolkens gentoo org> CommitDate: Tue Jul 20 01:20:45 2021 +0000 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=5bacb36e 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 gentoo.org> x11-drivers/nvidia-drivers/files/nvidia-470.conf | 31 ++++++++++++ .../nvidia-drivers/nvidia-drivers-470.57.02.ebuild | 56 +++++++++++++++------- 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 00000000000..4e363d2b278 --- /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 e93f07b1e50..ea8905ecfe0 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} ]] &&