Tech > LenovoT500Suspend

Lenovo T500 Suspend

Overview

This document contains notes on using suspend/hibernate on the Lenovo T500 with Debian 6.0 (Squeeze). Note that the behaviour of suspend varies between Debian versions.

It is well worth reading the documentation under /usr/share/doc/pm-utils/, /usr/share/doc/hibernate/ and the man pages from pm-suspend.

To debug the pm-utils scripts, set PM_DEBUG to "true" as follows:

  $ echo 'PM_DEBUG="true"' | sudo tee /etc/pm/config.d/10Debug

See also the Linux Kernel document, Debugging hibernation and suspend.

Warning: When attempts to sleep or suspend the system fail, it can corrupt file systems. Crashes can be quite severe. Make sure you have adequate backups before attempting these operations. One of my LVM partitions was corrupted beyond repair and had to be recovered from a backup.

Video Quirks

All models of T500, other than 2242CTO will default to using the default quirks defined in /usr/share/hal/fdi/information/10freedesktop/99-video-quirk-default.fdi which causes the system to freeze on thaw. It is necessary to modify /usr/share/hal/fdi/information/10freedesktop/20-video-quirk-pm-lenovo.fdi

Find out the model number of your T500 with the following command:

  $ lshal | grep system.hardware.product

In this example, the T500 has a model number of 2081CTO.

Add an entry in /usr/share/hal/fdi/information/10freedesktop/20-video-quirk-pm-lenovo.fdi below the existing entry for the T500 2242CTO model listed.

  <!-- T500 2081CTO -->
  <match key="system.hardware.product" string ="2081CTO">
    <match key="system.hardware.version" string = "ThinkPad T500">
    <merge key="power_management.quirk.vbe_post" type="bool">true</merge>
    <merge key="power_management.quirk.vbestate_restore" type="bool">true</merge>
    </match>
  </match>

Alternatively, modify the existing T500 entry...

  <!-- T500 -->
  <match key="system.hardware.product" string_outof ="2242CTO;2081CTO">
    <match key="system.hardware.version" string = "ThinkPad T500">
    <merge key="power_management.quirk.vbe_post" type="bool">true</merge>
    <merge key="power_management.quirk.vbestate_restore" type="bool">true</merge>
    </match>
  </match>

Restart hal and check what quirks are listed. There should only be the power_management.quirk.vbestate_restore quirk.

  $ sudo /etc/init.d/hal restart
  $ lshal | grep quirk

Key Bindings

Add an ACPI event by creating the following file:

  $ cat <<EOF | sudo tee -a /etc/acpi/events/hibernatebtn
event=button[ /]suspend
action=/etc/acpi/hibernatebtn.sh
EOF

This will call the hibernate button script when the suspend key is pressed. See Linux (Debian Squeeze) on Thinkpad T500 for more information. That document also contains scripts and instructions for setting other keys to work with xbindkeys.

xbindkeys

The following is a summary from Linux (Debian Squeeze) on Thinkpad T500.

  1. Install the following packages:

    $ sudo apt-get install xbindkeys xbindkeys-config xosd-bin
  2. Ensure xbindkeys is running when you start X by adding the following to ~/.profile:

    $ cat <<EOF>> ~/.profile
    xbindkeys &
    EOF
  3. Optionally, create a script to show the brightness level when the 'brightness' buttons are pressed:

    $ cat <<EOF | sudo tee -a /usr/local/bin/brightness.sh
    #!/bin/bash
    # from http://caedesnotes.wordpress.com/2011/01/05/linux-debian-squeeze-on-thinkpad-t500/
    
    if [ -n "$XAUTHORITY" ]; then
      # kill other osd_cat processes to prevent overlapping
      if [ $(ps -A | grep osd_cat | wc -l) -gt 0 ]; then
        killall osd_cat
      fi
      i=$(cat /sys/class/backlight/acpi_video0/brightness)
      let i_perc=(100*$i)/15
      osd_cat -d 1 -A center -p bottom -o 50 -c yellow -s 1 \
        -f -adobe-courier-bold-r-normal--*-240-*-*-m-*-iso8859-1 \
        -b percentage -P $i_perc -T "Brightness: $i / 15"
    fi
    EOF

    Check that the path /sys/class/backlight/acpi_video0/brightness is appropriate for you and change if necessary.

  4. Optionally, create a script for switching between touchpad, Trackpoint and both:

    $ cat <<EOF | sudo tee -a /usr/local/bin/toggletouchpad.sh
    #!/bin/bash
    # from http://caedesnotes.wordpress.com/2011/01/05/linux-debian-squeeze-on-thinkpad-t500/
    # adapted from http://forums.gentoo.org/viewtopic-p-6241953.html?sid=815e3e5f2bb9ccfbef0c8ff6cb37914b#6241953
    
    if synclient -l | grep -q TouchpadOff[^[:alnum:]]*0 ; then    
       synclient TouchpadOff=1                                    
       status="TouchPad OFF"                                      
    else
       synclient TouchpadOff=0
       status="TouchPad ON"
    fi
    
    # kill other osd_cat processes to prevent overlapping
    if [ $(ps -A | grep osd_cat | wc -l) -gt 0 ]; then
      killall osd_cat
    fi
    if [ -n "$XAUTHORITY" ]; then
      echo $status | osd_cat -d 3 -p bottom -A center -o -50 -s 1 -c green \
      -f -adobe-courier-bold-r-normal--*-240-*-*-m-*-iso8859-1
    fi
    EOF
  5. Optionally, create a script for handling the volume keys:

    $ cat <<EOF | sudo tee -a /usr/local/bin/volume.sh
    #!/bin/bash
    # from http://caedesnotes.wordpress.com/2011/01/05/linux-debian-squeeze-on-thinkpad-t500/
    # adapted from http://ztatlock.blogspot.com/2009/01/volume-control-with-amixer-and-osdcat.html
    
    CHANNEL=Master
    
    if [ "$1" = "-h" ] || [ "$1" = "--help" ] ; then
      p=$(basename $0)
      cat <<HERE
    
      Usage: $p <channel> <option>
      where option is in {+, -, m, u} or is a percent
      e.g. $p 50       # sets $CHANNEL to 50%
           $p Front m  # toggles the mute of the channel Front
    
    HERE
      exit 0
    fi
    
    if [ $# -eq 2 ] ; then
      CHANNEL=$1
      shift
    fi
    
    function vol_level {
      amixer get $CHANNEL |\
      grep 'Front Left:'  |\
      cut -d " " -f 7     |\
      sed 's/[^0-9]//g'
    }
    
    
    function osd {
      killall osd_cat &> /dev/null
      echo $* |\
      osd_cat -d 2 -l 1 -p bottom -c green -s 1 -A center -o 50 \
      -f '-adobe-courier-bold-r-normal--*-240-*-*-m-*-iso8859-1' &
    }
    
    function mute_osd {
        if [ $(amixer get $CHANNEL | grep Playback | grep "\[on\]" | wc -l) -gt 0 ]
        then
            osd $CHANNEL Unmuted
        else
            osd $CHANNEL Muted
        fi
    }
    
    function vol_osd {
      killall osd_cat &> /dev/null
      osd_cat -d 2 -l 2 -p bottom -c green -s 1 -A center -o 50 \
      -f '-adobe-courier-bold-r-normal--*-240-*-*-m-*-iso8859-1' \
        -T "Volume ($CHANNEL) : $(vol_level) %" -b percentage -P $(vol_level) &
    }
    
    case "$1" in
      "+")
        amixer -q set $CHANNEL 5%+
        vol_osd
        ;;
      "-")
        amixer -q set $CHANNEL 5%-
        vol_osd
        ;;
      "m")
        amixer -q set $CHANNEL toggle
        mute_osd
        ;;
      *)
        amixer -q set $CHANNEL $1%
        ;;
    esac
    EOF
  6. Optionally, create a script for displaying battery information:

    $ cat <<EOF | sudo tee -a /usr/local/bin/batteryinfo.sh
    #!/bin/bash
    # from http://caedesnotes.wordpress.com/2011/01/05/linux-debian-squeeze-on-thinkpad-t500/
    
    # path to your battery. make sure it's correct
    BAT_PATH="/sys/class/power_supply/BAT0"
    
    if [ -n "$XAUTHORITY" ]; then
        # kill other osd_cat processes to prevent overlapping
        if [ $(ps -A | grep osd_cat | wc -l) -gt 0 ]; then
            killall osd_cat
        fi
        BAT_FULL=$(cat $BAT_PATH/energy_full)
        BAT_NOW=$(cat $BAT_PATH/energy_now)
        STATUS=$(cat $BAT_PATH/status)
        let perc=(100*$BAT_NOW)/$BAT_FULL
    
        osd_cat -d 2 -A center -p bottom -o 50 -c yellow -s 1 \
         -f -adobe-courier-bold-r-normal--*-240-*-*-m-*-iso8859-1 \
         -b percentage -P $perc -T "Battery $perc % loaded, $STATUS"
    fi
    EOF
  7. Run the xbindkeys-config GUI to bind the following keys to the appropriate actions:

    The xbindkeys utility stores the configuration settings in ~/.xbindkeysrc.

Name Key Action

Brightness Up XF86MonBrightnessUp /usr/local/bin/brightness.sh Brightness Down XF86MonBrightnessDown /usr/local/bin/brightness.sh Toggle Touchpad NoSymbol /usr/local/bin/toggletouchpad.sh Configure Display XF86Display arandr Volume Up XF86AudioRaiseVolume /usr/local/bin/volume.sh "+" Volume Down XF86AudioLowerVolume /usr/local/bin/volume.sh "-" Volume Mute XF86AudioMute /usr/local/bin/volume.sh m Screen Lock XF86ScreenSaver xscreensaver-command -lock Battery Status XF86Battery /usr/local/bin/batteryinfo.sh

Checking whether suspend-hybrid is supported

The pm-is-supported script can be used to see what operations are supported. It is intended to be called by other scripts, but it's return result can be seen and tested with either of the following commands. (If the first command prints a 0, then it is supported, if a 1, it is not supported.)

  $ pm-is-supported --suspend-hybrid; echo "$?"
  $ pm-is-supported --suspend-hybrid && echo "True"

Screen Lock

Screen locking can be disabled by setting LOCK_SCREEN to true in /etc/default/acpi-support. Note that there may be other reasons why the screen gets locked. E.g. with LXDE, selecting Hibernate from the LXDE Logout Menu, locks the screen anyway.

Issues

Integrated Graphics Card

Suspending after having performed a sleep seems to frequently result in being unable to shutdown the system. Some aspects work, others are unresponsive. E.g. Unable to kill lxpanel when using LXDE. This seems to only occur after a previous sleep. Also, there is a possibility that it's aggravated by running the Google Chrome Web-Browser.

Generally, sleep and suspend appear far more reliable when using the discrete (ATI Radeon HD 3650) graphics card, rather than the integrated (Intel Mobile 4 Series) graphics card.

See also HOWTO: Enabling Kernel Mode Setting (KMS) in Debian Linux kernel which describes rebuilding the kernel with KMS enabled (CONFIG_DRM_I915=m and CONFIG_DRM_I915_KMS=m) and booting with command line parameters of video=i915:modeset=1 (ensuring vga=791 is not used).

An alternative is to install the xserver-xorg-video-intel package from Debian Backports. Due to packaging dependencies, this also updates the ATI Radeon drivers for the discrete graphics card (the xserver-xorg-video-radeon package).

  $ cat <<EOF | sudo tee -a /etc/apt/sources.list.d/squeeze-backports.list
deb http://backports.debian.org/debian-backports squeeze-backports main
EOF

  $ sudo apt-get update
  $ sudo apt-get -t squeeze-backports install xserver-xorg-video-intel

Discrete Graphics Card

I was getting long delays during sleep, suspend and thaw, adding about one minute to the process. Installing the firmware-linux-nonfree package resolves the issues.

If Totem/Movie Player appears to be playing very dark or completely black video, check the contrast setting is not at zero under Edit->Preferences->Display.

There are two sets of drivers available on Debian. There are the radeon open source driver and the fglrx proprietary driver. There are pros and cons between the two. Primarily, the radeon open source driver enables native resolution on the console, but does not provide 3D functionality. The proprietary fglrx one does not provide native resolution on the console, but does provide 3D functionality.

By default, Debian installs the open source Radeon drivers. To install the proprietary drivers, see Installing proprietary ATI driver fglrx/Catalyst - Debian.

Removing the radeon open source drivers

Before installing the flrx drivers, remove and purge the open source ones:

  sudo apt-get purge xserver-xorg-video-ati xserver-xorg-video-radeon

Installing the fglrx drivers

  sudo apt-get install fglrx-driver fglrx-control fglrx-glx \
  fglrx-atieventsd fglrx-modules-dkms

Removing the fglrx drivers

Before installing the open source drivers, remove and purge the fglrx ones:

  sudo apt-get purge fglrx-driver fglrx-control fglrx-glx \
  fglrx-atieventsd fglrx-modules-dkms

Installing the radeon open source drivers

  sudo apt-get install xserver-xorg-video-ati

Network Manager

Occasionally, after that, Network Manager's state remains or becomes 'disconnected'. You can see the state with the following command.

  $ sudo dbus_send --print-reply --system \
              --type=method_call \
              --dest=org.freedesktop.NetworkManager \
              /org/freedesktop/NetworkManager       \
              org.freedesktop.NetworkManager.state

The returned result has the following meaning:

NM_STATE_UNKNOWN = 0
The NetworkManager daemon is in an unknown state.
NM_STATE_ASLEEP = 1
The NetworkManager daemon is asleep and all interfaces managed by it are inactive.
NM_STATE_CONNECTING = 2
The NetworkManager daemon is connecting a device.
NM_STATE_CONNECTED = 3
The NetworkManager daemon is connected.
NM_STATE_DISCONNECTED = 4
The NetworkManager daemon is disconnected.

It is usually sufficient re-connect the network device using the Network Manager applet, e.g. click on Auto eth0 under the list of 'Available' networks. Failing that, Network Manager can be restarted with:

  $ sudo /etc/init.d/network-manager restart

Bluetooth

Occasionally, after thaw, bluetooth is not enabled. Usually, you can just run the bluetooth manager and re-enable it. Alternatively, physically switch the bluetooth/wireless hardware off and on again.

The state has been correctly saved in /var/run/pm-utils/pm-suspend/storage/state:ibm_bluetooth as enabled but fails to start.

This condition also seems to result in messages similar to connect-debounce failed port x disabled being written to tty terminals.

Alternatively, the following command re-enables bluetooth:

  $ echo "enable" | sudo tee /proc/acpi/ibm/bluetooth

Battery Drain Whilst Hibernated

http://www.thinkwiki.org/wiki/Problem_with_high_power_drain_in_ACPI_sleep

Xen

Xen dom0 fails to suspend for me - just hangs. It appears to be outstanding in the Xen Roadmap.

References


-- Frank Dean - 3 Dec 2011

Related Topics: ThinkPadBlueTooth, LenovoTips