qemu-usb: increase USB2/3 root ports to 8 each

In the default setting the number of root ports is set to 4. This
also limits the number of USB host devices that may be attached to
the VM. Since the USB webcam shares the slots, that leaves us with
only 3 available USB2 slots to attach USB host devices. Depending on
the use-case that might not be enough.

This commit statically increases the number of ports to 8 each and
adapts the qemu-usb glue-code accordingly.

Many thanks to Raphael for initial investigation and workaround.

Fixes #4310.
This commit is contained in:
Josef Söntgen 2021-11-01 16:23:58 +01:00 committed by Christian Helmuth
parent 6d991313b1
commit 6ecae6adb3
4 changed files with 24 additions and 3 deletions

View File

@ -1 +1 @@
a716b3ed197d29cb3f059a76de9bb4e0e8c708f0
8b0fa7bf30ac8ee32c547b0eb5f468b947f12ae6

View File

@ -12,6 +12,7 @@ HASH_INPUT += $(REP_DIR)/src/lib/qemu-usb/files.list
PATCHES := src/lib/qemu-usb/patches/xhci_pci_register.patch \
src/lib/qemu-usb/patches/usb_bus_nfree.patch \
src/lib/qemu-usb/patches/hcd-xhci-bei.patch \
src/lib/qemu-usb/patches/hcd-xhci-numports.patch \
src/lib/qemu-usb/patches/xhci_frame_wrap.patch
PATCH_OPT:= -p1

View File

@ -0,0 +1,13 @@
--- a/src/lib/qemu/hw/usb/hcd-xhci.c
+++ b/src/lib/qemu/hw/usb/hcd-xhci.c
@@ -3577,8 +3594,8 @@
static Property xhci_properties[] = {
DEFINE_PROP_BIT("streams", XHCIState, flags,
XHCI_FLAG_ENABLE_STREAMS, true),
- DEFINE_PROP_UINT32("p2", XHCIState, numports_2, 4),
- DEFINE_PROP_UINT32("p3", XHCIState, numports_3, 4),
+ DEFINE_PROP_UINT32("p2", XHCIState, numports_2, 8),
+ DEFINE_PROP_UINT32("p3", XHCIState, numports_3, 8),
DEFINE_PROP_LINK("host", XHCIState, hostOpaque, TYPE_DEVICE,
DeviceState *),
DEFINE_PROP_END_OF_LIST(),

View File

@ -40,10 +40,16 @@ static bool const verbose_mmio = false;
namespace {
/* keep in sync with hcd-xhci.c */
#define MAX_NUMPORTS (2 * 8)
#define OFF_OPER 0x40
#define OFF_RUNTIME 0x1000
#define OFF_PORTS (OFF_OPER + 0x400)
constexpr unsigned max_numports()
{
return MAX_NUMPORTS;
}
bool port_access(Genode::off_t offset)
{
bool const v = (offset >= OFF_PORTS) && (offset < OFF_RUNTIME);
@ -56,6 +62,7 @@ uint32_t port_index(Genode::off_t offset)
return (offset - OFF_PORTS) / 0x10;
}
#undef MAX_NUMPORTS
#undef OFF_OPER
#undef OFF_RUNTIME
#undef OFF_PORTS
@ -279,7 +286,7 @@ struct Object_pool
USB_HOST_DEVICE, /* USB host device driver */
USB_WEBCAM, /* USB webcam device driver */
USB_FIRST_FREE, /* first free device */
MAX = 14 /* host devices (USB_FIRST_FREE to MAX) */
MAX = USB_FIRST_FREE + max_numports() /* host devices (USB_FIRST_FREE to MAX) */
};
bool used[MAX];
@ -620,7 +627,7 @@ struct Controller : public Qemu::Controller
Genode::off_t offset;
MemoryRegionOps const *ops;
} mmio_regions [16];
} mmio_regions [max_numports() + 4 /* number of HC MMIO regions */];
uint64_t _mmio_size;