From owner-freebsd-usb@FreeBSD.ORG Sat Sep 13 20:43:31 2008 Return-Path: Delivered-To: freebsd-usb@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 726C1106566B for ; Sat, 13 Sep 2008 20:43:31 +0000 (UTC) (envelope-from hselasky@c2i.net) Received: from swip.net (mailfe05.swip.net [212.247.154.129]) by mx1.freebsd.org (Postfix) with ESMTP id D05BC8FC1D for ; Sat, 13 Sep 2008 20:43:30 +0000 (UTC) (envelope-from hselasky@c2i.net) X-Cloudmark-Score: 0.000000 [] X-Cloudmark-Analysis: v=1.0 c=1 a=twss2o89-wcA:10 a=UuSVL50luqwA:10 a=ZtwMFzhc6XSROYQlMkMA/A==:17 a=P5cRHfBawXX1qdusQwkA:9 a=2a7NSrnlS5m-QOCSKI0A:7 a=f9b9f4_cv0ms1oi5xjX1iZCzIYoA:4 a=9aOQ2cSd83gA:10 a=LY0hPdMaydYA:10 Received: from [62.113.133.218] (account mc467741@c2i.net [62.113.133.218] verified) by mailfe05.swip.net (CommuniGate Pro SMTP 5.2.6) with ESMTPA id 972976722; Sat, 13 Sep 2008 22:43:22 +0200 From: Hans Petter Selasky To: "Olivier SMEDTS" Date: Sat, 13 Sep 2008 22:45:13 +0200 User-Agent: KMail/1.9.7 References: <367b2c980809121246j16fba781s29c0da806f555ebe@mail.gmail.com> <200809132016.10604.hselasky@c2i.net> <367b2c980809131332l1d07ff8ah7072f912e357782@mail.gmail.com> In-Reply-To: <367b2c980809131332l1d07ff8ah7072f912e357782@mail.gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200809132245.14748.hselasky@c2i.net> Cc: freebsd-usb@freebsd.org Subject: Re: new usb2 stack : -current patch with mpsafe tty layer available ? X-BeenThere: freebsd-usb@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: FreeBSD support for USB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 13 Sep 2008 20:43:31 -0000 On Saturday 13 September 2008, Olivier SMEDTS wrote: > 2008/9/13 Hans Petter Selasky : > > BTW: If you do a SVN update now on my tree, it should be up to date with > > mpsafe TTY so usb2_serial should build fine. > > What are the needed patchs in order to build usb2_sound ? > I use latest HDA patchs from ariff. Hi, You need the following three additional patches: ==== src/sys/dev/sound/pcm/channel.c @@ -570,13 +570,26 @@ void chn_intr(struct pcm_channel *c) { - CHN_LOCK(c); + uint8_t do_unlock; + if (CHN_LOCK_OWNED(c)) { + /* + * Allow sound drivers to call this function with + * "CHN_LOCK()" locked: + */ + do_unlock = 0; + } else { + do_unlock = 1; + CHN_LOCK(c); + } c->interrupts++; if (c->direction == PCMDIR_PLAY) chn_wrintr(c); else chn_rdintr(c); - CHN_UNLOCK(c); + if (do_unlock) { + CHN_UNLOCK(c); + } + return; } u_int32_t ==== src/sys/dev/sound/pcm/channel.h @@ -258,11 +258,13 @@ #endif #ifdef USING_MUTEX +#define CHN_LOCK_OWNED(c) mtx_owned((struct mtx *)((c)->lock)) #define CHN_LOCK(c) mtx_lock((struct mtx *)((c)->lock)) #define CHN_UNLOCK(c) mtx_unlock((struct mtx *)((c)->lock)) #define CHN_TRYLOCK(c) mtx_trylock((struct mtx *)((c)->lock)) #define CHN_LOCKASSERT(c) mtx_assert((struct mtx *)((c)->lock), MA_OWNED) #else +#define CHN_LOCK_OWNED(c) 0 #define CHN_LOCK(c) #define CHN_UNLOCK(c) #define CHN_TRYLOCK(c) ==== //depot/vendor/freebsd/src/sys/dev/sound/pcm/mixer.c#41 (text+ko) - //depot/projects/usb/src/sys/dev/sound/pcm/mixer.c#11 (text+ko) ==== content @@ -589,7 +589,7 @@ KASSERT(m->type == MIXER_TYPE_SECONDARY, ("%s(): illegal mixer type=%d", __func__, m->type)); - snd_mtxlock(m->lock); + /* mixer uninit can sleep --hps */ MIXER_UNINIT(m); @@ -704,14 +704,24 @@ return EBUSY; } + /* destroy dev can sleep --hps */ + + snd_mtxunlock(m->lock); + pdev->si_drv1 = NULL; destroy_dev(pdev); + snd_mtxlock(m->lock); + for (i = 0; i < SOUND_MIXER_NRDEVICES; i++) mixer_set(m, i, 0); mixer_setrecsrc(m, SOUND_MASK_MIC); + snd_mtxunlock(m->lock); + + /* mixer uninit can sleep --hps */ + MIXER_UNINIT(m); snd_mtxfree(m->lock); @@ -1280,3 +1290,16 @@ return (EINVAL); } + +/* + * Allow the sound driver to use the mixer lock to protect its mixer + * data: + */ +struct mtx * +mixer_get_lock(struct snd_mixer *m) +{ + if (m->lock == NULL) { + return (&Giant); + } + return (m->lock); +} ==== src/sys/dev/sound/pcm/mixer.h @@ -56,6 +56,7 @@ u_int32_t mix_getparent(struct snd_mixer *m, u_int32_t dev); u_int32_t mix_getchild(struct snd_mixer *m, u_int32_t dev); void *mix_getdevinfo(struct snd_mixer *m); +struct mtx *mixer_get_lock(struct snd_mixer *m); extern int mixer_count; --HPS