bayasdev / envycontrol

Easy GPU switching for Nvidia Optimus laptops under Linux
https://bayas.dev/envycontrol
MIT License
1.14k stars 55 forks source link

[BUG] Black screen on Nvidia mode with sddm #132

Closed LMnet closed 9 months ago

LMnet commented 9 months ago

Describe the bug After choosing nvidia mode and rebooting I see a black screen.

To Reproduce Steps to reproduce the behavior:

  1. Run sudo envycontrol -s nvidia --dm sddm --verbose
  2. Reboot

Expected behavior Normal booting

System Information:

Additional context

After rebooting I switched to another TTY and checked the status of sddm:

~ systemctl status sddm
● sddm.service - Simple Desktop Display Manager
     Loaded: loaded (/lib/systemd/system/sddm.service; enabled; vendor preset: enabled)
     Active: active (running) since Sun 2023-09-24 13:52:20 NZDT; 44s ago
       Docs: man:sddm(1)
             man:sddm.conf(5)
   Main PID: 1417 (sddm)
      Tasks: 2 (limit: 18889)
     Memory: 18.9M
        CPU: 120ms
     CGroup: /system.slice/sddm.service
             └─1417 /usr/bin/sddm

Sep 24 13:52:23 lmnet-tm1701 sddm[1417]: Failed to read display number from pipe
Sep 24 13:52:23 lmnet-tm1701 sddm[1417]: Display server stopping...
Sep 24 13:52:23 lmnet-tm1701 sddm[1417]: Attempt 2 starting the Display server on vt 2 failed
Sep 24 13:52:25 lmnet-tm1701 sddm[1417]: Display server starting...
Sep 24 13:52:25 lmnet-tm1701 sddm[1417]: Writing cookie to "/run/sddm/xauth_eTBgLw"
Sep 24 13:52:25 lmnet-tm1701 sddm[1417]: Running: /usr/bin/X -nolisten tcp -background none -seat seat0 vt2 -auth /run/sddm/xauth_eTBgLw -noreset -displayfd 16
Sep 24 13:52:25 lmnet-tm1701 sddm[1417]: Failed to read display number from pipe
Sep 24 13:52:25 lmnet-tm1701 sddm[1417]: Display server stopping...
Sep 24 13:52:25 lmnet-tm1701 sddm[1417]: Attempt 3 starting the Display server on vt 2 failed
Sep 24 13:52:25 lmnet-tm1701 sddm[1417]: Could not start Display server on vt 2

Looks like something is wrong with the display number.

Here how it looks in the hybrid mode, when everything works fine:

~ systemctl status sddm
● sddm.service - Simple Desktop Display Manager
     Loaded: loaded (/lib/systemd/system/sddm.service; enabled; vendor preset: enabled)
     Active: active (running) since Sun 2023-09-24 13:47:49 NZDT; 1min 10s ago
       Docs: man:sddm(1)
             man:sddm.conf(5)
   Main PID: 1407 (sddm)
      Tasks: 20 (limit: 18889)
     Memory: 212.2M
        CPU: 2.137s
     CGroup: /system.slice/sddm.service
             ├─1407 /usr/bin/sddm
             └─1410 /usr/lib/xorg/Xorg -nolisten tcp -background none -seat seat0 vt2 -auth /run/sddm/xauth_XcENZY -noreset -displayfd 16

Sep 24 13:47:51 lmnet-tm1701 sddm[1407]: Reading from "/usr/share/xsessions/plasma.desktop"
Sep 24 13:47:51 lmnet-tm1701 sddm[1407]: Session "/usr/share/xsessions/plasma.desktop" selected, command: "/usr/bin/startplasma-x11" for VT 2
Sep 24 13:47:51 lmnet-tm1701 sddm-helper[1440]: [PAM] Starting...
Sep 24 13:47:51 lmnet-tm1701 sddm-helper[1440]: [PAM] Authenticating...
Sep 24 13:47:51 lmnet-tm1701 sddm-helper[1440]: [PAM] returning.
Sep 24 13:47:51 lmnet-tm1701 sddm[1407]: Authentication for user  "lmnet"  successful
Sep 24 13:47:51 lmnet-tm1701 sddm-helper[1440]: pam_unix(sddm-autologin:session): session opened for user lmnet(uid=1000) by (uid=0)
Sep 24 13:47:52 lmnet-tm1701 sddm-helper[1440]: Writing cookie to "/tmp/xauth_DgeiIt"
Sep 24 13:47:52 lmnet-tm1701 sddm-helper[1440]: Starting X11 session: "" "/etc/sddm/Xsession \"/usr/bin/startplasma-x11\""
Sep 24 13:47:52 lmnet-tm1701 sddm[1407]: Session started true

And here is the logs of switching to nvidia:

~ sudo envycontrol -s nvidia --dm sddm  --verbose
update-initramfs: Generating /boot/initrd.img-6.2.0-32-generic
I: The initramfs will attempt to resume from /dev/nvme0n1p3
I: (UUID=24919cfc-9cd1-478e-a0d8-eb4c1c4df49d)
I: Set the RESUME variable to override this.
update-initramfs: Generating /boot/initrd.img-6.2.0-26-generic
I: The initramfs will attempt to resume from /dev/nvme0n1p3
I: (UUID=24919cfc-9cd1-478e-a0d8-eb4c1c4df49d)
I: Set the RESUME variable to override this.
update-initramfs: Generating /boot/initrd.img-5.15.0-83-generic
I: The initramfs will attempt to resume from /dev/nvme0n1p3
I: (UUID=24919cfc-9cd1-478e-a0d8-eb4c1c4df49d)
I: Set the RESUME variable to override this.
Switching to nvidia mode
Enable ForceCompositionPipeline: False
Enable Coolbits: False
Successfully enabled nvidia-persistenced.service
# Automatically generated by EnvyControl

Section "ServerLayout"
    Identifier "layout"
    Screen 0 "nvidia"
    Inactive "intel"
EndSection

Section "Device"
    Identifier "nvidia"
    Driver "nvidia"
    BusID "PCI:1:0:0"
EndSection

Section "Screen"
    Identifier "nvidia"
    Device "nvidia"
    Option "AllowEmptyInitialConfiguration"
EndSection

Section "Device"
    Identifier "intel"
    Driver "modesetting"
EndSection

Section "Screen"
    Identifier "intel"
    Device "intel"
EndSection

# Automatically generated by EnvyControl

options nvidia-drm modeset=1
options nvidia NVreg_UsePageAttributeTable=1 NVreg_InitializeSystemMemoryAllocations=0

#!/bin/sh
# Xsetup - run as root before the login dialog appears

if [ -e /sbin/prime-offload ]; then
    echo running NVIDIA Prime setup /sbin/prime-offload
    /sbin/prime-offload
fi

#!/bin/sh
# Automatically generated by EnvyControl

xrandr --setprovideroutputsource "modesetting" NVIDIA-0
xrandr --auto

Rebuilding the initramfs...
Successfully rebuilt the initramfs!
Operation completed successfully
Please reboot your computer for changes to take effect!
LMnet commented 9 months ago

Turns out it was a driver issue. I completely removed all nvidia and nouveau packages and after that installed nvidia driver one more time. After that everything works as expected.