All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Rafael J. Wysocki" <rafael@kernel.org>
To: Alan Stern <stern@rowland.harvard.edu>
Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>,
	Linux PM <linux-pm@vger.kernel.org>,
	Douglas Anderson <dianders@chromium.org>,
	LKML <linux-kernel@vger.kernel.org>,
	Ulf Hansson <ulf.hansson@linaro.org>
Subject: Re: [PATCH] PM: runtime: Return -EINPROGRESS from rpm_resume() in the RPM_NOWAIT case
Date: Thu, 22 Sep 2022 21:33:47 +0200	[thread overview]
Message-ID: <CAJZ5v0huvrHrk_8Jh3vWSEx-MEEZcZop_XCZeQ1FcNmD+7xZBQ@mail.gmail.com> (raw)
In-Reply-To: <Yyy4O/NUMSRtCmhI@rowland.harvard.edu>

On Thu, Sep 22, 2022 at 9:32 PM Alan Stern <stern@rowland.harvard.edu> wrote:
>
> On Thu, Sep 22, 2022 at 08:04:40PM +0200, Rafael J. Wysocki wrote:
> > From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> >
> > The prospective callers of rpm_resume() passing RPM_NOWAIT to it may
> > be confused when it returns 0 without actually resuming the device
> > which may happen if the device is suspending at the given time and it
> > will only resume when the suspend in progress has completed.  To avoid
> > that confusion, return -EINPROGRESS from rpm_resume() in that case.
> >
> > Since none of the current callers passing RPM_NOWAIT to rpm_resume()
> > check its return value, this change has no functional impact.
> >
> > Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> > ---
> >  drivers/base/power/runtime.c |    7 +++++--
> >  1 file changed, 5 insertions(+), 2 deletions(-)
> >
> > Index: linux-pm/drivers/base/power/runtime.c
> > ===================================================================
> > --- linux-pm.orig/drivers/base/power/runtime.c
> > +++ linux-pm/drivers/base/power/runtime.c
> > @@ -792,10 +792,13 @@ static int rpm_resume(struct device *dev
> >               DEFINE_WAIT(wait);
> >
> >               if (rpmflags & (RPM_ASYNC | RPM_NOWAIT)) {
>
> Hmmm, and what if a caller sets both of these flags?  I guess in that
> case he gets what he deserves.

Exactly.

> > -                     if (dev->power.runtime_status == RPM_SUSPENDING)
> > +                     if (dev->power.runtime_status == RPM_SUSPENDING) {
> >                               dev->power.deferred_resume = true;
> > -                     else
> > +                             if (rpmflags & RPM_NOWAIT)
> > +                                     retval = -EINPROGRESS;
> > +                     } else {
> >                               retval = -EINPROGRESS;
> > +                     }
> >                       goto out;
> >               }
>
> Acked-by: Alan Stern <stern@rowland.harvard.edu>

Thanks!

  reply	other threads:[~2022-09-22 19:34 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-22 18:04 [PATCH] PM: runtime: Return -EINPROGRESS from rpm_resume() in the RPM_NOWAIT case Rafael J. Wysocki
2022-09-22 19:32 ` Alan Stern
2022-09-22 19:33   ` Rafael J. Wysocki [this message]
2022-09-22 19:43 ` Doug Anderson
2022-09-23 13:25 ` Ulf Hansson
2022-09-23 15:52   ` Rafael J. Wysocki
2022-09-26  9:49     ` Ulf Hansson

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=CAJZ5v0huvrHrk_8Jh3vWSEx-MEEZcZop_XCZeQ1FcNmD+7xZBQ@mail.gmail.com \
    --to=rafael@kernel.org \
    --cc=dianders@chromium.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=rjw@rjwysocki.net \
    --cc=stern@rowland.harvard.edu \
    --cc=ulf.hansson@linaro.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 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.