Skip to content

Commit

Permalink
thermal/drivers/cpufreq_cooling: Fix return of cpufreq_set_cur_state
Browse files Browse the repository at this point in the history
When setting the cooling device current state from userspace via sysfs,
the operation fails by returning an -EINVAL.

It appears the recent changes with the per-policy frequency QoS
introduced a regression as reported by:

 https://lkml.org/lkml/2020/3/20/599

The function freq_qos_update_request returns 0 or 1 describing update
effectiveness, and a negative error code on failure. However,
cpufreq_set_cur_state returns 0 on success or an error code otherwise.

Consider the QoS update as successful if the function does not return
an error.

Fixes: 3000ce3 ("cpufreq: Use per-policy frequency QoS")
Signed-off-by: Willy Wolff <willy.mh.wolff.ml@gmail.com>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Link: https://lore.kernel.org/r/20200321092740.7vvwfxsebcrznydh@macmini.local
  • Loading branch information
Willy Wolff authored and Daniel Lezcano committed Mar 23, 2020
1 parent 2b8f1f0 commit ff44f67
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions drivers/thermal/cpufreq_cooling.c
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,7 @@ static int cpufreq_set_cur_state(struct thermal_cooling_device *cdev,
unsigned long state)
{
struct cpufreq_cooling_device *cpufreq_cdev = cdev->devdata;
int ret;

/* Request state should be less than max_level */
if (WARN_ON(state > cpufreq_cdev->max_level))
Expand All @@ -442,8 +443,9 @@ 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));
ret = freq_qos_update_request(&cpufreq_cdev->qos_req,
get_state_freq(cpufreq_cdev, state));
return ret < 0 ? ret : 0;
}

/* Bind cpufreq callbacks to thermal cooling device ops */
Expand Down

0 comments on commit ff44f67

Please sign in to comment.