* [Qemu-devel] [PATCH 0/3] usb-host: some little tweaks to hopefully reduce usb pass-through problems. @ 2019-05-22 9:46 Gerd Hoffmann 2019-05-22 9:47 ` [Qemu-devel] [PATCH 1/3] usb: call reset handler before updating state Gerd Hoffmann ` (2 more replies) 0 siblings, 3 replies; 4+ messages in thread From: Gerd Hoffmann @ 2019-05-22 9:46 UTC (permalink / raw) To: qemu-devel; +Cc: Gerd Hoffmann Gerd Hoffmann (3): usb: call reset handler before updating state usb-host: skip reset for untouched devices usb-host: avoid libusb_set_configuration calls hw/usb/core.c | 2 +- hw/usb/host-libusb.c | 21 +++++++++++++-------- 2 files changed, 14 insertions(+), 9 deletions(-) -- 2.18.1 ^ permalink raw reply [flat|nested] 4+ messages in thread
* [Qemu-devel] [PATCH 1/3] usb: call reset handler before updating state 2019-05-22 9:46 [Qemu-devel] [PATCH 0/3] usb-host: some little tweaks to hopefully reduce usb pass-through problems Gerd Hoffmann @ 2019-05-22 9:47 ` Gerd Hoffmann 2019-05-22 9:47 ` [Qemu-devel] [PATCH 2/3] usb-host: skip reset for untouched devices Gerd Hoffmann 2019-05-22 9:47 ` [Qemu-devel] [PATCH 3/3] usb-host: avoid libusb_set_configuration calls Gerd Hoffmann 2 siblings, 0 replies; 4+ messages in thread From: Gerd Hoffmann @ 2019-05-22 9:47 UTC (permalink / raw) To: qemu-devel; +Cc: Gerd Hoffmann That way the device reset handler can see what the before-reset state of the device is. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> --- hw/usb/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/usb/core.c b/hw/usb/core.c index 8fbd9c7d573b..3ab48a16074b 100644 --- a/hw/usb/core.c +++ b/hw/usb/core.c @@ -87,10 +87,10 @@ void usb_device_reset(USBDevice *dev) if (dev == NULL || !dev->attached) { return; } + usb_device_handle_reset(dev); dev->remote_wakeup = 0; dev->addr = 0; dev->state = USB_STATE_DEFAULT; - usb_device_handle_reset(dev); } void usb_wakeup(USBEndpoint *ep, unsigned int stream) -- 2.18.1 ^ permalink raw reply related [flat|nested] 4+ messages in thread
* [Qemu-devel] [PATCH 2/3] usb-host: skip reset for untouched devices 2019-05-22 9:46 [Qemu-devel] [PATCH 0/3] usb-host: some little tweaks to hopefully reduce usb pass-through problems Gerd Hoffmann 2019-05-22 9:47 ` [Qemu-devel] [PATCH 1/3] usb: call reset handler before updating state Gerd Hoffmann @ 2019-05-22 9:47 ` Gerd Hoffmann 2019-05-22 9:47 ` [Qemu-devel] [PATCH 3/3] usb-host: avoid libusb_set_configuration calls Gerd Hoffmann 2 siblings, 0 replies; 4+ messages in thread From: Gerd Hoffmann @ 2019-05-22 9:47 UTC (permalink / raw) To: qemu-devel; +Cc: Gerd Hoffmann If the guest didn't talk to the device yet, skip the reset. Without this usb-host devices get resetted a number of times at boot time for no good reason. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> --- hw/usb/host-libusb.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/hw/usb/host-libusb.c b/hw/usb/host-libusb.c index 67b7465915f5..4e9a45a5d26f 100644 --- a/hw/usb/host-libusb.c +++ b/hw/usb/host-libusb.c @@ -1459,6 +1459,9 @@ static void usb_host_handle_reset(USBDevice *udev) if (!s->allow_guest_reset) { return; } + if (udev->addr == 0) { + return; + } trace_usb_host_reset(s->bus_num, s->addr); -- 2.18.1 ^ permalink raw reply related [flat|nested] 4+ messages in thread
* [Qemu-devel] [PATCH 3/3] usb-host: avoid libusb_set_configuration calls 2019-05-22 9:46 [Qemu-devel] [PATCH 0/3] usb-host: some little tweaks to hopefully reduce usb pass-through problems Gerd Hoffmann 2019-05-22 9:47 ` [Qemu-devel] [PATCH 1/3] usb: call reset handler before updating state Gerd Hoffmann 2019-05-22 9:47 ` [Qemu-devel] [PATCH 2/3] usb-host: skip reset for untouched devices Gerd Hoffmann @ 2019-05-22 9:47 ` Gerd Hoffmann 2 siblings, 0 replies; 4+ messages in thread From: Gerd Hoffmann @ 2019-05-22 9:47 UTC (permalink / raw) To: qemu-devel; +Cc: Gerd Hoffmann Seems some devices become confused when we call libusb_set_configuration(). So before calling the function check whenever the device has multiple configurations in the first place, and in case it hasn't (which is the case for the majority of devices) simply skip the call as it will have no effect anyway. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> --- hw/usb/host-libusb.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/hw/usb/host-libusb.c b/hw/usb/host-libusb.c index 4e9a45a5d26f..4f765d7f9a2f 100644 --- a/hw/usb/host-libusb.c +++ b/hw/usb/host-libusb.c @@ -1225,19 +1225,21 @@ static void usb_host_set_address(USBHostDevice *s, int addr) static void usb_host_set_config(USBHostDevice *s, int config, USBPacket *p) { - int rc; + int rc = 0; trace_usb_host_set_config(s->bus_num, s->addr, config); usb_host_release_interfaces(s); - rc = libusb_set_configuration(s->dh, config); - if (rc != 0) { - usb_host_libusb_error("libusb_set_configuration", rc); - p->status = USB_RET_STALL; - if (rc == LIBUSB_ERROR_NO_DEVICE) { - usb_host_nodev(s); + if (s->ddesc.bNumConfigurations != 1) { + rc = libusb_set_configuration(s->dh, config); + if (rc != 0) { + usb_host_libusb_error("libusb_set_configuration", rc); + p->status = USB_RET_STALL; + if (rc == LIBUSB_ERROR_NO_DEVICE) { + usb_host_nodev(s); + } + return; } - return; } p->status = usb_host_claim_interfaces(s, config); if (p->status != USB_RET_SUCCESS) { -- 2.18.1 ^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2019-05-22 9:51 UTC | newest] Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2019-05-22 9:46 [Qemu-devel] [PATCH 0/3] usb-host: some little tweaks to hopefully reduce usb pass-through problems Gerd Hoffmann 2019-05-22 9:47 ` [Qemu-devel] [PATCH 1/3] usb: call reset handler before updating state Gerd Hoffmann 2019-05-22 9:47 ` [Qemu-devel] [PATCH 2/3] usb-host: skip reset for untouched devices Gerd Hoffmann 2019-05-22 9:47 ` [Qemu-devel] [PATCH 3/3] usb-host: avoid libusb_set_configuration calls Gerd Hoffmann
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.