Received: by 2002:ab2:6203:0:b0:1f5:f2ab:c469 with SMTP id o3csp2965455lqt; Tue, 23 Apr 2024 07:04:04 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCU2FEwSmp8RhypxBFyKVCswAVbLq8TSUB/NHdpdCOBNg7STZy1uKzuFD7NWqZeQoIbp/Ju5U7/Ok3NsVkaX4h1i6h67TzDH8grulpYeQQ== X-Google-Smtp-Source: AGHT+IHd9+KM6fye+5Xagp5Nhke3Kq3ixTpXbZN2DvMyBa6WB9ZyjQ90mmkpNGKE3lRFZbWbJgR7 X-Received: by 2002:a17:902:f68f:b0:1e3:cdd1:dd80 with SMTP id l15-20020a170902f68f00b001e3cdd1dd80mr15713249plg.6.1713881043936; Tue, 23 Apr 2024 07:04:03 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713881043; cv=pass; d=google.com; s=arc-20160816; b=pBy2Vw9DSN7YvDsj0KYYijU/8QGQU25nVkw8Ey86GfrBFc9KIO4d5CNfKvMumsMRm8 KxdCmHa04lFCwuQH1Qen06K/LYujIj926e5+CI3Iy9fk18vT/sPxbRXHsX/M2P4XTw+L AyGaUbFH2XKID/zWsGPi2z3qMKxNo4pgoQPTYJPeJgKExxFxTVnWhiUEFxnSKV5gm5Za zvxHzOmtIlg/B75ckHOig9oBVxsEcL3R1I7ze6UudY9y3F7frl0TMg+oEbkqZn6ZDtrq QfVnTqkaq3WsSd67mQAz4CpYj58tiJCwGDyUnSAM54/qLiN5kCeS7qlOJZvBE5tfBLfK zbRA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date; bh=aBmL1J4yQsdKrVHYVgsXR5WR1JN4yvqqv7O7CEw4850=; fh=guViJ9BZ/BZld+F4SlQ3xQ8Z1Iq9FdQjsus6xCQEle8=; b=tw5jZaan17SS3njFpgIsXJqFGGxiyzd45DSFRU23RbYBcYLEgG/0y+MYQyDamLMccW 4bJNG6sJjo0acjb91fS0erczqKUGDSXF4tp0/5j3tM7vLTksDMEnQ833T6Ru2i+XwZmS u+vssM0BuRrGbbnmEJO175knEUguzfBA4AfwkCGHnyIglo6KcFyiyYJ79FGY1BwL4+Tf uhJr4PV1HN7SJesTF3lQwm7i2VVaYjJrCIj4kFOjlsW5Jpm6HJGfhfjjuxjb7iC7uGty Gz3y8ocgthpyr3WkdudW6zJk527ERz+LLdch1Fho3gyZZnRiK2eYLmM2cCIqnx7vbZ7G CSdg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=pengutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-155293-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-155293-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id h2-20020a170902f54200b001e587cae58dsi9627060plf.638.2024.04.23.07.04.03 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Apr 2024 07:04:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-155293-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=pengutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-155293-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-155293-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 7BF05B22E9C for ; Tue, 23 Apr 2024 13:38:10 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1BE08136989; Tue, 23 Apr 2024 13:38:02 +0000 (UTC) Received: from metis.whiteo.stw.pengutronix.de (metis.whiteo.stw.pengutronix.de [185.203.201.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BF164135A61 for ; Tue, 23 Apr 2024 13:37:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.203.201.7 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713879481; cv=none; b=fLrhqycjjGbLgjhCnHPdwQ3KOgBbTojQVzK4qAIq2Q0qPZe1uxxuOAE8uuncpmAWEPNzAVMdXfWx0xJzg2Z1NX0nQAcInJP4EAh+lB63BFGRb+UvTDC6gmB5ozh2gPnOI/2P5YSGaSq2xGYMXgfpzi4rJXNm9W2/e1fBl0unE5I= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713879481; c=relaxed/simple; bh=69jnoKvvCDmMn/lAjGuLECv91VIAAt67LYlGv0q5hNI=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=BwfcsRdQcTt3EXMrSHo+p6m3VuRWyQtSsXrkCLNs/WDduNVGMrMa0v82WvpA3dguXXFMe4YlP+mCyRc9iP5g8iLl1YaOViPqGLQOZfndxskcIuyANmFB80yeep0iE5oqL6uU9Tc9Wf4V0gjzg8naWbpUaXsI9U8F8y9qMA4V72Q= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pengutronix.de; spf=pass smtp.mailfrom=pengutronix.de; arc=none smtp.client-ip=185.203.201.7 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pengutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pengutronix.de Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.whiteo.stw.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rzGLJ-0000Fg-JC; Tue, 23 Apr 2024 15:37:53 +0200 Received: from [2a0a:edc0:2:b01:1d::c5] (helo=pty.whiteo.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rzGLI-00Du9u-IJ; Tue, 23 Apr 2024 15:37:52 +0200 Received: from mgr by pty.whiteo.stw.pengutronix.de with local (Exim 4.96) (envelope-from ) id 1rzGLI-009tVB-1Z; Tue, 23 Apr 2024 15:37:52 +0200 Date: Tue, 23 Apr 2024 15:37:52 +0200 From: Michael Grzeschik To: Thinh Nguyen Cc: Greg Kroah-Hartman , "linux-usb@vger.kernel.org" , "linux-kernel@vger.kernel.org" Subject: Re: [PATCH v2] usb: dwc3: gadget: check drained isoc ep Message-ID: References: <20240307-dwc3-gadget-complete-irq-v2-1-8c5e9b35f7b9@pengutronix.de> <20240402230555.xgt5uilc42diyr4m@synopsys.com> <20240402231848.4hzzrxegjrcmdab2@synopsys.com> <20240404002906.wk6xbz2wp2tf2xwn@synopsys.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="M6Szu+DUfPV4wPeQ" Content-Disposition: inline In-Reply-To: <20240404002906.wk6xbz2wp2tf2xwn@synopsys.com> X-Sent-From: Pengutronix Hildesheim X-URL: http://www.pengutronix.de/ X-Accept-Language: de,en X-Accept-Content-Type: text/plain X-SA-Exim-Connect-IP: 2a0a:edc0:0:c01:1d::a2 X-SA-Exim-Mail-From: mgr@pengutronix.de X-SA-Exim-Scanned: No (on metis.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org --M6Szu+DUfPV4wPeQ Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hi Thinh, On Thu, Apr 04, 2024 at 12:29:14AM +0000, Thinh Nguyen wrote: >On Tue, Apr 02, 2024, Thinh Nguyen wrote: >> On Tue, Apr 02, 2024, Thinh Nguyen wrote: >> > My concern here is for the case where transfer_in_flight =3D=3D true a= nd >> >> I mean transfer_in_flight =3D=3D false >> >> > list_empty(started_list) =3D=3D false. That means that the requests in= the >> > started_list are completed but are not given back to the gadget driver. >> > >> > Since they remained in the started_list, they will be resubmitted again >> > on the next usb_ep_queue. We may send duplicate transfers right? > >Actually, since the requests are completed, the HWO bits are cleared, >nothing is submitted and no duplicate. But since the requests are not >given back yet from the started_list, then the next Start_Transfer >command will begin with the TRB address of the completed request >(HWO=3D0), the controller may not process the next TRBs. Have you tested >this scenario? > >> > >> > You can try to cleanup requests in the started_list, but you need to be >> > careful to make sure you're not out of sync with the transfer completi= on >> > events and new requests from gadget driver. >> > > >Was the problem you encounter due to no_interrupt settings where the >it was set to the last request of the uvc data pump? > >if that's the case, can UVC function driver make sure to not set >no_interrupt to the last request of the data pump from the UVC? Actually no. What I want to do is to ensure that the dwc3 stream is stopped when the hardware was drained. Which is a valid point in my case. Since we are actually potentially enqueueing new request in the complete handler, be it zero length or real transfers. Calling kick_transfer on an drained hw will absolutely run into missed isocs if the irq thread was called late. We saw this on real hardwar= e, where another irq_thread was scheduled with the same priority as the dwc3 irq_thread but was running so long that the HW was running dry in between the hw irq and the actual dwc3_irq_thread run. Michael --=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 | --M6Szu+DUfPV4wPeQ Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEElXvEUs6VPX6mDPT8C+njFXoeLGQFAmYnuawACgkQC+njFXoe LGT/DxAAwz6KulNc5KIUpueaEMu7WCq3l/4Bf+MoO37W9b1F8VVNE2jwZaLn/8iO rYUEIyJ6yqeiB4PrT3oBUwmqXQ39xMzzPqeFYwNA9WOa9e2vBVNE9ZesNpZVra/Q uNEoMVN56nWz2kIRLhl5egV5t96GGQMI4zi6UQx8OHXK6zKbhJcNh5zrDZT6gbRi X2MDOKF2TS9jrJK8TyU+gtbyjPdcrgmKfhv/XYmk3KaMBnVMx9EFoevQ+n2Vl6Nn 51qkbjEooQ4uma+IitEI6tLjaytCOq57JPkMOUqArzXyhDyAhzmo8Lj0RDAhfFus TFk1TP6ee30tT4+Wvn6x8zD4FdOwqhYhaDfqRhmwdTGuAZ4bjGbsYhn/IT3PSNGF VyA1XiBqd+aqqBoxqTqMUChZ/uXjxqnJSjryCdwkNjHbxxkjoA9WWPE3QyBZXewn oEKaNC7G34SiyqubGuLinDBD9Q6gbtNSxCSxCdAEOWKUfI6NVjwr9Dve7dhpTlAu EqfJJu+Ittz3kB5qddDV43OVc7tpv2Tl6t04gyIuiNyoWxY0InHVJUhYW8hXFle7 EaRn10m7ApNsKmF3Xmixw1uO6qp/Op4F2lvFIgNgkOowrm+zLWUULeR8RFx/HvWR b5cfRa47S0aUYmloKE93BoH7hN5S/JQ8fNzT+C3ljMr/eL3cEt0= =kvaR -----END PGP SIGNATURE----- --M6Szu+DUfPV4wPeQ--