[SOLVED]Laptop screen stays black on resume from suspend

Everything about X, Gnome, KDE, ... and everything running on it

[SOLVED]Laptop screen stays black on resume from suspend

Postby meridionaljet » 2011-06-22 15:59

Hello,

I'm running Debian Squeeze on a Dell Studio 1558 laptop, and I have my laptop set to suspend when my lid is closed. Resuming from suspend seems to work but the screen remains blank, forcing me to hard reboot every time. Upon reading this thread: http://forums.debian.net/viewtopic.php?f=5&t=59618, I checked /var/log/pm-suspend.log, and found this:

Code: Select all
Tue Jun 21 23:07:12 AKDT 2011: performing suspend
Tue Jun 21 23:07:28 AKDT 2011: Awake.
Tue Jun 21 23:07:28 AKDT 2011: Running hooks for resume
/usr/lib/pm-utils/sleep.d/99video resume suspend:Couldn't get a file descriptor referring to the console
Couldn't get a file descriptor referring to the console
Returned exit code 1.
/usr/lib/pm-utils/sleep.d/98video-quirk-db-handler resume suspend:success.
/usr/lib/pm-utils/sleep.d/95led resume suspend:not applicable.
/usr/lib/pm-utils/sleep.d/95anacron resume suspend:success.
/usr/lib/pm-utils/sleep.d/94cpufreq resume suspend:success.
/usr/lib/pm-utils/sleep.d/90clock resume suspend:not applicable.
/usr/lib/pm-utils/sleep.d/75modules resume suspend:success.
/usr/lib/pm-utils/sleep.d/70action_wpa resume suspend:success.
/usr/lib/pm-utils/sleep.d/55NetworkManager resume suspend:success.
/usr/lib/pm-utils/sleep.d/49bluetooth resume suspend:not applicable.
/etc/pm/sleep.d/10_unattended-upgrades-hibernate resume suspend:success.
/usr/lib/pm-utils/sleep.d/00powersave resume suspend:success.
/usr/lib/pm-utils/sleep.d/00logging resume suspend:success.
/usr/lib/pm-utils/sleep.d/000kernel-change resume suspend:success.


The previously mentioned thread suggested moving the 99video script out of the way to a new directory. I did so, and my laptop did resume the next time I tried suspending, but it seems very unstable. It won't always resume correctly, and upon resume gnome will often be slow, and sometimes things like audio won't work correctly. I definitely don't feel comfortable leaving my configuration this way. Considering that the log tells us exactly what's wrong (can't get a file descriptor referring to the console), I was hoping for some more direct solutions. Any help would be appreciated.
Last edited by meridionaljet on 2011-06-25 09:42, edited 1 time in total.
meridionaljet
 
Posts: 21
Joined: 2011-06-22 15:53

Re: Laptop screen stays black on resume from suspend

Postby oOarthurOo » 2011-06-22 21:17

The suggestion of moving it out of the way is just a diagnostic exercise, not a solution per se. The solution would be to determine what quirks, if any, provide reliable resume from suspend.

I believe I referenced a couple sites that explain how to do that, but to sketch it out for you, this is how I troubleshoot suspend resume problems.

1) I move those scripts out of the way, the ones under pm-utils/sleep.d
--> Create a subdirecty called disabled, and move all those that in the log you see "not applicable" since they don't do anything anyway, then move the two video ones as well. I also move the modules one.
--> We can always just move them back and restore default functionality (or in your case, non-functionality)

2) Now when we suspend resume what's happening is pm-suspend is being invoked without any arguments. Go ahead and try it. It probably won't work. But if it comes back up, and switching to another vt (Ctrl+Alt+F1), then back to vt7 (where 'x' is), restores your video, guess what, there's a workaround for that. You need to tell it to do pm-suspend --quirk-switch-vte or whatever the quirk is called.

3) Testing it in this way is rather tedious. So make a script to do it for you, and test the various combinations (ie. quirks) that are available. The easiest way to do this is to copy the video script from disabled back to the sleep.d directory, and rename it something like 99-video-test. Open it up in your favourite editor, and get rid of all the 'if then' or match statements, and comment out all the possible quirks, and just have it apply one quirk at a time. When you stumble upon one that definitely doesn't work, comment it out and try the next. Using the script method makes it a bit easier to track what you've tried, and to test it out under various conditions, like autosuspend after a set amount of time, suspend on lid close, and from the menu. Also, you can test it for a few days and not have to use the terminal as root everytime you want to suspend.

If after some time of troubleshooting you can't find any quirk that works, then it may be time to look at a backported kernel, and whether there are any newer drivers for your video card available. If you have a newer laptop, say, past 6 months or so, chances are it won't be supported very well in Squeeze, since the drivers and kernel were locked down before your laptop was even released.

If you need help with the script, post the contents of the 99 video file in code tags and I or someone else can maybe help you out there. I don't have a debian box with pm-utils anymore, and I'm not sure if the files on Fedora are identical to those in Squeeze.
oOarthurOo
 
Posts: 545
Joined: 2008-10-25 12:00
Location: Canada

Re: Laptop screen stays black on resume from suspend

Postby meridionaljet » 2011-06-23 02:37

oOarthurOo wrote:The suggestion of moving it out of the way is just a diagnostic exercise, not a solution per se. The solution would be to determine what quirks, if any, provide reliable resume from suspend.

I believe I referenced a couple sites that explain how to do that, but to sketch it out for you, this is how I troubleshoot suspend resume problems.

1) I move those scripts out of the way, the ones under pm-utils/sleep.d
--> Create a subdirecty called disabled, and move all those that in the log you see "not applicable" since they don't do anything anyway, then move the two video ones as well. I also move the modules one.
--> We can always just move them back and restore default functionality (or in your case, non-functionality)

2) Now when we suspend resume what's happening is pm-suspend is being invoked without any arguments. Go ahead and try it. It probably won't work. But if it comes back up, and switching to another vt (Ctrl+Alt+F1), then back to vt7 (where 'x' is), restores your video, guess what, there's a workaround for that. You need to tell it to do pm-suspend --quirk-switch-vte or whatever the quirk is called.

3) Testing it in this way is rather tedious. So make a script to do it for you, and test the various combinations (ie. quirks) that are available. The easiest way to do this is to copy the video script from disabled back to the sleep.d directory, and rename it something like 99-video-test. Open it up in your favourite editor, and get rid of all the 'if then' or match statements, and comment out all the possible quirks, and just have it apply one quirk at a time. When you stumble upon one that definitely doesn't work, comment it out and try the next. Using the script method makes it a bit easier to track what you've tried, and to test it out under various conditions, like autosuspend after a set amount of time, suspend on lid close, and from the menu. Also, you can test it for a few days and not have to use the terminal as root everytime you want to suspend.

If after some time of troubleshooting you can't find any quirk that works, then it may be time to look at a backported kernel, and whether there are any newer drivers for your video card available. If you have a newer laptop, say, past 6 months or so, chances are it won't be supported very well in Squeeze, since the drivers and kernel were locked down before your laptop was even released.

If you need help with the script, post the contents of the 99 video file in code tags and I or someone else can maybe help you out there. I don't have a debian box with pm-utils anymore, and I'm not sure if the files on Fedora are identical to those in Squeeze.


Thanks for posting. With 99video still being run, I tried ctrl+alt+F1 and ctrl+alt+F7 and my video came back like you said, so I need that "quirk-switch-vte" or whatever its real name is. I don't know if it's in my 99video script or not. Nothing seems to be commented out, so perhaps I need to add it, but you said you didn't know its real name. I also wouldn't know how to append it to the script properly. Any suggestions? Here's the full 99video script:

Code: Select all
#!/bin/sh
#
# Copyright 2006-2007 Richard Hughes <richard@hughsie.com>
# Copyright 2007 Peter Jones <pjones@redhat.com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of version 2 of the GNU General Public License as
# published by the Free Software Foundation.

# Handle video quirks.  If you are having suspend/resume issues,
# troubleshooting using this hook is probably the best place to start.
# If it weren't for video card quirks, suspend/resume on Linux would be
# a whole lot more stable.

. "${PM_FUNCTIONS}"

for opt in $PM_CMDLINE; do
   case "${opt##--quirk-}" in # just quirks, please
      dpms-on)       QUIRK_DPMS_ON="true" ;;
      dpms-suspend)       QUIRK_DPMS_SUSPEND="true" ;;
      radeon-off)       QUIRK_RADEON_OFF="true" ;;
      reset-brightness)  QUIRK_RESET_BRIGHTNESS="true" ;;
      s3-bios)       QUIRK_S3_BIOS="true" ;;
      s3-mode)       QUIRK_S3_MODE="true" ;;
      vbe-post)       QUIRK_VBE_POST="true" ;;
      vbemode-restore)   QUIRK_VBEMODE_RESTORE="true" ;;
      vbestate-restore)  QUIRK_VBESTATE_RESTORE="true" ;;
      vga-mode-3)       QUIRK_VGA_MODE_3="true" ;;
      no-fb)          QUIRK_NOFB="true" ;;
      save-pci)       QUIRK_SAVE_PCI="true" ;;
           no-chvt)           QUIRK_NO_CHVT="true" ;;
      none)          QUIRK_NONE="true" ;;
      *) continue ;;
   esac
done

reset_brightness()
{
   for bl in /sys/class/backlight/* ; do
      [ -f "$bl/brightness" ] || continue
      BR="$(cat $bl/brightness)"
      echo 0 > "$bl/brightness"
      echo "$BR" > "$bl/brightness"
   done
}

if command_exists vbetool; then
   vbe() { vbetool "$@"; }
else
   vbe() { echo "vbetool not installed!" 1>&2; return 1; }
fi

if command_exists radeontool; then
   radeon() { radeontool "$@"; }
else
   radeon() { echo "radeontool not found" 1>&2; return 1; }
fi

die_if_framebuffer()
{
   [ -d "/sys/class/graphics/fb0" ] || return
   echo "--quirk-no-fb passed, but system is using a framebuffer."
   echo "Aborting."
   exit 1
}


save_fbcon()
{
   local con
   for con in /sys/class/graphics/*/state; do
      [ -f $con ] || continue
      echo 1 >"${con}"
   done
}

resume_fbcon()
{
   local con
   for con in /sys/class/graphics/*/state; do
      [ -f $con ] || continue
      echo 0 >"${con}"
   done
}

maybe_chvt()
{
    is_set "$QUIRK_NO_CHVT" && return
    fgconsole |savestate console
    chvt 63
}

maybe_deallocvt()
{
    state_exists console || return 0
    chvt $(restorestate console)
    deallocvt 63
}

# Some tiny helper functions for quirk handling
quirk() { is_set "$1" && [ -z $QUIRK_NONE ]; }

# save/restore vbe state
vbe_savestate() { vbe vbestate save |savestate vbestate; }
vbe_restorestate() { restorestate vbestate |vbe vbestate restore; }

# save/restore the vbe mode
vbe_savemode() { vbe vbemode get |savestate vbemode; }
vbe_restoremode()
{
   # this is a little mode complicated to handle special-casing mode 3.
   local vbemode=$(restorestate vbemode)
   if [ "$vbemode" = "3" ]; then
      vbe vgamode set $vbemode
   else
      vbe vbemode set $vbemode
   fi
}

# post the video card
vbe_post()
{
   local rom="/var/run/video.rom"
   # if we do not have a romfile, do not post with it.
   [ -f "$rom" ] || unset rom
   vbe post $rom
   sleep 0.1
}

# turn critical bits of radeon cards off/on
radeon_off() { radeon dac off; radeon light off; }
radeon_on() { radeon dac on; radeon light on; }

# save and restore video card PCI config state
save_pci()
{
   local pci="/sys/bus/pci/devices"
   for dev in "${pci}"/*; do
      [ -f "${dev}/class" ] || continue
      [ $(cat "${dev}/class") = "0x030000" ] || continue
      [ -f "${dev}/config" ] || continue
      # it is a video card, it has a configuration.  Save it.
      savestate "pci_video_${dev##*/}" <${dev}/config
   done
}

restore_pci()
{
   local pci="/sys/bus/pci/devices"
   for dev in "${pci}"/*; do
      state_exists "pci_video_${dev##*/}" || continue
      restorestate "pci_video_${dev##*/}" > "${dev}/config"
   done
}

suspend_video()
{
   # 0=nothing, 1=s3_bios, 2=s3_mode, 3=both
   local acpi_flag=0
   quirk "${QUIRK_S3_BIOS}" &&       acpi_flag=$(($acpi_flag + 1))
   quirk "${QUIRK_S3_MODE}" &&       acpi_flag=$(($acpi_flag + 2))
   sysctl -w kernel.acpi_video_flags=$acpi_flag
   
   quirk "${QUIRK_NOFB}" &&       die_if_framebuffer
   quirk "${QUIRK_VBESTATE_RESTORE}" &&    vbe_savestate
   quirk "${QUIRK_VBEMODE_RESTORE}" &&    vbe_savemode
   quirk "${QUIRK_RADEON_OFF}" &&       radeon_off
   quirk "${QUIRK_SAVE_PCI}" &&       save_pci
   quirk "${QUIRK_VGA_MODE_3}" &&       vbe vbemode set 3
   quirk "${QUIRK_DPMS_SUSPEND}" &&    vbe dpms suspend
   save_fbcon
}
resume_video()
{
   # We might need to do one or many of these quirks
   quirk "${QUIRK_SAVE_PCI}" &&       restore_pci
   quirk "${QUIRK_VBE_POST}" &&       vbe_post
   quirk "${QUIRK_VBESTATE_RESTORE}" &&    vbe_restorestate
   quirk "${QUIRK_VBEMODE_RESTORE}" &&    vbe_restoremode
   resume_fbcon    # also should be handled by a quirk.
   quirk "${QUIRK_RADEON_OFF}" &&       radeon_on
   quirk "${QUIRK_DPMS_ON}" &&       vbe dpms on
   quirk "${QUIRK_RESET_BRIGHTNESS}" &&    reset_brightness
   return 0  # avoid spurious hook exit failure message.
}

help() {
   echo  # first echo makes it look nicer.
   echo "Video quirk handler options:"
   echo
   echo "  --quirk-dpms-on"
   echo "  --quirk-dpms-suspend"
   echo "  --quirk-radeon-off"
   echo "  --quirk-reset-brightness"
   echo "  --quirk-s3-bios"
   echo "  --quirk-s3-mode"
   echo "  --quirk-vbe-post"
   echo "  --quirk-vbemode-restore"
   echo "  --quirk-vbestate-restore"
   echo "  --quirk-vga-mode-3"
   echo "  --quirk-none"
}

case "$1" in
   suspend) maybe_chvt; suspend_video ;;
   hibernate) maybe_chvt
      if is_set "$HIBERNATE_RESUME_POST_VIDEO"; then
         suspend_video
      fi
      ;;
   resume) resume_video; maybe_deallocvt;;
   thaw)
      if is_set "${HIBERNATE_RESUME_POST_VIDEO}"; then
         resume_video
      fi
      maybe_deallocvt
      ;;
   help) help ;;
esac
meridionaljet
 
Posts: 21
Joined: 2011-06-22 15:53

Re: Laptop screen stays black on resume from suspend

Postby oOarthurOo » 2011-06-24 18:36

Ok, try
Code: Select all
pm-suspend --quirk-vbemode-restore

if that works, we can apply it permanently. Otherwise, try
Code: Select all
pm-suspend --quirk-vbestate-restore

You'll need to try them a few times, to see if they work semi-reliably. Run both in terminal as root.

Also, check out this page:http://hal.freedesktop.org/quirk/quirk-suspend-index.html
oOarthurOo
 
Posts: 545
Joined: 2008-10-25 12:00
Location: Canada

Re: Laptop screen stays black on resume from suspend

Postby lbm » 2011-06-24 19:47

What kernel are you running ?

My problems was fixed completely in kernel 2.6.38 (I think it was)...
User avatar
lbm
 
Posts: 480
Joined: 2009-05-16 09:24
Location: Denmark

Re: Laptop screen stays black on resume from suspend

Postby meridionaljet » 2011-06-25 04:57

oOarthurOo wrote:Ok, try
Code: Select all
pm-suspend --quirk-vbemode-restore

if that works, we can apply it permanently. Otherwise, try
Code: Select all
pm-suspend --quirk-vbestate-restore

You'll need to try them a few times, to see if they work semi-reliably. Run both in terminal as root.

Also, check out this page:http://hal.freedesktop.org/quirk/quirk-suspend-index.html


Neither of those quirks worked. The 2nd one caused the screen to display a gray-colored pattern before suspend, but it would not resume.

I'm unsure how to use what is on the link you gave me. Perhaps if I had a list of quirks to try with trial and error, that would be at least a place to start. Hopefully there is a quirk out there for me that works.
meridionaljet
 
Posts: 21
Joined: 2011-06-22 15:53

Re: Laptop screen stays black on resume from suspend

Postby meridionaljet » 2011-06-25 04:58

lbm wrote:What kernel are you running ?

My problems was fixed completely in kernel 2.6.38 (I think it was)...


I'm on the stock 2.6.32 kernel. I recently tried installing 2.6.38 with backports and it was unstable, not supporting my graphics card for some reason, and I wasn't in the mood to try reinstalling when it already worked perfectly fine on the stock kernel.
meridionaljet
 
Posts: 21
Joined: 2011-06-22 15:53

Re: Laptop screen stays black on resume from suspend

Postby meridionaljet » 2011-06-25 09:42

I appear to have found an apparent solution. I added the file /etc/pm/config.d/10no-vt-switch and added the line ADD_PARAMETERS=" --quirk-no-chvt "

Apparently the issue was not telling my video to switch back to vt7, but rather telling it not to switch anywhere else in the first place. Thanks for your guys' help.
meridionaljet
 
Posts: 21
Joined: 2011-06-22 15:53

Re: [SOLVED]Laptop screen stays black on resume from suspend

Postby oOarthurOo » 2011-06-27 14:27

Nice job. And thanks for posting the solution for others as well.
oOarthurOo
 
Posts: 545
Joined: 2008-10-25 12:00
Location: Canada

Re: [SOLVED]Laptop screen stays black on resume from suspend

Postby xchris » 2012-01-07 22:30

Hi,

I have, too, some issues with suspend/resume (custom pc : Asrock H67m-itx, i5-2500)
The main problem is that the system does not resume after suspend.... in fact I noticed
that during the resume, the HDD and the CPU fan are working, but there is no keyboard (PS/2) nor USB (optical mouse's laser led is not working) nor video output...

I even installed the 2.6.39-bpo.2-amd64 kernel (plus some xorg etc, packs for the sandy bridge) from backports (using now the 2.6.32-5-amd64).

After I reading this thread, I noticed that I have some good results by issuing the "pm-suspend --quirk-vbemode-restore " in this case the resume is ok, just I have to do ctrl-alt- F1 / ctrl-alt-F7 to see the desktop again...

anyway, I don't know really how can I use permanently this quirk, as my effin hardware is displayes like this :

system.hardware.primary_video.product = 258 (0x102) (int)
system.hardware.primary_video.vendor = 32902 (0x8086) (int)
system.hardware.product = 'To Be Filled By O.E.M.' (string)
system.hardware.serial = 'To Be Filled By O.E.M.' (string)
system.hardware.uuid = '00020003-xxxx-xxxx-xxxx-xxxx' (string)
system.hardware.vendor = 'To Be Filled By O.E.M.' (string)
system.hardware.version = 'To Be Filled By O.E.M.' (string)

Any ideas/help please let me know!

Thank you in advance

chris

update : it seems that the pm-suspend --quirk-vbemode-restore works just a couple of times.. then the video freezes.. (not even suspend)
xchris
 
Posts: 5
Joined: 2011-12-18 14:09

Re: [SOLVED]Laptop screen stays black on resume from suspend

Postby tshann » 2012-02-29 09:13

It's quite a while since this thread was last posted. But I just wanted to say, that the solution by meridionaljet solved it for me. I had just removed Nouveau from my squeeze (crunchbang) rig and installed Nvidia's proprietary via sgfxi. After that I could not restore from suspend - but hibernate was fine. After creating a file
/etc/pm/config.d/10no-vt-switch and added the line ADD_PARAMETERS=" --quirk-no-chvt "
as noted, and then testing suspend, it immediately worked. In my case, there was no file 10no-vt-switch in the above mentioned directory. So I literally created it using root and gedit, and just pasted the verbatim line ADD_PARAMETERS=" --quirk-no-chvt " and saved the file. I was skeptical it'd work, but it was picked up and worked immediately. So I'm very grateful.
tshann
 
Posts: 2
Joined: 2012-02-29 09:07

Re: [SOLVED]Laptop screen stays black on resume from suspend

Postby xchris » 2012-03-01 09:50

oh! FANTASTIC! cheers for this mate!
xchris
 
Posts: 5
Joined: 2011-12-18 14:09


Return to Desktop & Multimedia

Who is online

Users browsing this forum: No registered users and 3 guests

fashionable