From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: <3A969972.5FFD0AE@princeton.edu> From: Martin Harriss MIME-Version: 1.0 To: 9fans@cse.psu.edu, 9trouble@plan9.bell-labs.com Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Subject: [9fans] S3 video problem solved, and a patch Date: Fri, 23 Feb 2001 12:10:10 -0500 Topicbox-Message-UUID: 69dc908e-eac9-11e9-9e20-41e7f4b1d025 I took another look last night at the problem that I was having with the S3 video card (was getting "no free address space" message.) The good news is that I fixed the problem. The following description is probably old hat to the Bell Labs folks, but may be of interest to other 9fans. The S3 video driver, along with other drivers of various kinds, calls "pcimatch" to find a data structure kept by the pci code that holds card configuration information. Included in that information is a physical address that the kernel must map in order to access the frame buffer. The pcimatch routine looks up entries based on PCI vendor ID and card ID. Either can be wild-carded in the call to pcimatch. It so happens that I have another S3 card in the system in question - an S3 sound card. (Not supported by Plan 9, but I sometimes run other software on this system.) The call to pcimatch in vgas3.c was finding the information on the S3 sound card, since all it was looking for was the vendor ID. This information was not at all what the video driver wanted, and it barfed. (Note that it's not possible to include a device ID in the call to pcimatch, as there are many device variants of S3 video cards, all supported by the same driver.) The following (admittedly ugly) patch to vgas3.c fixes the problem by forcing vgas3.c to ignore cards that are not display adapters. It probably argues for a more intelligent pcimatch routine with an additional argument for device class, but I don't feel like opening that can of worms right now. Martin Harriss --------------------------------------------------------------------- diff -c vgas3.c vgas3.c.dist *** vgas3.c Fri Feb 23 11:46:40 2001 --- vgas3.c.dist Wed Feb 21 11:21:13 2001 *************** *** 100,118 **** mmiosize = 0; mmiobase = 0; mmioname = nil; ! ! /* ! * S3 makes cards other than display controllers. Make ! * sure we've found a display controller and not ! * one of their sound cards. ! */ ! p = nil; ! while (p = pcimatch(p, PCIS3, 0)){ ! /* device class 3 is display card */ ! if (p -> ccrb == 3) ! break; ! } ! if (p) { for(i=0; imem); i++){ if(p->mem[i].size >= *size && ((p->mem[i].bar & ~0x0F) & (*align-1)) == 0) --- 100,106 ---- mmiosize = 0; mmiobase = 0; mmioname = nil; ! if(p = pcimatch(nil, PCIS3, 0)){ for(i=0; imem); i++){ if(p->mem[i].size >= *size && ((p->mem[i].bar & ~0x0F) & (*align-1)) == 0)