platform/core/system/pass.git
2 years agolib: tmonitor: Implement tmonitor APIs 15/271615/14
Dongwoo Lee [Mon, 7 Mar 2022 07:49:04 +0000 (16:49 +0900)]
lib: tmonitor: Implement tmonitor APIs

Tmonitor provides resource monitoring feature by using socket
connection. This is the first version of that implements a
subset of a tmonitor API set.

Change-Id: I9174ba3849f0eae069ace34e9a1b26be0064a436
Signed-off-by: Sung-hun Kim <sfoon.kim@samsung.com>
Signed-off-by: Dongwoo Lee <dwoo08.lee@samsung.com>
2 years agomonitor: Add request-server and request-handler-thread 14/271614/13
Dongwoo Lee [Mon, 7 Mar 2022 07:50:11 +0000 (16:50 +0900)]
monitor: Add request-server and request-handler-thread

To provide libpass API via socket, a manager is required to
manage network connections and requests from clients.

Request-server is a manager to manage network connections.
It accepts and establishes a socket connection from each
client, then spawns a per-client request-handler-thread to
deal with incoming requests from the client if required.

Change-Id: I17cdf1fde69022663c2369b55982ac43e5b5c688
Signed-off-by: Sung-hun Kim <sfoon.kim@samsung.com>
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
Signed-off-by: Dongwoo Lee <dwoo08.lee@samsung.com>
2 years agoutil: resource: Give unique id for each resource 78/271978/4
Dongwoo Lee [Thu, 3 Mar 2022 11:42:40 +0000 (20:42 +0900)]
util: resource: Give unique id for each resource

Change-Id: I9f4eb44862ed42a2189d1c1f6cac47e760b876fe
Signed-off-by: Dongwoo Lee <dwoo08.lee@samsung.com>
2 years agoresource: Rework resource creation and initialization 77/271977/4
Dongwoo Lee [Thu, 24 Feb 2022 11:40:11 +0000 (20:40 +0900)]
resource: Rework resource creation and initialization

Change-Id: I386e277a20418b4030d3d5a63dcf10ea15898c6c
Signed-off-by: Dongwoo Lee <dwoo08.lee@samsung.com>
2 years agoutil: thread: Support free function for destorying queue 66/271766/2 accepted/tizen/unified/20220302.131908 submit/tizen/20220302.025412 submit/tizen/20220302.031108
Dongwoo Lee [Mon, 28 Feb 2022 09:02:10 +0000 (18:02 +0900)]
util: thread: Support free function for destorying queue

Since lock-free queue can have various data type, users can pass free
function when creating queue along with the corresponding data type in
queue.

Change-Id: I4ede38bd6e36a1622bb39c7183829c5372e3264b
Signed-off-by: Dongwoo Lee <dwoo08.lee@samsung.com>
2 years agoutil: kernel: Use 64-bit unsigned integer for memory information 65/271765/2
Dongwoo Lee [Mon, 28 Feb 2022 05:29:14 +0000 (14:29 +0900)]
util: kernel: Use 64-bit unsigned integer for memory information

Since memory information node of kernel can be presented with 32-bit
signed variable as maximum 2GB, to overcome this limitation, this
changes related functions using 64-bit unsigned integer variable.

Change-Id: Id1b1da468ca5e7c98cd65318c854cd5a98ae2086
Signed-off-by: Dongwoo Lee <dwoo08.lee@samsung.com>
2 years agoresource: Distinguish signed/unsigned and 32/64 bits integer data types 64/271764/1
Dongwoo Lee [Mon, 28 Feb 2022 03:46:25 +0000 (12:46 +0900)]
resource: Distinguish signed/unsigned and 32/64 bits integer data types

To provide clients with the precise integer values, now support the new
data types:
 - DATA_TYPE_INT(32-bit signed integer),
 - DATA_TPYE_INT64(64-bit signed integer),
 - DATA_TYPE_UINT(32-bit unsigned integer),
 - DATA_TPYE_UINT64(64-bit unsigned integer),

Change-Id: I8f70fb38a1fd9876b53d52c2f7592120fc0f9b5c
Signed-off-by: Dongwoo Lee <dwoo08.lee@samsung.com>
2 years agoutil: kernel: Fix STATIC_OVERFLOW issue 54/271754/2
Chanwoo Choi [Mon, 28 Feb 2022 05:41:36 +0000 (14:41 +0900)]
util: kernel: Fix STATIC_OVERFLOW issue

Change-Id: Ic8118a695865913f06da029a47278cccfd266c09
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2 years agoresource: system: avoid possible use-after-free in error path 52/271752/4
Seung-Woo Kim [Mon, 28 Feb 2022 03:42:53 +0000 (12:42 +0900)]
resource: system: avoid possible use-after-free in error path

In error path, assigned pointer is not cleared after free. Fix
to avoid possible use-after-free with the not cleared pointer.

Change-Id: Idaa222afc9660e68cc5021bd251f21cd47e30b97
Signed-off-by: Seung-Woo Kim <sw0312.kim@samsung.com>
2 years agoresource: system: Fix NULL_AFTER_DEREF issue 48/271748/4
Chanwoo Choi [Mon, 28 Feb 2022 03:03:36 +0000 (12:03 +0900)]
resource: system: Fix NULL_AFTER_DEREF issue

Change-Id: I9d25da863b004e11a71e0a44d7f8a0aebb22bc2c
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2 years agoresource: Fix build warning for memory/process resource driver 22/271722/2
Chanwoo Choi [Fri, 25 Feb 2022 10:35:46 +0000 (19:35 +0900)]
resource: Fix build warning for memory/process resource driver

- Build warning 1
src/resource/resource-memory.c:42:10: warning: implicit declaration
  of function 'kernel_get_memory_total' [-Wimplicit-function-declaration]
[   11s]    42 |   return kernel_get_memory_total();
[   11s]       |          ^~~~~~~~~~~~~~~~~~~~~~~
src/resource/resource-memory.c:44:10: warning: implicit declaration
  of function 'kernel_get_memory_info' [-Wimplicit-function-declaration]
[   11s]    44 |   return kernel_get_memory_info(PROC_MEM_INFO_MEM_AVAILABLE);

- Build warning 2
src/resource/resource-process.c:452:19: warning: unused variable 'memory' [-Wunused-variable]
[   12s]   452 |  struct resource *memory;

Change-Id: I2a473453fb02fc7dd1eb8319474fe9e8633ea2a0
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2 years agopass: Add capability for netlink interface 08/271608/1
Dongwoo Lee [Wed, 23 Feb 2022 09:16:16 +0000 (18:16 +0900)]
pass: Add capability for netlink interface

Due to CVE-2011-2494 which prohibits non-privileged users from getting
process information via netlink, pass daemon should be executed by
root or get capability on NET_ADMIN. To do this, it adds capability
into systemd service attribute with cap_net_admin.

Change-Id: Iefd4ca98e963b38a038a8c326f3abad996bb81ee
Signed-off-by: Dongwoo Lee <dwoo08.lee@samsung.com>
2 years agoresource: process: Add new PROCESS_COMM and PROCESS_MEM_PERCENT attributes 15/271515/2
Dongwoo Lee [Tue, 22 Feb 2022 06:21:32 +0000 (15:21 +0900)]
resource: process: Add new PROCESS_COMM and PROCESS_MEM_PERCENT attributes

This introduces the new attributes as follows:

PROCESS_COMM: shows the name of process.
PROCESS_MEM_PERCENT: shows ratio of process rss against system memory.

Change-Id: Ia50715204c4195deed3b469798f3626a2ea45d5c
Signed-off-by: Dongwoo Lee <dwoo08.lee@samsung.com>
2 years agoutil: kernel: export apis for getting memory info 07/271607/1
Dongwoo Lee [Wed, 23 Feb 2022 08:39:57 +0000 (17:39 +0900)]
util: kernel: export apis for getting memory info

Change-Id: Ibd7c78f61de9ffcc8b9635a42c779af550c61124
Signed-off-by: Dongwoo Lee <dwoo08.lee@samsung.com>
2 years agoutil: kernel: Read stationary values once 06/271606/1
Dongwoo Lee [Wed, 23 Feb 2022 07:58:04 +0000 (16:58 +0900)]
util: kernel: Read stationary values once

Since statinary kernel sysfs or procfs nodes is not have to be
read every time, it lets them being read once.

Change-Id: Icee5f825694867ecb84847fd46830274fe8219d3
Signed-off-by: Dongwoo Lee <dwoo08.lee@samsung.com>
2 years agoresource: process: Handle pid, tgid into parsing nla types 14/271514/1
Dongwoo Lee [Mon, 21 Feb 2022 07:22:01 +0000 (16:22 +0900)]
resource: process: Handle pid, tgid into parsing nla types

To prevent pid, tgid is considered error case, add handling of them.

Change-Id: I3ef127312e860f8bf625a8427d5e40cfb68196cc
Signed-off-by: Dongwoo Lee <dwoo08.lee@samsung.com>
2 years agoresource: Add process resource driver 56/271356/2
Dongwoo Lee [Fri, 4 Feb 2022 06:54:46 +0000 (15:54 +0900)]
resource: Add process resource driver

Process resource driver provides information about process using
procfs and taskstats.

[Detailed description of added system attributes]
PROCESS_CPU_UTIL:  It shows cpu usage including its all threads.
PROCESS_MEM_VIRT:  It shows all memory that the process can
access, including memory that is swapped out,
memory that is allocated, but not used, and
memory that is from shared libraries.
PROCESS_MEM_RSS:  It shows how much memory is allocated to that
process and is in RAM.
PROCESS_DISK_READ: It shows acutal disk read bytes per second.
PROCESS_DISK_WRITE: It shows acutal disk write bytes per second.

Change-Id: Iab4a76334fc786f068cbee396f3896184cbfff47
Signed-off-by: Dongwoo Lee <dwoo08.lee@samsung.com>
2 years agoutil: resource: Add missing NULL checking for setting interest mask 60/271260/6
Chanwoo Choi [Thu, 17 Feb 2022 09:16:05 +0000 (18:16 +0900)]
util: resource: Add missing NULL checking for setting interest mask

Change-Id: Ibd91d659b9f0c8fee73114b97fafdde2cd3118a9
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2 years agoresource: Add battery resource driver 56/271256/7
Chanwoo Choi [Thu, 17 Feb 2022 04:12:49 +0000 (13:12 +0900)]
resource: Add battery resource driver

Add battery resouce driver which read the Linux standard power_supply
interface to get the battery information.

[Detailed description of battery attributes]
- BATTERY_CAPACITY indicates the SoC (State of Charging)and unit is %.
- BATTERY_STATUS indicates the charging status.
- BATTERY_TEMPERATURE indicates the battery temperature.
- BATTERY_VOLTAGE_NOW indicates the voltage value now.
- BATTERY_CURRENT_NOW indicates the current value now.
- BATTERY_PRESENT indicates the connection status of battery.
- BATTERY_ONLINE indicates the connection status of charging cable.

Change-Id: I6011e155d3e401f82538abbccba7ba02e33d796b
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2 years agoutil: common: Add sys_get_int helper funciton to get integer 55/271255/5
Chanwoo Choi [Thu, 17 Feb 2022 07:05:33 +0000 (16:05 +0900)]
util: common: Add sys_get_int helper funciton to get integer

Change-Id: I8eca9fe1bb1f0c95954d0439d0f398795a5421db
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2 years agoresource: memory: Add RESOURCE_DRIVER_NO_DEVICE flag 18/271218/12
Chanwoo Choi [Thu, 17 Feb 2022 03:21:06 +0000 (12:21 +0900)]
resource: memory: Add RESOURCE_DRIVER_NO_DEVICE flag

Add RESOURCE_DRIVER_NO_DEVICE flag because memory resouce device
is always existing and fix wrong word.

Change-Id: Iad20a8d7f68a38925c74460e1eda51ec7a1e5128
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2 years agoresource: Add system resource driver 12/271212/16
Chanwoo Choi [Thu, 10 Feb 2022 06:41:49 +0000 (15:41 +0900)]
resource: Add system resource driver

The system resource driver provides the system attributes expressing
the whole system information.

[Detailed description of added system attributes]
- SYSTEM_CPU_UTIL : Average cpu utilization of all cpus
- SYSTEM_CPU_USER_UTIL : Average cpu utilization of all cpus on user
- SYSTEM_CPU_SYS_UTIL : Average cpu utilization of all cpus on system
- SYSTEM_PER_CPU_UTIL : Per-cpu utilization of all cpus
- SYSTEM_PER_CPU_USER_UTIL : Per-cpu utilization on user
- SYSTEM_PER_CPU_SYS_UTIL : Per-cpu utilization on system
- SYSTEM_POSSIBLE_CPU : the number of all cpus regardless cpu online status.
- SYSTEM_ONLINE_CPU : the number of online cpu.

Change-Id: Ide1673e8dae0076bb5dd47002457d0ff0e43649b
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2 years agoutil: resource: Add missing free operation for put_resource_attr_array 13/271213/10
Chanwoo Choi [Thu, 17 Feb 2022 03:11:01 +0000 (12:11 +0900)]
util: resource: Add missing free operation for put_resource_attr_array

Change-Id: I65f3eef225cc8601b52f99c987c70ce3209f14ea
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2 years agoutil: resouce: Add missing function declaration of put functions 11/271211/10
Chanwoo Choi [Thu, 17 Feb 2022 02:07:24 +0000 (11:07 +0900)]
util: resouce: Add missing function declaration of put functions

Change-Id: I5f31f0727b1b61f54161e2d0814f97a85e7043a3
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2 years agoutil: kernel: Add cpu utilization helper function 10/271210/9
Chanwoo Choi [Wed, 16 Feb 2022 07:51:54 +0000 (16:51 +0900)]
util: kernel: Add cpu utilization helper function

Add cpu utilization helper function as following:

[Detailed description of cpu utilization helper function]
int kernel_get_avg_cpu_util(struct cpu_util_data *avg_cpu)
: Store the average cpu utilization of all cpus to 'avg_cpu'

int kernel_get_per_cpu_util(struct cpu_util_data *cpus, int num_possible_cpus,
    int *num_online_cpus);
: Store the per-cpu utilization datas to 'cpus' and store the number of
online to 'num_online_cpus'

Change-Id: I1594dc656759194ffa9468ed6eebbc159a47e5fd
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2 years agoutil: kernel: Add kernel helper funtion to get number of cpu 49/271149/4
Dongwoo Lee [Wed, 16 Feb 2022 03:40:42 +0000 (12:40 +0900)]
util: kernel: Add kernel helper funtion to get number of cpu

include/util/kernel.h provides helper function to get the information
from standardy linux kernel interface. This version provdies the
function to get the number of online/possible cpu.

Change-Id: I4c5ae5d73e3250b141e5aea69231b6e850790a25
Signed-off-by: Dongwoo Lee <dwoo08.lee@samsung.com>
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2 years agoutil: resouce: Print attribute name when upate fail 91/270991/1
Chanwoo Choi [Fri, 11 Feb 2022 02:16:24 +0000 (11:16 +0900)]
util: resouce: Print attribute name when upate fail

Change-Id: I63524d282d7083663b580dea7edbd81b57b7e8b3
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2 years agoresource: display: Fix error when get_fps_info return null 90/270990/1
Chanwoo Choi [Thu, 10 Feb 2022 10:13:48 +0000 (19:13 +0900)]
resource: display: Fix error when get_fps_info return null

When enlightenment doesn't draw the anything, get_fps_info of enlightenment
doesn't return the fps information with null. DISPLAY_FPS returns the 0.0
for handling this case.

And add RESOURCE_DRIVER_NO_DEVICE flag to display resource driver.

Change-Id: I4087e97f49231ab45bd1ce88a17a0cca5baf3441
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2 years agoutil: resource: Add preprocessing before updating attributes 83/270883/2
Dongwoo Lee [Thu, 10 Feb 2022 12:00:11 +0000 (21:00 +0900)]
util: resource: Add preprocessing before updating attributes

There are resource information to be shared between attributes, so as
to support these resources this introduces prepare_update(), the new
driver operation called before update_resource_attrs() automatically.
In order to prevent updating each resource individually, removes
get_resource_attr_*_sync() functions and prohibits calling
update_resource_attr() soley.

Change-Id: Id3c0b19c6b4a78a6c7a018d8ead7d95f2cd8f4f1
Signed-off-by: Dongwoo Lee <dwoo08.lee@samsung.com>
2 years agoutil: resource: Make resource has its own driver 82/270882/2
Dongwoo Lee [Thu, 10 Feb 2022 11:42:14 +0000 (20:42 +0900)]
util: resource: Make resource has its own driver

Change-Id: I5355dd10289ecd51546b7db26ee769439c17a734
Signed-off-by: Dongwoo Lee <dwoo08.lee@samsung.com>
2 years agoresource: display: Fix build error 61/270861/1
Chanwoo Choi [Thu, 10 Feb 2022 08:14:48 +0000 (17:14 +0900)]
resource: display: Fix build error

Change-Id: I643f110698f1f623cf4a6478c03cb64306781abf
Fixes: cc6617bc6f29 ("resource: Add display resource driver")
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2 years agoresource: Add display resource driver 86/270786/3
Chanwoo Choi [Tue, 8 Feb 2022 10:22:29 +0000 (19:22 +0900)]
resource: Add display resource driver

The resource-display.c provides the display information
like FPS (Frame Per Second) as the display resource driver.
This version supportsthe only DISPLAY_FPS attribute.

Change-Id: I105fb0d463e4ce55cff48ddf291f642ea5ca723d
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2 years agoutil: resource: Bypass checking device for virtual device 38/270838/2
Dongwoo Lee [Tue, 8 Feb 2022 10:38:52 +0000 (19:38 +0900)]
util: resource: Bypass checking device for virtual device

Change-Id: I07076a0549130d452d82e611011389bd58843d88
Signed-off-by: Dongwoo Lee <dwoo08.lee@samsung.com>
2 years agoutil: common: Add BIT operation 42/270842/1
Dongwoo Lee [Thu, 10 Feb 2022 04:06:19 +0000 (13:06 +0900)]
util: common: Add BIT operation

Change-Id: I6db6713364c702e16018bba092fbc39a344fd9d5
Signed-off-by: Dongwoo Lee <dwoo08.lee@samsung.com>
2 years agoutil: resource: Add init/exit ops for resource driver 37/270837/2
Dongwoo Lee [Mon, 7 Feb 2022 12:53:50 +0000 (21:53 +0900)]
util: resource: Add init/exit ops for resource driver

Change-Id: Ie71a2f7de493f198dc57d9daa0b939b3c9eb8e4b
Signed-off-by: Dongwoo Lee <dwoo08.lee@samsung.com>
2 years agoutil: resource: Remove unnecessary passing user_data parameter 36/270836/1
Dongwoo Lee [Mon, 7 Feb 2022 12:41:36 +0000 (21:41 +0900)]
util: resource: Remove unnecessary passing user_data parameter

Change-Id: Ie867d19c667c3a7a273d31719161d74137d3cf84
Signed-off-by: Dongwoo Lee <dwoo08.lee@samsung.com>
2 years agoutil: gdbus: Rename gdbus-util functions by removing the specific module name 85/270785/1
Chanwoo Choi [Tue, 8 Feb 2022 07:19:19 +0000 (16:19 +0900)]
util: gdbus: Rename gdbus-util functions by removing the specific module name

Rename gdbus-util functions by removing the specific module name
without any behavior changes.

Change-Id: I5d0265a985443a628d1265c371c444686ba7d88e
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2 years agoutil: gdbus-util: Fix memory leak issue 04/270704/2
Chanwoo Choi [Tue, 8 Feb 2022 03:08:46 +0000 (12:08 +0900)]
util: gdbus-util: Fix memory leak issue

Change-Id: I3df1d2edbeec17f14cf87ee55065922e0362ba5f
Reported-by: Seung-Woo Kim <sw0312.kim@samsung.com>
Suggested-by: Seung-Woo Kim <sw0312.kim@samsung.com>
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2 years agomonitor: Add monitor module 24/270624/5
Dongwoo Lee [Mon, 7 Feb 2022 05:24:56 +0000 (14:24 +0900)]
monitor: Add monitor module

This introduce the new pass module monitor which provides methods for
accessing or controlling resources in a common way. By just creating
and queuing a request, resource attributes are updated, and we can
exploit it easily. And attributes also can be filtered in order not
to take unnecessary attributes by set interest mask.

How to request resource update:
 1) create resource
 2) set interest attributes for resource
 3) create monitor command
 4) bind resource with command
 5) submit command (sync or async)
 6) if async) wait for done
 7) get attributes values by 'get' function as following the
    corresponding type
 8) PTR_TYPE, STRING_TYPE, ARRAY_TYPE attributes should be call 'put'
    function to release memory

Change-Id: I110e46b96691381629b8da619d3519c50e409693
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
Signed-off-by: Dongwoo Lee <dwoo08.lee@samsung.com>
2 years agomonitor: internal: Add pointer attribute data type 23/270623/3
Dongwoo Lee [Mon, 7 Feb 2022 05:19:39 +0000 (14:19 +0900)]
monitor: internal: Add pointer attribute data type

Change-Id: Id4d711e38a036b26a8a24af3b7e92ab4177d8445
Signed-off-by: Dongwoo Lee <dwoo08.lee@samsung.com>
2 years agoresource: Rework attribute value handling 22/270622/3
Dongwoo Lee [Fri, 4 Feb 2022 07:24:35 +0000 (16:24 +0900)]
resource: Rework attribute value handling

Change-Id: I8777093c47963a84913b9f7388816cd8cd455d58
Signed-off-by: Dongwoo Lee <dwoo08.lee@samsung.com>
2 years agoutil: resource: Use internal interest_mask 20/270620/2
Dongwoo Lee [Fri, 4 Feb 2022 04:16:20 +0000 (13:16 +0900)]
util: resource: Use internal interest_mask

Since interesting attributes might not be changed usually, it seems
better that each resource has interest_mask internally.

Change-Id: I6276dbb688ee4a3c5f68eff323bce6c5b1e967a1
Signed-off-by: Dongwoo Lee <dwoo08.lee@samsung.com>
2 years agopass: Add resource_device for each h/w resource 02/270602/6
Chanwoo Choi [Sun, 6 Feb 2022 08:31:16 +0000 (17:31 +0900)]
pass: Add resource_device for each h/w resource

Change-Id: I1b124c8828f05103226d9d84558d45bb397cedba
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2 years agoutil: resource: Add resource_device struct and functions 01/270601/4
Chanwoo Choi [Sun, 6 Feb 2022 08:13:48 +0000 (17:13 +0900)]
util: resource: Add resource_device struct and functions

Add resource_device structure for expressing the each h/w resource
such as CPU, GPU, Memory BUS, battery and so on.

Each h/w board has the different h/w resource information
such as the number of h/w resource, name, access path and so on.
PASS daemon has already supported the configuration method to get
the h/w resource information like /hal/etc/pass/pass.json.
Each h/w resource has the unique name, resource type and resource index
because board is able to have the one more same resource like big.LITTLE
cpu cluster.

When creating the instance of struct resource, will use the struct
resource_drvier and resource_device with resource type and index argument
because the user of create_resource() cannot get the unique resource name
which depends on the specific h/w. But the user of create_resource()
can get the available count of specific resource type by get_resource_device_*().

[How to create the instance of struct resource]
1. Find resource_device with resource type and index
2. Find resource_driver with resource type
3. Create the instance of struct resource by using resouce_device/driver info.

And rename from get_resource_driver to find_resource_driver.

Change-Id: I8c2fa6c8d22dcea996a12048fcab7de21eca652d
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2 years agopass: rescon: Move overriable property into pass_rescon struct 00/270600/3
Chanwoo Choi [Sun, 6 Feb 2022 08:18:27 +0000 (17:18 +0900)]
pass: rescon: Move overriable property into pass_rescon struct

The 'overriable' property is used for only rescon module.
It means that be able to move 'overriable' property from struct pass_resource
to struct pass_rescon for more capsulation.

Change-Id: Icd63b1b25fb8dcb64fd1d9fd894d2b604f10ea22
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2 years agolib: tmonitor: Add libpass skeleton package for Tizen Monitor (tmonitor) 23/270523/6
Chanwoo Choi [Fri, 4 Feb 2022 04:21:17 +0000 (13:21 +0900)]
lib: tmonitor: Add libpass skeleton package for Tizen Monitor (tmonitor)

Add libpass skelegon packages which contains the shared library and
header files. Initial version just contains the Tizen Monitor's
shared library and header file. But it just defines the tmonitor
interface without any detailed implementation. It shold be implemnted.

[Newlyd Added Packages]
- libpass-1.2.0-1.aarch64.rpm
- libpass-debuginfo-1.2.0-1.aarch64.rpm
- libpass-devel-1.2.0-1.aarch64.rpm

[File Hierarchy]

└── usr
    â”œâ”€â”€ include
    â”‚   â””── pass
    â”‚       â””── tmonitor.h
    â”œâ”€â”€ lib
    â”‚   â””── debug
    â”‚       â””── usr
    â”‚           â””── lib64
    â”‚               â””── libpass.so.0.1.0.debug
    â”œâ”€â”€ lib64
    â”‚   â”œâ”€â”€ libpass.so -> libpass.so.0
    â”‚   â”œâ”€â”€ libpass.so.0 -> libpass.so.0.1.0
    â”‚   â”œâ”€â”€ libpass.so.0.1.0
    â”‚   â””── pkgconfig
    â”‚       â””── pass.pc
    â””── share
        â””── licenses
            â””── libpass
                â””── LICENSE

Change-Id: I28d0e07e70db80471b50e749991f375267c8a0cb
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2 years agopass: Move pass.pc.in into packaging and remove unused files 18/270518/1
Chanwoo Choi [Fri, 4 Feb 2022 03:44:59 +0000 (12:44 +0900)]
pass: Move pass.pc.in into packaging and remove unused files

Move pass.pc.in into packaging directory and commit 469051e30f820
("pass: hal: Replace HAL interface with hal-api-power") has removed
the pass-hal-devel package. But, pass-hal-devel.pc.in/.manifest files
were not removed. Remove unused pass-hal-devel related files.

Change-Id: I7d568a8389c35c5d76064fbb844e76bb65a06a52
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2 years agoutil: resource: Check data type is integer or not when getting value 17/270517/1
Chanwoo Choi [Fri, 4 Feb 2022 03:28:08 +0000 (12:28 +0900)]
util: resource: Check data type is integer or not when getting value

Each resource_attribute has the only one data type like integer, string
and so on. When using the getter function for specific data type such as
get_resource_attr_integer(), must need to check the data type of
resource attribute.

Change-Id: I868c31011d61efe05ae8a72966db462370408977
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2 years agoutil: resource: Enable updating resources with interest mask 69/270469/3
Dongwoo Lee [Thu, 3 Feb 2022 06:31:33 +0000 (15:31 +0900)]
util: resource: Enable updating resources with interest mask

Change-Id: I0ea7b2b9bae7ad1c5291307581cbfae78004400f
Signed-off-by: Dongwoo Lee <dwoo08.lee@samsung.com>
2 years agoutil: resource: Change resource attribute id 68/270468/3
Dongwoo Lee [Thu, 3 Feb 2022 06:31:21 +0000 (15:31 +0900)]
util: resource: Change resource attribute id

This do refactoring resource attribute ids can be distinguished by
bitfield operation.

Change-Id: I07da21e442f761ffc212cab4507f4d7cd48d73d5
Signed-off-by: Dongwoo Lee <dwoo08.lee@samsung.com>
2 years agomonitor: Rename monitor.h to monitor-internal.h 67/270467/2
Dongwoo Lee [Thu, 3 Feb 2022 06:31:16 +0000 (15:31 +0900)]
monitor: Rename monitor.h to monitor-internal.h

Change-Id: I2a6463736ec92ba808c56d7c1cc0c2f083e4588b
Signed-off-by: Dongwoo Lee <dwoo08.lee@samsung.com>
2 years agoutil: Add lock-free queue utility 66/270466/2
Dongwoo Lee [Thu, 3 Feb 2022 06:30:59 +0000 (15:30 +0900)]
util: Add lock-free queue utility

Now lock-free queue for supporting multi-thread without lock
contention will be provided.

Change-Id: I6459e397954c95831ca3b31359cb9136eb59705e
Signed-off-by: Dongwoo Lee <dwoo08.lee@samsung.com>
2 years agoutil: thread: Let thread use self-allocated memory 65/270465/2
Dongwoo Lee [Thu, 3 Feb 2022 06:30:50 +0000 (15:30 +0900)]
util: thread: Let thread use self-allocated memory

Make easy to use thread without concerning about memory using thread

Change-Id: I170fd0afe772f47554dca95f3f61afd6b38e2921
Signed-off-by: Dongwoo Lee <dwoo08.lee@samsung.com>
2 years agoutil: thread: Fix to unlock mutex before doing job 64/270464/2
Dongwoo Lee [Thu, 3 Feb 2022 06:30:36 +0000 (15:30 +0900)]
util: thread: Fix to unlock mutex before doing job

Change-Id: I1af301998cdae5c92ffd249b9c61dfb9696e8677
Signed-off-by: Dongwoo Lee <dwoo08.lee@samsung.com>
2 years agoutil: thread: Fix missing preprocessor 63/270463/2
Dongwoo Lee [Thu, 3 Feb 2022 06:30:18 +0000 (15:30 +0900)]
util: thread: Fix missing preprocessor

This corrects that thread header is missing preprocessor define to prevent
including it multiple times.

Change-Id: Ic66e09df0759cbd72e03979861485fe1961b80f7
Signed-off-by: Dongwoo Lee <dwlee08@gmail.com>
2 years agoresource: Add memory resource driver 74/270274/4
Sung-hun Kim [Thu, 27 Jan 2022 08:27:30 +0000 (17:27 +0900)]
resource: Add memory resource driver

Change-Id: I74291dac952a7cba3a7c56038081215cb05b7adb
Signed-off-by: Sung-hun Kim <sfoon.kim@samsung.com>
2 years agoutil: monitor: Fix a typo 73/270273/2
Sung-hun Kim [Thu, 27 Jan 2022 08:26:20 +0000 (17:26 +0900)]
util: monitor: Fix a typo

Change-Id: I98c1d0f42073c15fddf460e79701c1a0819eb862
Signed-off-by: Sung-hun Kim <sfoon.kim@samsung.com>
2 years agoutil: Add common thread utility 70/270170/3
Dongwoo Lee [Mon, 24 Jan 2022 12:35:42 +0000 (21:35 +0900)]
util: Add common thread utility

To support multi-thread by common utility, now three types of threads
are provided as like 'daemon', 'worker', and 'timer'.

Change-Id: Ie2ac65187cab0ce9ec41a5610fc0b99d08f9e42a
Signed-off-by: Dongwoo Lee <dwoo08.lee@samsung.com>
2 years agoutil: common: Move container_of macro to common.h 07/270007/3
Chanwoo Choi [Mon, 24 Jan 2022 06:47:35 +0000 (15:47 +0900)]
util: common: Move container_of macro to common.h

Change-Id: I02fc5d60110132481719ded0d805dc88e12b9d2a
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2 years agoresource: Add CPU/BUS/GPU resource driver 86/269986/6
Dongwoo Lee [Tue, 18 Jan 2022 07:26:26 +0000 (16:26 +0900)]
resource: Add CPU/BUS/GPU resource driver

Change-Id: I3aef9258ae02f80b9bf87d438352d57a33411576
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2 years agopass: resmon: Replace timer-related code with timer utility 85/269985/6
Chanwoo Choi [Thu, 20 Jan 2022 09:11:26 +0000 (18:11 +0900)]
pass: resmon: Replace timer-related code with timer utility

Change-Id: I30d9f3a8cc37036bb37c350565c6ef2c58f2bdba
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2 years agoutil: timer: Add timer management 84/269984/6
Chanwoo Choi [Thu, 20 Jan 2022 08:14:01 +0000 (17:14 +0900)]
util: timer: Add timer management

Add internal helper functions of timer and uevent code. It will be used
on multiple point in PASS daemon.

Change-Id: Id9abc31433021eb850ad0529cc1ee6b6fcf31cab
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2 years agoutil: resource: Add resource management 83/269983/6
Dongwoo Lee [Tue, 18 Jan 2022 06:32:00 +0000 (15:32 +0900)]
util: resource: Add resource management

Resource Manager provides the template and then each resource
is able to make the their own resource driver under src/resource
directory. Also, each resoruce is able to have the multiple attributes
such as min frequency of CPU, max frequency of CPU, available memory of
Memory and so on. Lastly, each attribute must define the their onw data
type like integer, double, string and so on.

[Example of resource and attribue, data type]
resource A
- attribute A1 with data type
- attribute A2 with data type
resource B
- attribute B1 with data type
- attribute B2 with data type
- attribute B3 with data type
resource C
...
resource D
...

[Newly added functions for resource manager]
- Add/Remove resource driver like resource-cpu.c. resource-memory.c
void add_resource_driver(const struct resource_driver *resource_driver);
void remove_resource_driver(const struct resource_driver *resource_driver);

- Create/Delete resource instance like CPU/BUS/GPU/Battery/Memory/Proc
struct resource *create_resource(int resource_type, char *resource_name);
void delete_resource(struct resource *resource);

- Update the attribute values of each resource
int update_resource_attr(struct resource *resource, int attr_id);
int update_resource_attrs(struct resource *resource);

- Get the attribute values of specific attribute
struct resource_attribute_value *get_resource_attr_value(struct resource *resource, int attr_id);
int get_resource_attr_integer(struct resource *resource, int attr_id);
int get_resource_attr_integer_sync(struct resource *resource, int attr_id);

Change-Id: I45e7ef3e6c8138b49063dd9fc6e84dd8b9448c0a
Signed-off-by: Dongwoo Lee <dwoo08.lee@samsung.com>
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2 years agomonitor: Define resource attribute id and data type 82/269982/4
Chanwoo Choi [Tue, 18 Jan 2022 08:29:17 +0000 (17:29 +0900)]
monitor: Define resource attribute id and data type

monitor.h header file defines the resource attribute id and data type
of attribute. Resource Manager provides the template and then each resource
is able to make the their own resource driver under src/resource
directory. Also, each resoruce is able to have the multiple attributes
such as min frequency of CPU, max frequency of CPU, available memory of
Memory and so on. Lastly, each attribute must define the their onw data
type like integer, double, string and so on.

Change-Id: I7c869a1db496a78f08f3e735a2319c910af4058c
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2 years agoutil: Change directgory name from include/pass to include/util 81/269981/4
Chanwoo Choi [Wed, 19 Jan 2022 10:03:37 +0000 (19:03 +0900)]
util: Change directgory name from include/pass to include/util

Change directory name from include/pass to include/util
because 'include/util' directory declares the utility functions.

Change-Id: Ie3dc727aac7ff4c074bea7ab5bec632685a9685e
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2 years agoutil: devices: Rename to init_devices and exit_devices 80/269980/4
Chanwoo Choi [Thu, 20 Jan 2022 07:01:14 +0000 (16:01 +0900)]
util: devices: Rename to init_devices and exit_devices

Change-Id: Id3dd8898849d0be990a36c305d1c5e1d3a80b7fa
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2 years agopass: Remove unneeded header including 78/269978/4
Chanwoo Choi [Wed, 19 Jan 2022 09:54:54 +0000 (18:54 +0900)]
pass: Remove unneeded header including

Change-Id: Ie7590805ce3d0b002dd1f67c7fd3dc8e85f1930d
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2 years agopass: resmon: Use monitor id to identify timer instead of monitor type 77/269977/4
Chanwoo Choi [Wed, 12 Jan 2022 06:36:50 +0000 (15:36 +0900)]
pass: resmon: Use monitor id to identify timer instead of monitor type

Support that a pass_resource can register the multiple timers with same
monitor type. If use monitor type as ID, a pass_resource is not able
to use the one more timers with same monitor type. It is wrong
registration.

Change-Id: I8e0d24fe038039076bbd8a9cd47b3dedd54913c5
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2 years agopass: resmon: Remove dependency of monitor->result and monitor->ops 76/269976/3
Chanwoo Choi [Thu, 13 Jan 2022 05:58:45 +0000 (14:58 +0900)]
pass: resmon: Remove dependency of monitor->result and monitor->ops

Remove dependency of monitor->result and monitor->ops for supporting
the basic timer functionality. If monitor->ops is NULL, pass_resmon.c
just creates the periodic timer and uevent timer.

Change-Id: I43839a1b27f961d933e40177e1b2821b8ce775f0
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2 years agopass: resmon: Remove dependnecy of resource type 75/269975/2
Chanwoo Choi [Mon, 10 Jan 2022 08:52:08 +0000 (17:52 +0900)]
pass: resmon: Remove dependnecy of resource type

Change-Id: I966c38bca2b52a40205b13f54db2bf5e4dc5ef49
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2 years agopass: rescon: Fix missing NULL check 12/270012/1
Dongwoo Lee [Mon, 24 Jan 2022 06:46:33 +0000 (15:46 +0900)]
pass: rescon: Fix missing NULL check

Change-Id: I374f3d608b055ea589d9ed1dbb4ca43d890a3fa3
Signed-off-by: Dongwoo Lee <dwoo08.lee@samsung.com>
2 years agopass: rescon: Fix overridable property 95/269395/2
Dongwoo Lee [Thu, 13 Jan 2022 11:57:04 +0000 (20:57 +0900)]
pass: rescon: Fix overridable property

To prevent updating not overridable resources, adds more checks for
overridable, and also set overridable as true by default.

Change-Id: I06802347ca210653dce0e04d78e4cde55df6937f
Signed-off-by: Dongwoo Lee <dwoo08.lee@samsung.com>
2 years agopass: Change directory name from core to util 73/268373/1
Chanwoo Choi [Wed, 22 Dec 2021 03:00:38 +0000 (12:00 +0900)]
pass: Change directory name from core to util

Change directory name from core to util because 'src/core' directory
contains the util functions and then move 'src/util/main.c' to src/main.c
in order to improve the readability of PASS daemon starting point.

Change-Id: I26d421d67ff4790c82e2a1af22d208104ad136db
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
3 years agopass: Allow level update only for overridable resources 60/265560/6
Dongwoo Lee [Wed, 20 Oct 2021 04:19:32 +0000 (21:19 -0700)]
pass: Allow level update only for overridable resources

To prevent unoverridable state such as LimitAction of thermal, this
adds overridable property to resources. Target level of those
resources can be update only overridable is 'true'.

Change-Id: Ia8187b014c1b86fd5d3e3039046cc28c1c48a95b
Signed-off-by: Dongwoo Lee <dwlee08@gmail.com>
3 years agopass: thermal: Add overridable property 59/265559/3
Dongwoo Lee [Wed, 20 Oct 2021 03:54:46 +0000 (20:54 -0700)]
pass: thermal: Add overridable property

To represent scenario overridable which means that the resource is
allowed or disallowed to be changed by other modules such as PMQoS.

Change-Id: I8871b013ff93882c8cb0656f94e1e450e864e4ac
Signed-off-by: Dongwoo Lee <dwlee08@gmail.com>
3 years agopass: thermal: Fix to copy scenario name for thermal_data 89/263889/6 accepted/tizen/6.5/unified/20211028.115350 accepted/tizen/unified/20210926.235732 submit/tizen/20210924.100744 submit/tizen_6.5/20211028.162501 tizen_6.5.m2_release
Dongwoo Lee [Mon, 13 Sep 2021 05:18:15 +0000 (14:18 +0900)]
pass: thermal: Fix to copy scenario name for thermal_data

Scenario name in thermal_data can be modified by thermal module, so
it has side-effect intruding supported scenario list. This fixes to
copy scenario instead of assigning pointer to prevent side-effect.

Change-Id: I21fde12fed6bcd72fb83a6171e1b0a6d350261bd
Signed-off-by: Dongwoo Lee <dwoo08.lee@samsung.com>
3 years agopass: thermal: Set a separate threshold for warning level reduction 88/263888/5
Dongwoo Lee [Tue, 14 Sep 2021 04:22:42 +0000 (13:22 +0900)]
pass: thermal: Set a separate threshold for warning level reduction

To prevent warning level is continuously changing at the edge of the
temperature range, this adds distinct thresholds for warning level
reduction.

Change-Id: I0f0e911c1b3a6ee88fa7b26162d076f811a8ffea
Signed-off-by: Dongwoo Lee <dwoo08.lee@samsung.com>
3 years agopass: thermal: Determine scenario with range value 87/263887/5
Dongwoo Lee [Tue, 31 Aug 2021 03:40:48 +0000 (12:40 +0900)]
pass: thermal: Determine scenario with range value

To prevent to be confused for determining scenario as following the
temperature, now it is settled with range of temperature.

Change-Id: Ic605a9b629da79129cbac8c5750316e16cc1c47e
Signed-off-by: Dongwoo Lee <dwoo08.lee@samsung.com>
3 years agopass: Add JSON API for getting object from object 86/263886/2
Dongwoo Lee [Tue, 31 Aug 2021 11:59:30 +0000 (20:59 +0900)]
pass: Add JSON API for getting object from object

Since JSON object can have another object, now pass can parse object
from object.

Change-Id: I962fc8464e6cae895f178d19bcee095178157c08
Signed-off-by: Dongwoo Lee <dwoo08.lee@samsung.com>
3 years agopass: thermal: Fix build warning 21/263221/2 accepted/tizen/unified/20210830.103730 submit/tizen/20210830.024411
Dongwoo Lee [Mon, 30 Aug 2021 00:46:21 +0000 (09:46 +0900)]
pass: thermal: Fix build warning

Since the third agrument of strncpy means maximum permitted size of
destination, using length of source string cause warning as like
"specified bound depends on the length of the source argument". This
fixes warning to use NAME_MAX instead of source length.

Change-Id: I07399700ea454100ca0924c93eca6a99cb54b8cd
Signed-off-by: Dongwoo Lee <dwoo08.lee@samsung.com>
3 years agounittest: power-haltests: Restart PASS daemon when PutResource tc is failed 73/263173/1 accepted/tizen/unified/20210827.110834 submit/tizen/20210827.070901
Chanwoo Choi [Fri, 27 Aug 2021 07:00:25 +0000 (16:00 +0900)]
unittest: power-haltests: Restart PASS daemon when PutResource tc is failed

Even if PutResource tc is failed, need to restore the status of PASS
daemon. So that restart PASS daemon.

Change-Id: I3c4dab4f30a16660f0718bc1cd579afa15f75fbf
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
3 years agopass: parser: Fix uninitialized value of number_of_cpus property 68/263168/3
Chanwoo Choi [Fri, 27 Aug 2021 06:35:02 +0000 (15:35 +0900)]
pass: parser: Fix uninitialized value of number_of_cpus property

If json configuraiton file doesn't contain the 'number_of_cpus'
property, number_of_cpus has the minus value. It causes the problem.
So that fix uninitialized value of number_of_cpus property when value is
out of range.

Change-Id: Ibac93e89b3cd85181287773b0bf0cf7f4aa6f692
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
3 years agopass: thermal: Fix to handle priority of initial state properly 67/263167/1
Dongwoo Lee [Fri, 27 Aug 2021 05:49:49 +0000 (14:49 +0900)]
pass: thermal: Fix to handle priority of initial state properly

At first, priority is intended to treat lower value as higher
priority, but it is not handled intentionally when monitoring devices.
So this fixes to handle it properly and to this end it is required to
retrieve highest priority from the corresponding thermal device.
Finally, instead of plain scenario string the notifer_data structure
is passed as THERMAL_GET_SCENARIO parameter to get both scenario and
priority.

Change-Id: I330729be2890cdcb89ee7a677af2c0b8d4905fb0
Signed-off-by: Dongwoo Lee <dwoo08.lee@samsung.com>
3 years agopass: thermal: Fix invalid return value 66/263166/1
Dongwoo Lee [Fri, 27 Aug 2021 05:46:45 +0000 (14:46 +0900)]
pass: thermal: Fix invalid return value

This fixes to not return value for void functions.

Change-Id: Ic341a80a69da983ffc5d76905c190957a6148632
Signed-off-by: Dongwoo Lee <dwoo08.lee@samsung.com>
3 years agopass: thermal: Supprot mupltiple resources for 'thermal_get_scenario' 05/262805/2
Dongwoo Lee [Fri, 20 Aug 2021 02:45:41 +0000 (11:45 +0900)]
pass: thermal: Supprot mupltiple resources for 'thermal_get_scenario'

To response 'getCoolDownStatus' dbus method call during boot, initial
scenario state should be set before thermal monitor works once. When
there are multiple resources which have thermal data, the final state
of thermal scenario should be determined theirs priority. For this,
this enables supporting multiple resources on 'thermal_get_scenario'
handler.

Change-Id: I920de0440efac9706405bcf63b0c110b407ddd60
Signed-off-by: Dongwoo Lee <dwoo08.lee@samsung.com>
3 years agopass: thermal: Notify scenario only when it changed 13/262413/4
Dongwoo Lee [Mon, 9 Aug 2021 03:26:26 +0000 (12:26 +0900)]
pass: thermal: Notify scenario only when it changed

Since this, thermal monitor notify scenario when it is different with
previous on. To this end, set callback to thermal_result for notifying
scenario, and it called when the scenario is changed. And this also
enables to do different notification process for both thermal_monitor
and get_scenario handler.

Change-Id: Ib0e7cda2926f4402563b00e94125511954b2a043
Signed-off-by: Dongwoo Lee <dwoo08.lee@samsung.com>
3 years agopass: thermal: Set priority of thermal device through config file 12/262412/4
Dongwoo Lee [Wed, 4 Aug 2021 06:20:59 +0000 (15:20 +0900)]
pass: thermal: Set priority of thermal device through config file

Now, the priority of each thermal device is can be determined by
configuration file in pass-hal with 'thermal_priority' section.

Change-Id: I677dd719672dea43c6675ccf774e646b492914d5
Signed-off-by: Dongwoo Lee <dwoo08.lee@samsung.com>
3 years agothermal: Support multiple thermal resources 11/262411/3
Dongwoo Lee [Tue, 3 Aug 2021 07:44:49 +0000 (16:44 +0900)]
thermal: Support multiple thermal resources

To handle thermal scenario from multiple resources, manage the
thermal data along with its own property.

Change-Id: I933205f17dd7dc2e264fa2322b3a301b8f8e01d5
Signed-off-by: Dongwoo Lee <dwoo08.lee@samsung.com>
3 years agopass: thermal: Send scenario with additional information 10/262410/3
Dongwoo Lee [Fri, 30 Jul 2021 07:50:28 +0000 (16:50 +0900)]
pass: thermal: Send scenario with additional information

In order to prepare the case that pass can have multiple thermal
monitors, each monitor sends additional information which includes
resource name as a key.

Change-Id: I47b9fca69c9580774ddffd065bf86e4eef09ee56
Signed-off-by: Dongwoo Lee <dwoo08.lee@samsung.com>
3 years agopass: thermal: Fix missing unregister operation 10/262710/1
Dongwoo Lee [Wed, 11 Aug 2021 02:15:41 +0000 (11:15 +0900)]
pass: thermal: Fix missing unregister operation

DEVICE_NOTIFIER_THERMAL is registered during probe, but it is not
unregistered during exit. So this adds missing unregister to exit.

Change-Id: I035547932abed44a255b0701f2290e3e74d7d3a3
Signed-off-by: Dongwoo Lee <dwoo08.lee@samsung.com>
3 years agopass: Add support of battery charging properties 48/262548/1 accepted/tizen/unified/20210816.122910 submit/tizen/20210813.100724
Chanwoo Choi [Fri, 13 Aug 2021 04:23:46 +0000 (13:23 +0900)]
pass: Add support of battery charging properties

In order to control the battery charging status and charging current,
add new properties as following:

[Newly added properties for battery h/w resource]
- 'battery,charging_status' property in 'level_list' section
- 'battery,charging_current_limit' property in 'level_list' section

[Example of charging properties]
In case of scripts/pass-battery.json,
"support" : true,
"init_level" : 0,
"level_list" :
[
{
"level" : 0,
"battery,charging_status" : 0, // POWER_SUPPLY_STATUS_UNKNOWN
"battery_charging_currnt_uA" : 2048000
}, {
"level" : 1,
"battery,charging_status" : 0, // POWER_SUPPLY_STATUS_UNKNOWN
"battery_charging_currnt_uA" : 1024000
}, {
"level" : 2,
"battery,charging_status" : 3, // POWER_SUPPLY_STATUS_NOT_CHARGING
"battery_charging_currnt_uA" : 1024000
}
],

Change-Id: I5a762d3127c2b156be377846a8ab19c4e582b247
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
3 years agopass: Update supported module information for PASS_RESOURCE_BATTERY/NONSTANDARD_ID 75/262475/3 submit/tizen/20210813.010414 submit/tizen/20210813.013856
Chanwoo Choi [Wed, 11 Aug 2021 10:30:37 +0000 (19:30 +0900)]
pass: Update supported module information for PASS_RESOURCE_BATTERY/NONSTANDARD_ID

Update supported module information for both new PASS_RESOURCE_BATTERY_ID type
and PASS_RESOURCE_NONSTANDARD_ID type as following:

[Updated supported module list for each h/w resource type]
1. PASS_RESOURCE_BATTERY_ID (new h/w resoruce type)
- PASS_MODULE_PARSER
- PASS_MODULE_RESCON
- PASS_MODULE_RESMON
- PASS_MODULE_PMQOS
- PASS_MODULE_THERMAL

2. PASS_RESOURCE_NONSTANDARD_ID
- PASS_MODULE_RESMON
- PASS_MODULE_PMQOS
- PASS_MODULE_THERMAL

Change-Id: I9161898b7d9b8b886081eabac3eb91db3fc8b76e
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
3 years agopass: parser: Don't check resource type when verify pass_level 74/262474/2
Chanwoo Choi [Wed, 11 Aug 2021 11:03:43 +0000 (20:03 +0900)]
pass: parser: Don't check resource type when verify pass_level

'struct pass_level' doesn't have the any dependency of h/w resource
type. So that don't check the resource type when verify pass_level.

Change-Id: Ib2aa302f6ed84e741b61e4e6b5b7db895152ba4c
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
3 years agopass: parser: Remove unnecessary log when PMQOS module is not used 73/262473/1
Chanwoo Choi [Wed, 11 Aug 2021 10:57:09 +0000 (19:57 +0900)]
pass: parser: Remove unnecessary log when PMQOS module is not used

If 'pmqos_property' is false, don't need to print the state of pmqos for
each h/w resource. Remove unnecessary log when PMQOS module is not used.

Change-Id: I09eed2828aa760c57e92bd1bda449e428769983f
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
3 years agopass: hal: Add missing save/restore of initdata for cooling-device property 72/262472/1
Chanwoo Choi [Wed, 11 Aug 2021 10:29:54 +0000 (19:29 +0900)]
pass: hal: Add missing save/restore of initdata for cooling-device property

The commit 256425c1250a ("pass: Add support of cooling-device property")
added cooling-device property. But, this commit didn't add the
save/restore of initdata for cooling-device property. In order to
restore the initial value of cooling-device property after finishing
PASS daemon, add missing save/restore of initdata for cooling-device property.

Change-Id: I97317a11613bfc29851ef1eecd7b9d7b531c7578
Fixes: 256425c1250a ("pass: Add support of cooling-device property")
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
3 years agopass: resmon: Add new power_supply uevent type to catch temperature changes 67/262367/2
Chanwoo Choi [Mon, 9 Aug 2021 04:54:26 +0000 (13:54 +0900)]
pass: resmon: Add new power_supply uevent type to catch temperature changes

The power_supply subsystem in Linux kernel provides the temperature information
via POWER_SUPPLY_PROP_TEMP property. In order to catch the temperature changes,
add power_supply uevent subsystem type. When send power_supply uevent to
user-space from kernel space, resource monitor try to get the current
temperature for deciding the proper thermal scenario and then control the h/w
resources.

Change-Id: If5ae48885f2c5b895bf24c5f9da3193fdea85981
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
3 years agopass: resmon: Add support of multiple uevent subsystem type by one resource monitor 66/262366/2
Chanwoo Choi [Mon, 9 Aug 2021 04:18:51 +0000 (13:18 +0900)]
pass: resmon: Add support of multiple uevent subsystem type by one resource monitor

The an 'struct resmon_ops' instance has supported only one uevent subsystem type.
But, even if subsystems in linux kernel are different, sometimes treats
the same raw data like thermal. For example, both thermal and power_supply
subsystems provides the current temperature to user-space via uevent and sysfs
node. So that Add support of multiple uevent subsystem type by one resource monitor
instance.

Change-Id: I2ad7f25f1a894539ea1e460c4faeb5334acc50b5
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
3 years agopass: parser: Add missing code for PASS_RESROUCE_BATTERY_ID 10/262210/1 accepted/tizen/unified/20210809.061413 submit/tizen/20210809.032652
Chanwoo Choi [Wed, 4 Aug 2021 08:56:27 +0000 (17:56 +0900)]
pass: parser: Add missing code for PASS_RESROUCE_BATTERY_ID

When using 'battery' h/w resouce in /hal/etc/pass/pass.conf,
the following error happen. So that add the missing code for PASS_RESROUCE_BATTERY_ID.

[Error log]
pass-parser.c: parse_resource_data(748) > Unknown 'device_type' property value (battery)

Change-Id: I30fb782e4e67b0fbe728201e30e2e4d0a1698c4c
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
3 years agopass: Add support of cooling-device property 56/262156/1
Chanwoo Choi [Tue, 3 Aug 2021 06:19:23 +0000 (15:19 +0900)]
pass: Add support of cooling-device property

Already thermal monitor in pass get the thermal information with
'thermal_device_name' property. When over-temperature is deteced,
must need to prevent the dangerous situation by using the cooling-device
which is attached to a thermal device.

So that add 'cooling_device_name' property in 'device_list' section
in order to get/set the information of cooling-device.
Also, 'thermal,cooling_device_state' property will be used
when try to change the state of cooling-device if over-temperature is
detected.

Lastly, enable thermal operation for both new PASS_RESOURCE_BATTERY_ID devie type
and PASS_RESOURCE_NONSTANDARD_ID.

[Newly added properties for cooling-device]
- 'cooling_device_name' property in 'device_list' section
- 'thermal,cooling_device_state' property in 'level_list' section

[Example of cooling-device properties]
In case of scripts/pass.json,
                        "device_name"           : "cpu0",
                        "device_config_path"    : "/hal/etc/pass/pass-cpu0.json",
                        "thermal_device_name"   : "thermal_zone0",
                        "cooling_device_name"   : "cooling_device0", <- Added
                        "cpu,number_of_cpus"    : 4,
                        "cpu,first_cpu"         : 0,

In case of scripts/pass-cpu0.json,
                {
                        "level"                         : 0,
                        "dvfs,minimum_frequency_khz"    : 600000,
                        "dvfs,maximum_frequency_khz"    : 1500000,
                        "thermal,cooling_device_state"  : 0 <- Added
                }, {
                        "level"                         : 1,
                        "dvfs,minimum_frequency_khz"    : 1500000,
                        "dvfs,maximum_frequency_khz"    : 1500000,
                        "thermal,cooling_device_state"  : 1 <- Added
                },

Change-Id: I86bfc5ce2037559e81bbf70567b82457167d4ced
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
3 years agopass: rescon: Fix wrong initial value to distinguish either property is added or not 55/262155/1
Chanwoo Choi [Mon, 2 Aug 2021 10:09:40 +0000 (19:09 +0900)]
pass: rescon: Fix wrong initial value to distinguish either property is added or not

The commit d54cf9cc4588 ("pass: rescon: Add support for multiple
scenario pass_level") has defined the MIN_INT (zeor) to inialize
the property values in struct pass_level. But, some property values
will have the zero value like cooling_device_state is zero.
In that case, if MIN_INT is zero, cannot separate the following two
cases:
- propery is absence in configuration file -> 0
- property value is zero in configuration file -> 0

In order to separate the above two cases, change the MIN_INT value
from 0 to -1. After changes, can separate the two cases as following:
- propery is absence in configuration file -> -1
- property value is zero in configuration file -> 0

Change-Id: I2ee3fe9372c2deb82018949fc2b4b85eb3bb96ff
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>