Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
[SOLVED] black screen when resuming from suspend with nvidia
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo
View previous topic :: View next topic  
Author Message
smartding
n00b
n00b


Joined: 22 Jan 2021
Posts: 61

PostPosted: Tue Apr 06, 2021 3:34 am    Post subject: [SOLVED] black screen when resuming from suspend with nvidia Reply with quote

I'm using a NVIDIA GeForce GTX 750 Ti graphics card with x11-drivers/nvidia-drivers-460.56 driver.

The nvidia-driver package comes with some scripts for systemd to support suspend/resume. I'm not using systemd, so I wrote the following script, and placed it in "/lib64/elogind/system-sleep/"

Code:

#!/bin/bash
 
case $1/$2 in
    pre/*)
        /usr/bin/logger -t suspend -s "nvidia-sleep.sh suspend"
        /usr/bin/nvidia-sleep.sh "suspend"
        ;;
    post/*)
        /usr/bin/logger -t resume -s "nvidia-sleep.sh resume"
        /usr/bin/nvidia-sleep.sh "resume"
        ;;
esac


I was able to suspend to ram by running "sudo loginctl suspend", but got a black screen when resuming. At this point:

1. the keyboard seems to be working, I can turn on/off the "Num Lock" led
2. If I press the power button now, I get a terminal ( not a X11 terminal ) and normal shutdown messages show up in it.

The /var/log/messages shows:

Code:

Apr  6 11:20:24 gentoobox suspend: nvidia-sleep.sh suspend
Apr  6 11:20:24 gentoobox kernel: [  172.142797] PM: suspend entry (deep)
Apr  6 11:20:24 gentoobox kernel: [  172.164154] Filesystems sync: 0.021 seconds
Apr  6 11:20:36 gentoobox kernel: [  172.164459] Freezing user space processes ... (elapsed 0.000 seconds) done.
Apr  6 11:20:36 gentoobox kernel: [  172.165450] OOM killer disabled.
Apr  6 11:20:36 gentoobox kernel: [  172.165451] Freezing remaining freezable tasks ... (elapsed 0.000 seconds) done.
Apr  6 11:20:36 gentoobox kernel: [  172.166470] printk: Suspending console(s) (use no_console_suspend to debug)
Apr  6 11:20:36 gentoobox kernel: [  172.178375] sd 1:0:0:0: [sdb] Synchronizing SCSI cache
Apr  6 11:20:36 gentoobox kernel: [  172.178405] sd 0:0:0:0: [sda] Synchronizing SCSI cache
Apr  6 11:20:36 gentoobox kernel: [  172.178537] sd 1:0:0:0: [sdb] Stopping disk
Apr  6 11:20:36 gentoobox kernel: [  172.182171] sd 0:0:0:0: [sda] Stopping disk
Apr  6 11:20:36 gentoobox kernel: [  172.704667] ACPI: Preparing to enter system sleep state S3
Apr  6 11:20:36 gentoobox kernel: [  172.913538] PM: Saving platform NVS memory
Apr  6 11:20:36 gentoobox kernel: [  172.913573] Disabling non-boot CPUs ...
Apr  6 11:20:36 gentoobox kernel: [  172.914833] smpboot: CPU 1 is now offline
Apr  6 11:20:36 gentoobox kernel: [  172.916274] smpboot: CPU 2 is now offline
Apr  6 11:20:36 gentoobox kernel: [  172.917741] smpboot: CPU 3 is now offline
Apr  6 11:20:36 gentoobox kernel: [  172.918506] ACPI: Low-level resume complete
Apr  6 11:20:36 gentoobox kernel: [  172.918538] PM: Restoring platform NVS memory
Apr  6 11:20:36 gentoobox kernel: [  172.921040] smpboot: Scheduler frequency invariance went wobbly, disabling!
Apr  6 11:20:36 gentoobox kernel: [  172.921080] Enabling non-boot CPUs ...
Apr  6 11:20:36 gentoobox kernel: [  172.921103] x86: Booting SMP configuration:
Apr  6 11:20:36 gentoobox kernel: [  172.921103] smpboot: Booting Node 0 Processor 1 APIC 0x2
Apr  6 11:20:36 gentoobox kernel: [  172.922993] ACPI: \_PR_.CPU1: Found 2 idle states
Apr  6 11:20:36 gentoobox kernel: [  172.923073] CPU1 is up
Apr  6 11:20:36 gentoobox kernel: [  172.923087] smpboot: Booting Node 0 Processor 2 APIC 0x4
Apr  6 11:20:36 gentoobox kernel: [  172.924965] ACPI: \_PR_.CPU2: Found 2 idle states
Apr  6 11:20:36 gentoobox kernel: [  172.925039] CPU2 is up
Apr  6 11:20:36 gentoobox kernel: [  172.925056] smpboot: Booting Node 0 Processor 3 APIC 0x6
Apr  6 11:20:36 gentoobox kernel: [  172.926880] ACPI: \_PR_.CPU3: Found 2 idle states
Apr  6 11:20:36 gentoobox kernel: [  172.926966] CPU3 is up
Apr  6 11:20:36 gentoobox kernel: [  172.927684] ACPI: Waking up from system sleep state S3
Apr  6 11:20:36 gentoobox kernel: [  172.964900] rtlwifi: rtlwifi: wireless switch is on
Apr  6 11:20:36 gentoobox kernel: [  172.965222] sd 0:0:0:0: [sda] Starting disk
Apr  6 11:20:36 gentoobox kernel: [  172.965243] sd 1:0:0:0: [sdb] Starting disk
Apr  6 11:20:36 gentoobox kernel: [  173.066255] r8169 0000:04:00.0 eth0: Link is Down
Apr  6 11:20:36 gentoobox kernel: [  173.252447] usb 3-3: reset full-speed USB device number 4 using xhci_hcd
Apr  6 11:20:36 gentoobox kernel: [  173.271517] ata1: SATA link up 6.0 Gbps (SStatus 133 SControl 300)
Apr  6 11:20:36 gentoobox kernel: [  173.273765] ata1.00: configured for UDMA/133
Apr  6 11:20:36 gentoobox kernel: [  178.315285] ata2: link is slow to respond, please be patient (ready=0)
Apr  6 11:20:36 gentoobox kernel: [  179.147291] ata2: SATA link up 6.0 Gbps (SStatus 133 SControl 300)
Apr  6 11:20:36 gentoobox kernel: [  179.683898] ata2.00: configured for UDMA/100
Apr  6 11:20:36 gentoobox kernel: [  179.691477] OOM killer enabled.
Apr  6 11:20:36 gentoobox kernel: [  179.691478] Restarting tasks ... done.
Apr  6 11:20:36 gentoobox kernel: [  179.691993] PM: suspend exit
Apr  6 11:20:36 gentoobox pulseaudio[1731]: [alsa-sink-ALC662 rev3 Analog] alsa-util.c: Could not recover alsa device from SUSPENDED state, trying to restart PCM
Apr  6 11:20:36 gentoobox resume: nvidia-sleep.sh resume
Apr  6 11:20:36 gentoobox kernel: [  179.824635] nvidia-sleep.sh (2467) used greatest stack depth: 12120 bytes left




-------

Edit: if I run "echo mem | sudo tee /sys/power/state" instead of "sudo loginctl suspend", everything works.


Last edited by smartding on Thu Jun 10, 2021 1:52 am; edited 1 time in total
Back to top
View user's profile Send private message
mega_flow
n00b
n00b


Joined: 26 Jun 2016
Posts: 48
Location: Belgium

PostPosted: Tue Apr 06, 2021 5:28 pm    Post subject: Reply with quote

I use this script for openrc

https://github.com/elogind/elogind/issues/140

Code:

#!/bin/bash

WHEN="$1"
WHAT="$2"

if [[ ! -f /usr/bin/nvidia-sleep.sh ]]; then
  exit 0
fi

if [[ "xpre" = "x$WHEN" ]]; then
  if [[ "xsuspend" = "x$WHAT" ]]; then
    /usr/bin/logger -t "$WHAT" -s "nvidia-sleep.sh $WHEN"
    /usr/bin/nvidia-sleep.sh "suspend"
  else
    /usr/bin/logger -t "$WHAT" -s "nvidia-sleep.sh $WHEN"
    /usr/bin/nvidia-sleep.sh "hibernate"
  fi
elif [[ "xpost" = "x$WHEN" ]]; then
  sleep 1
  /usr/bin/logger -t "$WHAT" -s "nvidia-sleep.sh $WHEN"
  /usr/bin/nvidia-sleep.sh "resume" &
fi

exit 0

_________________
Intel(R) Core(TM) i5-10300H - GeForce GTX 1660 Ti Mobile
Back to top
View user's profile Send private message
smartding
n00b
n00b


Joined: 22 Jan 2021
Posts: 61

PostPosted: Wed Apr 07, 2021 1:30 am    Post subject: Reply with quote

mega_flow wrote:
I use this script for openrc

https://github.com/elogind/elogind/issues/140

Code:

#!/bin/bash

WHEN="$1"
WHAT="$2"

if [[ ! -f /usr/bin/nvidia-sleep.sh ]]; then
  exit 0
fi

if [[ "xpre" = "x$WHEN" ]]; then
  if [[ "xsuspend" = "x$WHAT" ]]; then
    /usr/bin/logger -t "$WHAT" -s "nvidia-sleep.sh $WHEN"
    /usr/bin/nvidia-sleep.sh "suspend"
  else
    /usr/bin/logger -t "$WHAT" -s "nvidia-sleep.sh $WHEN"
    /usr/bin/nvidia-sleep.sh "hibernate"
  fi
elif [[ "xpost" = "x$WHEN" ]]; then
  sleep 1
  /usr/bin/logger -t "$WHAT" -s "nvidia-sleep.sh $WHEN"
  /usr/bin/nvidia-sleep.sh "resume" &
fi

exit 0


Thanks.

I tried your script, but still got a black screen.
Back to top
View user's profile Send private message
mega_flow
n00b
n00b


Joined: 26 Jun 2016
Posts: 48
Location: Belgium

PostPosted: Wed Apr 07, 2021 2:13 am    Post subject: Reply with quote

have u chmod +x the script ? so it can run
_________________
Intel(R) Core(TM) i5-10300H - GeForce GTX 1660 Ti Mobile
Back to top
View user's profile Send private message
smartding
n00b
n00b


Joined: 22 Jan 2021
Posts: 61

PostPosted: Wed Apr 07, 2021 3:47 am    Post subject: Reply with quote

mega_flow wrote:
have u chmod +x the script ? so it can run


yes, I made it executable.
Back to top
View user's profile Send private message
Fitzcarraldo
Veteran
Veteran


Joined: 30 Aug 2008
Posts: 1967
Location: United Kingdom

PostPosted: Wed Apr 07, 2021 11:11 am    Post subject: Reply with quote

I had a similar problem with a blank screen after resuming my Clevo W230SS laptop from suspension, and I implemented the following two elogind hook scripts to fix the problem, although these days I only need the second one:

lib64/elogind/system-sleep/04-nvidia-drivers

Code:
#!/bin/sh
#
# Unload nvidia modules on hibernate or suspend
# Load nvidia modules on thaw or resume

function unload_if_loaded() {
    MODULE=$1
    if lsmod | grep "$MODULE" &>/dev/null; then
        rmmod $MODULE
    fi
}

case $1/$2 in
     pre/*)
         unload_if_loaded nvidia_drm
         unload_if_loaded nvidia_modeset
         unload_if_loaded nvidia
     ;;
     post/*)
         modprobe nvidia_drm
     ;;
     *)
         exit $NA
     ;;
esac


The laptop runs KDE and the following hook script is needed in order resume successfully:

/lib64/elogind/system-sleep/02-toggle-compositing

Code:
#!/bin/sh
#
# Turn off compositing on hibernate or suspend
# Turn on compositing on thaw or resume

username=fitzcarraldo
userhome=/home/$username
export XAUTHORITY="$userhome/.Xauthority"
export DISPLAY=":0"

case $1/$2 in
     pre/*)
          su $username -c "qdbus org.kde.KWin /Compositor suspend" &
     ;;
     post/*)
          su $username -c "/usr/bin/kwin_x11 --replace" &
          su $username -c "qdbus org.kde.KWin /Compositor resume" &
     ;;
     *)
          exit $NA
     ;;
esac

_________________
Clevo W230SS: amd64 nvidia-drivers & xf86-video-intel.
Compal NBLB2: ~amd64 xf86-video-ati. Dual boot Win 7 Pro 64-bit.
OpenRC eudev elogind & KDE on both.

Fitzcarraldo's blog
Back to top
View user's profile Send private message
smartding
n00b
n00b


Joined: 22 Jan 2021
Posts: 61

PostPosted: Wed Apr 07, 2021 1:34 pm    Post subject: Reply with quote

Fitzcarraldo wrote:
I had a similar problem with a blank screen after resuming my Clevo W230SS laptop from suspension, and I implemented the following two elogind hook scripts to fix the problem, although these days I only need the second one:

lib64/elogind/system-sleep/04-nvidia-drivers

Code:
#!/bin/sh
#
# Unload nvidia modules on hibernate or suspend
# Load nvidia modules on thaw or resume

function unload_if_loaded() {
    MODULE=$1
    if lsmod | grep "$MODULE" &>/dev/null; then
        rmmod $MODULE
    fi
}

case $1/$2 in
     pre/*)
         unload_if_loaded nvidia_drm
         unload_if_loaded nvidia_modeset
         unload_if_loaded nvidia
     ;;
     post/*)
         modprobe nvidia_drm
     ;;
     *)
         exit $NA
     ;;
esac


The laptop runs KDE and the following hook script is needed in order resume successfully:

/lib64/elogind/system-sleep/02-toggle-compositing

Code:
#!/bin/sh
#
# Turn off compositing on hibernate or suspend
# Turn on compositing on thaw or resume

username=fitzcarraldo
userhome=/home/$username
export XAUTHORITY="$userhome/.Xauthority"
export DISPLAY=":0"

case $1/$2 in
     pre/*)
          su $username -c "qdbus org.kde.KWin /Compositor suspend" &
     ;;
     post/*)
          su $username -c "/usr/bin/kwin_x11 --replace" &
          su $username -c "qdbus org.kde.KWin /Compositor resume" &
     ;;
     *)
          exit $NA
     ;;
esac


Thanks.

I'm not using kde, so I only tried the first script, still black screen
Back to top
View user's profile Send private message
smartding
n00b
n00b


Joined: 22 Jan 2021
Posts: 61

PostPosted: Thu Jun 10, 2021 1:52 am    Post subject: Reply with quote

I figured it out.

Someone already reported the same issue on bugzilla: https://bugs.gentoo.org/693384

It's a confirmed bug of elogind, I tried one of the solutions in that discussion, and it works!

Code:

#!/bin/sh
case "${1-}" in
    'pre')
        /usr/bin/nvidia-sleep.sh suspend
        ;;
    'post')
        /usr/bin/nvidia-sleep.sh resume &
        ;;
    *)
        exit 1
        ;;
esac
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum