Wednesday, January 24, 2007

Running Linux on the Lenovo Thinkpad T60

(Link to webpage)
I've recently purchased a Lenovo Thinkpad T60 (reviews: here and here). The machine is powered by an Intel Core Duo processor, with two cores of each 1.83Ghz. More specs:
  • 1GB RAM
  • Intel IPW3945 ABG WiFi chip
  • 14" 1400x1050 TFT display
  • 60GB harddrive
  • CDRW / DVD combo drive
  • Intel Corporation 82573L Gigabit Ethernet Controller
  • ATi x1300 graphics

Kernel and drivers

Not all of the hardware in the T60 is supported out of the box. VGA and WLAN chips are pretty new, so I had to manually install drivers for those. With recent kernels (2.6.17 and higher) CPU hotplugging works - you can switch off one CPU while everything is running and switch it back on. It is even possible to set different cpufreq governors for each core and have the cores running at different speeds, those speeds are 1,0Ghz, 1,33Ghz and 1,83Ghz.

Intel IPW3845 WLAN

Intel has released a driver for the WLAN chip on http://ipw3945.sourceforge.net. In order to use the driver, you first need to compile and install the ieee80211 subsystem. Additionally, you need a binary microcode image for the WiFi chip, and a userspace daemon. The installation of the driver is a little complicated because you need 4 different components, but once done, the driver behaves stable and works very well with the exceptions that power management does not seem to be supported yet. (Note that I'm not refering to suspend and resume hooks in the driver, but to the wireless powermanagement you're setting with iwconfig [iface] power.) WPA supplicant works well with those drivers, using no encryption, WEP and WPA-PSK encryption. I did not yet test others.

I've created a patch containing the ieee80211 subsystem updates and the ipw driver, you can get it in the Files section. This patch can be applied to the kernel source directly, it saves you reinstalling the driver after a kernel rebuild.

ATi X1300 Graphics

Currently, there is no Open Source driver for the ATi x1300 chips other than VESA, which is quite slow.
ATi has recently released a binary driver that also works with the x1300 chips, albeit with minor problems: I'm getting minor corruption of the framebuffer consoles. (The problem is known to the ATi developers and should be fixed in one of the upcoming releases. Update: This problem is fixed in recent versions, the packages in the files section do not have this problem any more.)

I've generated suitable driver packages for Kubuntu Dapper Drake (6.06) and Edgy Eft (6.10). You can download the packages from the Files section.

Suspend2 (suspend-to-disk)

I've added Suspend2 to the kernel. This makes the suspend process quite a lot faster (I measured 40% compared with vanilla's swsusp) and adds possibilities for a nice progress bar, along with some other neat features. If you use the kernel image I've put in the files section, that would save you the hassle of patching and compiling it yourself. I've also put a hibernate.conf example in the Files section. In order to test, change the file so it says

ProcSetting userui_program /usr/local/sbin/suspend2ui_text
#ProcSetting userui_program /usr/local/sbin/suspend2ui_fbsplash
You can add a snazzy framebuffer splash later. How to do so is documented on suspend2.net.

Using ATi's binary driver, it took me some time to figure out that I need to setting

ProcSetting extra_pages_allowance 36000 
in /etc/hibernate/hibernate.conf, otherwise the machine would hang on suspend. With this setting, suspend2 is completely reliable for me.

(disk-backed) suspend-to-RAM

Suspend-to-RAM works reliably on this machine. I'm using a disk-backed implementation provided by suspend2 and the hibernate script (that's also used for suspend-to-disk in fact). The only change I made is setting
PowerdownMethod 3  
in hibernate.conf. 3 stands for S3 (suspend-to-RAM), 4 is S4 (suspend-to-disk). Setting it to 3 will make the notebook write a memory image to disk and then enter suspend-to-RAM. The notebook will actually need a little energy then, but you'll be able to resume much faster than with S4 (about 10 seconds with S3, around 30 seconds with S4, depending on imagesize and other variables). The memory image on disk adds the advantage that in case you run out of battery (or something else goes wrong with suspend-to-RAM), you're still able to resume from disk and continue working. Neat.

Minor suspend-related problems and workarounds

Note that in order to make suspend working with the fglrx binary ATi driver, the fglrx kernel module needs to be loaded. Having it not loaded, it's still possible to use X, albeit with slower rendering and no 3d, but suspend will crash reliably.
After a suspend/resume cycle the scrolling features of the touchpad is lost, switching to another VT and back to VT7 makes it work again. Compiling the evdev driver into the kernel image also solves this problem. (CONFIG_INPUT_EVDEV=y, this is done in the provided kernel image.)

Multimedia

Controlling the volume via the multimedia buttons on the notebook works fine out of the box using kmilo.

I'm using kmplayer to watch movies and xine to watch DVDs. For most DVDs to work, you need to install libdvdcss2. This library is due to it's questionable legal status in some countries (Hello USA!) not in the official Ubuntu archives. I've installed it from debian-multimedia.org, using the following line in my /etc/apt/sources.list:

deb http://www.debian-multimedia.org etch main
. If playing DVDs is terribly slow, check with hdparm if DMA is enables on the drive, and if not, read this.

In order to be able to use the sound device with more than one application at the same time, you can modify your /etc/asound.conf file as follows (or just create the file if it's not there):

pcm.card0 {
type hw
card 0
}

pcm.!default {
type plug
slave.pcm "dmixer"

}

pcm.dmixer {
type dmix
ipc_key 1025
slave {
pcm "hw:0,0"
period_time 0
period_size 2048 #1024
buffer_size 32768 #4096
#periods 128
rate 48000 #44100
}
bindings {
0 0
1 1
}
}
This enables ALSA's DMix plugin and unblocks the sounds device once an application is using it.

Various issues

DMA problems on DVD drive

DMA on the DVD-drive was switched off initially. The reason is that the IDE driver will claim the DVD drive first, it'll then appear as /dev/hdc. In this case, DMA cannot be switched on. Adding

hdc=noprobe libata.atapi_enabled=1
will solve that problem. Since the storage devices can be used with libata and thus do not need CONFIG_IDE, we can also switch it off in the kernel config and thus avoiding this problem. (I did this in my example .config.) I found this workaround on ThinkWiki.

Storage / SATA

At the moment of writing, the kernel's AHCI driver does not play nicely with suspend. In the BIOS, I switched from AHCI to "compatibility" mode, which works around that problem. I the meantime, the driver is being fixed, so I expect this to vanish with one of the next releases of the Linux kernel.

Various hacks

GRUB kernel options

In order to use swsusp, you need to add a kernel parameter, resume=/dev/sda1, where sda1 is your swap partition. (I have a swap partition of 1GB, which should be enough if I'm not "fully loaded".) Here's my grub entry:
title   Ubuntu, kernel 2.6.17.1
root (hd0,1)
kernel /boot/vmlinuz-2.6.17.1 root=/dev/sda2 ro vga=791 \
acpi_sleep=s3_bios,s3_mode quiet splash
savedefault
boot
(note that the kernel line has to be 1 line.)

Files

I've created a T60 kit for those that don't want to go through the hassle of collecting all the stuff in different places. This package should provide you with suitable drivers for the T60 hardware, it also has config files that you can use as a reference point.
The packages contain a kernel image which has ipw3945 support built-in (Note that you still need the microcode image and the ipw3945d daemon). There is also a couple of packages for the ATi driver, basically, you need to install all the packages here to get a kernel which has hardware accelerated graphics, support for the WLAN chip and swsusp support.

You can download the customized packages here.

Install them like this:
sudo dpkg -i xorg-driver-fglrx_8.25.18-1_i386.deb \
fglrx-control_8.25.18-1_i386.deb \
fglrx-sources_8.25.18-1_i386.deb \
xorg-driver-fglrx-dev_8.25.18-1_i386.deb \
kernel-image-2.6.17.1_10.00.Custom_i386.deb \
fglrx-kernel-2.6.17.1_8.25.18-1+10.00.Custom_i386.deb
If you prefer to patch and configure your kernel yourself, you can use the ipw3945 patch and the libata-acpi patch, along with my .config

Resources

17-10-2006, 22:03 h
© Sebastian Kügler