Skip to content

Commit 0952177

Browse files
lukaszluba-armdlezcano
authored andcommitted
thermal/core/power_allocator: Update once cooling devices when temp is low
The cooling device state change generates an event, also when there is no need, because temperature is low and device is not throttled. Avoid to unnecessary update the cooling device which means also not sending event. The cooling device state has not changed because the temperature is still below the first activation trip point value, so we can do this. Add a tracking mechanism to make sure it updates cooling devices only once - when the temperature dropps below first trip point. Reported-by: Daniel Lezcano <daniel.lezcano@linaro.org> Signed-off-by: Lukasz Luba <lukasz.luba@arm.com> Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org> Link: https://lore.kernel.org/r/20210422114308.29684-4-lukasz.luba@arm.com
1 parent d3b60ed commit 0952177

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

drivers/thermal/gov_power_allocator.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -571,7 +571,7 @@ static void reset_pid_controller(struct power_allocator_params *params)
571571
params->prev_err = 0;
572572
}
573573

574-
static void allow_maximum_power(struct thermal_zone_device *tz)
574+
static void allow_maximum_power(struct thermal_zone_device *tz, bool update)
575575
{
576576
struct thermal_instance *instance;
577577
struct power_allocator_params *params = tz->governor_data;
@@ -594,9 +594,10 @@ static void allow_maximum_power(struct thermal_zone_device *tz)
594594
*/
595595
cdev->ops->get_requested_power(cdev, &req_power);
596596

597-
instance->cdev->updated = false;
597+
if (update)
598+
__thermal_cdev_update(instance->cdev);
599+
598600
mutex_unlock(&instance->cdev->lock);
599-
thermal_cdev_update(instance->cdev);
600601
}
601602
mutex_unlock(&tz->lock);
602603
}
@@ -710,6 +711,7 @@ static int power_allocator_throttle(struct thermal_zone_device *tz, int trip)
710711
int ret;
711712
int switch_on_temp, control_temp;
712713
struct power_allocator_params *params = tz->governor_data;
714+
bool update;
713715

714716
/*
715717
* We get called for every trip point but we only need to do
@@ -721,9 +723,10 @@ static int power_allocator_throttle(struct thermal_zone_device *tz, int trip)
721723
ret = tz->ops->get_trip_temp(tz, params->trip_switch_on,
722724
&switch_on_temp);
723725
if (!ret && (tz->temperature < switch_on_temp)) {
726+
update = (tz->last_temperature >= switch_on_temp);
724727
tz->passive = 0;
725728
reset_pid_controller(params);
726-
allow_maximum_power(tz);
729+
allow_maximum_power(tz, update);
727730
return 0;
728731
}
729732

0 commit comments

Comments
 (0)