Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

drivers: thermal: step_wise: add support for hysteresis #5936

Merged
merged 1 commit into from
Feb 9, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 17 additions & 6 deletions drivers/thermal/gov_step_wise.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,22 +86,33 @@ static void thermal_zone_trip_update(struct thermal_zone_device *tz, int trip_id
struct thermal_instance *instance;
bool throttle = false;
int old_target;
int hyst_temp;

trend = get_tz_trend(tz, trip_id);

if (tz->temperature >= trip->temperature) {
throttle = true;
trace_thermal_zone_trip(tz, trip_id, trip->type);
}
hyst_temp = trip->temperature - trip->hysteresis;

dev_dbg(&tz->device, "Trip%d[type=%d,temp=%d]:trend=%d,throttle=%d\n",
trip_id, trip->type, trip->temperature, trend, throttle);
dev_dbg(&tz->device,
"Trip%d[type=%d,temp=%d,hyst=%d]:trend=%d,throttle=%d\n",
trip_id, trip->type, trip->temperature, hyst_temp, trend, throttle);

list_for_each_entry(instance, &tz->thermal_instances, tz_node) {
if (instance->trip != trip)
continue;

old_target = instance->target;
throttle = false;
/*
* Lower the mitigation only if the temperature
* goes below the hysteresis temperature.
*/
if (tz->temperature >= trip->temperature ||
(tz->temperature >= hyst_temp &&
old_target == instance->upper)) {
throttle = true;
trace_thermal_zone_trip(tz, trip_id, trip->type);
}

instance->target = get_target_state(instance, trend, throttle);
dev_dbg(&instance->cdev->device, "old_target=%d, target=%d\n",
old_target, (int)instance->target);
Expand Down
Loading