From: Chanwoo Choi Date: Tue, 13 Feb 2018 13:34:01 +0000 (+0900) Subject: pass: resmon: Add timer-based RESMON_SRC_THERMAL source X-Git-Tag: submit/tizen/20180409.024353~17 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=2fabc28a84d2920d516c5e65ff3bc093c6f3442d;p=platform%2Fcore%2Fsystem%2Fpass.git pass: resmon: Add timer-based RESMON_SRC_THERMAL source RESMON_SRC_THERMAL indicates the thermal monitoring for h/w resource such as CPU, GPU and so on. It is used to decide the current system status like 'Low, Normal, High, Critical and Danger according to temperature of h/w resource'. Also, other subsystems and user-processes can use the temperature information. It is standard Linux Kernel interface which provides the thermal infomation 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) - 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: Ia6272621caea45a3c117d4d5bb9512ccafb9947a Signed-off-by: Chanwoo Choi --- diff --git a/src/pass/pass-resmon-source.c b/src/pass/pass-resmon-source.c index 9c8efcb..754d854 100644 --- a/src/pass/pass-resmon-source.c +++ b/src/pass/pass-resmon-source.c @@ -21,22 +21,56 @@ #include #include "pass.h" +#include "pass-hal.h" #include "pass-resmon.h" #include "pass-resmon-internal.h" /* RESMON_SRC_THERMAL */ static int resmon_thermal_init(struct resmon *monitor) { + struct resmon_result_src_thermal *result; + + if (monitor->result) + return 0; + + result = calloc(1, sizeof(*result)); + if (!result) + return -ENOMEM; + + monitor->result = result; + return 0; } static int resmon_thermal_exit(struct resmon *monitor) { + if (!monitor->result) + return 0; + + free(monitor->result); + monitor->result = NULL; + return 0; } static int resmon_thermal_timer_handler(struct resmon *monitor, void *result) { + 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; } diff --git a/src/pass/pass-resmon.h b/src/pass/pass-resmon.h index 52fdb4e..b3fb8fc 100644 --- a/src/pass/pass-resmon.h +++ b/src/pass/pass-resmon.h @@ -38,6 +38,7 @@ enum resmon_timer_type { * the linux kernel standard interface. * * Description of result format of resource monitor's source type: + * - RESMON_SRC_THERMAL: struct resmon_result_src_thermal * - RESMON_SRC_CPUHP : struct resmon_result_src_cpuhp */ enum resmon_src_type { @@ -46,6 +47,11 @@ enum resmon_src_type { RESMON_SRC_CPUHP = 0x2, }; +/* Result of RESMON_SRC_THERMAL resource monitor */ +struct resmon_result_src_thermal { + int temp; +}; + /* Result of RESMON_SRC_CPUHP's resource monitor */ struct resmon_result_src_cpuhp { int64_t time;