From: "Rafael J. Wysocki" <rjw@sisk.pl>
To: Alan Stern <stern@rowland.harvard.edu>
Cc: Kevin Hilman <khilman@deeprootsystems.com>,
Linux-pm mailing list <linux-pm@lists.linux-foundation.org>,
Partha Basak <p-basak2@ti.com>,
linux-omap@vger.kernel.org
Subject: Re: [PATCH] PM: add synchronous runtime interface for interrupt handlers
Date: Fri, 8 Oct 2010 21:53:35 +0200 [thread overview]
Message-ID: <201010082153.35192.rjw@sisk.pl> (raw)
In-Reply-To: <Pine.LNX.4.44L0.1010081200200.27105-100000@netrider.rowland.org>
On Friday, October 08, 2010, Alan Stern wrote:
> On Thu, 7 Oct 2010, Rafael J. Wysocki wrote:
>
> > > If the PM core simply avoids releasing dev->power.lock before
> > > invoking the runtime_suspend or runtime_resume callback, the
> > > end result is almost the same as with busy-waiting.
> >
> > This is slightly more complicated, because suspend is a bit different from
> > resume. I think it's generally acceptable to refuse to do a "fast path" suspend
> > if the device state is not RPM_ACTIVE at the moment, but refusing to do
> > a "fast path" resume may be more problematic (more on that later).
>
> That's what I thought too, but Kevin has suggested this might not be
> so.
>
> > The particular case we need to handle (I think) is that some devices need to be
> > resumed "atomically" as a part of bringing a CPU package out of a C-like-state
> > (Kevin, is that correct?). In that case not only we can't defer the resume (by
> > using a workqueue), but also we have to finish the resume within strict time
> > constraints (the time to leave the given C-like-state is one of the parameters
> > used by cpuidle governors to decide which state to choose).
>
> To what extent can this really happen? If the CPU was previously in a
> C-like state then it couldn't be in the middle of changing the device's
> power state. Maybe a different CPU was suspending or resuming the
> device, but if that's so then why would this CPU need to resume it as
> part of bringing the package out of the C-like state?
That's the case when user space writes to /sys/devices/.../power/control on
another CPU.
> > On the other hand, busy waiting (by looping) in the case the state is
> > RPM_RESUMING is as though the callbacks were executed under a spinlock and we
> > happened to wait on it. I'd prefer to avoid that. Moreover, if the state is
> > RPM_SUSPENDING at the time a "fast path" resume is started, we are almost
> > guaranteed to violate the time constraints (by busy waiting for the suspend to
> > complete and carrying out the resume).
>
> I'm not convinced that the time constraints are all that hard. At
> least, I can't think of a situation where we do face a hard time limit
> and also the device might be in the middle of a transition when we need
> to resume it.
Now that I think of it, you seem to be right.
> > So, here's an idea:
> >
> > First, let's introduce two flags in struct dev_pm_info, irq_safe and
> > fast_resume. The former has to be set so that the things above work.
> >
> > Second, let's add a new flag to pass to __pm_runtime_{suspend|resume}(),
> > RPM_FAST_RESUME such that if it is passed to __pm_runtime_suspend(), it
> > causes fast_resume to be set for the given device (if the status is already
> > RPM_SUSPENDED, it just sets the flag, otherwise it suspends the device
> > normally and then sets the flag). Now, if fast_resume is set,
> > __pm_runtime_resume() has to be passed RPM_FAST_RESUME, or it will
> > fail (it also will fail if passed RPM_FAST_RESUME and fast_resume isn't
> > set). In that case the status has to be RPM_SUSPENDED or RPM_RESUMING
> > (otherwise fast_resume won't be set)
>
> Why not? Does fast_resume ever get cleared?
Yes, when the "fast resume" has completed.
> > and if it is RPM_RESUMING, this means
> > that the other resume has been called with RPM_FAST_RESUME too (it would
> > fail otherwise), so it's fine to busy loop until the status is RPM_SUSPENDED
> > (it's the caller's problem to avoid that). RPM_FAST_RESUME causes
> > __pm_runtime_resume() to avod turning interrupts on.
> >
> > If necessary, there may be a flag for __pm_runtime_suspend() that will
> > carry out "atomic" suspend, but I'm not sure if that's necessary. Kevin?
>
> This seems much more complicated than we need. Why not require for any
> particular device that all resumes and suspends are either always fast
> or always normal (i.e., always done with interrupts disabled or always
> done with interrupts enabled)? That's what the original patch does.
>
> Sure, maybe some devices don't need to have fast suspend all the time.
> But we don't lose anything by requiring them to always use it in order
> to gain the benefit of fast resume.
I think we should avoid turning interrupts off for the whole suspend/resume
time if not strictly necessary.
Thanks,
Rafael
next prev parent reply other threads:[~2010-10-08 19:54 UTC|newest]
Thread overview: 67+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-09-24 0:05 runtime_pm_get_sync() from ISR with IRQs disabled? Kevin Hilman
2010-09-24 15:13 ` [linux-pm] " Alan Stern
2010-09-24 18:54 ` Kevin Hilman
2010-09-24 20:04 ` Rafael J. Wysocki
2010-09-27 13:57 ` Alan Stern
2010-09-27 20:00 ` Rafael J. Wysocki
2010-09-27 20:39 ` Alan Stern
2010-09-27 21:09 ` Rafael J. Wysocki
2010-09-28 14:55 ` Alan Stern
2010-09-28 18:19 ` Rafael J. Wysocki
2010-09-30 18:25 ` [PATCH] PM: add synchronous runtime interface for interrupt handlers Alan Stern
2010-09-30 20:15 ` Rafael J. Wysocki
2010-09-30 21:42 ` Alan Stern
2010-09-30 22:41 ` Rafael J. Wysocki
2010-10-01 14:28 ` Alan Stern
2010-10-01 21:23 ` Rafael J. Wysocki
2010-10-02 14:12 ` Alan Stern
2010-10-02 22:06 ` Rafael J. Wysocki
2010-10-03 15:52 ` Alan Stern
2010-10-03 20:33 ` Rafael J. Wysocki
2010-10-05 21:44 ` Kevin Hilman
2010-10-06 15:58 ` Alan Stern
2010-10-06 19:33 ` Rafael J. Wysocki
2010-10-06 19:35 ` Kevin Hilman
2010-10-06 20:28 ` Alan Stern
2010-10-06 21:47 ` Rafael J. Wysocki
2010-10-07 15:26 ` Alan Stern
2010-10-07 16:52 ` Kevin Hilman
2010-10-07 17:35 ` Alan Stern
2010-10-07 21:11 ` Rafael J. Wysocki
2010-10-07 23:15 ` Kevin Hilman
2010-10-07 23:37 ` Rafael J. Wysocki
2010-10-07 23:55 ` Kevin Hilman
2010-10-08 16:22 ` Alan Stern
2010-10-08 21:04 ` Kevin Hilman
2010-10-08 19:57 ` Rafael J. Wysocki
2010-10-08 16:18 ` Alan Stern
2010-10-08 19:53 ` Rafael J. Wysocki [this message]
2010-10-09 11:09 ` [linux-pm] " Rafael J. Wysocki
2010-10-11 17:00 ` Alan Stern
2010-10-11 22:30 ` Rafael J. Wysocki
2010-11-19 15:45 ` [PATCH ver. 2] " Alan Stern
2010-11-20 12:56 ` Rafael J. Wysocki
2010-11-20 16:59 ` Alan Stern
2010-11-20 19:41 ` [linux-pm] " Alan Stern
2010-11-21 23:45 ` Rafael J. Wysocki
2010-11-21 23:41 ` Rafael J. Wysocki
2010-11-22 15:38 ` Alan Stern
2010-11-22 23:01 ` Rafael J. Wysocki
2010-11-23 3:19 ` Alan Stern
2010-11-23 22:51 ` Rafael J. Wysocki
2010-11-24 0:11 ` Kevin Hilman
2010-11-24 16:43 ` Alan Stern
2010-11-24 18:03 ` Kevin Hilman
2010-11-24 14:56 ` Alan Stern
2010-11-24 20:33 ` Rafael J. Wysocki
2010-11-25 15:52 ` [PATCH ver. 3] " Alan Stern
2010-11-25 18:58 ` [linux-pm] " Oliver Neukum
2010-11-25 20:03 ` Rafael J. Wysocki
2010-11-26 22:23 ` Rafael J. Wysocki
2010-10-06 23:51 ` [PATCH] " Kevin Hilman
2010-09-30 22:02 ` Rafael J. Wysocki
2010-10-01 14:12 ` Alan Stern
2010-10-01 21:14 ` Rafael J. Wysocki
2010-09-27 21:11 ` [linux-pm] runtime_pm_get_sync() from ISR with IRQs disabled? Kevin Hilman
2010-09-24 20:27 ` Alan Stern
2010-09-24 21:52 ` Kevin Hilman
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=201010082153.35192.rjw@sisk.pl \
--to=rjw@sisk.pl \
--cc=khilman@deeprootsystems.com \
--cc=linux-omap@vger.kernel.org \
--cc=linux-pm@lists.linux-foundation.org \
--cc=p-basak2@ti.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;
as well as URLs for NNTP newsgroup(s).