From owner-freebsd-bugs Wed Dec 5 1:20:17 2001 Delivered-To: freebsd-bugs@hub.freebsd.org Received: from freefall.freebsd.org (freefall.FreeBSD.org [216.136.204.21]) by hub.freebsd.org (Postfix) with ESMTP id 59B4A37B419 for ; Wed, 5 Dec 2001 01:20:08 -0800 (PST) Received: (from gnats@localhost) by freefall.freebsd.org (8.11.6/8.11.6) id fB59K8v22307; Wed, 5 Dec 2001 01:20:08 -0800 (PST) (envelope-from gnats) Received: from scrooge.etek.chalmers.se (scrooge.etek.chalmers.se [129.16.32.112]) by hub.freebsd.org (Postfix) with ESMTP id 14BDC37B405 for ; Wed, 5 Dec 2001 01:18:00 -0800 (PST) Received: (from b@localhost) by scrooge.etek.chalmers.se (8.11.3/8.11.3) id fB59Imi42578; Wed, 5 Dec 2001 10:18:48 +0100 (CET) (envelope-from b) Message-Id: <200112050918.fB59Imi42578@scrooge.etek.chalmers.se> Date: Wed, 5 Dec 2001 10:18:48 +0100 (CET) From: b@etek.chalmers.se Reply-To: b@etek.chalmers.se To: FreeBSD-gnats-submit@freebsd.org Cc: b@etek.chalmers.se X-Send-Pr-Version: 3.113 Subject: kern/32530: Fix for midi(4) causing hang at boot with some SB AWE64 cards Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org >Number: 32530 >Category: kern >Synopsis: Fix for midi(4) causing hang at boot with some SB AWE64 cards >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Wed Dec 05 01:20:08 PST 2001 >Closed-Date: >Last-Modified: >Originator: Magnus Backstrom >Release: FreeBSD 5.0-CURRENT i386 >Organization: Chalmers UofT >Environment: FreeBSD knase19.etek.chalmers.se 5.0-CURRENT FreeBSD 5.0-CURRENT #4: Wed Dec 5 09:33:11 CET 2001 root@knase19.etek.chalmers.se:/usr/src/sys/i386/compile/FNATT i386 >Description: I tried configuring a kernel with midi. The machine stopped dead while booting, right after finding the emu8000 wavetable chip on a SB AWE64 PNP card in the machine. It turns out the card has a bug which results in some I/O registers not getting configured by PNP. The driver did not correctly recognize the situation, and got stuck in a loop while interviewing the card. I located and fixed the immediate problem. Please see the patches below, and advise. >How-To-Repeat: Configure midi into a 5.0-CURRENT kernel, and have an AWE64 in your machine that isn't known by sys/isa/pnp.c->pnp_quirks. >Fix: Two patches. One for the driver, one to update a table of PNP IDs a bit: Patch #1, repairs the emu8000 resource allocation so that an incorrectly PNP-configured card gets rejected gracefully instead of causing a hang. ================================================================ --- sys/dev/sound/isa/emu8000.c.ctm Fri Nov 16 16:34:19 2001 +++ sys/dev/sound/isa/emu8000.c Wed Dec 5 09:08:48 2001 @@ -1895,30 +1895,39 @@ static int emu_allocres(sc_p scp, device_t dev) { - int iobase; + int i; - if (scp->io[0] == NULL) { - scp->io_rid[0] = 0; - scp->io[0] = bus_alloc_resource(dev, SYS_RES_IOPORT, &scp->io_rid[0], 0, ~0, 4, RF_ACTIVE); - } - if (scp->io[0] == NULL) - return (1); - iobase = rman_get_start(scp->io[0]); - if (scp->io[1] == NULL) { - scp->io_rid[1] = 1; - scp->io[1] = bus_alloc_resource(dev, SYS_RES_IOPORT, &scp->io_rid[1], iobase + 0x400, iobase + 0x400 + 3, 4, RF_ACTIVE); - } - if (scp->io[2] == NULL) { - scp->io_rid[2] = 2; - scp->io[2] = bus_alloc_resource(dev, SYS_RES_IOPORT, &scp->io_rid[2], iobase + 0x800, iobase + 0x800 + 3, 4, RF_ACTIVE); + /* + * Attempt to allocate the EMU8000's three I/O port ranges. + */ + for (i = 0; i < 3; i++) + { + if (scp->io[i] == NULL) + { + scp->io_rid[i] = i; + scp->io[i] = bus_alloc_resource(dev, SYS_RES_IOPORT, + &(scp->io_rid[i]), + 0, ~0, 4, RF_ACTIVE); + } } - if (scp->io[0] == NULL || scp->io[1] == NULL || scp->io[2] == NULL) { - printf("emu_allocres: failed.\n"); - return (1); + /* + * Fail if any of the I/O ranges failed (I.e. weren't identified and + * configured by PNP, which can happen if the ID of the card isn't + * known by the PNP quirk-handling logic) + */ + if (scp->io[0] == NULL || scp->io[1] == NULL || scp->io[2] == NULL) + { + printf("emu%d: Resource alloc failed, pnp_quirks " + "may need { 0x%08x, 0x%08x }\n", + device_get_unit(dev), + isa_get_vendorid(dev), + isa_get_logicalid(dev)); + + return 1; } - return (0); + return 0; } /* Releases resources. */ ================================================================ Patch #2, adds the Vendor and Logical IDs of the particular kind of AWE64 board that I have to the pnp_quirks table in sys/isa/pnp.c, thus enabling correct probe/attach of the card. ================================================================ --- sys/isa/pnp.c.ctm Fri Nov 16 16:34:35 2001 +++ sys/isa/pnp.c Wed Dec 5 09:31:18 2001 @@ -83,6 +83,8 @@ PNP_QUIRK_EXTRA_IO, 0x400, 0x800 }, { 0xc1008c0e /* SB64(CTL00c1) */, 0x22008c0e, PNP_QUIRK_EXTRA_IO, 0x400, 0x800 }, + { 0xc5008c0e /* SB64(CTL00c5) */, 0x22008c0e, + PNP_QUIRK_EXTRA_IO, 0x400, 0x800 }, { 0xe4008c0e /* SB64(CTL00e4) */, 0x22008c0e, PNP_QUIRK_EXTRA_IO, 0x400, 0x800 }, ================================================================ >Release-Note: >Audit-Trail: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message