From 5c773b992d8db9e58df1879cc8b284623f772f13 Mon Sep 17 00:00:00 2001 From: Vivek Aknurwar Date: Mon, 11 Jul 2022 17:26:56 -0700 Subject: [PATCH] cpufreq: qcom-hw: clear thermal pressure when thermal condition exits clear thermal pressure when thermal polling is stopped as throttle frequency is greater than what scheduler or cpu are set to. This change prevents throttle loop exiting with stale, non-zero thermal pressure resulted from race condition of requested frequency change after throttle_freq condition check in throttle loop. Change-Id: If9c40e20350c5d33b3ad7a58cfe213eeb5dda74b Signed-off-by: Vivek Aknurwar --- drivers/cpufreq/qcom-cpufreq-hw.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/drivers/cpufreq/qcom-cpufreq-hw.c b/drivers/cpufreq/qcom-cpufreq-hw.c index b9e62f92e4ce..1449199e35d4 100644 --- a/drivers/cpufreq/qcom-cpufreq-hw.c +++ b/drivers/cpufreq/qcom-cpufreq-hw.c @@ -377,18 +377,13 @@ static void qcom_lmh_dcvs_notify(struct qcom_cpufreq_data *data) if (IS_ERR(opp) && PTR_ERR(opp) == -ERANGE) opp = dev_pm_opp_find_freq_ceil(dev, &freq_hz); - if (IS_ERR(opp)) { + if (IS_ERR(opp)) dev_warn(dev, "Can't find the OPP for throttling: %pe!\n", opp); - } else { - throttled_freq = freq_hz / HZ_PER_KHZ; - - trace_dcvsh_freq(cpu, qcom_cpufreq_hw_get(cpu), throttled_freq); - - /* Update thermal pressure (the boost frequencies are accepted) */ - arch_update_thermal_pressure(policy->related_cpus, throttled_freq); - + else dev_pm_opp_put(opp); - } + + throttled_freq = freq_hz / HZ_PER_KHZ; + trace_dcvsh_freq(cpu, qcom_cpufreq_hw_get(cpu), throttled_freq); /* * In the unlikely case policy is unregistered do not enable @@ -403,6 +398,8 @@ static void qcom_lmh_dcvs_notify(struct qcom_cpufreq_data *data) * for, then stop polling and switch back to interrupt mechanism. */ if (throttled_freq >= qcom_cpufreq_hw_get(cpu)) { + throttled_freq = policy->cpuinfo.max_freq; + enable_irq(data->throttle_irq); trace_dcvsh_throttle(cpu, 0); } else { @@ -410,6 +407,9 @@ static void qcom_lmh_dcvs_notify(struct qcom_cpufreq_data *data) msecs_to_jiffies(10)); } + /* Update thermal pressure (the boost frequencies are accepted) */ + arch_update_thermal_pressure(policy->related_cpus, throttled_freq); + out: mutex_unlock(&data->throttle_lock); }