Saturday, August 29, 2009

Radeon KMS on Gentoo (almost!)

Radeon KMS has been in the Linux kernel for a few months now; it may not be stable or even complete yet, but I still want it. :o

(If you have no idea what Radeon KMS is, this post isn't for you. I'm mainly writing it for future reference.)

I started from the guide that Dave Airlie wrote a few months ago on his blog. It's somewhat out of date, since a lot of the code he recommends pulling from git has made it into released versions, but still needs some extra configure options.

Before you try this guide: it ends in a hard lockup on my system. All the steps appear correct; I don't know whether I screwed up or whether the latest code is broken right now, but don't get your hopes up. I'm putting this online purely for reference.

Step 1: Kernel, at least 2.6.31

As of 2.6.31, the Radeon KMS kernel bits are in as a staging driver. To enable KMS, you have to enable:

Device Drivers > Staging drivers > uncheck "Exclude staging drivers from being built"
Device Drivers > Staging drivers > Enable modesetting on radeon by default

Step 2: libdrm, at least 2.4.12

libdrm needs an extra configure option to enable KMS. Copy the ebuild into your overlay, rename it libdrm-2.4.12-r99 or something, and add the following line to it:

CONFIGURE_OPTIONS="--enable-radeon-experimental-api"

And then re-emerge.

Step 3: xf86-video-ati, from git (or newer than 6.12.2)

The ATI driver hasn't seen a release in like five months, so this one still needs to be pulled from git. As of this writing, there's a bug in the latest git tree - in radeon_dri2.c, in radeon_dri2_create_buffer, it assigns to the format field of a DRI2BufferPtr. Unfortunately, format was only added in a later version of that struct (DRI2Buffer2Ptr, iirc), so this fails to compile. The bug's been there for two months now, so I don't know if my setup is just weird or what.

Quick but shady patch: just comment out the assignment.

diff --git a/src/radeon_dri2.c b/src/radeon_dri2.c
index 613fde8..37db359 100644
--- a/src/radeon_dri2.c
+++ b/src/radeon_dri2.c
@@ -202,7 +202,7 @@ radeon_dri2_create_buffer(DrawablePtr drawable,
buffers->pitch = pixmap->devKind;
buffers->cpp = pixmap->drawable.bitsPerPixel / 8;
buffers->driverPrivate = privates;
- buffers->format = format;
+ //buffers->format = format;
buffers->flags = 0; /* not tiled */
privates->pixmap = pixmap;
privates->attachment = attachment;
Copy the xf86-video-ati-6.12.2 ebuild (not the -r1, it has extra patches that I'm not sure we want, since they apply to a five month older version) in the portage tree to your overlay, and rename it xf86-video-ati-9999.ebuild - this will automatically turn it into a live git ebuild. Save the above patch in files/ as xf86-video-ati_buffer-version.patch. Add to the end of src_prepare:

epatch ${FILESDIR}/xf86-video-ati_buffer-version.patch

With this, it should build.

Step 4: Mesa, at least 7.5

Dave Airlie's guide says to rebuild mesa from git at this point, but since a version has been released since then, I'm not sure this step is necessary anymore. Re-emerge mesa if you're feeling superstitious.

At this point, you might have working KMS! I get a nice "[KMS] Kernel modesetting enabled." message in my Xorg.log, but then my whole system crashes pretty hard. I'm planning to poke the radeon driver devs and see what they think, and then I'll update this post with details.

3 comments:

FireBurn said...

I'm using the x11 overlay and I'm not having any issues with KMS with radeon. Are you using r600 or r700? These aren't supported yet with KMS

P. Static said...

...wait, the x11 overlay has KMS stuff? Oh, man, wish I'd known that this morning. XD

123 123 said...

Nice blog as for me. I'd like to read something more about this topic.
BTW check the design I've made myself London escorts