diff mbox series

[v2,2/5] thermal: cpufreq_cooling: Use new thermal pressure update function

Message ID 20211015144550.23719-3-lukasz.luba@arm.com (mailing list archive)
State Superseded
Headers show
Series Refactor thermal pressure update to avoid code duplication | expand

Commit Message

Lukasz Luba Oct. 15, 2021, 2:45 p.m. UTC
Thermal pressure provides a new API, which allows to use CPU frequency
as an argument. That removes the need of local conversion to capacity.
Use this new function and remove old conversion code.

Signed-off-by: Lukasz Luba <lukasz.luba@arm.com>
---
 drivers/thermal/cpufreq_cooling.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

Comments

Dietmar Eggemann Oct. 26, 2021, 4:51 p.m. UTC | #1
On 15/10/2021 16:45, Lukasz Luba wrote:

[...]

> @@ -479,10 +478,7 @@ static int cpufreq_set_cur_state(struct thermal_cooling_device *cdev,
>  	if (ret >= 0) {
>  		cpufreq_cdev->cpufreq_state = state;
>  		cpus = cpufreq_cdev->policy->related_cpus;
> -		max_capacity = arch_scale_cpu_capacity(cpumask_first(cpus));
> -		capacity = frequency * max_capacity;
> -		capacity /= cpufreq_cdev->policy->cpuinfo.max_freq;

Took me a while to realize that `cpufreq_cdev->policy->cpuinfo.max_freq`
is 1000 * per_cpu(freq_factor, cpu), the latter being used now in
arch_thermal_pressure_update(). Maybe worth mentioning in the patch header?
Lukasz Luba Oct. 27, 2021, 9 a.m. UTC | #2
On 10/26/21 5:51 PM, Dietmar Eggemann wrote:
> On 15/10/2021 16:45, Lukasz Luba wrote:
> 
> [...]
> 
>> @@ -479,10 +478,7 @@ static int cpufreq_set_cur_state(struct thermal_cooling_device *cdev,
>>   	if (ret >= 0) {
>>   		cpufreq_cdev->cpufreq_state = state;
>>   		cpus = cpufreq_cdev->policy->related_cpus;
>> -		max_capacity = arch_scale_cpu_capacity(cpumask_first(cpus));
>> -		capacity = frequency * max_capacity;
>> -		capacity /= cpufreq_cdev->policy->cpuinfo.max_freq;
> 
> Took me a while to realize that `cpufreq_cdev->policy->cpuinfo.max_freq`
> is 1000 * per_cpu(freq_factor, cpu), the latter being used now in
> arch_thermal_pressure_update(). Maybe worth mentioning in the patch header?
> 

OK, I will put that information into the patch description in the next
version.
diff mbox series

Patch

diff --git a/drivers/thermal/cpufreq_cooling.c b/drivers/thermal/cpufreq_cooling.c
index 43b1ae8a7789..835c091ce818 100644
--- a/drivers/thermal/cpufreq_cooling.c
+++ b/drivers/thermal/cpufreq_cooling.c
@@ -462,7 +462,6 @@  static int cpufreq_set_cur_state(struct thermal_cooling_device *cdev,
 	struct cpufreq_cooling_device *cpufreq_cdev = cdev->devdata;
 	struct cpumask *cpus;
 	unsigned int frequency;
-	unsigned long max_capacity, capacity;
 	int ret;
 
 	/* Request state should be less than max_level */
@@ -479,10 +478,7 @@  static int cpufreq_set_cur_state(struct thermal_cooling_device *cdev,
 	if (ret >= 0) {
 		cpufreq_cdev->cpufreq_state = state;
 		cpus = cpufreq_cdev->policy->related_cpus;
-		max_capacity = arch_scale_cpu_capacity(cpumask_first(cpus));
-		capacity = frequency * max_capacity;
-		capacity /= cpufreq_cdev->policy->cpuinfo.max_freq;
-		arch_set_thermal_pressure(cpus, max_capacity - capacity);
+		arch_thermal_pressure_update(cpus, frequency);
 		ret = 0;
 	}