thebeanogamer / rpms / qemu-kvm

Forked from rpms/qemu-kvm 5 months ago
Clone

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

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