From owner-freebsd-usb@FreeBSD.ORG Fri Jun 3 13:52:06 2005 Return-Path: X-Original-To: freebsd-usb@freebsd.org Delivered-To: freebsd-usb@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 7157516A41C for ; Fri, 3 Jun 2005 13:52:06 +0000 (GMT) (envelope-from sebastien.b@swissinfo.org) Received: from md1.swissinfo.org (md1.swissinfo.org [146.159.4.92]) by mx1.FreeBSD.org (Postfix) with ESMTP id DA89443D4C for ; Fri, 3 Jun 2005 13:52:05 +0000 (GMT) (envelope-from sebastien.b@swissinfo.org) Received: from mail.swissinfo.org ([194.6.181.33]) by md1.swissinfo.org (phad1.swissinfo.org [146.159.6.9]) (MDaemon.PRO.v7.2.1.R) with ESMTP id 44-md50000500135.msg for ; Fri, 03 Jun 2005 15:33:39 +0200 Received: from [192.168.0.87] (82.216.69.248) by mail.swissinfo.org (7.0.020) (authenticated as sebastien.b) id 4153942003DED505; Fri, 3 Jun 2005 15:33:36 +0200 From: Seb To: hselasky@c2i.net Date: Fri, 3 Jun 2005 15:35:52 +0200 User-Agent: KMail/1.8 References: <200505252120.22408.sebastien.b@swissinfo.org> <200505271331.05132.sebastien.b@swissinfo.org> <200505281531.14351.hselasky@c2i.net> In-Reply-To: <200505281531.14351.hselasky@c2i.net> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200506031535.53126.sebastien.b@swissinfo.org> X-Spam-Processed: phad1.swissinfo.org, Fri, 03 Jun 2005 15:33:39 +0200 (not processed: message from valid local sender) X-MDRemoteIP: 194.6.181.33 X-Return-Path: sebastien.b@swissinfo.org X-MDaemon-Deliver-To: freebsd-usb@freebsd.org X-MDAV-Processed: phad1.swissinfo.org, Fri, 03 Jun 2005 15:51:59 +0200 Cc: freebsd-usb@freebsd.org Subject: Re: usbd_bulk_transfer returns 1 (USBD_IN_PROGRESS) ?! X-BeenThere: freebsd-usb@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: FreeBSD support for USB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 03 Jun 2005 13:52:06 -0000 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