All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH 1/3] usb-redir: An interface count of 0 is a valid value
@ 2012-03-31 15:14 Hans de Goede
  2012-03-31 15:14 ` [Qemu-devel] [PATCH 2/3] usb-redir: Reset device address and speed on disconnect Hans de Goede
  2012-03-31 15:14 ` [Qemu-devel] [PATCH 3/3] usb-redir: Not finding an async urb id is not an error Hans de Goede
  0 siblings, 2 replies; 3+ messages in thread
From: Hans de Goede @ 2012-03-31 15:14 UTC (permalink / raw)
  To: Gerd Hoffmann; +Cc: Hans de Goede, qemu-devel

An interface-count of 0 happens when a device is in unconfigured state when
it gets redirected. So we should not use 0 to detect not having received
interface info from our peer.

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

diff --git a/hw/usb/redirect.c b/hw/usb/redirect.c
index c9d22e4..9cea7c1 100644
--- a/hw/usb/redirect.c
+++ b/hw/usb/redirect.c
@@ -39,6 +39,7 @@
 #include "hw/usb.h"
 
 #define MAX_ENDPOINTS 32
+#define NO_INTERFACE_INFO 255 /* Valid interface_count always <= 32 */
 #define EP2I(ep_address) (((ep_address & 0x80) >> 3) | (ep_address & 0x0f))
 #define I2EP(i) (((i & 0x10) << 3) | (i & 0x0f))
 
@@ -968,7 +969,7 @@ static void usbredir_handle_destroy(USBDevice *udev)
 
 static int usbredir_check_filter(USBRedirDevice *dev)
 {
-    if (dev->interface_info.interface_count == 0) {
+    if (dev->interface_info.interface_count == NO_INTERFACE_INFO) {
         ERROR("No interface info for device\n");
         goto error;
     }
@@ -1132,7 +1133,7 @@ static void usbredir_device_disconnect(void *priv)
         QTAILQ_INIT(&dev->endpoint[i].bufpq);
     }
     usb_ep_init(&dev->dev);
-    dev->interface_info.interface_count = 0;
+    dev->interface_info.interface_count = NO_INTERFACE_INFO;
 }
 
 static void usbredir_interface_info(void *priv,
-- 
1.7.9.3

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [Qemu-devel] [PATCH 2/3] usb-redir: Reset device address and speed on disconnect
  2012-03-31 15:14 [Qemu-devel] [PATCH 1/3] usb-redir: An interface count of 0 is a valid value Hans de Goede
@ 2012-03-31 15:14 ` Hans de Goede
  2012-03-31 15:14 ` [Qemu-devel] [PATCH 3/3] usb-redir: Not finding an async urb id is not an error Hans de Goede
  1 sibling, 0 replies; 3+ messages in thread
From: Hans de Goede @ 2012-03-31 15:14 UTC (permalink / raw)
  To: Gerd Hoffmann; +Cc: Hans de Goede, qemu-devel

Without this disconnected devices look like the last redirected device
in the monitor in "info usb".

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

diff --git a/hw/usb/redirect.c b/hw/usb/redirect.c
index 9cea7c1..11d3b2b 100644
--- a/hw/usb/redirect.c
+++ b/hw/usb/redirect.c
@@ -1134,6 +1134,8 @@ static void usbredir_device_disconnect(void *priv)
     }
     usb_ep_init(&dev->dev);
     dev->interface_info.interface_count = NO_INTERFACE_INFO;
+    dev->dev.addr = 0;
+    dev->dev.speed = 0;
 }
 
 static void usbredir_interface_info(void *priv,
-- 
1.7.9.3

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [Qemu-devel] [PATCH 3/3] usb-redir: Not finding an async urb id is not an error
  2012-03-31 15:14 [Qemu-devel] [PATCH 1/3] usb-redir: An interface count of 0 is a valid value Hans de Goede
  2012-03-31 15:14 ` [Qemu-devel] [PATCH 2/3] usb-redir: Reset device address and speed on disconnect Hans de Goede
@ 2012-03-31 15:14 ` Hans de Goede
  1 sibling, 0 replies; 3+ messages in thread
From: Hans de Goede @ 2012-03-31 15:14 UTC (permalink / raw)
  To: Gerd Hoffmann; +Cc: Hans de Goede, qemu-devel

We clear our pending async urb list on device disconnect and we may still
receive "packet complete" packets from our peer after this, which will then
refer to packet ids no longer in our list.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
 hw/usb/redirect.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/hw/usb/redirect.c b/hw/usb/redirect.c
index 11d3b2b..b872626 100644
--- a/hw/usb/redirect.c
+++ b/hw/usb/redirect.c
@@ -276,7 +276,7 @@ static AsyncURB *async_find(USBRedirDevice *dev, uint32_t packet_id)
             return aurb;
         }
     }
-    ERROR("could not find async urb for packet_id %u\n", packet_id);
+    DPRINTF("could not find async urb for packet_id %u\n", packet_id);
     return NULL;
 }
 
-- 
1.7.9.3

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2012-03-31 15:12 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-03-31 15:14 [Qemu-devel] [PATCH 1/3] usb-redir: An interface count of 0 is a valid value Hans de Goede
2012-03-31 15:14 ` [Qemu-devel] [PATCH 2/3] usb-redir: Reset device address and speed on disconnect Hans de Goede
2012-03-31 15:14 ` [Qemu-devel] [PATCH 3/3] usb-redir: Not finding an async urb id is not an error Hans de Goede

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.