Bug 76411

Summary: [patch] AGP aperture incorrectly probed for SiS 755 AGP
Product: Base System Reporter: Jonathan Fosburgh <jonathan>
Component: kernAssignee: Eric Anholt <anholt>
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: 5.3-STABLE   
Hardware: Any   
OS: Any   

Description Jonathan Fosburgh 2005-01-18 15:00:49 UTC
This is an Athlon 64 system with an ECS 755-A2 mobo, using the SiS 755 chipset.  When trying to load drm, the agp driver incorrectly probes the aperture as 4MB, regardless of what I specify it as in the BIOS.  I have used 32, 128, and 256MB aperture sizes and all fail the same way. In trying to troubleshoot this, one of the things I found was the driver was not correctly ID'ing the hardware. The following patch from Junk-uk Kim corrected that (though not the issue):

Index: pci/agp_amd64.c
===================================================================
RCS file: /home/ncvs/src/sys/pci/agp_amd64.c,v
retrieving revision 1.3
diff -u -r1.3 agp_amd64.c
--- pci/agp_amd64.c	5 Oct 2004 04:40:32 -0000	1.3
+++ pci/agp_amd64.c	11 Jan 2005 21:57:44 -0000
@@ -80,12 +80,12 @@
 	switch (pci_get_devid(dev)) {
 	case 0x74541022:
 		return ("AMD 8151 AGP graphics tunnel");
-	case 0x10221039:
-		return ("SiS 755 host to AGP bridge");
 	case 0x02041106:
 		return ("VIA 8380 host to PCI bridge");
 	case 0x02821106:
 		return ("VIA K8T800Pro host to PCI bridge");
+	case 0x07551039:
+		return ("SiS 755 host to AGP bridge");
 	case 0x31881106:
 		return ("VIA 8385 host to PCI bridge");
 	};
Index: pci/agp_sis.c
===================================================================
RCS file: /home/ncvs/src/sys/pci/agp_sis.c,v
retrieving revision 1.16
diff -u -r1.16 agp_sis.c
--- pci/agp_sis.c	30 Dec 2004 07:18:58 -0000	1.16
+++ pci/agp_sis.c	11 Jan 2005 21:57:44 -0000
@@ -105,8 +105,6 @@
 		return ("SiS 746 host to AGP bridge");
 	case 0x07601039:
 		return ("SiS 760 host to AGP bridge");
-	case 0x10221039:	/* AMD64 */
-		return NULL;
 	};
 
 	return NULL;

Additionally, I found a small program posted to x11@ from Junk-uk Kim that checks what the AGP driver is probing.  The output from that program is:

version: 0.0
bridge id: 0x7551039
agp_mode: 0x1f000217
aper_base: 0xd0000000
aper_size: 4
pg_total: 112640
pg_system: 112640
pg_used: 0
MTRR: d0000000/400000
entry.key : 2
ioctl(AGPIOC_BIND): Invalid argument

dmesg from a verbose boot:
Jan 12 20:56:46 gw kernel: agp0: <SiS 755 host to AGP bridge> mem 0xe8000000-0xebffffff at device 0.0 on pci0
Jan 12 20:56:46 gw kernel: agp0: Reserved 0x4000000 bytes for rid 0x10 type 3 at 0xe8000000
Jan 12 20:56:46 gw kernel: agp0: allocating GATT for aperture of size 4M

And an error from trying to bind:

agp0: binding memory at bad offset 0x400000

The output from pciconf  for the AGP device:

agp0@pci0:0:0:  class=0x060000 card=0x18911019 chip=0x07551039 rev=0x01 hdr=0x00
    vendor   = 'Silicon Integrated Systems (SiS)'
    device   = 'SiSM650? Host-to-PCI Bridge'
    class    = bridge
    subclass = HOST-PCI

How-To-Repeat: On a mobo (possibly this same model?) using the SiS755 chipset, attempt to do anything that causes the AGP driver to attempt to bind to memory, such as using DRI.
Comment 1 Jonathan Fosburgh 2005-01-23 04:32:32 UTC
I have fixed the problem.  I looked into agp_amd64.c and agp_sis.c on -CURRENT 
and found that AGP_AMD_GART appears to have been removed.  I therefore 
modified Junk-uk's patch to agp_sis.c.  Here is a diff from the version in 
RELENG_5:

--- agp_sis.c.orig      Sat Jan 22 21:49:03 2005
+++ agp_sis.c   Sat Jan 22 21:51:05 2005
@@ -109,7 +109,7 @@
        case 0x07601039:
                return ("SiS 760 host to AGP bridge");
 #if defined(__amd64__) || defined(AGP_AMD64_GART)
-       case 0x10221039:        /* AMD64 */
+       case 0x7551039: /* AMD64 */
                return NULL;
 #endif
        };

glxinfo now reports director rendering enabled.	OpenGL apps now perform *much* 
better.
Comment 2 Jonathan Fosburgh 2005-01-24 03:24:09 UTC
I forgot to mention that I left the patch to agp_amd64.c as-is.
Comment 3 Jonathan Fosburgh 2005-02-11 01:47:06 UTC
Can anybody look at this and commit it?
Comment 4 Eric Anholt freebsd_committer freebsd_triage 2005-02-14 07:31:07 UTC
State Changed
From-To: open->patched

Fixed in HEAD, will merge RSN (post-sleep).  Grab the PR for now. 


Comment 5 Eric Anholt freebsd_committer freebsd_triage 2005-02-14 07:31:07 UTC
Responsible Changed
From-To: freebsd-bugs->anholt

Fixed in HEAD, will merge RSN (post-sleep).  Grab the PR for now.
Comment 6 Eric Anholt freebsd_committer freebsd_triage 2005-02-15 01:26:04 UTC
State Changed
From-To: patched->closed

Committed, thanks!