Skip to content

Commit

Permalink
Merge pull request #24 from plundstr/master
Browse files Browse the repository at this point in the history
Sanity checking for thermal limits
  • Loading branch information
Pekka Lundstrom committed Oct 2, 2013
2 parents cb8a729 + 2c9af4e commit cd00d47
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 15 deletions.
2 changes: 1 addition & 1 deletion configure.ac
@@ -1,5 +1,5 @@
# Package name and version
AC_INIT(dsme, 0.62.18)
AC_INIT(dsme, 0.62.19)

AM_INIT_AUTOMAKE

Expand Down
41 changes: 33 additions & 8 deletions modules/thermalmanager.c
Expand Up @@ -367,6 +367,7 @@ void module_fini(void)
#ifdef DSME_THERMAL_TUNING
#include <stdio.h>

/* Thermal values can be configured in file /etc/dsme/temp_<name>.conf */
#define DSME_THERMAL_TUNING_CONF_PATH "/etc/dsme/temp_"

static FILE* thermal_tuning_file(const char* thermal_object_name)
Expand All @@ -375,7 +376,7 @@ static FILE* thermal_tuning_file(const char* thermal_object_name)

snprintf(name,
sizeof(name),
"%s%s",
"%s%s.conf",
DSME_THERMAL_TUNING_CONF_PATH,
thermal_object_name);

Expand All @@ -396,18 +397,42 @@ static bool thermal_object_config_read(

for (i = 0; i < THERMAL_STATUS_COUNT; ++i) {
if (fscanf(f,
"%d, %d, %d, %d",
"%d, %d, %d",
&new_config.state[i].min,
&new_config.state[i].max,
&new_config.state[i].mintime,
&new_config.state[i].maxtime) != 4)
{
dsme_log(LOG_ERR, "syntax error in thermal tuning on line %d", i+1);
&new_config.state[i].maxtime) != 3) {
success = false;
}
if (success) {
/* Do some sanity checking for values
* Temp values should be between 20-200, and in ascending order.
* Min must be < max
* Next min <= previous max
* Polling times should also make sense 10-1000s
*/
if (((i > THERMAL_STATUS_NORMAL) && (new_config.state[i].min < 20)) ||
(new_config.state[i].max < 20) ||
(new_config.state[i].min > 200) ||
((i > THERMAL_STATUS_FATAL) && (new_config.state[i].max > 200)) ||
(new_config.state[i].min >= new_config.state[i].max) ||
((i > THERMAL_STATUS_NORMAL) && (new_config.state[i].min <= new_config.state[i-1].min)) ||
((i > THERMAL_STATUS_NORMAL) && (new_config.state[i].max <= new_config.state[i-1].max)) ||
((i > THERMAL_STATUS_NORMAL) && (new_config.state[i].min > new_config.state[i-1].max)) ||
(new_config.state[i].maxtime < 10) ||
(new_config.state[i].maxtime > 1000)) {
success = false;
}
}
if (success) {
/* Note, it is important to give big enough window min..max
* then IPHB can freely choose best wake-up time
*/
new_config.state[i].mintime = new_config.state[i].maxtime/2;
} else {
dsme_log(LOG_ERR, "syntax error in thermal tuning on line %d", i+1);
break;
}
}

if (success) {
*config = new_config;
}
Expand Down Expand Up @@ -512,6 +537,6 @@ static void log_temperature(int temperature, const thermal_object_t* thermal_obj
status_string(thermal_object->status));
fflush(log_file);
dsme_log(LOG_DEBUG,"%s %d C %s", thermal_object->conf->name,
temperature, status_string(thermal_object->status));
temperature, status_string(thermal_object->status));
}
#endif
8 changes: 4 additions & 4 deletions modules/thermalobject_hw.c
Expand Up @@ -41,8 +41,8 @@ static thermal_object_configuration_t core_thermal_conf = {
"hw_core",
{
/* (min, max], [mintime, maxtime] */
{ -99, 100, 110, 120 }, /* NORMAL */
{ 99, 110, 55, 60 }, /* WARNING */
{ -99, 100, 60, 120 }, /* NORMAL */
{ 99, 110, 30, 60 }, /* WARNING */
{ 109, 119, 5, 10 }, /* ALERT */
{ 119, 200, 5, 10 } /* FATAL */
},
Expand All @@ -62,8 +62,8 @@ static thermal_object_configuration_t battery_thermal_conf = {
"hw_battery",
{
/* (min, max], [mintime, maxtime] */
{ -99, 60, 110, 120 }, /* NORMAL */
{ 59, 65, 55, 60 }, /* WARNING */
{ -99, 60, 60, 120 }, /* NORMAL */
{ 59, 65, 30, 60 }, /* WARNING */
{ 64, 68, 5, 10 }, /* ALERT */
{ 68, 99, 5, 10 }, /* FATAL */
},
Expand Down
2 changes: 1 addition & 1 deletion rpm/dsme.spec
Expand Up @@ -13,7 +13,7 @@ Name: dsme
# << macros

Summary: Device State Management Entity
Version: 0.62.18
Version: 0.62.19
Release: 0
Group: System/System Control
License: LGPLv2+
Expand Down
2 changes: 1 addition & 1 deletion rpm/dsme.yaml
@@ -1,6 +1,6 @@
Name: dsme
Summary: Device State Management Entity
Version: 0.62.18
Version: 0.62.19
Release: 0
Group: System/System Control
License: LGPLv2+
Expand Down

0 comments on commit cd00d47

Please sign in to comment.