Skip to content

Commit

Permalink
tools/thermal: tmon: add --target-temp parameter
Browse files Browse the repository at this point in the history
If we launch in daemon mode (--daemon), we don't have the ncurses UI,
but we might want to set the target temperature still. For example,
someone might stick the following in their boot script:

  tmon --control intel_powerclamp --target-temp 90 --log --daemon

This would turn on CPU idle injection when we're around 90 degrees
celsius, and would log temperature and throttling info to
/var/tmp/tmon.log.

Signed-off-by: Brian Norris <[email protected]>
Acked-by: Jacob Pan <[email protected]>
Reviewed-by: Florian Fainelli <[email protected]>
Signed-off-by: Zhang Rui <[email protected]>
  • Loading branch information
computersforpeace authored and zhang-rui committed Feb 28, 2015
1 parent c517d83 commit 4cc32cb
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
2 changes: 2 additions & 0 deletions tools/thermal/tmon/tmon.8
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ The \fB-l --log\fP option write data to /var/tmp/tmon.log
.PP
The \fB-t --time-interval\fP option sets the polling interval in seconds
.PP
The \fB-T --target-temp\fP option sets the initial target temperature
.PP
The \fB-v --version\fP option shows the version of \fBtmon \fP
.PP
The \fB-z --zone\fP option sets the target therma zone instance to be controlled
Expand Down
14 changes: 12 additions & 2 deletions tools/thermal/tmon/tmon.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ void usage()
printf(" -h, --help show this help message\n");
printf(" -l, --log log data to /var/tmp/tmon.log\n");
printf(" -t, --time-interval sampling time interval, > 1 sec.\n");
printf(" -T, --target-temp initial target temperature\n");
printf(" -v, --version show version\n");
printf(" -z, --zone target thermal zone id\n");

Expand Down Expand Up @@ -219,6 +220,7 @@ static struct option opts[] = {
{ "control", 1, NULL, 'c' },
{ "daemon", 0, NULL, 'd' },
{ "time-interval", 1, NULL, 't' },
{ "target-temp", 1, NULL, 'T' },
{ "log", 0, NULL, 'l' },
{ "help", 0, NULL, 'h' },
{ "version", 0, NULL, 'v' },
Expand All @@ -231,15 +233,15 @@ int main(int argc, char **argv)
{
int err = 0;
int id2 = 0, c;
double yk = 0.0; /* controller output */
double yk = 0.0, temp; /* controller output */
int target_tz_index;

if (geteuid() != 0) {
printf("TMON needs to be run as root\n");
exit(EXIT_FAILURE);
}

while ((c = getopt_long(argc, argv, "c:dlht:vgz:", opts, &id2)) != -1) {
while ((c = getopt_long(argc, argv, "c:dlht:T:vgz:", opts, &id2)) != -1) {
switch (c) {
case 'c':
no_control = 0;
Expand All @@ -254,6 +256,14 @@ int main(int argc, char **argv)
if (ticktime < 1)
ticktime = 1;
break;
case 'T':
temp = strtod(optarg, NULL);
if (temp < 0) {
fprintf(stderr, "error: temperature must be positive\n");
return 1;
}
target_temp_user = temp;
break;
case 'l':
printf("Logging data to /var/tmp/tmon.log\n");
logging = 1;
Expand Down

0 comments on commit 4cc32cb

Please sign in to comment.