Skip to content

Commit

Permalink
thermal: gov_power_allocator: Allow binding before cooling devices
Browse files Browse the repository at this point in the history
Commit e83747c ("thermal: gov_power_allocator: Set up trip points earlier")
added a check that would fail binding the governer if there is no
cooling devices bound to the thermal zone. Unfortunately this causes
issues in cases when the TZ is bound to the governer before the cooling
devices are attached to it. (I.e. when the tz is registered using
thermal_zone_device_register_with_trips().)

Additionally, the documentation across gov_power_allocator suggests it's
intended to allow it to be bound to thermal zones without cooling
devices (and thus without passive/active trip points), however the same
commit added a check for the trip point to be present, causing those TZ
to fail probing.

Those changes cause all thermal zones to fail on some devices (such as
sc7180-acer-aspire1) and prevent the kernel from controlling the cpu/gpu
frequency based on the temperature, as well as loosing other
"informational" thermal zones.

This commit partially reverts the referenced one by dropping the trip
point check and by allowing the TZ to probe even if no actor bufer was
allocated.

Fixes: e83747c ("thermal: gov_power_allocator: Set up trip points earlier")
Signed-off-by: Nikita Travkin <nikita@trvn.ru>
  • Loading branch information
TravMurav committed Mar 21, 2024
1 parent bd9f11b commit 39f857f
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions drivers/thermal/gov_power_allocator.c
Original file line number Diff line number Diff line change
Expand Up @@ -679,11 +679,6 @@ static int power_allocator_bind(struct thermal_zone_device *tz)
return -ENOMEM;

get_governor_trips(tz, params);
if (!params->trip_max) {
dev_warn(&tz->device, "power_allocator: missing trip_max\n");
kfree(params);
return -EINVAL;
}

ret = check_power_actors(tz, params);
if (ret < 0) {
Expand All @@ -693,7 +688,7 @@ static int power_allocator_bind(struct thermal_zone_device *tz)
}

ret = allocate_actors_buffer(params, ret);
if (ret) {
if (ret && ret != -EINVAL) {
dev_warn(&tz->device, "power_allocator: allocation failed\n");
kfree(params);
return ret;
Expand All @@ -712,9 +707,10 @@ static int power_allocator_bind(struct thermal_zone_device *tz)
if (!tz->tzp->sustainable_power)
dev_warn(&tz->device, "power_allocator: sustainable_power will be estimated\n");

estimate_pid_constants(tz, tz->tzp->sustainable_power,
params->trip_switch_on,
params->trip_max->temperature);
if (params->trip_max)
estimate_pid_constants(tz, tz->tzp->sustainable_power,
params->trip_switch_on,
params->trip_max->temperature);

reset_pid_controller(params);

Expand Down

0 comments on commit 39f857f

Please sign in to comment.