From c233df77efbd1501e39003d5085b37b505ff3dfc Mon Sep 17 00:00:00 2001 From: christophsanz Date: Mon, 16 Mar 2026 21:55:18 +0100 Subject: [PATCH 1/3] =?UTF-8?q?=F0=9F=90=9B=20profiles/graphic=5Fdrivers:?= =?UTF-8?q?=20skip=20early=20KMS=20for=20eGPUs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Detect removable NVIDIA GPUs (Thunderbolt, USB4) via the sysfs `removable` attribute and skip writing early KMS modules to mkinitcpio. These GPUs aren't available during initramfs, so forcing nvidia/nvidia_modeset/nvidia_uvm/nvidia_drm early causes Xid errors and no display output. If all NVIDIA GPUs are removable, the driver loads later via udev when the eGPU is "hotplugged". If any non-removable NVIDIA GPU exists, early KMS is still enabled. --- profiles/pci/graphic_drivers/profiles.toml | 76 +++++++++++++++++++++- 1 file changed, 74 insertions(+), 2 deletions(-) diff --git a/profiles/pci/graphic_drivers/profiles.toml b/profiles/pci/graphic_drivers/profiles.toml index 07bb560..330acff 100644 --- a/profiles/pci/graphic_drivers/profiles.toml +++ b/profiles/pci/graphic_drivers/profiles.toml @@ -48,10 +48,46 @@ conditional_packages = """ """ pre_install = """ - cat </etc/mkinitcpio.conf.d/10-chwd.conf + # Skip early KMS if all NVIDIA GPUs are removable (eGPU). + # Removable GPUs (Thunderbolt, USB4) aren't available during initramfs, + # so loading these modules early causes Xid errors and no display output. + needs_early_kms=true + + 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 + + # Removable = eGPU (Thunderbolt, USB4, etc.) + if [ "$(cat "$dev/removable" 2>/dev/null)" = "removable" ]; then + needs_early_kms=false + else + needs_early_kms=true + break + fi + done + + if [ "$needs_early_kms" = true ]; then + 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 + else + echo "chwd: NVIDIA GPU is removable (eGPU), skipping early KMS modules" + cat </etc/mkinitcpio.conf.d/10-chwd.conf +# This file is automatically generated by chwd. PLEASE DO NOT EDIT IT. +# NVIDIA early KMS modules skipped — GPU is removable (eGPU). +EOF + fi # Remove kms hook from mkinitcpio.conf on desktops device_type="$(cat /sys/devices/virtual/dmi/id/chassis_type)" @@ -126,10 +162,46 @@ conditional_packages = """ """ pre_install = """ - cat </etc/mkinitcpio.conf.d/10-chwd.conf + # Skip early KMS if all NVIDIA GPUs are removable (eGPU). + # Removable GPUs (Thunderbolt, USB4) aren't available during initramfs, + # so loading these modules early causes Xid errors and no display output. + needs_early_kms=true + + 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 + + # Removable = eGPU (Thunderbolt, USB4, etc.) + if [ "$(cat "$dev/removable" 2>/dev/null)" = "removable" ]; then + needs_early_kms=false + else + needs_early_kms=true + break + fi + done + + if [ "$needs_early_kms" = true ]; then + 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 + else + echo "chwd: NVIDIA GPU is removable (eGPU), skipping early KMS modules" + cat </etc/mkinitcpio.conf.d/10-chwd.conf +# This file is automatically generated by chwd. PLEASE DO NOT EDIT IT. +# NVIDIA early KMS modules skipped — GPU is removable (eGPU). +EOF + fi # Remove kms hook from mkinitcpio.conf on desktops device_type="$(cat /sys/devices/virtual/dmi/id/chassis_type)" From 73eaa6e6e74699c6d3e168e8aa708788181801d6 Mon Sep 17 00:00:00 2001 From: christophsanz Date: Sat, 28 Mar 2026 09:46:45 +0100 Subject: [PATCH 2/3] remove useless branches --- profiles/pci/graphic_drivers/profiles.toml | 44 +++++----------------- 1 file changed, 10 insertions(+), 34 deletions(-) diff --git a/profiles/pci/graphic_drivers/profiles.toml b/profiles/pci/graphic_drivers/profiles.toml index 330acff..d360cf0 100644 --- a/profiles/pci/graphic_drivers/profiles.toml +++ b/profiles/pci/graphic_drivers/profiles.toml @@ -48,11 +48,9 @@ conditional_packages = """ """ pre_install = """ - # Skip early KMS if all NVIDIA GPUs are removable (eGPU). + # 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. - needs_early_kms=true - for dev in /sys/bus/pci/devices/*; do vendor="$(cat "$dev/vendor" 2>/dev/null)" class="$(cat "$dev/class" 2>/dev/null)" @@ -67,27 +65,17 @@ pre_install = """ *) continue ;; esac - # Removable = eGPU (Thunderbolt, USB4, etc.) + # Skip removable GPUs (eGPU via Thunderbolt, USB4, etc.) if [ "$(cat "$dev/removable" 2>/dev/null)" = "removable" ]; then - needs_early_kms=false - else - needs_early_kms=true - break + continue fi - done - if [ "$needs_early_kms" = true ]; then 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 - else - echo "chwd: NVIDIA GPU is removable (eGPU), skipping early KMS modules" - cat </etc/mkinitcpio.conf.d/10-chwd.conf -# This file is automatically generated by chwd. PLEASE DO NOT EDIT IT. -# NVIDIA early KMS modules skipped — GPU is removable (eGPU). -EOF - fi + break + done # Remove kms hook from mkinitcpio.conf on desktops device_type="$(cat /sys/devices/virtual/dmi/id/chassis_type)" @@ -162,11 +150,9 @@ conditional_packages = """ """ pre_install = """ - # Skip early KMS if all NVIDIA GPUs are removable (eGPU). + # 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. - needs_early_kms=true - for dev in /sys/bus/pci/devices/*; do vendor="$(cat "$dev/vendor" 2>/dev/null)" class="$(cat "$dev/class" 2>/dev/null)" @@ -181,27 +167,17 @@ pre_install = """ *) continue ;; esac - # Removable = eGPU (Thunderbolt, USB4, etc.) + # Skip removable GPUs (eGPU via Thunderbolt, USB4, etc.) if [ "$(cat "$dev/removable" 2>/dev/null)" = "removable" ]; then - needs_early_kms=false - else - needs_early_kms=true - break + continue fi - done - if [ "$needs_early_kms" = true ]; then 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 - else - echo "chwd: NVIDIA GPU is removable (eGPU), skipping early KMS modules" - cat </etc/mkinitcpio.conf.d/10-chwd.conf -# This file is automatically generated by chwd. PLEASE DO NOT EDIT IT. -# NVIDIA early KMS modules skipped — GPU is removable (eGPU). -EOF - fi + break + done # Remove kms hook from mkinitcpio.conf on desktops device_type="$(cat /sys/devices/virtual/dmi/id/chassis_type)" From d9b309372dce32b7cb3c4ded18cebd7dd0bc6ae3 Mon Sep 17 00:00:00 2001 From: Christoph Sanz <22081130+christophsanz@users.noreply.github.com> Date: Sat, 28 Mar 2026 12:05:10 +0100 Subject: [PATCH 3/3] Update profiles/pci/graphic_drivers/profiles.toml Co-authored-by: Vasiliy Stelmachenok <92667539+ventureoo@users.noreply.github.com> --- profiles/pci/graphic_drivers/profiles.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/profiles/pci/graphic_drivers/profiles.toml b/profiles/pci/graphic_drivers/profiles.toml index d360cf0..384e22e 100644 --- a/profiles/pci/graphic_drivers/profiles.toml +++ b/profiles/pci/graphic_drivers/profiles.toml @@ -66,7 +66,7 @@ pre_install = """ esac # Skip removable GPUs (eGPU via Thunderbolt, USB4, etc.) - if [ "$(cat "$dev/removable" 2>/dev/null)" = "removable" ]; then + if [[ -e "$dev/removable" && "$(cat "$dev/removable")" = "removable" ]]; then continue fi