linux-tegra.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ARM: tegra: cpufreq: move clk_get/put out of function tegra_cpu_init/exit
@ 2012-12-21 10:09 Richard Zhao
       [not found] ` <1356084595-17800-1-git-send-email-linuxzsc-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
  0 siblings, 1 reply; 7+ messages in thread
From: Richard Zhao @ 2012-12-21 10:09 UTC (permalink / raw)
  To: linux-tegra-u79uwXL29TY76Z2rM5mHXA
  Cc: swarren-3lzwWm7+Weoh9ZMKESR00Q,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r, Richard Zhao

tegra_cpu_init/exit will be called every time one cpu core is online or
offline. And all cpu cores share same clocks, redundant clk_get/put
wast time,  so I move them out.

Signed-off-by: Richard Zhao <linuxzsc-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
---
 arch/arm/mach-tegra/cpu-tegra.c |   40 +++++++++++++++++++--------------------
 1 file changed, 20 insertions(+), 20 deletions(-)

diff --git a/arch/arm/mach-tegra/cpu-tegra.c b/arch/arm/mach-tegra/cpu-tegra.c
index 627bf0f..4faa3c6 100644
--- a/arch/arm/mach-tegra/cpu-tegra.c
+++ b/arch/arm/mach-tegra/cpu-tegra.c
@@ -217,24 +217,6 @@ static int tegra_cpu_init(struct cpufreq_policy *policy)
 	if (policy->cpu >= NUM_CPUS)
 		return -EINVAL;
 
-	cpu_clk = clk_get_sys(NULL, "cpu");
-	if (IS_ERR(cpu_clk))
-		return PTR_ERR(cpu_clk);
-
-	pll_x_clk = clk_get_sys(NULL, "pll_x");
-	if (IS_ERR(pll_x_clk))
-		return PTR_ERR(pll_x_clk);
-
-	pll_p_clk = clk_get_sys(NULL, "pll_p");
-	if (IS_ERR(pll_p_clk))
-		return PTR_ERR(pll_p_clk);
-
-	emc_clk = clk_get_sys("cpu", "emc");
-	if (IS_ERR(emc_clk)) {
-		clk_put(cpu_clk);
-		return PTR_ERR(emc_clk);
-	}
-
 	clk_prepare_enable(emc_clk);
 	clk_prepare_enable(cpu_clk);
 
@@ -259,8 +241,6 @@ static int tegra_cpu_exit(struct cpufreq_policy *policy)
 {
 	cpufreq_frequency_table_cpuinfo(policy, freq_table);
 	clk_disable_unprepare(emc_clk);
-	clk_put(emc_clk);
-	clk_put(cpu_clk);
 	return 0;
 }
 
@@ -281,12 +261,32 @@ static struct cpufreq_driver tegra_cpufreq_driver = {
 
 static int __init tegra_cpufreq_init(void)
 {
+	cpu_clk = clk_get_sys(NULL, "cpu");
+	if (IS_ERR(cpu_clk))
+		return PTR_ERR(cpu_clk);
+
+	pll_x_clk = clk_get_sys(NULL, "pll_x");
+	if (IS_ERR(pll_x_clk))
+		return PTR_ERR(pll_x_clk);
+
+	pll_p_clk = clk_get_sys(NULL, "pll_p");
+	if (IS_ERR(pll_p_clk))
+		return PTR_ERR(pll_p_clk);
+
+	emc_clk = clk_get_sys("cpu", "emc");
+	if (IS_ERR(emc_clk)) {
+		clk_put(cpu_clk);
+		return PTR_ERR(emc_clk);
+	}
+
 	return cpufreq_register_driver(&tegra_cpufreq_driver);
 }
 
 static void __exit tegra_cpufreq_exit(void)
 {
         cpufreq_unregister_driver(&tegra_cpufreq_driver);
+	clk_put(emc_clk);
+	clk_put(cpu_clk);
 }
 
 
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH] ARM: tegra: cpufreq: move clk_get/put out of function tegra_cpu_init/exit
       [not found] ` <1356084595-17800-1-git-send-email-linuxzsc-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
@ 2012-12-21 21:27   ` Stephen Warren
       [not found]     ` <50D4D44F.2080203-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>
  2013-01-02 19:36   ` Stephen Warren
  1 sibling, 1 reply; 7+ messages in thread
From: Stephen Warren @ 2012-12-21 21:27 UTC (permalink / raw)
  To: Richard Zhao, Prashant Gaikwad, Peter De Schrijver
  Cc: linux-tegra-u79uwXL29TY76Z2rM5mHXA,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r

On 12/21/2012 03:09 AM, Richard Zhao wrote:
> tegra_cpu_init/exit will be called every time one cpu core is online or
> offline. And all cpu cores share same clocks, redundant clk_get/put
> wast time,  so I move them out.

I think this is reasonable.

Prashant, Peter, any comments?

Is any other work in tegra_cpu_init() redundant? Is tegra_cpu_init()
supposed to be called due to hotplug, or is that a bug in the cpufreq core?

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] ARM: tegra: cpufreq: move clk_get/put out of function tegra_cpu_init/exit
       [not found]     ` <50D4D44F.2080203-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>
@ 2012-12-23 10:35       ` Prashant Gaikwad
  2012-12-24  2:26         ` Richard Zhao
       [not found]         ` <50D6DE6E.4060106-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
  2013-01-02 12:30       ` Peter De Schrijver
  1 sibling, 2 replies; 7+ messages in thread
From: Prashant Gaikwad @ 2012-12-23 10:35 UTC (permalink / raw)
  To: Stephen Warren
  Cc: Richard Zhao, Peter De Schrijver,
	linux-tegra-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org

On Saturday 22 December 2012 02:57 AM, Stephen Warren wrote:
> On 12/21/2012 03:09 AM, Richard Zhao wrote:
>> tegra_cpu_init/exit will be called every time one cpu core is online or
>> offline. And all cpu cores share same clocks, redundant clk_get/put
>> wast time,  so I move them out.
> I think this is reasonable.
>
> Prashant, Peter, any comments?
>
> Is any other work in tegra_cpu_init() redundant? Is tegra_cpu_init()
> supposed to be called due to hotplug, or is that a bug in the cpufreq core?

Looks good. Also, instead of array we can use single variable for 
target_cpu_speed.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] ARM: tegra: cpufreq: move clk_get/put out of function tegra_cpu_init/exit
  2012-12-23 10:35       ` Prashant Gaikwad
@ 2012-12-24  2:26         ` Richard Zhao
       [not found]         ` <50D6DE6E.4060106-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
  1 sibling, 0 replies; 7+ messages in thread
From: Richard Zhao @ 2012-12-24  2:26 UTC (permalink / raw)
  To: Prashant Gaikwad
  Cc: linux-tegra@vger.kernel.org, Peter De Schrijver,
	linux-arm-kernel@lists.infradead.org, Stephen Warren

On Sun, Dec 23, 2012 at 6:35 PM, Prashant Gaikwad <pgaikwad@nvidia.com> wrote:
> On Saturday 22 December 2012 02:57 AM, Stephen Warren wrote:
>>
>> On 12/21/2012 03:09 AM, Richard Zhao wrote:
>>>
>>> tegra_cpu_init/exit will be called every time one cpu core is online or
>>> offline. And all cpu cores share same clocks, redundant clk_get/put
>>> wast time,  so I move them out.
>>
>> I think this is reasonable.
>>
>> Prashant, Peter, any comments?
>>
>> Is any other work in tegra_cpu_init() redundant? Is tegra_cpu_init()
>> supposed to be called due to hotplug, or is that a bug in the cpufreq
>> core?
When cpu goes offline, kernel don't know whether it'll come back.
Sounds reasonable.
>
>
> Looks good. Also, instead of array we can use single variable for
> target_cpu_speed.
I think yes. If one day the cores support rate changing independently,
we can create another driver. It supposed to be another patch to do it.

Thanks
Richard

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] ARM: tegra: cpufreq: move clk_get/put out of function tegra_cpu_init/exit
       [not found]         ` <50D6DE6E.4060106-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
@ 2013-01-02 12:20           ` Peter De Schrijver
  0 siblings, 0 replies; 7+ messages in thread
From: Peter De Schrijver @ 2013-01-02 12:20 UTC (permalink / raw)
  To: Prashant Gaikwad
  Cc: Stephen Warren, Richard Zhao,
	linux-tegra-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org

On Sun, Dec 23, 2012 at 11:35:26AM +0100, Prashant Gaikwad wrote:
> On Saturday 22 December 2012 02:57 AM, Stephen Warren wrote:
> > On 12/21/2012 03:09 AM, Richard Zhao wrote:
> >> tegra_cpu_init/exit will be called every time one cpu core is online or
> >> offline. And all cpu cores share same clocks, redundant clk_get/put
> >> wast time,  so I move them out.
> > I think this is reasonable.
> >
> > Prashant, Peter, any comments?
> >
> > Is any other work in tegra_cpu_init() redundant? Is tegra_cpu_init()
> > supposed to be called due to hotplug, or is that a bug in the cpufreq core?
> 
> Looks good. Also, instead of array we can use single variable for 
> target_cpu_speed.
> 

No. The target_cpu_speed becomes useful once we have clusterswitching. We can
use it to determine if we want to switch to the other cluster.

Cheers,

Peter.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] ARM: tegra: cpufreq: move clk_get/put out of function tegra_cpu_init/exit
       [not found]     ` <50D4D44F.2080203-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>
  2012-12-23 10:35       ` Prashant Gaikwad
@ 2013-01-02 12:30       ` Peter De Schrijver
  1 sibling, 0 replies; 7+ messages in thread
From: Peter De Schrijver @ 2013-01-02 12:30 UTC (permalink / raw)
  To: Stephen Warren
  Cc: Richard Zhao, Prashant Gaikwad,
	linux-tegra-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org

On Fri, Dec 21, 2012 at 10:27:43PM +0100, Stephen Warren wrote:
> On 12/21/2012 03:09 AM, Richard Zhao wrote:
> > tegra_cpu_init/exit will be called every time one cpu core is online or
> > offline. And all cpu cores share same clocks, redundant clk_get/put
> > wast time,  so I move them out.
> 
> I think this is reasonable.
> 
> Prashant, Peter, any comments?
> 
> Is any other work in tegra_cpu_init() redundant? Is tegra_cpu_init()
> supposed to be called due to hotplug, or is that a bug in the cpufreq core?

I think we want to keep target_cpu_speed[] as a possible input for the
(to be upstreamed) cluster switching logic. Yes, tegra_cpu_init() should be
called due to hotplug. Some systems might need specific initialization for
cpufreq when a new CPU comes online. Also the available frequencies might
be different per CPU. So this information needs to be provided for each
CPU.

Cheers,

Peter.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] ARM: tegra: cpufreq: move clk_get/put out of function tegra_cpu_init/exit
       [not found] ` <1356084595-17800-1-git-send-email-linuxzsc-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
  2012-12-21 21:27   ` Stephen Warren
@ 2013-01-02 19:36   ` Stephen Warren
  1 sibling, 0 replies; 7+ messages in thread
From: Stephen Warren @ 2013-01-02 19:36 UTC (permalink / raw)
  To: Richard Zhao
  Cc: linux-tegra-u79uwXL29TY76Z2rM5mHXA,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r

On 12/21/2012 03:09 AM, Richard Zhao wrote:
> tegra_cpu_init/exit will be called every time one cpu core is online or
> offline. And all cpu cores share same clocks, redundant clk_get/put
> wast time,  so I move them out.

I've applied this to Tegra's for-3.9/soc branch.

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2013-01-02 19:36 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-12-21 10:09 [PATCH] ARM: tegra: cpufreq: move clk_get/put out of function tegra_cpu_init/exit Richard Zhao
     [not found] ` <1356084595-17800-1-git-send-email-linuxzsc-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2012-12-21 21:27   ` Stephen Warren
     [not found]     ` <50D4D44F.2080203-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>
2012-12-23 10:35       ` Prashant Gaikwad
2012-12-24  2:26         ` Richard Zhao
     [not found]         ` <50D6DE6E.4060106-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2013-01-02 12:20           ` Peter De Schrijver
2013-01-02 12:30       ` Peter De Schrijver
2013-01-02 19:36   ` Stephen Warren

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).