preload preload preload preload preload preload
archive of dennis g. / XORN.ORG 9

Running GNU/Linux on an IBM/Lenovo Thinkpad Z61e

With kernel 2.6.25.4 from kernel.org - get my kernel .config

This page should just help you to find a good start with the Thinkpad Z61e (and probably also with Z61m, Z61t, Z61p, and some R61 series Thinkpads), some things here were found randomly among the internet, and some are found out by myself (a good source is of course also http://www.thinkwiki.org) . They should work for all Distributions but are just tested on Debian Lenny.

Xorg/X-Server

Put these settings at the right position in your /etc/X11/xorg.conf, it should both help you save power and give you a graphic speed up!

### Excerpt from File: /etc/X11/xorg.conf
Section "Device"
        Identifier      "Intel 945GM"
        Driver          "intel"
        Option "MTRR"   "on"
        Option "FramebufferCompression" "on"
        Option "AccelMethod" "EXA"
        Option "Tiling" "on"
        Option "VBERestore" "yes"
        Option "UseFBDev" "true"
        BusID           "PCI:0:2:0"
EndSection

The following config was my old one, it might speed up graphics more than the above config, it made Sauerbraten run from 1-2fps to playable (not completely lag-free though). If you did experiment around with the both setups, I'm happy to receive a mail about the power-saving(with just Desktop applications) and performance differences(in OpenGL), and which is the best combination.

### Excerpt from File: /etc/X11/xorg.conf - old setup
Section "Device"
        Identifier	"Intel 945GM(E)"
        Driver		"i810"
        Option		"MTRR" "on"
        VideoRAM	131072
        Option		"LinearAlloc" "6144"
        Option		"XAANoOffscreenPixmaps" "true"
        Option		"UseFBDev" "false"
        BusID		"PCI:0:2:0"
EndSection

You could also try with a higher VideoRAM number if you upgraded your RAM (which will then be used from you systems ram). Another thing which can speed things up is to export the INTEL_BATCH=1, I added "export INTEL_BATCH=1" to the /etc/X11/Xsession - be aware that you have to put it before the "exit 0" command.

Wireless with the Intel Pro Wireless 3945

Since 2.6.24, the official debian packages and kernel.org sources all include the completely working opensource iwl3945 drivers.

Card Reader

Works nice since 2.6.22, just load the modules sdhci, mmc_core, mmc_block and all the tifm_* modules

ACPI

The Debian acpid and acpi-support packages are doing "relatively" fine here - if you are using xscreensaver to lock. But be aware, that if you set an auto-lock of xscreensaver, this could messup your X after hibernation or sleep (it tries to double lock, or whatever, and the mouse becomes unmovable in X). I'm not sure if this is the cause, but I didn't investigate it close enough so far.

I use userspace suspend (uswsusp package) anyway.

Hibernate and Sleep

As you wish, working less good or bad. I am using userspace suspend, because my partitions (inclusive swap) are all encrypted. So this was the only method to be able to use hibernate and sleep and have my partitions all securely encrypted.

To get it working really nice, install uswsusp ("aptitude install uswsusp"). Then you can use the following commands (be careful with -f if you are not sure, at the moment this is needed because the Z61e isn't in the whitelist, but it is nearly the same as a Z60e, and works wonderfully):

To suspend to ram, just do:
s2ram -f
To suspend to ram and disk (like suspend to ram, but if your battery will be down completely you can also restore everything from disk):
s2both -f -p DEVICE
To just suspend to disk (if you want a faster boot, could be used instead of shutting down):
s2disk DEVICE

ACPI-Buttons

I just list the things I changed, the rest was either already working or I never needed it:

These are OLDER things, the more recently acpi packages in Debian are nearly doing exactly what I want

Make Lock(Fn-F2) and Battery(Fn-F3) do something:

Manually edit /etc/acpi/thinkpad-lockorbattery.sh and comment out system_manufactuer and put IBM for it.

Then you change the hotkey event /etc/acpi/events/ibm-lockbtn with the key of /etc/acpi/events/lenovo-lockbtn and the screen locking will work fine with Fn-F2 (tested with xscreensaver running).

The files/changes will look like this afterwards:

### Excerpt from File: /etc/acpi/thinkpad-lockorbattery.sh
#system_manufactuer=`dmidecode -s system-manufacturer`
system_manufactuer=IBM
### File: /etc/acpi/events/lenovo-lockbtn
event=ibm/hotkey HKEY 00000080 00001003
action=/etc/acpi/lockbtn.sh
### File: /etc/acpi/events/ibm-lockbtn
event=ibm/hotkey HKEY 00000080 00001002
action=/etc/acpi/thinkpad-lockorbattery.sh

The Fn-F3 key is not that useful like that in my opinion, as it will power on the display again if you move the mouse. In my opinion it shouldn't do that, as you can already make the screen be off with xscreensaver automatically after a defined time. So you can use the dpms.sh script to be able to power it on/off with the Fn-F3 as a switch (and don't forget to "chmod +x /etc/acpi/dpms.sh"):

### File: /etc/acpi/events/lenovo-lockbtn
event=ibm/hotkey HKEY 00000080 00001003
action=/etc/acpi/dpms.sh
### File: /etc/acpi/dpms.sh
#!/bin/sh

STATF="/tmp/dpms-state"

if [ -f $STATF ]; then
        STATUS=`cat $STATF`
else
        echo on > $STATF
fi

if [ $STATUS == "on" ]; then
        vbetool dpms off
        echo off > $STATF
else
        vbetool dpms on
        echo on > $STATF
fi

Sleep (Fn-F4)

Just add "s2ram -f" to the /etc/acpi/sleepbtn.sh, but you have to have the "uswsusp" package installed. (You could also use the /etc/acpi/sleep.sh script, but this is causing much issues here, compared to the fast, clean and stable s2ram command from uswsusp). If you are using "powersaved" by chance, you might want to remove the acpi_fakekey command, as powersaved will listen for the fakekeys the acpid is doing (as far as I know, but I don't use powersaved, read more about how I have the cpu frequency scaling working here). I would also add the command the Fn-F2 uses to lock the screen as this is more secure (/etc/acpi/thinkpad-lockorbattery.sh or rather /etc/acpi/screenblank.sh) and add it to sleepbtn.sh. The /etc/acpi/sleepbtn.sh should look as simple as this then:

### File: /etc/acpi/sleepbtn.sh
#!/bin/bash
sh /etc/acpi/screenblank.sh && s2ram -f

Eject CD (Fn-F9)

This can be used to eject cds, it might also be used to unmount all removable devices, but I'm lazy to look up how to handle that and don't really need it:

### File: /etc/acpi/events/ibm-ejectbtn
event=ibm/hotkey HKEY 00000080 00001009
action=/usr/bin/eject

Hibernation (Fn-F12)

To make it work with userspace suspend (uswsusp), edit /etc/acpi/hibernatebtn.sh:

### File: /etc/acpi/hibernatebtn.sh
#!/bin/sh

test -f /usr/share/acpi-support/power-funcs || exit 0
#. /usr/share/acpi-support/key-constants
#acpi_fakekey $KEY_SUSPEND

sh /etc/acpi/hibernate.sh

The other Buttons

The Browser Back and Browser Forward Buttons (the two buttons next to the arrows), the Blue Buttons on the Arrows which are used in Combination, and the Fn Key itself can be easily and fully used by putting this to X by xmodmap:

### File: /etc/X11/Xmodmap
keycode 233 = XF86Forward
keycode 234 = XF86Back

keycode 162 = XF86AudioPlay
keycode 164 = XF86AudioStop
keycode 153 = XF86AudioNext
keycode 144 = XF86AudioPrev

keycode 227 = F35

The Volume and Mute Keys control the Hardware directly and don't need any setup.

tpb

If you want to see what those are doing, use the program "tpb" to show it in X. To setup what the "ThinkVantage" or "Thinkpad"-Key should do, comment it out and put the desired command behind "THINKPAD" in the /etc/tpbrc. The command will be executed in all running X sessions as the user of the respective session.

/etc/rc.local and /etc/sysctl.conf - options to get more out of your battery!

If you are looking for the frequency scaling, just insert that in the /etc/rc.local. Just read my comments below and you will know what the other things are for (uncomment the things you need):

### File: /etc/rc.local
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.

## tpb for users not in group nvram:
#chmod 755 /dev/nvram &

#### Battery:

echo 85 > /sys/devices/platform/smapi/BAT0/start_charge_thresh &
echo 95 > /sys/devices/platform/smapi/BAT0/stop_charge_thresh &

#### Powersaving:

echo ondemand > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor &
echo 1 > /sys/devices/system/cpu/sched_mc_power_savings &

#echo 1500 > /proc/sys/vm/dirty_writeback_centisecs &

/usr/sbin/ethtool -s eth1 wol d &

#echo Y > /sys/module/snd_ac97_codec/parameters/power_save &

# maximal sampling rate
cat /sys/devices/system/cpu/cpu0/cpufreq/ondemand/sampling_rate_max > /sys/devices/system/cpu/cpu0/cpufreq/ondemand/sampling_rate &

# sata power saving:
echo min_power > /sys/class/scsi_host/host0/link_power_management_policy
echo min_power > /sys/class/scsi_host/host1/link_power_management_policy
echo min_power > /sys/class/scsi_host/host2/link_power_management_policy
echo min_power > /sys/class/scsi_host/host3/link_power_management_policy

# iwl3945 ???
echo 5 > /sys/devices/pci0000:00/0000:00:1c.1/0000:03:00.0/power_level

# power_level
for i in /sys/bus/pci/devices/*/power_level ; do echo 5 > $i ; done

# powersaving again
echo 1500 > /proc/sys/vm/dirty_writeback_centisecs &

####
#### Thinklight:

chgrp users /proc/acpi/ibm/light &
chmod 775 /proc/acpi/ibm/light &

exit 0

Add these to your sysctl.conf to make the kernel use swap just when really needed, and for more powersaving

### Excerpt from File: /etc/sysctl.conf
vm.dirty_writeback_centisecs = 1500
vm.swappiness = 1
vm.laptop_mode = 5
kernel.nmi_watchdog = 0

modules

If you want the tp_smapi module, for custom kernels you have to install thinkpad-source and compile it. Otherwise there should be a package tp-smapi-modules.

# /etc/modules: kernel modules to load at boot time.
#
# This file contains the names of kernel modules that should be loaded
# at boot time, one per line. Lines beginning with "#" are ignored.

thinkpad_acpi #earlier called ibm_acpi
tp_smapi
#hdaps
ipw3945
speedstep_centrino
cpufreq_ondemand
nvram
loop
#sbp2

Sources / Further Information

Interesting links that helped me:

Keywords for crawlers: Firefox GNU Linux Photography Software Hardware Thinkpad Z61e X61s Dennis Debian Camera Gear Microcontroller Buttons
(c) Dennis G. 2004-2011 created with the gimp and text editor last change of this file: April 19, 2009 - 01:20