Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp2338218ybb; Fri, 27 Mar 2020 03:44:33 -0700 (PDT) X-Google-Smtp-Source: ADFU+vtugGnd3/y2TGFwlvCkb+P980TLvfOTK/mF8beGKHUk75R2LxU6TJKcn0p2zmeNjDAUpbP9 X-Received: by 2002:a9d:d36:: with SMTP id 51mr10173593oti.308.1585305873719; Fri, 27 Mar 2020 03:44:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585305873; cv=none; d=google.com; s=arc-20160816; b=H+g/AGt8+aBOgE6yeQdvdiG2iRqNWzr3PVsXdG49n5xLeanmWRvoXsF1KZoIR4GBqC pAhAe95yMJTl/R6DE8T9GQP4Z2X137oJP3WnSzjpnxatEFEoBAFWCLdgGqjYsF3V+ILT lugr3ZwmJxNO7IidRkBDNEQ2rwOUhMrKtMdqImlY+SzBWgATKkEUl6gh1D+IQkEMGiLB 7yCyXjX5DDtRn/HiyaAeBS+UgKGhoLNMAtni/t2aSyjXazIrKQUqx4utj2KBU4t4iuP5 c9DwuN/fUcKNcxCtZK51FgmY8dFmYm1q+TvZ521yoVQpjUrOIlXb0BNjVZqYaVKFsKN4 94/g== 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=J/jp3hBbJhsxvRCksQl3tQUiOT32IzvVaiZY2tvt8qQ=; b=1GxVV5bRiL1n1dDidMcRUiPkOplfsBXDO12s2J6lU+U3MDYJso665paSuQ4YE6atSI TkJdJS8v1yVeFQSR9vFGWn8zxFss6nT+3rXr3vo1DWooWmzrWSM9bKCtUOtb6QJdmJZj bkVW+1140DB1tuehsqB/eBocVYXqPMQhIkThxHKUB0UGkIrxvwkrMSZQhcoY9oQGHUK2 RTMhHo7UnM0xraOmtf5gyXRRnawRFoCRZf81Aoq/uLW1DYnwKw9D2cdmAn+pnSKRFtqU BpmDHgwodyRX0U7M4w7RswPFC027Nd+UPHm0qdm2GrElsMf6PKGuRMYkmdZoQnMFS4to y6fg== 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 m67si2239999oib.215.2020.03.27.03.44.20; Fri, 27 Mar 2020 03:44:33 -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 S1726439AbgC0Kn7 (ORCPT + 99 others); Fri, 27 Mar 2020 06:43:59 -0400 Received: from metis.ext.pengutronix.de ([85.220.165.71]:58081 "EHLO metis.ext.pengutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726215AbgC0Kn6 (ORCPT ); Fri, 27 Mar 2020 06:43:58 -0400 Received: from ptx.hi.pengutronix.de ([2001:67c:670:100:1d::c0]) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jHmSv-0001Op-Nz; Fri, 27 Mar 2020 11:43:53 +0100 Received: from mgr by ptx.hi.pengutronix.de with local (Exim 4.92) (envelope-from ) id 1jHmSu-0004GC-Gm; Fri, 27 Mar 2020 11:43:52 +0100 Date: Fri, 27 Mar 2020 11:43:52 +0100 From: Michael Grzeschik To: Lars-Peter Clausen Cc: alexandru.Ardelean@analog.com, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, balbi@kernel.org, gregkh@linuxfoundation.org, bigeasy@linutronix.de, m.olbrich@pengutronix.de, kernel@pengutronix.de Subject: Re: [PATCH] usb: dwc3: gadget: don't dequeue requests on already disabled endpoints Message-ID: <20200327104352.GF27849@pengutronix.de> References: <20200327084302.606-1-m.grzeschik@pengutronix.de> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="EDJsL2R9iCFAt7IV" Content-Disposition: inline In-Reply-To: X-Sent-From: Pengutronix Hildesheim X-URL: http://www.pengutronix.de/ X-IRC: #ptxdist @freenode X-Accept-Language: de,en X-Accept-Content-Type: text/plain X-Uptime: 11:40:34 up 36 days, 18:11, 85 users, load average: 0.51, 0.21, 0.14 User-Agent: Mutt/1.10.1 (2018-07-13) X-SA-Exim-Connect-IP: 2001:67c:670:100:1d::c0 X-SA-Exim-Mail-From: mgr@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --EDJsL2R9iCFAt7IV Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Mar 27, 2020 at 10:14:10AM +0100, Lars-Peter Clausen wrote: > On 3/27/20 9:43 AM, Michael Grzeschik wrote: > > dwc3_gadget_ep_disable gets called before the last request gets > > dequeued. > >=20 > > In __dwc3_gadget_ep_disable all started, pending and cancelled > > lists for this endpoint will call dwc3_gadget_giveback in > > dwc3_remove_requests. > >=20 > > After that no list containing the afterwards dequed request, > > therefor it is not necessary to run the dequeue routine. > >=20 > > Signed-off-by: Michael Grzeschik > > --- > > @Lars-Peter Clausen: > >=20 > > This patch addresses the case that not queued requests get dequeued. > > The only case that this happens seems on disabling the gadget. >=20 >=20 > I don't believe it does. Calling usb_ep_dequeue() is not limited to be > called after the endpoint has been disabled. It is part of the API and can > be called at any time. E.g. with function_fs you can abort a queued trans= fer > from userspace at any time. OK, can you give me an Userspace example how to simply trigger the issue. I tried to figure your mentioned function stack but it would be much easier if it could be reproduced. The patch on the other hand can stand on itself, as it then fixes another code path that is much more common. Regads, Michael > >=20 > > drivers/usb/dwc3/gadget.c | 3 +++ > > 1 file changed, 3 insertions(+) > >=20 > > diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c > > index 9a6f741d1db0dc..5d4fa8d6c93e49 100644 > > --- a/drivers/usb/dwc3/gadget.c > > +++ b/drivers/usb/dwc3/gadget.c > > @@ -1609,6 +1609,9 @@ static int dwc3_gadget_ep_dequeue(struct usb_ep *= ep, > > trace_dwc3_ep_dequeue(req); > > + if (!(dep->flags & DWC3_EP_ENABLED)) > > + return 0; > > + > > spin_lock_irqsave(&dwc->lock, flags); > > list_for_each_entry(r, &dep->pending_list, list) { >=20 >=20 >=20 --=20 Pengutronix e.K. | | Steuerwalder Str. 21 | http://www.pengutronix.de/ | 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | --EDJsL2R9iCFAt7IV Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEElXvEUs6VPX6mDPT8C+njFXoeLGQFAl592N0ACgkQC+njFXoe LGQtSw/9FwbQzq60D+PS5pBU5U5GKKy5ji9a4ukn3qdw/DMIYlV8Q6b/upxspaPP g+1LQ/WmyxD+fhu2W9s9ylRvXaLa3ZuDiKDNpaFpt/q9DRM182FDg3pOc1nOAOn2 Rot5Hk2NkrgDwDLRBv45cHT8omfckLTmheZGl0XM5T/rIAsy2Qhr0KmEVYWnUQpy v7COEA3YjfvFQUlLJDz3+ZRkvaWjcyqCVQb2SF9CjINbeO9/DchfubzmXXFH1qA+ 7X8HqM6+t/JJbfmQnp/6HgmCV/kN27EjCZ7xhMNAWW3eYf883g/hmSx5+PmHrsvC HVCCHnlsKA1QnDpTSAX4Tqt7w1kNiWOfrX00q/pH3/VNaS1mK175seUYtm/PlHz6 1QhkxktjPDJFXISHv9ig0wirK6Ox+M6I5QgzPIN7aqjL4Re0GRZQPvYv2EP8u7uf f53+AwhSvPeVunxCFMSDusXgiKhKxEFkyNvSP4HGBC0biZqhjMkMIF3TMuBWx8u0 KRX2l1rnLFxwx4mKXfZ2811nhLB7me5wn6e3nGDC9I113JDEXMb37Yq8O5HxzJ8L ZBSt2XvfeEy6Iut6hmsVCi2c1TdTrKwv8hk1QB3Kb2/6ZCFJoCiqorR2gm6Ul+Rt Y4LbBdRUhR/C7ol6s5iC/NRB5fmw+buTkpUuCRkhqJGdrF5wm04= =3ul1 -----END PGP SIGNATURE----- --EDJsL2R9iCFAt7IV--