From owner-freebsd-bugs Mon Oct 29 8:30:16 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 0614437B405 for ; Mon, 29 Oct 2001 08:30:01 -0800 (PST) Received: (from gnats@localhost) by freefall.freebsd.org (8.11.4/8.11.4) id f9TGU0Z18538; Mon, 29 Oct 2001 08:30:00 -0800 (PST) (envelope-from gnats) Received: from h132-197-97-45.gte.com (h132-197-179-27.gte.com [132.197.179.27]) by hub.freebsd.org (Postfix) with ESMTP id 4DDD637B401 for ; Mon, 29 Oct 2001 08:29:39 -0800 (PST) Received: (from ak03@localhost) by h132-197-97-45.gte.com (8.11.6/8.11.4) id f9TGTcK00687; Mon, 29 Oct 2001 11:29:38 -0500 (EST) (envelope-from ak03) Message-Id: <200110291629.f9TGTcK00687@h132-197-97-45.gte.com> Date: Mon, 29 Oct 2001 11:29:38 -0500 (EST) From: "Alexander N. Kabaev" Reply-To: "Alexander N. Kabaev" To: FreeBSD-gnats-submit@freebsd.org X-Send-Pr-Version: 3.113 Subject: kern/31597: pcm_addchan incorrectly adds vchans to PCMDIR_REC channels 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: 31597 >Category: kern >Synopsis: pcm_addchan incorrectly adds vchans to PCMDIR_REC channels >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 29 08:30:00 PST 2001 >Closed-Date: >Last-Modified: >Originator: Alexander N. Kabaev >Release: FreeBSD 5.0-CURRENT i386 >Organization: Verizon Data Services >Environment: System: FreeBSD kanpc.gte.com 5.0-CURRENT FreeBSD 5.0-CURRENT #0: Thu Oct 25 10:14:33 EDT 2001 root@kanpc.gte.com:/usr/src/sys/i386/compile/KANPC i386 ES1371-based audio card. >Description: pcm_addchans function in sys/dev/sound/pcm/sound.c incorrectly adds virtual channels to each and every hardware channel, passed to it as a parameter. If the hardware channel has the direction set to PCMDIR_REC, this leads to the scenario, where PCMDIR_PLAY virtual channel sits on top of PCMDIR_REC physical channel. Each attempt to play through such a vistual channel leads to "interrupt" timeout,channel dead" errors. When hw.snd.maxautovchans= is set through /boot/loader.conf, virtual channels subsystem is enabled at the >How-To-Repeat: Set the hw.snd.maxautovchans= in /boot/loader.conf. This way virtual channels will be enabled at the sound card probe time and virtual channel will be created for each hardware channel on the card. Now, if driver calls pcm_addchan(..., PCMDIR_REC) before pcm_addchan(..., PCMDIR_PLAY), the virtual channel sitting on top of the record channel will be choosen at the next playback attempt and playback will fail with the above interrupt timeout message. The problem can not be reproduced if hw.snd.maxautovchans is being set through sysctl, because pcm_setmaxautovchan function is smart enough to ignore record channels and it will only create single vcannel on the first free hardware playback channel. >Fix: The following patch changes pcm_addchan function to only create virtual channels if the parent channel is PCMDIR_PLAY and if no virtual channels have been created already. This fixes pcm playback on my -CURRENT boxes. Index: sound.c =================================================================== RCS file: /usr/ncvs/src/sys/dev/sound/pcm/sound.c,v retrieving revision 1.66 diff -u -r1.66 sound.c --- sound.c 18 Sep 2001 14:50:52 -0000 1.66 +++ sound.c 29 Oct 2001 15:40:53 -0000 @@ -503,7 +503,8 @@ return err; } - if (snd_maxautovchans > 0 && (d->flags & SD_F_AUTOVCHAN)) { + if (snd_maxautovchans > 0 && (d->flags & SD_F_AUTOVCHAN) && + ch->direction == PCMDIR_PLAY && d->vchancount == 0) { ch->flags |= CHN_F_BUSY; err = vchan_create(ch); if (err) { >Release-Note: >Audit-Trail: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message