From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756750AbbE2PIP (ORCPT ); Fri, 29 May 2015 11:08:15 -0400 Received: from bear.ext.ti.com ([192.94.94.41]:40445 "EHLO bear.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756721AbbE2PH7 (ORCPT ); Fri, 29 May 2015 11:07:59 -0400 Date: Fri, 29 May 2015 10:05:49 -0500 From: Felipe Balbi To: sundeep subbaraya CC: "balbi@ti.com" , Paul Zimmerman , "linux-kernel@vger.kernel.org" , "linux-usb@vger.kernel.org" Subject: Re: DWC3 linux driver query Message-ID: <20150529150549.GC2026@saruman.tx.rr.com> Reply-To: References: <20150528141147.GC13729@saruman.tx.rr.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="9Ek0hoCL9XbhcSqy" Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --9Ek0hoCL9XbhcSqy Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, May 29, 2015 at 07:01:16PM +0530, sundeep subbaraya wrote: > Hi Felipe, >=20 > On Thu, May 28, 2015 at 7:41 PM, Felipe Balbi wrote: > > Hi, > > > > On Thu, May 28, 2015 at 04:53:09PM +0530, sundeep subbaraya wrote: > >> Hi Felipe and Paul, > > > > btw, Paul has left Synopys :-) >=20 > ahh I see.. > > > >> I am seeing an issue while testing iperf for USB ethernet gadget with > >> dwc3 controller in 2.0 mode. After debugging I figured out that: > >> > >> 1. Network gadget queues say 3 requests. (for IN endpoint) > >> 2. It turns out with req.no_interrupt flag, > >> DWC3 driver issues START_TRANSFER with req0:IOC, req1, req2:LST > >> 3. As per driver state machine, we get XFERNOTREADY then prepare these > >> TRBs and issue start transfer. Make Endpoint state as Busy. > >> 4. Endpoint state is set to free in XFERINPROGRESS or XFERCOMPLETE eve= nt. > >> 5. The issue I see here is there are NAKs going to host (seen in > >> analyzer) in between req0 and req2 hence XFERNOTREADY(Transfer Active) > >> events in between XFERINPROGRESS and XFERCOMPLETE events. > >> 6. As a result, EP is set as free in XFERINPROGRESS, since EP is free > >> start transfer command is issued in XFERNOTREADY handler.The command > >> fails since controller did not release the xfer resource yet. > >> > >> I feel controller behaviour is fine since it sends NAK and writes that > >> event. Driver may have to be modified to make EP as free only in > >> XFERCOMPLETE event handler (ofcourse not for Isoc). > > > > this sounds like the correct solution. > > > >> Note I am testing on a platform which is very slow (the interface > >> between DDR and core runs at 4Mhz). > > > > sweet :-) >=20 > No it is not :) :). I struggled a lot while debugging :( >=20 > > > >> Where as on Zynq (DWC3 in PL), a faster system compared to above one I > > > > hey, when will we see a glue layer for Zynq ? :-) >=20 > we don't have hardware with 2.0 and 3.0 PHY together currently. I will > write and test > once the hardware is ready :) >=20 > > > >> do not see any NAKs in between Start transfer command and XFERCOMPLETE > >> event. > >> > >> What do you guys say? Do you agree linux driver has to be modified or > >> Core should never issue NAKs in between Start transfer and > >> XFERCOMPLETE? > > > > well, if we queued enough transfers, it shouldn't NAK. OTOH, we > > shouldn't allow for a new StartTransfer command until all pending > > requests have been transferred. >=20 > Yes correct but the hardware design is very slow here so hitting this case > > > >> A patch correcting DEPCMD status macros has been applied. Thank you > >> Felipe for trace points in driver otherwise it would have taken very > >> long time to figure out the root cause :) . > > > > yeah, those are really helpful :-) > > > >> Below is the trace log:(enabled only for IN bulk endpoint) > >> > >> irq/97-dwc3-1308 [001] d... 553.713513: dwc3_msg: ep1in-bulk > >> XFERNOTREADY.Transfer Not Active > >> irq/97-dwc3-1308 [001] d... 553.713768: dwc3_msg: ep1in-bulk: > >> req ffffffc039a68580 dma 011c60a2 length 1558 IOC > >> > >> irq/97-dwc3-1308 [001] d... 553.714266: dwc3_msg: ep1in-bulk: > >> req ffffffc039a687c0 dma 011c10a2 length 1558 > >> > >> irq/97-dwc3-1308 [001] d... 553.714753: dwc3_msg: ep1in-bulk: > >> req ffffffc039a68700 dma 011c18a2 length 1558 last IOC > >> > >> irq/97-dwc3-1308 [001] d... 553.717768: dwc3_msg: ep1in-bulk > >> XFERNOTREADY.Transfer Active > >> irq/97-dwc3-1308 [001] d... 553.718203: dwc3_msg: ep1in-bulk E= P BUSY > >> irq/97-dwc3-1308 [001] d... 553.718412: dwc3_msg: ep1in-bulk > >> XFERNOTREADY.Transfer Active > >> irq/97-dwc3-1308 [001] d... 553.718638: dwc3_msg: ep1in-bulk E= P BUSY > >> irq/97-dwc3-1308 [001] d... 553.718837: dwc3_msg: ep1in-bulk > >> XFERNOTREADY.Transfer Active > >> irq/97-dwc3-1308 [001] d... 553.719049: dwc3_msg: ep1in-bulk E= P BUSY > >> irq/97-dwc3-1308 [001] d... 553.719248: dwc3_msg: ep1in-bulk > >> XFERINPROGRESS > >> irq/97-dwc3-1308 [001] d... 553.719520: dwc3_msg: request > >> ffffffc039a68580 from ep1in-bulk completed 1558/1558 =3D=3D=3D> 0 > >> > >> irq/97-dwc3-1308 [001] d... 553.720225: dwc3_msg: ep1in-bulk > >> XFERNOTREADY.Transfer Active > >> irq/97-dwc3-1308 [001] d... 553.720612: dwc3_msg: ep1in-bulk > >> XFERNOTREADY.Transfer Active > >> irq/97-dwc3-1308 [001] d... 553.720826: dwc3_msg: ep1in-bulk E= P BUSY > >> irq/97-dwc3-1308 [001] d... 553.721026: dwc3_msg: ep1in-bulk > >> XFERNOTREADY.Transfer Active > >> irq/97-dwc3-1308 [001] d... 553.721243: dwc3_msg: ep1in-bulk E= P BUSY > >> irq/97-dwc3-1308 [001] d... 553.721446: dwc3_msg: ep1in-bulk > >> XFERCOMPLETE > >> irq/97-dwc3-1308 [001] d... 553.721711: dwc3_msg: request > >> ffffffc039a687c0 from ep1in-bulk completed 1558/1558 =3D=3D=3D> 0 > >> > >> irq/97-dwc3-1308 [001] d... 553.722411: dwc3_msg: request > >> ffffffc039a68700 from ep1in-bulk completed 1558/1558 =3D=3D=3D> 0 > >> > >> irq/97-dwc3-1308 [001] d... 553.722910: dwc3_msg: ep1in-bulk > >> XFERNOTREADY.Transfer Not Active > >> irq/97-dwc3-1308 [001] d... 553.723159: dwc3_msg: ep1in-bulk: > >> req ffffffc039a68ac0 dma 398b18a2 length 1558 > >> > >> irq/97-dwc3-1308 [001] d... 553.723649: dwc3_msg: ep1in-bulk: > >> req ffffffc039a68c40 dma 3a1ce8a2 length 1558 > >> > >> irq/97-dwc3-1308 [001] d... 553.724136: dwc3_msg: ep1in-bulk: > >> req ffffffc039a68580 dma 3cc258a2 length 1558 last > >> > >> irq/97-dwc3-1308 [001] d... 553.724722: dwc3_msg: CMD Error:1 = for ep 3 > >> irq/97-dwc3-1308 [001] d... 553.727245: dwc3_msg: ep1in-bulk > >> XFERNOTREADY.Transfer Active > >> irq/97-dwc3-1308 [001] d... 553.727767: dwc3_msg: CMD Error:1 = for ep 3 > >> irq/97-dwc3-1308 [001] d... 553.728049: dwc3_msg: ep1in-bulk > >> XFERNOTREADY.Transfer Active > >> irq/97-dwc3-1308 [001] d... 553.728394: dwc3_msg: CMD Error:1 = for ep 3 > >> irq/97-dwc3-1308 [001] d... 553.731226: dwc3_msg: ep1in-bulk > >> XFERNOTREADY.Transfer Active > >> irq/97-dwc3-1308 [001] d... 553.731658: dwc3_msg: CMD Error:1 = for ep 3 > > > > Can you try patch below ? > > > > diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c > > index a03a485205c7..cad747865ce0 100644 > > --- a/drivers/usb/dwc3/gadget.c > > +++ b/drivers/usb/dwc3/gadget.c > > @@ -1907,12 +1907,16 @@ static void dwc3_endpoint_transfer_complete(str= uct dwc3 *dwc, > > { > > unsigned status =3D 0; > > int clean_busy; > > + u32 is_xfer_complete; > > + > > + is_xfer_complete =3D (event->endpoint_event =3D=3D DWC3_DEPEVT_= XFERCOMPLETE); > > > > if (event->status & DEPEVT_STATUS_BUSERR) > > status =3D -ECONNRESET; >=20 > > > > clean_busy =3D dwc3_cleanup_done_reqs(dwc, dep, event, status); > > - if (clean_busy) > > + if (clean_busy & (is_xfer_complete || > > + usb_endpoint_xfer_isoc(dep->endpoint.de= sc))) >=20 > works perfect now and it should be &&. > Thanks for the immediate patch. What's next? Shall I send patch for > this or you applied this one already? I'll send this formally and apply for v4.2 merge window with a Cc stable tag. Can I add your Tested-by ? --=20 balbi --9Ek0hoCL9XbhcSqy Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBAgAGBQJVaIBNAAoJEIaOsuA1yqREGkgQAJidzXAIegT6kmA0X+PIiweL C/DbXhN8trLQQRGif+jUuQaalnXkUQiVmAdW28+aTJwSo7ti2/WJmIn00Vy8bl+E Jnv7wayCr2CXIjAZyfBkpLM8ZfO2BICRKEtYkLk6ENNrxE/c8KS6w5TdtiNjw4sp aYx3qISEj0PDGWt6qMGnLOP31TQTn6YNwbwuDB6eLDIveSvIdMc0LIvw6W0HvnAP R0y+rnWhofAqjnAnGUgrpL3IHwDKeZjapP7g6z1fJPpvR/T70fLcfMVcHBpg4a9T f/2NfeIrtviYGTypzwImQ3VdQxNgR/A5WSDp9EfcgN5j33uF968JQfnja1KF873I DVjnwlCSz9Mw11oMw4BXZ6Ur/TVSatY8nI2F6pQUmSIrWQvHW0mTX/1/fjarJEsm +oPcWRMERSZztG5g7wBhIcZXYxS+SjJ9lsnJY5KdZpDh9vgBGgtIGLKalghuEGvj Isey9hPubvLz1qwGLOX569fEXkNZq3m3Yn+ou/J/MOmrIr4uZLKyKvWoxsHORyVO rVdHkd5JAG3ZLNNy8HqSWkLkcSzZpwh1eJduwjj+t8dHJVbbmQxanKP234cgOsqj lZ2dV0cI1VhNQ4yHkbuUYGxnVAwa6HgoE0sDFE0ya3fAHM/+icqAAJFXko7QqFbR OAm7u2XgZ9lVo8NC+UXi =tNz4 -----END PGP SIGNATURE----- --9Ek0hoCL9XbhcSqy--