[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Bug#345497: xserver-xorg: [mga] unresolved symbol in mga_drv.o crashes xserver, leaving the console unusable



Hi everyone,
Just in case somebody cares - I've had the same problem with my G550 card after upgrading to Xorg 6.9.0. Since I'm using this card in hi-res modes via DVI, I had some motivation to look at this issue a little more thoroughly. I took some time to compare the Xorg 6.9.0 mga driver with the source of the mga driver provided by Matrox for the Xorg 6.8.2 release. The main problem seemed to me that the names of quite a few symbols have changed. I fixed the mis-matching names in the Matrox mga / Xorg 6.8.2 driver source, recompiled Xorg 6.9.0 and got a mga_drv.so and mga_hal_drv.so which has been working just fine with the current Debian testing 6.9.0 Xorg release for the last 6 weeks. Since Matrox hasn't released an updated driver for Xorg 6.9.0 yet, I decided to post this stuff here. Below is the somewhat lengthy way to get the working modules. Drop me a note if you like a binary (i386) copy of the compiled mga_drv.o/mga_hal_drv.o instead of going through the hassle to recompile yourself.

Best regards,
Dirk

# --------------------
# get matrox driver (includes HAL library) from www.matrox.com
# unpack in ~dirk/downloads
#
cd ~dirk/downloads
tar xvfz mgadriver-x86-4.3.0-src.tar.gz

# get debian xorg 6.9.0 tgz and patch from debian mirror
# unpack in /usr/local source and patch stage 1
#
cd /usr/local/src
tar xvfz ~dirk/xorg-x11_6.9.0.dfsg.1.orig.tar.gz
cd xorg-x11-6.9.0.dfsg.1/
patch -p1 < ../xorg-x11_6.9.0.dfsg.1-4.diff

# patch 6.9.0 mga driver to match 4.3 HALlib
#
cd xc/programs/Xserver/hw/xfree86/drivers/mga/HALlib
SRC=matrox_driver-x86-4.3.0-src/6.8.2/src/mga/HALlib
cp ~dirk/downloads/$SRC/* .
cd ..

# replacement symbols derived by comparing binding.h and client.h versions
#
cat > /tmp/replace <<EOF
ClientReadConfigSpaceByte    ->   MGAClientReadConfigSpaceByte
ClientReadConfigSpaceDword   ->   MGAClientReadConfigSpaceDword
ClientWriteConfigSpaceByte   ->   MGAClientWriteConfigSpaceByte
ClientWriteConfigSpaceDword  ->   MGAClientWriteConfigSpaceDword
ClientOpenRegisterBase       ->   MGAClientOpenRegisterBase
ClientCloseRegisterBase      ->   MGAClientCloseRegisterBase
ClientReadRegisterByte       ->   MGAClientReadRegisterByte
ClientReadRegisterDword      ->   MGAClientReadRegisterDword
ClientWriteRegisterByte      ->   MGAClientWriteRegisterByte
ClientWriteRegisterDword     ->   MGAClientWriteRegisterDword
ClientOpenMemoryBase         ->   MGAClientOpenMemoryBase
ClientCloseMemoryBase        ->   MGAClientCloseMemoryBase
ClientReadMemoryByte         ->   MGAClientReadMemoryByte
ClientReadMemoryDword        ->   MGAClientReadMemoryDword
ClientWriteMemoryByte        ->   MGAClientWriteMemoryByte
ClientWriteMemoryDword       ->   MGAClientWriteMemoryDword
ClientOpenSystemDevice       ->   MGAClientOpenSystemDevice
ClientCloseSystemDevice      ->   MGAClientCloseSystemDevice
ClientReadSystemDeviceByte   ->   MGAClientReadSystemDeviceByte
ClientReadSystemDeviceDword  ->   MGAClientReadSystemDeviceDword
ClientWriteSystemDeviceByte  ->   MGAClientWriteSystemDeviceByte
ClientWriteSystemDeviceDword ->   MGAClientWriteSystemDeviceDword
ClientWait                   ->   MGAClientWait
ClientGetBiosInfo            ->   MGAClientGetBiosInfo
ClientReadDDCEdid            ->   MGAClientReadDDCEdid
ClientDebug                  ->   MGAClientDebug
MGACloseLibrary              ->   MATROXCloseLibrary
MGAValidateMode              ->   MATROXValidateMode
MGAValidateVideoParameters   ->   MATROXValidateVideoParameters
MGASetMode                   ->   MATROXSetMode
MGASetTVMode                 ->   MATROXSetTVMode
MGASetVgaMode                ->   MATROXSetVgaMode
MGASaveVgaState              ->   MATROXSaveVgaState
MGARestoreVgaState           ->   MATROXRestoreVgaState
MGAInitHardware              ->   MATROXInitHardware
MGAGetVideoParameters        ->   MATROXGetVideoParameters
MGAGetHardwareInfo           ->   MATROXGetHardwareInfo
MGAGetClientPointer          ->   MATROXGetClientPointer
MGAOpenLibrary               ->   MATROXOpenLibrary
MGAGetBOARDHANDLESize        ->   MATROXGetBOARDHANDLESize
MGASetTVStandard             ->   MATROXSetTVStandard
MGASetTVCableType            ->   MATROXSetTVCableType
HALSetDisplayStart           ->   MATROXSetDisplayStart
ClientLocateFirstTwisterOfQuad -> MGAClientLocateFirstTwisterOfQuad
ClientSearchDevNode            -> MGAClientSearchDevNode
ClientCallBiosInt10            -> MGAClientCallBiosInt10
ClientCustomCall               -> MGAClientCustomCall
ClientApplyEpromPatch          -> MGAClientApplyEpromPatch
ClientDetectHostInterface      -> MGAClientDetectHostInterface
ClientHSLPatchFunction         -> MGAClientHSLPatchFunction
ClientInitTimeBase             -> MGAClientInitTimeBase
ClientOpenDMABase              -> MGAClientOpenDMABase
ClientReadDMAByte              -> MGAClientReadDMAByte
ClientReadBIOS                 -> MGAClientReadBIOS
ClientWriteBIOS                -> MGAClientWriteBIOS
ClientFunctions                -> GClientFunctions
EOF

# create list of files to be patched and symbols to be replaced
#
FILES=" "
SYMBS=" "
for SYM in `cat /tmp/replace | awk '{print $1}'`; do
 OUT=`grep -l $SYM *`
 [ -z "$OUT" ] && continue
 SYMBS="${SYMBS}${SYM} "
 for F in $OUT; do
   [ `echo "$FILES" | grep -c " $F "` -eq 0 ] && FILES="${FILES}${F} "
 done
done

# patch files
#
for F in $FILES; do
 for SYM in $SYMBS; do
   NSYM=`awk '/^'$SYM' / {print $3}' /tmp/replace`
   sed -e 's/'$SYM'/'$NSYM'/g' $F > abcde; mv abcde $F
 done
done
#

# update config to include matrox HAL library
#
cd /usr/local/src/xorg-x11-6.9.0.dfsg.1/xc/config/cf/
cp xf86site.def host.def
vi host.def
# uncomment "#define HaveMatroxHal   YES" in host.def

# patch and build
#
cd ../../..
make -f debian/rules patch
make -f debian/rules build-server > make.out 2>&1 &

# copy the compliled mga_drv.so and mga_hal_drv.so drivers to X11 driver dir
# done

# get matrox driver (includes HAL library) from www.matrox.com
# unpack in ~dirk/downloads
# 
cd ~dirk/downloads
tar xvfz mgadriver-x86-4.3.0-src.tar.gz

# get debian xorg 6.9.0 tgz and patch from debian mirror
# unpack in /usr/local source and patch stage 1
#
cd /usr/local/src
tar xvfz ~dirk/xorg-x11_6.9.0.dfsg.1.orig.tar.gz 
cd xorg-x11-6.9.0.dfsg.1/
patch -p1 < ../xorg-x11_6.9.0.dfsg.1-4.diff 

#####################################################################
# Option 1: replace 6.9.0 mga driver completely by mga-shipped driver
# disadvantage: DRI doesn't work
#
cd xc/programs/Xserver/hw/xfree86/drivers
rm -rf mga/
cp -r ~dirk/downloads/matrox_driver-x86-4.3.0-src/6.8.2/src/mga .
#
# end Option 1
#####################################################################

#####################################################################
# Option 2: patch 6.9.0 mga driver to match 4.3 HALlib
#
cd xc/programs/Xserver/hw/xfree86/drivers/mga/HALlib
SRC=matrox_driver-x86-4.3.0-src/6.8.2/src/mga/HALlib
cp ~dirk/downloads/$SRC/* .
cd ..

# replacement symbols derived by comparing binding.h and client.h versions
#
cat > /tmp/replace <<EOF
ClientReadConfigSpaceByte    ->   MGAClientReadConfigSpaceByte
ClientReadConfigSpaceDword   ->   MGAClientReadConfigSpaceDword
ClientWriteConfigSpaceByte   ->   MGAClientWriteConfigSpaceByte
ClientWriteConfigSpaceDword  ->   MGAClientWriteConfigSpaceDword
ClientOpenRegisterBase       ->   MGAClientOpenRegisterBase
ClientCloseRegisterBase      ->   MGAClientCloseRegisterBase
ClientReadRegisterByte       ->   MGAClientReadRegisterByte
ClientReadRegisterDword      ->   MGAClientReadRegisterDword
ClientWriteRegisterByte      ->   MGAClientWriteRegisterByte
ClientWriteRegisterDword     ->   MGAClientWriteRegisterDword
ClientOpenMemoryBase         ->   MGAClientOpenMemoryBase
ClientCloseMemoryBase        ->   MGAClientCloseMemoryBase
ClientReadMemoryByte         ->   MGAClientReadMemoryByte
ClientReadMemoryDword        ->   MGAClientReadMemoryDword
ClientWriteMemoryByte        ->   MGAClientWriteMemoryByte
ClientWriteMemoryDword       ->   MGAClientWriteMemoryDword
ClientOpenSystemDevice       ->   MGAClientOpenSystemDevice
ClientCloseSystemDevice      ->   MGAClientCloseSystemDevice
ClientReadSystemDeviceByte   ->   MGAClientReadSystemDeviceByte
ClientReadSystemDeviceDword  ->   MGAClientReadSystemDeviceDword
ClientWriteSystemDeviceByte  ->   MGAClientWriteSystemDeviceByte
ClientWriteSystemDeviceDword ->   MGAClientWriteSystemDeviceDword
ClientWait                   ->   MGAClientWait
ClientGetBiosInfo            ->   MGAClientGetBiosInfo
ClientReadDDCEdid            ->   MGAClientReadDDCEdid
ClientDebug                  ->   MGAClientDebug
MGACloseLibrary              ->   MATROXCloseLibrary
MGAValidateMode              ->   MATROXValidateMode
MGAValidateVideoParameters   ->   MATROXValidateVideoParameters
MGASetMode                   ->   MATROXSetMode
MGASetTVMode                 ->   MATROXSetTVMode
MGASetVgaMode                ->   MATROXSetVgaMode
MGASaveVgaState              ->   MATROXSaveVgaState
MGARestoreVgaState           ->   MATROXRestoreVgaState
MGAInitHardware              ->   MATROXInitHardware
MGAGetVideoParameters        ->   MATROXGetVideoParameters
MGAGetHardwareInfo           ->   MATROXGetHardwareInfo
MGAGetClientPointer          ->   MATROXGetClientPointer
MGAOpenLibrary               ->   MATROXOpenLibrary
MGAGetBOARDHANDLESize        ->   MATROXGetBOARDHANDLESize
MGASetTVStandard             ->   MATROXSetTVStandard
MGASetTVCableType            ->   MATROXSetTVCableType
HALSetDisplayStart           ->   MATROXSetDisplayStart
ClientLocateFirstTwisterOfQuad -> MGAClientLocateFirstTwisterOfQuad
ClientSearchDevNode            -> MGAClientSearchDevNode
ClientCallBiosInt10            -> MGAClientCallBiosInt10
ClientCustomCall               -> MGAClientCustomCall
ClientApplyEpromPatch          -> MGAClientApplyEpromPatch
ClientDetectHostInterface      -> MGAClientDetectHostInterface
ClientHSLPatchFunction         -> MGAClientHSLPatchFunction
ClientInitTimeBase             -> MGAClientInitTimeBase
ClientOpenDMABase              -> MGAClientOpenDMABase
ClientReadDMAByte              -> MGAClientReadDMAByte
ClientReadBIOS                 -> MGAClientReadBIOS
ClientWriteBIOS                -> MGAClientWriteBIOS
ClientFunctions                -> GClientFunctions
EOF

# create list of files to be patched and symbols to be replaced
#
FILES=" "
SYMBS=" "
for SYM in `cat /tmp/replace | awk '{print $1}'`; do
  OUT=`grep -l $SYM *`
  [ -z "$OUT" ] && continue
  SYMBS="${SYMBS}${SYM} "
  for F in $OUT; do
    [ `echo "$FILES" | grep -c " $F "` -eq 0 ] && FILES="${FILES}${F} "
  done
done

# patch files
#
for F in $FILES; do
  for SYM in $SYMBS; do
    NSYM=`awk '/^'$SYM' / {print $3}' /tmp/replace`
    sed -e 's/'$SYM'/'$NSYM'/g' $F > abcde; mv abcde $F
  done
done
#
# end Option 2
#####################################################################

# update config to include matrox HAL library
#
cd /usr/local/src/xorg-x11-6.9.0.dfsg.1/xc/config/cf/
cp xf86site.def host.def
vi host.def
# uncomment "#define HaveMatroxHal   YES" in host.def

# patch and build
#
cd ../../..
make -f debian/rules patch
make -f debian/rules build-server > make.out 2>&1 &

# copy the compliled mga_drv.so and mga_hal_drv.so drivers to X11 driver dir
# done


Reply to: