From: mturquette@ti.com (Turquette, Mike)
To: linux-arm-kernel@lists.infradead.org
Subject: common clock framework
Date: Fri, 4 May 2012 16:08:20 -0700 [thread overview]
Message-ID: <CAJOA=zOs8FLTRUh=LOd2f=YxFz7Sdxgp2JJurpQkdDFALcCiVw@mail.gmail.com> (raw)
In-Reply-To: <20120504082110.GB16535@pengutronix.de>
On Fri, May 4, 2012 at 1:21 AM, Sascha Hauer <s.hauer@pengutronix.de> wrote:
> On Thu, May 03, 2012 at 07:02:07PM -0700, Chao Xie wrote:
>> Hi,
>> The common clock driver in drivers/clk/ has been integrated into mainline. In fact, I still have some questions to the driver.
>> 1. Why need big lock: enable_lock and prepare_lock?
>> ? ?Using these locks means that the clock enable and prepare operation cannot re-entered.
>
> This has been discussed at length on the list. Short answer is that it's
> not trivial to properly lock the clock tree (or parts thereof) if we have
> individual clock locks. The possibility of having a lock per tree has
> been discussed if the single lock approach turns out to be unsufficient.
> This may be added later.
I think it is worth discussing improvements to the locking scheme.
More on that below.
snip
>> 3. how to handle voltage changes in clock framework? ?When some
>> clock's rate is changed, the voltage for the component that using the
>> clock may need changed too. So where to add the voltage change
>> sequence?
>
> Clocks have notifiers attached to them. You can hook yourself into a pre
> rate change (increasing the voltage here) and into a post rate change
> (decreasing the voltage here).
> That said, we are not there yet. Once the clock framework has settled
> and is actually used in SoCs I'm sure somebody will come up with some
> driver which can be passed a freq <-> voltage table for a given
> regulator clock pair.
We are very close. I have been hacking on this in a private branch
and have converted OMAP's CPUfreq driver over to using *only* the the
clock framework for DVFS.
Good news: it works! The CPUfreq driver's .target callback does the
normal rate validation and table lookup to get a good rate for the
CPU, then it simply calls clk_set_rate. The pre- and post-rate-change
notifiers are then fired off. I have added notifier handlers to the
OMAP regulator drivers which use a look-up-table (soon to be converted
to the OPP library) to determine voltage and they simply call
regulator_set_voltage either before or after the clock rate changes,
depending on scaling direction.
Bad news: lockdep gets cranky about possible deadlocks due to holding
prepare_lock and then trying to hold it again in a rate-change
notifier handler (from OMAP's regulator code). Specifically
clk_set_rate holds prepare_lock, and then the i2c message sent to the
PMIC to raise voltage calls clk_prepare as part of the standard
messaging sequence. This is clearly a candidate for a deadlock.
Having clk_set_rate and clk_prepare both hold the same prepare_lock
mutex seems suboptimal, but it is easy. Having reentrant accesses to
the clock tree is going to be hard... I've spent some time thinking
of ways to solve this, but I would appreciate suggestions. I suspect
the exact same case I'm describing above will affect many SoCs.
Regards,
Mike
next prev parent reply other threads:[~2012-05-04 23:08 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-05-04 2:02 common clock framework Chao Xie
2012-05-04 8:21 ` Sascha Hauer
2012-05-04 8:45 ` Chao Xie
2012-05-04 9:15 ` Russell King - ARM Linux
2012-05-04 10:20 ` Sascha Hauer
2012-05-04 23:08 ` Turquette, Mike [this message]
2012-05-05 8:28 ` Sascha Hauer
2012-05-05 17:44 ` Turquette, Mike
2012-05-08 9:01 ` Mark Brown
2012-05-08 17:29 ` Turquette, Mike
[not found] ` <CAG9bXv=T7v_MBUOmCsp4n0SNmYY_DOEkhQXAp0rTGpdi6KkXNA@mail.gmail.com>
2012-05-06 23:49 ` Mike Turquette
2012-05-07 3:49 ` Raul Xiong
[not found] ` <AAD1C6EB06EE3649B35B7E026785068D1A74B2C256@SC-VEXCH2.marvell.com>
[not found] ` <A63A0DC671D719488CD1A6CD8BDC16CF1A0F044EB4@SC-VEXCH4.marvell.com>
[not found] ` <53612FE6B944314AAADB181E45A45B6413D3FF9F37@sc-vexch3.marvell.com>
2012-05-18 8:41 ` Chao Xie
2012-05-22 18:57 ` Mike Turquette
2012-05-22 19:11 ` Mike Turquette
2012-06-14 13:09 ` Lei Wen
[not found] <AAD1C6EB06EE3649B35B7E026785068D1A749F0DB6@SC-VEXCH2.marvell.com>
[not found] ` <CAJOA=zPAy3AV6Dg9sE+fro1ZCmbxeCH8aeR5-YqffZphRkUQMQ@mail.gmail.com>
[not found] ` <AAD1C6EB06EE3649B35B7E026785068D1A749F10CC@SC-VEXCH2.marvell.com>
2012-04-25 4:40 ` Turquette, Mike
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='CAJOA=zOs8FLTRUh=LOd2f=YxFz7Sdxgp2JJurpQkdDFALcCiVw@mail.gmail.com' \
--to=mturquette@ti.com \
--cc=linux-arm-kernel@lists.infradead.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).