Blame SOURCES/kvm-usb-host-avoid-libusb_set_configuration-calls.patch

ae23c9
From c7150963b7db0123299f2430eea956c6a83f69d4 Mon Sep 17 00:00:00 2001
ae23c9
From: Gerd Hoffmann <kraxel@redhat.com>
ae23c9
Date: Tue, 4 Jun 2019 05:12:46 +0100
ae23c9
Subject: [PATCH 4/8] usb-host: avoid libusb_set_configuration calls
ae23c9
MIME-Version: 1.0
ae23c9
Content-Type: text/plain; charset=UTF-8
ae23c9
Content-Transfer-Encoding: 8bit
ae23c9
ae23c9
RH-Author: Gerd Hoffmann <kraxel@redhat.com>
ae23c9
Message-id: <20190604051246.11374-5-kraxel@redhat.com>
ae23c9
Patchwork-id: 88472
ae23c9
O-Subject: [RHEL-8.1.0 qemu-kvm PATCH 4/4] usb-host: avoid libusb_set_configuration calls
ae23c9
Bugzilla: 1713677
ae23c9
RH-Acked-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
ae23c9
RH-Acked-by: Philippe Mathieu-Daudé <philmd@redhat.com>
ae23c9
RH-Acked-by: Max Reitz <mreitz@redhat.com>
ae23c9
ae23c9
Seems some devices become confused when we call
ae23c9
libusb_set_configuration().  So before calling the function check
ae23c9
whenever the device has multiple configurations in the first place, and
ae23c9
in case it hasn't (which is the case for the majority of devices) simply
ae23c9
skip the call as it will have no effect anyway.
ae23c9
ae23c9
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
ae23c9
Message-id: 20190522094702.17619-4-kraxel@redhat.com
ae23c9
(cherry picked from commit bfe44898848614cfcb3a269bc965afbe1f0f331c)
ae23c9
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
ae23c9
---
ae23c9
 hw/usb/host-libusb.c | 18 ++++++++++--------
ae23c9
 1 file changed, 10 insertions(+), 8 deletions(-)
ae23c9
ae23c9
diff --git a/hw/usb/host-libusb.c b/hw/usb/host-libusb.c
ae23c9
index dd3ed02..587ff70 100644
ae23c9
--- a/hw/usb/host-libusb.c
ae23c9
+++ b/hw/usb/host-libusb.c
ae23c9
@@ -1220,19 +1220,21 @@ static void usb_host_set_address(USBHostDevice *s, int addr)
ae23c9
 
ae23c9
 static void usb_host_set_config(USBHostDevice *s, int config, USBPacket *p)
ae23c9
 {
ae23c9
-    int rc;
ae23c9
+    int rc = 0;
ae23c9
 
ae23c9
     trace_usb_host_set_config(s->bus_num, s->addr, config);
ae23c9
 
ae23c9
     usb_host_release_interfaces(s);
ae23c9
-    rc = libusb_set_configuration(s->dh, config);
ae23c9
-    if (rc != 0) {
ae23c9
-        usb_host_libusb_error("libusb_set_configuration", rc);
ae23c9
-        p->status = USB_RET_STALL;
ae23c9
-        if (rc == LIBUSB_ERROR_NO_DEVICE) {
ae23c9
-            usb_host_nodev(s);
ae23c9
+    if (s->ddesc.bNumConfigurations != 1) {
ae23c9
+        rc = libusb_set_configuration(s->dh, config);
ae23c9
+        if (rc != 0) {
ae23c9
+            usb_host_libusb_error("libusb_set_configuration", rc);
ae23c9
+            p->status = USB_RET_STALL;
ae23c9
+            if (rc == LIBUSB_ERROR_NO_DEVICE) {
ae23c9
+                usb_host_nodev(s);
ae23c9
+            }
ae23c9
+            return;
ae23c9
         }
ae23c9
-        return;
ae23c9
     }
ae23c9
     p->status = usb_host_claim_interfaces(s, config);
ae23c9
     if (p->status != USB_RET_SUCCESS) {
ae23c9
-- 
ae23c9
1.8.3.1
ae23c9