linux-acpi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Rafael J. Wysocki" <rjw@rjwysocki.net>
To: Alan Stern <stern@rowland.harvard.edu>
Cc: Linux PM <linux-pm@vger.kernel.org>,
	LKML <linux-kernel@vger.kernel.org>,
	Linux ACPI <linux-acpi@vger.kernel.org>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	"Rafael J. Wysocki" <rafael@kernel.org>,
	Mika Westerberg <mika.westerberg@linux.intel.com>
Subject: Re: [PATCH] PM: sleep: core: Fix the handling of pending runtime resume requests
Date: Mon, 24 Aug 2020 19:31:01 +0200	[thread overview]
Message-ID: <3393548.q2lFjJrsnI@kreacher> (raw)
In-Reply-To: <20200824150421.GD329866@rowland.harvard.edu>

On Monday, August 24, 2020 5:04:21 PM CEST Alan Stern wrote:
> On Mon, Aug 24, 2020 at 03:36:36PM +0200, Rafael J. Wysocki wrote:
> > > Furthermore, by the logic used in this patch, the call to 
> > > pm_wakeup_event() in the original code is also redundant: Any required 
> > > wakeup event should have been generated when the runtime resume inside 
> > > pm_runtime_barrer() was carried out.
> > 
> > It should be redundant in the real wakeup event cases, but it may cause
> > spurious suspend aborts to occur when there are no real system wakeup
> > events.
> > 
> > Actually, the original code is racy with respect to system wakeup events,
> > because it depends on the exact time when the runtime-resume starts.  Namely,
> > if it manages to start before the freezing of pm_wq, the wakeup will be lost
> > unless the driver takes care of reporting it, which means that drivers really
> > need to do that anyway.  And if they do that (which hopefully is the case), the
> > pm_wakeup_event() call in the core may be dropped.
> 
> In other words, wakeup events are supposed to be reported at the time 
> the wakeup request is first noticed, right?

That's correct.

> We don't want to wait until 
> a resume or runtime_resume callback runs; thanks to this race the 
> callback might not run at all if the event isn't reported first.

The callback will run, either through the wq or by the pm_runtime_barrier(),
but if it runs through the wq, pm_runtime_barrier() will return 0 and
pm_wakeup_event() will not called by the core, so it must be called from
elsewhere anyway.

> Therefore the reasoning behind the original code appears to have been 
> highly suspect.

Indeed.

> If there already was a queued runtime-resume request 
> for the device and the device was wakeup-enabled, the wakeup event 
> should _already_ have been reported at the time the request was queued.  
> And we shouldn't rely on it being reported by the runtime-resume 
> callback routine.

Right.

> > > This means that the code could be simplified to just:
> > > 
> > > 	pm_runtime_barrier(dev);
> > 
> > Yes, it could, so I'm going to re-spin the patch with this code simplification
> > and updated changelog.
> > 
> > > Will this fix the reported bug?
> > 
> > I think so.
> 
> Okay, we'll see!

Fair enough!





      reply	other threads:[~2020-08-24 17:31 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-21 17:41 [PATCH] PM: sleep: core: Fix the handling of pending runtime resume requests Rafael J. Wysocki
2020-08-21 19:34 ` Alan Stern
2020-08-24  8:34   ` Mika Westerberg
2020-08-24 13:38     ` Rafael J. Wysocki
2020-08-24 13:59       ` Mika Westerberg
2020-08-24 13:36   ` Rafael J. Wysocki
2020-08-24 15:04     ` Alan Stern
2020-08-24 17:31       ` Rafael J. Wysocki [this message]

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=3393548.q2lFjJrsnI@kreacher \
    --to=rjw@rjwysocki.net \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=mika.westerberg@linux.intel.com \
    --cc=rafael@kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).