public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Stephen Warren <swarren@wwwdotorg.org>
To: Viresh Kumar <viresh.kumar@linaro.org>
Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>,
	Lists linaro-kernel <linaro-kernel@lists.linaro.org>,
	"linux-pm@vger.kernel.org" <linux-pm@vger.kernel.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	Arvind Chauhan <arvind.chauhan@arm.com>,
	Stephen Warren <swarren@nvidia.com>,
	Doug Anderson <dianders@chromium.org>,
	Russell King - ARM Linux <linux@arm.linux.org.uk>,
	Nicolas Pitre <nicolas.pitre@linaro.org>,
	Thomas Abraham <thomas.abraham@linaro.org>,
	Peter De Schrijver <pdeschrijver@nvidia.com>
Subject: Re: [PATCH V4 3/3] cpufreq: Tegra: implement intermediate frequency callbacks
Date: Fri, 30 May 2014 10:26:28 -0600	[thread overview]
Message-ID: <5388B134.9090307@wwwdotorg.org> (raw)
In-Reply-To: <CAKohponsZOpV74+SLMDLy0oCV-j896wA9--bwbwk4GUL59m1ug@mail.gmail.com>

On 05/29/2014 07:56 PM, Viresh Kumar wrote:
> On 29 May 2014 23:10, Stephen Warren <swarren@wwwdotorg.org> wrote:
>> This patch breaks Tegra. The reason is below.
...
>>> +disable_pll_x:
>>> +     clk_disable_unprepare(pll_x_clk);
>>
>> ... so this turns off pll_x even though we're running from it.
> 
> Can you describe the role of the enable/disable of this pll_x_clk please?
> Which all clocks depend on it, etc? So that I understand why its important
> to enable it and for which clocks. And also if we need to disable it after
> changing to any freq..

I believe the issue is this:

We can't change the rate of pll_x while it's being used as a source for
something. I'm not 100% sure why. I assume the PLL output simply isn't
stable enough while changing rates; perhaps it can go out-of-range, or
generate glitches.

This means we must switch the CPU clock source to something else (we use
pll_p) while changing the pll_x rate.

Since the CPU is the only thing that uses pll_x, if we switch the CPU to
some other clock source, pll_x will become unused, so it will be
automatically disabled.

Disabling the PLL, and then re-enabling it later when switching the CPU
back to it, presumably takes some extra time (e.g. waiting for PLL lock
when it starts back up), so the code takes an extra reference to the
clock (prepare_enable) before switching the CPU away from it, and drops
that (disable_unprepare) after switching the CPU back to it.

The only case pll_x is disabled is when we use a cpufreq of 216MHz; that
frequency is provided by pll_p itself, so we never switch back to pll_x
in this case, and do want to shut down pll_x to save some power.

Now, in your patch when switching from 216MHz to pll_x, the initial
prepare_enable(pll_x) never happens, then the CPU is switched back to
pll_x which turns it on, then the unpaired disable_unprepare(pll_x)
happens which turns off pll_x even though the CPU is using it as clock
source. Arguably the clock API has a bug in that it shouldn't allow
these unpaired calls to break the reference counting, but that's the way
the API is right now.

  reply	other threads:[~2014-05-30 16:26 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-21  8:59 [PATCH V4 0/3] cpufreq: add support for intermediate (stable) frequencies Viresh Kumar
2014-05-21  8:59 ` [PATCH V4 1/3] cpufreq: handle calls to ->target_index() in separate routine Viresh Kumar
2014-05-26 23:21   ` Rafael J. Wysocki
2014-05-26 23:59     ` Viresh Kumar
2014-05-21  8:59 ` [PATCH V4 2/3] cpufreq: add support for intermediate (stable) frequencies Viresh Kumar
2014-05-22 16:37   ` Stephen Warren
2014-05-23  4:24     ` Viresh Kumar
2014-05-23 15:56       ` Stephen Warren
2014-05-26  4:01         ` Viresh Kumar
2014-05-28 19:40   ` Doug Anderson
2014-05-30  1:19     ` Viresh Kumar
2014-05-21  8:59 ` [PATCH V4 3/3] cpufreq: Tegra: implement intermediate frequency callbacks Viresh Kumar
2014-05-22 16:39   ` Stephen Warren
2014-05-23  4:05     ` Viresh Kumar
2014-05-29 17:42       ` Stephen Warren
2014-06-02 10:01         ` Viresh Kumar
2014-05-29 17:40   ` Stephen Warren
2014-05-30  1:56     ` Viresh Kumar
2014-05-30 16:26       ` Stephen Warren [this message]
2014-06-02 10:06         ` Viresh Kumar
2014-06-02 16:50           ` Stephen Warren

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=5388B134.9090307@wwwdotorg.org \
    --to=swarren@wwwdotorg.org \
    --cc=arvind.chauhan@arm.com \
    --cc=dianders@chromium.org \
    --cc=linaro-kernel@lists.linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=linux@arm.linux.org.uk \
    --cc=nicolas.pitre@linaro.org \
    --cc=pdeschrijver@nvidia.com \
    --cc=rjw@rjwysocki.net \
    --cc=swarren@nvidia.com \
    --cc=thomas.abraham@linaro.org \
    --cc=viresh.kumar@linaro.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