diff --git a/kernel/sched/walt/walt.c b/kernel/sched/walt/walt.c index fa2d3d3bf5df..4cc53c862870 100644 --- a/kernel/sched/walt/walt.c +++ b/kernel/sched/walt/walt.c @@ -3821,31 +3821,32 @@ static void walt_cpu_frequency_limits(void *unused, struct cpufreq_policy *polic */ static void android_rvh_update_cpu_capacity(void *unused, int cpu, unsigned long *capacity) { - unsigned long max_capacity = arch_scale_cpu_capacity(cpu); + unsigned long fmax_capacity = arch_scale_cpu_capacity(cpu); unsigned long thermal_pressure = arch_scale_thermal_pressure(cpu); unsigned long thermal_cap; struct walt_sched_cluster *cluster; - unsigned long rt_pressure = max_capacity - *capacity; + unsigned long rt_pressure = fmax_capacity - *capacity; + struct rq *rq = cpu_rq(cpu); if (unlikely(walt_disabled)) return; /* - * thermal_pressure = max_capacity - curr_cap_as_per_thermal. + * thermal_pressure = cpu_scale - curr_cap_as_per_thermal. * so, - * curr_cap_as_per_thermal = max_capacity - thermal_pressure. + * curr_cap_as_per_thermal = cpu_scale - thermal_pressure. */ - thermal_cap = max_capacity - thermal_pressure; + thermal_cap = fmax_capacity - thermal_pressure; cluster = cpu_cluster(cpu); - /* reduce the max_capacity under cpufreq constraints */ + /* reduce the fmax_capacity under cpufreq constraints */ if (cluster->max_freq != cluster->max_possible_freq) - max_capacity = mult_frac(max_capacity, cluster->max_freq, + fmax_capacity = mult_frac(fmax_capacity, cluster->max_freq, cluster->max_possible_freq); - cpu_rq(cpu)->cpu_capacity_orig = min(max_capacity, thermal_cap); - *capacity = cpu_rq(cpu)->cpu_capacity_orig - rt_pressure; + rq->cpu_capacity_orig = min(fmax_capacity, thermal_cap); + *capacity = max(rq->cpu_capacity_orig - rt_pressure, 1UL); } static void android_rvh_sched_cpu_starting(void *unused, int cpu)