diff options
author | Peter Maydell <peter.maydell@linaro.org> | 2020-01-13 14:19:56 +0000 |
---|---|---|
committer | Peter Maydell <peter.maydell@linaro.org> | 2020-01-13 14:19:57 +0000 |
commit | 3c8a6575985b1652b45bfa670b5e1907d642cfa0 (patch) | |
tree | fc5ff4e637a17f557ee30a17bad695d2625c1f3f /hw/usb/redirect.c | |
parent | 981c9b88e674408a1579ca3aa8d42770e3b689de (diff) | |
parent | 236846a019c4f7aa3111026fc9a1fe09684c8978 (diff) |
Merge remote-tracking branch 'remotes/kraxel/tags/usb-20200113-pull-request' into staging
usb: bugfixes for xhci, usb pass-through and usb redirection.
# gpg: Signature made Mon 13 Jan 2020 13:06:35 GMT
# gpg: using RSA key 4CB6D8EED3E87138
# gpg: Good signature from "Gerd Hoffmann (work) <kraxel@redhat.com>" [full]
# gpg: aka "Gerd Hoffmann <gerd@kraxel.org>" [full]
# gpg: aka "Gerd Hoffmann (private) <kraxel@gmail.com>" [full]
# Primary key fingerprint: A032 8CFF B93A 17A7 9901 FE7D 4CB6 D8EE D3E8 7138
* remotes/kraxel/tags/usb-20200113-pull-request:
xhci: recheck slot status
xhci: Fix memory leak in xhci_kick_epctx when poweroff GuestOS
usbredir: Prevent recursion in usbredir_write
usb-redir: remove 'remote wakeup' flag from configuration descriptor
usb-host: remove 'remote wakeup' flag from configuration descriptor
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'hw/usb/redirect.c')
-rw-r--r-- | hw/usb/redirect.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/hw/usb/redirect.c b/hw/usb/redirect.c index 0068aa8a19..efdbcc074c 100644 --- a/hw/usb/redirect.c +++ b/hw/usb/redirect.c @@ -113,6 +113,8 @@ struct USBRedirDevice { /* Properties */ CharBackend cs; bool enable_streams; + bool suppress_remote_wake; + bool in_write; uint8_t debug; int32_t bootindex; char *filter_str; @@ -290,6 +292,13 @@ static int usbredir_write(void *priv, uint8_t *data, int count) return 0; } + /* Recursion check */ + if (dev->in_write) { + DPRINTF("usbredir_write recursion\n"); + return 0; + } + dev->in_write = true; + r = qemu_chr_fe_write(&dev->cs, data, count); if (r < count) { if (!dev->watch) { @@ -300,6 +309,7 @@ static int usbredir_write(void *priv, uint8_t *data, int count) r = 0; } } + dev->in_write = false; return r; } @@ -1994,6 +2004,23 @@ static void usbredir_control_packet(void *priv, uint64_t id, memcpy(dev->dev.data_buf, data, data_len); } p->actual_length = len; + /* + * If this is GET_DESCRIPTOR request for configuration descriptor, + * remove 'remote wakeup' flag from it to prevent idle power down + * in Windows guest + */ + if (dev->suppress_remote_wake && + control_packet->requesttype == USB_DIR_IN && + control_packet->request == USB_REQ_GET_DESCRIPTOR && + control_packet->value == (USB_DT_CONFIG << 8) && + control_packet->index == 0 && + /* bmAttributes field of config descriptor */ + len > 7 && (dev->dev.data_buf[7] & USB_CFG_ATT_WAKEUP)) { + DPRINTF("Removed remote wake %04X:%04X\n", + dev->device_info.vendor_id, + dev->device_info.product_id); + dev->dev.data_buf[7] &= ~USB_CFG_ATT_WAKEUP; + } usb_generic_async_ctrl_complete(&dev->dev, p); } free(data); @@ -2535,6 +2562,8 @@ static Property usbredir_properties[] = { DEFINE_PROP_UINT8("debug", USBRedirDevice, debug, usbredirparser_warning), DEFINE_PROP_STRING("filter", USBRedirDevice, filter_str), DEFINE_PROP_BOOL("streams", USBRedirDevice, enable_streams, true), + DEFINE_PROP_BOOL("suppress-remote-wake", USBRedirDevice, + suppress_remote_wake, true), DEFINE_PROP_END_OF_LIST(), }; |