Improving VT switching with KMS

Ari Entlich atrigent at
Wed Feb 24 12:54:16 PST 2010

Hey all!

So I'm that annoying guy who keeps asking questions on the irc channel about VT switching and KMS. I suppose I am now moving that discussion here so as to (hopefully) get more responses.

So I made a kernel patch which allows (at least as far as the VT subsystem is concerned) a VT switch to happen even if the VT being switched away from is managed by a process. Since this new VT mode is basically a cross between VT_AUTO and VT_PROCESS, I just called it VT_PROCESS_AUTO. My impression (and the impression of a couple of other people who I've asked) is that this is now safe to do with KMS.

However, I'd like to confirm some of my impressions as well as get help on how to use the new mode in X. So:

Question #1 is to the developers of the xf86 video drivers which can use KMS (I think this is currently intel + ati + nouveau, but please correct me if I'm wrong), as well as to the developers of KMS itself:

When using KMS, is it safe for the {Enter,Leave}VT callbacks to not be called exactly prior to entering/leaving a VT? Obviously if the drivers didn't register these callbacks then it would be pretty easy to tell, but all three of the drivers listed above DO register these callbacks, whether in the KMS context or otherwise. So since I assume that these callbacks do have some purpose, I guess my question is really: what sort of effect would not executing them have? Would it cause text VTs to not work? Would it cause subsequent usage of X to not work? Would it have some other problematic effect? I'd just like to get as many opinions about this as possible, because it's a pretty crucial point in all this.

Question #2 is directed at the developers who work on the X server:

Even if the answer to question #1 is yes, the X server still needs to be able to decide whether to use VT_PROCESS_AUTO, i.e. it needs to be able to check whether KMS is being used. Not having done any X hacking, this is proving to have quite a learning curve for me. Here are some of the preliminary assumptions I'm making and some of the things I've determined by grepping through the code (lots of these things will be obvious to most of you, just bear with me):

1. At least at first, I'm only going to try to get this working for the xfree86 server (i.e. not the kdrive or dmx servers, which I think(?) will also need some modification, assuming they're still maintained?).
2. It looks like all of the information needed to make the KMS determination is stored in global variables (xf86Screens, etc), so I won't need to modify a bunch of functions so that they can pass more information around. This should make it easier.
3. The check would have to be done for all screens, because the VT callbacks are executed for all of them on leave/enter (this would probably be obvious to me if I had ever used more than one screen, but I never have). Alternatively, maybe the check could just be done for all devices in use, if this is more efficient?
4. There seem to me to be two different ways of accomplishing the check itself:
  a. The check would be done completely in the X server, i.e. the X server does all of the KMS detection itself. I think I could use something like the i830_kernel_mode_enabled function in the intel driver, minus the module loading functions. I guess the downside of this is that the X server would have to link with libdrm.
  b. The video drivers could set a field in the ScrnInfoPtr that they are given (or wherever) which specifies whether switching before calling the callbacks is allowed. The downside of this approach is that it would probably cause an ABI-level incompatibility, and also drivers which can use KMS would have to modified. However, it might be more correct because the drivers could say whether they are actually using KMS, instead of just whether KMS is supported (or is KMS always being used when it is supported?). Also, the drivers could set this field during the course of their own initialization, which would resulting in very little new code. The X server could set this field to FALSE by default, so that non-KMS drivers wouldn't have to be modified.

How does this sound? Does most of this sound right? Which way should I perform the check?

Also, I'm curious if there's actually really any interest in this change. I don't know if it's just that I've been asking at the wrong times or what, but responses to my queries about this stuff on the irc channel seem to be a bit apathetic. Is this not something people want/care about?



More information about the xorg-devel mailing list