From owner-freebsd-hackers@FreeBSD.ORG Fri Oct 3 16:17:06 2003 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 2373916A4B3 for ; Fri, 3 Oct 2003 16:17:06 -0700 (PDT) Received: from boeing.ieo-research.it (boeing.ieo-research.it [213.92.108.145]) by mx1.FreeBSD.org (Postfix) with ESMTP id 64CCB44005 for ; Fri, 3 Oct 2003 16:17:04 -0700 (PDT) (envelope-from andrea.cocito@ieo-research.it) Received: (qmail 25020 invoked from network); 3 Oct 2003 23:17:02 -0000 Received: from unknown (HELO ieo-research.it) (acocito@[62.211.141.36]) (envelope-sender ) by smtp.ieo-research.it (qmail-ldap-1.03) with SMTP for ; 3 Oct 2003 23:17:02 -0000 Mime-Version: 1.0 (Apple Message framework v578) To: freebsd-hackers@freebsd.org Message-Id: Content-Type: multipart/mixed; boundary=Apple-Mail-5-1016450387 From: Andrea Cocito Date: Sat, 4 Oct 2003 01:16:36 +0200 X-Mailer: Apple Mail (2.578) Subject: agp broken for ali... this is the patch, PLEASE import it :) X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 03 Oct 2003 23:17:06 -0000 --Apple-Mail-5-1016450387 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII; format=flowed Hallo, I sent a temporary patch a while ago, no answer. So sorry for the report but *please* fix this: this makes non-bootable several laptops and industrial systems. On some ALI chipsets the agp bus returns an aperture size of zero, and the kernel panics. The way it is handled for *any* agp bus if the aperture size is zero (or the window can not be allocated) is deadly broken. Attached the patch to fix the broken code and handle it "at the best effort" as the coded was supposed to do, PLEASE someone import it. Sorry for attaching it. Is only 4k and I cannot currently send-pr it. Thanks, A. --Apple-Mail-5-1016450387 Content-Transfer-Encoding: 7bit Content-Type: application/octet-stream; x-unix-mode=0644; name="agp.patch" Content-Disposition: attachment; filename=agp.patch diff -u -r /sys/pci/agp_ali.c /sys_patched/pci/agp_ali.c --- /sys/pci/agp_ali.c Mon Aug 4 09:25:13 2003 +++ /sys_patched/pci/agp_ali.c Tue Aug 5 22:30:17 2003 @@ -101,21 +101,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. */ diff -u -r /sys/pci/agp_amd.c /sys_patched/pci/agp_amd.c --- /sys/pci/agp_amd.c Mon Aug 4 09:33:42 2003 +++ /sys_patched/pci/agp_amd.c Tue Aug 5 22:30:56 2003 @@ -239,19 +239,20 @@ sc->bsh = rman_get_bushandle(sc->regs); sc->initial_aperture = AGP_GET_APERTURE(dev); + gatt = NULL; - for (;;) { - gatt = agp_amd_alloc_gatt(dev); - if (gatt) + while (AGP_GET_APERTURE(dev) != 0) { + gatt = agp_amd_alloc_gatt(dev); + 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. */ diff -u -r /sys/pci/agp_intel.c /sys_patched/pci/agp_intel.c --- /sys/pci/agp_intel.c Mon Aug 4 09:33:28 2003 +++ /sys_patched/pci/agp_intel.c Tue Aug 5 22:36:23 2003 @@ -147,21 +147,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. */ diff -u -r /sys/pci/agp_sis.c /sys_patched/pci/agp_sis.c --- /sys/pci/agp_sis.c Tue Apr 15 06:37:29 2003 +++ /sys_patched/pci/agp_sis.c Tue Aug 5 22:36:54 2003 @@ -103,21 +103,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. */ diff -u -r /sys/pci/agp_via.c /sys_patched/pci/agp_via.c --- /sys/pci/agp_via.c Tue Apr 15 06:37:29 2003 +++ /sys_patched/pci/agp_via.c Tue Aug 5 22:37:15 2003 @@ -109,21 +109,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. */ --Apple-Mail-5-1016450387 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII; format=flowed --Apple-Mail-5-1016450387--