From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KWSrj-0007DV-Od for qemu-devel@nongnu.org; Fri, 22 Aug 2008 05:23:31 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KWSri-0007CT-P7 for qemu-devel@nongnu.org; Fri, 22 Aug 2008 05:23:31 -0400 Received: from [199.232.76.173] (port=57765 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KWSri-0007C1-9c for qemu-devel@nongnu.org; Fri, 22 Aug 2008 05:23:30 -0400 Received: from hall.aurel32.net ([91.121.138.14]:59620) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1KWSrh-00069k-RM for qemu-devel@nongnu.org; Fri, 22 Aug 2008 05:23:30 -0400 Date: Fri, 22 Aug 2008 11:23:27 +0200 From: Aurelien Jarno Subject: Re: [Qemu-devel] [PATCH] uhci: improved TD matching, working ISOC transfers Message-ID: <20080822092327.GA15946@volta.aurel32.net> References: <1219384493-6423-1-git-send-email-maxk@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-15 Content-Disposition: inline In-Reply-To: <1219384493-6423-1-git-send-email-maxk@kernel.org> Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: kvm@vger.kernel.org, Max Krasnyansky On Fri, Aug 22, 2008 at 05:54:53AM +0000, Max Krasnyansky wrote: > While trying to make VX-3000 camera work on XP under KVM I realized that > we do not necessarily have to find original TD address. All we care about > is the token which identifies the transfer rather well (direction, endpoint, > size, etc). > This is especially important for the isochronous transfers because otherwise > they are being canceled left and right and we do not make much progress. > > With this patch all devices that used bulk transfers that I've tried so > far continue to work just as well. And now my USB web cammera (isoc transfers) > is working well tool. It's not as smooth as native Windows but it's pretty > darn smooth. > > The cool thing is that new USB code (both usb-uhci and usb-linux) is totaly > generic and does not need any special logic for ISOC. > > Signed-off-by: Max Krasnyansky Thanks, applied. > --- > hw/usb-uhci.c | 40 ++++++++++++++++++++++++++++------------ > 1 files changed, 28 insertions(+), 12 deletions(-) > > diff --git a/hw/usb-uhci.c b/hw/usb-uhci.c > index 1b15074..0714520 100644 > --- a/hw/usb-uhci.c > +++ b/hw/usb-uhci.c > @@ -265,25 +265,41 @@ static void uhci_async_cancel_all(UHCIState *s) > static UHCIAsync *uhci_async_find_td(UHCIState *s, uint32_t addr, uint32_t token) > { > UHCIAsync *async = s->async_pending; > + UHCIAsync *match = NULL; > + int count = 0; > + > + /* > + * We're looking for the best match here. ie both td addr and token. > + * Otherwise we return last good match. ie just token. > + * It's ok to match just token because it identifies the transaction > + * rather well, token includes: device addr, endpoint, size, etc. > + * > + * Also since we queue async transactions in reverse order by returning > + * last good match we restores the order. > + * > + * It's expected that we wont have a ton of outstanding transactions. > + * If we ever do we'd want to optimize this algorithm. > + */ > > while (async) { > - if (async->td == addr) { > - if (async->token == token) > - return async; > - > - /* > - * TD was reused for a different transfer. > - * Invalidate the original one asap. > - */ > - if (async->valid > 0) { > - async->valid = 0; > - dprintf("husb: bad reuse. td 0x%x\n", async->td); > + if (async->token == token) { > + /* Good match */ > + match = async; > + > + if (async->td == addr) { > + /* Best match */ > + break; > } > } > > async = async->next; > + count++; > } > - return NULL; > + > + if (count > 64) > + fprintf(stderr, "uhci: warning lots of async transactions\n"); > + > + return match; > } > > static void uhci_attach(USBPort *port1, USBDevice *dev); > -- > 1.5.5.1 > > > > -- .''`. Aurelien Jarno | GPG: 1024D/F1BCDB73 : :' : Debian developer | Electrical Engineer `. `' aurel32@debian.org | aurelien@aurel32.net `- people.debian.org/~aurel32 | www.aurel32.net