tech-x11 archive

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

s3 doesn't work on non i386/amd64



Hello,
Xorg stopped working for me after upgrading from NetBSD 8.x to 9.x and 
hasn't worked since, it always segfaults. There is the Xorg log output 
posted on the port-prep mailing list, although it does not really provide 
any specific clues to the root cause. I've recently used GDB on Xorg with 
debug sets and believe the problem was introduced when some changes were 
made to the s3 driver and a few related files. The backtrace output is 
also on the port-prep mailing list.

The flow is:
vgaHWSetStdFuncs(hwp) ->
ci_legacy_open_io(hwp->dev, 0, 64 * 1024) ->
!pci_sys->methods->open_legacy_io(ret, dev, base, size) -> resolves to:
pci_device_netbsd_open_legacy_io(...)

The actual code snippets are as follows:

http://cvsweb.netbsd.org/bsdweb.cgi/xsrc/external/mit/xf86-video-s3/dist/
src/s3_driver.c?annotate=1.6
-------------------------------------------------------------------------
                    303: static Bool S3PreInit(ScrnInfoPtr pScrn, int 
flags)
                    304: {
                    305:        EntityInfoPtr pEnt;
                    306:        S3Ptr pS3;
                    307:        vgaHWPtr hwp;
                    308:        ClockRangePtr clockRanges;
1.3       mrg       309:        vbeInfoPtr pVBE;
1.1       mrg       310:        rgb zeros = {0, 0, 0};
                    311:        Gamma gzeros = {0.0, 0.0, 0.0};
                    312:        int i, vgaCRIndex, vgaCRReg;
                    313:        unsigned char tmp;
1.5       mrg       314:        const char *s;
1.1       mrg       315:
                    316:         if (flags & PROBE_DETECT)
                    317:                 return FALSE;
                    318:
                    319:         if (!xf86LoadSubModule(pScrn, "vgahw"))
                    320:                 return FALSE;
                    321:
                    322:         if (!vgaHWGetHWRec(pScrn))
                    323:                 return FALSE;
                    324:
                    325:         hwp = VGAHWPTR(pScrn);
1.3       mrg       326:        vgaHWSetStdFuncs(hwp);
1.1       mrg       327:         vgaHWGetIOBase(hwp);
-------------------------------------------------------------------------

http://cvsweb.netbsd.org/bsdweb.cgi/xsrc/external/mit/xorg-server/dist/hw/
xfree86/vgahw/vgaHW.c?annotate=1.2
-------------------------------------------------------------------------
                    329: void
                    330: vgaHWSetStdFuncs(vgaHWPtr hwp)
                    331: {
1.2     ! tsutsui   332:     hwp->writeCrtc = stdWriteCrtc;
        !           333:     hwp->readCrtc = stdReadCrtc;
        !           334:     hwp->writeGr = stdWriteGr;
        !           335:     hwp->readGr = stdReadGr;
        !           336:     hwp->readST00 = stdReadST00;
        !           337:     hwp->readST01 = stdReadST01;
        !           338:     hwp->readFCR = stdReadFCR;
        !           339:     hwp->writeFCR = stdWriteFCR;
        !           340:     hwp->writeAttr = stdWriteAttr;
        !           341:     hwp->readAttr = stdReadAttr;
        !           342:     hwp->writeSeq = stdWriteSeq;
        !           343:     hwp->readSeq = stdReadSeq;
        !           344:     hwp->writeMiscOut = stdWriteMiscOut;
        !           345:     hwp->readMiscOut = stdReadMiscOut;
        !           346:     hwp->enablePalette = stdEnablePalette;
        !           347:     hwp->disablePalette = stdDisablePalette;
        !           348:     hwp->writeDacMask = stdWriteDacMask;
        !           349:     hwp->readDacMask = stdReadDacMask;
        !           350:     hwp->writeDacWriteAddr = 
stdWriteDacWriteAddr;
        !           351:     hwp->writeDacReadAddr = stdWriteDacReadAddr;
        !           352:     hwp->writeDacData = stdWriteDacData;
        !           353:     hwp->readDacData = stdReadDacData;
        !           354:     hwp->readEnable = stdReadEnable;
        !           355:     hwp->writeEnable = stdWriteEnable;
        !           356:
        !           357:     hwp->io = pci_legacy_open_io(hwp->dev, 0, 64 
* 1024);
1.1       mrg       358: }
-------------------------------------------------------------------------

http://cvsweb.netbsd.org/bsdweb.cgi/xsrc/external/mit/libpciaccess/dist/
src/common_io.c?annotate=1.1.1.4
-------------------------------------------------------------------------
                    108: struct pci_io_handle *
                    109: pci_legacy_open_io(struct pci_device *dev, 
pciaddr_t base, pciaddr_t size)
                    110: {
                    111:     struct pci_io_handle *ret;
                    112:
                    113:     if (!pci_sys->methods->open_legacy_io)
                    114:        return NULL;
                    115:
                    116:     ret = new_io_handle();
                    117:     if (!ret)
                    118:        return NULL;
                    119:
                    120:     if (!pci_sys->methods->open_legacy_io(ret, 
dev, base, size)) {
                    121:        delete_io_handle(ret);
                    122:        return NULL;
                    123:     }
                    124:
                    125:     return ret;
                    126: }
-------------------------------------------------------------------------

http://cvsweb.netbsd.org/bsdweb.cgi/xsrc/external/mit/libpciaccess/dist/
src/netbsd_pci.c?annotate=1.13
-------------------------------------------------------------------------
        !           723: static struct pci_io_handle *
        !           724: pci_device_netbsd_open_legacy_io(struct 
pci_io_handle *ret,
        !           725:     struct pci_device *dev, pciaddr_t base, 
pciaddr_t size)
        !           726: {
        !           727: #if defined(__i386__)
        !           728:        struct i386_iopl_args ia;
        !           729:
        !           730:        ia.iopl = 1;
        !           731:        if (sysarch(I386_IOPL, &ia))
        !           732:                return NULL;
        !           733:
        !           734:        ret->base = base;
        !           735:        ret->size = size;
        !           736:        return ret;
        !           737: #elif defined(__amd64__)
        !           738:        struct x86_64_iopl_args ia;
        !           739:
        !           740:        ia.iopl = 1;
        !           741:        if (sysarch(X86_64_IOPL, &ia))
        !           742:                return NULL;
        !           743:
        !           744:        ret->base = base;
        !           745:        ret->size = size;
        !           746:        return ret;
        !           747: #else
        !           748:        return NULL;
        !           749: #endif
        !           750: }
=========================================================================

This always returns a NULL handle because the system I'm using is not i386 
or amd64. This causes this to segfault:
vgaHWGetIOBase(hwp) ->
hwp->readMiscOut(hwp) -> resolves to:
stdReadMiscOut(vgaHWPtr hwp) -> which calls:
pci_io_read8(hwp->io, VGA_MISC_OUT_R) ->
segfault, as hwp->io is 0x0


http://cvsweb.netbsd.org/bsdweb.cgi/xsrc/external/mit/xorg-server/dist/hw/
xfree86/vgahw/vgaHW.c?annotate=1.2
-------------------------------------------------------------------------
                   1787: void
                   1788: vgaHWGetIOBase(vgaHWPtr hwp)
                   1789: {
                   1790:     hwp->IOBase = (hwp->readMiscOut(hwp) & 
0x01) ?
1.2     ! tsutsui  1791:         VGA_IOBASE_COLOR : VGA_IOBASE_MONO;
1.1       mrg      1792:     xf86DrvMsgVerb(hwp->pScrn->scrnIndex, 
X_INFO, 3,
1.2     ! tsutsui  1793:                    "vgaHWGetIOBase: hwp->IOBase 
is 0x%04x\n", hwp->IOBase);
1.1       mrg      1794: }

-------------------------------------------------------------------------
                    259: static CARD8
                    260: stdReadMiscOut(vgaHWPtr hwp)
                    261: {
1.2     ! tsutsui   262:     return pci_io_read8(hwp->io, VGA_MISC_OUT_R);
1.1       mrg       263: }
=========================================================================

It would seem that pci_device_netbsd_open_legacy_io(...) would need to be 
modified to allow for non x86 systems to use the s3 driver.



Home | Main Index | Thread Index | Old Index