From owner-freebsd-bugs@FreeBSD.ORG Sun Oct 5 19:40:34 2003 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id A956D16A65B for ; Sun, 5 Oct 2003 19:40:33 -0700 (PDT) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 640DA44003 for ; Sun, 5 Oct 2003 19:40:26 -0700 (PDT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.12.9/8.12.9) with ESMTP id h962eQFY017199 for ; Sun, 5 Oct 2003 19:40:26 -0700 (PDT) (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.12.9/8.12.9/Submit) id h962eQuO017198; Sun, 5 Oct 2003 19:40:26 -0700 (PDT) (envelope-from gnats) Resent-Date: Sun, 5 Oct 2003 19:40:26 -0700 (PDT) Resent-Message-Id: <200310060240.h962eQuO017198@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, The Black Hacker Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 138D016A4B3 for ; Sun, 5 Oct 2003 19:36:52 -0700 (PDT) Received: from bag.ieo-research.it (bag.ieo-research.it [213.92.108.146]) by mx1.FreeBSD.org (Postfix) with ESMTP id 6313743F85 for ; Sun, 5 Oct 2003 19:36:50 -0700 (PDT) (envelope-from blackye@bag.ieo-research.it) Received: from bag.ieo-research.it (localhost [127.0.0.1]) by bag.ieo-research.it (8.12.9/8.12.9) with ESMTP id h962YLTu033669 for ; Mon, 6 Oct 2003 04:34:21 +0200 (CEST) (envelope-from blackye@bag.ieo-research.it) Received: (from blackye@localhost) by bag.ieo-research.it (8.12.9/8.12.9/Submit) id h962YK9Y033668; Mon, 6 Oct 2003 04:34:20 +0200 (CEST) Message-Id: <200310060234.h962YK9Y033668@bag.ieo-research.it> Date: Mon, 6 Oct 2003 04:34:20 +0200 (CEST) From: Andrea Cocito To: FreeBSD-gnats-submit@FreeBSD.org X-Send-Pr-Version: 3.113 Subject: kern/57631: Boot failing for ALi chipsets, patch attached X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: The Black Hacker List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 06 Oct 2003 02:40:34 -0000 >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: