linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] thermal: cpu_cooling: Iterate over all CPUs in clip_cpu mask to get frequency table
@ 2015-07-01  4:07 Pi-Cheng Chen
  2015-07-01  4:13 ` Pi-Cheng Chen
  0 siblings, 1 reply; 5+ messages in thread
From: Pi-Cheng Chen @ 2015-07-01  4:07 UTC (permalink / raw)
  To: linux-arm-kernel

__cpufreq_cooling_register() might fail if some CPU other than first one in
clip_cpu mask is present earlier e.g. CPU hotplug. Iterate all CPUs in the mask
to handle this case.

Signed-off-by: Pi-Cheng Chen <pi-cheng.chen@linaro.org>
---
 drivers/thermal/cpu_cooling.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/thermal/cpu_cooling.c b/drivers/thermal/cpu_cooling.c
index 6509c61..d5e4ea8 100644
--- a/drivers/thermal/cpu_cooling.c
+++ b/drivers/thermal/cpu_cooling.c
@@ -776,7 +776,13 @@ __cpufreq_cooling_register(struct device_node *np,
 	char dev_name[THERMAL_NAME_LENGTH];
 	struct cpufreq_frequency_table *pos, *table;
 	unsigned int freq, i, num_cpus;
-	int ret;
+	int ret, cpu;
+
+	for_each_cpu(cpu, clip_cpus) {
+		table = cpufreq_frequency_get_table(cpu);
+		if (table)
+			break;
+	}
 
 	table = cpufreq_frequency_get_table(cpumask_first(clip_cpus));
 	if (!table) {
-- 
1.9.1

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

* [PATCH] thermal: cpu_cooling: Iterate over all CPUs in clip_cpu mask to get frequency table
  2015-07-01  4:07 [PATCH] thermal: cpu_cooling: Iterate over all CPUs in clip_cpu mask to get frequency table Pi-Cheng Chen
@ 2015-07-01  4:13 ` Pi-Cheng Chen
  2015-07-07  7:52   ` Javi Merino
  2015-07-07 10:27   ` Viresh Kumar
  0 siblings, 2 replies; 5+ messages in thread
From: Pi-Cheng Chen @ 2015-07-01  4:13 UTC (permalink / raw)
  To: linux-arm-kernel

Sorry for the mistake I made when cherry-picking the patch. Fix and resend
again.

__cpufreq_cooling_register() might fail if some CPU other than first one in
clip_cpu mask is present earlier e.g. CPU hotplug. Iterate all CPUs in the mask
to handle this case.

Signed-off-by: Pi-Cheng Chen <pi-cheng.chen@linaro.org>
---
 drivers/thermal/cpu_cooling.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/drivers/thermal/cpu_cooling.c b/drivers/thermal/cpu_cooling.c
index 6509c61..5e90eb6 100644
--- a/drivers/thermal/cpu_cooling.c
+++ b/drivers/thermal/cpu_cooling.c
@@ -776,9 +776,14 @@ __cpufreq_cooling_register(struct device_node *np,
 	char dev_name[THERMAL_NAME_LENGTH];
 	struct cpufreq_frequency_table *pos, *table;
 	unsigned int freq, i, num_cpus;
-	int ret;
+	int ret, cpu;
+
+	for_each_cpu(cpu, clip_cpus) {
+		table = cpufreq_frequency_get_table(cpu);
+		if (table)
+			break;
+	}
 
-	table = cpufreq_frequency_get_table(cpumask_first(clip_cpus));
 	if (!table) {
 		pr_debug("%s: CPUFreq table not found\n", __func__);
 		return ERR_PTR(-EPROBE_DEFER);
-- 
1.9.1

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

* [PATCH] thermal: cpu_cooling: Iterate over all CPUs in clip_cpu mask to get frequency table
  2015-07-01  4:13 ` Pi-Cheng Chen
@ 2015-07-07  7:52   ` Javi Merino
  2015-07-07 10:27   ` Viresh Kumar
  1 sibling, 0 replies; 5+ messages in thread
From: Javi Merino @ 2015-07-07  7:52 UTC (permalink / raw)
  To: linux-arm-kernel

On Wed, Jul 01, 2015 at 05:13:14AM +0100, Pi-Cheng Chen wrote:
> Sorry for the mistake I made when cherry-picking the patch. Fix and resend
> again.
> 
> __cpufreq_cooling_register() might fail if some CPU other than first one in
> clip_cpu mask is present earlier e.g. CPU hotplug. Iterate all CPUs in the mask
> to handle this case.
> 
> Signed-off-by: Pi-Cheng Chen <pi-cheng.chen@linaro.org>

Looks good to me.  FWIW,

Acked-by: Javi Merino <javi.merino@arm.com>

> ---
>  drivers/thermal/cpu_cooling.c | 9 +++++++--
>  1 file changed, 7 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/thermal/cpu_cooling.c b/drivers/thermal/cpu_cooling.c
> index 6509c61..5e90eb6 100644
> --- a/drivers/thermal/cpu_cooling.c
> +++ b/drivers/thermal/cpu_cooling.c
> @@ -776,9 +776,14 @@ __cpufreq_cooling_register(struct device_node *np,
>  	char dev_name[THERMAL_NAME_LENGTH];
>  	struct cpufreq_frequency_table *pos, *table;
>  	unsigned int freq, i, num_cpus;
> -	int ret;
> +	int ret, cpu;
> +
> +	for_each_cpu(cpu, clip_cpus) {
> +		table = cpufreq_frequency_get_table(cpu);
> +		if (table)
> +			break;
> +	}
>  
> -	table = cpufreq_frequency_get_table(cpumask_first(clip_cpus));
>  	if (!table) {
>  		pr_debug("%s: CPUFreq table not found\n", __func__);
>  		return ERR_PTR(-EPROBE_DEFER);
> -- 
> 1.9.1
> 
> 
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
> 

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

* [PATCH] thermal: cpu_cooling: Iterate over all CPUs in clip_cpu mask to get frequency table
  2015-07-01  4:13 ` Pi-Cheng Chen
  2015-07-07  7:52   ` Javi Merino
@ 2015-07-07 10:27   ` Viresh Kumar
  2015-07-08  1:50     ` Pi-Cheng Chen
  1 sibling, 1 reply; 5+ messages in thread
From: Viresh Kumar @ 2015-07-07 10:27 UTC (permalink / raw)
  To: linux-arm-kernel

On 01-07-15, 12:13, Pi-Cheng Chen wrote:
> Sorry for the mistake I made when cherry-picking the patch. Fix and resend
> again.

You really want above to show up in git logs ?

Any comments like this should be present:
- in cover-letter
- OR after the three dashes below ---
- OR must be followed with a scissors line, like this:
  --------------8<--------

> __cpufreq_cooling_register() might fail if some CPU other than first one in
> clip_cpu mask is present earlier e.g. CPU hotplug. Iterate all CPUs in the mask
> to handle this case.
> 
> Signed-off-by: Pi-Cheng Chen <pi-cheng.chen@linaro.org>
> ---
>  drivers/thermal/cpu_cooling.c | 9 +++++++--
>  1 file changed, 7 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/thermal/cpu_cooling.c b/drivers/thermal/cpu_cooling.c
> index 6509c61..5e90eb6 100644
> --- a/drivers/thermal/cpu_cooling.c
> +++ b/drivers/thermal/cpu_cooling.c
> @@ -776,9 +776,14 @@ __cpufreq_cooling_register(struct device_node *np,
>  	char dev_name[THERMAL_NAME_LENGTH];
>  	struct cpufreq_frequency_table *pos, *table;
>  	unsigned int freq, i, num_cpus;
> -	int ret;
> +	int ret, cpu;
> +
> +	for_each_cpu(cpu, clip_cpus) {
> +		table = cpufreq_frequency_get_table(cpu);
> +		if (table)
> +			break;
> +	}
>  
> -	table = cpufreq_frequency_get_table(cpumask_first(clip_cpus));

Nah, that's wrong. I hope that's a hypothetical problem and not a real
one. Would have been better if cpufreq maintainers were cc'd as they
can provide more insight into this :)

cpufreq_frequency_get_table() does: policy->freq_table and so it
doesn't matter if the cpu is online or not.

cpufreq_cpu_data was getting unset earlier on hotplug, but that's not
the case anymore. So nothing to worry about :)

-- 
viresh

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

* [PATCH] thermal: cpu_cooling: Iterate over all CPUs in clip_cpu mask to get frequency table
  2015-07-07 10:27   ` Viresh Kumar
@ 2015-07-08  1:50     ` Pi-Cheng Chen
  0 siblings, 0 replies; 5+ messages in thread
From: Pi-Cheng Chen @ 2015-07-08  1:50 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Viresh,

On Tue, Jul 7, 2015 at 6:27 PM, Viresh Kumar <viresh.kumar@linaro.org> wrote:
> On 01-07-15, 12:13, Pi-Cheng Chen wrote:
>> Sorry for the mistake I made when cherry-picking the patch. Fix and resend
>> again.
>
> You really want above to show up in git logs ?
>
> Any comments like this should be present:
> - in cover-letter
> - OR after the three dashes below ---
> - OR must be followed with a scissors line, like this:
>   --------------8<--------

Thanks for the lesson. :)

>
>> __cpufreq_cooling_register() might fail if some CPU other than first one in
>> clip_cpu mask is present earlier e.g. CPU hotplug. Iterate all CPUs in the mask
>> to handle this case.
>>
>> Signed-off-by: Pi-Cheng Chen <pi-cheng.chen@linaro.org>
>> ---
>>  drivers/thermal/cpu_cooling.c | 9 +++++++--
>>  1 file changed, 7 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/thermal/cpu_cooling.c b/drivers/thermal/cpu_cooling.c
>> index 6509c61..5e90eb6 100644
>> --- a/drivers/thermal/cpu_cooling.c
>> +++ b/drivers/thermal/cpu_cooling.c
>> @@ -776,9 +776,14 @@ __cpufreq_cooling_register(struct device_node *np,
>>       char dev_name[THERMAL_NAME_LENGTH];
>>       struct cpufreq_frequency_table *pos, *table;
>>       unsigned int freq, i, num_cpus;
>> -     int ret;
>> +     int ret, cpu;
>> +
>> +     for_each_cpu(cpu, clip_cpus) {
>> +             table = cpufreq_frequency_get_table(cpu);
>> +             if (table)
>> +                     break;
>> +     }
>>
>> -     table = cpufreq_frequency_get_table(cpumask_first(clip_cpus));
>
> Nah, that's wrong. I hope that's a hypothetical problem and not a real
> one. Would have been better if cpufreq maintainers were cc'd as they
> can provide more insight into this :)
>
> cpufreq_frequency_get_table() does: policy->freq_table and so it
> doesn't matter if the cpu is online or not.
>
> cpufreq_cpu_data was getting unset earlier on hotplug, but that's not
> the case anymore. So nothing to worry about :)

Yes. This is based on the case before 4.2-rc1 which policy of cpu will
be destroy after all cpus in a cluster are unplugged (right?). Since it
is not the case anymore now, this patch is not needed at all.
Thanks.

Best Regards,
Pi-Cheng

>
> --
> viresh

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

end of thread, other threads:[~2015-07-08  1:50 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-07-01  4:07 [PATCH] thermal: cpu_cooling: Iterate over all CPUs in clip_cpu mask to get frequency table Pi-Cheng Chen
2015-07-01  4:13 ` Pi-Cheng Chen
2015-07-07  7:52   ` Javi Merino
2015-07-07 10:27   ` Viresh Kumar
2015-07-08  1:50     ` Pi-Cheng Chen

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