]> www.infradead.org Git - users/willy/xarray.git/commitdiff
thermal/cpu-cooling: Update thermal pressure in case of a maximum frequency capping
authorThara Gopinath <thara.gopinath@linaro.org>
Sat, 22 Feb 2020 00:52:12 +0000 (19:52 -0500)
committerIngo Molnar <mingo@kernel.org>
Fri, 6 Mar 2020 11:57:21 +0000 (12:57 +0100)
Thermal governors can request for a CPU's maximum supported frequency to
be capped in case of an overheat event. This in turn means that the
maximum capacity available for tasks to run on the particular CPU is
reduced. Delta between the original maximum capacity and capped maximum
capacity is known as thermal pressure. Enable cpufreq cooling device to
update the thermal pressure in event of a capped maximum frequency.

Signed-off-by: Thara Gopinath <thara.gopinath@linaro.org>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Link: https://lkml.kernel.org/r/20200222005213.3873-9-thara.gopinath@linaro.org
drivers/thermal/cpufreq_cooling.c

index fe83d7a210d478b54c9ab71df1bbd88d2c8fb6f1..4ae8c856c88ededfa67e867c8b8b7fdf5844c6b5 100644 (file)
@@ -431,6 +431,10 @@ static int cpufreq_set_cur_state(struct thermal_cooling_device *cdev,
                                 unsigned long state)
 {
        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 */
        if (WARN_ON(state > cpufreq_cdev->max_level))
@@ -442,8 +446,19 @@ static int cpufreq_set_cur_state(struct thermal_cooling_device *cdev,
 
        cpufreq_cdev->cpufreq_state = state;
 
-       return freq_qos_update_request(&cpufreq_cdev->qos_req,
-                               get_state_freq(cpufreq_cdev, state));
+       frequency = get_state_freq(cpufreq_cdev, state);
+
+       ret = freq_qos_update_request(&cpufreq_cdev->qos_req, frequency);
+
+       if (ret > 0) {
+               cpus = cpufreq_cdev->policy->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);
+       }
+
+       return ret;
 }
 
 /* Bind cpufreq callbacks to thermal cooling device ops */