[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 2/5] usb-redir: remove 'remote wakeup' flag from configuration des
From: |
Gerd Hoffmann |
Subject: |
[PULL 2/5] usb-redir: remove 'remote wakeup' flag from configuration descriptor |
Date: |
Mon, 13 Jan 2020 14:06:43 +0100 |
From: Yuri Benditovich <address@hidden>
If the redirected device has this capability, Windows guest may
place the device into D2 and expect it to wake when the device
becomes active, but this will never happen. For example, when
internal Bluetooth adapter is redirected, keyboards and mice
connected to it do not work. Current commit removes this
capability (starting from machine 5.0)
Set 'usb-redir.suppress-remote-wake' property to 'off' to keep
'remote wake' as is or to 'on' to remove 'remote wake' on
4.2 or earlier.
Signed-off-by: Yuri Benditovich <address@hidden>
Message-id: address@hidden
Signed-off-by: Gerd Hoffmann <address@hidden>
---
hw/core/machine.c | 1 +
hw/usb/redirect.c | 20 ++++++++++++++++++++
2 files changed, 21 insertions(+)
diff --git a/hw/core/machine.c b/hw/core/machine.c
index c5d32f56db93..3e288bfceb7f 100644
--- a/hw/core/machine.c
+++ b/hw/core/machine.c
@@ -33,6 +33,7 @@ GlobalProperty hw_compat_4_2[] = {
{ "virtio-scsi-device", "seg_max_adjust", "off"},
{ "vhost-blk-device", "seg_max_adjust", "off"},
{ "usb-host", "suppress-remote-wake", "off" },
+ { "usb-redir", "suppress-remote-wake", "off" },
};
const size_t hw_compat_4_2_len = G_N_ELEMENTS(hw_compat_4_2);
diff --git a/hw/usb/redirect.c b/hw/usb/redirect.c
index e0f5ca6f818b..b5c15586874a 100644
--- a/hw/usb/redirect.c
+++ b/hw/usb/redirect.c
@@ -113,6 +113,7 @@ struct USBRedirDevice {
/* Properties */
CharBackend cs;
bool enable_streams;
+ bool suppress_remote_wake;
uint8_t debug;
int32_t bootindex;
char *filter_str;
@@ -1989,6 +1990,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);
@@ -2530,6 +2548,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(),
};
--
2.18.1
- [PULL 0/5] Usb 20200113 patches, Gerd Hoffmann, 2020/01/13
- [PULL 1/5] usb-host: remove 'remote wakeup' flag from configuration descriptor, Gerd Hoffmann, 2020/01/13
- [PULL 5/5] xhci: recheck slot status, Gerd Hoffmann, 2020/01/13
- [PULL 3/5] usbredir: Prevent recursion in usbredir_write, Gerd Hoffmann, 2020/01/13
- [PULL 2/5] usb-redir: remove 'remote wakeup' flag from configuration descriptor,
Gerd Hoffmann <=
- [PULL 4/5] xhci: Fix memory leak in xhci_kick_epctx when poweroff GuestOS, Gerd Hoffmann, 2020/01/13
- Re: [PULL 0/5] Usb 20200113 patches, Peter Maydell, 2020/01/13