Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753412AbcJMJuI (ORCPT ); Thu, 13 Oct 2016 05:50:08 -0400 Received: from mga14.intel.com ([192.55.52.115]:49446 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752777AbcJMJt7 (ORCPT ); Thu, 13 Oct 2016 05:49:59 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.31,339,1473145200"; d="asc'?scan'208";a="889578449" From: Felipe Balbi To: Baolin Wang , Janusz Dziedzic Cc: Greg KH , Mark Brown , USB , LKML Subject: Re: [RESEND PATCH v3 1/2] usb: dwc3: gadget: Add disconnect checking when changing function dynamically In-Reply-To: References: <521625dd7f5e335e2a681ec65ebffc5832207e5f.1475570367.git.baolin.wang@linaro.org> <87oa2ovicc.fsf@linux.intel.com> Date: Thu, 13 Oct 2016 12:49:08 +0300 Message-ID: <87d1j4vasr.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: 3066 Lines: 82 --=-=-= Content-Type: text/plain Content-Transfer-Encoding: quoted-printable Hi, Baolin Wang writes: >>>>>>> diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c >>>>>>> index 1783406..ca2ae5b 100644 >>>>>>> --- a/drivers/usb/dwc3/gadget.c >>>>>>> +++ b/drivers/usb/dwc3/gadget.c >>>>>>> @@ -241,6 +241,9 @@ int dwc3_send_gadget_ep_cmd(struct dwc3_ep *dep= , unsigned cmd, >>>>>>> int susphy =3D false; >>>>>>> int ret =3D -EINVAL; >>>>>>> >>>>>>> + if (!dwc->pullups_connected) >>>>>>> + return -ESHUTDOWN; >>>>>>> + >>>> >>>> you skip trace_dwc3_gadget_ep_cmd() >>> >>> Yes, we did not need trace here since we did not send out the command. >>> >> What in such case: enumeration will not work and this will be because >> this ESHUTDOWN or wrong pullups_connected usage. Without a trace you >> will not know where the problem is. >> In my opinion this trace could be useful. > > We have returned the '-ESHUTDOWN' error number for user to know what > happened. No, this is actually not good and Janusz has a very valid point here. When we're debugging something in dwc3, we want to rely on tracepoints to tell us what's going on. I don't want to have to add more debugging messages to print out that ESHUTDOWN error just so I can figure out what's going on. You should be patching this in a way that the tracepoint is still printed out properly. Keep in mind that you should be setting ret to -ESHUTDOWN and make sure the trace is printed. Same patch should, then, patch trace.h to handle =2DESHUTDOWN as an error case, i.e. following hunk should be added: diff --git a/drivers/usb/dwc3/debug.h b/drivers/usb/dwc3/debug.h index d93780e84f07..70b783f0507d 100644 =2D-- a/drivers/usb/dwc3/debug.h +++ b/drivers/usb/dwc3/debug.h @@ -319,6 +319,8 @@ static inline const char *dwc3_ep_cmd_status_string(int= status) switch (status) { case -ETIMEDOUT: return "Timed Out"; + case -ESHUTDOWN: + return "Shut Down"; case 0: return "Successful"; case DEPEVT_TRANSFER_NO_RESOURCE: =2D-=20 balbi --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIcBAEBCAAGBQJX/1iUAAoJEMy+uJnhGpkGFzkP/3sDEtV9VzQAinCXMRsBZzhC ZRyl3ag9m3SSlDzFAcUwHbPvf51XLIsI5bEaNxD7vF5I3sk3aL0S6wgIVe7l1mEA eBL/1adFxglIWeCJFTUQnX4h9TgTQ/4zhO2EA0nJd+ik+9WdMynjep34DupWaHMq ceeeszcn/W+EuD6SWDhZ0X141uO6HUH8nLVZs9ts4myaPzqbHkC7e0l5WT0c80LI LDANiBlHryojvc9LRpjKYOjoRNmjGjbtnza81oAKI75vE+pBijTdyuwrPeLscUeH HiRJPpRCokqR8FCNGDKctZmljd2paEp+sGYyupypHuIlTgWXSJiEkzQXSb9ZKeuw FrNs1ZonUW1e9ecRSouNK9y/QVahodmzxphwi4xNrVvwaaQAHDtJWt3HzThgi2YM jo0ZMpwhyx1as9M5wq3r5zRwuLEUrnURJuIoESbJ5sLEN6q9QXZ2N2mtP7YGNOag nGWpANl+wbKYISuxh8E4CHcVreMTuiSYSoHIEjp/5bMzoaGHyGBuWq3MqiNRFYEH F6t2v9Hw2Pu0ImDlEBT2Cgi21Um+aZ90+LK7wJaUW53W3+Xc2N8Z2lV6aLxcdD/6 vrK2z3+2cqmqCdTellF/cqbpz4IzbEGcAMNyEUPegkgqon1nwT2jAGHRQfxQl+mQ gdIRyoD+9IjyJTMOij2g =wVyN -----END PGP SIGNATURE----- --=-=-=--