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

next in thread | previous in thread | raw e-mail | index | archive | help
Thanks for the patchs. I've got it working, no problem with my usb
mouse and FAT32 formatted usb flash key.

One glitch though : a warning in usb2_serial with latest CURRENT,
which made gcc fail with -Werror :
cc -O2 -pipe -march=native -fno-strict-aliasing -Werror -D_KERNEL
-DKLD_MODULE -std=c99 -nostdinc   -I. -I@ -I@/contrib/altq
-finline-limit=8000 --param inline-unit-growth=100 --param
large-function-growth=1000 -fno-common  -fno-omit-frame-pointer
-mcmodel=kernel -mno-red-zone  -mfpmath=387 -mno-sse -mno-sse2
-mno-sse3 -mno-mmx -mno-3dnow  -msoft-float
-fno-asynchronous-unwind-tables -ffreestanding -fstack-protector
-fstack-protector -Wall -Wredundant-decls -Wnested-externs
-Wstrict-prototypes  -Wmissing-prototypes -Wpointer-arith -Winline
-Wcast-qual  -Wundef -Wno-pointer-sign -fformat-extensions -c
/work/src/sys/modules/usb2/serial/../../../dev/usb2/serial/usb2_serial.c
cc1: warnings being treated as errors
/work/src/sys/modules/usb2/serial/../../../dev/usb2/serial/usb2_serial.c:
In function 'usb2_com_put_data':
/work/src/sys/modules/usb2/serial/../../../dev/usb2/serial/usb2_serial.c:1043:
warning: 'cnt' may be used uninitialized in this function

I had to compile it without -Werror.

Olivier

2008/9/13 Hans Petter Selasky <hselasky@c2i.net>:
> 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
>



-- 
Olivier Smedts _
 ASCII ribbon campaign ( )
e-mail: olivier@gid0.org - against HTML email & vCards X
www: http://www.gid0.org - against proprietary attachments / \

 "Il y a seulement 10 sortes de gens dans le monde :
 ceux qui comprennent le binaire,
 et ceux qui ne le comprennent pas."



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