From nobody@FreeBSD.org  Tue Jan 18 14:59:58 2005
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id 163EF16A4CE
	for <freebsd-gnats-submit@FreeBSD.org>; Tue, 18 Jan 2005 14:59:58 +0000 (GMT)
Received: from www.freebsd.org (www.freebsd.org [216.136.204.117])
	by mx1.FreeBSD.org (Postfix) with ESMTP id CDEC443D3F
	for <freebsd-gnats-submit@FreeBSD.org>; Tue, 18 Jan 2005 14:59:57 +0000 (GMT)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.13.1/8.13.1) with ESMTP id j0IExvre028356
	for <freebsd-gnats-submit@FreeBSD.org>; Tue, 18 Jan 2005 14:59:57 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.13.1/8.13.1/Submit) id j0IExvuP028355;
	Tue, 18 Jan 2005 14:59:57 GMT
	(envelope-from nobody)
Message-Id: <200501181459.j0IExvuP028355@www.freebsd.org>
Date: Tue, 18 Jan 2005 14:59:57 GMT
From: Jonathan Fosburgh <jonathan@fosburgh.org>
To: freebsd-gnats-submit@FreeBSD.org
Subject: AGP aperture incorrectly probed for SiS 755 AGP
X-Send-Pr-Version: www-2.3

>Number:         76411
>Category:       kern
>Synopsis:       [patch] AGP aperture incorrectly probed for SiS 755 AGP
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    anholt
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Tue Jan 18 15:00:49 GMT 2005
>Closed-Date:    Tue Feb 15 01:26:14 GMT 2005
>Last-Modified:  Tue Feb 15 01:26:14 GMT 2005
>Originator:     Jonathan Fosburgh
>Release:        5.3-STABLE (i386)
>Organization:
>Environment:
FreeBSD gw.fosburgh.org 5.3-STABLE FreeBSD 5.3-STABLE #9: Mon Jan 17 21:14:35 CST 2005     root@gw.fosburgh.org:/usr/obj/usr/src/sys/vmbsd  i386
    
>Description:
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.
>Fix:
      
>Release-Note:
>Audit-Trail:

From: Jonathan Fosburgh <jonathan@fosburgh.org>
To: freebsd-gnats-submit@freebsd.org, jonathan@fosburgh.org
Cc:  
Subject: Re: kern/76411: [patch] AGP aperture incorrectly probed for SiS 755 AGP
Date: Sat, 22 Jan 2005 22:32:32 -0600

 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.

From: Jonathan Fosburgh <jonathan@fosburgh.org>
To: freebsd-gnats-submit@freebsd.org, jonathan@fosburgh.org
Cc:  
Subject: Re: kern/76411: [patch] AGP aperture incorrectly probed for SiS 755 AGP
Date: Sun, 23 Jan 2005 21:24:09 -0600

 I forgot to mention that I left the patch to agp_amd64.c as-is.

From: Jonathan Fosburgh <jonathan@fosburgh.org>
To: freebsd-gnats-submit@freebsd.org
Cc:  
Subject: Re: kern/76411: [patch] AGP aperture incorrectly probed for SiS 755 AGP
Date: Thu, 10 Feb 2005 19:47:06 -0600

 Can anybody look at this and commit it?
State-Changed-From-To: open->patched 
State-Changed-By: anholt 
State-Changed-When: Mon Feb 14 07:31:07 GMT 2005 
State-Changed-Why:  
Fixed in HEAD, will merge RSN (post-sleep).  Grab the PR for now. 


Responsible-Changed-From-To: freebsd-bugs->anholt 
Responsible-Changed-By: anholt 
Responsible-Changed-When: Mon Feb 14 07:31:07 GMT 2005 
Responsible-Changed-Why:  
Fixed in HEAD, will merge RSN (post-sleep).  Grab the PR for now. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=76411 
State-Changed-From-To: patched->closed 
State-Changed-By: anholt 
State-Changed-When: Tue Feb 15 01:26:04 GMT 2005 
State-Changed-Why:  
Committed, thanks! 

http://www.freebsd.org/cgi/query-pr.cgi?pr=76411 
>Unformatted:
