qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Hans de Goede <hdegoede@redhat.com>
To: Gerd Hoffmann <kraxel@redhat.com>
Cc: Hans de Goede <hdegoede@redhat.com>, qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH 2/8] combined-packet: Add a workaround for Linux usbfs + live migration
Date: Wed, 31 Oct 2012 13:47:10 +0100	[thread overview]
Message-ID: <1351687636-14253-3-git-send-email-hdegoede@redhat.com> (raw)
In-Reply-To: <1351687636-14253-1-git-send-email-hdegoede@redhat.com>

Older versions (anything but the latest) of Linux usbfs + libusb(x),
will submit larger (bulk) transfers split into multiple 16k submissions,
which means that rather then all tds getting linked into the queue in
one atomic operarion they get linked in a bunch at a time, which could
cause problems if:
1) We scan the queue while libusb is in the middle of submitting a split
   bulk transfer
2) While this bulk transfer is pending we migrate to another host.

The problem is that after 2, the new host will rescan the queue and
combine the packets in one large transfer, where as 1) has caused the
original host to see them as 2 transfers. This patch fixes this by stopping
combinging if we detect a 16k transfer with its int_req flag set.

This should not adversely effect performance for other cases as:
1) Linux never sets the interrupt flag on packets other then the last
2) Windows does set the in_req flag on each td, but will submit large
transfers in 20k tds thus never triggering the check

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
 hw/usb/combined-packet.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/hw/usb/combined-packet.c b/hw/usb/combined-packet.c
index 652bf02..3904e71 100644
--- a/hw/usb/combined-packet.c
+++ b/hw/usb/combined-packet.c
@@ -117,7 +117,7 @@ void usb_ep_combine_input_packets(USBEndpoint *ep)
 {
     USBPacket *p, *u, *next, *prev = NULL, *first = NULL;
     USBPort *port = ep->dev->port;
-    int ret;
+    int ret, totalsize;
 
     assert(ep->pipeline);
     assert(ep->pid == USB_TOKEN_IN);
@@ -161,8 +161,11 @@ void usb_ep_combine_input_packets(USBEndpoint *ep)
         }
 
         /* Is this packet the last one of a (combined) transfer? */
+        totalsize = (p->combined) ? p->combined->iov.size : p->iov.size;
         if ((p->iov.size % ep->max_packet_size) != 0 || !p->short_not_ok ||
-                next == NULL) {
+                next == NULL ||
+                /* Work around for Linux usbfs bulk splitting + migration */
+                (totalsize == 16348 && p->int_req)) {
             ret = usb_device_handle_data(ep->dev, first);
             assert(ret == USB_RET_ASYNC);
             if (first->combined) {
-- 
1.7.12.1

  parent reply	other threads:[~2012-10-31 12:45 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-31 12:47 [Qemu-devel] usb input pipelining patches v3 Hans de Goede
2012-10-31 12:47 ` [Qemu-devel] [PATCH 1/8] usb: Add packet combining functions Hans de Goede
2012-11-01 10:08   ` Gerd Hoffmann
2012-11-01 13:14     ` Hans de Goede
2012-11-01 13:28       ` Hans de Goede
2012-11-01 13:59     ` Hans de Goede
2012-11-01 14:23       ` Gerd Hoffmann
2012-11-01 16:17         ` Hans de Goede
2012-11-01 16:42           ` Gerd Hoffmann
2012-11-01 19:07             ` Hans de Goede
2012-10-31 12:47 ` Hans de Goede [this message]
2012-10-31 12:47 ` [Qemu-devel] [PATCH 3/8] usb-redir: Add support for 32 bits bulk packet length Hans de Goede
2012-10-31 12:47 ` [Qemu-devel] [PATCH 4/8] usb-redir: Add support for input pipelining Hans de Goede
2012-11-01 10:10   ` Gerd Hoffmann
2012-11-01 13:16     ` Hans de Goede
2012-10-31 12:47 ` [Qemu-devel] [PATCH 5/8] usb-redir: Add an usbredir_setup_usb_eps() helper function Hans de Goede
2012-10-31 12:47 ` [Qemu-devel] [PATCH 6/8] usb-redir: Use reject rather the disconnect on bad ep info Hans de Goede
2012-10-31 12:47 ` [Qemu-devel] [PATCH 7/8] usb-redir: Allow to attach USB 2.0 devices to 1.1 host controller Hans de Goede
2012-10-31 12:47 ` [Qemu-devel] [PATCH 8/8] usb-redir: Allow redirecting super speed devices to high speed controllers Hans de Goede

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=1351687636-14253-3-git-send-email-hdegoede@redhat.com \
    --to=hdegoede@redhat.com \
    --cc=kraxel@redhat.com \
    --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).