Commit 4cc32cb4e92622757685c8732bdfc400243a5644

Authored by Brian Norris
Committed by Zhang Rui
1 parent c517d838eb

tools/thermal: tmon: add --target-temp parameter

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 <computersforpeace@gmail.com>
Acked-by: Jacob Pan <jacob.jun.pan@linux.intel.com>
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: Zhang Rui <rui.zhang@intel.com>

Showing 2 changed files with 14 additions and 2 deletions Side-by-side Diff

tools/thermal/tmon/tmon.8
... ... @@ -55,6 +55,8 @@
55 55 .PP
56 56 The \fB-t --time-interval\fP option sets the polling interval in seconds
57 57 .PP
  58 +The \fB-T --target-temp\fP option sets the initial target temperature
  59 +.PP
58 60 The \fB-v --version\fP option shows the version of \fBtmon \fP
59 61 .PP
60 62 The \fB-z --zone\fP option sets the target therma zone instance to be controlled
tools/thermal/tmon/tmon.c
... ... @@ -64,6 +64,7 @@
64 64 printf(" -h, --help show this help message\n");
65 65 printf(" -l, --log log data to /var/tmp/tmon.log\n");
66 66 printf(" -t, --time-interval sampling time interval, > 1 sec.\n");
  67 + printf(" -T, --target-temp initial target temperature\n");
67 68 printf(" -v, --version show version\n");
68 69 printf(" -z, --zone target thermal zone id\n");
69 70  
... ... @@ -219,6 +220,7 @@
219 220 { "control", 1, NULL, 'c' },
220 221 { "daemon", 0, NULL, 'd' },
221 222 { "time-interval", 1, NULL, 't' },
  223 + { "target-temp", 1, NULL, 'T' },
222 224 { "log", 0, NULL, 'l' },
223 225 { "help", 0, NULL, 'h' },
224 226 { "version", 0, NULL, 'v' },
... ... @@ -231,7 +233,7 @@
231 233 {
232 234 int err = 0;
233 235 int id2 = 0, c;
234   - double yk = 0.0; /* controller output */
  236 + double yk = 0.0, temp; /* controller output */
235 237 int target_tz_index;
236 238  
237 239 if (geteuid() != 0) {
... ... @@ -239,7 +241,7 @@
239 241 exit(EXIT_FAILURE);
240 242 }
241 243  
242   - while ((c = getopt_long(argc, argv, "c:dlht:vgz:", opts, &id2)) != -1) {
  244 + while ((c = getopt_long(argc, argv, "c:dlht:T:vgz:", opts, &id2)) != -1) {
243 245 switch (c) {
244 246 case 'c':
245 247 no_control = 0;
... ... @@ -253,6 +255,14 @@
253 255 ticktime = strtod(optarg, NULL);
254 256 if (ticktime < 1)
255 257 ticktime = 1;
  258 + break;
  259 + case 'T':
  260 + temp = strtod(optarg, NULL);
  261 + if (temp < 0) {
  262 + fprintf(stderr, "error: temperature must be positive\n");
  263 + return 1;
  264 + }
  265 + target_temp_user = temp;
256 266 break;
257 267 case 'l':
258 268 printf("Logging data to /var/tmp/tmon.log\n");