public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Felipe Balbi <balbi@kernel.org>
To: Baolin Wang <baolin.wang@linaro.org>
Cc: Greg KH <gregkh@linuxfoundation.org>,
	Mark Brown <broonie@kernel.org>, USB <linux-usb@vger.kernel.org>,
	LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] dwc3: gadget: Defer starting the gadget device until gadget is power on
Date: Wed, 18 May 2016 13:22:45 +0300	[thread overview]
Message-ID: <8760ubzmve.fsf@linux.intel.com> (raw)
In-Reply-To: <CAMz4kuJrR2=46GkzX_BfJ2tDsbMxPibGqBQ36whr-PaYUCYHRA@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 1890 bytes --]


Hi,

Baolin Wang <baolin.wang@linaro.org> 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);
+

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.

cheers

-- 
balbi

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 818 bytes --]

  reply	other threads:[~2016-05-18 10:24 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-13 10:24 [PATCH] dwc3: gadget: Defer starting the gadget device until gadget is power on Baolin Wang
2016-05-13 10:40 ` Felipe Balbi
2016-05-13 11:34   ` Baolin Wang
2016-05-13 12:09     ` Felipe Balbi
2016-05-13 12:35       ` Baolin Wang
2016-05-13 12:46         ` Felipe Balbi
2016-05-15  5:24           ` Baolin Wang
2016-05-17  7:56           ` Baolin Wang
2016-05-17  8:00             ` Felipe Balbi
2016-05-17  8:45               ` Baolin Wang
2016-05-17  9:25                 ` Felipe Balbi
2016-05-17 10:47                   ` Baolin Wang
2016-05-18  9:59                     ` Baolin Wang
2016-05-18 10:12                       ` Felipe Balbi
2016-05-18 10:17                         ` Baolin Wang
2016-05-18 10:22                           ` Felipe Balbi [this message]
2016-05-18 11:06                             ` Baolin Wang
2016-05-18 11:21                               ` Felipe Balbi
2016-05-18 11:26                                 ` Baolin Wang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8760ubzmve.fsf@linux.intel.com \
    --to=balbi@kernel.org \
    --cc=baolin.wang@linaro.org \
    --cc=broonie@kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox