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] [5070] uhci: Fixed length handling for SETUP and OUT tokens
Date: Fri, 22 Aug 2008 08:58:08 +0000	[thread overview]
Message-ID: <E1KWSTA-00058T-QS@cvs.savannah.gnu.org> (raw)

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

Log Message:
-----------
uhci: Fixed length handling for SETUP and OUT tokens

Fixes regression reported agains Linux 2.6.18.
Looks like XP and newer Linux kernels are less sensitive
to length returned for control transfers.

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 08:58:00 UTC (rev 5069)
+++ trunk/hw/usb-uhci.c	2008-08-22 08:58:08 UTC (rev 5070)
@@ -635,7 +635,7 @@
 
     dprintf("uhci: packet enter. pid %s addr 0x%02x ep %d len %d\n",
            pid2str(p->pid), p->devaddr, p->devep, p->len);
-    if (p->pid == USB_TOKEN_OUT)
+    if (p->pid == USB_TOKEN_OUT || p->pid == USB_TOKEN_SETUP)
         dump_data(p->data, p->len);
 
     ret = USB_RET_NODEV;
@@ -755,7 +755,7 @@
 static int uhci_handle_td(UHCIState *s, uint32_t addr, UHCI_TD *td, uint32_t *int_mask)
 {
     UHCIAsync *async;
-    int len = 0, max_len, ret = 0;
+    int len = 0, max_len;
     uint8_t pid;
 
     /* Is active ? */
@@ -798,12 +798,13 @@
     case USB_TOKEN_OUT:
     case USB_TOKEN_SETUP:
         cpu_physical_memory_read(td->buffer, async->buffer, max_len);
-        ret = uhci_broadcast_packet(s, &async->packet);
-        len = max_len;
+        len = uhci_broadcast_packet(s, &async->packet);
+        if (len >= 0)
+            len = max_len;
         break;
 
     case USB_TOKEN_IN:
-        ret = uhci_broadcast_packet(s, &async->packet);
+        len = uhci_broadcast_packet(s, &async->packet);
         break;
 
     default:
@@ -814,17 +815,17 @@
         return -1;
     }
  
-    if (ret == USB_RET_ASYNC) {
+    if (len == USB_RET_ASYNC) {
         uhci_async_link(s, async);
         return 2;
     }
 
-    async->packet.len = ret;
+    async->packet.len = len;
 
 done:
-    ret = uhci_complete_td(s, td, async, int_mask);
+    len = uhci_complete_td(s, td, async, int_mask);
     uhci_async_free(s, async);
-    return ret;
+    return len;
 }
 
 static void uhci_async_complete(USBPacket *packet, void *opaque)

                 reply	other threads:[~2008-08-22  8:58 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=E1KWSTA-00058T-QS@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).