]> git.proxmox.com Git - mirror_qemu.git/commit
usb-serial: chunk data to wMaxPacketSize
authorJason Andryuk <jandryuk@gmail.com>
Mon, 16 Mar 2020 17:46:08 +0000 (13:46 -0400)
committerGerd Hoffmann <kraxel@redhat.com>
Tue, 17 Mar 2020 08:05:33 +0000 (09:05 +0100)
commit87db78f743668224ae9a5346229faed56ef7ff66
treedbedeadd39ef07639887f1b22853bddb480c31c9
parent2bcf4e9ff9a3f29b21e6d487d89264d191df5822
usb-serial: chunk data to wMaxPacketSize

usb-serial has issues with xHCI controllers where data is lost in the
VM.  Inspecting the URBs in the guest, EHCI starts every 64 byte boundary
(wMaxPacketSize) with a header.  EHCI hands packets into
usb_serial_token_in() with size 64, so these cannot cross the 64 byte
boundary.  The xHCI controller has packets of 512 bytes and the usb-serial
will just write through the 64 byte boundary.  In the guest, this means
data bytes are interpreted as header, so data bytes don't make it out
the serial interface.

Re-work usb_serial_token_in to chunk data into 64 byte units - 2 byte
header and 62 bytes data.  The Linux driver reads wMaxPacketSize to find
the chunk size, so we match that.

Real hardware was observed to pass in 512 byte URBs (496 bytes data +
8 * 2 byte headers).  Since usb-serial only buffers 384 bytes of data,
usb-serial will pass in 6 64 byte blocks and 1 12 byte partial block for
462 bytes max.

Signed-off-by: Jason Andryuk <jandryuk@gmail.com>
Message-id: 20200316174610.115820-3-jandryuk@gmail.com
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
hw/usb/dev-serial.c