Blame 0111-usb-redir-Add-flow-control-support.patch

bd56df
From 70a31fcb3f1238e92279cdc023b83ba3a3042cff Mon Sep 17 00:00:00 2001
bd56df
Message-Id: <70a31fcb3f1238e92279cdc023b83ba3a3042cff.1346162949.git.crobinso@redhat.com>
bd56df
In-Reply-To: <90a59d545ad6759c105b0bfcfca70f574482584f.1346162949.git.crobinso@redhat.com>
bd56df
References: <90a59d545ad6759c105b0bfcfca70f574482584f.1346162949.git.crobinso@redhat.com>
Justin M. Forbes d4cdad
From: Hans de Goede <hdegoede@redhat.com>
Justin M. Forbes d4cdad
Date: Tue, 19 Jul 2011 10:56:19 +0200
bd56df
Subject: [PATCH 111/114] usb-redir: Add flow control support
Justin M. Forbes d4cdad
Justin M. Forbes d4cdad
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
bd56df
Signed-off-by: Cole Robinson <crobinso@redhat.com>
Justin M. Forbes d4cdad
---
b6dd5a
 hw/usb/redirect.c | 26 ++++++++++++++++++++++++--
Hans de Goede 329b58
 1 file changed, 24 insertions(+), 2 deletions(-)
Justin M. Forbes d4cdad
Hans de Goede 329b58
diff --git a/hw/usb/redirect.c b/hw/usb/redirect.c
b6dd5a
index ecb2cd4..1460515 100644
Hans de Goede 329b58
--- a/hw/usb/redirect.c
Hans de Goede 329b58
+++ b/hw/usb/redirect.c
b6dd5a
@@ -236,12 +236,22 @@ static int usbredir_read(void *priv, uint8_t *data, int count)
Justin M. Forbes d4cdad
 static int usbredir_write(void *priv, uint8_t *data, int count)
Justin M. Forbes d4cdad
 {
Justin M. Forbes d4cdad
     USBRedirDevice *dev = priv;
Justin M. Forbes d4cdad
+    int r;
Hans de Goede 329b58
 
Justin M. Forbes d4cdad
-    if (!dev->cs->opened) {
Justin M. Forbes d4cdad
+    if (!dev->cs->opened || dev->cs->write_blocked) {
Justin M. Forbes d4cdad
         return 0;
Justin M. Forbes d4cdad
     }
Hans de Goede 329b58
 
Justin M. Forbes d4cdad
-    return qemu_chr_fe_write(dev->cs, data, count);
Justin M. Forbes d4cdad
+    r = qemu_chr_fe_write(dev->cs, data, count);
Justin M. Forbes d4cdad
+
Justin M. Forbes d4cdad
+    if (r < 0) {
Justin M. Forbes d4cdad
+        if (dev->cs->write_blocked) {
Justin M. Forbes d4cdad
+            return 0;
Justin M. Forbes d4cdad
+        }
Justin M. Forbes d4cdad
+        return -1;
Justin M. Forbes d4cdad
+    }
Justin M. Forbes d4cdad
+
Justin M. Forbes d4cdad
+    return r;
Justin M. Forbes d4cdad
 }
Hans de Goede 329b58
 
Justin M. Forbes d4cdad
 /*
b6dd5a
@@ -892,10 +902,22 @@ static void usbredir_chardev_event(void *opaque, int event)
Justin M. Forbes d4cdad
     }
Justin M. Forbes d4cdad
 }
Hans de Goede 329b58
 
Justin M. Forbes d4cdad
+static void usbredir_chardev_write_unblocked(void *opaque)
Justin M. Forbes d4cdad
+{
Justin M. Forbes d4cdad
+    USBRedirDevice *dev = opaque;
Justin M. Forbes d4cdad
+
Justin M. Forbes d4cdad
+    if (dev->parser == NULL) {
Justin M. Forbes d4cdad
+        /* usbredir_open_close_bh hasn't handled the open event yet */
Justin M. Forbes d4cdad
+        return;
Justin M. Forbes d4cdad
+    }
Justin M. Forbes d4cdad
+    usbredirparser_do_write(dev->parser);
Justin M. Forbes d4cdad
+}
Justin M. Forbes d4cdad
+
Justin M. Forbes d4cdad
 static const QemuChrHandlers usbredir_chr_handlers = {
Justin M. Forbes d4cdad
     .fd_can_read = usbredir_chardev_can_read,
Justin M. Forbes d4cdad
     .fd_read = usbredir_chardev_read,
Justin M. Forbes d4cdad
     .fd_event = usbredir_chardev_event,
Justin M. Forbes d4cdad
+    .fd_write_unblocked = usbredir_chardev_write_unblocked,
Justin M. Forbes d4cdad
 };
Hans de Goede 329b58
 
Justin M. Forbes d4cdad
 /*
Justin M. Forbes d4cdad
-- 
b6dd5a
1.7.11.2
Justin M. Forbes d4cdad