qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Aurelien Jarno <aurelien@aurel32.net>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] [5072] uhci: improved TD matching, working ISOC transfers
Date: Fri, 22 Aug 2008 09:23:07 +0000	[thread overview]
Message-ID: <E1KWSrL-0006io-RN@cvs.savannah.gnu.org> (raw)

Revision: 5072
          http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=5072
Author:   aurel32
Date:     2008-08-22 09:23:06 +0000 (Fri, 22 Aug 2008)

Log Message:
-----------
uhci: improved TD matching, working ISOC transfers

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 <maxk@kernel.org>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>

Modified Paths:
--------------
    trunk/hw/usb-uhci.c

Modified: trunk/hw/usb-uhci.c
===================================================================
--- trunk/hw/usb-uhci.c	2008-08-22 09:03:17 UTC (rev 5071)
+++ trunk/hw/usb-uhci.c	2008-08-22 09:23:06 UTC (rev 5072)
@@ -265,25 +265,41 @@
 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;
+        if (async->token == token) {
+            /* Good match */
+            match = 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->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);

                 reply	other threads:[~2008-08-22  9:23 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=E1KWSrL-0006io-RN@cvs.savannah.gnu.org \
    --to=aurelien@aurel32.net \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).