Skip to content

virtio-usb: add dual-role virtio USB driver

Igor Skalkin linux-usb virtualization 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest8 patches 15 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/8virtio-usb: add protocol header and skeleton dual-role driverMAINTAINERS drivers/usb/Kconfig drivers/usb/Makefile +5 more+580 -04 replies
2/8virtio-usb: add host role (USB Host Controller) supportdrivers/usb/virtio_usb/Makefile drivers/usb/virtio_usb/controller.c drivers/usb/virtio_usb/controller.h +5 more+2585 -162 replies
3/8virtio-usb: add device role (USB Device Controller) supportdrivers/usb/virtio_usb/Makefile drivers/usb/virtio_usb/controller.c drivers/usb/virtio_usb/controller.h +3 more+1566 -130 replies
4/8virtio-usb: add OTG role query supportdrivers/usb/virtio_usb/Makefile drivers/usb/virtio_usb/controller.c drivers/usb/virtio_usb/controller.h +2 more+277 -180 replies
5/8virtio-usb: add USB On-The-Go role-switching supportdrivers/usb/virtio_usb/controller.c drivers/usb/virtio_usb/controller.h drivers/usb/virtio_usb/device.c +4 more+474 -1120 replies
6/8virtio-usb: rework endpoint lifecycle to an async split-phase state machinedrivers/usb/virtio_usb/device.c drivers/usb/virtio_usb/device.h+639 -1590 replies
7/8virtio-usb: add SuperSpeed device-role supportdrivers/usb/virtio_usb/device.c include/uapi/linux/virtio_usb.h+56 -60 replies
8/8virtio-usb: support a guest UDC name prefix from the bind eventdrivers/usb/virtio_usb/device.c include/uapi/linux/virtio_usb.h+42 -90 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH 0/8] virtio-usb: add dual-role virtio USB driver

This series adds a new virtio-usb driver: a dual-role virtio device capable of acting as a USB host controller, a USB device controller, or both simultaneously with runtime role switching between the two (USB OTG-style role switching) on ports that support it.

The corresponding virtio-usb device specification has been posted to virtio-comment for review. This series matches the v2 revision of that spec, which reconciles a small number of protocol details (per-role virtqueue presentation, host-role vp_idx for hub/multi-VP support, and the device-role BIND/UNBIND event split) that were clarified while integrating and testing this driver against the spec:

[RFC PATCH v2] virtio-usb: Add initial virtio-usb specification Igor Skalkin <[email protected]> [email protected]
https://lore.kernel.org/virtio-comment/[email protected]/

This driver has been tested end-to-end against our own userspace virtio-usb device implementation (host-side backend) in two setups:
- arm64 hardware with a type-1 hypervisor, exercising a real dwc3 USB controller on the host side.
- x86 with a type-2 hypervisor (QEMU/KVM), using dummy_hcd/dummy_udc on the host side in place of real USB hardware.
Host role and device role were exercised in both setups: testusb on the guest, over a virtualized host port, against g_zero running on a real hardware UDC or on dummy UDC on the host side (host role); and testusb on the host side, against g_zero running on a virtualized UDC on the guest (device role); plus real USB mass-storage hardware/gadgets and iperf3 over usbnet. Role switching was exercised in both setups as well, but not with a real OTG cable/ID-pin connection:
on dwc3, role switching was driven through its "role-switch" sysfs configuration; on dummy_hcd, it was emulated by toggling between two simultaneously-configured dummy_hcd instances on the same port. Testing with a real OTG connection is planned as a follow-up.

Known scope: this driver virtualizes an entire UDC per device-role port, with each port owned by a single guest. USB function-level virtualization - a single physical UDC exposing a composite gadget whose individual functions are routed to different guests - is a separate approach currently being explored, and is out of scope for this series.

Patch summary:
1: protocol header and skeleton dual-role driver (probe/remove
plumbing, no role support yet).
2: USB host controller (HCD) role support.
3: USB device controller (UDC) role support.
4-5: USB OTG-style role query and role-switching support.
6: endpoint-lifecycle robustness rework (async split-phase state
machine, replacing an earlier out-of-tree gadget.nonatomic patch that didn't pass upstream review).
7: SuperSpeed device-role support.
8: guest UDC naming fix (name prefix from the bind event).

Aiswarya Cyriac (3):
virtio-usb: add protocol header and skeleton dual-role driver
virtio-usb: add host role (USB Host Controller) support
virtio-usb: add device role (USB Device Controller) support

Igor Skalkin (5):
virtio-usb: add OTG role query support
virtio-usb: add USB On-The-Go role-switching support
virtio-usb: rework endpoint lifecycle to an async split-phase state
machine
virtio-usb: add SuperSpeed device-role support
virtio-usb: support a guest UDC name prefix from the bind event

 MAINTAINERS                         |   10 +
 drivers/usb/Kconfig                 |    2 +
 drivers/usb/Makefile                |    1 +
 drivers/usb/virtio_usb/Kconfig      |   21 +
 drivers/usb/virtio_usb/Makefile     |    9 +
 drivers/usb/virtio_usb/controller.c |  422 ++++++++
 drivers/usb/virtio_usb/controller.h |  152 +++
 drivers/usb/virtio_usb/device.c     | 1893 +++++++++++++++++++++++++++++++++++
 drivers/usb/virtio_usb/device.h     |  115 +++
 drivers/usb/virtio_usb/host.c       | 1368 +++++++++++++++++++++++++
 drivers/usb/virtio_usb/host.h       |  203 ++++
 drivers/usb/virtio_usb/otg.c        |  403 ++++++++
 drivers/usb/virtio_usb/otg.h        |   38 +
 drivers/usb/virtio_usb/vq_common.c  |  740 ++++++++++++++
 drivers/usb/virtio_usb/vq_common.h  |  163 +++
 include/uapi/linux/virtio_usb.h     |  346 +++++++
 16 files changed, 5886 insertions(+)
 create mode 100644 drivers/usb/virtio_usb/Kconfig
 create mode 100644 drivers/usb/virtio_usb/Makefile
 create mode 100644 drivers/usb/virtio_usb/controller.c
 create mode 100644 drivers/usb/virtio_usb/controller.h
 create mode 100644 drivers/usb/virtio_usb/device.c
 create mode 100644 drivers/usb/virtio_usb/device.h
 create mode 100644 drivers/usb/virtio_usb/host.c
 create mode 100644 drivers/usb/virtio_usb/host.h
 create mode 100644 drivers/usb/virtio_usb/otg.c
 create mode 100644 drivers/usb/virtio_usb/otg.h
 create mode 100644 drivers/usb/virtio_usb/vq_common.c
 create mode 100644 drivers/usb/virtio_usb/vq_common.h
 create mode 100644 include/uapi/linux/virtio_usb.h
Signature · 1 line
2.49.0