Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754230AbcJMLSg (ORCPT ); Thu, 13 Oct 2016 07:18:36 -0400 Received: from mail-oi0-f50.google.com ([209.85.218.50]:34484 "EHLO mail-oi0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754119AbcJMLS2 (ORCPT ); Thu, 13 Oct 2016 07:18:28 -0400 MIME-Version: 1.0 In-Reply-To: References: <521625dd7f5e335e2a681ec65ebffc5832207e5f.1475570367.git.baolin.wang@linaro.org> <87oa2ovicc.fsf@linux.intel.com> <87d1j4vasr.fsf@linux.intel.com> From: Janusz Dziedzic Date: Thu, 13 Oct 2016 13:16:52 +0200 Message-ID: Subject: Re: [RESEND PATCH v3 1/2] usb: dwc3: gadget: Add disconnect checking when changing function dynamically To: Baolin Wang Cc: Felipe Balbi , Greg KH , Mark Brown , USB , LKML Content-Type: text/plain; charset=UTF-8 X-DomainID: tieto.com Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2667 Lines: 74 On 13 October 2016 at 12:41, Baolin Wang wrote: > On 13 October 2016 at 17:49, Felipe Balbi wrote: >> >> 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 = false; >>>>>>>>> int ret = -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. > > Fine. Will fix this in next version. > BTW, did you test this patch with device mode? Seems in my setup this fail - DWC3_DEPCMD_SETEPCONFIG for ep0out and gadget_start() failed (enumeration fail). Don't we need to queue ep0 cmds before pullup? BR Janusz >> >> 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 >> -ESHUTDOWN 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 >> --- 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: >> >> -- >> balbi > > > > -- > Baolin.wang > Best Regards