From owner-freebsd-bugs Fri Feb 22 22:30:32 2002 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 BAAA137B404 for ; Fri, 22 Feb 2002 22:30:00 -0800 (PST) Received: (from gnats@localhost) by freefall.freebsd.org (8.11.6/8.11.6) id g1N6U0V05855; Fri, 22 Feb 2002 22:30:00 -0800 (PST) (envelope-from gnats) Received: from mail503.nifty.com (mail503.nifty.com [202.248.37.211]) by hub.freebsd.org (Postfix) with ESMTP id 41D4D37B405 for ; Fri, 22 Feb 2002 22:20:13 -0800 (PST) Received: from localhost by mail503.nifty.com (8.11.6+3.4W/3.7W-01/21/02) with ESMTP id g1N6Hum24207 for ; Sat, 23 Feb 2002 15:17:56 +0900 Message-Id: <20020223.135440.74753592.t.ichinoseki@nifty.com> Date: Sat, 23 Feb 2002 13:54:40 +0900 (JST) From: Toshikazu ICHINOSEKI Reply-To: Toshikazu ICHINOSEKI To: FreeBSD-gnats-submit@freebsd.org X-Send-Pr-Version: 3.113 Subject: kern/35230: Neomagic sound driver probe and play timeout problem 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: 35230 >Category: kern >Synopsis: Neomagic sound driver probe and play timeout problem >Confidential: no >Severity: serious >Priority: medium >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Fri Feb 22 22:30:00 PST 2002 >Closed-Date: >Last-Modified: >Originator: Toshikazu Ichinoseki >Release: FreeBSD 4.5-STABLE i386 >Organization: >Environment: System: FreeBSD capella 4.5-STABLE FreeBSD 4.5-STABLE #0: Sat Feb 23 00:38:24 JST 2002 toshi@capella:/usr/src/sys/compile/CAPELLA i386 Machine: Panasonic Let's note CF-M2EV (Celeron-550MHz, 440BX, 128MB Mem, NeoMagic NM2200 graphics/sound chip (MagicMedia 256AV)) >Description: The NeoMagic 256AV pcm sound device worked well on 4.3-RELEASE. But 4.5-stable does not probe NeoMagic 256AV audio chip since fails to detect mixer at nm_pci_probe(). After forcing to skip checking mixer presence code, neomagic sound driver becomes to probe 256AV chip. But played music is strange and "pcm0: play interrupt timeout, channel dead" message is displayed on console when I try to play music using mpg123 or play (part of sox). This problem is the same with problem report kern/29465. >How-To-Repeat: 4.5-stable fails to probe every time in boot or kldloading snd_neomagic kernel module. After forcing to probe, channel always is timeout when I play sound. >Fix: I referred to NetBSD's neo.c and made patch to fix this problem. Included patch improves followings: 1. Panasonic CF-M2EV needs resetting soud device before checking mixer is present or not. 2. To synchronize neomagic driver with pcm channel layer, the initial value of BUFFER_WMARK register of Play/Record is set with same value of channel block size and update them on every interrupt. 3. Prevent to make noise on suspending while playing. This patch can apply 4.5-stable and 5-current and also apply 4.4-RELEASE and 4.5-RELEASE. --------------- patch is from here --------------------------------- Index: neomagic.c =================================================================== RCS file: /local/cvsroot/src/sys/dev/sound/pci/neomagic.c,v retrieving revision 1.7.2.9 diff -u -r1.7.2.9 neomagic.c --- neomagic.c 1 Aug 2001 03:40:58 -0000 1.7.2.9 +++ neomagic.c 18 Feb 2002 14:05:10 -0000 @@ -47,7 +47,8 @@ /* channel registers */ struct sc_chinfo { - int spd, dir, fmt; + int active, spd, dir, fmt; + u_int32_t blksize, wmark; struct snd_dbuf *buffer; struct pcm_channel *channel; struct sc_info *parent; @@ -203,14 +204,17 @@ nm_waitcd(struct sc_info *sc) { int cnt = 10; + int fail = 1; while (cnt-- > 0) { if (nm_rd(sc, sc->ac97_status, 2) & sc->ac97_busy) DELAY(100); - else + else { + fail = 0; break; + } } - return (nm_rd(sc, sc->ac97_status, 2) & sc->ac97_busy); + return (fail); } static u_int32_t @@ -338,6 +342,9 @@ chnbuf = (dir == PCMDIR_PLAY)? sc->pbuf : sc->rbuf; ch = (dir == PCMDIR_PLAY)? &sc->pch : &sc->rch; + ch->active = 0; + ch->blksize = 0; + ch->wmark = 0; ch->buffer = b; sndbuf_setup(ch->buffer, (u_int8_t *)rman_get_virtual(sc->buf) + chnbuf, NM_BUFFSIZE); if (bootverbose) @@ -376,6 +383,10 @@ static int nmchan_setblocksize(kobj_t obj, void *data, u_int32_t blocksize) { + struct sc_chinfo *ch = data; + + ch->blksize = blocksize; + return blocksize; } @@ -395,26 +406,32 @@ if (ch->dir == PCMDIR_PLAY) { if (go == PCMTRIG_START) { + ch->active = 1; + ch->wmark = ch->blksize; nm_wr(sc, NM_PBUFFER_START, sc->pbuf, 4); nm_wr(sc, NM_PBUFFER_END, sc->pbuf + NM_BUFFSIZE - ssz, 4); nm_wr(sc, NM_PBUFFER_CURRP, sc->pbuf, 4); - nm_wr(sc, NM_PBUFFER_WMARK, sc->pbuf + NM_BUFFSIZE / 2, 4); + nm_wr(sc, NM_PBUFFER_WMARK, sc->pbuf + ch->wmark, 4); nm_wr(sc, NM_PLAYBACK_ENABLE_REG, NM_PLAYBACK_FREERUN | NM_PLAYBACK_ENABLE_FLAG, 1); nm_wr(sc, NM_AUDIO_MUTE_REG, 0, 2); } else { + ch->active = 0; nm_wr(sc, NM_PLAYBACK_ENABLE_REG, 0, 1); nm_wr(sc, NM_AUDIO_MUTE_REG, NM_AUDIO_MUTE_BOTH, 2); } } else { if (go == PCMTRIG_START) { + ch->active = 1; + ch->wmark = ch->blksize; nm_wr(sc, NM_RECORD_ENABLE_REG, NM_RECORD_FREERUN | NM_RECORD_ENABLE_FLAG, 1); nm_wr(sc, NM_RBUFFER_START, sc->rbuf, 4); nm_wr(sc, NM_RBUFFER_END, sc->rbuf + NM_BUFFSIZE, 4); nm_wr(sc, NM_RBUFFER_CURRP, sc->rbuf, 4); - nm_wr(sc, NM_RBUFFER_WMARK, sc->rbuf + NM_BUFFSIZE / 2, 4); + nm_wr(sc, NM_RBUFFER_WMARK, sc->rbuf + ch->wmark, 4); } else { + ch->active = 0; nm_wr(sc, NM_RECORD_ENABLE_REG, 0, 1); } } @@ -465,11 +482,19 @@ if (status & sc->playint) { status &= ~sc->playint; + sc->pch.wmark += sc->pch.blksize; + sc->pch.wmark %= NM_BUFFSIZE; + nm_wr(sc, NM_PBUFFER_WMARK, sc->pbuf + sc->pch.wmark, 4); + nm_ackint(sc, sc->playint); chn_intr(sc->pch.channel); } if (status & sc->recint) { status &= ~sc->recint; + sc->rch.wmark += sc->rch.blksize; + sc->rch.wmark %= NM_BUFFSIZE; + nm_wr(sc, NM_RBUFFER_WMARK, sc->rbuf + sc->rch.wmark, 4); + nm_ackint(sc, sc->recint); chn_intr(sc->rch.channel); } @@ -590,6 +615,12 @@ return ENXIO; } + /* + * My Panasonic CF-M2EV needs resetting device + * before checking mixer is present or not. + * t.ichinoseki@nifty.com. + */ + nm_wr(sc, 0, 0x11, 1); /* reset device */ if ((nm_rd(sc, NM_MIXER_PRESENCE, 2) & NM_PRESENCE_MASK) != NM_PRESENCE_VALUE) { i = 0; /* non-ac97 card, but not listed */ @@ -710,6 +741,25 @@ } static int +nm_pci_suspend(device_t dev) +{ + struct sc_info *sc; + + sc = pcm_getdevinfo(dev); + + /* stop playing */ + if (sc->pch.active) { + nm_wr(sc, NM_PLAYBACK_ENABLE_REG, 0, 1); + nm_wr(sc, NM_AUDIO_MUTE_REG, NM_AUDIO_MUTE_BOTH, 2); + } + /* stop recording */ + if (sc->rch.active) { + nm_wr(sc, NM_RECORD_ENABLE_REG, 0, 1); + } + return 0; +} + +static int nm_pci_resume(device_t dev) { struct sc_info *sc; @@ -726,6 +776,17 @@ device_printf(dev, "unable to reinitialize the mixer\n"); return ENXIO; } + /* restart playing */ + if (sc->pch.active) { + nm_wr(sc, NM_PLAYBACK_ENABLE_REG, NM_PLAYBACK_FREERUN | + NM_PLAYBACK_ENABLE_FLAG, 1); + nm_wr(sc, NM_AUDIO_MUTE_REG, 0, 2); + } + /* restart recording */ + if (sc->rch.active) { + nm_wr(sc, NM_RECORD_ENABLE_REG, NM_RECORD_FREERUN | + NM_RECORD_ENABLE_FLAG, 1); + } return 0; } @@ -734,6 +795,7 @@ DEVMETHOD(device_probe, nm_pci_probe), DEVMETHOD(device_attach, nm_pci_attach), DEVMETHOD(device_detach, nm_pci_detach), + DEVMETHOD(device_suspend, nm_pci_suspend), DEVMETHOD(device_resume, nm_pci_resume), { 0, 0 } }; ------ to here -------------------------------------------------------- Following is the dmesg of verbose boot after pached. Copyright (c) 1992-2002 The FreeBSD Project. Copyright (c) 1979, 1980, 1983, 1986, 1988, 1989, 1991, 1992, 1993, 1994 The Regents of the University of California. All rights reserved. FreeBSD 4.5-STABLE #0: Sat Feb 23 00:38:24 JST 2002 toshi@capella:/usr/src/sys/compile/CAPELLA Calibrating clock(s) ... TSC clock: 545941275 Hz, i8254 clock: 1193186 Hz Timecounter "i8254" frequency 1193186 Hz CPU: Pentium III/Pentium III Xeon/Celeron (545.94-MHz 686-class CPU) Origin = "GenuineIntel" Id = 0x683 Stepping = 3 Features=0x383f9ff real memory = 134152192 (131008K bytes) Physical memory chunk(s): 0x00001000 - 0x0009efff, 647168 bytes (158 pages) 0x0053a000 - 0x07fe5fff, 128630784 bytes (31404 pages) config> q avail memory = 125349888 (122412K bytes) bios32: Found BIOS32 Service Directory header at 0xc00f6cf0 bios32: Entry = 0xfd890 (c00fd890) Rev = 0 Len = 1 pcibios: PCI BIOS entry at 0x13d pnpbios: Found PnP BIOS data at 0xc00f6d20 pnpbios: Entry = f0000:a5f3 Rev = 1.0 Other BIOS signatures found: ACPI: 000f6cb0 Preloaded elf kernel "kernel" at 0xc0513000. Preloaded userconfig_script "/boot/kernel.conf" at 0xc051309c. Preloaded elf module "splash_bmp.ko" at 0xc05130ec. Preloaded elf module "vesa.ko" at 0xc0513190. Preloaded elf module "vn.ko" at 0xc051322c. Preloaded elf module "snd_neomagic.ko" at 0xc05132c8. Preloaded elf module "snd_pcm.ko" at 0xc051336c. Preloaded elf module "agp.ko" at 0xc051340c. Preloaded elf module "smbfs.ko" at 0xc05134a8. Preloaded elf module "libmchain.ko" at 0xc0513548. Preloaded elf module "libiconv.ko" at 0xc05135ec. Preloaded elf module "joy.ko" at 0xc051368c. VESA: information block 56 45 53 41 00 02 20 01 00 01 00 00 00 00 22 00 00 01 26 00 05 02 00 01 00 01 09 01 00 01 1b 01 00 01 00 01 01 01 02 01 03 01 04 01 05 01 07 01 0d 01 0e 01 10 01 11 01 12 01 13 01 14 01 15 01 VESA: 24 mode(s) found VESA: v2.0, 2432k memory, flags:0x0, mode table:0xc04b12a2 (1000022) VESA: MagicMedia 256AV 48K VESA: NeoMagic MagicMedia 256AV 01.0 netsmb_dev: loaded Pentium Pro MTRR support enabled md0: Malloc disk Creating DISK md0 module_register_init: MOD_LOAD (splash_bmp, c04aa7b8, 0) error 2 Math emulator present pci_open(1): mode 1 addr port (0x0cf8) is 0x80010014 pci_open(1a): mode1res=0x80000000 (0x80000000) pci_cfgcheck: device 0 [class=060000] [hdr=00] is there (id=71908086) Using $PIR table, 8 entries at 0xc00fdf40 apm0: on motherboard apm: found APM BIOS v1.2, connected at v1.2 npx0: on motherboard npx0: INT 16 interface pcib0: on motherboard found-> vendor=0x8086, dev=0x7190, revid=0x03 class=06-00-00, hdrtype=0x00, mfdev=0 subordinatebus=0 secondarybus=0 map[10]: type 1, range 32, base dd800000, size 22 found-> vendor=0x8086, dev=0x7191, revid=0x03 class=06-04-00, hdrtype=0x01, mfdev=0 subordinatebus=1 secondarybus=1 found-> vendor=0x10f7, dev=0x8317, revid=0x02 class=07-80-00, hdrtype=0x00, mfdev=0 subordinatebus=0 secondarybus=0 intpin=a, irq=9 map[10]: type 1, range 32, base 00001080, size 7 found-> vendor=0x8086, dev=0x7110, revid=0x02 class=06-01-00, hdrtype=0x00, mfdev=1 subordinatebus=0 secondarybus=0 found-> vendor=0x8086, dev=0x7111, revid=0x01 class=01-01-80, hdrtype=0x00, mfdev=0 subordinatebus=0 secondarybus=0 map[20]: type 1, range 32, base 00001050, size 4 found-> vendor=0x8086, dev=0x7112, revid=0x01 class=0c-03-00, hdrtype=0x00, mfdev=0 subordinatebus=0 secondarybus=0 intpin=d, irq=10 map[20]: type 1, range 32, base 0000fc20, size 5 found-> vendor=0x8086, dev=0x7113, revid=0x03 class=06-80-00, hdrtype=0x00, mfdev=0 subordinatebus=0 secondarybus=0 map[90]: type 1, range 32, base 00001040, size 4 found-> vendor=0x134d, dev=0x7890, revid=0x02 class=07-03-01, hdrtype=0x00, mfdev=0 subordinatebus=0 secondarybus=0 intpin=a, irq=9 map[10]: type 1, range 32, base 00001400, size 6 found-> vendor=0x1180, dev=0x0476, revid=0x80 class=06-07-00, hdrtype=0x02, mfdev=1 subordinatebus=2 secondarybus=2 intpin=a, irq=10 found-> vendor=0x1180, dev=0x0476, revid=0x80 class=06-07-00, hdrtype=0x02, mfdev=1 subordinatebus=3 secondarybus=3 intpin=b, irq=10 found-> vendor=0x8086, dev=0x1229, revid=0x08 class=02-00-00, hdrtype=0x00, mfdev=0 subordinatebus=0 secondarybus=0 intpin=a, irq=9 map[10]: type 1, range 32, base dd100000, size 12 map[14]: type 1, range 32, base 00001440, size 6 map[18]: type 1, range 32, base dd000000, size 20 pci0: on pcib0 agp0: mem 0xdd800000-0xddbfffff at device 0.0 on pci0 agp0: allocating GATT for aperture of size 4M pcib1: at device 1.0 on pci0 found-> vendor=0x10c8, dev=0x0005, revid=0x20 class=03-00-00, hdrtype=0x00, mfdev=1 subordinatebus=0 secondarybus=0 intpin=a, irq=10 map[10]: type 1, range 32, base de000000, size 24 map[14]: type 1, range 32, base dd400000, size 22 map[18]: type 1, range 32, base dd200000, size 20 found-> vendor=0x10c8, dev=0x8005, revid=0x20 class=04-01-00, hdrtype=0x00, mfdev=1 subordinatebus=0 secondarybus=0 intpin=b, irq=10 map[10]: type 1, range 32, base ddc00000, size 22 map[14]: type 1, range 32, base dd300000, size 20 pci1: on pcib1 pci1: (vendor=0x10c8, dev=0x0005) at 0.0 irq 10 pcm0: mem 0xdd300000-0xdd3fffff,0xddc00000-0xddffffff irq 10 at device 0.1 on pci1 pcm0: ac97 codec id 0x83847609 (SigmaTel STAC9721/9723) pcm0: ac97 codec features 18 bit DAC, 18 bit ADC, 5 bit master volume, SigmaTel 3D Enhancement pcm0: ac97 primary codec extended features AMAP pcm0: rec buf 0xc8583800 pcm0: play buf 0xc857f800 pci0: (vendor=0x10f7, dev=0x8317) at 4.0 irq 9 isab0: at device 7.0 on pci0 isa0: on isab0 atapci0: port 0x1050-0x105f at device 7.1 on pci0 ata0: iobase=0x01f0 altiobase=0x03f6 bmaddr=0x1050 ata0: mask=03 status0=50 status1=00 ata0: mask=03 ostat0=50 ostat2=00 ata0-master: ATAPI probe a=00 b=00 ata0-slave: ATAPI probe a=00 b=00 ata0: mask=03 status0=50 status1=00 ata0-master: ATA probe a=01 b=a5 ata0: devices=01 ata0: at 0x1f0 irq 14 on atapci0 ata1: iobase=0x0170 altiobase=0x0376 bmaddr=0x1058 ata1: mask=03 status0=50 status1=01 ata1: mask=03 ostat0=50 ostat2=01 ata1-master: ATAPI probe a=14 b=eb ata1-slave: ATAPI probe a=ff b=ff ata1: mask=03 status0=00 status1=01 ata1-slave: ATA probe a=00 b=ff ata1: devices=04 ata1: at 0x170 irq 15 on atapci0 uhci0: port 0xfc20-0xfc3f irq 10 at device 7.2 on pci0 using shared irq10. usb0: on uhci0 usb0: USB revision 1.0 uhub0: Intel UHCI root hub, class 9/0, rev 1.00/1.00, addr 1 uhub0: 2 ports with 2 removable, self powered chip0: port 0x1040-0x104f at device 7.3 on pci0 pci0: (vendor=0x134d, dev=0x7890) at 9.0 irq 9 pcic0: irq 10 at device 10.0 on pci0 pcic0: PCI Memory allocated: 0x44000000 pcic0: PCI Configuration space: 0x00: 0x04761180 0x02100007 0x06070080 0x00824000 0x10: 0x44000000 0x020000dc 0x40020200 0x00000000 0x20: 0x00000000 0x00000000 0x00000000 0x00000000 0x30: 0x00000000 0x00000000 0x00000000 0x07a0010a 0x40: 0x832e10f7 0x00000001 0x00000000 0x00000000 0x50: 0x00000000 0x00000000 0x00000000 0x00000000 0x60: 0x00000000 0x00000000 0x00000000 0x00000000 0x70: 0x00000000 0x00000000 0x00000000 0x00000000 0x80: 0x00000001 0x00000000 0x04630463 0x00000000 0x90: 0x00000000 0x00000000 0x00000000 0x00000000 0xa0: 0x00020000 0x00000000 0x00000000 0x00000000 0xb0: 0x00000000 0x00000000 0x00000000 0x00000000 0xc0: 0x832e10f7 0x00000000 0x00000000 0x00000000 0xd0: 0x00000000 0x00000000 0x00000000 0xfe190001 0xe0: 0x24c04000 0x00000000 0x00000000 0x00000000 0xf0: 0x00000000 0x00000000 0x00000000 0x00000000 pccard0: on pcic0 pcic1: irq 10 at device 10.1 on pci0 pcic1: PCI Memory allocated: 0x44001000 pcic1: PCI Configuration space: 0x00: 0x04761180 0x02100007 0x06070080 0x00824000 0x10: 0x44001000 0x020000dc 0x40030300 0x00000000 0x20: 0x00000000 0x00000000 0x00000000 0x00000000 0x30: 0x00000000 0x00000000 0x00000000 0x07a0020a 0x40: 0x832e10f7 0x00000001 0x00000000 0x00000000 0x50: 0x00000000 0x00000000 0x00000000 0x00000000 0x60: 0x00000000 0x00000000 0x00000000 0x00000000 0x70: 0x00000000 0x00000000 0x00000000 0x00000000 0x80: 0x00000001 0x00000000 0x04630463 0x00000000 0x90: 0x00000000 0x00000000 0x00000000 0x00000000 0xa0: 0x00020000 0x00000000 0x00000000 0x00000000 0xb0: 0x00000000 0x00000000 0x00000000 0x00000000 0xc0: 0x832e10f7 0x00000000 0x00000000 0x00000000 0xd0: 0x00000000 0x00000000 0x00000000 0xfe190001 0xe0: 0x24c04000 0x00000000 0x00000000 0x00000000 0xf0: 0x00000000 0x00000000 0x00000000 0x00000000 pccard1: on pcic1 fxp0: port 0x1440-0x147f mem 0xdd000000-0xdd0fffff,0xdd100000-0xdd100fff irq 9 at device 11.0 on pci0 fxp0: using memory space register mapping fxp0: Ethernet address 00:80:45:12:50:b3 fxp0: PCI IDs: 8086 1229 10f7 832e 0008 fxp0: Dynamic Standby mode is disabled inphy0: on miibus0 inphy0: 10baseT, 10baseT-FDX, 100baseTX, 100baseTX-FDX, auto bpf: fxp0 attached pcic-: pcic0 exists, using next available unit number pcic-: pcic1 exists, using next available unit number Trying Read_Port at 203 Trying Read_Port at 243 Trying Read_Port at 283 Trying Read_Port at 2c3 Trying Read_Port at 303 Trying Read_Port at 343 Trying Read_Port at 383 Trying Read_Port at 3c3 ex_isa_identify() isa_probe_children: disabling PnP devices isa_probe_children: probing non-PnP devices orm0: