Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 6 Oct 2003 04:34:20 +0200 (CEST)
From:      Andrea Cocito <blackye@break.net>
To:        FreeBSD-gnats-submit@FreeBSD.org
Subject:   kern/57631: Boot failing for ALi chipsets, patch attached
Message-ID:  <200310060234.h962YK9Y033668@bag.ieo-research.it>
Resent-Message-ID: <200310060240.h962eQuO017198@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         57631
>Category:       kern
>Synopsis:       Boot failing for ALi chipsets, patch attached
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sun Oct 05 19:40:25 PDT 2003
>Closed-Date:
>Last-Modified:
>Originator:     The Black Hacker
>Release:        FreeBSD 5.1-RELEASE i386
>Organization:
>Environment:
System: FreeBSD bag.ieo-research.it 5.1-RELEASE FreeBSD 5.1-RELEASE #0: Mon Jul 21 16:46:37 CEST 2003 root@bag.ieo-research.it:/usr/src/sys/i386/compile/BAG i386
>Description:
Booting on several chipsets, inluding ALi and others used for laptops
and industrial systems, fails. This is due to the fact that the AGP
bus requests an aperture size of "zero"; which is probably wrong but
the code supposed to handle this in src/pci/agp_*.c is deadly broken.
>How-To-Repeat:
Try to boot any 5.* version on the affected machines
>Fix:
Patch follows.
Index: sys/pci/agp_ali.c
===================================================================
RCS file: /home/ncvs/src/sys/pci/agp_ali.c,v
retrieving revision 1.8
diff -u -r1.8 agp_ali.c
--- sys/pci/agp_ali.c	22 Aug 2003 07:13:20 -0000	1.8
+++ sys/pci/agp_ali.c	5 Oct 2003 18:19:02 -0000
@@ -102,21 +102,20 @@
 		return error;
 
 	sc->initial_aperture = AGP_GET_APERTURE(dev);
+	gatt = NULL;
 
-	for (;;) {
+	while (AGP_GET_APERTURE(dev) != 0) {
 		gatt = agp_alloc_gatt(dev);
-		if (gatt)
+		if (gatt != NULL)
 			break;
-
-		/*
-		 * Probably contigmalloc failure. Try reducing the
-		 * aperture so that the gatt size reduces.
-		 */
-		if (AGP_SET_APERTURE(dev, AGP_GET_APERTURE(dev) / 2)) {
-			agp_generic_detach(dev);
-			return ENOMEM;
-		}
+		AGP_SET_APERTURE(dev, AGP_GET_APERTURE(dev) / 2);
+	}
+		
+	if (gatt == NULL) {
+		agp_generic_detach(dev);
+		return ENOMEM;
 	}
+
 	sc->gatt = gatt;
 
 	/* Install the gatt. */
Index: sys/pci/agp_amd.c
===================================================================
RCS file: /home/ncvs/src/sys/pci/agp_amd.c,v
retrieving revision 1.16
diff -u -r1.16 agp_amd.c
--- sys/pci/agp_amd.c	22 Aug 2003 07:13:20 -0000	1.16
+++ sys/pci/agp_amd.c	5 Oct 2003 18:19:02 -0000
@@ -240,19 +240,20 @@
 	sc->bsh = rman_get_bushandle(sc->regs);
 
 	sc->initial_aperture = AGP_GET_APERTURE(dev);
+	gatt = NULL;
 
-	for (;;) {
+	while (AGP_GET_APERTURE(dev) != 0) {
 		gatt = agp_amd_alloc_gatt(dev);
-		if (gatt)
+		if (gatt != NULL)
 			break;
+		AGP_SET_APERTURE(dev, AGP_GET_APERTURE(dev) / 2);
+	}
 
-		/*
-		 * Probably contigmalloc failure. Try reducing the
-		 * aperture so that the gatt size reduces.
-		 */
-		if (AGP_SET_APERTURE(dev, AGP_GET_APERTURE(dev) / 2))
-			return ENOMEM;
+	if (gatt == NULL) {
+		agp_generic_detach(dev);
+		return ENOMEM;
 	}
+
 	sc->gatt = gatt;
 
 	/* Install the gatt. */
Index: sys/pci/agp_intel.c
===================================================================
RCS file: /home/ncvs/src/sys/pci/agp_intel.c,v
retrieving revision 1.19
diff -u -r1.19 agp_intel.c
--- sys/pci/agp_intel.c	17 Sep 2003 02:58:17 -0000	1.19
+++ sys/pci/agp_intel.c	5 Oct 2003 18:19:02 -0000
@@ -154,21 +154,20 @@
 	    MAX_APSIZE;
 	pci_write_config(dev, AGP_INTEL_APSIZE, value, 1);
 	sc->initial_aperture = AGP_GET_APERTURE(dev);
+	gatt = NULL;
 
-	for (;;) {
+	while (AGP_GET_APERTURE(dev) != 0) {
 		gatt = agp_alloc_gatt(dev);
-		if (gatt)
+		if (gatt != NULL)
 			break;
-
-		/*
-		 * Probably contigmalloc failure. Try reducing the
-		 * aperture so that the gatt size reduces.
-		 */
-		if (AGP_SET_APERTURE(dev, AGP_GET_APERTURE(dev) / 2)) {
-			agp_generic_detach(dev);
-			return ENOMEM;
-		}
+		AGP_SET_APERTURE(dev, AGP_GET_APERTURE(dev) / 2);
+	}
+		
+	if (gatt == NULL) {
+		agp_generic_detach(dev);
+		return ENOMEM;
 	}
+
 	sc->gatt = gatt;
 
 	/* Install the gatt. */
Index: sys/pci/agp_sis.c
===================================================================
RCS file: /home/ncvs/src/sys/pci/agp_sis.c,v
retrieving revision 1.9
diff -u -r1.9 agp_sis.c
--- sys/pci/agp_sis.c	22 Aug 2003 07:13:20 -0000	1.9
+++ sys/pci/agp_sis.c	5 Oct 2003 18:19:02 -0000
@@ -104,21 +104,20 @@
 		return error;
 
 	sc->initial_aperture = AGP_GET_APERTURE(dev);
+	gatt = NULL;
 
-	for (;;) {
+	while (AGP_GET_APERTURE(dev) != 0) {
 		gatt = agp_alloc_gatt(dev);
-		if (gatt)
+		if (gatt != NULL)
 			break;
-
-		/*
-		 * Probably contigmalloc failure. Try reducing the
-		 * aperture so that the gatt size reduces.
-		 */
-		if (AGP_SET_APERTURE(dev, AGP_GET_APERTURE(dev) / 2)) {
-			agp_generic_detach(dev);
-			return ENOMEM;
-		}
+		AGP_SET_APERTURE(dev, AGP_GET_APERTURE(dev) / 2);
+	}
+		
+	if (gatt == NULL) {
+		agp_generic_detach(dev);
+		return ENOMEM;
 	}
+
 	sc->gatt = gatt;
 
 	/* Install the gatt. */
Index: sys/pci/agp_via.c
===================================================================
RCS file: /home/ncvs/src/sys/pci/agp_via.c,v
retrieving revision 1.11
diff -u -r1.11 agp_via.c
--- sys/pci/agp_via.c	22 Aug 2003 07:13:20 -0000	1.11
+++ sys/pci/agp_via.c	5 Oct 2003 18:19:03 -0000
@@ -112,21 +112,20 @@
 		return error;
 
 	sc->initial_aperture = AGP_GET_APERTURE(dev);
+	gatt = NULL;
 
-	for (;;) {
+	while (AGP_GET_APERTURE(dev) != 0) {
 		gatt = agp_alloc_gatt(dev);
-		if (gatt)
+		if (gatt != NULL)
 			break;
-
-		/*
-		 * Probably contigmalloc failure. Try reducing the
-		 * aperture so that the gatt size reduces.
-		 */
-		if (AGP_SET_APERTURE(dev, AGP_GET_APERTURE(dev) / 2)) {
-			agp_generic_detach(dev);
-			return ENOMEM;
-		}
+		AGP_SET_APERTURE(dev, AGP_GET_APERTURE(dev) / 2);
+	}
+		
+	if (gatt == NULL) {
+		agp_generic_detach(dev);
+		return ENOMEM;
 	}
+
 	sc->gatt = gatt;
 
 	/* Install the gatt. */

>Release-Note:
>Audit-Trail:
>Unformatted:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200310060234.h962YK9Y033668>