linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: u.kleine-koenig@pengutronix.de (Uwe Kleine-König)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v3 3/5] clk: introduce the common clock framework
Date: Fri, 2 Dec 2011 21:32:03 +0100	[thread overview]
Message-ID: <20111202203203.GB4585@pengutronix.de> (raw)
In-Reply-To: <20111202202306.GF19739@n2100.arm.linux.org.uk>

Hello,

On Fri, Dec 02, 2011 at 08:23:06PM +0000, Russell King - ARM Linux wrote:
> On Fri, Dec 02, 2011 at 10:13:10AM -0700, Paul Walmsley wrote:
> > Hi Russell,
> > 
> > On Thu, 1 Dec 2011, Russell King - ARM Linux wrote:
> > 
> > > On Wed, Nov 30, 2011 at 06:20:50PM -0700, Paul Walmsley wrote:
> > > > 1. When a clock user calls clk_enable() on a clock, the clock framework 
> > > > should prevent other users of the clock from changing the clock's rate.  
> > > > This should persist until the clock user calls clk_disable() (but see also 
> > > > #2 below).  This will ensure that clock users can rely on the rate 
> > > > returned by clk_get_rate(), as long as it's called between clk_enable() 
> > > > and clk_disable().  And since the clock's rate is guaranteed to remain the 
> > > > same during this time, code that cannot tolerate clock rate changes 
> > > > without special handling (such as driver code for external I/O devices) 
> > > > will work safely without further modification.
> > > 
> > > So, if you have a PLL whose parent clock is not used by anything else.
> > > You want to program it to a certain rate.
> > > 
> > > You call clk_disable() on the PLL clock.
> > 
> > The approach described wouldn't require the PLL to be disabled before 
> > changing its rate.  If there are no other users of the PLL, or if the 
> > other users of the PLL have indicated that it's safe for others to change 
> > the PLL's rate, the clock framework would allow the PLL rate change, even 
> > if the PLL is enabled.  (modulo any notifier activity, and assuming that 
> > the underlying PLL hardware allows its frequency to be reprogrammed while 
> > the PLL is enabled)
> > 
> > > This walks up the tree and disables the parent.  You then try to set the 
> > > rate using clk_set_rate(). clk_set_rate() in this circumstance can't 
> > > wait for the PLL to lock because it can't - there's no reference clock 
> > > for it.
> > 
> > As an aside, this seems like a good time to mention that the behavior of 
> > clk_set_rate() on a disabled clock needs to be clarified.
> 
> It's more complicated than that.  Clocks have more states than just
> enabled and disabled.
> 
> There is:
> - unprepared
> - prepared and disabled
> - prepared and enabled
> 
> Implementations can chose at which point to enable their PLLs and wait
> for them to lock - but if they want to sleep while waiting, they must
> do this in the prepare method, not the enable method (remember, enable
> is to be callable from atomic contexts.)
> 
> So, it's entirely possible that a prepared clock will have the PLLs up
> and running, which means that clk_set_rate() can also wait for the PLL
> to stablize (which would be a good idea.)
> 
> Now... we can say that PLLs should be locked when the prepare method
> returns, or whenever clk_set_rate() returns.  The problem with that is
> there's a race condition between clk_enable() and clk_set_rate() - if
> we allow clk_set_rate() to sleep waiting for the PLL to lock, a
> concurrent clk_enable() can't be prevented from returning because
> that would involve holding a spinlock...
But you can achieve that the concurrent clk_enable fails. Would that be
sane?

Best regards
Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-K?nig            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

  reply	other threads:[~2011-12-02 20:32 UTC|newest]

Thread overview: 65+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-11-22  1:40 [PATCH v3 0/5] common clk framework Mike Turquette
2011-11-22  1:40 ` [PATCH v3 1/5] clk: Kconfig: add entry for HAVE_CLK_PREPARE Mike Turquette
2011-11-26  0:51   ` Shawn Guo
2011-11-22  1:40 ` [PATCH v3 2/5] Documentation: common clk API Mike Turquette
2011-11-23  2:03   ` Saravana Kannan
2011-11-23 20:33     ` Turquette, Mike
2011-11-26  8:47       ` Shawn Guo
2011-11-27  1:43         ` Turquette, Mike
2011-11-22  1:40 ` [PATCH v3 3/5] clk: introduce the common clock framework Mike Turquette
2011-11-23  3:12   ` Saravana Kannan
2011-11-23 21:30     ` Turquette, Mike
2011-11-26 13:22   ` Shawn Guo
2011-11-27  6:00     ` Turquette, Mike
2011-12-01  1:20   ` Paul Walmsley
2011-12-01  5:53     ` Turquette, Mike
2011-12-01  6:39       ` Paul Walmsley
2011-12-01 14:42         ` Mark Brown
2011-12-01 18:25           ` Turquette, Mike
2011-12-01 18:30           ` Paul Walmsley
2011-12-01 18:32             ` Mark Brown
2011-12-01 22:03             ` Russell King - ARM Linux
2011-12-03  1:04               ` Paul Walmsley
2011-12-01  8:45     ` Russell King - ARM Linux
2011-12-02 17:13       ` Paul Walmsley
2011-12-02 20:23         ` Russell King - ARM Linux
2011-12-02 20:32           ` Uwe Kleine-König [this message]
2011-12-01  2:13   ` Paul Walmsley
2011-12-05 21:15   ` Paul Walmsley
2011-12-05 23:48     ` Russell King - ARM Linux
2011-12-06  1:37       ` Paul Walmsley
2011-12-06  6:28         ` Paul Walmsley
2011-12-05 23:40   ` Turquette, Mike
2011-11-22  1:40 ` [PATCH v3 4/5] clk: basic gateable and fixed-rate clks Mike Turquette
2011-11-22 13:11   ` Arnd Bergmann
2011-11-22 15:03     ` Mark Salter
2011-11-22 15:49       ` Arnd Bergmann
2011-11-26 13:48   ` Shawn Guo
2011-11-27  6:03     ` Turquette, Mike
2011-11-27  0:09   ` Shawn Guo
2011-11-22  1:40 ` [PATCH v3 5/5] clk: export tree topology and clk data via sysfs Mike Turquette
2011-11-22 13:07   ` Arnd Bergmann
2011-11-22 17:42     ` Mike Turquette
2011-11-22 15:49   ` Greg KH
2011-11-22 17:57     ` Mike Turquette
2011-11-22 19:13       ` Greg KH
2011-11-23  3:48         ` Saravana Kannan
2011-11-23 20:43           ` Turquette, Mike
2011-11-23 16:59         ` Tony Lindgren
2011-11-23 18:06           ` Russell King - ARM Linux
2011-11-23 18:55             ` Tony Lindgren
2011-11-23 19:09               ` Mark Brown
2011-11-23 19:19                 ` Tony Lindgren
2011-11-23 22:42               ` Russell King - ARM Linux
2011-11-24  1:08                 ` Tony Lindgren
     [not found]   ` <CACxGe6sOd6MiyYaok6BsihJtp-NNsm3WQf+aUPGMRFRpSLw2mQ@mail.gmail.com>
2011-11-22 18:01     ` Mike Turquette
2011-11-22 19:19       ` Grant Likely
2011-11-22 20:02         ` Arnd Bergmann
2011-11-22 20:19           ` Turquette, Mike
2011-11-22 15:42 ` [PATCH v3 0/5] common clk framework Greg KH
2011-11-22 17:45   ` Russell King - ARM Linux
2011-11-22 18:09     ` Mike Turquette
2011-11-22 19:12       ` Greg KH
2011-11-22 19:30         ` Mark Brown
2011-11-26  7:06 ` Shawn Guo
2011-11-27  1:12   ` 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=20111202203203.GB4585@pengutronix.de \
    --to=u.kleine-koenig@pengutronix.de \
    --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).