|
|
Subscribe / Log in / New account

LCA: Graphics driver ponies

By Jonathan Corbet
January 26, 2010
Those of you who have come to appreciate Dave Airlie's kitten-filled presentations might just have been dissatisfied with his linux.conf.au talk, which was called "So you moved graphics drivers to the kernel.. what next? I can haz ponies?" But ponies, too, can be cute, and the update on the state of graphics drivers in the kernel was well worth the listening.

It has now been about a year since kernel mode setting (KMS) was merged into the mainline kernel. KMS ends the "mess" which came from having graphics drivers in user space; digging out of that particular hole took a good seven years or so. But now our graphics drivers are in the kernel, just like most other drivers.

Beyond cleaning up the mess, there are a few other good reasons for merging KMS. One is that the system is now able to make full use of the power-saving features of the hardware; before KMS, the kernel never really knew enough about what was going on with the hardware to do this. The Intel drivers can now perform as well as Windows with regard to power saving; the ATI drivers, instead, are not quite there yet. Another nice [Dave
Airlie] feature is the ability to use a kernel debugger on a system with graphics running; it's now possible to trap into the debugger, then return to a running system and have everything just work.

One of the reasons why KMS took so long to merge is that it places a number of new requirements on the kernel. At the top of the list is a proper manager for graphical memory. That's a hard problem, one that the graphics developers always intended to get to sometime Real Soon Now. Eventually the TTM developers got to it, but they quickly ran into a number of API difficulties. After some effort, the Intel developers decided that a generic approach to the memory management API wasn't going to work; out of that realization came the GEM memory manager, which only tried to solve the Intel problem.

Developers working on ATI chipsets, in turn, soon realized that GEM did not have the capabilities that they needed. So they went back to TTM, but not before bolting something that looks a lot like the GEM API onto it. TTM was recently merged, making KMS possible for ATI chipsets as well.

So what is coming? One future feature is the Gallium 3D architecture. Gallium, says Dave, is starting to work, but full functionality will take a while yet. Moving drivers to Gallium is going to be a painful exercise; there are already plenty of APIs that these drivers need to support. DRI2 is also coming along. This feature really needed KMS to work properly, especially when compositing is being used. There are still performance issues which must be resolved, though.

Another thing to look forward to is the Wayland display server. Wayland can be seen as a simpler, smaller replacement for X built on KMS. It can run GTK and GL applications now; there is also an X server emulator which can run on top of it. A few difficulties remain, including the fundamental fact that Wayland is not X; since X is the standard in this area, alternatives are going to be hard to sell. The Wayland developers also have not yet really dealt with the input problem, but input is a big piece of the X code. So Wayland, too, will be a while in coming; it may find its way into embedded situations first.

Dave spent some time on the current state of the graphics drivers. Intel, he says, is currently in the leading position. It supports KMS for everything - well, almost everything; the "chipset we won't name" (the proprietary GMA500) still lacks support. The driver is feature-complete, but Dave isn't quite ready to call it "mature"; another release or two will be required first. As discussed here previously, the driver will need to retain user mode setting (UMS) support for some time, but the current upstream X.org sources have already removed UMS from the X server.

The ATI/AMD drivers are further behind, but getting closer; this driver is harder than the Intel driver, due to the large number of chipset variations. Chipsets from R100 to R700 are currently supported; R800 support can be expected within a few weeks. The driver works "nearly as well as the old stuff" at this point; suspend and resume work better than before. Support for power-saving features is missing but expected for 2.6.34. The Radeon driver is currently in the staging tree, but it might move out before the end of the 2.6.33 development cycle.

What about the RadeonHD driver? That fork of the driver is primarily the result of a disagreement over the use of ATI's BIOS tables; the Radeon driver has an interpreter for these tables, while RadeonHD reimplements the functionality that those tables provide. Using the BIOS tables makes life a lot easier; it lets the driver ignore a lot of the details associated with different chipset variations. The BIOS table code is part of the KMS implementation which has been merged into the mainline; that should, Dave thinks, resolve this disagreement.

The "pony" displayed for the Nouveau discussion was a Trojan horse. Nouveau, of course, was merged for 2.6.33. The driver has just lost its user-mode support; it will be KMS only. Chipsets from the NV4 through the G80 are supported, with the final pieces to be filled in soon. The "ctxprogs" firmware is being figured out; the NV40 version has already been replaced with a rewritten, freely-licensed equivalent and NV50 is in the works. Dave noted that, whatever one thinks about NVIDIA's approach to working with the community, its hardware tends to be relatively good and easy to work with.

When Dave was asked about support for non-Linux systems, he replied that most of them have been left behind at this point. There is, apparently, an OpenSolaris port being done within Sun, but no code has been released from that group. One other audience member asked about running X without root privileges: that does work now, and Moblin is doing it. There are some problems remaining, though, especially with fast user switching. In the absence of a revoke() system call, there's no way to guarantee that one user isn't listening in on another. Since revoke() is known to be a hard problem, it's not clear how this issue will be resolved.

Index entries for this article
KernelDevice drivers
KernelNouveau
Conferencelinux.conf.au/2010


to post comments

LCA: Graphics driver ponies

Posted Jan 28, 2010 4:36 UTC (Thu) by thedevil (guest, #32913) [Link] (13 responses)

I have 2 comments about the ATI side. 1. I think what in the staging tree in 2.6.32 is just the option of making KMS the default. Even if you don't enable the staging tree at all you can already use KMS just by doing
echo 'options radeon modeset=1' >> /etc/modprobe.d/local-radeon.conf
2. I tried it, it works fine in X, and I see no problems as long as my virtual consoles start in old-fashioned text mode. They actually seem to be changed to an internal framebuffer mode as soon as I switch to them with Alt+Ctl+Fn . But I get a very unexpected result when I enable *both* KMS and vesafb. When I switch to a virtual console with Alt+Ctl+Fn, my monitor displays the "No signal" message and goes to sleep! So, based on this experience I am not going to use KMS quite yet.

LCA: Graphics driver ponies

Posted Jan 28, 2010 5:01 UTC (Thu) by BenHutchings (subscriber, #37955) [Link] (7 responses)

The DRI+KMS graphics drivers will conflict with framebuffer drivers for the same hardware. The kernel only allows one driver to bind to each PCI device and normally that prevents you from making this mistake. vesafb is an exception because it doesn't bind to a specific PCI device, but you should not expect it to work.

LCA: Graphics driver ponies

Posted Jan 28, 2010 6:43 UTC (Thu) by thedevil (guest, #32913) [Link] (6 responses)

Hmm. Maybe my memory is really going to $@#! due to middle age, but I seem to remember that saner switching between X and VCs was one of the selling points of KMS. But if that means you have to stay in 80x25 for the VCs it's not very persuasive.

LCA: Graphics driver ponies

Posted Jan 28, 2010 13:29 UTC (Thu) by xav (guest, #18536) [Link] (4 responses)

By default on my system KMS sets the console framebuffer to 1900x1200, which makes fro a quite high res text console (I don't know how much, but far more than 80x25).

LCA: Graphics driver ponies

Posted Jan 28, 2010 14:57 UTC (Thu) by nix (subscriber, #2304) [Link] (2 responses)

I do wonder how to set the resolution to something nonstandard. As far as
I can tell with Radeon KMS there is no way: the resolution the monitor
prefers is always selected. This is normally fine for those of us with
LCDs, but for the poor sods stuck on CRTs it seems suboptimal.

(but, yes, a nice fb console with huge numbers of rows and columns which
does not bugger up X acceleration is a major plus of KMS. Another major
plus.)

LCA: Graphics driver ponies

Posted Jan 28, 2010 21:52 UTC (Thu) by michich (guest, #17902) [Link] (1 responses)

Boot parameter video=800x600 works for me with Radeon KMS. See Documentation/fb/modedb.txt.

LCA: Graphics driver ponies

Posted Jan 28, 2010 22:53 UTC (Thu) by nix (subscriber, #2304) [Link]

OK, no wonder I couldn't find the docs. fb/modedb.txt is, uh, not the most
obvious of places :)

(though 800x600 is the last-ditch fallback resolution in any case, so
perhaps not the best one to test with.)

LCA: Graphics driver ponies

Posted Feb 2, 2010 1:38 UTC (Tue) by Spudd86 (subscriber, #51683) [Link]

If the text is too small change the console font to something bigger.

LCA: Graphics driver ponies

Posted Jan 28, 2010 20:59 UTC (Thu) by BenHutchings (subscriber, #37955) [Link]

You set it through the KMS driver, not vesafb. (But don't ask me how!)

LCA: Graphics driver ponies

Posted Jan 28, 2010 7:42 UTC (Thu) by airlied (subscriber, #9104) [Link] (3 responses)

If you don't enable KMS by default using the staging option, udev won't load it, so you'll need to load it by hand before starting X. This is really why distros need to ship support for KMS by default or don't bother.

So just load it by default somewhere before X starts and get a hires console.

LCA: Graphics driver ponies

Posted Jan 29, 2010 5:05 UTC (Fri) by thedevil (guest, #32913) [Link] (2 responses)

But it doesn't work! It gives me the same "No signal" behavior as when I enable vesafb.

I guess I should report this, but where?

LCA: Graphics driver ponies

Posted Jan 30, 2010 4:09 UTC (Sat) by thedevil (guest, #32913) [Link] (1 responses)

Solved! It turns out I haven't selected fbcon in the kernel config. So this is really a bug in the kernel build system: drm + kms should autoselect fbcon.

LCA: Graphics driver ponies

Posted Jan 30, 2010 11:36 UTC (Sat) by chris.wilson (guest, #42619) [Link]

It does, but only if you have not also selected to optimize for small/embedded systems where you can opt out of the overhead of allocating a framebuffer for the console.

config DRM_KMS_HELPER
tristate
depends on DRM
select FB
select FRAMEBUFFER_CONSOLE if !EMBEDDED

LCA: Graphics driver ponies

Posted Feb 2, 2010 1:37 UTC (Tue) by Spudd86 (subscriber, #51683) [Link]

err, you REALLY ought to make sure the KMS driver is controlling your consoles... if somehow you managed to end up binding vesafb to your consoles with the radeon DRI stuff assuming KMS bad things would happen...

You CAN'T use both at the same time, KMS implies framebuffer console with the KMS based driver controlling it. (And vesafb should do nothing)

Unclear paragraph

Posted Jan 28, 2010 10:56 UTC (Thu) by epa (subscriber, #39769) [Link] (2 responses)

KMS ends the "mess" which came from having graphics drivers in the kernel; digging out of that particular hole took a good seven years or so. But now our graphics drivers are in the kernel, just like most other drivers.
I don't understand - are the drivers in the kernel or not, and is this a mess?

Unclear paragraph

Posted Jan 28, 2010 13:25 UTC (Thu) by niner (subscriber, #26151) [Link]

They have not been in the kernel which lead to a mess, but now they are. I
already reported that obvious typo. But it's still very early in the
morning over in the U.S.

Unclear paragraph

Posted Jan 28, 2010 14:25 UTC (Thu) by corbet (editor, #1) [Link]

That's a really silly mistake; I'm not sure how it got through. It's fixed now, sorry for the confusion.

LCA: Graphics driver ponies

Posted Jan 28, 2010 13:57 UTC (Thu) by Tet (guest, #5433) [Link] (10 responses)

The driver has just lost its user-mode support; it will be KMS only

I do wish they wouldn't do this. It essentially prevents me from using a recent kernel. With my card, KMS causes a segfault in the server, but it works just fine without KMS. I understand why they want to do it. The non-KMS code is messy, and they don't want to maintain it. But it works, in places where KMS currently doesn't.

LCA: Graphics driver ponies

Posted Jan 28, 2010 15:43 UTC (Thu) by rahulsundaram (subscriber, #21946) [Link] (5 responses)

The answer there is not to maintain two different systems with different bugs in each of them but fix the one that is there for the longer term

LCA: Graphics driver ponies

Posted Jan 28, 2010 16:49 UTC (Thu) by nix (subscriber, #2304) [Link]

Especially given that the non-KMS code is not just 'messy' but
misdesigned. Multiple drivers in kernel and userspace arguing over a
single video card is pretty much obviously a bad idea. If video cards on
PCs had never been capable of displaying text, I suspect this design would
never have lasted as long as it has, at least on Linux: this meant that
most people could just use a text-mode console and pretend that there was
only one graphics driver, the 2D X one, when in fact the other driver was
in the video card...

LCA: Graphics driver ponies

Posted Jan 29, 2010 21:08 UTC (Fri) by Tet (guest, #5433) [Link] (3 responses)

Agreed. Clearly maintaining both is not viable. All I'm proposing is not removing the non-KMS code until the KMS code is stable and usable. Importantly, that has to include older hardware (not obsolete, just not cutting edge). It seems there's been a reasonable amount of work on getting KMS working with newer video cards. But it needs to work on cards that are 3 or 4 years old, too, and based on my experience, it currently doesn't.

LCA: Graphics driver ponies

Posted Jan 30, 2010 6:03 UTC (Sat) by rahulsundaram (subscriber, #21946) [Link] (1 responses)

Have you reported your bug? We can debate on what is the right threshold but it is also the case as long as there are two different systems end users tend to switch between them and never report bugs

LCA: Graphics driver ponies

Posted Jan 31, 2010 16:21 UTC (Sun) by Tet (guest, #5433) [Link]

Yes. For better or for worse, I report every problem I find as a bug. The usual response seems to be to ignore it, wait for a year and then close the bug because it's for an unsupported release. But I have to keep trying...

LCA: Graphics driver ponies

Posted Jan 30, 2010 18:48 UTC (Sat) by nix (subscriber, #2304) [Link]

It certainly should work with older hardware: my 2000-vintage system (now
reserved for compatibility checking) with its Radeon 9250 is quite happy
with KMS.

However ATI have a crazy variety of cards, all wired up slightly
differently, and the pre-ATOM ones don't give the drivers much help to
fight through the morass. So, yes, report as a bug.

LCA: Graphics driver ponies

Posted Jan 28, 2010 19:34 UTC (Thu) by jsbarnes (guest, #4096) [Link]

Please file a bug. A server segfault obviously shouldn't happen, but should also be pretty easy to fix.

LCA: Graphics driver ponies

Posted Jan 28, 2010 22:02 UTC (Thu) by Thalience (subscriber, #4217) [Link] (2 responses)

As I understood it, the component that would lose UMS support is the X Driver (DDX). So you wouldn't be able to run a newer X on an old kernel.

LCA: Graphics driver ponies

Posted Jan 28, 2010 22:59 UTC (Thu) by nix (subscriber, #2304) [Link] (1 responses)

... or on a non-Linux OS. I suppose OSes that can't be bothered to
implement KMS over the course of many years are probably moribund anyway.
(The cynic in me would say that everything but Linux is pretty moribund as
an X server platform these days...)

LCA: Graphics driver ponies

Posted Feb 2, 2010 1:43 UTC (Tue) by Spudd86 (subscriber, #51683) [Link]

Apparently people ARE working on it for FreeBSD and Solaris, but FreeBSD doesn't have as many people as Linux so it might be a while

LCA: Graphics driver ponies

Posted Jan 28, 2010 15:56 UTC (Thu) by ernstp (guest, #13694) [Link]

And now we have power management for Radeon also:
http://git.kernel.org/?p=linux/kernel/git/airlied/drm-2.6...

It's all coming together very quickly now! I guess that's the benefit of having several full time employees working on this... :-)

(Not sent to Linus yet though)

revoke()

Posted Jan 28, 2010 16:43 UTC (Thu) by chrish (guest, #351) [Link] (2 responses)

"One other audience member asked about running X without root privileges: that does work now, and Moblin is doing it. There are some problems remaining, though, especially with fast user switching. In the absence of a revoke() system call, there's no way to guarantee that one user isn't listening in on another."

Could someone expdand on the part in bold and describe in more detail what the problem is? Why would fast user switching cause a single fd to be allocated to processes belonging to different users?

revoke()

Posted Jan 28, 2010 17:59 UTC (Thu) by wingo (guest, #26929) [Link]

I don't know, but I'll hazard a guess: the input and output devices of an X session are file descriptors, and have to be handed to and from the display manager and different userspace, and there's nothing preventing one user from keeping a dupped copy of one of the devices.

At least this comment should provoke someone knowledgeable to correct me :)

revoke()

Posted Feb 1, 2010 0:05 UTC (Mon) by whot (subscriber, #50317) [Link]

The evdev input driver opens /dev/input/eventX file descriptors. The same fd can be opened by another process allowing this process to read events coming from the devices. Currently, you need to be root to open the devices.

If the fd of a keyboard can be opened by a user, this user is able to read keyboard events. Example scenario:
1. user A logs in, /dev/input/event0 is opened as keyboard
2. user A starts keyboard sniffer on /dev/input/event0 because he or she has permissions to open this file.
3. user A uses fast user switching
4. user B logs in, /dev/input/event0 is opened as keyboard

Unless any process by user A can be suspended or revoked access to the fd, this process can sniff keyboard events from user B.


Copyright © 2010, Eklektix, Inc.
This article may be redistributed under the terms of the Creative Commons CC BY-SA 4.0 license
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds