omarchy icon indicating copy to clipboard operation
omarchy copied to clipboard

Hybrid GPU toggle leaves supergfxd stuck when the NVIDIA module cannot be unloaded

Open mohammed-bageri opened this issue 3 months ago • 6 comments

System details

Lenovo laptop, AMD Raphael iGPU, NVIDIA RTX 5060 Laptop GPU, Omarchy 4.0.1-1, Linux 7.1.9-arch1-2, supergfxctl 5.2.7-2, NVIDIA 610.57.04

What's wrong?

I used omarchy toggle hybrid gpu to switch from Hybrid to Integrated mode and rebooted.

After boot, supergfxd was running, but queries hung:

$ timeout 5 supergfxctl -g
# exits with 124

The Omarchy toggle reported:

supergfxd is not responding. Try again, or check: systemctl status supergfxd

The relevant service log was:

Did rmmod for driver nvidia_drm
Did rmmod for driver nvidia_modeset
Did rmmod for driver nvidia_uvm
Action thread errored: Modprobe error: rmmod nvidia failed: "rmmod: ERROR: Module nvidia is in use"

At that point /etc/supergfxd.conf contained "mode": "Integrated". The NVIDIA device was left partially initialized/unbound and the daemon no longer answered clients.

I recovered by changing the saved mode back to Hybrid, removing the two Integrated-only files below, and rebooting:

/usr/lib/systemd/system-sleep/force-igpu
/etc/systemd/system/supergfxd.service.d/delay-start.conf

After reboot, supergfxctl -g reported Hybrid and nvidia-smi worked normally.

If the NVIDIA modules cannot be unloaded, the toggle should fail without leaving the daemon stuck and the saved configuration halfway switched. It may also be worth checking what is holding the NVIDIA module before committing the Integrated-mode configuration.

Possibly related: #6399 and #5408, although those reports appear to fail at different points.

mohammed-bageri avatar Aug 27 '26 08:08 mohammed-bageri

I think the underlying cause of this is #8352, which nobody has connected to the Integrated-mode toggle yet.

install/hardware/nvidia.sh unconditionally writes:

# /etc/mkinitcpio.conf.d/nvidia.conf
MODULES+=(nvidia nvidia_modeset nvidia_uvm nvidia_drm)

with no check for whether NVIDIA is the only GPU. Because MODULES= force-loads via explicit modprobe, it bypasses the blacklist nvidia that supergfxd writes to /etc/modprobe.d/supergfxd.conf when the saved mode is Integrated. So on a hybrid laptop the NVIDIA stack loads from the initramfs on every boot regardless of the blacklist, and supergfxd is then forced to rmmod a live driver at runtime, at the exact moment the display manager starts — which is where both your failure and mine happen.

That is why the toggle "cannot unload the module": in Integrated mode it should never have been loaded in the first place.

I hit the same trigger on an ASUS AMD+NVIDIA laptop with a worse outcome — the rmmod didn't fail cleanly like yours, it deadlocked in the kernel:

kernel: [drm] [nvidia-drm] [GPU ID 0x00006500] Unloading driver
<no further output — ever>

No error and no return, which holds the whole DRM subsystem, so the boot black-screens and even VT switching is dead. Your rmmod: ERROR: Module nvidia is in use at least fails cleanly and leaves you a shell. Same root cause, two severities.

One detail worth knowing if you try to reproduce: for me it only failed on battery (D3cold resume during the unload). Identical boots on AC completed the unload in 402 ms and came up fine.

Removing /etc/mkinitcpio.conf.d/nvidia.conf and rebuilding the initramfs fixed it completely — supergfxd now finds nothing to unload and the rmmod is a no-op. Details and verification in #8352. On a hybrid system those modules buy nothing in the initramfs anyway, since the dGPU drives no display (Cannot find any crtc or sizes).

Worth noting your recovery step of removing delay-start.conf may have helped for a reason other than the obvious: its sleep 5 lands the rmmod ~20 ms before sddm: Initializing..., timing the teardown into the display-manager race rather than away from it.

zc0rp10 avatar Sep 01 '26 18:09 zc0rp10

Thanks for the detailed log. I read this against quattro at c352b62d6. I did not reproduce it: it needs a hybrid AMD or Intel + NVIDIA laptop, and our test machines are VMs without one.

What the code shows. install/hardware/nvidia.sh still writes /etc/mkinitcpio.conf.d/nvidia.conf with MODULES+=(nvidia nvidia_modeset nvidia_uvm nvidia_drm) on every NVIDIA machine, hybrid ones included. omarchy toggle hybrid gpu edits /etc/supergfxd.conf, installs delay-start.conf and force-igpu, and reboots. It does not rebuild the initramfs. So the first boot in Integrated mode runs an image built while you were in Hybrid mode, and that image loads the NVIDIA stack before supergfxd starts. supergfxd then has to rmmod a driver that is already live, and in your log that is the step that failed.

One correction to the explanation in the comment above: MODULES= does not ignore blacklists. mkinitcpio loads early modules with modprobe -qab, and -b applies blacklists to modules named explicitly. The problem is timing. The image only contains the /etc/modprobe.d it was built with, and supergfxd only writes its Integrated-mode blacklist after it tries the unload.

Related work. Open PR #8263 stops early-loading NVIDIA when another GPU drives the display. For existing hybrid installs it removes nvidia.conf and rebuilds the initramfs once. It was written for #8352, hibernation resume failing for the same early-load reason. It removes the initramfs load described above, so it may well fix this too. That isn't proven yet, though. On the first Integrated boot udev can still autoload nvidia from the real root, because the old modprobe config has no blacklist yet. Nothing in your log says what was still holding nvidia when the unload failed.

What it would not fix. The daemon stopping answering after a failed rmmod happens inside supergfxd, not in Omarchy. On Omarchy's side, the toggle gives up with "supergfxd is not responding" before it reaches the step that switches back to Hybrid. So when the daemon is stuck, the manual recovery you did is the only way back. I've passed that to the maintainer rather than changing the toggle's behaviour here.

Could you test this on your laptop? On a hybrid machine, what #8263 (head 0cdb9d691e943fa3556c82539f6bf2afb6d50f4e) changes amounts to:

sudo rm /etc/mkinitcpio.conf.d/nvidia.conf
sudo limine-mkinitcpio

Then switch to Integrated with omarchy toggle hybrid gpu and reboot. Please tell us whether supergfxctl -g answers, and paste journalctl -b -u supergfxd. If it hangs again, please also paste lsmod | grep nvidia, cat /sys/module/nvidia/refcnt and sudo fuser -v /dev/nvidia* from that boot, which should show what is holding the module. You recover the same way as before. On a hybrid machine you don't need to put nvidia.conf back.

Checked by Claude Opus 5.5, with Codex at medium effort as a second opinion. Codex agreed on the early-load mechanism, though that agreement isn't guaranteed to be independent. It added two findings of its own: supergfxd writes its blacklist only after the unload, and the toggle has no way back to Hybrid while the daemon is stuck. This is waiting on your test result.

omarchybot avatar Oct 09 '26 03:10 omarchybot

Another data point, same setup as this thread: AMD iGPU + RTX 50-series, the dGPU being removed shortly after boot, and the display stack hanging. On this machine it shows up as an SDDM login loop.

Hardware / versions

  • Framework Laptop 16: AMD Radeon 860M iGPU (c2:00.0) + NVIDIA RTX 5070 dGPU module (c1:00.0)
  • linux-omarchy 7.2.15-1, nvidia-open-dkms 615.78.08-1 (DKMS installed for the running kernel), Mesa 26.2.5

Symptom SDDM accepts the password, the screen goes dark, and the greeter comes back, every time. Eventually the greeter stopped taking keyboard input and VT switching died, as in @zc0rp10's report. A Limine snapshot looped the same way. I recovered with systemd.unit=multi-user.target.

Logs The NVIDIA driver loads early and is unloaded about 6 s later. There is no crash. The timing matches the sleep 5 race described above:

20:21:54 NVRM: loading NVIDIA UNIX Open Kernel Module for x86_64 615.78.08
20:21:54 [drm] Initialized nvidia-drm 0.0.0 for 0000:c1:00.0 on minor 1
20:22:00 [drm] [nvidia-drm] [GPU ID 0x0000c100] Unloading driver
20:22:01 nvidia-nvlink: Unregistered Nvlink Core

Afterwards modprobe nvidia_drm returns No such device. Hyprland, both the greeter and the session, picks the iGPU correctly, then:

[EGL] Command eglQueryDevicesEXT errored out with EGL_BAD_ALLOC (0x12291): Failed to allocate device list.

Nothing is logged after the GL extension list. Hyprland then spins (Consumed 50.968s CPU time over 40.362s wall clock), uwsm times out (Autoready failed: Timed out waiting for variables), systemd SIGKILLs it, and SDDM shows the greeter again. coredumpctl also shows Hyprland SIGSEGVs under the sddm UID.

So besides the rmmod hang, a dGPU that disappears mid-startup seems to break NVIDIA's EGL device enumeration and hang Hyprland in renderer init.

I haven't yet confirmed the supergfxd mode on this machine or run the nvidia.conf removal test requested above. I'll report back with both.

roshan-readyon avatar Nov 10 '26 05:11 roshan-readyon

Follow-up with both results:

  • supergfxd mode: confirmed "mode": "Integrated", set via the Omarchy toggle.
  • nvidia.conf test: moved /etc/mkinitcpio.conf.d/nvidia.conf aside and ran limine-mkinitcpio, staying in Integrated mode. Still loops.
  • Switching back to Hybrid: restored nvidia.conf, set "mode": "Hybrid", removed force-igpu and delay-start.conf, then ran limine-mkinitcpio and systemctl daemon-reload. These are the same steps as omarchy-toggle-hybrid-gpu. Still loops.

So on this machine, removing early NVIDIA loading doesn't fix it, and once Integrated mode has been used, going back to Hybrid the same way the toggle does doesn't recover the system either. Something beyond the mode setting is still breaking startup.

roshan-readyon avatar Nov 10 '26 06:11 roshan-readyon

Correction to my two comments above: the login loop on my machine was not caused by supergfxd or Integrated mode. Please disregard my nvidia.conf and Hybrid test results as evidence for this issue.

Root cause: my Hyprland config loaded a locally built HyprExpo plugin (hl.plugin.load(".../hyprexpo-0.56.2.so")). Hyprland hung during startup with high CPU whenever that plugin was loaded. Commenting out the one require line that loads it fixed the loop immediately. The SDDM greeter was unaffected, and Hyprland started fine with an empty config, which is how I found it.

What still holds from my earlier logs: in Integrated mode the NVIDIA driver was unloaded about 6 s after boot, and Hyprland logged eglQueryDevicesEXT ... EGL_BAD_ALLOC. That turned out not to be what hung Hyprland on this machine.

For anyone recovering from Integrated mode: the steps in #11808 got NVIDIA working again in Hybrid for me (stop supergfxd, delete /etc/modprobe.d/supergfxd.conf, set the mode to Hybrid, rebuild with limine-mkinitcpio).

Sorry for the noise.

roshan-readyon avatar Nov 11 '26 05:11 roshan-readyon

The November 11 correction withdraws the Framework laptop's login-loop and GPU-toggle test results: that login loop stopped after its owner disabled a locally built HyprExpo plugin. Those tests therefore do not establish whether #8263 fixes the original failed-rmmod report here.

I read the new replies and checked quattro at c6be7abb9. The old toggle name now forwards to omarchy-device-gpu-hybrid; it still exits when supergfxctl -g times out, before reaching the Hybrid recovery branch. No hardware reproduction or tests ran in this pass: the workers have no hybrid NVIDIA GPU. This follow-up was checked by GPT-6 in Codex (effort not exposed) alone; a new second opinion was not requested because it remains waiting for diagnostic evidence.

@mohammed-bageri, did the removal/rebuild test requested above change the failure on your Lenovo? Please include your current Omarchy, kernel and NVIDIA versions and journalctl -b -u supergfxd from the failing boot. If queries still hang, the lsmod, NVIDIA reference-count and device-holder output requested above would help distinguish the failed module unload here from the later audio-device unbind failure reported in #10445. We still need that result before treating #8263 as a fix for this issue.

omarchybot avatar Nov 18 '26 02:11 omarchybot