From: "Rafael J. Wysocki" <rjw@sisk.pl>
To: Alan Stern <stern@rowland.harvard.edu>
Cc: Linux-pm mailing list <linux-pm@lists.linux-foundation.org>,
Kevin Hilman <khilman@deeprootsystems.com>,
Partha Basak <p-basak2@ti.com>,
linux-omap@vger.kernel.org
Subject: Re: [PATCH] PM: add synchronous runtime interface for interrupt handlers
Date: Fri, 1 Oct 2010 00:41:26 +0200 [thread overview]
Message-ID: <201010010041.26326.rjw@sisk.pl> (raw)
In-Reply-To: <Pine.LNX.4.44L0.1009301703270.1314-100000@iolanthe.rowland.org>
On Thursday, September 30, 2010, Alan Stern wrote:
> On Thu, 30 Sep 2010, Rafael J. Wysocki wrote:
>
> > > --- usb-2.6.orig/include/linux/pm.h
> > > +++ usb-2.6/include/linux/pm.h
> > > @@ -485,6 +485,7 @@ struct dev_pm_info {
> > > unsigned int run_wake:1;
> > > unsigned int runtime_auto:1;
> > > unsigned int no_callbacks:1;
> > > + unsigned int callbacks_in_irq:1;
> >
> > I kind of don't like this name. What about irq_safe ?
>
> Sure, that's a better name.
>
> > > --- usb-2.6.orig/include/linux/pm_runtime.h
> > > +++ usb-2.6/include/linux/pm_runtime.h
> > > @@ -21,6 +21,7 @@
> > > #define RPM_GET_PUT 0x04 /* Increment/decrement the
> > > usage_count */
> > > #define RPM_AUTO 0x08 /* Use autosuspend_delay */
> > > +#define RPM_IRQ 0x10 /* Don't enable interrupts */
> > >
> > > #ifdef CONFIG_PM_RUNTIME
> > >
> > > @@ -40,6 +41,7 @@ extern int pm_generic_runtime_idle(struc
> > > extern int pm_generic_runtime_suspend(struct device *dev);
> > > extern int pm_generic_runtime_resume(struct device *dev);
> > > extern void pm_runtime_no_callbacks(struct device *dev);
> > > +extern void pm_runtime_callbacks_in_irq(struct device *dev);
> >
> > Perhaps this one can be called pm_runtime_irq_safe() in analogy to the struct
> > member?
>
> Yes.
>
> > Hmm. This looks rather complicated. I don't really feel good about this
> > change. It seems to me that it might be better to actually implement
> > the _irq() helpers from scratch. I think I'll try to do that.
>
> That might work out better, but there will be a substantial amount of
> code duplication. Try it and see how it turns out.
I think you're right, but I'm not sure yet.
> > Overall, it looks like there's some overlap between RPM_IRQ and
> > power.callbacks_in_irq, where the latter may influence the behavior of the
> > helpers even if RPM_IRQ is unset.
>
> Exactly. That was intentional.
>
> > I think we should return error code if RPM_IRQ is used, but
> > power.callbacks_in_irq is not set.
>
> The patch does that.
>
> > If RPM_IRQ is not set, but
> > power.callbacks_in_irq is set, we should fall back to the normal behavior
> > (ie. do not avoid sleeping).
>
> By "do not avoid sleeping", do you mean that
>
> (1) the helper functions should be allowed to sleep, or
>
> (2) the callbacks should be invoked with interrupts enabled?
>
> The patch already does (1). By contrast, (2) isn't safe. It means
> there is a risk of having one thread do a busy-wait with interrupts
> disabled, waiting for another thread that can sleep.
In my opinion the _irq operations should really be one-shot, without
any looping, waking up parents etc. I mean, if the parent is not RPM_ACTIVE,
the _irq resume should immediately fail and analogously for the _irq
suspend. And so on. As simple as reasonably possible.
> > That's why I think it's better to change the name of power.callbacks_in_irq
> > to power.irq_safe.
> >
> > Also I think we should refuse to set power.callbacks_in_irq for a device
> > whose partent (1) doesn't have power.callbacks_in_irq and (2) doesn't
> > have power.ignore_children set , and (3) doesn't have power.disable_depth > 0.
> > Then, once we've set power.callbacks_in_irq for a device, we should take
> > this into consideration when trying to change the parent's settings.
>
> That's not a bad idea, but I don't know if it's necessary in practice.
> With the current patch, if you violate this condition you will simply
> encounter an error when the PM core refuses to resume a sleeping
> parent. Maybe we should allow violations and the resulting refusals
> but print a warning message in the system log.
Yes, see above. I think printing a message in case a suspended parent
prevented an _irq resume from happening, for example, is a good idea.
> > There probably is more subtelties like this, but I can't see them at the moment.
>
> There are some subtle aspects related to the interplay between idle and
> the other callbacks. In principle, the idle and suspend callbacks
> doesn't need to have interrupts disabled -- we don't care if interrupt
> handlers can't do synchronous suspends; they only need synchronous
> resumes. But I wanted to keep things simple, so I treated all the
> callbacks the same.
OK
> Going further, I'm still a little dubious about the whole point of
> having idle notifications at all. I don't see why the PM core can't
> notify a subsystem that a device is idle just by calling the
> runtime_suspend routine.
Well, calling _idle is like saying "I think this device may be idle, please
consider suspending it", while calling _suspend is like saying "suspend
this device unless you can't". I think that's enough of a difference to
have separate _idle.
> The routine doesn't have to suspend if it
> doesn't want to, and it can always schedule a delayed suspend or an
> autosuspend. Maybe you know of a use case where having explicit idle
> notifications really does help, but I can't think of any.
A subsystem or a driver may want to schedule the suspend with a timeout
if _idle is called instead of just suspending synchronously. The r8169 driver
actually does something similar (although a bit more complicated).
> One more thing: I'm not sure we really need the "notify" variable in
> rpm_suspend. When a suspend callback fails, it means the device is in
> use. Whatever is using the device should then be responsible for
> sending its own idle notification when it is finished; we shouldn't
> need to send a notification as soon as the suspend callback fails.
OK, I'm fine with removing it or calling rpm_idle(dev, RPM_ASYNC)
instead of rpm_idle(dev, 0) in there.
Thanks,
Rafael
next prev parent reply other threads:[~2010-09-30 22:42 UTC|newest]
Thread overview: 144+ 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 ` Alan Stern
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 13:57 ` [linux-pm] " Alan Stern
2010-09-27 20:00 ` Rafael J. Wysocki
2010-09-27 20:00 ` [linux-pm] " Rafael J. Wysocki
2010-09-27 20:39 ` Alan Stern
2010-09-27 21:09 ` Rafael J. Wysocki
2010-09-27 21:09 ` [linux-pm] " Rafael J. Wysocki
2010-09-28 14:55 ` Alan Stern
2010-09-28 18:19 ` Rafael J. Wysocki
2010-09-28 18:19 ` [linux-pm] " Rafael J. Wysocki
2010-09-30 18:25 ` [PATCH] PM: add synchronous runtime interface for interrupt handlers Alan Stern
2010-09-30 18:25 ` Alan Stern
2010-09-30 20:15 ` Rafael J. Wysocki
2010-09-30 20:15 ` Rafael J. Wysocki
2010-09-30 21:42 ` Alan Stern
2010-09-30 22:41 ` Rafael J. Wysocki
2010-09-30 22:41 ` Rafael J. Wysocki [this message]
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 14:12 ` Alan Stern
2010-10-02 22:06 ` Rafael J. Wysocki
2010-10-03 15:52 ` Alan Stern
2010-10-03 15:52 ` Alan Stern
2010-10-03 20:33 ` Rafael J. Wysocki
2010-10-03 20:33 ` Rafael J. Wysocki
2010-10-08 23:24 ` PATCH: PM / Runtime: Remove idle notification after failing suspend (was: Re: [linux-pm] [PATCH] PM: add synchronous ...) Rafael J. Wysocki
2010-10-10 20:18 ` PATCH: PM / Runtime: Remove idle notification after failing suspend (was: " Alan Stern
2010-10-10 20:18 ` PATCH: PM / Runtime: Remove idle notification after failing suspend (was: Re: [linux-pm] " Alan Stern
2010-10-08 23:24 ` PATCH: PM / Runtime: Remove idle notification after failing suspend (was: " Rafael J. Wysocki
2010-10-02 22:06 ` [PATCH] PM: add synchronous runtime interface for interrupt handlers Rafael J. Wysocki
2010-10-05 21:44 ` Kevin Hilman
2010-10-06 15:58 ` Alan Stern
2010-10-06 15:58 ` Alan Stern
2010-10-06 19:33 ` Rafael J. Wysocki
2010-10-06 19:33 ` Rafael J. Wysocki
2010-10-06 19:35 ` Kevin Hilman
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 16:52 ` Kevin Hilman
2010-10-07 17:35 ` Alan Stern
2010-10-07 21:11 ` Rafael J. Wysocki
2010-10-07 21:11 ` Rafael J. Wysocki
2010-10-07 23:15 ` Kevin Hilman
2010-10-07 23:15 ` Kevin Hilman
2010-10-07 23:37 ` Rafael J. Wysocki
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 16:22 ` Alan Stern
2010-10-08 21:04 ` Kevin Hilman
2010-10-08 21:04 ` Kevin Hilman
2010-10-08 19:57 ` Rafael J. Wysocki
2010-10-08 19:57 ` Rafael J. Wysocki
2010-10-07 23:55 ` Kevin Hilman
2010-10-08 16:18 ` Alan Stern
2010-10-08 16:18 ` Alan Stern
2010-10-08 19:53 ` Rafael J. Wysocki
2010-10-09 11:09 ` [linux-pm] " Rafael J. Wysocki
2010-10-11 17:00 ` Alan Stern
2010-10-11 17:00 ` [linux-pm] " Alan Stern
2010-10-11 22:30 ` Rafael J. Wysocki
2010-10-11 22:30 ` Rafael J. Wysocki
2010-10-09 11:09 ` Rafael J. Wysocki
2010-10-08 19:53 ` Rafael J. Wysocki
2010-10-07 17:35 ` Alan Stern
2010-10-07 15:26 ` Alan Stern
2010-11-19 15:45 ` [PATCH ver. 2] " Alan Stern
2011-04-11 15:47 ` Sylwester Nawrocki
2011-04-11 16:08 ` Alan Stern
2011-04-11 17:20 ` Sylwester Nawrocki
2011-04-11 18:37 ` Alan Stern
2010-11-19 15:45 ` Alan Stern
2010-11-20 12:56 ` Rafael J. Wysocki
2010-11-20 12:56 ` Rafael J. Wysocki
2010-11-20 16:59 ` Alan Stern
2010-11-20 19:41 ` Alan Stern
2010-11-20 19:41 ` [linux-pm] " Alan Stern
2010-11-21 23:45 ` Rafael J. Wysocki
2010-11-21 23:45 ` [linux-pm] " 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-22 23:01 ` Rafael J. Wysocki
2010-11-23 3:19 ` Alan Stern
2010-11-23 22:51 ` Rafael J. Wysocki
2010-11-23 22:51 ` Rafael J. Wysocki
2010-11-24 0:11 ` Kevin Hilman
2010-11-24 0:11 ` Kevin Hilman
2010-11-24 16:43 ` Alan Stern
2010-11-24 18:03 ` Kevin Hilman
2010-11-24 18:03 ` Kevin Hilman
2010-11-24 16:43 ` Alan Stern
2010-11-24 14:56 ` Alan Stern
2010-11-24 14:56 ` Alan Stern
2010-11-24 20:33 ` Rafael J. Wysocki
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-25 20:03 ` [linux-pm] " Rafael J. Wysocki
2010-11-25 18:58 ` Oliver Neukum
2010-11-26 22:23 ` Rafael J. Wysocki
2010-11-26 22:23 ` Rafael J. Wysocki
2010-11-25 15:52 ` Alan Stern
2010-11-23 3:19 ` [PATCH ver. 2] " Alan Stern
2010-11-22 15:38 ` Alan Stern
2010-11-21 23:41 ` Rafael J. Wysocki
2010-11-20 16:59 ` Alan Stern
2010-10-06 21:47 ` [PATCH] " Rafael J. Wysocki
2010-10-06 23:51 ` Kevin Hilman
2010-10-06 23:51 ` Kevin Hilman
2010-10-06 20:28 ` Alan Stern
2010-10-05 21:44 ` Kevin Hilman
2010-10-01 14:28 ` Alan Stern
2010-09-30 21:42 ` Alan Stern
2010-09-30 21:42 ` Alan Stern
2010-09-30 22:02 ` Rafael J. Wysocki
2010-10-01 14:12 ` Alan Stern
2010-10-01 14:12 ` Alan Stern
2010-10-01 21:14 ` Rafael J. Wysocki
2010-10-01 21:14 ` Rafael J. Wysocki
2010-10-01 22:37 ` [PATCH] PM / Runtime: Reduce code duplication in core helper functions (was: Re: [linux-pm] [PATCH] PM: add synchronous ...) Rafael J. Wysocki
2010-10-02 14:15 ` [PATCH] PM / Runtime: Reduce code duplication in core helper functions (was: " Alan Stern
2010-10-02 14:15 ` [PATCH] PM / Runtime: Reduce code duplication in core helper functions (was: Re: [linux-pm] " Alan Stern
2010-10-01 22:37 ` [PATCH] PM / Runtime: Reduce code duplication in core helper functions (was: " Rafael J. Wysocki
2010-09-28 14:55 ` runtime_pm_get_sync() from ISR with IRQs disabled? Alan Stern
2010-09-27 21:11 ` Kevin Hilman
2010-09-27 21:11 ` [linux-pm] " Kevin Hilman
2010-09-27 20:39 ` Alan Stern
2010-09-24 20:04 ` Rafael J. Wysocki
2010-09-24 20:27 ` [linux-pm] " Alan Stern
2010-09-24 21:52 ` Kevin Hilman
2010-09-24 21:52 ` Kevin Hilman
2010-09-24 20:27 ` Alan Stern
2010-09-24 18:54 ` 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=201010010041.26326.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 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.