From 1072a91592f2bc17cf80c6eae1e689483e3fd0cf Mon Sep 17 00:00:00 2001 From: Sebastian Sumpf Date: Mon, 4 Oct 2021 12:09:09 +0200 Subject: [PATCH] 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 --- repos/libports/src/lib/qemu-usb/host.cc | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/repos/libports/src/lib/qemu-usb/host.cc b/repos/libports/src/lib/qemu-usb/host.cc index 49e047a83e..f1e10f2c0e 100644 --- a/repos/libports/src/lib/qemu-usb/host.cc +++ b/repos/libports/src/lib/qemu-usb/host.cc @@ -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: