From owner-cvs-src@FreeBSD.ORG Wed Jan 28 00:02:17 2004 Return-Path: Delivered-To: cvs-src@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id DD17416A4CE; Wed, 28 Jan 2004 00:02:17 -0800 (PST) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id 45D8343D48; Wed, 28 Jan 2004 00:02:16 -0800 (PST) (envelope-from truckman@FreeBSD.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.12.10/8.12.10) with ESMTP id i0S82G0B069691; Wed, 28 Jan 2004 00:02:16 -0800 (PST) (envelope-from truckman@repoman.freebsd.org) Received: (from truckman@localhost) by repoman.freebsd.org (8.12.10/8.12.10/Submit) id i0S82GxT069687; Wed, 28 Jan 2004 00:02:16 -0800 (PST) (envelope-from truckman) Message-Id: <200401280802.i0S82GxT069687@repoman.freebsd.org> From: Don Lewis Date: Wed, 28 Jan 2004 00:02:15 -0800 (PST) To: src-committers@FreeBSD.org, cvs-src@FreeBSD.org, cvs-all@FreeBSD.org X-FreeBSD-CVS-Branch: HEAD Subject: cvs commit: src/sys/dev/sound/pcm buffer.c buffer.h channel.c channel.h dsp.c sound.c sound.h vchan.c X-BeenThere: cvs-src@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: CVS commit messages for the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 28 Jan 2004 08:02:18 -0000 truckman 2004/01/28 00:02:15 PST FreeBSD src repository Modified files: sys/dev/sound/pcm buffer.c buffer.h channel.c channel.h dsp.c sound.c sound.h vchan.c Log: Change KASSERT() in feed_vchan16() into an explicit test and call to panic() so that the buffer overflow just beyond this point is always caught, even when the code is not compiled with INVARIANTS. Change chn_setblocksize() buffer reallocation code to attempt to avoid the feed_vchan16() buffer overflow by attempting to always keep the bufsoft buffer at least as large as the bufhard buffer. Print a diagnositic message Danger! %s bufsoft size increasing from %d to %d after CHANNEL_SETBLOCKSIZE() if our best attempts fail. If feed_vchan16() were to be called by the interrupt handler while locks are dropped in chn_setblocksize() to increase the size bufsoft to match the size of bufhard, the panic() code in feed_vchan16() will be triggered. If the diagnostic message is printed, it is a warning that a panic is possible if the system were to see events in an "unlucky" order. Change the locking code to avoid the need for MTX_RECURSIVE mutexes. Add the MTX_DUPOK option to the channel mutexes and change the locking sequence to always lock the parent channel before its children to avoid the possibility of deadlock. Actually implement locking assertions for the channel mutexes and fix the problems found by the resulting assertion violations. Clean up the locking code in dsp_ioctl(). Allocate the channel buffers using the malloc() M_WAITOK option instead of M_NOWAIT so that buffer allocation won't fail. Drop locks across the malloc() calls. Add/modify KASSERTS() in attempt to detect problems early. Abuse layering by adding a pointer to the snd_dbuf structure that points back to the pcm_channel that owns it. This allows sndbuf_resize() to do proper locking without having to change the its API, which is used by the hardware drivers. Don't dereference a NULL pointer when setting hw.snd.maxautovchans if a hardware driver is not loaded. Noticed by Ryan Sommers . Tested by: Stefan Ehmann Tested by: matk (Mathew Kanner) Tested by: Gordon Bergling Revision Changes Path 1.22 +40 -17 src/sys/dev/sound/pcm/buffer.c 1.9 +2 -1 src/sys/dev/sound/pcm/buffer.h 1.94 +100 -23 src/sys/dev/sound/pcm/channel.c 1.29 +4 -1 src/sys/dev/sound/pcm/channel.h 1.72 +16 -75 src/sys/dev/sound/pcm/dsp.c 1.89 +57 -19 src/sys/dev/sound/pcm/sound.c 1.55 +1 -0 src/sys/dev/sound/pcm/sound.h 1.16 +25 -4 src/sys/dev/sound/pcm/vchan.c