From: Peter Chen <hzpeterchen@gmail.com>
To: Baolin Wang <baolin.wang@linaro.org>
Cc: Greg KH <gregkh@linuxfoundation.org>,
stefan.koch10@gmail.com, Alan Stern <stern@rowland.harvard.edu>,
Oliver Neukum <oneukum@suse.com>,
falakreyaz@gmail.com, Mark Brown <broonie@kernel.org>,
USB <linux-usb@vger.kernel.org>,
LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] usb: core: Add runtime resume checking
Date: Wed, 10 Aug 2016 14:18:01 +0800 [thread overview]
Message-ID: <20160810061801.GA1412@shlinux2> (raw)
In-Reply-To: <CAMz4kuKH_gvyObrthqvyWPN0x+62pLq-F0Fk-08Jk0Er5-Pv6Q@mail.gmail.com>
On Wed, Aug 10, 2016 at 10:33:31AM +0800, Baolin Wang wrote:
> Hi Greg,
>
> On 9 August 2016 at 18:26, Greg KH <gregkh@linuxfoundation.org> wrote:
> > On Tue, Aug 09, 2016 at 05:33:33PM +0800, Baolin Wang wrote:
> >> When the usb device has entered suspend state by runtime suspend method, and
> >> the sustem also try to enter suspend state by issuing usb_dev_suspend(), it
> >> will issue pm_runtime_resume() function to deal with wrong wakeup setting in
> >> choose_wakeup() function.
> >>
> >> But if usb device resumes failed due to xhci has been into suspend state and
> >> hardware is not accessible, which will set runtime errors. Thus when there is
> >> slave attached, usb device will resume failed by runtime resume method due to
> >> previous runtime errors.
> >
> > I really can't parse the first sentance in this paragraph, what exactly
> > makes xhci so "unique" here?
>
> Sorry for confusing, I try to explain it clearly. Considering strict
> power management for mobile device, we should also power off the usb
> controller if there are no slaves attached even though it is usb host
> function.
>
> For example: No slave attached----> usb interface runtime suspend
> ----> usb device runtime suspend -----> xhci suspend -----> power off
> usb controller. After that if the system wants to enter suspend state,
> then it also will issue usb_dev_suspend(), then the
> pm_runtime_resume() function (issued in choose_wakeup() function) will
> return -ESHUTDOWN due to xhci has been suspend and hardware is not
> accessible.
Why the controller does not be resumed when the root hub has issued
runtime resume?
Peter
>
> After system entering resume state, if there is slave attached ---->
> power on usb controller -----> xhci resume -----> usb device runtime
> resume ----> usb interface runtime resume. Usb device will resume
> failed if runtime errors is set (-ESHUTDOWN), thus we should clear the
> runtime errors in choose_wakeup() function to avoid this situation.
>
> >
> >> Then we should check if it resumes successfully in choose_wakeup() function,
> >
> > what is "it"?
>
> It present pm_runtime_resume() issued in choose_wakeup() function.
>
> >
> >> if it failed we should clear the runtime errors by pm_runtime_set_suspended()
> >> function to avoid runtime resume failure.
> >
> > Again, what is "it"?
>
> It present pm_runtime_resume() issued in choose_wakeup() function.
>
> >
> >>
> >> Signed-off-by: Baolin Wang <baolin.wang@linaro.org>
> >> ---
> >> drivers/usb/core/driver.c | 9 +++++++--
> >> 1 file changed, 7 insertions(+), 2 deletions(-)
> >>
> >> diff --git a/drivers/usb/core/driver.c b/drivers/usb/core/driver.c
> >> index dadd1e8d..a1a0f5f 100644
> >> --- a/drivers/usb/core/driver.c
> >> +++ b/drivers/usb/core/driver.c
> >> @@ -1412,6 +1412,7 @@ static int usb_resume_both(struct usb_device *udev, pm_message_t msg)
> >> static void choose_wakeup(struct usb_device *udev, pm_message_t msg)
> >> {
> >> int w;
> >> + int ret;
> >>
> >> /* Remote wakeup is needed only when we actually go to sleep.
> >> * For things like FREEZE and QUIESCE, if the device is already
> >> @@ -1431,8 +1432,12 @@ static void choose_wakeup(struct usb_device *udev, pm_message_t msg)
> >> /* If the device is autosuspended with the wrong wakeup setting,
> >> * autoresume now so the setting can be changed.
> >> */
> >> - if (udev->state == USB_STATE_SUSPENDED && w != udev->do_remote_wakeup)
> >> - pm_runtime_resume(&udev->dev);
> >> + if (udev->state == USB_STATE_SUSPENDED && w != udev->do_remote_wakeup) {
> >> + ret = pm_runtime_resume(&udev->dev);
> >> + if (ret == -ESHUTDOWN)
> >> + pm_runtime_set_suspended(&udev->dev);
> >
> > why is 'ret' needed:
> > if (pm_runtime_resume(&udev->dev) == -ESHUTDOWN)
>
> OK. I can modify it in next version if you agree this patch.
>
> >
> >
> > Why would resume fail?
>
> Like I explained above. Thanks.
>
> --
> Baolin.wang
> Best Regards
> --
> To unsubscribe from this list: send the line "unsubscribe linux-usb" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
--
Best Regards,
Peter Chen
next prev parent reply other threads:[~2016-08-10 19:23 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-08-09 9:33 [PATCH] usb: core: Add runtime resume checking Baolin Wang
2016-08-09 10:26 ` Greg KH
2016-08-10 2:33 ` Baolin Wang
2016-08-10 6:18 ` Peter Chen [this message]
2016-08-10 6:43 ` Baolin Wang
2016-08-10 9:07 ` Peter Chen
2016-08-10 9:35 ` Baolin Wang
2016-08-10 14:25 ` Alan Stern
2016-08-11 3:08 ` Baolin Wang
2016-08-11 6:54 ` Peter Chen
2016-08-11 8:07 ` Baolin Wang
2016-08-11 8:19 ` Peter Chen
2016-08-11 8:41 ` Baolin Wang
2016-08-11 8:44 ` Peter Chen
2016-08-11 9:08 ` Baolin Wang
[not found] ` <20160810081707.GB7753@kroah.com>
2016-08-10 8:23 ` 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=20160810061801.GA1412@shlinux2 \
--to=hzpeterchen@gmail.com \
--cc=baolin.wang@linaro.org \
--cc=broonie@kernel.org \
--cc=falakreyaz@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=oneukum@suse.com \
--cc=stefan.koch10@gmail.com \
--cc=stern@rowland.harvard.edu \
/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