From nobody Tue May 7 18:28:44 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1584438797; cv=none; d=zohomail.com; s=zohoarc; b=ZWBKYnD8syqB3FCESN10xqKRbR0H23DwbRhC5pAt5hA4gSTyRvmSX3p3aA780JkhpszbBOi1bmTJu3yX4Uarii919e33ckiYZGSeRHyJoLX/ppckOqVB3UWd+8+K0OvdKJ454KuGJPJ2EuT06Eyz1ygwImtTFefqvvplxoWPJZQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1584438797; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=bTpbC0hF4n0wMioutkMBf7peWozKB0jLJMnAudSFGwY=; b=jIYxTO04VOAcmPGeaad6jYq4ONiIlT2TyLRsnAOPDPQWTl01RdK9IhPgM7q6W4NlRFIQweGV1xCJErGPELgTmyqKQERoa2TVfobUtJdP9V9xmNEp5rrtnBHAGYuMnDUwZCJ6sq+2liRo4B1oG2jM89AMT6Gfvz5aABaQVgBgNpc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1584438797299233.5995794813549; Tue, 17 Mar 2020 02:53:17 -0700 (PDT) Received: from localhost ([::1]:55258 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jE8uS-0001FF-9m for importer@patchew.org; Tue, 17 Mar 2020 05:53:16 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56950) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jE8sJ-0005oh-LY for qemu-devel@nongnu.org; Tue, 17 Mar 2020 05:51:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jE8sI-0004qL-EC for qemu-devel@nongnu.org; Tue, 17 Mar 2020 05:51:03 -0400 Received: from us-smtp-delivery-74.mimecast.com ([216.205.24.74]:44089) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jE8sI-0004oR-A6 for qemu-devel@nongnu.org; Tue, 17 Mar 2020 05:51:02 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-201-7wGnlxRFO6KDj6MIwrJcfQ-1; Tue, 17 Mar 2020 05:50:55 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 2DF951005514; Tue, 17 Mar 2020 09:50:54 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-112-49.ams2.redhat.com [10.36.112.49]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0D1D68F343; Tue, 17 Mar 2020 09:50:50 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 013139D21; Tue, 17 Mar 2020 10:50:50 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1584438659; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=bTpbC0hF4n0wMioutkMBf7peWozKB0jLJMnAudSFGwY=; b=Fd16xF7Wz3FveBQs/puHGTEmIxizFRhFbZEncqTb4G9emXI1ZOwWsT9UBJnwJqUiupF4Wx aZjUh8OwjqTIJ6hzJsykpvrdBmWC4qjl40lSMfgiOzWN10l64adh7XjHjBKgKAczxbatN1 SS7KbdPlzAjV1sInvEMXSDQlnYcvByM= X-MC-Unique: 7wGnlxRFO6KDj6MIwrJcfQ-1 From: Gerd Hoffmann To: qemu-devel@nongnu.org Subject: [PULL 1/4] usb-serial: Move USB_TOKEN_IN into a helper function Date: Tue, 17 Mar 2020 10:50:46 +0100 Message-Id: <20200317095049.28486-2-kraxel@redhat.com> In-Reply-To: <20200317095049.28486-1-kraxel@redhat.com> References: <20200317095049.28486-1-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 216.205.24.74 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Samuel Thibault , Gerd Hoffmann , Jason Andryuk Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Jason Andryuk We'll be adding a loop, so move the code into a helper function. breaks are replaced with returns. While making this change, add braces to single line if statements to comply with coding style and keep checkpatch happy. Signed-off-by: Jason Andryuk Message-id: 20200316174610.115820-2-jandryuk@gmail.com Signed-off-by: Gerd Hoffmann --- hw/usb/dev-serial.c | 80 ++++++++++++++++++++++++++------------------- 1 file changed, 46 insertions(+), 34 deletions(-) diff --git a/hw/usb/dev-serial.c b/hw/usb/dev-serial.c index daac75b7aec2..d807ce577110 100644 --- a/hw/usb/dev-serial.c +++ b/hw/usb/dev-serial.c @@ -358,13 +358,56 @@ static void usb_serial_handle_control(USBDevice *dev,= USBPacket *p, } } =20 +static void usb_serial_token_in(USBSerialState *s, USBPacket *p) +{ + int first_len, len; + uint8_t header[2]; + + first_len =3D RECV_BUF - s->recv_ptr; + len =3D p->iov.size; + if (len <=3D 2) { + p->status =3D USB_RET_NAK; + return; + } + header[0] =3D usb_get_modem_lines(s) | 1; + /* We do not have the uart details */ + /* handle serial break */ + if (s->event_trigger && s->event_trigger & FTDI_BI) { + s->event_trigger &=3D ~FTDI_BI; + header[1] =3D FTDI_BI; + usb_packet_copy(p, header, 2); + return; + } else { + header[1] =3D 0; + } + len -=3D 2; + if (len > s->recv_used) { + len =3D s->recv_used; + } + if (!len) { + p->status =3D USB_RET_NAK; + return; + } + if (first_len > len) { + first_len =3D len; + } + usb_packet_copy(p, header, 2); + usb_packet_copy(p, s->recv_buf + s->recv_ptr, first_len); + if (len > first_len) { + usb_packet_copy(p, s->recv_buf, len - first_len); + } + s->recv_used -=3D len; + s->recv_ptr =3D (s->recv_ptr + len) % RECV_BUF; + + return; +} + static void usb_serial_handle_data(USBDevice *dev, USBPacket *p) { USBSerialState *s =3D (USBSerialState *)dev; uint8_t devep =3D p->ep->nr; struct iovec *iov; - uint8_t header[2]; - int i, first_len, len; + int i; =20 switch (p->pid) { case USB_TOKEN_OUT: @@ -382,38 +425,7 @@ static void usb_serial_handle_data(USBDevice *dev, USB= Packet *p) case USB_TOKEN_IN: if (devep !=3D 1) goto fail; - first_len =3D RECV_BUF - s->recv_ptr; - len =3D p->iov.size; - if (len <=3D 2) { - p->status =3D USB_RET_NAK; - break; - } - header[0] =3D usb_get_modem_lines(s) | 1; - /* We do not have the uart details */ - /* handle serial break */ - if (s->event_trigger && s->event_trigger & FTDI_BI) { - s->event_trigger &=3D ~FTDI_BI; - header[1] =3D FTDI_BI; - usb_packet_copy(p, header, 2); - break; - } else { - header[1] =3D 0; - } - len -=3D 2; - if (len > s->recv_used) - len =3D s->recv_used; - if (!len) { - p->status =3D USB_RET_NAK; - break; - } - if (first_len > len) - first_len =3D len; - usb_packet_copy(p, header, 2); - usb_packet_copy(p, s->recv_buf + s->recv_ptr, first_len); - if (len > first_len) - usb_packet_copy(p, s->recv_buf, len - first_len); - s->recv_used -=3D len; - s->recv_ptr =3D (s->recv_ptr + len) % RECV_BUF; + usb_serial_token_in(s, p); break; =20 default: --=20 2.18.2 From nobody Tue May 7 18:28:44 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1584438728; cv=none; d=zohomail.com; s=zohoarc; b=Lb/80ozYvcINP1W6sETihGfEQgyM6ApZA1PJ+5TCyr/G/yWO8diiJSRLPjOtpGGYetxZY7nC/Ev945xJO1hlrxErYQmZ4tZK9bI6UfO1mo1PMsdfoYIKvXDnhfimZ5Z6D/pzr5EiYSyMbGGZHy3ORiGJrhrYgOAqiH6R8ATDGIU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1584438728; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=dFH1Yj5Sjk9qto7j29PpSqX35LZhn2npn279aodx5tQ=; b=cZIC9VDNsPbdWcyOhTKvj+T/nAnTaDLGv03O+bgyv02SWtyrOmcwdVVx4i+t3L2gqWCW6EzcHAddXv0QSGRBFR6VEEgpfKsbRgbxQlYQT2yQAZHyYCuaOp8QvPFBSght4seAtn/qorgA5shy6vmrxangl/K3tt+lsNjlt28k408= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1584438728239239.49532865487276; Tue, 17 Mar 2020 02:52:08 -0700 (PDT) Received: from localhost ([::1]:55236 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jE8tK-0007P3-Pv for importer@patchew.org; Tue, 17 Mar 2020 05:52:06 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56911) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jE8sI-0005oC-Cm for qemu-devel@nongnu.org; Tue, 17 Mar 2020 05:51:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jE8sD-0004kq-Sx for qemu-devel@nongnu.org; Tue, 17 Mar 2020 05:51:02 -0400 Received: from us-smtp-delivery-74.mimecast.com ([63.128.21.74]:53091) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jE8sD-0004jf-Oh for qemu-devel@nongnu.org; Tue, 17 Mar 2020 05:50:57 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-298-I8zxG01nN-Wt_VARvcg4wQ-1; Tue, 17 Mar 2020 05:50:55 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 1F66D107ACCA; Tue, 17 Mar 2020 09:50:54 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-112-49.ams2.redhat.com [10.36.112.49]) by smtp.corp.redhat.com (Postfix) with ESMTP id D6C9D60BEE; Tue, 17 Mar 2020 09:50:50 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 09D386FF; Tue, 17 Mar 2020 10:50:50 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1584438657; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=dFH1Yj5Sjk9qto7j29PpSqX35LZhn2npn279aodx5tQ=; b=QolOe/AWr48yczOBOC4rvd6RaRLadx4rvu/N0AUYxiTGZIYYeIK4F1oiPm4vB+MioJCIx3 HfeMO6cMl5pIA7NpH1EceMg1SX+EmhiclxhRoGquxx9oizKe/hlsog7NhpkEoI8vH4aTsh XZSYvZwFhE4sexLeqiajkjRXAHliBZc= X-MC-Unique: I8zxG01nN-Wt_VARvcg4wQ-1 From: Gerd Hoffmann To: qemu-devel@nongnu.org Subject: [PULL 2/4] usb-serial: chunk data to wMaxPacketSize Date: Tue, 17 Mar 2020 10:50:47 +0100 Message-Id: <20200317095049.28486-3-kraxel@redhat.com> In-Reply-To: <20200317095049.28486-1-kraxel@redhat.com> References: <20200317095049.28486-1-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 63.128.21.74 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Samuel Thibault , Gerd Hoffmann , Jason Andryuk Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Jason Andryuk 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 Message-id: 20200316174610.115820-3-jandryuk@gmail.com Signed-off-by: Gerd Hoffmann --- hw/usb/dev-serial.c | 47 ++++++++++++++++++++++++++++----------------- 1 file changed, 29 insertions(+), 18 deletions(-) diff --git a/hw/usb/dev-serial.c b/hw/usb/dev-serial.c index d807ce577110..ec091b6a366c 100644 --- a/hw/usb/dev-serial.c +++ b/hw/usb/dev-serial.c @@ -360,15 +360,16 @@ static void usb_serial_handle_control(USBDevice *dev,= USBPacket *p, =20 static void usb_serial_token_in(USBSerialState *s, USBPacket *p) { - int first_len, len; + const int max_packet_size =3D desc_iface0.eps[0].wMaxPacketSize; + int packet_len; uint8_t header[2]; =20 - first_len =3D RECV_BUF - s->recv_ptr; - len =3D p->iov.size; - if (len <=3D 2) { + packet_len =3D p->iov.size; + if (packet_len <=3D 2) { p->status =3D USB_RET_NAK; return; } + header[0] =3D usb_get_modem_lines(s) | 1; /* We do not have the uart details */ /* handle serial break */ @@ -380,24 +381,34 @@ static void usb_serial_token_in(USBSerialState *s, US= BPacket *p) } else { header[1] =3D 0; } - len -=3D 2; - if (len > s->recv_used) { - len =3D s->recv_used; - } - if (!len) { + + if (!s->recv_used) { p->status =3D USB_RET_NAK; return; } - if (first_len > len) { - first_len =3D len; + + while (s->recv_used && packet_len > 2) { + int first_len, len; + + len =3D MIN(packet_len, max_packet_size); + len -=3D 2; + if (len > s->recv_used) { + len =3D s->recv_used; + } + + first_len =3D RECV_BUF - s->recv_ptr; + if (first_len > len) { + first_len =3D len; + } + usb_packet_copy(p, header, 2); + usb_packet_copy(p, s->recv_buf + s->recv_ptr, first_len); + if (len > first_len) { + usb_packet_copy(p, s->recv_buf, len - first_len); + } + s->recv_used -=3D len; + s->recv_ptr =3D (s->recv_ptr + len) % RECV_BUF; + packet_len -=3D len + 2; } - usb_packet_copy(p, header, 2); - usb_packet_copy(p, s->recv_buf + s->recv_ptr, first_len); - if (len > first_len) { - usb_packet_copy(p, s->recv_buf, len - first_len); - } - s->recv_used -=3D len; - s->recv_ptr =3D (s->recv_ptr + len) % RECV_BUF; =20 return; } --=20 2.18.2 From nobody Tue May 7 18:28:44 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1584438728; cv=none; d=zohomail.com; s=zohoarc; b=YnSyg5pPtoPL+evGiJCwyKvE2QFgQGXAw0R/2pLs9X8ZFS9D3p3AxDS0/oBtWqsIRh/OFiWVmnPlqX2EOIGbBXlMJ6X9CpKu9vJF4bFurqdrJhUIgNGX6aT9t18wYa3QyxjxhmtqP5bHOgcLbXyH4VIeffJOLhFkAufvGFNf1EY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1584438728; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=Ps2X/VA5xqFwtlTlvRKCA4P0jgcwtIx4fu8RvAmrg3w=; b=RVJatiNZAMmAkyjdhx4s/42WmwnvCeehlYo8c4fcnT9pDi/Fbbf3wLFyTohEHbJa7BOSGAWW26FBHUrLIwtqC3Y1B9oGqcFNGXAsb2XE2q4E4qRLMRNCTe77BPZSefVoff4v3dW58mKt12ndAYWgjAM4pC//MBHLsFqHevfKl6c= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1584438728286104.91321718198924; Tue, 17 Mar 2020 02:52:08 -0700 (PDT) Received: from localhost ([::1]:55242 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jE8tK-0007Rd-V4 for importer@patchew.org; Tue, 17 Mar 2020 05:52:06 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56909) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jE8sI-0005oA-C4 for qemu-devel@nongnu.org; Tue, 17 Mar 2020 05:51:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jE8sD-0004k0-KR for qemu-devel@nongnu.org; Tue, 17 Mar 2020 05:51:02 -0400 Received: from us-smtp-delivery-74.mimecast.com ([63.128.21.74]:32755) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jE8sD-0004iy-GT for qemu-devel@nongnu.org; Tue, 17 Mar 2020 05:50:57 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-364-AiylvWGePB6b6gnxXAo0Ow-1; Tue, 17 Mar 2020 05:50:54 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id CCF20800D5A; Tue, 17 Mar 2020 09:50:53 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-112-49.ams2.redhat.com [10.36.112.49]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0D35160BE0; Tue, 17 Mar 2020 09:50:50 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 123A72049D; Tue, 17 Mar 2020 10:50:50 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1584438657; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Ps2X/VA5xqFwtlTlvRKCA4P0jgcwtIx4fu8RvAmrg3w=; b=BilLykQ6c8QrS2t1Mh343Nny6WHr10uLiR8ZjFA3+/Z3UZ/yUOaPJHgSDFmupZBoDUv0f/ cE+INfzUv9SImlEBXIaR+KOvEjJEVOvnGBylnoZfAaI4W/Uiz4U7hQZzb+4XFMBL3/NTqo g7ZiospQWhH0m89grh85rL+QQ1q0EVk= X-MC-Unique: AiylvWGePB6b6gnxXAo0Ow-1 From: Gerd Hoffmann To: qemu-devel@nongnu.org Subject: [PULL 3/4] usb-serial: Increase receive buffer to 496 Date: Tue, 17 Mar 2020 10:50:48 +0100 Message-Id: <20200317095049.28486-4-kraxel@redhat.com> In-Reply-To: <20200317095049.28486-1-kraxel@redhat.com> References: <20200317095049.28486-1-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 63.128.21.74 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Samuel Thibault , Gerd Hoffmann , Jason Andryuk Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Jason Andryuk A FTDI USB adapter on an xHCI controller can send 512 byte USB packets. These are 8 * ( 2 bytes header + 62 bytes data). A 384 byte receive buffer is insufficient to fill a 512 byte packet, so bump the receive size to 496 ( 512 - 2 * 8 ). Signed-off-by: Jason Andryuk Reviewed-by: Samuel Thibault Message-id: 20200316174610.115820-4-jandryuk@gmail.com Signed-off-by: Gerd Hoffmann --- 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 ec091b6a366c..77b964588b5f 100644 --- a/hw/usb/dev-serial.c +++ b/hw/usb/dev-serial.c @@ -29,7 +29,7 @@ do { printf("usb-serial: " fmt , ## __VA_ARGS__); } while= (0) #define DPRINTF(fmt, ...) do {} while(0) #endif =20 -#define RECV_BUF 384 +#define RECV_BUF (512 - (2 * 8)) =20 /* Commands */ #define FTDI_RESET 0 --=20 2.18.2 From nobody Tue May 7 18:28:44 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1584438728; cv=none; d=zohomail.com; s=zohoarc; b=UNo6HDbqrgUFNz82t3mxefecXhF/7AemJNhEOOOKKcWMcmUgh9j1BHxmCrn5GWsre87UK3bFNRnUjC3fssDCqOmHRV/KNOeAcweNgFvuZGpoTsFOtQV2xKyuABerl8ksZXPKQRARd2GJKCmaCqHou5MWt4oQKJIShsXonM9UkV0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1584438728; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=9inKhgTKTv0zqUNtHcvV+Fodc2GZ+KSmWsdMNps03Lw=; b=GJ4B5x9TPiCclD/f/kkUBLkJyoasJ3JlU5Mkk6Ttbi64s0L1sMLr+LD9+CSGp4DvwgJ37lTCjJET5w/GaNVBE56Om0tBr4ulsWmYGaN0gWLD8NAldWBOzSpIf/T2DPysGvRDZtUuJPMTP8B5ZyOn3TUp+I8vKyJWyyvhcVMqyAk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1584438728242100.54123600498406; Tue, 17 Mar 2020 02:52:08 -0700 (PDT) Received: from localhost ([::1]:55239 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jE8tK-0007Q0-L3 for importer@patchew.org; Tue, 17 Mar 2020 05:52:06 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56910) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jE8sI-0005oB-C4 for qemu-devel@nongnu.org; Tue, 17 Mar 2020 05:51:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jE8sD-0004kJ-On for qemu-devel@nongnu.org; Tue, 17 Mar 2020 05:51:02 -0400 Received: from us-smtp-delivery-74.mimecast.com ([216.205.24.74]:38327) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jE8sD-0004ja-L3 for qemu-devel@nongnu.org; Tue, 17 Mar 2020 05:50:57 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-273-djqS0EqCMci9L8iicU9oeg-1; Tue, 17 Mar 2020 05:50:55 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D94F7801E6C; Tue, 17 Mar 2020 09:50:53 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-112-49.ams2.redhat.com [10.36.112.49]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0D2578F37B; Tue, 17 Mar 2020 09:50:50 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 1A88B204A0; Tue, 17 Mar 2020 10:50:50 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1584438657; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=9inKhgTKTv0zqUNtHcvV+Fodc2GZ+KSmWsdMNps03Lw=; b=d3yfzBSSwLrPh3/VeqYSI63Fx2aSYuMSyDjtm/ch1b+3edd/INYIXV6Q0BwYp7Nbl9zblP FHz6va+dfMDj0j40nVw/i5pMXF+iYKp1uYXPAhN/EycR3XT5yccYOsQiNrv3L60hXZCmbq zmIfT7aiC8QE2WwRIRkNHGnu70CVJcg= X-MC-Unique: djqS0EqCMci9L8iicU9oeg-1 From: Gerd Hoffmann To: qemu-devel@nongnu.org Subject: [PULL 4/4] usb-serial: Fix timeout closing the device Date: Tue, 17 Mar 2020 10:50:49 +0100 Message-Id: <20200317095049.28486-5-kraxel@redhat.com> In-Reply-To: <20200317095049.28486-1-kraxel@redhat.com> References: <20200317095049.28486-1-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 216.205.24.74 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Samuel Thibault , Gerd Hoffmann , Jason Andryuk Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Jason Andryuk 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 Reviewed-by: Samuel Thibault Message-id: 20200316174610.115820-5-jandryuk@gmail.com Signed-off-by: Gerd Hoffmann --- 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, U= SBPacket *p, break; case DeviceInVendor | FTDI_GET_MDM_ST: data[0] =3D usb_get_modem_lines(s) | 1; - data[1] =3D 0; + data[1] =3D FTDI_THRE | FTDI_TEMT; p->actual_length =3D 2; break; case DeviceOutVendor | FTDI_SET_EVENT_CHR: --=20 2.18.2