Debugging Mesa DRI for the Intel i965 on a Lenovo R61

Here I am trying to crank out something for the ICFP Programming Contest and I have a huge host of OpenGL problems with my new laptop. This stuff should come in handy for all those people out there with a Lenovo R61 running Gentoo Linux with Mesa 6.5… all two of them.

Anyhow, no math or programming in this post, I’m afraid, just good old-fashioned system debugging.

Background

If I run any of the provided servers for the ICFP contest without DRI, I get no output. This is an FAQ but I’m on Gentoo and the FAQ is no help. It is also discussed in this bug report. Since it seems people have more success with accelerated drivers (why?) and software GL is known to work on my system for other programs, I suspect it is a bug specialized to the libraries used in the provided server. The quickest way to solve this, I figured, was to try an accelerated DRI driver for the Intel i965 in my Lenovo R61.

Kernel

First, I check that the kernel knows about the card and has DRM (the kernel end of DRI) set up:

$ zcat /proc/config.gz  | grep DRM
...
CONFIG_DRM=y
...
CONFIG_DRM_I915=y
...

The i965 uses the same driver as the i915 so this is good. Next, dmesg:

$ dmesg | grep drm
[drm] Initialized drm 1.1.0 20060810
[drm] Initialized i915 1.6.0 20060119 on minor 0

Good. The kernel is happy.

X.org

First, enable DRI in /etc/X11/xorg.conf

Section "Module"
   ...
   Load "dri"
   ...
EndSection

I should point out this other part of my xorg.conf:

Section "Device"
   ...
   Driver      "intel"
   ...
EndSection

Next, I start X and see what it says about DRI and DRM.

$ grep 'dri[^v]' /var/log/Xorg.0.log
(II) LoadModule: "dri"
(II) Loading /usr/lib/xorg/modules/extensions//libdri.so
(II) Module dri: vendor="X.Org Foundation"
drmOpenDevice: node name is /dev/dri/card0
drmOpenDevice: node name is /dev/dri/card0
drmOpenDevice: node name is /dev/dri/card0
(II) intel(0): [dri] visual configs initialized
drmOpenDevice: node name is /dev/dri/card0
drmOpenDevice: node name is /dev/dri/card0
(II) AIGLX: Loaded and initialized /usr/lib/dri/i965_dri.so

Now I run the provided server and it gives output! But the moment the rover’s viewing radius clips the edge of the world, my computer crashes! My /var/log/Xorg.0.log.old tells me this happened:

Fatal server error:
lockup

Well, yes. I noticed. After some googling, I read that it is a known bug with old version of the Mesa library. But Gentoo has newer versions (major number 7) marked unstable because of known bugs in their interface with the Native Posix Thread Library (i.e. USE=-nptl is mandatory).

Upgrading Mesa

I put this in /etc/portage/package.keywords:

media-libs/mesa ~x86

and the following in /etc/portage/package.use to avoid the nptl bug:

media-libs/mesa -nptl
x11-base/xorg-server -nptl

The latter is necessary because the setting of the flag must agree between xorg-server and mesa even though this dependency is beyond the capabilities of Portage to reason about. After re-installing, I go through the above checks again. The kernel checks out, but X does not:

$ grep 'dri[^v]' /var/log/Xorg.0.log.old 
(II) LoadModule: "dri"
(II) Loading /usr/lib/xorg/modules/extensions//libdri.so
(II) Module dri: vendor="X.Org Foundation"
drmOpenDevice: node name is /dev/dri/card0
drmOpenDevice: node name is /dev/dri/card0
drmOpenDevice: node name is /dev/dri/card0
(EE) intel(0): [dri] DRIScreenInit failed. Disabling DRI.
$ grep drm /var/log/Xorg.0.log.old 
drmOpenDevice: node name is /dev/dri/card0
drmOpenDevice: open result is 8, (OK)
drmOpenDevice: node name is /dev/dri/card0
drmOpenDevice: open result is 8, (OK)
drmOpenByBusid: Searching for BusID pci:0000:00:02.0
drmOpenDevice: node name is /dev/dri/card0
drmOpenDevice: open result is 8, (OK)
drmOpenByBusid: drmOpenMinor returns 8
drmOpenByBusid: drmGetBusid reports pci:0000:00:02.0
(II) intel(0): [drm] DRM interface version 1.0
(II) intel(0): [drm] drmSetBusid failed (8, pci:0000:00:02.0), Permission denied

I really don’t know what this means, and neither does anyone else on the internet really. The troubleshooting page on the DRI wiki says this may be caused by your kernel being compiled with a different version of GCC than the DRI driver, but not certainly, and not always. I do fit this description, so I decided to give it a shot. A bit nerve-wracking, since I don’t have a rescue disk with me, but it worked.

End of story. I can watch my mars rover in beautifully accelerated 3D. Here’s the final “good” output of all the above greping

$ dmesg | grep drm
[drm] Initialized drm 1.1.0 20060810
[drm] Initialized i915 1.6.0 20060119 on minor 0
 $ grep 'dri[^v]' /var/log/Xorg.0.log 
(II) LoadModule: "dri"
(II) Loading /usr/lib/xorg/modules/extensions//libdri.so
(II) Module dri: vendor="X.Org Foundation"
drmOpenDevice: node name is /dev/dri/card0
drmOpenDevice: node name is /dev/dri/card0
drmOpenDevice: node name is /dev/dri/card0
(II) intel(0): [dri] visual configs initialized
drmOpenDevice: node name is /dev/dri/card0
drmOpenDevice: node name is /dev/dri/card0
(II) AIGLX: Loaded and initialized /usr/lib/dri/i965_dri.so
$ grep drm /var/log/Xorg.0.log 
drmOpenDevice: node name is /dev/dri/card0
drmOpenDevice: open result is 8, (OK)
drmOpenDevice: node name is /dev/dri/card0
drmOpenDevice: open result is 8, (OK)
drmOpenByBusid: Searching for BusID pci:0000:00:02.0
drmOpenDevice: node name is /dev/dri/card0
drmOpenDevice: open result is 8, (OK)
drmOpenByBusid: drmOpenMinor returns 8
drmOpenByBusid: drmGetBusid reports pci:0000:00:02.0
(II) intel(0): [drm] DRM interface version 1.3
(II) intel(0): [drm] created "i915" driver at busid "pci:0000:00:02.0"
(II) intel(0): [drm] added 8192 byte SAREA at 0xf885d000
(II) intel(0): [drm] mapped SAREA 0xf885d000 to 0xb7fb0000
(II) intel(0): [drm] framebuffer handle = 0xe0050000
(II) intel(0): [drm] added 1 reserved context for kernel
(II) intel(0): [drm] Registers = 0xf8100000
(II) intel(0): [drm] ring buffer = 0xe0000000
(II) intel(0): [drm] init sarea width,height = 1280 x 1280 (pitch 1280)
(II) intel(0): [drm] Back Buffer = 0xe2158000
(II) intel(0): [drm] Depth Buffer = 0xe2798000
(II) intel(0): [drm] textures = 0xe2dd8000
(II) intel(0): [drm] Initialized kernel agp heap manager, 33554432
(II) intel(0): [drm] installed DRM signal handler
(II) intel(0): [drm] dma control initialized, using IRQ 20
drmOpenDevice: node name is /dev/dri/card0
drmOpenDevice: open result is 9, (OK)
drmOpenByBusid: Searching for BusID pci:0000:00:02.0
drmOpenDevice: node name is /dev/dri/card0
drmOpenDevice: open result is 9, (OK)
drmOpenByBusid: drmOpenMinor returns 9
drmOpenByBusid: drmGetBusid reports pci:0000:00:02.0

Leave a Reply

You must be logged in to post a comment.