diff --git a/profiles/pci/graphic_drivers/profiles.toml b/profiles/pci/graphic_drivers/profiles.toml index 07bb560..384e22e 100644 --- a/profiles/pci/graphic_drivers/profiles.toml +++ b/profiles/pci/graphic_drivers/profiles.toml @@ -48,10 +48,34 @@ conditional_packages = """ """ pre_install = """ - cat </etc/mkinitcpio.conf.d/10-chwd.conf + # Enable early KMS for non-removable NVIDIA GPUs. + # Removable GPUs (Thunderbolt, USB4) aren't available during initramfs, + # so loading these modules early causes Xid errors and no display output. + for dev in /sys/bus/pci/devices/*; do + vendor="$(cat "$dev/vendor" 2>/dev/null)" + class="$(cat "$dev/class" 2>/dev/null)" + + # Only check NVIDIA (0x10de) display devices + if [ "$vendor" != "0x10de" ]; then + continue + fi + + case "$class" in + 0x0300*|0x0302*|0x0380*) ;; # VGA, 3D, or display controller + *) continue ;; + esac + + # Skip removable GPUs (eGPU via Thunderbolt, USB4, etc.) + if [[ -e "$dev/removable" && "$(cat "$dev/removable")" = "removable" ]]; then + continue + fi + + cat </etc/mkinitcpio.conf.d/10-chwd.conf # This file is automatically generated by chwd. PLEASE DO NOT EDIT IT. MODULES+=(nvidia nvidia_modeset nvidia_uvm nvidia_drm) EOF + break + done # Remove kms hook from mkinitcpio.conf on desktops device_type="$(cat /sys/devices/virtual/dmi/id/chassis_type)" @@ -126,10 +150,34 @@ conditional_packages = """ """ pre_install = """ - cat </etc/mkinitcpio.conf.d/10-chwd.conf + # Enable early KMS for non-removable NVIDIA GPUs. + # Removable GPUs (Thunderbolt, USB4) aren't available during initramfs, + # so loading these modules early causes Xid errors and no display output. + for dev in /sys/bus/pci/devices/*; do + vendor="$(cat "$dev/vendor" 2>/dev/null)" + class="$(cat "$dev/class" 2>/dev/null)" + + # Only check NVIDIA (0x10de) display devices + if [ "$vendor" != "0x10de" ]; then + continue + fi + + case "$class" in + 0x0300*|0x0302*|0x0380*) ;; # VGA, 3D, or display controller + *) continue ;; + esac + + # Skip removable GPUs (eGPU via Thunderbolt, USB4, etc.) + if [ "$(cat "$dev/removable" 2>/dev/null)" = "removable" ]; then + continue + fi + + cat </etc/mkinitcpio.conf.d/10-chwd.conf # This file is automatically generated by chwd. PLEASE DO NOT EDIT IT. MODULES+=(nvidia nvidia_modeset nvidia_uvm nvidia_drm) EOF + break + done # Remove kms hook from mkinitcpio.conf on desktops device_type="$(cat /sys/devices/virtual/dmi/id/chassis_type)"