9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
* [9fans] S3 video problem solved, and a patch
@ 2001-02-23 17:10 Martin Harriss
  0 siblings, 0 replies; only message in thread
From: Martin Harriss @ 2001-02-23 17:10 UTC (permalink / raw)
  To: 9fans, 9trouble

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; i<nelem(p->mem); 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; i<nelem(p->mem); i++){
                        if(p->mem[i].size >= *size
                        && ((p->mem[i].bar & ~0x0F) & (*align-1)) == 0)


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2001-02-23 17:10 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-02-23 17:10 [9fans] S3 video problem solved, and a patch Martin Harriss

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).