From: Krzysztof Kozlowski <k.kozlowski@samsung.com>
To: Ulf Hansson <ulf.hansson@linaro.org>
Cc: Alan Stern <stern@rowland.harvard.edu>,
"Rafael J. Wysocki" <rjw@rjwysocki.net>,
"linux-pm@vger.kernel.org" <linux-pm@vger.kernel.org>
Subject: Re: [PATCH v10 1/5] PM / Runtime: Allow accessing irq_safe if no PM_RUNTIME
Date: Wed, 12 Nov 2014 11:44:52 +0100 [thread overview]
Message-ID: <1415789092.4247.6.camel@AMDC1943> (raw)
In-Reply-To: <CAPDyKFqzWvcr7qrnBed=atbtGoUTJ5-8URvn7ZMYJZoZk2+dYw@mail.gmail.com>
On śro, 2014-11-12 at 11:39 +0100, Ulf Hansson wrote:
> On 10 November 2014 19:59, Alan Stern <stern@rowland.harvard.edu> wrote:
> > [CC: list severely trimmed]
> >
> > On Mon, 10 Nov 2014, Ulf Hansson wrote:
> >
> >> >> There are an important advantage of using the pm_runtime_force_suspend() here.
> >> >>
> >> >> For the driver to handle clock gating at system PM suspend, it first
> >> >> needs to bring the device into full power, through
> >> >> pm_runtime_get_sync(). Otherwise it's not safe to gate the clock,
> >> >> since it may already be gated.
> >> >
> >> > That's fine, but it has nothing to do with pm_runtime_force_suspend().
> >> >
> >> > Besides, if the real question is whether or not to gate the clock (or
> >> > in other words, has the clock already been gated), why not just store a
> >> > "clock_is_gated" flag somewhere?
> >>
> >> You could do that, but it's easier to not.
> >
> > I'm not convinced. And you haven't said how this is related to
> > pm_runtime_force_suspend().
> >
> >> You will need to update the runtime PM status and disable runtime PM
> >> anyway, done by the API.
> >
> > So what? And what API are you referring to: the runtime PM API or
> > something else?
>
> Sorry if I was unclear, I was referring to pm_runtime_force_suspend().
>
> >
> > I get the feeling that I'm missing a lot of important points here.
> > What have you left out?
>
> First, this patch which we are discussing is about how the amba
> bus/drivers should cope with irq_safe devices. I think we have already
> solved that through Rafael's latest suggestion.
>
> In principle what you want me to elaborate upon, is why the
> pm_runtime_force_suspend|resume() helpers is a good choice for AMBA
> bus/drivers to use, right?
>
> Indeed the pm_runtime_force_suspend|resume() helpers was discussed
> thoroughly before Rafael, decided to merge them. I do now realize that
> I forgot to add some information about them into the runtime PM
> documentation, my bad. Will fix it soon.
>
> Anyway, this is copied from the function header, which gives you an
> overall idea why they are good for AMBA.
>
> /**
> * pm_runtime_force_suspend - Force a device into suspend state if needed.
> * @dev: Device to suspend.
> *
> * Disable runtime PM so we safely can check the device's runtime PM status and
> * if it is active, invoke it's .runtime_suspend callback to bring it into
> * suspend state. Keep runtime PM disabled to preserve the state unless we
> * encounter errors.
> *
> * Typically this function may be invoked from a system suspend callback to make
> * sure the device is put into low power state.
> */
>
> Since AMBA bus/drivers are handling runtime PM resources like
> clocks/pinctrl/etc from their runtime PM callbacks, using
> pm_runtime_force_suspen|resume() from their system PM callbacks makes
> perfect sense to me.
>
> >
> > As I understand the problem, you've got a bus type where some of the
> > drivers have IRQ-safe runtime PM (and therefore carry out their
> > suspend/resume operations in interrupt context) and others don't. The
> > subsystem core wants to maximize the power saving by deconfiguring some
> > clocks whenever a device is suspended, but this requires a process
> > context and so it can't be done directly when IRQ-safe runtime PM is
> > used.
> >
> > Is that a good summary? If it is, there are ways of dealing with this
>
> Yes.
>
> > that don't involve messing around with the runtime PM internals, or
> > using pm_runtime_force_suspend().
>
> The logic to handle that would in principle mean to keep track of the
> device's runtime PM status. That doesn't make sense, it's the job of
> the runtime PM core to do that!?
>
> Additionally, you would also need to protect the runtime PM resume
> callback from doing clock enable during system PM, unless you also
> disable runtime PM.
>
> To me, pm_runtime_force_suspend|resume() will do exactly what we need
> for the AMBA case.
Hmm... you're saying that runtime resume/suspend could happen during
execution of system resume/suspend callback?
Or maybe the runtime resume callback could be called after suspending
the device but before system sleep finishes?
In pl330 I wanted to do something like:
static int __maybe_unused pl330_suspend(struct device *dev)
{
struct amba_device *pcdev = to_amba_device(dev);
if (!pm_runtime_status_suspended(dev)) {
/* amba did not disable the clock */
amba_pclk_disable(pcdev);
}
amba_pclk_unprepare(pcdev);
return 0;
}
However I still wonder how this is safe against concurrent runtime PM...
Best regards,
Krzysztof
next prev parent reply other threads:[~2014-11-12 10:44 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-11-06 8:36 [PATCH v10 0/5] amba/dmaengine: pl330: add Power Management support Krzysztof Kozlowski
2014-11-06 8:36 ` [PATCH v10 1/5] PM / Runtime: Allow accessing irq_safe if no PM_RUNTIME Krzysztof Kozlowski
2014-11-06 10:00 ` Ulf Hansson
2014-11-06 22:51 ` Rafael J. Wysocki
2014-11-07 8:06 ` Krzysztof Kozlowski
2014-11-07 14:50 ` Alan Stern
2014-11-07 23:45 ` Rafael J. Wysocki
2014-11-10 14:11 ` Ulf Hansson
2014-11-10 16:36 ` Alan Stern
2014-11-10 18:35 ` Ulf Hansson
2014-11-10 18:59 ` Alan Stern
2014-11-12 8:56 ` Krzysztof Kozlowski
2014-11-12 10:39 ` Ulf Hansson
2014-11-12 10:44 ` Krzysztof Kozlowski [this message]
2014-11-12 16:34 ` Alan Stern
2014-11-13 10:22 ` Ulf Hansson
2014-11-13 15:55 ` Alan Stern
2014-11-10 13:38 ` Ulf Hansson
2014-11-10 13:43 ` Srikanth K
2014-11-06 8:36 ` [PATCH v10 2/5] amba: Add helpers for (un)preparing AMBA clock Krzysztof Kozlowski
2014-11-06 8:36 ` [PATCH v10 3/5] amba: Don't unprepare the clocks if device driver wants IRQ safe runtime PM Krzysztof Kozlowski
2014-11-06 10:03 ` Ulf Hansson
2014-11-06 22:52 ` Rafael J. Wysocki
2014-11-07 8:01 ` Krzysztof Kozlowski
2014-11-07 23:52 ` Rafael J. Wysocki
2014-11-06 8:36 ` [PATCH v10 4/5] dmaengine: pl330: add Power Management support Krzysztof Kozlowski
2014-11-06 12:45 ` Vinod Koul
2014-11-06 8:36 ` [PATCH v10 5/5] amba: Remove unused amba_pclk_enable/disable macros Krzysztof Kozlowski
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=1415789092.4247.6.camel@AMDC1943 \
--to=k.kozlowski@samsung.com \
--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 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).