linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] cpufreq: ARM big LITTLE: put DT nodes after using them
@ 2013-04-15  7:05 Viresh Kumar
  2013-04-15  7:05 ` [PATCH 2/2] cpufreq: ARM big LITTLE: Adapt to latest cpufreq updates Viresh Kumar
  2013-04-21 23:35 ` [PATCH 1/2] cpufreq: ARM big LITTLE: put DT nodes after using them Rafael J. Wysocki
  0 siblings, 2 replies; 3+ messages in thread
From: Viresh Kumar @ 2013-04-15  7:05 UTC (permalink / raw)
  To: rjw
  Cc: cpufreq, linux-pm, linux-kernel, robin.randhawa, Steve.Bannister,
	Liviu.Dudau, charles.garcia-tobin, arvind.chauhan, linaro-kernel,
	patches, Viresh Kumar

DT nodes should be put using of_node_put() to balance their usage counts. This
is not done properly in ARM's big LITTLE driver. Fix it.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
---
Hi Rafael,

These are fixes for 3.10

 drivers/cpufreq/arm_big_little_dt.c | 43 +++++++++++++++++++++++++------------
 1 file changed, 29 insertions(+), 14 deletions(-)

diff --git a/drivers/cpufreq/arm_big_little_dt.c b/drivers/cpufreq/arm_big_little_dt.c
index 452ff46..44be311 100644
--- a/drivers/cpufreq/arm_big_little_dt.c
+++ b/drivers/cpufreq/arm_big_little_dt.c
@@ -31,22 +31,28 @@
 
 static int dt_init_opp_table(struct device *cpu_dev)
 {
-	struct device_node *np = NULL;
+	struct device_node *np, *parent;
 	int count = 0, ret;
 
-	for_each_child_of_node(of_find_node_by_path("/cpus"), np) {
+	parent = of_find_node_by_path("/cpus");
+	if (!parent) {
+		pr_err("failed to find OF /cpus\n");
+		return -ENOENT;
+	}
+
+	for_each_child_of_node(parent, np) {
 		if (count++ != cpu_dev->id)
 			continue;
-		if (!of_get_property(np, "operating-points", NULL))
-			return -ENODATA;
-
-		cpu_dev->of_node = np;
-
-		ret = of_init_opp_table(cpu_dev);
-		if (ret)
-			return ret;
-
-		return 0;
+		if (!of_get_property(np, "operating-points", NULL)) {
+			ret = -ENODATA;
+		} else {
+			cpu_dev->of_node = np;
+			ret = of_init_opp_table(cpu_dev);
+		}
+		of_node_put(np);
+		of_node_put(parent);
+
+		return ret;
 	}
 
 	return -ENODEV;
@@ -54,15 +60,24 @@ static int dt_init_opp_table(struct device *cpu_dev)
 
 static int dt_get_transition_latency(struct device *cpu_dev)
 {
-	struct device_node *np = NULL;
+	struct device_node *np, *parent;
 	u32 transition_latency = CPUFREQ_ETERNAL;
 	int count = 0;
 
-	for_each_child_of_node(of_find_node_by_path("/cpus"), np) {
+	parent = of_find_node_by_path("/cpus");
+	if (!parent) {
+		pr_err("failed to find OF /cpus\n");
+		return -ENOENT;
+	}
+
+	for_each_child_of_node(parent, np) {
 		if (count++ != cpu_dev->id)
 			continue;
 
 		of_property_read_u32(np, "clock-latency", &transition_latency);
+		of_node_put(np);
+		of_node_put(parent);
+
 		return 0;
 	}
 
-- 
1.7.12.rc2.18.g61b472e


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

* [PATCH 2/2] cpufreq: ARM big LITTLE: Adapt to latest cpufreq updates
  2013-04-15  7:05 [PATCH 1/2] cpufreq: ARM big LITTLE: put DT nodes after using them Viresh Kumar
@ 2013-04-15  7:05 ` Viresh Kumar
  2013-04-21 23:35 ` [PATCH 1/2] cpufreq: ARM big LITTLE: put DT nodes after using them Rafael J. Wysocki
  1 sibling, 0 replies; 3+ messages in thread
From: Viresh Kumar @ 2013-04-15  7:05 UTC (permalink / raw)
  To: rjw
  Cc: cpufreq, linux-pm, linux-kernel, robin.randhawa, Steve.Bannister,
	Liviu.Dudau, charles.garcia-tobin, arvind.chauhan, linaro-kernel,
	patches, Viresh Kumar

This driver isn't updated to work with latest cpufreq core updates that happened
recently. Fix them.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
---
As original patch breaks compilation, its best to merge this patch with original
patch.

 drivers/cpufreq/arm_big_little.c | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/drivers/cpufreq/arm_big_little.c b/drivers/cpufreq/arm_big_little.c
index 1d29d1a..dbdf677 100644
--- a/drivers/cpufreq/arm_big_little.c
+++ b/drivers/cpufreq/arm_big_little.c
@@ -77,8 +77,6 @@ static int bL_cpufreq_set_target(struct cpufreq_policy *policy,
 			target_freq, relation, &freq_tab_idx);
 	freqs.new = freq_table[cur_cluster][freq_tab_idx].frequency;
 
-	freqs.cpu = policy->cpu;
-
 	pr_debug("%s: cpu: %d, cluster: %d, oldfreq: %d, target freq: %d, new freq: %d\n",
 			__func__, cpu, cur_cluster, freqs.old, target_freq,
 			freqs.new);
@@ -86,8 +84,7 @@ static int bL_cpufreq_set_target(struct cpufreq_policy *policy,
 	if (freqs.old == freqs.new)
 		return 0;
 
-	for_each_cpu(freqs.cpu, policy->cpus)
-		cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE);
+	cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE);
 
 	ret = clk_set_rate(clk[cur_cluster], freqs.new * 1000);
 	if (ret) {
@@ -97,8 +94,7 @@ static int bL_cpufreq_set_target(struct cpufreq_policy *policy,
 
 	policy->cur = freqs.new;
 
-	for_each_cpu(freqs.cpu, policy->cpus)
-		cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE);
+	cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE);
 
 	return ret;
 }
@@ -231,7 +227,7 @@ static struct cpufreq_driver bL_cpufreq_driver = {
 	.get			= bL_cpufreq_get,
 	.init			= bL_cpufreq_init,
 	.exit			= bL_cpufreq_exit,
-	.have_multiple_policies	= true,
+	.have_governor_per_policy = true,
 	.attr			= bL_cpufreq_attr,
 };
 
-- 
1.7.12.rc2.18.g61b472e


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

* Re: [PATCH 1/2] cpufreq: ARM big LITTLE: put DT nodes after using them
  2013-04-15  7:05 [PATCH 1/2] cpufreq: ARM big LITTLE: put DT nodes after using them Viresh Kumar
  2013-04-15  7:05 ` [PATCH 2/2] cpufreq: ARM big LITTLE: Adapt to latest cpufreq updates Viresh Kumar
@ 2013-04-21 23:35 ` Rafael J. Wysocki
  1 sibling, 0 replies; 3+ messages in thread
From: Rafael J. Wysocki @ 2013-04-21 23:35 UTC (permalink / raw)
  To: Viresh Kumar
  Cc: cpufreq, linux-pm, linux-kernel, robin.randhawa, Steve.Bannister,
	Liviu.Dudau, charles.garcia-tobin, arvind.chauhan, linaro-kernel,
	patches

On Monday, April 15, 2013 12:35:24 PM Viresh Kumar wrote:
> DT nodes should be put using of_node_put() to balance their usage counts. This
> is not done properly in ARM's big LITTLE driver. Fix it.
> 
> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
> ---
> Hi Rafael,
> 
> These are fixes for 3.10

Both applied.

Thanks,
Rafael


>  drivers/cpufreq/arm_big_little_dt.c | 43 +++++++++++++++++++++++++------------
>  1 file changed, 29 insertions(+), 14 deletions(-)
> 
> diff --git a/drivers/cpufreq/arm_big_little_dt.c b/drivers/cpufreq/arm_big_little_dt.c
> index 452ff46..44be311 100644
> --- a/drivers/cpufreq/arm_big_little_dt.c
> +++ b/drivers/cpufreq/arm_big_little_dt.c
> @@ -31,22 +31,28 @@
>  
>  static int dt_init_opp_table(struct device *cpu_dev)
>  {
> -	struct device_node *np = NULL;
> +	struct device_node *np, *parent;
>  	int count = 0, ret;
>  
> -	for_each_child_of_node(of_find_node_by_path("/cpus"), np) {
> +	parent = of_find_node_by_path("/cpus");
> +	if (!parent) {
> +		pr_err("failed to find OF /cpus\n");
> +		return -ENOENT;
> +	}
> +
> +	for_each_child_of_node(parent, np) {
>  		if (count++ != cpu_dev->id)
>  			continue;
> -		if (!of_get_property(np, "operating-points", NULL))
> -			return -ENODATA;
> -
> -		cpu_dev->of_node = np;
> -
> -		ret = of_init_opp_table(cpu_dev);
> -		if (ret)
> -			return ret;
> -
> -		return 0;
> +		if (!of_get_property(np, "operating-points", NULL)) {
> +			ret = -ENODATA;
> +		} else {
> +			cpu_dev->of_node = np;
> +			ret = of_init_opp_table(cpu_dev);
> +		}
> +		of_node_put(np);
> +		of_node_put(parent);
> +
> +		return ret;
>  	}
>  
>  	return -ENODEV;
> @@ -54,15 +60,24 @@ static int dt_init_opp_table(struct device *cpu_dev)
>  
>  static int dt_get_transition_latency(struct device *cpu_dev)
>  {
> -	struct device_node *np = NULL;
> +	struct device_node *np, *parent;
>  	u32 transition_latency = CPUFREQ_ETERNAL;
>  	int count = 0;
>  
> -	for_each_child_of_node(of_find_node_by_path("/cpus"), np) {
> +	parent = of_find_node_by_path("/cpus");
> +	if (!parent) {
> +		pr_err("failed to find OF /cpus\n");
> +		return -ENOENT;
> +	}
> +
> +	for_each_child_of_node(parent, np) {
>  		if (count++ != cpu_dev->id)
>  			continue;
>  
>  		of_property_read_u32(np, "clock-latency", &transition_latency);
> +		of_node_put(np);
> +		of_node_put(parent);
> +
>  		return 0;
>  	}
>  
> 
-- 
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.

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

end of thread, other threads:[~2013-04-21 23:27 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-04-15  7:05 [PATCH 1/2] cpufreq: ARM big LITTLE: put DT nodes after using them Viresh Kumar
2013-04-15  7:05 ` [PATCH 2/2] cpufreq: ARM big LITTLE: Adapt to latest cpufreq updates Viresh Kumar
2013-04-21 23:35 ` [PATCH 1/2] cpufreq: ARM big LITTLE: put DT nodes after using them Rafael J. Wysocki

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