pass: resmon: Add uevent-based RESMON_SRC_THERMAL source 67/172667/4
authorChanwoo Choi <cw00.choi@samsung.com>
Thu, 8 Mar 2018 11:00:30 +0000 (20:00 +0900)
committerChanwoo Choi <cw00.choi@samsung.com>
Fri, 16 Mar 2018 06:19:39 +0000 (15:19 +0900)
RESMON_SRC_THERMAL indicates the thermal monitoring for h/w resource
such as CPU, GPU and so on. The uevent-based RESMON_SRC_THERMAL uses
the uevent from kernel. When receving the uevent, RESMON_SRC_THERMAL
reads the temperature of h/w resource and then pass it to consumer
of resource monitor.

It is standard Linux Kernel interface which provides the thermal information
through thermal framework of Linux Kernel.

[Description of RESMON_SRC_THERMAL resource-monitor]
- The kind of resource data
: temperature of h/w resource (unit is centigrade)
: (e.g., 47000 means 47.0 degrees centigrade)

- The 'subsystem' name for uevent-based RESMON_SRC_THERMAL
: "thermal"

- Path of RESMON_SRC_THERMAL monitoring
: cat /sys/class/thermal/thermal_zone[X]/temp

- Result of RESMON_SRC_THERMAL monitoring
$ cat /sys/class/thermal/thermal_zone0/temp
47000

For exmaple on TM2 board,
: thermal_zone0 for ARM big core on TM2
: thermal_zone2 for ARM GPU on TM2
: thermal_zone3 for ARM LITTLE core on TM2

Change-Id: Ib66abc11b16c1e17084bc9b89e06c4fb81e6f897
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
src/pass/pass-resmon-source.c

index a3a0b8e461c1ece03431a3b4c3d981e65fe3bc8a..5da41bde738d12d3b814c323f63d3124df51405f 100644 (file)
@@ -74,6 +74,28 @@ static int resmon_thermal_timer_handler(struct resmon *monitor, void *result)
        return 0;
 }
 
+static int resmon_thermal_uevent_handler(struct resmon *monitor, void *result,
+                                               struct udev_device *dev)
+{
+       struct pass_resmon *resmon = monitor->resmon;
+       struct pass_resource *res =
+                       container_of(resmon, struct pass_resource, resmon);
+       struct resmon_result_src_thermal *thermal_result = result;
+       int temp;
+
+       if (!thermal_result)
+               return -ENOMEM;
+
+       /* Get temperature of h/w resource */
+       temp = pass_get_temp(res);
+       if (temp < 0)
+               return temp;
+
+       thermal_result->temp = temp;
+
+       return 0;
+}
+
 /* RESMON_SRC_CPUHP */
 #define RESMON_SRC_CPUHP_COUNT 20
 static int resmon_cpuhp_init(struct resmon *monitor)
@@ -176,8 +198,8 @@ struct resmon_ops thermal_src_ops = {
        .init = resmon_thermal_init,
        .exit = resmon_thermal_exit,
        .timer_handler = resmon_thermal_timer_handler,
-       .uevent_handler = NULL,
-       .uevent_subsystem = NULL,
+       .uevent_handler = resmon_thermal_uevent_handler,
+       .uevent_subsystem = "thermal",
        .uevent_devtype = NULL,
 };