Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp371057ybh; Wed, 11 Mar 2020 02:44:13 -0700 (PDT) X-Google-Smtp-Source: ADFU+vvA9u6M9TXSwHqiC7yd57V6g0Iua2wL49BtDyz1kWUokmTfXS8ehVmY8u0aIYQzBAfbykSU X-Received: by 2002:a9d:19c8:: with SMTP id k66mr1531271otk.43.1583919853695; Wed, 11 Mar 2020 02:44:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1583919853; cv=none; d=google.com; s=arc-20160816; b=z59XZxK6uLl7y1CBqp+kPfeRCqujCY5JeERlm7lmxH/Joq/zIzqamxqOy3yXTyzwGs brg0zBTHVvxD/YRwyixAQqE+2G9C0v3g8Eml7uLxV8HUiipsf3JOCSGn09UGwrSnWw7u kEUGKXkhcY5E1iIPKSZVhI6c1xZVMBv2LsUx3c3vqMZYEpTljKx2bT5KZVlzqVbIZ0TA 2MX+CW5yULRHciP1PhL2T3ugIw/glpr3ZDVjSAD1AvIOEx8e2LmXB4NCtJR/ghkNjojp 8D9PGX5BNBoXUFe/RRJVhMsNwm0hiCfRCPjsZct9+61ihFxglSr9xEFoeAbgLB0Ze4Kq hUbw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=gQIxKO1uYQtTpSu2rNzwcObyoG8CtHX+4+h9JDS6C6w=; b=QuYNw04x5uQrtduX1cAxIkCLjR8pDpeLCe8ZzBm6wq9YX0L1oIIznORREj+qRI/izI 31FuAN9VE7817LwvmAZgO5kGiFFQPAnKFS3s9m8/IxusWiOTufyQMkNF2Z5tZ3fTNAie 94zJrZDlWRkiOBdg1/+BBVZ2ukdFU6QkAp9i0SuWg2YxVTiyuzeOHNN67ZS1zZny4Ss9 7TmW17B5RfcOMjnb+EFz5BuXueWD5Ngb/iY918oH5PiluwibujSXBBdG7lxOkYRm4484 /JWycgWZAJ0MTDjJ17ZlasMuRBpTSoCcQ3U/OgT12cpxR9+AGxRQ+mZRV+AujWWwNQjD vaYQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w21si870982oia.257.2020.03.11.02.44.00; Wed, 11 Mar 2020 02:44:13 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728263AbgCKJm1 (ORCPT + 99 others); Wed, 11 Mar 2020 05:42:27 -0400 Received: from jabberwock.ucw.cz ([46.255.230.98]:48988 "EHLO jabberwock.ucw.cz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726160AbgCKJm0 (ORCPT ); Wed, 11 Mar 2020 05:42:26 -0400 Received: by jabberwock.ucw.cz (Postfix, from userid 1017) id A7E691C031B; Wed, 11 Mar 2020 10:42:24 +0100 (CET) Date: Wed, 11 Mar 2020 10:42:24 +0100 From: Pavel Machek To: =?utf-8?B?TWljaGHFgiBNaXJvc8WCYXc=?= Cc: Pavel Machek , Greg Kroah-Hartman , linux-kernel@vger.kernel.org, stable@vger.kernel.org, Sergey Organov , Felipe Balbi , Sasha Levin Subject: Re: [PATCH 4.19 12/86] usb: gadget: serial: fix Tx stall after buffer overflow Message-ID: <20200311094223.GA15976@duo.ucw.cz> References: <20200310124530.808338541@linuxfoundation.org> <20200310124531.459641903@linuxfoundation.org> <20200310150834.GA24886@duo.ucw.cz> <20200310225118.GA32479@qmqm.qmqm.pl> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="GvXjxJ+pjyke8COw" Content-Disposition: inline In-Reply-To: <20200310225118.GA32479@qmqm.qmqm.pl> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --GvXjxJ+pjyke8COw Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hi! > > > From: Sergey Organov > > >=20 > > > [ Upstream commit e4bfded56cf39b8d02733c1e6ef546b97961e18a ] > > >=20 > > > Symptom: application opens /dev/ttyGS0 and starts sending (writing) to > > > it while either USB cable is not connected, or nobody listens on the > > > other side of the cable. If driver circular buffer overflows before > > > connection is established, no data will be written to the USB layer > > > until/unless /dev/ttyGS0 is closed and re-opened again by the > > > application (the latter besides having no means of being notified abo= ut > > > the event of establishing of the connection.) > > >=20 > > > Fix: on open and/or connect, kick Tx to flush circular buffer data to > > > USB layer. > >=20 > > > diff --git a/drivers/usb/gadget/function/u_serial.c b/drivers/usb/gad= get/function/u_serial.c > > > index d4d317db89df5..38afe96c5cd26 100644 > > > --- a/drivers/usb/gadget/function/u_serial.c > > > +++ b/drivers/usb/gadget/function/u_serial.c > > > @@ -567,8 +567,10 @@ static int gs_start_io(struct gs_port *port) > > > port->n_read =3D 0; > > > started =3D gs_start_rx(port); > > > =20 > > > - /* unblock any pending writes into our circular buffer */ > > > if (started) { > > > + gs_start_tx(port); > > > + /* Unblock any pending writes into our circular buffer, in case > > > + * we didn't in gs_start_tx() */ > > > tty_wakeup(port->port.tty); > >=20 > > I'm confused. gs-start_tx() is done twice in a row. Its return > > convention seem to be 0 in success case, and non-zero on failure. But > > it is assigned to variable called "started", which does not sound like > > "error" to me. > >=20 > > Are you sure this is correct? >=20 > The function before 'if (started)' is gs_start_rx() - it's RX not > TX. Aha, I missed that, sorry for the noise. Best regards, Pavel --=20 DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany --GvXjxJ+pjyke8COw Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iF0EABECAB0WIQRPfPO7r0eAhk010v0w5/Bqldv68gUCXmiyfwAKCRAw5/Bqldv6 8pr/AJ9aSgvJ5WVI5DzY9pWECe0/+CVTOgCgjReT0Iys54B1ezCHTMyeB2GZffM= =+MLw -----END PGP SIGNATURE----- --GvXjxJ+pjyke8COw--