Skip to content

Commit

Permalink
static: create device nodes if nvidia driver is loaded
Browse files Browse the repository at this point in the history
Do the same actions as the 71-nvidia.rules files shipped by
nvidia-kernel-common-* in case the nvidia driver has been loaded in
the system.
  • Loading branch information
alfonsosanchezbeato committed Oct 9, 2024
1 parent aa8ed89 commit deea8f5
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 2 deletions.
11 changes: 11 additions & 0 deletions static/usr/bin/nvidia-create-device
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/sh -eux

mknod -m 666 /dev/nvidia0 c 195 0
mknod -m 666 /dev/nvidiactl c 195 255
mknod -m 666 /dev/nvidia-modeset c 195 254

major=$(sed -n 's|^\([0-9]*\) nvidia-uvm$|\1|p' /proc/devices)
if [ -n "$major" ]; then
mknod -m 666 /dev/nvidia-uvm c "$major" 0
mknod -m 666 /dev/nvidia-uvm-tools c "$major" 1
fi
22 changes: 20 additions & 2 deletions static/usr/lib/udev/rules.d/71-nvidia.rules
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,28 @@
#
# Tag the device as master-of-seat so that logind is happy
# (see LP: #1365336)
SUBSYSTEM=="pci", ATTRS{vendor}=="0x10de", TAG+="seat", TAG+="master-of-seat"
SUBSYSTEM=="pci", ATTRS{vendor}=="0x10de", DRIVERS=="nvidia", TAG+="seat", TAG+="master-of-seat"

# Load and unload nvidia-modeset module
ACTION=="add", DEVPATH=="/bus/pci/drivers/nvidia", RUN+="/sbin/modprobe nvidia-modeset"
ACTION=="remove", DEVPATH=="/bus/pci/drivers/nvidia", RUN+="/sbin/modprobe -r nvidia-modeset"

# Load and unload nvidia-drm module
ACTION=="add", DEVPATH=="/bus/pci/drivers/nvidia", RUN+="/sbin/modprobe nvidia-drm"
ACTION=="remove", DEVPATH=="/bus/pci/drivers/nvidia", RUN+="/sbin/modprobe -r nvidia-drm"

# Load and unload nvidia-uvm module
ACTION=="add", DEVPATH=="/bus/pci/drivers/nvidia", RUN+="/sbin/modprobe nvidia-uvm"
ACTION=="remove", DEVPATH=="/bus/pci/drivers/nvidia", RUN+="/sbin/modprobe -r nvidia-uvm"

# This will create the device nvidia device nodes
ACTION=="add", DEVPATH=="/bus/pci/drivers/nvidia", RUN+="/usr/bin/nvidia-create-device"

# Create the device node for the nvidia-uvm module
ACTION=="add", DEVPATH=="/module/nvidia_uvm", SUBSYSTEM=="module", RUN+="/usr/bin/nvidia-create-device"

# Enable runtime PM for NVIDIA VGA/3D controller devices
ACTION=="add", SUBSYSTEM=="pci", ATTR{vendor}=="0x10de", ATTR{class}=="0x03[0-9]*", TEST=="power/control", ATTR{power/control}="auto"
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=="add", SUBSYSTEM=="pci", ATTR{vendor}=="0x10de", ATTR{class}=="0x040300", TEST=="power/control", ATTR{power/control}="auto"
Expand Down

0 comments on commit deea8f5

Please sign in to comment.