February 2013 Archives

2013-02-04 23:20:50

NetBSD support for Intel kernel Mode Setting

A few versions ago, Intel started releasing drivers for their graphics cards which would rely on the kernel to switch between graphics modes (a new development from the Linux/FLOS world). This would, for example, ease the transition between framebuffer consoles and X11.

Since however the NetBSD kernel doesn't yet (as of version 6.0) support setting graphics modes, this means that later Intel drivers don't work under current NetBSD releases.

And there our hero, Grégoire Sutre, comes to play. He started a project on GitHub to port DRM/GEM to NetBSD from OpenBSD, which had a paid person implementing it for them under a BSD license.

Testing it on the stable release

A while ago, I replaced my old Thinkpad T61 with a T520. Unfortunately, this meant I also had to switch from NetBSD to Debian GNU/Linux because NetBSD wouldn't run on the T520 and I didn't have the time to change that. Also, at that time, neither of the BSDs supported kernel mode setting.

A few days ago, prompted by the announcement of the CONFIG_VT deprecation under Linux, I decided to make another attempt at getting NetBSD to run on the T520 and stumbled across Grégoires work. It was a bit awkward to take his changes and to apply them to NetBSD 6.0, because they were made for NetBSD-current and had to be modified first. Nonetheless, I managed to apply them relatively sensibly.

The rest doesn't take a lot of time to lay out. I built a release with the changes and applied it to my NetBSD system. There, everything worked. I had Intel graphics.

So I decided to upload a patch to my FTP server. In addition to that, I also built the release sets and an installation ISO image and uploaded them. You can find everything on ftp.bsdprojects.net under NetBSD-6.0-drmgem-20130203.

How to apply the patch to NetBSD-6

The distribution method Grégoire chose was a bit awkward to use (as described above), so I decided to create two patches (one for src, one for xsrc) and distribute those instead for NetBSD-6. The rest of the procedure is pretty straightforward. First, fetch the patches:

% ftp http://ftp.bsdprojects.net/pub/bsdprojects/NetBSD/NetBSD-6.0-drmgem-20130203/netbsd6-drmgem-src-20130203.diff.gz
% ftp http://ftp.bsdprojects.net/pub/bsdprojects/NetBSD/NetBSD-6.0-drmgem-20130203/netbsd6-drmgem-xsrc-20130203.diff.gz

Then, get the source code from CVS.

% cvs -d anoncvs@anoncvs.xy.netbsd.org:/cvsroot co -P -rnetbsd-6 src
% cvs -d anoncvs@anoncvs.xy.netbsd.org:/cvsroot co -P -rnetbsd-6 xsrc

Apply the patches:

% (cd xsrc && zcat ../netbsd6-drmgem-xsrc-20130203.diff.gz | patch -p0)
% cd src && zcat ../netbsd6-drmgem-src-20130203.diff.gz | patch -p0

… and build the tools and release:

% ./build.sh -j 9 -x tools
% ./build.sh -j 9 -x release
% ./build.sh -j 9 -x install=/

Then ensure that all your pkgsrc packages are linked against the X.Org release installed from the base. Things might work ok if you link the clients against X.Org from pkgsrc, but the pkgsrc X server certainly won't work. And if you already use X.Org from base anyway, why not use it for everything.

The Future

Right now the drmgem code is in a state where Intel kernel mode setting works. However, all the DRM modules have been deactivated in the X.Org source. This is because they don't seem to work yet. So the patch cannot yet be committed as it is, because for everybody who's not using Intel, it would be a step back.

So this means that the patch needs some brushing up. But it's good, solid work and will hopefully be ready to be committed into the source base some day soon.

What's left to say: Thank you, Grégoire Sutre, for your good work! If we can help you somehow, please let us know.

Flattr this