From owner-freebsd-usb@FreeBSD.ORG Sun Feb 1 19:59:04 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 C71391065670 for ; Sun, 1 Feb 2009 19:59:04 +0000 (UTC) (envelope-from thompsa@FreeBSD.org) Received: from pele.citylink.co.nz (pele.citylink.co.nz [202.8.44.226]) by mx1.freebsd.org (Postfix) with ESMTP id 67D0E8FC18 for ; Sun, 1 Feb 2009 19:59:04 +0000 (UTC) (envelope-from thompsa@FreeBSD.org) Received: from localhost (localhost [127.0.0.1]) by pele.citylink.co.nz (Postfix) with ESMTP id BCCFFFF7A; Mon, 2 Feb 2009 08:59:03 +1300 (NZDT) X-Virus-Scanned: Debian amavisd-new at citylink.co.nz Received: from pele.citylink.co.nz ([127.0.0.1]) by localhost (pele.citylink.co.nz [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id I1cAhhy+pcAp; Mon, 2 Feb 2009 08:59:00 +1300 (NZDT) Received: from citylink.fud.org.nz (unknown [202.8.44.45]) by pele.citylink.co.nz (Postfix) with ESMTP; Mon, 2 Feb 2009 08:59:00 +1300 (NZDT) Received: by citylink.fud.org.nz (Postfix, from userid 1001) id B17CD1142C; Mon, 2 Feb 2009 08:58:59 +1300 (NZDT) Date: Sun, 1 Feb 2009 11:58:59 -0800 From: Andrew Thompson To: Hans Petter Selasky Message-ID: <20090201195859.GH32503@citylink.fud.org.nz> References: <200902011220.18745.hselasky@c2i.net> <200902012001.06914.hselasky@c2i.net> <20090201191432.GD32503@citylink.fud.org.nz> <200902012031.56899.hselasky@c2i.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <200902012031.56899.hselasky@c2i.net> User-Agent: Mutt/1.5.17 (2007-11-01) 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:59:05 -0000 On Sun, Feb 01, 2009 at 08:31:55PM +0100, Hans Petter Selasky wrote: > 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: There are a few options, - coalesce on a single task (on,off,on = on), the off never happened. - drain the task first then resubmit Those cover both scenarios, (1) you dont care about previous state or (2) you do care so ensure the previous state has executed. If for some reason those are not sufficient then the driver is free to implement its own queue. The current implementation in usb is quite clever but its important not to complicate the internals for situations that dont happen in real life. Andrew