qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Gerd Hoffmann <kraxel@redhat.com>
To: qemu-devel@nongnu.org
Cc: Samuel Thibault <samuel.thibault@ens-lyon.org>,
	Gerd Hoffmann <kraxel@redhat.com>,
	Jason Andryuk <jandryuk@gmail.com>
Subject: [PULL 4/4] usb-serial: Fix timeout closing the device
Date: Tue, 17 Mar 2020 10:50:49 +0100	[thread overview]
Message-ID: <20200317095049.28486-5-kraxel@redhat.com> (raw)
In-Reply-To: <20200317095049.28486-1-kraxel@redhat.com>

From: Jason Andryuk <jandryuk@gmail.com>

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 | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/hw/usb/dev-serial.c b/hw/usb/dev-serial.c
index 77b964588b5f..d2c03681b7f0 100644
--- a/hw/usb/dev-serial.c
+++ b/hw/usb/dev-serial.c
@@ -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:
-- 
2.18.2



  parent reply	other threads:[~2020-03-17  9:52 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-17  9:50 [PULL 0/4] Usb 20200317 patches Gerd Hoffmann
2020-03-17  9:50 ` [PULL 1/4] usb-serial: Move USB_TOKEN_IN into a helper function Gerd Hoffmann
2020-03-17  9:50 ` [PULL 2/4] usb-serial: chunk data to wMaxPacketSize Gerd Hoffmann
2020-03-17  9:50 ` [PULL 3/4] usb-serial: Increase receive buffer to 496 Gerd Hoffmann
2020-03-17  9:50 ` Gerd Hoffmann [this message]
2020-03-17 14:44 ` [PULL 0/4] Usb 20200317 patches Peter Maydell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200317095049.28486-5-kraxel@redhat.com \
    --to=kraxel@redhat.com \
    --cc=jandryuk@gmail.com \
    --cc=qemu-devel@nongnu.org \
    --cc=samuel.thibault@ens-lyon.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).