usb4bsd patch review [was Re: ...]

Hans Petter Selasky hselasky at
Thu Aug 21 07:04:17 UTC 2008

On Wednesday 20 August 2008, Alfred Perlstein wrote:
> [[ Reply to Hans at end of this ]]
> [[ Reply to Kris inline ]]


I've CC'ed multimedia. We have the following diff to mixer.c. Can anyone tell 
if it will have any negative consequences:

--- sys/dev/sound/pcm/mixer.c August 2008
+++ August 2008
@@ -589,7 +589,7 @@
            ("%s(): illegal mixer type=%d", __func__, m->type));
-       snd_mtxlock(m->lock);
+       /* mixer uninit can sleep --hps */
@@ -704,14 +704,24 @@
                return EBUSY;
+       /* destroy dev can sleep --hps */
+       snd_mtxunlock(m->lock);
        pdev->si_drv1 = NULL;
+       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 */
@@ -1280,3 +1290,16 @@
        return (EINVAL);

> > >>P.S. There were a number of questions you didn't answer, can I assume
> > >>those will follow later?
> > >
> > >Could you please repeat the questions you did not get an answer to?
> >
> > I've repeated some of them already.  e.g. in this mail you still didn't
> > answer the "is it safe to drop the locks" question which was asked
> > twice.  Rather than me repeating them yet again, I'd suggest you go back
> > and take another close read over my emails and your responses, and reply
> > to the questions that are still not resolved.
> Hans, let's just leave sound the way it is.  I will remove that
> part of the patch.  It might be better to leave a bad locking
> in that generates a warning rather than obscure the locking issue
> by removing the warning without fully understanding the issues.

USB audio is the only sound device I know about that is regularly plugged in 
and out, which is causing this code path to be executed, unless you load 
unload a sound module, which I think is very rarely done.

The lock in question has never before been exposed to the underlying layers, 
so the funtions that are called should not have any knowledge about it and 
consequently not depend on it either.

Alfred: Just make sure that everything builds. We can fix up these issues 
afterwards. If USB sound support is broken it is not that critical.


More information about the freebsd-multimedia mailing list