FreeBSD on the Lenovo T550

Posted on April 27, 2016

I recently got a new laptop: a Lenovo T550. After installing FreeBSD 10.3 on it, I realized that there is neither support for the built in WiFi card (which is however working in FreeBSD 11, so that’s not so much of a problem) nor for the graphics card. Right now, the only option for X11 appears to be Vesa.

Although the Vesa driver seemed to do its jobs, it was terribly slow. I had to wait a couple of seconds for some xterms to open. After some digging around, I found this thread on the FreeBSD forums. After following the instructions there, my X11 now finally works at a decent speed.

The instructions basically boil down to: set the video memory to write-combine mode using MTRR. The FreeBSD forum thread explains it pretty well, so I’m not going to repeat that here. There is only one minor thing you need to be aware of. On my system, the video memory is at 0xe0000000. However, a simple memcontrol set -b 0xe0000000 -l 0x2000000 -o BIOS write-combine does not work. This is due to the fact that the memory from 0xc0000000 on is set to uncacheable. The video memory falls in this range, so you first have to remove the MTRR entry that affects the memory from 0xc0000000 on. After removing this MTRR entry, you can do memcontrol set -b 0xe0000000 -l 0x2000000 -o BIOS write-combine in order to get faster graphics. However, this leaves the system in a pretty bad state: my system just froze when I closed the display lid, when I pulled the power plug etc. In order to fix this, you also need to set the memory before and after the video memory to uncacheable again. The following file seems to do the trick:

#!/bin/sh
memcontrol clear -b 0xc0000000 -l 0x40000000
memcontrol set -b 0xc0000000 -l 0x20000000 -o BIOS uncacheable
memcontrol set -b 0xe0000000 -l 0x2000000 -o BIOS write-combine
memcontrol set -b 0xe2000000 -l 0x2000000 -o BIOS uncacheable
memcontrol set -b 0xe4000000 -l 0x4000000 -o BIOS uncacheable
memcontrol set -b 0xe8000000 -l 0x8000000 -o BIOS uncacheable
memcontrol set -b 0xf0000000 -l 0x10000000 -o BIOS uncacheable

Have fun :)