]> git.proxmox.com Git - mirror_qemu.git/commitdiff
usb-serial: Fix timeout closing the device
authorJason Andryuk <jandryuk@gmail.com>
Mon, 16 Mar 2020 17:46:10 +0000 (13:46 -0400)
committerGerd Hoffmann <kraxel@redhat.com>
Tue, 17 Mar 2020 08:05:34 +0000 (09:05 +0100)
Linux guests wait ~30 seconds when closing the emulated /dev/ttyUSB0.
During that time, the kernel driver is sending many control URBs
requesting GetModemStat (5).  Real hardware returns a status with
FTDI_THRE (Transmitter Holding Register) and FTDI_TEMT (Transmitter
Empty) set.  QEMU leaves them clear, and it seems Linux is waiting for
FTDI_TEMT to be set to indicate the tx queue is empty before closing.

Set the bits when responding to a GetModemStat query and avoid the
shutdown delay.

Signed-off-by: Jason Andryuk <jandryuk@gmail.com>
Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
Message-id: 20200316174610.115820-5-jandryuk@gmail.com
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
hw/usb/dev-serial.c

index 77b964588b5f4c2fd0aa9bb5bb4ec3026e40800a..d2c03681b7f0187d9f7ce4810b456806e3303bf6 100644 (file)
@@ -332,7 +332,7 @@ static void usb_serial_handle_control(USBDevice *dev, USBPacket *p,
         break;
     case DeviceInVendor | FTDI_GET_MDM_ST:
         data[0] = usb_get_modem_lines(s) | 1;
-        data[1] = 0;
+        data[1] = FTDI_THRE | FTDI_TEMT;
         p->actual_length = 2;
         break;
     case DeviceOutVendor | FTDI_SET_EVENT_CHR: