Askannz / optimus-manager

A Linux program to handle GPU switching on Optimus laptops.
MIT License
2.28k stars 166 forks source link

optimus-manager does not support "Discrete graphics" in BIOS/UEFI #533

Open Klusio19 opened 1 year ago

Klusio19 commented 1 year ago

I have a Lenovo Legion Y540 with i7-9750H and GTX1660 Ti. Running latest Arch Linux with Gnome using modified gdm-prime. In BIOS/UEFI I can choose "Switchable Graphcis" or "Discrete Grahpics" (this machine is muxed). In switchable mode as the name says, the integrated Intel GPU, and dedicated Nvidia GPU are available. In "Discrete Graphics" only NVIDIA GPU is available. And when I choose "Discrete Graphics" in BIOS, and boot Arch, the booting process is running to finally be stuck at "reached graphics target". I can't even enter tty (kind of) by Ctrl+Alt+F* , because the screen flickers every ~0.5 seconds, and after I enter the tty, it lasts only for that ~0.5 seconds, and then it goes back to boot screen with logs. I can only click the power button to shut down the machine. I also tried disabling the systemd service in the grub entry, that did not work. Only after uninstalling optimus-manager completely, I can boot with discrete graphics.

Here is my config:

[amd]
DRI=2
driver=modesetting
tearfree=

[intel]
DRI=2
accel=
driver=intel
modeset=yes
tearfree=

[nvidia]
DPI=96
PAT=yes
allow_external_gpus=no
dynamic_power_management=fine
ignore_abi=no
modeset=yes
options=overclocking

[optimus]
auto_logout=yes
pci_power_control=no
pci_remove=no
pci_reset=no
startup_auto_battery_mode=integrated
startup_auto_extpower_mode=nvidia
startup_mode=nvidia
switching=none

I'll also attach gdm, optimus-daemon, optimus switch, optimus-manager.service, xorg logs, from the failed boot when I tried to to that. I'll drop kernel log too, but it's useless I think, because it's from already properly (selected switchable graphics) booted system. gdm-log.log kernel-logs.log optimus-daemon.log optimus-manager.service.log switch-log.log xorg-log.log

Zyfarok commented 1 year ago

I think optimus-manager doesn't support mux switching yet ? It would be nice if it did. I have the same issue on my Lenovo P1 Gen 6 on SDDM when switching to dGPU-only in BIOS (except than I can enter tty)

supergfxctl supports MUX-switching on ASUS notebooks, but it's not always working that well on non-ASUS notebooks yet, and its maintainer seems focused on wayland support only.

nwildner commented 3 months ago

Yup. Looking at the logs it seems that optimus-manager is not being able to handle a midding integrated GPU.

Snippet from the optimus-manager.service logs provided by the reporter

Feb 12 20:04:00 legion-arch python3[527]: Traceback (most recent call last):
Feb 12 20:04:00 legion-arch python3[527]:   File "/usr/lib/python3.10/site-packages/optimus_manager/hooks/pre_xorg_start.py", line 51, in main
Feb 12 20:04:00 legion-arch python3[527]:     setup_kernel_state(config, prev_state, requested_mode)
Feb 12 20:04:00 legion-arch python3[527]:   File "/usr/lib/python3.10/site-packages/optimus_manager/kernel.py", line 22, in setup_kernel_state
Feb 12 20:04:00 legion-arch python3[527]:     _nvidia_up(config, hybrid=(requested_mode == "hybrid"))
Feb 12 20:04:00 legion-arch python3[527]:   File "/usr/lib/python3.10/site-packages/optimus_manager/kernel.py", line 81, in _nvidia_up
Feb 12 20:04:00 legion-arch python3[527]:     if not pci.is_nvidia_visible():
Feb 12 20:04:00 legion-arch python3[527]:   File "/usr/lib/python3.10/site-packages/optimus_manager/pci.py", line 67, in is_nvidia_visible
Feb 12 20:04:00 legion-arch python3[527]:     bus_ids = get_gpus_bus_ids(notation_fix=False)
Feb 12 20:04:00 legion-arch python3[527]:   File "/usr/lib/python3.10/site-packages/optimus_manager/pci.py", line 100, in get_gpus_bus_ids
Feb 12 20:04:00 legion-arch python3[527]:     raise PCIError("Cannot find the integrated GPU. Is this an Optimus system ?")
Feb 12 20:04:00 legion-arch python3[527]: optimus_manager.pci.PCIError: Cannot find the integrated GPU. Is this an Optimus system ?
Feb 12 20:04:00 legion-arch python3[527]: [1194] INFO: Removing /etc/X11/xorg.conf.d/10-optimus-manager.conf (if present)
Feb 12 20:04:00 legion-arch python3[527]: [1194] INFO: Writing state {'type': 'pre_xorg_start_failed', 'switch_id': '20230212T200358',

Funny thing is that when I'm on "Ultimate Mode" on my ASUS laptop as well(discrete only from BIOS), and my last mode set was nvidia, I have no problems neither I've investigated in the past since it was "kinda working".

This could be a feature request however, someone should send a PR for this.

Maybe instead of raising an exception that the integrated GPU is missing and assuming it is a desktop, if an iGPU is missing, nvidia mode should be forced otherwise.

Anyway, I'm marking this case as a "Feature Request" and changing it's title.