Subject: [PATCH v4 1/2] ARM: keystone: pm: switch to use generic pm domains

From: [email-masked] (Grygorii Strashko)
Date: Tue, 25 Nov 2014 16:53:56 +0200

Hi Russell,

On 11/25/2014 04:04 PM, Russell King - ARM Linux wrote:
> On Tue, Nov 25, 2014 at 03:30:20PM +0200, Grygorii Strashko wrote:
>> On 11/25/2014 02:09 PM, Arnd Bergmann wrote:
>>> It might be possible to do this implicitly if the driver calls clk_get(),
>>> basically doing clk_get() (or another call if necessary) would prevent the
>>> simple pmdomain from turning it off during suspend.
>>
>> Unfortunately, clk_get() will not work, because drivers still need to use it
>> to get functional clocks even if they are not going to control them explicitly.
>> For example, if it need to know clock's rate.
> 
> If you don't want a clock to be turned off, then clk_get() it, then
> clk_prepare() it, and finally clk_enable() it.
> 
> Even if someone else gets it, the only time that a clock is turned off
> is when _all_ users of it mutually agree that it can be turned off - by
> every user disabling (and possibly unpreparing) it.
> 
> So, if the PM domain code gets a clock, prepares and enables it, then
> a driver gets the same clock, prepares and enables it also, it won't
> be disabled until _both_ the PM domain code _and_ the driver disable
> and unprepare the clock.
> 

All 100% true :)

But the question here is how prevent pm_clk domain (clock_ops.c) from
getting the control on clock if this particular clock is optional from driver's
perspective. So, only driver should control it. As opposite, all other clocks
should be controlled by pm-domain (in case of GPD from .start/stop callbacks).

You can find more detailed description of problem which this patch was
created to solve here:
https://lkml.org/lkml/2014/11/19/225

Thanks for your time.

regards,
-grygorii