usbd_bulk_transfer returns 1 (USBD_IN_PROGRESS) ?!

Seb sebastien.b at swissinfo.org
Fri Jun 3 06:52:06 PDT 2005


On Saturday 28 May 2005 15:31, Hans Petter Selasky wrote:
> On Friday 27 May 2005 13:31, Seb wrote:
> > But I didn't fix it with mutexes, I used semaphores instead.
> > I initialize a semaphore with a value equal to 1 and then, before the USB
> > transfers, I do :
>
> while(entered)
> {
>
> > mtx_unlock(&Giant);
> > sema_wait(&sc->usb_tx_sema);
> > mtx_lock(&Giant);
>
> }
>   entered = 1;
>
> > And after the USB transfers :
> > sema_post(&sc->usb_tx_sema);
>
>   entered = 0;

I'm afraid I don't understand why I should do that.
Moreover, if the functions are never called concurrently, the semaphore value 
will never go down...

> > Is this OK ?
>
> I think it is better you use "sx_xlock", "sx_xunlock" and "sx_init".
> See "man sx".

What would be the difference with mutexes ? Only so that I can sleep while 
holding the lock ?
Is calling sx_xlock() safe while holding Giant ? The manual page does not 
specify this...

> If you do things via callback you can remove "sc->tx_queues[]" and
> associated functions. 

No, these are also part of Conexant's proprietary protocol.

> I think you will get better performance using 
> callbacks. And most importantly, you are no longer blocking the callers of
> those functions that send packets.

With the device's protocol which require chained transfers, it will be a mess.
That's why I use those software interrupt handlers.
Regards,
Sebastien



More information about the freebsd-usb mailing list