Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 13 Sep 2008 22:45:13 +0200
From:      Hans Petter Selasky <hselasky@c2i.net>
To:        "Olivier SMEDTS" <olivier@gid0.org>
Cc:        freebsd-usb@freebsd.org
Subject:   Re: new usb2 stack : -current patch with mpsafe tty layer available ?
Message-ID:  <200809132245.14748.hselasky@c2i.net>
In-Reply-To: <367b2c980809131332l1d07ff8ah7072f912e357782@mail.gmail.com>
References:  <367b2c980809121246j16fba781s29c0da806f555ebe@mail.gmail.com> <200809132016.10604.hselasky@c2i.net> <367b2c980809131332l1d07ff8ah7072f912e357782@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Saturday 13 September 2008, Olivier SMEDTS wrote:
> 2008/9/13 Hans Petter Selasky <hselasky@c2i.net>:
> > 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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200809132245.14748.hselasky>