diff mbox

[v2] cpufreq: exynos: Use simple approach to asses if cpu cooling can be used

Message ID 1423151689-27490-1-git-send-email-l.majewski@samsung.com (mailing list archive)
State Not Applicable, archived
Headers show

Commit Message

Lukasz Majewski Feb. 5, 2015, 3:54 p.m. UTC
Commit: e725d26c4857e5e41975b5e74e64ce6ab09a7121 provided possibility to
use device tree to asses if cpu can be used as cooling device. Since the
code was somewhat awkward, simpler approach has been proposed.

Test HW: Exynos 4412 - Odroid U3.

Suggested-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
---
Changes for v2:
- Remove superfluous *np pointer
---
 drivers/cpufreq/exynos-cpufreq.c | 21 ++++++---------------
 1 file changed, 6 insertions(+), 15 deletions(-)

Comments

Lukasz Majewski Feb. 26, 2015, 10:36 a.m. UTC | #1
Hi Eduardo,

> Commit: e725d26c4857e5e41975b5e74e64ce6ab09a7121 provided possibility
> to use device tree to asses if cpu can be used as cooling device.
> Since the code was somewhat awkward, simpler approach has been
> proposed.
> 
> Test HW: Exynos 4412 - Odroid U3.
> 
> Suggested-by: Viresh Kumar <viresh.kumar@linaro.org>
> Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> Acked-by: Viresh Kumar <viresh.kumar@linaro.org>

This patch is also missing from linux-thermal-soc tree.

I will add it to samsung thermal tree, since Viresh has ACK'ed it.

> ---
> Changes for v2:
> - Remove superfluous *np pointer
> ---
>  drivers/cpufreq/exynos-cpufreq.c | 21 ++++++---------------
>  1 file changed, 6 insertions(+), 15 deletions(-)
> 
> diff --git a/drivers/cpufreq/exynos-cpufreq.c
> b/drivers/cpufreq/exynos-cpufreq.c index 5e98c6b..82d2fbb 100644
> --- a/drivers/cpufreq/exynos-cpufreq.c
> +++ b/drivers/cpufreq/exynos-cpufreq.c
> @@ -159,7 +159,7 @@ static struct cpufreq_driver exynos_driver = {
>  
>  static int exynos_cpufreq_probe(struct platform_device *pdev)
>  {
> -	struct device_node *cpus, *np;
> +	struct device_node *cpu0;
>  	int ret = -EINVAL;
>  
>  	exynos_info = kzalloc(sizeof(*exynos_info), GFP_KERNEL);
> @@ -206,28 +206,19 @@ static int exynos_cpufreq_probe(struct
> platform_device *pdev) if (ret)
>  		goto err_cpufreq_reg;
>  
> -	cpus = of_find_node_by_path("/cpus");
> -	if (!cpus) {
> -		pr_err("failed to find cpus node\n");
> +	cpu0 = of_get_cpu_node(0, NULL);
> +	if (!cpu0) {
> +		pr_err("failed to find cpu0 node\n");
>  		return 0;
>  	}
>  
> -	np = of_get_next_child(cpus, NULL);
> -	if (!np) {
> -		pr_err("failed to find cpus child node\n");
> -		of_node_put(cpus);
> -		return 0;
> -	}
> -
> -	if (of_find_property(np, "#cooling-cells", NULL)) {
> -		cdev = of_cpufreq_cooling_register(np,
> +	if (of_find_property(cpu0, "#cooling-cells", NULL)) {
> +		cdev = of_cpufreq_cooling_register(cpu0,
>  						   cpu_present_mask);
>  		if (IS_ERR(cdev))
>  			pr_err("running cpufreq without cooling
> device: %ld\n", PTR_ERR(cdev));
>  	}
> -	of_node_put(np);
> -	of_node_put(cpus);
>  
>  	return 0;
>
Eduardo Valentin Feb. 26, 2015, 6:25 p.m. UTC | #2
On Thu, Feb 26, 2015 at 11:36:24AM +0100, Lukasz Majewski wrote:
> Hi Eduardo,
> 
> > Commit: e725d26c4857e5e41975b5e74e64ce6ab09a7121 provided possibility
> > to use device tree to asses if cpu can be used as cooling device.
> > Since the code was somewhat awkward, simpler approach has been
> > proposed.
> > 
> > Test HW: Exynos 4412 - Odroid U3.
> > 
> > Suggested-by: Viresh Kumar <viresh.kumar@linaro.org>
> > Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> > Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
> 
> This patch is also missing from linux-thermal-soc tree.
> 
> I will add it to samsung thermal tree, since Viresh has ACK'ed it.

Do we have any dependency with something which is only in the thermal
tree(s)? If not, I suggest the cpufreq changes go via cpufreq tree(s).


BR,

Eduardo Valentin

> 
> > ---
> > Changes for v2:
> > - Remove superfluous *np pointer
> > ---
> >  drivers/cpufreq/exynos-cpufreq.c | 21 ++++++---------------
> >  1 file changed, 6 insertions(+), 15 deletions(-)
> > 
> > diff --git a/drivers/cpufreq/exynos-cpufreq.c
> > b/drivers/cpufreq/exynos-cpufreq.c index 5e98c6b..82d2fbb 100644
> > --- a/drivers/cpufreq/exynos-cpufreq.c
> > +++ b/drivers/cpufreq/exynos-cpufreq.c
> > @@ -159,7 +159,7 @@ static struct cpufreq_driver exynos_driver = {
> >  
> >  static int exynos_cpufreq_probe(struct platform_device *pdev)
> >  {
> > -	struct device_node *cpus, *np;
> > +	struct device_node *cpu0;
> >  	int ret = -EINVAL;
> >  
> >  	exynos_info = kzalloc(sizeof(*exynos_info), GFP_KERNEL);
> > @@ -206,28 +206,19 @@ static int exynos_cpufreq_probe(struct
> > platform_device *pdev) if (ret)
> >  		goto err_cpufreq_reg;
> >  
> > -	cpus = of_find_node_by_path("/cpus");
> > -	if (!cpus) {
> > -		pr_err("failed to find cpus node\n");
> > +	cpu0 = of_get_cpu_node(0, NULL);
> > +	if (!cpu0) {
> > +		pr_err("failed to find cpu0 node\n");
> >  		return 0;
> >  	}
> >  
> > -	np = of_get_next_child(cpus, NULL);
> > -	if (!np) {
> > -		pr_err("failed to find cpus child node\n");
> > -		of_node_put(cpus);
> > -		return 0;
> > -	}
> > -
> > -	if (of_find_property(np, "#cooling-cells", NULL)) {
> > -		cdev = of_cpufreq_cooling_register(np,
> > +	if (of_find_property(cpu0, "#cooling-cells", NULL)) {
> > +		cdev = of_cpufreq_cooling_register(cpu0,
> >  						   cpu_present_mask);
> >  		if (IS_ERR(cdev))
> >  			pr_err("running cpufreq without cooling
> > device: %ld\n", PTR_ERR(cdev));
> >  	}
> > -	of_node_put(np);
> > -	of_node_put(cpus);
> >  
> >  	return 0;
> >  
> 
> 
> 
> -- 
> Best regards,
> 
> Lukasz Majewski
> 
> Samsung R&D Institute Poland (SRPOL) | Linux Platform Group
Lukasz Majewski Feb. 26, 2015, 9:23 p.m. UTC | #3
Hi Eduardo,

> On Thu, Feb 26, 2015 at 11:36:24AM +0100, Lukasz Majewski wrote:
> > Hi Eduardo,
> > 
> > > Commit: e725d26c4857e5e41975b5e74e64ce6ab09a7121 provided
> > > possibility to use device tree to asses if cpu can be used as
> > > cooling device. Since the code was somewhat awkward, simpler
> > > approach has been proposed.
> > > 
> > > Test HW: Exynos 4412 - Odroid U3.
> > > 
> > > Suggested-by: Viresh Kumar <viresh.kumar@linaro.org>
> > > Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> > > Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
> > 
> > This patch is also missing from linux-thermal-soc tree.
> > 
> > I will add it to samsung thermal tree, since Viresh has ACK'ed it.
> 
> Do we have any dependency with something which is only in the thermal
> tree(s)? If not, I suggest the cpufreq changes go via cpufreq tree(s).

As fair as I remember, Viresh didn't mind if this patch would go via
thermal tree, since it is an integral part of the thermal solution for
Exynos.

Frankly, I'm for keeping all "related" patches in one tree
(especially when somebody already ACKed the patch) and not split them
into several trees.

Look how bad things look now with thermal DTS patches .... If we would
have taken them all at once, we hadn't had current problems.

Best regards,
Lukasz Majewski

> 
> 
> BR,
> 
> Eduardo Valentin
> 
> > 
> > > ---
> > > Changes for v2:
> > > - Remove superfluous *np pointer
> > > ---
> > >  drivers/cpufreq/exynos-cpufreq.c | 21 ++++++---------------
> > >  1 file changed, 6 insertions(+), 15 deletions(-)
> > > 
> > > diff --git a/drivers/cpufreq/exynos-cpufreq.c
> > > b/drivers/cpufreq/exynos-cpufreq.c index 5e98c6b..82d2fbb 100644
> > > --- a/drivers/cpufreq/exynos-cpufreq.c
> > > +++ b/drivers/cpufreq/exynos-cpufreq.c
> > > @@ -159,7 +159,7 @@ static struct cpufreq_driver exynos_driver = {
> > >  
> > >  static int exynos_cpufreq_probe(struct platform_device *pdev)
> > >  {
> > > -	struct device_node *cpus, *np;
> > > +	struct device_node *cpu0;
> > >  	int ret = -EINVAL;
> > >  
> > >  	exynos_info = kzalloc(sizeof(*exynos_info), GFP_KERNEL);
> > > @@ -206,28 +206,19 @@ static int exynos_cpufreq_probe(struct
> > > platform_device *pdev) if (ret)
> > >  		goto err_cpufreq_reg;
> > >  
> > > -	cpus = of_find_node_by_path("/cpus");
> > > -	if (!cpus) {
> > > -		pr_err("failed to find cpus node\n");
> > > +	cpu0 = of_get_cpu_node(0, NULL);
> > > +	if (!cpu0) {
> > > +		pr_err("failed to find cpu0 node\n");
> > >  		return 0;
> > >  	}
> > >  
> > > -	np = of_get_next_child(cpus, NULL);
> > > -	if (!np) {
> > > -		pr_err("failed to find cpus child node\n");
> > > -		of_node_put(cpus);
> > > -		return 0;
> > > -	}
> > > -
> > > -	if (of_find_property(np, "#cooling-cells", NULL)) {
> > > -		cdev = of_cpufreq_cooling_register(np,
> > > +	if (of_find_property(cpu0, "#cooling-cells", NULL)) {
> > > +		cdev = of_cpufreq_cooling_register(cpu0,
> > >  						   cpu_present_mask);
> > >  		if (IS_ERR(cdev))
> > >  			pr_err("running cpufreq without cooling
> > > device: %ld\n", PTR_ERR(cdev));
> > >  	}
> > > -	of_node_put(np);
> > > -	of_node_put(cpus);
> > >  
> > >  	return 0;
> > >  
> > 
> > 
> > 
> > -- 
> > Best regards,
> > 
> > Lukasz Majewski
> > 
> > Samsung R&D Institute Poland (SRPOL) | Linux Platform Group
diff mbox

Patch

diff --git a/drivers/cpufreq/exynos-cpufreq.c b/drivers/cpufreq/exynos-cpufreq.c
index 5e98c6b..82d2fbb 100644
--- a/drivers/cpufreq/exynos-cpufreq.c
+++ b/drivers/cpufreq/exynos-cpufreq.c
@@ -159,7 +159,7 @@  static struct cpufreq_driver exynos_driver = {
 
 static int exynos_cpufreq_probe(struct platform_device *pdev)
 {
-	struct device_node *cpus, *np;
+	struct device_node *cpu0;
 	int ret = -EINVAL;
 
 	exynos_info = kzalloc(sizeof(*exynos_info), GFP_KERNEL);
@@ -206,28 +206,19 @@  static int exynos_cpufreq_probe(struct platform_device *pdev)
 	if (ret)
 		goto err_cpufreq_reg;
 
-	cpus = of_find_node_by_path("/cpus");
-	if (!cpus) {
-		pr_err("failed to find cpus node\n");
+	cpu0 = of_get_cpu_node(0, NULL);
+	if (!cpu0) {
+		pr_err("failed to find cpu0 node\n");
 		return 0;
 	}
 
-	np = of_get_next_child(cpus, NULL);
-	if (!np) {
-		pr_err("failed to find cpus child node\n");
-		of_node_put(cpus);
-		return 0;
-	}
-
-	if (of_find_property(np, "#cooling-cells", NULL)) {
-		cdev = of_cpufreq_cooling_register(np,
+	if (of_find_property(cpu0, "#cooling-cells", NULL)) {
+		cdev = of_cpufreq_cooling_register(cpu0,
 						   cpu_present_mask);
 		if (IS_ERR(cdev))
 			pr_err("running cpufreq without cooling device: %ld\n",
 			       PTR_ERR(cdev));
 	}
-	of_node_put(np);
-	of_node_put(cpus);
 
 	return 0;