From e8758eb974fd49fc82b90afab4b60c586b9b4ecc Mon Sep 17 00:00:00 2001 From: wangjianyu3 Date: Tue, 19 Dec 2023 10:48:04 +0800 Subject: [PATCH] Thermal/step_wise: Increase cooling state in case of "stable" trend and "hot" trip. Signed-off-by: wangjianyu3 --- drivers/thermal/thermal_dummy.c | 2 +- drivers/thermal/thermal_step_wise.c | 25 ++++++++++++++++++------- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/drivers/thermal/thermal_dummy.c b/drivers/thermal/thermal_dummy.c index 7765a052a7..c8d40d3319 100644 --- a/drivers/thermal/thermal_dummy.c +++ b/drivers/thermal/thermal_dummy.c @@ -102,7 +102,7 @@ static int dummy_cpufreq_resume (FAR struct cpufreq_policy *driver); static const struct thermal_zone_trip_s g_dummy_trips[] = { {.name = "cpu_crit", .temp = 90, .hyst = 10, .type = THERMAL_CRITICAL}, - {.name = "cpu_alert1", .temp = 70, .hyst = 10, .type = THERMAL_NORMAL}, + {.name = "cpu_alert1", .temp = 70, .hyst = 10, .type = THERMAL_HOT}, {.name = "cpu_alert0", .temp = 60, .hyst = 10, .type = THERMAL_NORMAL}, }; diff --git a/drivers/thermal/thermal_step_wise.c b/drivers/thermal/thermal_step_wise.c index 283f782267..5405ba8ee8 100644 --- a/drivers/thermal/thermal_step_wise.c +++ b/drivers/thermal/thermal_step_wise.c @@ -84,22 +84,21 @@ static unsigned int get_target_state(FAR struct thermal_instance_s *instance, bool throttle) { FAR struct thermal_cooling_device_s *cdev = instance->cdev; - unsigned int next_state = THERMAL_NO_TARGET; unsigned int cur_state = instance->target; if (!cdev->ops || !cdev->ops->get_state) { - return next_state; + return THERMAL_NO_TARGET; } if (cur_state == THERMAL_NO_TARGET) { if (throttle) { - next_state = validate_state(instance, throttle, cur_state, 1); + return validate_state(instance, throttle, cur_state, 1); } - return next_state; + return THERMAL_NO_TARGET; } /* Update Cooling State */ @@ -109,25 +108,37 @@ static unsigned int get_target_state(FAR struct thermal_instance_s *instance, case THERMAL_TREND_RAISING: if (throttle) { - next_state = validate_state(instance, throttle, cur_state, 1); + return validate_state(instance, throttle, cur_state, 1); } break; case THERMAL_TREND_DROPPING: if (!throttle) { - next_state = validate_state(instance, throttle, cur_state, -1); + return validate_state(instance, throttle, cur_state, -1); } break; case THERMAL_TREND_STABLE: + if (throttle) + { + enum thermal_trip_type_e type; + int ret; + + ret = thermal_zone_get_trip_type(instance->zdev, instance->trip, + &type); + if (ret >= 0 && type == THERMAL_HOT) + { + return validate_state(instance, throttle, cur_state, 1); + } + } break; default: break; } - return next_state; + return THERMAL_NO_TARGET; } /* step_wise */