public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "Rafael J. Wysocki" <rjw@sisk.pl>
To: Alan Stern <stern@rowland.harvard.edu>
Cc: Greg KH <gregkh@suse.de>, LKML <linux-kernel@vger.kernel.org>,
	ACPI Devel Maling List <linux-acpi@vger.kernel.org>,
	"Linux-pm mailing list" <linux-pm@lists.linux-foundation.org>,
	Ingo Molnar <mingo@elte.hu>,
	Arjan van de Ven <arjan@infradead.org>
Subject: Re: [patch update] PM: Introduce core framework for run-time PM of I/O devices (rev. 6)
Date: Mon, 29 Jun 2009 17:55:37 +0200	[thread overview]
Message-ID: <200906291755.38232.rjw@sisk.pl> (raw)
In-Reply-To: <Pine.LNX.4.44L0.0906291107040.16597-100000@iolanthe.rowland.org>

On Monday 29 June 2009, Alan Stern wrote:
> On Mon, 29 Jun 2009, Rafael J. Wysocki wrote:
> 
> > > > So, it seems, pm_request_resume() can't kill suspend requests by itself
> > > > and instead it has to queue up resume requests for this purpose, which
> > > > brings us right back to the problem of two requests queued up at a time
> > > > (a delayed suspend request and a resume request that is supposed to cancel it).
> > > 
> > > No, you're trying to do too much.  If the state is RPM_IDLE (i.e., a 
> > > suspend request is pending) then rpm_request_resume doesn't need to do 
> > > anything.  The device is already resumed!  Sure, it can try to kill the 
> > > request and change the state to RPM_ACTIVE, but it doesn't need to.
> > 
> > I think it does need to do that, because the reuqest may be scheduled way
> > in the future and we can't preserve its work structure until it runs.
> > pm_request_resume() doesn't know in advance when the suspend work function is
> > going to be queued up and run.
> 
> It doesn't need to know.  All it needs to do is guarantee that the
> device will be in a resumed state some time not long after the function
> returns.  Thus calling rpm_request_resume while the status is RPM_IDLE
> is like calling it while the status is RPM_ACTIVE.  In neither case
> does it have to do anything, because the device will already be resumed
> when it returns.

Not exactly, because RPM_IDLE prevents idle notifications from being run,
as it means a suspend has already been requested, which is not really the
case after pm_request_resume().

> Perhaps instead we should provide a way to kill a pending suspend
> request?  It's not clear that anyone would need this.  The only reason
> I can think of is if you wanted to change the timeout duration.  But it
> wouldn't be able to run in interrupt context.
> 
> > > Think about it.  Even if the suspend request were killed off, there's 
> > > always the possibility that someone could call rpm_runtime_suspend 
> > > right afterward.  If the driver really wants to resume the device and 
> > > prevent it from suspending again, then the driver should call 
> > > pm_runtime_get before pm_request_resume.  Then it won't matter if the 
> > > suspend request runs.
> > 
> > No, it doesn't matter if the request runs, but it does matter if the work
> > structure used for queuing it up may be used for another purpose. :-)
> 
> What else would it be used for?  If rpm_request_resume returns without 
> doing anything and leaves the status set to RPM_IDLE, then the work 
> structure won't be reused until the status changes.

Which is not right, because we may want to run ->runtime_idle() before
the status is changed.

That's why I think pm_request_resume() should queue up a resume request if
a suspend request is pending.

> > The problem with pm_<something>_put is that it does two things at a time,
> > decrements the resume counter and runs or queues up an idle notification.
> > Perhaps it's a good idea to call it after the second thing and change
> > pm_runtime_get() to pm_runtime_inuse(), so that we have:
> > 
> > * pm_runtime_inuse() - increment the resume counter
> > * pm_runtime_idle() - decrement the resume counter and run idle notification
> > * pm_request_idle()  - decrement the resume counter and queue idle notification
> > 
> > and __pm_runtime_idle() as the "bare" idle notification function?
> 
> I could live with that, but the nice thing about "get" and "put" is
> that they directly suggest a counter is being maintained and therefore
> the calls have to balance.  Maybe we should just call it 
> rpm_request_put and not worry that the put happens immediately.

OK

Best,
Rafael

  reply	other threads:[~2009-06-29 15:55 UTC|newest]

Thread overview: 52+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-06-22 23:21 [PATCH] PM: Introduce core framework for run-time PM of I/O devices (rev. 3) Rafael J. Wysocki
2009-06-23 17:00 ` Rafael J. Wysocki
2009-06-23 17:10 ` Alan Stern
2009-06-24  0:08   ` Rafael J. Wysocki
2009-06-24  0:36     ` [patch update] PM: Introduce core framework for run-time PM of I/O devices (rev. 4) Rafael J. Wysocki
2009-06-24 19:24       ` [patch update] PM: Introduce core framework for run-time PM of I/O devices (rev. 5) Rafael J. Wysocki
2009-06-24 21:30         ` Alan Stern
2009-06-25 16:49           ` [linux-pm] " Alan Stern
2009-06-25 21:58             ` Rafael J. Wysocki
2009-06-25 23:17               ` Rafael J. Wysocki
2009-06-26 18:06               ` Alan Stern
2009-06-26 20:46                 ` [patch update] PM: Introduce core framework for run-time PM of I/O devices (rev. 6) Rafael J. Wysocki
2009-06-26 21:13                   ` Alan Stern
2009-06-26 22:32                     ` Rafael J. Wysocki
2009-06-27  1:25                       ` Alan Stern
2009-06-27 14:51                       ` Alan Stern
2009-06-27 21:51                         ` [patch update] PM: Introduce core framework for run-time PM of I/O devices (rev. 7) Rafael J. Wysocki
2009-06-28 10:25                     ` [patch update] PM: Introduce core framework for run-time PM of I/O devices (rev. 6) Rafael J. Wysocki
2009-06-28 21:07                       ` Alan Stern
2009-06-29  0:15                         ` Rafael J. Wysocki
2009-06-29  3:05                           ` Alan Stern
2009-06-29 14:09                             ` Rafael J. Wysocki
2009-06-29 14:29                               ` Alan Stern
2009-06-29 14:54                                 ` Rafael J. Wysocki
2009-06-29 15:27                                   ` Alan Stern
2009-06-29 15:55                                     ` Rafael J. Wysocki [this message]
2009-06-29 16:10                                       ` Alan Stern
2009-06-29 16:39                                         ` Rafael J. Wysocki
2009-06-29 17:29                                           ` Alan Stern
2009-06-29 18:25                                             ` Rafael J. Wysocki
2009-06-29 19:25                                               ` Alan Stern
2009-06-29 21:04                                                 ` Rafael J. Wysocki
2009-06-29 22:00                                                   ` Alan Stern
2009-06-29 22:50                                                     ` Rafael J. Wysocki
2009-06-30 15:10                                                       ` Alan Stern
2009-06-30 22:30                                                         ` [RFC] Run-time PM framework (was: Re: [patch update] PM: Introduce core framework for run-time PM of I/O devices (rev. 6)) Rafael J. Wysocki
2009-07-01 15:35                                                           ` Alan Stern
2009-07-01 22:19                                                             ` Rafael J. Wysocki
2009-07-02 15:42                                                               ` Rafael J. Wysocki
2009-07-02 15:55                                                               ` Alan Stern
2009-07-02 17:50                                                                 ` Rafael J. Wysocki
2009-07-02 19:53                                                                   ` Alan Stern
2009-07-02 23:05                                                                     ` Rafael J. Wysocki
2009-07-03 20:58                                                                       ` Alan Stern
2009-07-03 23:57                                                                         ` Rafael J. Wysocki
2009-07-04  3:12                                                                           ` Alan Stern
2009-07-04 21:27                                                                             ` Rafael J. Wysocki
2009-07-05 14:50                                                                               ` Alan Stern
2009-07-05 21:47                                                                                 ` Rafael J. Wysocki
2009-06-26 21:49           ` [patch update] PM: Introduce core framework for run-time PM of I/O devices (rev. 5) Rafael J. Wysocki
2009-06-25 14:57         ` Magnus Damm
2009-06-26 22:02           ` Rafael J. Wysocki

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=200906291755.38232.rjw@sisk.pl \
    --to=rjw@sisk.pl \
    --cc=arjan@infradead.org \
    --cc=gregkh@suse.de \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@lists.linux-foundation.org \
    --cc=mingo@elte.hu \
    --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