Comment 9 for bug 140051

Revision history for this message
Martin-Éric Racine (q-funk) wrote : Re: amd driver fails to autoconfigure

Anti Sullin of artecdesign.ee made the following comments :

After a full day of debugging, the result is: we have a picture
(although as we don't support DDC monitor detection, it's defaulted to
800x600@60Hz 256colors; didn't look where that comes from). Still, the
system has some strange problems, things crash etc... But that may be a
problem of my edubuntu server.

X gets started twice. Once with -configure option, that autodetects
video HW and monitors and writes config file. Second run is started with
that config file.
On the first run, all drivers are probed. Those, that existed, are
preinit'ed to try to get monitor information (if not, then defaults are
probably used). (screen configuration is not there as it does not exist
yet).
On second run, the AMD driver is loaded and preinit is called. But at
that point, the screen information is already there and everything works.

The bug is that the screen information is not passed to the PreInit
function at probe run. (in AMD/geode LX case LXPreInit()). LXPreInit
loads vgahw module (for manipulating something via vga i/o addreses...
is this needed at all?) and then calls function vgaHWGetHWRec there.
That accesses scrp->confScreen->options, but scrp->confScreen is a null
pointer because we are on a probe run and we don't have any screens
yet... And BANG, segmentation fault. (Some more accesses of
scrp->confScreen are in LXPreInit, too... so removing vgahw doesn't help).

The gdb log about the crash, too.

Program received signal SIGSEGV, Segmentation fault.
0xb7816f6f in vgaHWGetHWRec (scrp=0x8227610)
  at ../../../../hw/xfree86/vgahw/vgaHW.c:1721
1721 ../../../../hw/xfree86/vgahw/vgaHW.c: No such file or directory.
      in ../../../../hw/xfree86/vgahw/vgaHW.c
(gdb) bt
#0 0xb7816f6f in vgaHWGetHWRec (scrp=0x8227610)
  at ../../../../hw/xfree86/vgahw/vgaHW.c:1721
#1 0xb7cc8a35 in LXPreInit (pScrni=0x8227610, flags=1) at
amd_lx_driver.c:488
#2 0x080bb72e in DoConfigure ()
  at ../../../../hw/xfree86/common/xf86Configure.c:985
#3 0x080a8b05 in InitOutput (pScreenInfo=0x8202a80, argc=3,
argv=0xbfac7dd4)
  at ../../../../hw/xfree86/common/xf86Init.c:388
#4 0x08076ceb in main (argc=3, argv=0xbfac7dd4, envp=0xbfac7de4)
  at ../../dix/main.c:370

Fix:
-------------
1) as on ati driver, the driver does not have to initialize anything IF
the PROBE_DETECT flag is present. We should detect monitor (but don't
have to). After that, we need just to return TRUE;
So for a quick fix without any monitor detection, I just added

if (flags & PROBE_DETECT) return TRUE;

to the LXPreInit beginning (after variable declarations). X comes up and
we have a picture... although 800x600@60Hz,256colors only.

2) maybe the vgahw should be removed as on ati :
http://lists.freedesktop.org/archives/xorg/2004-December/004951.html ?
Is it needed at all?