diff options
author | Lukasz Luba <lukasz.luba@arm.com> | 2021-01-19 11:41:26 +0000 |
---|---|---|
committer | Daniel Lezcano <daniel.lezcano@linaro.org> | 2021-01-19 22:31:10 +0100 |
commit | 7a583405f24bffdd9f696a8e1b2f02c297245f4d (patch) | |
tree | e95fb6b8706511bab38b0882c1f04fb823062a17 | |
parent | 23ff8529ee207c634ce2e170c353938db7aa98a9 (diff) | |
download | linux-stable-7a583405f24bffdd9f696a8e1b2f02c297245f4d.tar.gz linux-stable-7a583405f24bffdd9f696a8e1b2f02c297245f4d.tar.bz2 linux-stable-7a583405f24bffdd9f696a8e1b2f02c297245f4d.zip |
thermal: power allocator: fail binding for non-power actor devices
The thermal zone can have cooling devices which are missing power actor
API. This could be due to missing Energy Model for devfreq or cpufreq
cooling device. In this case it is safe to fail the binding rather than
trying to workaround and control the temperature in such thermal zone.
Signed-off-by: Lukasz Luba <lukasz.luba@arm.com>
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Link: https://lore.kernel.org/r/20210119114126.19480-1-lukasz.luba@arm.com
-rw-r--r-- | drivers/thermal/gov_power_allocator.c | 35 |
1 files changed, 34 insertions, 1 deletions
diff --git a/drivers/thermal/gov_power_allocator.c b/drivers/thermal/gov_power_allocator.c index f8c3d1e40b86..92acae53df49 100644 --- a/drivers/thermal/gov_power_allocator.c +++ b/drivers/thermal/gov_power_allocator.c @@ -590,13 +590,42 @@ static void allow_maximum_power(struct thermal_zone_device *tz) } /** + * check_power_actors() - Check all cooling devices and warn when they are + * not power actors + * @tz: thermal zone to operate on + * + * Check all cooling devices in the @tz and warn every time they are missing + * power actor API. The warning should help to investigate the issue, which + * could be e.g. lack of Energy Model for a given device. + * + * Return: 0 on success, -EINVAL if any cooling device does not implement + * the power actor API. + */ +static int check_power_actors(struct thermal_zone_device *tz) +{ + struct thermal_instance *instance; + int ret = 0; + + list_for_each_entry(instance, &tz->thermal_instances, tz_node) { + if (!cdev_is_power_actor(instance->cdev)) { + dev_warn(&tz->device, "power_allocator: %s is not a power actor\n", + instance->cdev->type); + ret = -EINVAL; + } + } + + return ret; +} + +/** * power_allocator_bind() - bind the power_allocator governor to a thermal zone * @tz: thermal zone to bind it to * * Initialize the PID controller parameters and bind it to the thermal * zone. * - * Return: 0 on success, or -ENOMEM if we ran out of memory. + * Return: 0 on success, or -ENOMEM if we ran out of memory, or -EINVAL + * when there are unsupported cooling devices in the @tz. */ static int power_allocator_bind(struct thermal_zone_device *tz) { @@ -604,6 +633,10 @@ static int power_allocator_bind(struct thermal_zone_device *tz) struct power_allocator_params *params; int control_temp; + ret = check_power_actors(tz); + if (ret) + return ret; + params = kzalloc(sizeof(*params), GFP_KERNEL); if (!params) return -ENOMEM; |