qemu-usb: disable remote wake up in config descriptors

Some guests don't handle remote wake up correctly causing devices to
stop functioning. Therefore, we disable the remote wake up bit (5) in
`bmAttributes` of the device configuration descriptor.

Thanks to Peter for the initial fix.

Fixes #4278
This commit is contained in:
Sebastian Sumpf 2021-10-04 12:09:09 +02:00 committed by Norman Feske
parent 07bb3fc1ec
commit 1072a91592

View File

@ -136,6 +136,16 @@ struct Completion : Usb::Completion
switch (packet.type) {
case Packet_type::CTRL:
actual_size = packet.control.actual_size;
/*
* Disable remote wakeup (bit 5) in 'bmAttributes' (content[7]) in reported
* configuration descriptor. On some systems (e.g., Windows) this will
* cause devices to stop working.
*/
if (packet.control.request == USB_REQ_GET_DESCRIPTOR
&& actual_size >= 8 && content[1] == USB_DT_CONFIG)
content[7] &= ~USB_CFG_ATT_WAKEUP;
break;
case Packet_type::BULK:
case Packet_type::IRQ: