devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Thierry Reding <thierry.reding@gmail.com>
To: Ulf Hansson <ulf.hansson@linaro.org>
Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>,
	Len Brown <len.brown@intel.com>, Pavel Machek <pavel@ucw.cz>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	"linux-pm@vger.kernel.org" <linux-pm@vger.kernel.org>,
	"linux-arm-kernel@lists.infradead.org"
	<linux-arm-kernel@lists.infradead.org>,
	ACPI Devel Maling List <linux-acpi@vger.kernel.org>,
	Geert Uytterhoeven <geert+renesas@glider.be>,
	Kevin Hilman <khilman@linaro.org>,
	Alan Stern <stern@rowland.harvard.edu>,
	Daniel Lezcano <daniel.lezcano@linaro.org>,
	Tomasz Figa <tomasz.figa@gmail.com>,
	"devicetree@vger.kernel.org" <devicetree@vger.kernel.org>,
	Linus Walleij <linus.walleij@linaro.org>,
	Simon Horman <horms@verge.net.au>,
	Magnus Damm <magnus.damm@gmail.com>,
	Ben Dooks <ben-linux@fluff.org>,
	Kukjin Kim <kgene.kim@samsung.com>,
	Stephen Boyd <sboyd@codeaurora.org>,
	Philipp Zabel <philipp.zabel@gmail.com>Mark Brown <br>
Subject: Re: [PATCH v5 00/11] PM / Domains: Generic OF-based support
Date: Thu, 25 Sep 2014 18:56:26 +0200	[thread overview]
Message-ID: <20140925165625.GC30382@ulmo> (raw)
In-Reply-To: <CAPDyKFp8oK6KAujU44NEwT2vL2_BBPSMuGPkyppHdonPfOmUrQ@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 4193 bytes --]

On Thu, Sep 25, 2014 at 05:29:10PM +0200, Ulf Hansson wrote:
> On 25 September 2014 13:21, Thierry Reding <thierry.reding@gmail.com> wrote:
> > I just noticed these patches because they conflicted with some of the
> > local patches I had to add a very similar framework. One of the reasons
> > why I hadn't posted these publicly yet is because the platform where I
> > want to use this (Tegra) is somewhat quirky when it comes to power
> > domains.
> 
> It's great that more things goes on in this area. :-)
> 
> >
> > On Tegra these domains are called power gates and they currently have
> > their own API. We've been looking at migrating things over to some
> > generic framework for some time and PM domains do seem like a good fit.
> > However one of the quirks regarding these domains on Tegra is that a
> > fixed sequence exists that needs to be respected when enabling or
> > disabling a power partition. The exact sequence can be found in the
> > drivers/soc/tegra/pmc.c driver's tegra_powergate_sequence_power_up()
> > function. Essentially we need to call into the clock and reset drivers
> > at very specific moments during the operations that the PMC does.
> 
> I am not sure I fully understand how the power gating actually
> happens. How is it triggered?

Drivers explicitly call the custom API. So all drivers that need to turn
on power partitions have a call to tegra_powergate_sequence_power_up()
in .probe() and tegra_powergate_power_off() in .remove().

> > One solution to this would be to make the needed clocks and resets
> > available to the power domain driver via DT, but then we have the
> > problem that two drivers would be controlling the same resources. For
> > example drivers could still want to disable the clock for more fine-
> > grained power management.
> 
> Sorry, but I think I need a better understanding to be able to comment.
> 
> But maybe, drivers could implement runtime PM support and define
> runtime PM callbacks. From the callbacks those will handle clocks and
> resets, is not that enough? What more is needed from a PM domain point
> of view?

Let me quote the actual power up sequence code:

	int tegra_powergate_sequence_power_up(int id, struct clk *clk,
					      struct reset_control *rst)
	{
		int ret;

		reset_control_assert(rst);

		ret = tegra_powergate_power_on(id);
		if (ret)
			goto err_power;

		ret = clk_prepare_enable(clk);
		if (ret)
			goto err_clk;

		usleep_range(10, 20);

		ret = tegra_powergate_remove_clamping(id);
		if (ret)
			goto err_clamp;

		usleep_range(10, 20);
		reset_control_deassert(rst);

		return 0;

	err_clamp:
		clk_disable_unprepare(clk);
	err_clk:
		tegra_powergate_power_off(id);
	err_power:
		return ret;
	}
	EXPORT_SYMBOL(tegra_powergate_sequence_power_up);

The critical part is that we need to enable the clock after the
partition has been powered, but before the clamps are removed.
Implementing this with runtime PM support in drivers won't work
because the power domain driver has to do both the powering up
and removing the clamps, so there's no place to inject the call
to enable the clock.

> > Furthermore for some devices it may turn out
> > that turning the domain off and on introduces too much latency to be
> > useful.
> 
> This should be handled by the generic PM domain governor. Through the
> per device QOS, you are able to set latencies constraints which could
> prevent a PM domain from being gated.

Okay, that sounds good.

> > Does anyone have any better ideas on how to make that work with this
> > generic PM domain framework? Or is Tegra just too special to be a good
> > fit?
> 
> I certainly think it's worth a try, I would be surprised if we
> shouldn't be able to address requirements from Tegra.
> 
> As you might have figured out, I am dedicated to improve the generic
> power domain such it could fit more SOCs than today, thus I am also
> hoping for more SOC to start to convert to it.

I do have code that seems to work in most cases without following the
above sequence, but there are no guarantees, so I'm reluctant to make
that change.

Thierry

[-- Attachment #2: Type: application/pgp-signature, Size: 819 bytes --]

  reply	other threads:[~2014-09-25 16:56 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-19 18:27 [PATCH v5 00/11] PM / Domains: Generic OF-based support Ulf Hansson
2014-09-19 18:27 ` [PATCH v5 01/11] PM / Domains: Add a detach callback to the struct dev_pm_domain Ulf Hansson
2014-09-22 11:15   ` Geert Uytterhoeven
2014-09-19 18:27 ` [PATCH v5 02/11] ACPI / PM: Assign the ->detach() callback when attaching the PM domain Ulf Hansson
2014-09-19 18:27 ` [PATCH v5 03/11] PM / Domains: Add generic OF-based PM domain look-up Ulf Hansson
2014-09-19 18:27 ` [PATCH v5 04/11] PM / Domains: Add APIs to attach/detach a PM domain for a device Ulf Hansson
2014-09-22 11:12   ` Geert Uytterhoeven
2014-09-19 18:27 ` [PATCH v5 05/11] drivercore / platform: Convert to dev_pm_domain_attach|detach() Ulf Hansson
     [not found] ` <1411151264-16245-1-git-send-email-ulf.hansson-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2014-09-19 18:27   ` [PATCH v5 06/11] i2c: core: " Ulf Hansson
     [not found]     ` <1411151264-16245-7-git-send-email-ulf.hansson-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2014-09-20 12:23       ` Wolfram Sang
2014-09-20 23:48         ` Rafael J. Wysocki
2014-09-22  9:52         ` Mika Westerberg
2014-09-22 10:00           ` Wolfram Sang
2014-09-19 18:27   ` [PATCH v5 07/11] mmc: sdio: " Ulf Hansson
2014-10-02  0:27     ` Dmitry Torokhov
2014-10-13  2:48       ` Aaron Lu
2014-10-13 11:44         ` Ulf Hansson
2014-09-19 18:27   ` [PATCH v5 10/11] ARM: exynos: Move to generic PM domain DT bindings Ulf Hansson
2014-09-19 18:27 ` [PATCH v5 08/11] spi: core: Convert to dev_pm_domain_attach|detach() Ulf Hansson
2014-09-19 18:27 ` [PATCH v5 09/11] amba: Add support for attach/detach of PM domains Ulf Hansson
2014-09-19 18:27 ` [PATCH v5 11/11] ACPI / PM: Convert acpi_dev_pm_detach() into a static function Ulf Hansson
2014-09-19 18:48 ` [PATCH v5 00/11] PM / Domains: Generic OF-based support Dmitry Torokhov
2014-09-22 14:19   ` Rafael J. Wysocki
2014-09-22 19:04     ` Ulf Hansson
2014-09-23  1:42     ` Mark Brown
2014-09-24 12:44     ` Grygorii Strashko
2014-09-24 13:51       ` Rafael J. Wysocki
2014-09-24 13:59         ` Grygorii Strashko
2014-09-25 11:21 ` Thierry Reding
2014-09-25 15:29   ` Ulf Hansson
2014-09-25 16:56     ` Thierry Reding [this message]
2014-09-26  0:27       ` Stephen Boyd
2014-09-26  5:08         ` Kevin Hilman
2014-09-26  7:44         ` Thierry Reding
2014-09-25 22:45   ` Kevin Hilman
2014-09-26  7:31     ` Thierry Reding
2014-09-26  8:06       ` Geert Uytterhoeven
2014-09-26  9:56         ` Thierry Reding
2014-09-26 10:01           ` Geert Uytterhoeven
2014-09-26 10:04             ` Thierry Reding
2014-09-26 14:50       ` 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=20140925165625.GC30382@ulmo \
    --to=thierry.reding@gmail.com \
    --cc=ben-linux@fluff.org \
    --cc=daniel.lezcano@linaro.org \
    --cc=devicetree@vger.kernel.org \
    --cc=geert+renesas@glider.be \
    --cc=gregkh@linuxfoundation.org \
    --cc=horms@verge.net.au \
    --cc=kgene.kim@samsung.com \
    --cc=khilman@linaro.org \
    --cc=len.brown@intel.com \
    --cc=linus.walleij@linaro.org \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=magnus.damm@gmail.com \
    --cc=pavel@ucw.cz \
    --cc=philipp.zabel@gmail.com \
    --cc=rjw@rjwysocki.net \
    --cc=sboyd@codeaurora.org \
    --cc=stern@rowland.harvard.edu \
    --cc=tomasz.figa@gmail.com \
    --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).