Driver Arch Problem: Order of CloseScreen Functions
Egbert Eich
eich at pdx.freedesktop.org
Fri May 20 04:11:01 PDT 2005
I came across a problem that must have been lingering for a while
but somehow nobody ever looked at it. Since there is an architectural
issue in the background I bring it up here instead of just fixing it
silently.
It may affect almost all drivers so every driver maintainer should
take a look at it.
I noticed that when DPMS was in some power save state when the Xserver
was terminated the text console was blank. When turning the screen on
prior to shutting down X everything was fine.
After some investigation I found the problem:
DPMSClose() calls the driver DPMS funtion to reenable the display when
called, however the call is shielded by a test for vtSema == TRUE.
DPMSClose() is one of the CloseScreen-wrappers called when the screen
is closed.
Since it is initialized *before* the DriverCloseScreen() wrapper is
added it is called *after* DriverCloseScreen().
There are two flaws in this design:
1. No function that accesses any hardware should be called *after*
DriverCloseScreen() has done its work.
2. When DriverCloseScreen() gets to the point where it calls further
down the wrapper chain it has already set vtSema to FALSE.
On most drivers we would not encounter this problem as the DriverRestore()
function would restore the DPMS state of the console along with the
other register values. Appearantly this didn't happen on the driver
I was looking at so this problem got exposed.
Anyway because of 1. above we need to take some action (and maybe
have to change the driver design guidlines somewhat).
We can either:
1. Eliminate the call to the driver DPMS function inside DPMSClose()
entirely relying on the DriverCloseScreen() or the driver Restore()
function to take care of this properly.
or
2. Change the order in which the DriverCloseScreen() and DPMSClose()
wrapper are applied (ie. moving DPMSInit() behind the driver
CloseScreen wrapping.
At the moment I would favor solution 1, but I may easily be convinced
otherwise.
NOTE: It is easily conceivable that more CloseScreen() functions
have the same problem!
Opinions?
Cheers,
Egbert.
More information about the xorg-arch
mailing list