[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 1/7] usb-host-libusb: Fix reset handling
From: |
Hans de Goede |
Subject: |
[Qemu-devel] [PATCH 1/7] usb-host-libusb: Fix reset handling |
Date: |
Mon, 23 Sep 2013 20:54:01 +0200 |
The guest will issue an initial device reset when the device is attached, but
since the current usb-host-libusb code only actually does the reset when
udev->configuration != 0, and on attach the device is not yet configured,
the reset gets ignored. This means that the device gets passed to the guest
in an unknown state, which is not good.
The udev->configuration check is there because of the release / claim
interfaces done around the libusb_device_reset call, but these are not
necessary. If interfaces are claimed when libusb_device_reset gets called
libusb will release + reclaim them itself.
The usb_host_ep_update call also is not necessary. If the reset succeeds the
original config and interface alt settings will be restored.
Last if the reset fails, that means the device has either disconnected or
morphed into an another device and has been completely re-enumerated,
so it is treated by the host as a new device and our handle is invalid,
so on reset failure we need to call usb_host_nodev().
Signed-off-by: Hans de Goede <address@hidden>
---
hw/usb/host-libusb.c | 10 ++++------
1 file changed, 4 insertions(+), 6 deletions(-)
diff --git a/hw/usb/host-libusb.c b/hw/usb/host-libusb.c
index b27f559..09a8a73 100644
--- a/hw/usb/host-libusb.c
+++ b/hw/usb/host-libusb.c
@@ -1277,16 +1277,14 @@ static void usb_host_flush_ep_queue(USBDevice *dev,
USBEndpoint *ep)
static void usb_host_handle_reset(USBDevice *udev)
{
USBHostDevice *s = USB_HOST_DEVICE(udev);
+ int rc;
trace_usb_host_reset(s->bus_num, s->addr);
- if (udev->configuration == 0) {
- return;
+ rc = libusb_reset_device(s->dh);
+ if (rc != 0) {
+ usb_host_nodev(s);
}
- usb_host_release_interfaces(s);
- libusb_reset_device(s->dh);
- usb_host_claim_interfaces(s, 0);
- usb_host_ep_update(s);
}
static int usb_host_alloc_streams(USBDevice *udev, USBEndpoint *ep,
--
1.8.3.1
- [Qemu-devel] [PATCH 0/7] usb: host-libusb and xhci fixes, Hans de Goede, 2013/09/23
- [Qemu-devel] [PATCH 1/7] usb-host-libusb: Fix reset handling,
Hans de Goede <=
- [Qemu-devel] [PATCH 2/7] usb-host-libusb: Configuration 0 may be a valid configuration, Hans de Goede, 2013/09/23
- [Qemu-devel] [PATCH 3/7] usb-host-libusb: Detach kernel drivers earlier, Hans de Goede, 2013/09/23
- [Qemu-devel] [PATCH 4/7] usb-hcd-xhci: Remove unused sstreamsm member from XHCIStreamContext, Hans de Goede, 2013/09/23
- [Qemu-devel] [PATCH 5/7] usb-hcd-xhci: Remove unused cancelled member from XHCITransfer, Hans de Goede, 2013/09/23
- [Qemu-devel] [PATCH 6/7] usb-hcd-xhci: Report completion of active transfer with CC_STOPPED on ep stop, Hans de Goede, 2013/09/23
- [Qemu-devel] [PATCH 7/7] usb-hcd-xhci: Update endpoint context dequeue pointer for streams too, Hans de Goede, 2013/09/23