Thermal/step_wise: Increase cooling state in case of "stable" trend and "hot" trip.

Signed-off-by: wangjianyu3 <wangjianyu3@xiaomi.com>
This commit is contained in:
wangjianyu3
2023-12-19 10:48:04 +08:00
committed by Xiang Xiao
parent 68d5516c90
commit e8758eb974
2 changed files with 19 additions and 8 deletions
+1 -1
View File
@@ -102,7 +102,7 @@ static int dummy_cpufreq_resume (FAR struct cpufreq_policy *driver);
static const struct thermal_zone_trip_s g_dummy_trips[] = static const struct thermal_zone_trip_s g_dummy_trips[] =
{ {
{.name = "cpu_crit", .temp = 90, .hyst = 10, .type = THERMAL_CRITICAL}, {.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}, {.name = "cpu_alert0", .temp = 60, .hyst = 10, .type = THERMAL_NORMAL},
}; };
+18 -7
View File
@@ -84,22 +84,21 @@ static unsigned int get_target_state(FAR struct thermal_instance_s *instance,
bool throttle) bool throttle)
{ {
FAR struct thermal_cooling_device_s *cdev = instance->cdev; FAR struct thermal_cooling_device_s *cdev = instance->cdev;
unsigned int next_state = THERMAL_NO_TARGET;
unsigned int cur_state = instance->target; unsigned int cur_state = instance->target;
if (!cdev->ops || !cdev->ops->get_state) if (!cdev->ops || !cdev->ops->get_state)
{ {
return next_state; return THERMAL_NO_TARGET;
} }
if (cur_state == THERMAL_NO_TARGET) if (cur_state == THERMAL_NO_TARGET)
{ {
if (throttle) 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 */ /* Update Cooling State */
@@ -109,25 +108,37 @@ static unsigned int get_target_state(FAR struct thermal_instance_s *instance,
case THERMAL_TREND_RAISING: case THERMAL_TREND_RAISING:
if (throttle) if (throttle)
{ {
next_state = validate_state(instance, throttle, cur_state, 1); return validate_state(instance, throttle, cur_state, 1);
} }
break; break;
case THERMAL_TREND_DROPPING: case THERMAL_TREND_DROPPING:
if (!throttle) if (!throttle)
{ {
next_state = validate_state(instance, throttle, cur_state, -1); return validate_state(instance, throttle, cur_state, -1);
} }
break; break;
case THERMAL_TREND_STABLE: 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; break;
default: default:
break; break;
} }
return next_state; return THERMAL_NO_TARGET;
} }
/* step_wise */ /* step_wise */