diff --git a/elements/components/nvidia.yml b/elements/components/nvidia.yml index 8ac9ef9a..d00eb7d6 100644 --- a/elements/components/nvidia.yml +++ b/elements/components/nvidia.yml @@ -8,40 +8,29 @@ depends: - components/x11/xserver.yml build-depends: - kernel/linux.yml + - components/gcc.yml + +environ: + - TAR_OPTIONS=--no-same-owner --no-same-permissions build-dir: "." sources: - - https://repo.rlxos.dev/external-sources/NVIDIA-Linux-x86_64-%{version}.tar.zst + - https://us.download.nvidia.com/XFree86/Linux-x86_64/%{version}/NVIDIA-Linux-x86_64-%{version}.run script: |- - cd kernel + sh NVIDIA-Linux-x86_64-%{version}.run -x + cd NVIDIA-Linux-x86_64-%{version}/kernel KERNEL_VERSION=$(ls -1 %{libdir}/modules/ | head -n1) - MODDIR=%{libdir}/modules/${KERNEL_VERSION} - make KERNEL_UNAME=$KERNEL_VERSION KERNEL_MODLIB=$MODDIR modules - make modules_install INSTALL_MOD_PATH=%{install-root}%{prefix} KERNEL_UNAME=$KERNEL_VERSION KERNEL_MODLIB=$MODDIR - - sed -i "s/__VERSION_STRING/%{version}/" dkms.conf - sed -i 's/__JOBS/`nproc`/' dkms.conf - sed -i 's/__DKMS_MODULES//' dkms.conf - sed -i '$iBUILT_MODULE_NAME[0]="nvidia"\ - DEST_MODULE_LOCATION[0]="/kernel/drivers/video"\ - BUILT_MODULE_NAME[1]="nvidia-uvm"\ - DEST_MODULE_LOCATION[1]="/kernel/drivers/video"\ - BUILT_MODULE_NAME[2]="nvidia-modeset"\ - DEST_MODULE_LOCATION[2]="/kernel/drivers/video"\ - BUILT_MODULE_NAME[3]="nvidia-drm"\ - DEST_MODULE_LOCATION[3]="/kernel/drivers/video"\ - BUILT_MODULE_NAME[4]="nvidia-peermem"\ - DEST_MODULE_LOCATION[4]="/kernel/drivers/video"' dkms.conf - - # Gift for linux-rt guys - sed -i 's/NV_EXCLUDE_BUILD_MODULES/IGNORE_PREEMPT_RT_PRESENCE=1 NV_EXCLUDE_BUILD_MODULES/' dkms.conf + + make KERNEL_UNAME=$KERNEL_VERSION modules + make -j1 modules_install INSTALL_MOD_PATH=%{install-root}%{prefix} KERNEL_UNAME=$KERNEL_VERSION cd .. + tar -xf nvidia-persistenced-init.tar.bz2 + install -Dm644 nvidia.icd "%{install-root}%{sysconfdir}/OpenCL/vendors/nvidia.icd" - # install -Dm755 "libnvidia-compiler.so.%{version}" "%{install-root}/usr/lib/libnvidia-compiler.so.%{version}" install -Dm755 "libnvidia-opencl.so.%{version}" "%{install-root}/usr/lib/libnvidia-opencl.so.%{version}" install -Dm755 nvidia_drv.so "%{install-root}/usr/lib/xorg/modules/drivers/nvidia_drv.so" @@ -53,7 +42,7 @@ script: |- ln -sr "%{install-root}/usr/lib/libnvidia-allocator.so.%{version}" "%{install-root}/usr/lib/gbm/nvidia-drm_gbm.so" # firmware - install -Dm644 firmware/gsp_*.bin -t "%{install-root}/usr/lib/firmware/nvidia/%{version}/" + install -Dm644 -t "%{install-root}/usr/lib/firmware/nvidia/%{version}/" firmware/*.bin # GLX extension module for X install -Dm755 "libglxserver_nvidia.so.%{version}" "%{install-root}/usr/lib/nvidia/xorg/libglxserver_nvidia.so.%{version}" @@ -180,16 +169,27 @@ script: |- EOF install -Dm644 /dev/stdin "%{install-root}"/usr/lib/udev/rules.d/60-nvidia.rules << "EOF" - # 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'" + # Device nodes are created by nvidia-modprobe, which is called by the nvidia DDX. + # In case the DDX is not started, the device nodes are never created, so call + # nvidia-modprobe in the udev rules to cover the Wayland/EGLStream and compute + # case without a started display. In the case where vfio-pci is used + # nvidia-modprobe should not be invoked. + ACTION=="add|bind", ATTR{vendor}=="0x10de", ATTR{class}=="0x03[0-9]*", \ + DRIVER=="nvidia", TEST!="/dev/nvidia-uvm", \ + RUN+="/usr/bin/nvidia-modprobe", \ + RUN+="/usr/bin/nvidia-modprobe -c0 -u" EOF - echo "blacklist nouveau" | install -Dm644 /dev/stdin "%{install-root}/usr/lib/modprobe.d/%{id}.conf" - echo "nvidia-uvm" | install -Dm644 /dev/stdin "%{install-root}/usr/lib/modules-load.d/%{id}.conf" + install -Dm644 /dev/stdin "%{install-root}/usr/lib/modprobe.d/%{id}.conf" << "EOF" + blacklist nouveau + options nvidia_drm modeset=1 + options nvidia NVreg_PreserveVideoMemoryAllocations=1 + EOF + + install -Dm644 /dev/stdin "%{install-root}/usr/lib/modules-load.d/%{id}.conf" << "EOF" + nvidia_drm + + EOF find "%{install-root}" -type f -name '*.so*' ! -path '*xorg/*' -print0 | while read -d $'\0' _lib; do