Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752380AbcJMH7c (ORCPT ); Thu, 13 Oct 2016 03:59:32 -0400 Received: from mga02.intel.com ([134.134.136.20]:39058 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751425AbcJMH72 (ORCPT ); Thu, 13 Oct 2016 03:59:28 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.31,339,1473145200"; d="asc'?scan'208";a="772079884" From: Felipe Balbi To: Baolin Wang Cc: Greg KH , Mark Brown , USB , LKML Subject: Re: [RESEND PATCH v3 2/2] usb: dwc3: Wait for control tranfer completed when stopping gadget In-Reply-To: References: <521625dd7f5e335e2a681ec65ebffc5832207e5f.1475570367.git.baolin.wang@linaro.org> <0e1e7e00e3e2aacf0fe0ee91854e6a0ee81cc320.1475570367.git.baolin.wang@linaro.org> <87lgxsvi7v.fsf@linux.intel.com> Date: Thu, 13 Oct 2016 10:54:54 +0300 Message-ID: <87fuo0vg35.fsf@linux.intel.com> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha256; protocol="application/pgp-signature" Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2600 Lines: 71 --=-=-= Content-Type: text/plain Content-Transfer-Encoding: quoted-printable Hi, Baolin Wang writes: > Hi, > > On 13 October 2016 at 15:08, Felipe Balbi wrote: >> >> Hi, >> >> Baolin Wang writes: >>> @@ -1487,10 +1496,22 @@ static int dwc3_gadget_pullup(struct usb_gadget= *g, int is_on) >>> >>> is_on =3D !!is_on; >>> >>> +try_again: >>> spin_lock_irqsave(&dwc->lock, flags); >>> ret =3D dwc3_gadget_run_stop(dwc, is_on, false); >>> spin_unlock_irqrestore(&dwc->lock, flags); >>> >>> + if (ret =3D=3D -EBUSY) { >>> + ret =3D wait_for_completion_timeout(&dwc->ep0_in_setup, >>> + msecs_to_jiffies(500)); >>> + if (ret =3D=3D 0) { >>> + dev_err(dwc->dev, "timeout to stop gadget.\n"); >>> + ret =3D -ETIMEDOUT; >>> + } else { >>> + goto try_again; >> >> you are not really reading my comments. It's the third time I tell you >> there's no need for try_again. If you can't complete a control transfer >> in 500ms, you already have other issues. Take this thing out of here. > > I think you misunderstood the code. If there is 500ms timeout, we will > return '-ETIMEDOUT' error. If the control transfer is completed before > timeout, we can not just return and we need try again to stop the > gadget, right? Any other good suggestion? Thanks. Yeah, change the patch a bit so you wait for completion before calling dwc3_gadget_runt_stop()? I mean, move the !is_on && ep0_state check before calling dwc3_gadget_run_stop() and wait_for_completion_timeout() there. =2D-=20 balbi --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIcBAEBCAAGBQJX/z3OAAoJEMy+uJnhGpkGxjoQAM5BcpyKACCTDnfibGi3+LoP uF/Y/jApVjHCAZEuV/tPBGb84OtocIAKdE/Fq/hN2mXdqPlKNfMOsvDVhuUALMnM qlV6C0ibbcBtvZFGnVtpy77rRhFM71epwhZYSDyoaId5/NFYJX744bPKTdY4VFgR MeGv4UtDJvhFY4Q6+d7P4O5LFKbLQtoyatxkRqyb5VuwYmQvIojLCqguLSChZcNY g+fvYmfw3u4aB7GfIVUeuowrdkz7JLgiwQIYzwWha5MpgLKzjfoW8kCCFifAfO+G bZJ6O/MgzNlH7+YusCRKC2Q87ubDiBnfAOF3uVyKAYsv3EXYYcVqcWM9MXEkPPGf qzK3Xz4ndWpBQH5/XdEV6reSPqNOsHc78KTU6uDLJywKX2xuPo0H3fSzu+hdwT2N wBcc7rrQKLpfNKF6Xw3fESRr9Ini8h8vW7iVnqUxy7uEtrMkr2DpinjVsMP5Q6Vx JQWxxI6/QtobbM84hmSc56ywXl9vXKkzKNlw9NgAK2AbV+GUM4meS8LJXhylc+H7 fsJOfsHOqr+egtG8v2iqg9QeBcBJ0+Ffhmgu0LE8N15K0gMVyiFapUvLyj9cmMXs /W8rFBBC2TsjhS4vTva5Kb2HJOtcWidnLB7OxNL2HNTVD0mXj3aUXPpQ49s5GIcs UYTZQ1Bj3rOTYcoZjf3P =QrUi -----END PGP SIGNATURE----- --=-=-=--