dcavalca / rpms / qemu

Forked from rpms/qemu a year ago
Clone

Blame 0145-usb-redir-Get-rid-of-local-shadow-copy-of-packet-hea.patch

5544c1
From 40d22426e0e12f26c7bfa5848cf0a9857d52dc99 Mon Sep 17 00:00:00 2001
Hans de Goede c8dfc6
From: Hans de Goede <hdegoede@redhat.com>
Hans de Goede c8dfc6
Date: Tue, 28 Aug 2012 09:05:38 +0200
5544c1
Subject: [PATCH] usb-redir: Get rid of local shadow copy of packet headers
Hans de Goede c8dfc6
Hans de Goede c8dfc6
The shadow copy only serves as an extra check (besides the packet-id) to
Hans de Goede c8dfc6
ensure the packet we get back is a reply to the packet we think it is.
Hans de Goede c8dfc6
Hans de Goede c8dfc6
This check has never triggered in all the time usb-redir is in use now,
Hans de Goede c8dfc6
and since the verified data in the returned packet-header is not used
Hans de Goede c8dfc6
otherwise, removing the check does not open any possibilities for the
Hans de Goede c8dfc6
usbredirhost to confuse us.
Hans de Goede c8dfc6
Hans de Goede c8dfc6
This is a preparation patch for completely getting rid of the async-packet
Hans de Goede c8dfc6
struct in usb-redir, instead relying on the (new) per ep queues in the
Hans de Goede c8dfc6
qemu usb core.
Hans de Goede c8dfc6
Hans de Goede c8dfc6
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Hans de Goede c8dfc6
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
5544c1
(cherry picked from commit 104981d52b63dc3d68f39d4442881c667f44bbb9)
5544c1
5544c1
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Hans de Goede c8dfc6
---
Hans de Goede c8dfc6
 hw/usb/redirect.c | 27 ---------------------------
Hans de Goede c8dfc6
 1 file changed, 27 deletions(-)
Hans de Goede c8dfc6
Hans de Goede c8dfc6
diff --git a/hw/usb/redirect.c b/hw/usb/redirect.c
5544c1
index 2cae8c5..e4ef372 100644
Hans de Goede c8dfc6
--- a/hw/usb/redirect.c
Hans de Goede c8dfc6
+++ b/hw/usb/redirect.c
Hans de Goede c8dfc6
@@ -99,11 +99,6 @@ struct AsyncURB {
Hans de Goede c8dfc6
     USBRedirDevice *dev;
Hans de Goede c8dfc6
     USBPacket *packet;
Hans de Goede c8dfc6
     uint32_t packet_id;
Hans de Goede c8dfc6
-    union {
Hans de Goede c8dfc6
-        struct usb_redir_control_packet_header control_packet;
Hans de Goede c8dfc6
-        struct usb_redir_bulk_packet_header bulk_packet;
Hans de Goede c8dfc6
-        struct usb_redir_interrupt_packet_header interrupt_packet;
Hans de Goede c8dfc6
-    };
Hans de Goede c8dfc6
     QTAILQ_ENTRY(AsyncURB)next;
Hans de Goede c8dfc6
 };
Hans de Goede c8dfc6
 
5544c1
@@ -500,7 +495,6 @@ static int usbredir_handle_bulk_data(USBRedirDevice *dev, USBPacket *p,
Hans de Goede c8dfc6
     bulk_packet.endpoint  = ep;
Hans de Goede c8dfc6
     bulk_packet.length    = p->iov.size;
Hans de Goede c8dfc6
     bulk_packet.stream_id = 0;
Hans de Goede c8dfc6
-    aurb->bulk_packet = bulk_packet;
Hans de Goede c8dfc6
 
Hans de Goede c8dfc6
     if (ep & USB_DIR_IN) {
Hans de Goede c8dfc6
         usbredirparser_send_bulk_packet(dev->parser, aurb->packet_id,
5544c1
@@ -581,7 +575,6 @@ static int usbredir_handle_interrupt_data(USBRedirDevice *dev,
Hans de Goede c8dfc6
 
Hans de Goede c8dfc6
         interrupt_packet.endpoint  = ep;
Hans de Goede c8dfc6
         interrupt_packet.length    = p->iov.size;
Hans de Goede c8dfc6
-        aurb->interrupt_packet     = interrupt_packet;
Hans de Goede c8dfc6
 
Hans de Goede c8dfc6
         usb_packet_copy(p, buf, p->iov.size);
Hans de Goede c8dfc6
         usbredir_log_data(dev, "interrupt data out:", buf, p->iov.size);
5544c1
@@ -762,7 +755,6 @@ static int usbredir_handle_control(USBDevice *udev, USBPacket *p,
Hans de Goede c8dfc6
     control_packet.value       = value;
Hans de Goede c8dfc6
     control_packet.index       = index;
Hans de Goede c8dfc6
     control_packet.length      = length;
Hans de Goede c8dfc6
-    aurb->control_packet       = control_packet;
Hans de Goede c8dfc6
 
Hans de Goede c8dfc6
     if (control_packet.requesttype & USB_DIR_IN) {
Hans de Goede c8dfc6
         usbredirparser_send_control_packet(dev->parser, aurb->packet_id,
5544c1
@@ -1326,14 +1318,6 @@ static void usbredir_control_packet(void *priv, uint32_t id,
Hans de Goede c8dfc6
         return;
Hans de Goede c8dfc6
     }
Hans de Goede c8dfc6
 
Hans de Goede c8dfc6
-    aurb->control_packet.status = control_packet->status;
Hans de Goede c8dfc6
-    aurb->control_packet.length = control_packet->length;
Hans de Goede c8dfc6
-    if (memcmp(&aurb->control_packet, control_packet,
Hans de Goede c8dfc6
-               sizeof(*control_packet))) {
Hans de Goede c8dfc6
-        ERROR("return control packet mismatch, please report this!\n");
Hans de Goede c8dfc6
-        len = USB_RET_NAK;
Hans de Goede c8dfc6
-    }
Hans de Goede c8dfc6
-
Hans de Goede c8dfc6
     if (aurb->packet) {
Hans de Goede c8dfc6
         len = usbredir_handle_status(dev, control_packet->status, len);
Hans de Goede c8dfc6
         if (len > 0) {
5544c1
@@ -1371,12 +1355,6 @@ static void usbredir_bulk_packet(void *priv, uint32_t id,
Hans de Goede c8dfc6
         return;
Hans de Goede c8dfc6
     }
Hans de Goede c8dfc6
 
Hans de Goede c8dfc6
-    if (aurb->bulk_packet.endpoint != bulk_packet->endpoint ||
Hans de Goede c8dfc6
-            aurb->bulk_packet.stream_id != bulk_packet->stream_id) {
Hans de Goede c8dfc6
-        ERROR("return bulk packet mismatch, please report this!\n");
Hans de Goede c8dfc6
-        len = USB_RET_NAK;
Hans de Goede c8dfc6
-    }
Hans de Goede c8dfc6
-
Hans de Goede c8dfc6
     if (aurb->packet) {
Hans de Goede c8dfc6
         len = usbredir_handle_status(dev, bulk_packet->status, len);
Hans de Goede c8dfc6
         if (len > 0) {
5544c1
@@ -1455,11 +1433,6 @@ static void usbredir_interrupt_packet(void *priv, uint32_t id,
Hans de Goede c8dfc6
             return;
Hans de Goede c8dfc6
         }
Hans de Goede c8dfc6
 
Hans de Goede c8dfc6
-        if (aurb->interrupt_packet.endpoint != interrupt_packet->endpoint) {
Hans de Goede c8dfc6
-            ERROR("return int packet mismatch, please report this!\n");
Hans de Goede c8dfc6
-            len = USB_RET_NAK;
Hans de Goede c8dfc6
-        }
Hans de Goede c8dfc6
-
Hans de Goede c8dfc6
         if (aurb->packet) {
Hans de Goede c8dfc6
             aurb->packet->result = usbredir_handle_status(dev,
Hans de Goede c8dfc6
                                                interrupt_packet->status, len);
Hans de Goede c8dfc6
-- 
5544c1
1.7.12.1
Hans de Goede c8dfc6