From owner-freebsd-bugs@FreeBSD.ORG Mon Oct 31 05:00:27 2011 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 7A8B91065670 for ; Mon, 31 Oct 2011 05:00:27 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id 57C2D8FC14 for ; Mon, 31 Oct 2011 05:00:27 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.4/8.14.4) with ESMTP id p9V50RkV077156 for ; Mon, 31 Oct 2011 05:00:27 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.4/8.14.4/Submit) id p9V50R6O077149; Mon, 31 Oct 2011 05:00:27 GMT (envelope-from gnats) Resent-Date: Mon, 31 Oct 2011 05:00:27 GMT Resent-Message-Id: <201110310500.p9V50R6O077149@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, Geoff Bailey Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 7B9F1106566B for ; Mon, 31 Oct 2011 04:57:38 +0000 (UTC) (envelope-from nobody@FreeBSD.org) Received: from red.freebsd.org (red.freebsd.org [IPv6:2001:4f8:fff6::22]) by mx1.freebsd.org (Postfix) with ESMTP id 6178C8FC13 for ; Mon, 31 Oct 2011 04:57:38 +0000 (UTC) Received: from red.freebsd.org (localhost [127.0.0.1]) by red.freebsd.org (8.14.4/8.14.4) with ESMTP id p9V4vbnk004391 for ; Mon, 31 Oct 2011 04:57:37 GMT (envelope-from nobody@red.freebsd.org) Received: (from nobody@localhost) by red.freebsd.org (8.14.4/8.14.4/Submit) id p9V4vbPR004366; Mon, 31 Oct 2011 04:57:37 GMT (envelope-from nobody) Message-Id: <201110310457.p9V4vbPR004366@red.freebsd.org> Date: Mon, 31 Oct 2011 04:57:37 GMT From: Geoff Bailey To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-3.1 Cc: Subject: kern/162181: [patch] The kernel sound driver module snd_emu10k1.ko hangs when loaded. X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 31 Oct 2011 05:00:27 -0000 >Number: 162181 >Category: kern >Synopsis: [patch] The kernel sound driver module snd_emu10k1.ko hangs when loaded. >Confidential: no >Severity: serious >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Mon Oct 31 05:00:26 UTC 2011 >Closed-Date: >Last-Modified: >Originator: Geoff Bailey >Release: FreeBSD 9.0-RC1 i386 >Organization: >Environment: System: FreeBSD leon 9.0-RC1 FreeBSD 9.0-RC1 #0: Tue Oct 18 18:30:38 UTC 2011 root@obrian.cse.buffalo.edu:/usr/obj/usr/src/sys/GENERIC i386 Sound Card: pcm0: port 0xdf80-0xdf9f irq 9 at device 12.0 on pci2 pciconf -lbv: pcm0@pci0:2:12:0: class=0x040100 card=0x80271102 chip=0x00021102 rev=0x08 hdr=0x00 vendor = 'Creative Labs' device = 'SB Live! EMU10k1' class = multimedia subclass = audio bar [10] = type I/O Port, range 32, base 0xdf80, size 32, enabled >Description: When you load the emu10k1 sound driver (kldload snd_emu10k1) it prints the sndstat message " port 0xdf80-0xdf9f irq 9 at device 12.0 on pci2" then the system hangs and must be powered down to continue. The hang usually happens in the middle of the emu_init() function while initializing the envelope engine, yet the problem appears not to be related to this section of code. The emu10kx driver works on my box but midi has been disabled in this driver. >How-To-Repeat: kldload snd_emu10k1 >Fix: 1. In the "emu_pci_attach()" function, move the "snd_setup_intr()" call before the call to "emu_init()". 2. Disable hardware midi interrupts in function "emu_midiattach()", since the midi2 driver uses software interrupts. With Fix-1 above only, the driver continuously sends "dodgy irq" messages from the "emu_intr()" function and the system hangs again. With these two changes (see attached patch), both audio and midi work as expected. Patch attached with submission follows: --- /usr/src/sys/dev/sound/pci/emu10k1.c Sun 30 Oct 2011 13:42:48 PDT +++ /usr/src/sys/dev/sound/pci/emu10k1.c Sun 30 Oct 2011 13:42:48 PDT @@ -1120,12 +1120,14 @@ static void emu_midiattach(struct sc_info *sc) { + /* midi2 uses a software interupt int i; i = emu_rd(sc, INTE, 4); i |= INTE_MIDIRXENABLE; emu_wr(sc, INTE, i, 4); - + */ + sc->mpu = mpu401_init(&emu_mpu_class, sc, emu_intr2, &sc->mpu_intr); } /* -------------------------------------------------------------------- */ @@ -2026,7 +2028,16 @@ device_printf(dev, "unable to create dma tag\n"); goto bad; } - + + i = 0; + sc->irq = bus_alloc_resource_any(dev, SYS_RES_IRQ, &i, + RF_ACTIVE | RF_SHAREABLE); + if (!sc->irq || + snd_setup_intr(dev, sc->irq, INTR_MPSAFE, emu_intr, sc, &sc->ih)) { + device_printf(dev, "unable to map interrupt\n"); + goto bad; + } + if (emu_init(sc) == -1) { device_printf(dev, "unable to initialize the card\n"); goto bad; @@ -2039,15 +2050,6 @@ emu_midiattach(sc); - i = 0; - sc->irq = bus_alloc_resource_any(dev, SYS_RES_IRQ, &i, - RF_ACTIVE | RF_SHAREABLE); - if (!sc->irq || - snd_setup_intr(dev, sc->irq, INTR_MPSAFE, emu_intr, sc, &sc->ih)) { - device_printf(dev, "unable to map interrupt\n"); - goto bad; - } - snprintf(status, SND_STATUSLEN, "at io 0x%lx irq %ld %s", rman_get_start(sc->reg), rman_get_start(sc->irq), PCM_KLDSTRING(snd_emu10k1)); >Release-Note: >Audit-Trail: >Unformatted: