From: "Henrik Rydberg" <rydberg@euromail.se>
To: Alan Stern <stern@rowland.harvard.edu>
Cc: Matthew Garrett <mjg59@srcf.ucam.org>,
Oliver Neukum <oliver@neukum.org>,
linux-input@vger.kernel.org, dtor@mail.ru
Subject: Re: [PATCH V3] input: Fix USB autosuspend on bcm5974
Date: Thu, 13 Oct 2011 19:21:36 +0200 [thread overview]
Message-ID: <20111013172136.GA2234@polaris.bitmath.org> (raw)
In-Reply-To: <Pine.LNX.4.44L0.1110131134270.2026-100000@iolanthe.rowland.org>
> > I tried the patch out, unfortunately it did not work. The second
> > suspend request returns with a -EINPROGRESS, here:
> >
> > if (dev->power.runtime_status == RPM_SUSPENDING) {
> > DEFINE_WAIT(wait);
> >
> > if (rpmflags & (RPM_ASYNC | RPM_NOWAIT)) {
> > retval = -EINPROGRESS;
> > goto out;
> > }
> >
> > /* Wait for the other suspend running in parallel with us. */
> > for (;;) {
> >
> > The reason is above my horizon, although RPM_ASYNC looks suspicious.
> > In general, we are re-entering rpm_suspend from within the driver
> > handler, so the exit condition of rpm_suspend may not have been
> > satisfied yet.
>
> Ah yes, I vaguely remember thinking that another part would have to be
> fixed. But it's not just the part you identified; the error actually
> occurred higher up. The patch below ought to help.
Yes, this works nicely, thank you. I attached my tested-by at the end,
presuming there will be a formal patch. :-)
> drivers/base/power/runtime.c | 18 ++++++++++++------
> 1 file changed, 12 insertions(+), 6 deletions(-)
>
> Index: usb-3.1/drivers/base/power/runtime.c
> ===================================================================
> --- usb-3.1.orig/drivers/base/power/runtime.c
> +++ usb-3.1/drivers/base/power/runtime.c
> @@ -278,8 +278,9 @@ static int rpm_callback(int (*cb)(struct
> * @rpmflags: Flag bits.
> *
> * Check if the device's runtime PM status allows it to be suspended. If
> - * another suspend has been started earlier, either return immediately or wait
> - * for it to finish, depending on the RPM_NOWAIT and RPM_ASYNC flags. Cancel a
> + * another suspend has been started earlier and the RPM_ASYNC flag isn't set,
> + * either return immediately or wait for it to finish, depending on the
> + * RPM_NOWAIT flag. Cancel a
> * pending idle notification. If the RPM_ASYNC flag is set then queue a
> * suspend request; otherwise run the ->runtime_suspend() callback directly.
> * If a deferred resume was requested while the callback was running then carry
> @@ -311,8 +312,7 @@ static int rpm_suspend(struct device *de
> goto out;
>
> /* If the autosuspend_delay time hasn't expired yet, reschedule. */
> - if ((rpmflags & RPM_AUTO)
> - && dev->power.runtime_status != RPM_SUSPENDING) {
> + if (rpmflags & RPM_AUTO) {
> unsigned long expires = pm_runtime_autosuspend_expiration(dev);
>
> if (expires != 0) {
> @@ -339,10 +339,16 @@ static int rpm_suspend(struct device *de
> /* Other scheduled or pending requests need to be canceled. */
> pm_runtime_cancel_pending(dev);
>
> - if (dev->power.runtime_status == RPM_SUSPENDING) {
> + /*
> + * If the request is synchronous, wait for a concurrent suspend attempt
> + * to finish. Allow asynchronous requests to go through; they will be
> + * cancelled if the concurrent suspend succeeds.
> + */
> + if (dev->power.runtime_status == RPM_SUSPENDING &&
> + !(rpmflags & RPM_ASYNC)) {
> DEFINE_WAIT(wait);
>
> - if (rpmflags & (RPM_ASYNC | RPM_NOWAIT)) {
> + if (rpmflags & RPM_NOWAIT) {
> retval = -EINPROGRESS;
> goto out;
> }
>
Tested-by: Henrik Rydberg <rydberg@euromail.se>
Thanks,
Henrik
next prev parent reply other threads:[~2011-10-13 17:14 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-10-10 15:47 [PATCH V3] input: Fix USB autosuspend on bcm5974 Matthew Garrett
2011-10-10 21:05 ` Henrik Rydberg
2011-10-10 21:12 ` Matthew Garrett
2011-10-10 22:44 ` Henrik Rydberg
2011-10-11 0:11 ` Matthew Garrett
2011-10-11 4:10 ` Oliver Neukum
2011-10-11 11:04 ` Henrik Rydberg
2011-10-11 11:09 ` Oliver Neukum
2011-10-11 20:42 ` Matthew Garrett
2011-10-12 6:32 ` Oliver Neukum
2011-10-12 14:33 ` Alan Stern
2011-10-12 14:37 ` Oliver Neukum
2011-10-12 15:28 ` Alan Stern
2011-10-12 16:16 ` Matthew Garrett
2011-10-12 16:56 ` Oliver Neukum
2011-10-12 16:59 ` Matthew Garrett
2011-10-12 17:24 ` Alan Stern
2011-10-12 17:26 ` Matthew Garrett
2011-10-12 17:41 ` Alan Stern
2011-10-12 18:33 ` Henrik Rydberg
2011-10-12 19:21 ` Alan Stern
2011-10-13 8:20 ` Henrik Rydberg
2011-10-13 15:49 ` Alan Stern
2011-10-13 17:21 ` Henrik Rydberg [this message]
2011-10-12 17:11 ` Oliver Neukum
2011-10-12 19:18 ` Alan Stern
2011-10-11 16:05 ` Dmitry Torokhov
2011-10-11 16:43 ` Alan Stern
2011-10-12 7:03 ` Oliver Neukum
2011-10-12 13:54 ` Matthew Garrett
2011-10-12 14:18 ` Alan Stern
2011-10-12 14:26 ` Matthew Garrett
2011-10-12 14:38 ` Oliver Neukum
2011-10-12 18:50 ` Henrik Rydberg
2011-10-13 6:47 ` Oliver Neukum
2011-10-10 21:16 ` Matthew Garrett
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=20111013172136.GA2234@polaris.bitmath.org \
--to=rydberg@euromail.se \
--cc=dtor@mail.ru \
--cc=linux-input@vger.kernel.org \
--cc=mjg59@srcf.ucam.org \
--cc=oliver@neukum.org \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.