Black screen on resume from suspend

I've had a long history with suspend problems on my main PC and finally I thought I should try to fix them. Back when I was on kernel 4.19 and Nvidia driver 430, resuming worked well enough, but my ethernet wouldn't reconnect, not even if I logged out and back in, requiring a reboot to fix. Now I'm on driver 435 with kernel 5.2.11 and the problem's gotten even worse. Now when I resume, I only see a black screen with my cursor. Switching to TTY2 works and if I type in xrandr it says it can't open the display. I've seen several topics here similar to mine, but they're all very old and mostly about laptops. I actually don't have a problem with suspending on my laptop running kernel 4.19 and the bumblebee drivers, only on my main PC. Here's its inxi

System:    Host: Kiko-LM Kernel: 5.2.11-1-MANJARO x86_64 bits: 64 compiler: gcc v: 9.1.0 Console: N/A wm: kwin_x11 dm: SDDM 
           Distro: Manjaro Linux 
Machine:   Type: Desktop System: Gigabyte product: AB350M-HD3 v: N/A serial: N/A 
           Mobo: Gigabyte model: AB350M-HD3-CF v: se1 serial: N/A UEFI: American Megatrends v: F42a date: 07/31/2019 
CPU:       Topology: 8-Core model: AMD Ryzen 7 1700 bits: 64 type: MT MCP arch: Zen rev: 1 L1 cache: 768 KiB 
           L2 cache: 4096 KiB L3 cache: 16.0 MiB 
           flags: avx avx2 lm nx pae sse sse2 sse3 sse4_1 sse4_2 sse4a ssse3 svm bogomips: 95846 
           Speed: 1346 MHz min/max: 1550/3000 MHz boost: enabled Core speeds (MHz): 1: 1347 2: 2245 3: 1343 4: 1345 5: 1343 
           6: 2257 7: 2254 8: 2247 9: 1345 10: 1346 11: 1346 12: 2251 13: 2252 14: 2251 15: 1344 16: 2451 
Graphics:  Device-1: NVIDIA GM204 [GeForce GTX 970] vendor: Gigabyte driver: nvidia v: 435.21 bus ID: 06:00.0 
           chip ID: 10de:13c2 
           Display: server: X.Org 1.20.5 driver: nvidia compositor: kwin_x11 resolution: 3840x2160~60Hz 
           OpenGL: renderer: GeForce GTX 970/PCIe/SSE2 v: 4.6.0 NVIDIA 435.21 direct render: Yes 
Audio:     Device-1: NVIDIA GM204 High Definition Audio vendor: Gigabyte driver: snd_hda_intel v: kernel bus ID: 06:00.1 
           chip ID: 10de:0fbb 
           Device-2: Advanced Micro Devices [AMD] Family 17h HD Audio vendor: Gigabyte driver: snd_hda_intel v: kernel 
           bus ID: 08:00.3 chip ID: 1022:1457 
           Device-3: Logitech [G533 Wireless Headset Dongle] type: USB driver: hid-generic,snd-usb-audio,usbhid bus ID: 3-1:2 
           chip ID: 046d:0a66 
           Sound Server: ALSA v: k5.2.11-1-MANJARO 
Network:   Device-1: Realtek RTL8111/8168/8411 PCI Express Gigabit Ethernet vendor: Gigabyte driver: r8168 v: 8.047.02-NAPI 
           port: f000 bus ID: 03:00.0 chip ID: 10ec:8168 
           IF: eno1 state: up speed: 100 Mbps duplex: full mac: <filter> 
           IF-ID-1: tun0 state: unknown speed: 10 Mbps duplex: full mac: N/A 
Drives:    Local Storage: total: 4.09 TiB used: 3.30 TiB (80.7%) 
           ID-1: /dev/sda vendor: Seagate model: ST2000DM006-2DM164 size: 1.82 TiB speed: 6.0 Gb/s rotation: 7200 rpm 
           serial: <filter> rev: CC26 scheme: GPT 
           ID-2: /dev/sdb vendor: Western Digital model: WD20EZRX-00DC0B0 size: 1.82 TiB speed: 6.0 Gb/s serial: <filter> 
           rev: 0A80 scheme: MBR 
           ID-3: /dev/sdc vendor: Western Digital model: WDS500G2B0B-00YS70 size: 465.76 GiB speed: 6.0 Gb/s serial: <filter> 
           rev: 00WD scheme: GPT 
Partition: ID-1: / size: 92.48 GiB used: 60.67 GiB (65.6%) fs: ext4 dev: /dev/sdc7 
           ID-2: swap-1 size: 5.00 GiB used: 0 KiB (0.0%) fs: swap dev: /dev/sdc6 
Sensors:   System Temperatures: cpu: 43.0 C mobo: N/A gpu: nvidia temp: 42 C 
           Fan Speeds (RPM): N/A gpu: nvidia fan: 34% 
Info:      Processes: 311 Uptime: 7m Memory: 15.67 GiB used: 1.80 GiB (11.5%) Init: systemd v: 242 Compilers: gcc: 9.1.0 
           clang: 8.0.1 Shell: bash (sudo) v: 5.0.9 running in: yakuake inxi: 3.0.36 

It's been at least 2 years since these other similar topics, what could be the problem now?

So, have you tried systemd workaround ? Since it applies to screen corruption it might help for black screen too.

Also, is the haveged service enabled on your Desktop?

1 Like

According to systemctl it is.

I also tried copying that service, substituting my name, enabling it, rebooting and then suspending. After resuming nothing's changed, still a black screen with only a cursor. And I checked the service from TTY2 just in case and it says it did execute successfully, but nothing happened.
I also found out I could execute startx from TTY2 to start another desktop, but it's a bit broken. My ethernet connection again couldn't resume and some of my background apps like my VPN were not running, or at least weren't showing on my system tray.

R8168 service:

1 Like

While that did fix the black screen, now it's back to the previous bug where my ethernet won't reconnect on resume. Here's my inxi -n

Network:   Device-1: Realtek RTL8111/8168/8411 PCI Express Gigabit Ethernet driver: r8168 
           IF: eno1 state: up speed: 100 Mbps duplex: full mac: e0:d5:5e:2c:f4:08 
           IF-ID-1: tun0 state: unknown speed: 10 Mbps duplex: full mac: N/A

and the script

#/etc/systemd/system/network-restart.service
#sudo systemctl enable network-restart.service
#sudo systemctl start network-restart.service
#sudo systemctl stop network-restart.service
#sudo systemctl disable network-restart.service
#systemctl status network-restart.service

[Unit]
Description=Network Suspend/Resume Service 
Before=sleep.target
StopWhenUnneeded=yes

[Service]
User=root
Type=oneshot
RemainAfterExit=yes
ExecStartPre=-/usr/bin/sudo -u $USER /bin/bash -lc 'nmcli networking off'
ExecStart=/usr/bin/sleep 1
ExecStart=-/usr/bin/systemctl stop NetworkManager
ExecStart=/usr/bin/sleep 1
ExecStart=-/usr/bin/ip link set eno1 down
ExecStop=/usr/bin/sleep 1
ExecStart=-/usr/bin/modprobe -r r8168
ExecStop=/usr/bin/sleep 3
ExecStart=-/usr/bin/modprobe r8168
ExecStop=/usr/bin/sleep 2
ExecStop=-/usr/bin/ip link set eno1 up
ExecStop=/usr/bin/sleep 2
ExecStop=-/usr/bin/systemctl start NetworkManager
ExecStop=/usr/bin/sleep 1
ExecStop=-/usr/bin/sudo -u $USER /bin/bash -lc 'nmcli networking on'

[Install]
WantedBy=sleep.target

Remove the driver using MHWD and your system will use the r8169 that works better.

Yes thank you, that was the final step needed to make @tbg 's script work.

1 Like

The service that tries to fix network? Funny! :joy:

It's because the r8168 driver creates all manner of havoc. So the service in combination with switching to r8169 seems to have magically corrected the problem. I have even dealt with cases where the r8168 driver was bizarrely preventing bootup.

1 Like

Modify to:

ExecStart=-/usr/bin/modprobe -r r8169 
ExecStop=-/usr/bin/modprobe r8169

If you have now switched to the r8169 driver you should modify r8168 to r8169 in the above lines of the service I wrote.

PS. it's generally considered poor form to credit yourself with the solution when you have merely implemented a service that was written by another forum member. If you have fundamentally modified the service yourself then it is certainly understandable accepting credit for the solution in that case.

Not a big deal, but it's just considered a little tacky when someone else went to all the effort of writing and testing a service to be taking credit yourself for the solution.

I'm glad that got things working properly for you.

1 Like

Originally I had marked your post as the solution until it got switched
Screenshot_20190911_091019

1 Like

Forum kindly sponsored by Bytemark