From: bilhuang@nvidia.com (Bill Huang)
To: linux-arm-kernel@lists.infradead.org
Subject: [RFC 1/1] clk: Add notifier support in clk_prepare_enable/clk_disable_unprepare
Date: Fri, 15 Mar 2013 19:25:55 -0700 [thread overview]
Message-ID: <1363400755.3875.0.camel@bilhuang-vm1> (raw)
In-Reply-To: <20130315170945.GM4977@n2100.arm.linux.org.uk>
On Sat, 2013-03-16 at 01:09 +0800, Russell King - ARM Linux wrote:
> On Tue, Mar 12, 2013 at 10:40:04PM -0700, Bill Huang wrote:
> > That will be too bad, it looks like we deadlock in the mechanism, we
> > cannot change existing drivers behavior (that means some call
> > clk_disable/enable directly, some are not), and we cannot hook notifier
> > in clk_disable/enable either, that means there seems no any chance to
> > get what we want, any idea?
>
> Look, the whole point is:
>
> - Drivers can call clk_enable/clk_disable from their atomic regions to
> control the clock. Drivers which do this also call clk_prepare/
> clk_unprepare from a schedulable context to perform any operations
> necessary to allow the clock to be used.
>
> - Drivers which only ever control the clock from a schedulable context
> *can* use clk_prepare_enable()/clk_disable_unprepare() to control
> their clock, which simplifies the coding in the driver.
>
> The whole point here is to cater for what is found on different SoCs and
> not need to keep rewriting the drivers between different SoCs.
>
> So, the idea is that:
>
> - clk_prepare() does whatever is needed to prepare a clock for use which
> may require waiting for the clock to be in a state which it can be
> enabled. In other words, if there is a PLL, the PLL is setup and
> we wait for it to report that it has locked.
>
> - clk_enable() is about turning the clock output on so that the device
> receives the clock.
>
> Now, in the case of a PLL directly feeding a device, it's entirely possible
> that clk_prepare() ends up providing the clock signal to the device, and
> clk_enable() does absolutely nothing.
>
> Or, if the clock has a gate on it, it's entirely possible that clk_prepare()
> does nothing, and clk_enable() unmasks the gate to allow the clock to be
> provided to the device - which can happen from atomic contexts.
>
> The whole point about the separation of these two functions is that device
> driver writers _can_ code their drivers for both situations and not care
> about how the SoC implements the clocking at all.
>
> Why did we end up with this split in the first place? Because we ran into
> the problem that some SoCs required a sleeping clk_enable() and others
> didn't, and the whole thing was turning into an incompatible mess.
>
> So, please. Realise that clk_prepare() and clk_enable() are the _official_
> APIs, and that clk_prepare_enable() is merely a helper function for drivers
> to allow them to automate the calling of those two functions in succession
> with _no_ _further_ _processing_ at all.
>
> So, if your hooks need to be callable from schedulable contexts, then you
> need to put them inside clk_prepare(). If your hooks are callable from
> atomic contexts, then they can go into clk_enable(). But what you can
> not do is put them into clk_prepare_enable().
Thanks a lot for good point.
next prev parent reply other threads:[~2013-03-16 2:25 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-03-12 12:37 [RFC 1/1] clk: Add notifier support in clk_prepare_enable/clk_disable_unprepare Bill Huang
2013-03-12 13:40 ` Russell King - ARM Linux
2013-03-13 1:47 ` Bill Huang
2013-03-13 4:42 ` Stephen Warren
2013-03-13 5:08 ` Bill Huang
2013-03-13 5:24 ` Stephen Warren
2013-03-13 5:40 ` Bill Huang
2013-03-13 18:10 ` Stephen Warren
2013-03-14 2:15 ` Bill Huang
2013-03-14 9:21 ` Peter De Schrijver
2013-03-14 9:28 ` Bill Huang
2013-03-14 17:54 ` Stephen Warren
2013-03-15 1:20 ` Bill Huang
2013-03-15 5:22 ` Stephen Warren
2013-03-15 5:48 ` Bill Huang
2013-03-15 9:39 ` Peter De Schrijver
2013-03-15 10:08 ` Ulf Hansson
2013-03-15 12:06 ` Bill Huang
2013-03-15 12:33 ` Ulf Hansson
2013-03-15 19:38 ` Stephen Warren
2013-03-16 1:54 ` Bill Huang
2013-03-18 10:36 ` Ulf Hansson
2013-03-21 22:28 ` Mike Turquette
2013-03-16 2:23 ` Bill Huang
2013-03-15 17:12 ` Russell King - ARM Linux
2013-03-15 17:09 ` Russell King - ARM Linux
2013-03-16 2:25 ` Bill Huang [this message]
2013-03-15 16:59 ` Russell King - ARM Linux
2013-03-15 16:57 ` Russell King - ARM Linux
2013-03-15 18:44 ` Nicolas Pitre
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=1363400755.3875.0.camel@bilhuang-vm1 \
--to=bilhuang@nvidia.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).