[lkml]   [2011]   [Jan]   [20]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
SubjectRe: Locking in the clk API
On Thu, Jan 20, 2011 at 05:02:55PM +0000, Ben Dooks wrote:
> If you want to make it so that each low-power mode has to work
> out what PLLs need to be disabled and then re-enabled makes me
> want to be sick. Hiding this stuff behind specific implementations
> is a recipe for disaster.

Why should systems which don't suffer from such problems be prevented
from gaining power saving from turning off their clocks when devices
are not being used (eg, the console serial port.)

One solution to your root PLL issue would be to have a separate set of
enable/disable API calls which get called at setup/release time (or
whatever you'd like to call it) which can only be called from non-atomic
context. Maybe clk_prepare() and clk_unprepare(). These functions
should perform whatever is necessary to ensure that the clock source
is available for use atomically when clk_enable() is called.

So, in your case, clk_prepare() ensures that the root PLL is enabled,
clk_unprepare() allows it to be turned off.

In the case of a console driver, clk_prepare() can be called when we
know the port will be used as a console. clk_enable() is then called
before writing out the string, and clk_disable() after we've completely
sent the last character.

This allows the best of both worlds. We now have a clk_enable() which
can be used to turn the clocks off through the clock tree up to the first
non-atomic clock, and we also have a way to deal with those which need
to sleep. So not only do "sleeping clock" implementations become possible
but these "sleeping clock" implementations also get the opportunity to
shutdown some of their clock tree with minimal latency for doing so.

 \ /
  Last update: 2011-01-20 20:11    [W:0.082 / U:18.328 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site