Repository: Askannz/optimus-manager

Issue #115: Issues when switching back to nvidia (xrandr or bbswitch issue)
Created: 2019-08-16T09:59:01Z
Describe the bug
When attempting to switch back to nvidia after having switched to intel, optimus manager will not actually switch to nvidia and will remain in intel mode.
There are two issues that I have encountered here:

when using the nouveau backend when switching to nvidia it will end up giving an error in the PRIME log saying Error : cannot setup PRIME : Cannot setup PRIME : Failed to execute 'xrandr --setprovideroutputsource modesetting NVIDIA-0' : . When checking lsmod it also states that nouveau is being used by -1, which I assume means that it is being unloaded. After that if I attempt to switch again I will encounter an error in the GPU setup log which states that it cannot unload nouveau: Cannot setup GPU : kernel setup error : Cannot unload nouveau : Failed to execute 'modprobe -r nouveau' : modprobe: ERROR: could not remove 'nouveau': Device or resource busy. It will then also display the standard text on TTY1 (so no Xorg session) and not allow me to switch TTY.
when using the bbswitch backend when switching back to nvidia it will give the following error in the GPU setup log Cannot setup GPU : kernel setup error : bbswitch failed to set the GPU to ON.

A third and possibly related issue is that when I set startup mode to be intel it will get my into SDDM where I can enter my password, but as soon as I attempt to switch TTY or actually log into my desktop it will just freeze.
For the second issue I have a sneaking suspicion that this is yet another set up ACPI issues caused by the manufacturer, although it does seem to properly turn the GPU of as stated by bbswitch and as measured by some very rudimentary comparative battery test I have run myself.
System info
Please include :

Distribution: Arch
Desktop manager: KDE plasma 5.16.4
Display manager: SDDM 0.18.6
Laptop model: Dell G5 5587

Logs
Logs when using nouveau as the backend
Logs when using bbswitch as the backend

Duplicate issue #570: Manjaro KDE: switch to nvidia and then see blacksreen
Created: 2024-07-05T15:15:52Z
Describe the bug
I use the Manjaro system, which has always been working normally. However, after a recent update, when switching to the NVIDIA graphics card, the entire system goes black, but I can still switch to other TTYs.
I checked the switch log and found: ERROR: Cannot setup PRIME (xrandr error).
How should I troubleshoot this error? Thank you for any responses.
System info
Please include :

Your distribution

$ neofetch
██████████████████  ████████   ling@ling-20ym 
██████████████████  ████████   -------------- 
██████████████████  ████████   OS: Manjaro Linux x86_64 
██████████████████  ████████   Host: 20YM Lenovo ThinkBook 16p Gen 2 
████████            ████████   Kernel: 6.1.94-1-MANJARO 
████████  ████████  ████████   Uptime: 8 mins 
████████  ████████  ████████   Packages: 1780 (pacman) 
████████  ████████  ████████   Shell: bash 5.2.26 
████████  ████████  ████████   Resolution: 2560x1600 
████████  ████████  ████████   DE: Plasma 6.0.5 
████████  ████████  ████████   WM: KWin 
████████  ████████  ████████   Theme: [Plasma], Breeze [GTK2/3] 
████████  ████████  ████████   Icons: [Plasma], McMojave-circle-dark [GTK2/3] 
████████  ████████  ████████   Terminal: konsole 
                               CPU: AMD Ryzen 7 5800H with Radeon Graphics (16) @ 3.200GHz 
                               GPU: AMD ATI Radeon Vega Series / Radeon Vega Mobile Series 
                               GPU: NVIDIA GeForce RTX 3060 Mobile / Max-Q 
                               Memory: 6526MiB / 23392MiB


Your desktop manager (KDE, GNOME, Cinnamon...), if you have one
KDE
You display manager (SDDM, GDM, LightDM...), if you have one. If you do not know, you are probably using the one coming with your desktop manager.
SDDM
Your laptop model, if you think it could be related to the problem
The version of optimus-manager you are using : latest stable release (optimus-manager), or the latest Git version (optimus-manager-git)
Optimus Manager (Client) version 1.5
optimus-manager-git 1:r729.32048d4.python-1
Your custom optimus-manager configuration file at /etc/optimus-manager/optimus-manager.conf, if you made one

cat /etc/optimus-manager/optimus-manager.conf                                                                                                   ✔ 
[amd]
DRI=3
driver=modesetting
tearfree=

[intel]
DRI=3
accel=
driver=modesetting
modeset=yes
tearfree=

[nvidia]
DPI=96
PAT=yes
allow_external_gpus=yes
dynamic_power_management=no
dynamic_power_management_memory_threshold=0
ignore_abi=no
modeset=yes
options=

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

Logs
Run optimus-manager --status in a console, and if an error message appears, post it here. The message should also point you to a log path, attach it here as well. If there is no error message but you are still experiencing issues, grab the most recent files in /var/log/optimus-manager/switch/ and /var/log/optimus-manager/daemon/.
$ optimus-manager --status
Optimus Manager (Client) version 1.5

Current GPU mode : hybrid
GPU mode requested for next login : no change
GPU at startup : hybrid
Temporary config path: no

$ cat /var/log/optimus-manager/switch/switch-20240705T225535.log
[9] INFO: # Xorg pre-start hook
[9] INFO: Previous state was: {'type': 'pending_pre_xorg_start', 'requested_mode': 'nvidia', 'current_mode': 'hybrid'}
[9] INFO: Requested mode is: nvidia
[52] INFO: Writing to /etc/X11/xorg.conf.d/10-optimus-manager.conf
[52] INFO: Writing state {'type': 'pending_post_xorg_start', 'switch_id': '20240705T225535', 'requested_mode': 'nvidia'}
[52] INFO: Xorg pre-start hook completed successfully.
[8] INFO: # Xorg post-start hook
[34] INFO: Running xrandr commands
[71] ERROR: Cannot setup PRIME (xrandr error):
None
[71] INFO: Running /etc/optimus-manager/xsetup-nvidia.sh
[78] ERROR: Cannot set DPI (xrandr error):
None
[78] INFO: Writing state {'type': 'done', 'switch_id': '20240705T225535', 'current_mode': 'nvidia'}
[78] INFO: Xorg post-start hook completed successfully.
[9] INFO: # Xorg pre-start hook
[9] INFO: Previous state was: {'type': 'done', 'switch_id': '20240705T225535', 'current_mode': 'nvidia'}
[9] INFO: Requested mode is: nvidia
[49] INFO: Writing to /etc/X11/xorg.conf.d/10-optimus-manager.conf
[49] INFO: Writing state {'type': 'pending_post_xorg_start', 'switch_id': '20240705T225535', 'requested_mode': 'nvidia'}
[50] INFO: Xorg pre-start hook completed successfully.

Closing comment (2024-07-05T15:36:42Z): Could this be related to?

#115

What happens if you follow the same procedure that is explained on that case? - : set switching=none and pci_power_control=yes. To switch GPUs, use --set-startup+ reboot instead of--switch`.
That is for testing to check out if switching=bbswitch isn't playing a role here. There is also some valuable information at the power management session of our wiki.
Also, keep using the optimus-manager-git since it bundles the last merged PRs from this repo :)
Edit: sorry, misclicked "Comment and Close" instead of just "Comment" here. My bad.