Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752319AbcJMHwA (ORCPT ); Thu, 13 Oct 2016 03:52:00 -0400 Received: from mail-yb0-f174.google.com ([209.85.213.174]:35037 "EHLO mail-yb0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751335AbcJMHvv (ORCPT ); Thu, 13 Oct 2016 03:51:51 -0400 MIME-Version: 1.0 In-Reply-To: <87lgxsvi7v.fsf@linux.intel.com> References: <521625dd7f5e335e2a681ec65ebffc5832207e5f.1475570367.git.baolin.wang@linaro.org> <0e1e7e00e3e2aacf0fe0ee91854e6a0ee81cc320.1475570367.git.baolin.wang@linaro.org> <87lgxsvi7v.fsf@linux.intel.com> From: Baolin Wang Date: Thu, 13 Oct 2016 15:51:44 +0800 Message-ID: Subject: Re: [RESEND PATCH v3 2/2] usb: dwc3: Wait for control tranfer completed when stopping gadget To: Felipe Balbi Cc: Greg KH , Mark Brown , USB , LKML Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1328 Lines: 38 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 = !!is_on; >> >> +try_again: >> spin_lock_irqsave(&dwc->lock, flags); >> ret = dwc3_gadget_run_stop(dwc, is_on, false); >> spin_unlock_irqrestore(&dwc->lock, flags); >> >> + if (ret == -EBUSY) { >> + ret = wait_for_completion_timeout(&dwc->ep0_in_setup, >> + msecs_to_jiffies(500)); >> + if (ret == 0) { >> + dev_err(dwc->dev, "timeout to stop gadget.\n"); >> + ret = -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. -- Baolin.wang Best Regards