From owner-freebsd-usb@FreeBSD.ORG Sun Feb 1 19:29:33 2009 Return-Path: Delivered-To: freebsd-usb@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 5B924106566C; Sun, 1 Feb 2009 19:29:33 +0000 (UTC) (envelope-from hselasky@c2i.net) Received: from swip.net (mailfe12.swipnet.se [212.247.155.97]) by mx1.freebsd.org (Postfix) with ESMTP id BBE3A8FC13; Sun, 1 Feb 2009 19:29:32 +0000 (UTC) (envelope-from hselasky@c2i.net) X-Cloudmark-Score: 0.000000 [] X-Cloudmark-Analysis: v=1.0 c=1 a=BejvGItzEIjqI3BsrNYA:9 a=Tttp81IOuuAXfQCtO2cA:7 a=9FKHxbkb01OtJpkWhrOyn3OtrCcA:4 a=LY0hPdMaydYA:10 Received: from [85.19.218.115] (account mc467741@c2i.net HELO [10.37.1.92]) by mailfe12.swip.net (CommuniGate Pro SMTP 5.2.6) with ESMTPA id 1016895934; Sun, 01 Feb 2009 20:29:31 +0100 From: Hans Petter Selasky To: Andrew Thompson Date: Sun, 1 Feb 2009 20:31:55 +0100 User-Agent: KMail/1.9.7 References: <200902011220.18745.hselasky@c2i.net> <200902012001.06914.hselasky@c2i.net> <20090201191432.GD32503@citylink.fud.org.nz> In-Reply-To: <20090201191432.GD32503@citylink.fud.org.nz> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200902012031.56899.hselasky@c2i.net> Cc: freebsd-usb@freebsd.org Subject: Re: USB2 patches 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: Sun, 01 Feb 2009 19:29:33 -0000 On Sunday 01 February 2009, Andrew Thompson wrote: > On Sun, Feb 01, 2009 at 08:01:05PM +0100, Hans Petter Selasky wrote: > > Hi Andrew, > > > > Regarding using taskqueues. > > > > Yes - USB2 can use taskqueues, but I would very much like to have the > > original queueing mechanism intact. > > Can you explain this further? What is t0 vs t1? > > A taskqueue will execute tasks sequentially, Hi Andrew, I've looked in the taskqueue code: if (task->ta_pending) { task->ta_pending++; TQ_UNLOCK(queue); return 0; } Take the following for example. Now you changed it a little bit, but I see similar issues where other commands are involved: 1) queue DTR on cmd 2) queue DTR off cmd 3) queue DTR on cmd Using the taskqueue there is no guarantee that the last command queued is the last command executed! That is dangerous! Because the existing taskqueue enqueue will only increment the pending count and return, if the command/task is already queued. In the example above you can end up like this: DTR on (pending = 2) DTR off (pending = 1) This is not correct. The queuing mechanism in USB2 guarantees that the last queued command is last executed: DTR on (first callback) DTR off (first callback) DTR on (second callback) Queuing: 1) queue DTR on cmd 2) queue DTR off cmd 3) queue DTR on cmd ... N) queue DTR XXX cmd Results in: 1) DTR on (first callback) 2) DTR off (first callback ... M) DTR XXX (second callback) If the user application is faster than USB "M" count is not the same like "N" count, of course. --HPS