From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752831AbcERLGp (ORCPT ); Wed, 18 May 2016 07:06:45 -0400 Received: from mail-yw0-f176.google.com ([209.85.161.176]:34766 "EHLO mail-yw0-f176.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751951AbcERLGn (ORCPT ); Wed, 18 May 2016 07:06:43 -0400 MIME-Version: 1.0 In-Reply-To: <8760ubzmve.fsf@linux.intel.com> References: <4d6528e4b742cacf34f384b766a7c3296dfe9dbf.1463134786.git.baolin.wang@linaro.org> <87oa8aqlzh.fsf@linux.intel.com> <87d1oqqhvs.fsf@linux.intel.com> <871t56qg67.fsf@linux.intel.com> <87a8jp15cn.fsf@linux.intel.com> <874m9x11er.fsf@linux.intel.com> <87bn43znc0.fsf@linux.intel.com> <8760ubzmve.fsf@linux.intel.com> Date: Wed, 18 May 2016 19:06:42 +0800 Message-ID: Subject: Re: [PATCH] dwc3: gadget: Defer starting the gadget device until gadget is power on From: Baolin Wang 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 Hi, On 18 May 2016 at 18:22, Felipe Balbi wrote: > > Hi, > > Baolin Wang writes: >>>> @@ -1485,16 +1490,11 @@ static int dwc3_gadget_run_stop(struct dwc3 >>>> *dwc, int is_on, int suspend) >>>> { >>>> u32 reg; >>>> u32 timeout = 500, i; >>>> >>>> + if (pm_runtime_suspended(dwc->dev)) >>>> + return 0; >>>> >>>> (2) >>>> @@ -1748,15 +1754,25 @@ static int dwc3_gadget_start(struct usb_gadget *g, >>>> * even though host mode might be active. Don't actually perform >>>> * device-specific initialization until device mode is activated. >>>> */ >>>> >>>> + if (pm_runtime_suspended(dwc->dev)) { >>>> + spin_unlock_irqrestore(&dwc->lock, flags); >>>> + return 0; >>>> + } >>>> >>>> + ret = __dwc3_gadget_start(dwc); >>>> + if (ret) >>>> + goto err1; >>>> >>>> So I think the dwc3 core can enter suspend mode before gadget function >>>> is ready to call the 'usb_gadget_udc_start()' and >>>> 'usb_udc_connect_control()', then if the dwc3 core has entered >>>> suspended mode, we need to return success when starting the gadget, >>>> and leave the gadget starting action from gadget resume. What do you >>>> think about that? Thanks. >>> >>> Well, if this makes it work properly. Then, yeah; looks okay to me. I'll >>> add this to the patch introducing runtime PM. >> >> OK. > > I've updated the branch with slightly modified version of your > changes. Can you test again just to make sure it still works ? > > Basically, here's what I did: > > on dwc3_gadget_start: > > - __dwc3_gadget_start(dwc); > + if (pm_runtime_active(dwc->dev)) > + __dwc3_gadget_start(dwc); > + Great. > > on run_stop, I kept the same thing. > > you just need to replace "usb: dwc3: implement runtime PM" with the new > version from my branch. Yeah, it can work well on my platform with your new patch. > > cheers > > -- > balbi -- Baolin.wang Best Regards