vbestate handling is broken in sleep/resume (Presario 700)

Bug #38500 reported by Tormod Volden
12
Affects Status Importance Assigned to Milestone
acpi-support (Ubuntu)
Fix Released
Medium
Unassigned

Bug Description

On my Presario 700, the consoles stay black after resume. I commented out the actual sleep trigger in sleep.sh to see if there was a hardware sleep issue, but no, the problem still appeared. In particular, the order and ways the vgastate is saved and restored, and in which mode, seems a little strange to me. I have tried to find documentation, but found nothing than the scripts themselves.

Looking at init.d/vbesave, prepare.sh and resume.sh I see:

If SAVE_VBE_STATE is set (in /etc/default/acpi-support)
 1) save the vbestate at boot (before starting X)
 2) save the vbestate before sleeping (which makes (1) pointless) unless vbemode=3

When it comes to the vbemode, I don't understand fully. Comments in prepare.sh explains that VESA modes are vbemode not equal "3".

So in case of vbemode !=3 (VESA)
 set mode to 3
 save state
 (sleep and wake up)
 set mode to original mode*
 restore state

In case of vbemode =3

 (do not save)
 (sleep and wake up)
 restore state from boot

*For me it sounds more natural to save and restore the state in the same mode, and then switch back to the original mode. But I don't know these things.

For my laptop, the state at booting is 16334 (IIRC). When I comment out the "save state" above, it works correctly, resume restores the state saved at boot, and the consoles are fine. So the problem seems to be that the state is saved in the "3" mode and restored in a non-"3" mode.

Please tell if I can provide more information, but be patient, since the laptop is not on internet...

Revision history for this message
Matthew Garrett (mjg59) wrote :

You're absolutely right, this is broken. Does it work if you edit resume.sh and change that block to read

# Attempt to restore some video card state
if [ x$SAVE_VBE_STATE = xtrue ]; then
  vbetool vbestate restore <$VBESTATE
  if [ $VBEMODE != "3" ]; then
    vbetool vbemode set $VBEMODE;
  fi
fi

? The reason to move back to mode 3 is that it's easier to try to get the card into text mode and work from there than it is to reinitialise directly into the vesa mode.

Changed in acpi-support:
status: Unconfirmed → In Progress
Paul Sladen (sladen)
Changed in acpi-support:
assignee: nobody → mjg59
Revision history for this message
Tormod Volden (tormodvolden) wrote :

Thanks, swapping the order like suggested above made wonders! Now the laptop sleeps and resumes happily with no grunginess.

The hibernation is more tricky, I seem to have more luck replacing "shutdown" with "platform" in /etc/defaults/acpi-support, but I have to do more tests to see exactly what is going on.

Revision history for this message
Tormod Volden (tormodvolden) wrote :

The above changes seem to have made they way into the newly organised /etc/acpi/resume.d/17-video-restore.sh, so maybe we can close this bug.

But I still experience problems resuming from hibernation: The screen goes black as if screen blanking is on. If a press a key, the screen turns on, I can see Ubuntu colours and the black shades from windows (maybe just old cruft from the video memory), then it freezes solid - no reaction to CapsLock or SysReq. This happens only if I have let the machine hibernate for some time, so this could have something to do with power management thinking it is time to lock or turn off the screen (for what I know).

Revision history for this message
Tormod Volden (tormodvolden) wrote :

I had Rhythmbox playing while I was hibernating, and at resume the music continued to play. Only when I hit a key to wake up the screen, the music went into a 0.5s-period loop together with the freeze described above.

I don't have a serial port on this laptop. Is there any way I can do any debugging?

In PowerManagement preferences I have put-computer/screen-to-sleep set to Never. I once resumed into a running screensaver (with no password locking), so the screensaver on its own should not be a problem.

Revision history for this message
Tormod Volden (tormodvolden) wrote :

I logged in through ssh from another machine, and the ssh session survived the hibernation. There was in particular this message:
[4298031.572000] [drm:savage_bci_wait_event_shadow] *ERROR* failed!
[4298031.572000] [drm] status=0x00000a75, e=0x0a78

When I pressed a key on the laptop and it crashed again, there was nothing more coming to the "tail -f syslog" in the ssh session.

Revision history for this message
Tormod Volden (tormodvolden) wrote : dmesg from resuming with DRI

For completeness, dmesg from the failed resume.

Revision history for this message
Tormod Volden (tormodvolden) wrote : dmesg from resuming when DRI is disabled

I am now running without DRI, and it resumed fine this time. I have to try more (especially let it hibernate for longer time) to see if this is the problem.

description: updated
Revision history for this message
Tormod Volden (tormodvolden) wrote :

I am tracking the drm errors and hangs in bug #43007. I think the vbestate handling in this bug is fine now.

Matthew Garrett (mjg59)
Changed in acpi-support:
status: In Progress → Fix Released
Revision history for this message
Tormod Volden (tormodvolden) wrote :

I have to reopen this bug. If laptop-detect (inside /etc/init/vbesave) fails to detect a laptop (for instance because of bug #40503), the vbestate is not saved.

In resume.d/17-video-restore.sh the vbestate is unconditionally restored. I guess the command will just fail if the $VBESTATE file does not exist. Anyway, it would be better to check if the file exist before carrying on.

suspend.d/80-video-vesa-state.sh also takes for granted that the file was saved at boot.

I guess this kicks in only in the case where SAVE_VBE_STATE has been set to true _and_ laptop-detect fails. Maybe SAVE_VBE_STATE should be disabled somehow if laptop-detect fails.

Since laptop-detect is broken on my laptop, I put "LAPTOP=true" in /etc/default/acpi-support, and this seems to have fixed the display corruption I had at resume from hibernation.

Changed in acpi-support:
status: Fix Released → Unconfirmed
Revision history for this message
Tormod Volden (tormodvolden) wrote :

How safe is it to use the vbestate saved during boot, now that usplash does its stuff? I inserted a "vbetool vbemode get" into /etc/init.d/vbesave and the result was 33047 and not 3.

Revision history for this message
Tormod Volden (tormodvolden) wrote :

I made a modified hibernate.sh, only sourcing the video-related scripts, and not doing the actual hibernation. After running this script the consoles are borked. Logging from that script, I see the vbetool complains:
++ vbetool vbestate restore
Function not supported

Revision history for this message
Tormod Volden (tormodvolden) wrote :

I said two comments ago that the "LAPTOP=true" trick had fixed the display corruption, but that is not true. It must have worked just intermittently.

Revision history for this message
Tormod Volden (tormodvolden) wrote :

3 comments ago I said the "vbemore get" returned 33047. This might be since: "The VESA specification does not require that "vbemode get" provides the correct mode if the current mode was set via some means other than the VESA BIOS extensions."

I looked some more into the vbetool code. The "Function not supported" message above comes from the do_set_mode(3,1) call in the restore_state function, which is equivalent to a "vbetool vgamode 3".

Revision history for this message
Tormod Volden (tormodvolden) wrote :

Actually, running "vbetool vgamode 3" (after switching to a console) cleans up the consoles again, apart from a gray background on some consoles which goes away by typing in it. Of course, the "Function not supported" appears, but it seems to do something good anyway.

Revision history for this message
Tormod Volden (tormodvolden) wrote :

Although I feel that my comments above about SAVE_VBE_STATE should be addressed at some point, I close the bug again for this time since this update fixed my consoles:

acpi-support (0.90) edgy; urgency=low

  * Explicitly switch the screen back to text mode if it was that way
    before resume

 -- Matthew Garrett <email address hidden> Sun, 15 Oct 2006 18:09:03 +0100

Changed in acpi-support:
status: Unconfirmed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.