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

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