Add udev rules for node presence and runtime PM

Based on https://github.com/negativo17/nvidia-kmod-common/blob/master/60-nvidia.rules

Supposedly helps with https://github.com/HansKristian-Work/vkd3d-proton/issues/711

Thanks to @aufkrawall for pinging
This commit is contained in:
Tk-Glitch 2021-10-01 16:30:50 +02:00
parent 8789c27a28
commit 7c0bbf61a7
2 changed files with 31 additions and 3 deletions

View File

@ -226,7 +226,7 @@ fi
pkgname=("${_pkgname_array[@]}")
pkgver=$_driver_version
pkgrel=178
pkgrel=179
arch=('x86_64')
url="http://www.nvidia.com/"
license=('custom:NVIDIA')
@ -252,6 +252,7 @@ fi
source=($_source_name
'10-nvidia-drm-outputclass.conf'
'nvidia-utils-tkg.sysusers'
'60-nvidia.rules'
'linux-version.diff' # include linux version
'01-ipmi-vm.diff' # ipmi & vm patch for older than 415.22 releases (2018.12.7) (396.xx)
'02-ipmi-vm.diff' # ipmi & vm patch for older than 415.22 releases (2018.12.7) (addon for 410+)
@ -287,6 +288,7 @@ msg2 "Selected driver integrity check behavior (md5sum or SKIP): $_md5sum" # If
md5sums=("$_md5sum"
'cb27b0f4a78af78aa96c5aacae23256c'
'3d2894e71d81570bd00bce416d3e547d'
'3d32130235acc5ab514e1021f7f5c439'
'7a825f41ada7e106c8c0b713a49b3bfa'
'd961d1dce403c15743eecfe3201e4b6a'
'14460615a9d4e247c8d9bcae8776ed48'
@ -1277,6 +1279,8 @@ nvidia-utils-tkg() {
install -Dm644 "$srcdir"/nvidia-utils-tkg.sysusers "$pkgdir"/usr/lib/sysusers.d/$pkgname.conf
install -Dm644 "$srcdir"/60-nvidia.rules "$pkgdir"/usr/lib/udev/rules.d/60-nvidia.rules
_create_links
}
package_nvidia-utils-tkg() {
@ -1334,7 +1338,7 @@ if [ "$_dkms" = "false" ] || [ "$_dkms" = "full" ]; then
find "$pkgdir" -name '*.ko' -exec gzip -n {} +
done
echo "blacklist nouveau" |
echo -e "blacklist nouveau\nblacklist lbm-nouveau\nalias nouveau off\nalias lbm-nouveau off" |
install -Dm644 /dev/stdin "${pkgdir}/usr/lib/modprobe.d/${pkgname}.conf"
}
package_nvidia-tkg() {
@ -1449,7 +1453,7 @@ if [ "$_dkms" = "true" ] || [ "$_dkms" = "full" ]; then
install -dm 755 "${pkgdir}"/usr/{lib/modprobe.d,src}
cp -dr --no-preserve='ownership' kernel-dkms "${pkgdir}/usr/src/nvidia-${pkgver}"
echo "blacklist nouveau" |
echo -e "blacklist nouveau\nblacklist lbm-nouveau\nalias nouveau off\nalias lbm-nouveau off" |
install -Dm644 /dev/stdin "${pkgdir}/usr/lib/modprobe.d/${pkgname}.conf"
install -Dt "${pkgdir}/usr/share/licenses/${pkgname}" -m644 "${srcdir}/${_pkg}/LICENSE"

24
system/60-nvidia.rules Normal file
View File

@ -0,0 +1,24 @@
# Make sure device nodes are present even when the DDX is not started for the Wayland/EGLStream case
KERNEL=="nvidia", RUN+="/usr/bin/bash -c '/usr/bin/mknod -Z -m 666 /dev/nvidiactl c $$(grep nvidia-frontend /proc/devices | cut -d \ -f 1) 255'"
KERNEL=="nvidia", RUN+="/usr/bin/bash -c 'for i in $$(cat /proc/driver/nvidia/gpus/*/information | grep Minor | cut -d \ -f 4); do /usr/bin/mknod -Z -m 666 /dev/nvidia$${i} c $$(grep nvidia-frontend /proc/devices | cut -d \ -f 1) $${i}; done'"
KERNEL=="nvidia_modeset", RUN+="/usr/bin/bash -c '/usr/bin/mknod -Z -m 666 /dev/nvidia-modeset c $$(grep nvidia-frontend /proc/devices | cut -d \ -f 1) 254'"
KERNEL=="nvidia_uvm", RUN+="/usr/bin/bash -c '/usr/bin/mknod -Z -m 666 /dev/nvidia-uvm c $$(grep nvidia-uvm /proc/devices | cut -d \ -f 1) 0'"
KERNEL=="nvidia_uvm", RUN+="/usr/bin/bash -c '/usr/bin/mknod -Z -m 666 /dev/nvidia-uvm-tools c $$(grep nvidia-uvm /proc/devices | cut -d \ -f 1) 1'"
# Enable runtime PM for NVIDIA VGA/3D controller devices
ACTION=="bind", SUBSYSTEM=="pci", ATTR{vendor}=="0x10de", ATTR{class}=="0x03[0-9]*", TEST=="power/control", ATTR{power/control}="auto"
# Enable runtime PM for NVIDIA Audio devices
ACTION=="bind", SUBSYSTEM=="pci", ATTR{vendor}=="0x10de", ATTR{class}=="0x040300", TEST=="power/control", ATTR{power/control}="auto"
# Enable runtime PM for NVIDIA USB xHCI Host Controller devices
ACTION=="bind", SUBSYSTEM=="pci", ATTR{vendor}=="0x10de", ATTR{class}=="0x0c0330", TEST=="power/control", ATTR{power/control}="auto"
# Enable runtime PM for NVIDIA USB Type-C UCSI devices
ACTION=="bind", SUBSYSTEM=="pci", ATTR{vendor}=="0x10de", ATTR{class}=="0x0c8000", TEST=="power/control", ATTR{power/control}="auto"
# Disable runtime PM for NVIDIA VGA/3D controller devices
ACTION=="unbind", SUBSYSTEM=="pci", ATTR{vendor}=="0x10de", ATTR{class}=="0x03[0-9]*", TEST=="power/control", ATTR{power/control}="on"
# Disable runtime PM for NVIDIA Audio devices
ACTION=="unbind", SUBSYSTEM=="pci", ATTR{vendor}=="0x10de", ATTR{class}=="0x040300", TEST=="power/control", ATTR{power/control}="on"
# Disable runtime PM for NVIDIA USB xHCI Host Controller devices
ACTION=="unbind", SUBSYSTEM=="pci", ATTR{vendor}=="0x10de", ATTR{class}=="0x0c0330", TEST=="power/control", ATTR{power/control}="on"
# Disable runtime PM for NVIDIA USB Type-C UCSI devices
ACTION=="unbind", SUBSYSTEM=="pci", ATTR{vendor}=="0x10de", ATTR{class}=="0x0c8000", TEST=="power/control", ATTR{power/control}="on"