render / rpms / qemu

Forked from rpms/qemu 9 months ago
Clone

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

Hans de Goede c8dfc6
From 3240adfcb041efcb11b4cbf4b08dc86be52b8ffc 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
Hans de Goede c8dfc6
Subject: [PATCH 320/366] usb-redir: Get rid of local shadow copy of packet
Hans de Goede c8dfc6
 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>
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
Hans de Goede c8dfc6
index 4121983..816a19a 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
 
Hans de Goede c8dfc6
@@ -510,7 +505,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,
Hans de Goede c8dfc6
@@ -591,7 +585,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);
Hans de Goede c8dfc6
@@ -772,7 +765,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,
Hans de Goede c8dfc6
@@ -1353,14 +1345,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) {
Hans de Goede c8dfc6
@@ -1398,12 +1382,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) {
Hans de Goede c8dfc6
@@ -1482,11 +1460,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
-- 
Hans de Goede c8dfc6
1.7.12
Hans de Goede c8dfc6