Subject: kern/35416: agp driver hangs on ALi/ULi M1689 chipset
To: None <kern-bug-people@netbsd.org, gnats-admin@netbsd.org,>
From: None <gary@duzan.org>
List: netbsd-bugs
Date: 01/13/2007 08:40:00
>Number:         35416
>Category:       kern
>Synopsis:       agp driver hangs on ALi/ULi M1689 chipset
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    kern-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sat Jan 13 08:40:00 +0000 2007
>Originator:     Gary Duzan
>Release:        NetBSD 4.99.8
>Organization:
	Not Much
>Environment:
System: NetBSD capo 4.99.8 NetBSD 4.99.8 (CAPO64) #29: Thu Jan 11 21:50:51 EST 2007 gary@capo:/usr/obj/sys/arch/amd64/compile.amd64/CAPO64 amd64
Architecture: x86_64
Machine: amd64
>Description:
	The M1689 is matched as an ali AGP device, but it seems to
	be more closely related to amd AGP. Reading the aperture
	size in the ali AGP driver returns zero, sending the attach
	into an infinite loop.
>How-To-Repeat:
	Configure a kernel with agp and boot it on an M1689 box.
>Fix:
	A quick attempt to get it working by matching against the
	amd AGP driver wasn't successful. The following keeps it
	from hanging, returning an error instead.


===================================================================
RCS file: /usr2/netbsd-cvs/src/sys/dev/pci/agp_ali.c,v
retrieving revision 1.11
diff -b -u -p -r1.11 agp_ali.c
--- agp_ali.c	16 Nov 2006 01:33:08 -0000	1.11
+++ agp_ali.c	9 Jan 2007 02:24:00 -0000
@@ -113,7 +113,8 @@ agp_ali_attach(struct device *parent, st
 		 * Probably contigmalloc failure. Try reducing the
 		 * aperture so that the gatt size reduces.
 		 */
-		if (AGP_SET_APERTURE(sc, AGP_GET_APERTURE(sc) / 2)) {
+		if (AGP_GET_APERTURE(sc) == 0 ||
+		    AGP_SET_APERTURE(sc, AGP_GET_APERTURE(sc) / 2)) {
 			agp_generic_detach(sc);
 			aprint_error(": failed to set aperture\n");
 			return ENOMEM;