Skip to contentSkip to conversation

usb patch queue

GIT PULL New Gerd Hoffmann 2 participants 5 messages Oct 11, 2012 – Oct 12, 2012

lore
Share & tools
lore
#2 lore raw

PATCH 2/3 usb-redir: Don't make migration fail in none seamless case

In reply to Gerd Hoffmann

From: Hans de Goede <[email protected]>

Instead simple disconnect the device like host redirection does on migration.

---
 hw/usb/redirect.c |   13 +++++++++----
 1 files changed, 9 insertions(+), 4 deletions(-)
hw/usb/redirect.c +9 -4
index 5e0f98d..2283565 100644
@@ -1614,12 +1614,17 @@ static int usbredir_get_parser(QEMUFile *f, void *priv, size_t unused)
     }
 
     /*
-     * Our chardev should be open already at this point, otherwise
-     * the usbredir channel will be broken (ie spice without seamless)
+     * If our chardev is not open already at this point the usbredir connection
+     * has been broken (non seamless migration, or restore from disk).
+     *
+     * In this case create a temporary parser to receive the migration data,
+     * and schedule the close_bh to report the device as disconnected to the
+     * guest and to destroy the parser again.
      */
     if (dev->parser == NULL) {
-        ERROR("get_parser called with closed chardev, failing migration\n");
-        return -1;
+        WARNING("usb-redir connection broken during migration\n");
+        usbredir_create_parser(dev);
+        qemu_bh_schedule(dev->chardev_close_bh);
     }
 
     data = g_malloc(len);
Signature · 1 line
1.7.1
#0 lore raw

Hi,

Pretty small this time with just a few bugfixes.

please pull,
Gerd

The following changes since commit b4ae3cfa57b8c1bdbbd7b7d420971e9171203ade:

ssi: Add slave autoconnect helper (2012-10-10 11:13:32 +1000)

are available in the git repository at:
git://git.kraxel.org/qemu usb.67

Hans de Goede (3):
usb-redir: Change usbredir_open_chardev into usbredir_create_parser
usb-redir: Don't make migration fail in none seamless case
uhci: Raise interrupt when requested even for non active tds

 hw/usb/hcd-uhci.c |   10 +++++++++-
 hw/usb/redirect.c |   24 ++++++++++++++----------
 2 files changed, 23 insertions(+), 11 deletions(-)
#1 lore raw

PATCH 1/3 usb-redir: Change usbredir_open_chardev into usbredir_create_parser

From: Hans de Goede <[email protected]>

As we need to create the parser at more places.

---
 hw/usb/redirect.c |   11 +++++------
 1 files changed, 5 insertions(+), 6 deletions(-)
hw/usb/redirect.c +5 -6
index b10241a..5e0f98d 100644
@@ -862,15 +862,11 @@ static void usbredir_chardev_close_bh(void *opaque)
     }
 }
 
-static void usbredir_chardev_open(USBRedirDevice *dev)
+static void usbredir_create_parser(USBRedirDevice *dev)
 {
     uint32_t caps[USB_REDIR_CAPS_SIZE] = { 0, };
     int flags = 0;
 
-    /* Make sure any pending closes are handled (no-op if none pending) */
-    usbredir_chardev_close_bh(dev);
-    qemu_bh_cancel(dev->chardev_close_bh);
-
     DPRINTF("creating usbredirparser\n");
 
     dev->parser = qemu_oom_check(usbredirparser_create());
@@ -982,7 +978,10 @@ static void usbredir_chardev_event(void *opaque, int event)
     switch (event) {
     case CHR_EVENT_OPENED:
         DPRINTF("chardev open\n");
-        usbredir_chardev_open(dev);
+        /* Make sure any pending closes are handled (no-op if none pending) */
+        usbredir_chardev_close_bh(dev);
+        qemu_bh_cancel(dev->chardev_close_bh);
+        usbredir_create_parser(dev);
         break;
     case CHR_EVENT_CLOSED:
         DPRINTF("chardev close\n");
Signature · 1 line
1.7.1
#3 lore raw

PATCH 3/3 uhci: Raise interrupt when requested even for non active tds

In reply to Gerd Hoffmann

From: Hans de Goede <[email protected]>

According to the spec we must raise an interrupt when one is requested even for non active tds.

Linux depends on this, for bulk transfers it runs an inactivity timer to work around a bug in early uhci revisions, when we take longer then 200 ms to process a packet, this timer goes of, and as part of the handling Linux then unlinks the qh, and relinks it after the frindex has increased by atleast 1, the problem is Linux only checks for the frindex increases on an interrupt, and we don't send that, causing the qh to go inactive for more then 32 frames, at which point we consider the packet cancelled.

---
 hw/usb/hcd-uhci.c |   10 +++++++++-
 1 files changed, 9 insertions(+), 1 deletions(-)
hw/usb/hcd-uhci.c +9 -1
index cdc8bc3..c2f08e3 100644
@@ -826,8 +826,16 @@ static int uhci_handle_td(UHCIState *s, uint32_t addr, UHCI_TD *td,
     USBEndpoint *ep;
 
     /* Is active ? */
-    if (!(td->ctrl & TD_CTRL_ACTIVE))
+    if (!(td->ctrl & TD_CTRL_ACTIVE)) {
+        /*
+         * ehci11d spec page 22: "Even if the Active bit in the TD is already
+         * cleared when the TD is fetched ... an IOC interrupt is generated"
+         */
+        if (td->ctrl & TD_CTRL_IOC) {
+                *int_mask |= 0x01;
+        }
         return TD_RESULT_NEXT_QH;
+    }
 
     async = uhci_async_find_td(s, addr, td);
     if (async) {
Signature · 1 line
1.7.1
#4 lore raw
In reply to Gerd Hoffmann
Quoted 7 lines · Gerd Hoffmann

Hi,

Pretty small this time with just a few bugfixes.

please pull,
Gerd

Pulled. Thanks.

Regards,

Anthony Liguori

Quoted 15 lines

The following changes since commit b4ae3cfa57b8c1bdbbd7b7d420971e9171203ade:

ssi: Add slave autoconnect helper (2012-10-10 11:13:32 +1000)

are available in the git repository at:
git://git.kraxel.org/qemu usb.67

Hans de Goede (3):
usb-redir: Change usbredir_open_chardev into usbredir_create_parser
usb-redir: Don't make migration fail in none seamless case
uhci: Raise interrupt when requested even for non active tds

 hw/usb/hcd-uhci.c |   10 +++++++++-
 hw/usb/redirect.c |   24 ++++++++++++++----------
 2 files changed, 23 insertions(+), 11 deletions(-)