Date: Fri, 3 Jun 2005 15:35:52 +0200 From: Seb <sebastien.b@swissinfo.org> To: hselasky@c2i.net Cc: freebsd-usb@freebsd.org Subject: Re: usbd_bulk_transfer returns 1 (USBD_IN_PROGRESS) ?! Message-ID: <200506031535.53126.sebastien.b@swissinfo.org> In-Reply-To: <200505281531.14351.hselasky@c2i.net> References: <200505252120.22408.sebastien.b@swissinfo.org> <200505271331.05132.sebastien.b@swissinfo.org> <200505281531.14351.hselasky@c2i.net>
next in thread | previous in thread | raw e-mail | index | archive | help
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200506031535.53126.sebastien.b>