platform/core/system/pass.git
6 years agopass: Consolidate the size of char arrary to the 255 byte 00/158900/1
Chanwoo Choi [Mon, 6 Nov 2017 01:40:00 +0000 (10:40 +0900)]
pass: Consolidate the size of char arrary to the 255 byte

The multiple modules define the char array with the different size.
It might make the confusion and overflow error. This patch consolidates
the size of char arrary to the 255 byte and changes the name of 'PASS_NAME_LEN'
to 'BUFF_MAX' in order to remove the unneeded 'PASS_*' prefix.

Change-Id: I2ee11313f10f52f5aa24628afbac9facd45b50ad
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
6 years agopass: Move local constatnt definition to the specific module 99/158899/1
Chanwoo Choi [Mon, 6 Nov 2017 01:29:38 +0000 (10:29 +0900)]
pass: Move local constatnt definition to the specific module

The some definitions were only used in the specific module.
They would be not included in the pass.h header file. This patch
moves the definition to the specific module.
- #define PASS_MIN_GOV_TIMEOUT 0.2 (pass-parser.c)
- #define PASS_CPU_STATS_DEFAULT 20 (pass.c)

Change-Id: Id3ce5c81198d74981a50541b6b71495c48bab3c3
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
6 years agopass: Remove unneeded constant definition 98/158898/1
Chanwoo Choi [Mon, 6 Nov 2017 01:23:01 +0000 (10:23 +0900)]
pass: Remove unneeded constant definition

This patch removes the following unneeded definitions and clean-up
the unnecessary blank line from pass.h.
- #define PASS_RESOURCE_MAX 10
- #define PASS_CLUSTER_0 0
- #define PASS_CLUSTER_1 1

Change-Id: I6354067570995e03a5d077611c13781191ae85e8
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
6 years agopass: pmqos: Change name of 'struct pass_scenario_policy' to 'struct pass_pmqos' 54/158854/1
Chanwoo Choi [Fri, 3 Nov 2017 09:15:05 +0000 (18:15 +0900)]
pass: pmqos: Change name of 'struct pass_scenario_policy' to 'struct pass_pmqos'

The 'struct pass_scenario_policy' indicates the PMQoS module
and contains the scenario information. The 'pass_scenario_policy'
name is ambiguous for indicating the PMQoS module. So, this patch changes
the name from 'struct pass_scenario_policy' to 'struct pass_pmqos'
for the readability.

Also, this patch changes the variable name from 'list' to 'scenarios'.
The pmqos->scenarios is better than 'pmqos->list' in side of readability
in order to indicate the scenario list.

Change-Id: I402cec7ff1f922edbe67b8c216408ff702f2a2fb
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
6 years agopass: gov: Move private structure from pass.h to pass-gov.h 11/158611/2
Chanwoo Choi [Thu, 2 Nov 2017 06:37:16 +0000 (15:37 +0900)]
pass: gov: Move private structure from pass.h to pass-gov.h

The following private data are only used in the pass-gov*.c.
- enum pass_gov_state
- struct pass_governor

So, this patch moves them from pass.h to pass-gov.h in order
to prevent the unnecessary access to them.

Change-Id: Ia205a1f510eeea50a113fbefee7a48a499818246
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
6 years agopass: rescon: Remove unneeded enumeration pass_cpu_state 10/158610/2
Chanwoo Choi [Thu, 2 Nov 2017 06:34:42 +0000 (15:34 +0900)]
pass: rescon: Remove unneeded enumeration pass_cpu_state

This patch removes the unnecessary enumeration pass_cpu_state.
Instead, this patch uses the integer (0 or 1) for cpu_up/down.

Change-Id: I12bbc54edff7047c06a18e5b04d03b8b807f15da
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
6 years agopass: Change name of 'struct pass_table' to 'struct pass_level' 09/158609/1
Chanwoo Choi [Thu, 2 Nov 2017 06:32:00 +0000 (15:32 +0900)]
pass: Change name of 'struct pass_table' to 'struct pass_level'

PASS used the 'Level' expression which indicates the basic unit.
The modules of PASS decide the next level and then resource-controller
module set the h/w resource according to the decided level.

Prior to that, PASS used the 'struct pass_table' name. It is not correct
and make the confusion possible. So, this patch changes the name
of 'struct pass_table' to 'struct pass_level'.

Change-Id: If0df603dbaf98aa22aad49af15636cd67b35692a
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
6 years agopass: parser: update pass->num_resources properly 19/158219/4
Seung-Woo Kim [Mon, 30 Oct 2017 10:34:33 +0000 (19:34 +0900)]
pass: parser: update pass->num_resources properly

During pass_resource_config(), if allocation of res is failed,
pass->num_resources is only updated. Also, after pass->res is
freed from pass_put_resource_config(), pass->num_resources is not
set to 0. Update pass->num_resources propery from both cases.

Change-Id: Idb72e0fe46889436ded7aa07e514e78e9594e2c6
Signed-off-by: Seung-Woo Kim <sw0312.kim@samsung.com>
6 years agopmqos: update scenarios->num properly from pmqos_parse_scenario() 18/158218/4
Seung-Woo Kim [Mon, 30 Oct 2017 10:27:26 +0000 (19:27 +0900)]
pmqos: update scenarios->num properly from pmqos_parse_scenario()

If allocation of scenarios->list is failed, only scenarios->num is
updated. Update the scenarios->num propery.

Change-Id: Ia9b6c47f8449870ddefaca600ed5d0c1d9c47fe7
Signed-off-by: Seung-Woo Kim <sw0312.kim@samsung.com>
6 years agopmqos: clear freed scenario->list in pmqos_put_scenario() 17/158217/4
Seung-Woo Kim [Mon, 30 Oct 2017 09:52:18 +0000 (18:52 +0900)]
pmqos: clear freed scenario->list in pmqos_put_scenario()

Clear freed scenario->list in pmqos_put_scenario() to remove
possiblity of use-after-free.

Change-Id: I55266716473889ede04384ed3b8825eaf1dfc32b
Signed-off-by: Seung-Woo Kim <sw0312.kim@samsung.com>
6 years agopmqos: fix wrong condition to clear in pmqos_put_scenario() 75/158575/1
Seung-Woo Kim [Thu, 2 Nov 2017 02:12:11 +0000 (11:12 +0900)]
pmqos: fix wrong condition to clear in pmqos_put_scenario()

There is wrong condition to check scenarios->list is null before
freeing it in pmqos_put_scenario(). Fix the wrong condition.

Change-Id: Ib759f0af452ed90512e8ed55f486943dd857b8ba
Signed-off-by: Seung-Woo Kim <sw0312.kim@samsung.com>
6 years agopass: parser: update policy->scenario.num_scenarios properly 16/158216/2
Seung-Woo Kim [Mon, 30 Oct 2017 10:42:24 +0000 (19:42 +0900)]
pass: parser: update policy->scenario.num_scenarios properly

The policy->scenario.num_scenarios is not updated properly if
allocation of policy->scernario.list is failed. Also for case of
free it. Update policy->scenario.num_scenarios properly for both
cases.

Change-Id: I0fe18520ab304c57df9e1cac8713848da19055e4
Signed-off-by: Seung-Woo Kim <sw0312.kim@samsung.com>
6 years agopass: parser: clear freed scenario.list in pass_put_table() 91/156991/7
Seung-Woo Kim [Mon, 23 Oct 2017 05:03:52 +0000 (14:03 +0900)]
pass: parser: clear freed scenario.list in pass_put_table()

Clear freed scenario.list in pass_put_table() to remove possibility
of use-after-free.

Change-Id: I959546e12c1f811313cd65b50b7bac18b9787d6d
Signed-off-by: Seung-Woo Kim <sw0312.kim@samsung.com>
6 years agopass: Remove use-after-free of policy->pass_table during pass_exit_resource() 15/158215/2
Seung-Woo Kim [Mon, 30 Oct 2017 09:46:32 +0000 (18:46 +0900)]
pass: Remove use-after-free of policy->pass_table during pass_exit_resource()

During the pass_exit_resource(), pass_put_table() frees the
g_pass->policy->pass_table, and after that, pass_hotplug_stop() is
called and uses the pointer. Remove the use-after-free by clearing
policy->pass_table from pass_put_table() instead of
__pass_governor_exit() and checking null from pass_hot_plug_stop().

Change-Id: I00d57320dd9ed9f0bcaed406f066bdce37215656
Signed-off-by: Seung-Woo Kim <sw0312.kim@samsung.com>
6 years agopass: Release v1.0.0 62/158162/1
Chanwoo Choi [Tue, 24 Oct 2017 05:47:30 +0000 (14:47 +0900)]
pass: Release v1.0.0

Detailed description for this release:
- Provide first Tizen Power-Management framework (PASS)
- Support Scenario-based PMQoS (pmqos)
- Support CPU Hotplug Manager (cpuhp)
- Support Resource Controller (rescon)
- Support HAL interface (hal)

Change-Id: Ic4cf720bba3cde0f2806466c0e06088f892234d9
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
6 years agohal: Fix the TOCTOU issue by using the path on dlopen directly 91/152591/2 accepted/tizen/4.0/unified/20170929.075611 accepted/tizen/unified/20170928.072150 submit/tizen/20170927.080101 submit/tizen_4.0/20170927.080359 tizen_4.0.IoT.p1_release tizen_4.0.m2_release
Chanwoo Choi [Tue, 26 Sep 2017 11:11:44 +0000 (20:11 +0900)]
hal: Fix the TOCTOU issue by using the path on dlopen directly

Prior to that, pass_get_hal_info() checks whether filename is
accessible or not wiht access() and then load the library through
dlopen(). This sequence between access() and dlopen() has the
TOCTOU (Time of Check to Time Of Use) issue. So, this patch just
removes the calling of access() and then only use dlopen()
in order to TOCTOU issue.

Change-Id: I510eb7bcd2e91a5bacd743ef22af92298f72b4ae
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
6 years agopass: Fix the not-null terminated string 44/152544/4
Chanwoo Choi [Tue, 26 Sep 2017 09:54:59 +0000 (18:54 +0900)]
pass: Fix the not-null terminated string

The read() function doesn't add the '\0' character
to the end of string. So, this patch adds the '\0' char
on the last point of string if there is no error.

Change-Id: I1b3bf879b9c38f19edad8279d036c68655fae83b
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
6 years agopass: Print thermal name for each resource 74/151574/2
Chanwoo Choi [Thu, 21 Sep 2017 07:49:21 +0000 (16:49 +0900)]
pass: Print thermal name for each resource

This patch just prints the thermal name for each resource
for starting PASS in order to provide the resource information.

Change-Id: I2824186649a784722d1647df2fea0082256a63a8
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
6 years agopass: pmqos: Fix the svace warning 31/149731/1 accepted/tizen/4.0/unified/20170919.170914 accepted/tizen/unified/20170915.194627 submit/tizen/20170915.013740 submit/tizen_4.0/20170915.014015
Chanwoo Choi [Wed, 13 Sep 2017 04:21:58 +0000 (13:21 +0900)]
pass: pmqos: Fix the svace warning

This patch fixes the following svace warning.

[Warning Info]
WID:31612805 locked has enum type which is not isomorphic with boolean type,
however it is used as a boolean expression

Change-Id: I428750f3b667b0178b8886976a2d34e4b906f5b6
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
6 years agohal: Remove unused log macros 21/149421/1
Chanwoo Choi [Tue, 12 Sep 2017 04:26:14 +0000 (13:26 +0900)]
hal: Remove unused log macros

This patch just removes the unused log macros.

Change-Id: Id67b404ca11e5e17a1811de84569c51352d809fa
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
6 years agopass: Fix the checkpatch's warning to keep the coding style 69/149269/1
Chanwoo Choi [Tue, 12 Sep 2017 04:09:51 +0000 (13:09 +0900)]
pass: Fix the checkpatch's warning to keep the coding style

This patch just fixes the following checkpatch's warnings.

[Warning results from Tizen's checkpatch]
src/pass/pass-parser.c:
:210: ERROR: [IDT_M_TAB] code indent should use tabs where possible
:210: ERROR: [IDT_M_TAB] please, no spaces at the start of a line
:480: ERROR: [SPC_M_KWD] space required before the open parenthesis '('
:483: ERROR: [SPC_M_KWD] space required before the open parenthesis '('
:615: ERROR: [SPC_M_OPR] spaces required around that '=' (ctx:WxV)

src/pass/pass.c
:355: ERROR: [IDT_M_TAB] please, no space before tabs
:366: ERROR: [IDT_M_TAB] please, no space before tabs

src/pass/pass-gov.c
:387: ERROR: [SPC_M_KWD] space required before the open parenthesis '('

src/core/device-notifier.c
:32: ERROR: [BRC_M_FTN] open brace '{' following function declarations go on the next line

src/pmqos/pmqos.c
:92: WARNING: [BRC_R_SST] braces {} are not necessary
for any arm of this statement

src/shared/log.h
:28: ERROR: [SPC_M_KWD] space required before the open parenthesis '('
:29: ERROR: [SPC_M_KWD] space required before the open parenthesis '('
:30: ERROR: [SPC_M_KWD] space required before the open parenthesis '('
:31: ERROR: [SPC_M_KWD] space required before the open parenthesis '('

src/pass/pass.h
:408: ERROR: [SPC_M_SEP] space prohibited after that open parenthesis '('
:408: ERROR: [SPC_M_SEP] space prohibited before that close parenthesis ')'
:409: ERROR: [SPC_M_OPR] space required after that ',' (ctx:VxV)
:409: ERROR: [SPC_M_OPR] space required after that ';' (ctx:VxV)
:409: ERROR: [SPC_M_SEP] space prohibited after that open parenthesis '('
:409: ERROR: [SPC_M_SEP] space prohibited before that close parenthesis ')'

src/core/config-parser.h
:40: ERROR: [IDT_M_TAB] please, no spaces at the start of a line

src/core/devices.h
:116: ERROR: [SPC_M_OPR] spaces required around that '?' (ctx:VxW)
:119: ERROR: [SPC_M_KWD] space required before the open parenthesis '('
:120: ERROR: [SPC_M_KWD] space required before the open parenthesis '('
:123: ERROR: [SPC_M_KWD] space required before the open parenthesis '('
:124: ERROR: [SPC_M_KWD] space required before the open parenthesis '('

src/core/common.h
:115: ERROR: [IDT_M_TAB] code indent should use tabs where possible
src/core/common.h:115: ERROR: [IDT_M_TAB] please, no spaces at the start of a line
src/core/common.h:116: ERROR: [IDT_M_TAB] code indent should use tabs where possible
src/core/common.h:116: ERROR: [IDT_M_TAB] please, no spaces at the start of a line
src/core/common.h:117: ERROR: [IDT_M_TAB] code indent should use tabs where possible
src/core/common.h:117: ERROR: [IDT_M_TAB] please, no spaces at the start of a line
src/core/common.h:118: ERROR: [IDT_M_TAB] code indent should use tabs where possible
src/core/common.h:118: ERROR: [IDT_M_TAB] please, no spaces at the start of a line

src/hal/hal-log.h
:29: ERROR: [SPC_M_KWD] space required before the open parenthesis '('
:30: ERROR: [SPC_M_KWD] space required before the open parenthesis '('
:31: ERROR: [SPC_M_KWD] space required before the open parenthesis '('
:32: ERROR: [SPC_M_KWD] space required before the open parenthesis '('
:33: ERROR: [SPC_M_KWD] space required before the open parenthesis '('
:34: ERROR: [SPC_M_KWD] space required before the open parenthesis '('
:35: ERROR: [SPC_M_KWD] space required before the open parenthesis '('
:36: ERROR: [SPC_M_KWD] space required before the open parenthesis '('

src/hal/hal.h
:26: ERROR: [SPC_M_OPR] space required after that ',' (ctx:VxV)
:26: ERROR: [SPC_M_OPR] space required after that ',' (ctx:VxV)
:26: ERROR: [SPC_M_OPR] space required after that ',' (ctx:VxV)
:29: ERROR: [SPC_M_OPR] space required after that ',' (ctx:VxV)
:29: ERROR: [SPC_M_OPR] space required after that ',' (ctx:VxV)
:29: ERROR: [SPC_M_OPR] space required after that ',' (ctx:VxV)
:29: ERROR: [SPC_M_OPR] space required after that ',' (ctx:VxV)
:29: ERROR: [SPC_M_OPR] space required after that ',' (ctx:Vx )
:29: ERROR: [SPC_M_OPR] space required after that ',' (ctx:VxV)
:31: ERROR: [SPC_M_OPR] space required after that ',' (ctx:VxV)
:31: ERROR: [SPC_M_OPR] space required after that ',' (ctx:VxV)
:31: ERROR: [SPC_M_OPR] space required after that ',' (ctx:VxV)

Change-Id: I9bfb0db97b825e00d89487929037f833ecc0f156
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
6 years agopass: hal: Remove the meaningless condition 88/147988/3 accepted/tizen/unified/20170913.070645 submit/tizen/20170911.052326
Chanwoo Choi [Wed, 6 Sep 2017 07:53:14 +0000 (16:53 +0900)]
pass: hal: Remove the meaningless condition

The function in the src/pass/pass-hal.c checks whehter
'res_name'/'res_thermal_name' are NULL or not. But,
those are always not NULL.

This patch removes the meaningless condition for res_name/res_thermal_name.

Change-Id: I5727a4520cbceb05f73321d97b5c3cf2a38d33c7
Reported-by: Dongwoo Lee <dwoo08.lee@samsung.com>
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
6 years agopass: Add new fault_around_bytes feature for memory h/w device 47/146347/4
Chanwoo Choi [Mon, 28 Aug 2017 03:02:59 +0000 (12:02 +0900)]
pass: Add new fault_around_bytes feature for memory h/w device

This patch adds the new 'fault_around_bytes'[1] feature
of the memory h/w device. When the page fault happens,
'fault_around_bytes' is used.

The 'fault_around_bytes' indicates the number of bytes to be mapped
around the fault. If the value is low, it is able to increase
the amount of empty memory on normal case. On the other hand,
if the value is high, it is able to improve the performance
by mapping the huge pages such as the app launching.

It can be adjusted on the fly according to the user requirements.

[1] https://lkml.org/lkml/2016/4/18/612

Change-Id: Ib33e071ac6f46dd746c00dd473bd48dfe48e1aea
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
6 years agopass: Add new struct pass_resource_memory to support memory h/w device 46/146346/3
Chanwoo Choi [Mon, 28 Aug 2017 02:47:16 +0000 (11:47 +0900)]
pass: Add new struct pass_resource_memory to support memory h/w device

This patch adds the new 'struct pass_resource_memory' in order to
manage the memory[1] h/w device according to the requirements.

If the new requirements arise in the future, the new functions
will be added in the struct pass_resource_memory.

[1] https://en.wikipedia.org/wiki/Computer_memory

Change-Id: Iccbb576757cf25f748fac6d03e3a5aebda5facd3
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
6 years agohal: Define new struct pass_resource_memory for memory h/w device 45/146345/3
Chanwoo Choi [Mon, 28 Aug 2017 01:34:07 +0000 (10:34 +0900)]
hal: Define new struct pass_resource_memory for memory h/w device

This patch defines the new 'struct pass_resource_memory' in order to
manage the memory[1] h/w device. The struct pass_resource_memory
includes the functions to handle the 'fault_around_bytes'[2]
for memory device.

[1] https://en.wikipedia.org/wiki/Computer_memory
[2] https://lkml.org/lkml/2016/4/18/612

Change-Id: Ib5694331ce24700ec6b84802a807826ed57192f2
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
6 years agopass: Add description of properties in the PASS's level 70/147970/2
Chanwoo Choi [Wed, 6 Sep 2017 06:31:25 +0000 (15:31 +0900)]
pass: Add description of properties in the PASS's level

This patch adds the detailed description for properties
in the PASS's level and removes the unused 'comm_cond' variable.

Change-Id: Iee4e3ce9b3b789b5b2d84e3edb10b4122308e595
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
6 years agocore: Replace functionalities based on Ecore with ones based on GLib 51/144851/15
Wook Song [Fri, 4 Aug 2017 06:04:17 +0000 (15:04 +0900)]
core: Replace functionalities based on Ecore with ones based on GLib

Since Ecore library is tightly coupled with EFL which is a set of
graphics libraries, for the devices without GUI, so called 'headless
devices', even if the system only requires the functionalities provided
by Ecore, many unnecessary packages should be included in it. This could
make the size of the platform image bigger. For this reason, we decided
to reimplement all the functionalites based on Ecore of PASS using GLib.

This patch replaces the functionalites based on Ecore with ones based on
GLib. In detail, the ecore main loop is changed to the glib main loop
and the ecore timer-based task handling is now changed to the glib
timeout-based task handling mechanism. In addition, in order to support
DBus IPC, PASS uses gdbus now instead of edbus. The code based on gdbus
which was implemented the old-fashioned way is also refactored by this
patch.

Change-Id: I6660c7f84da0ba5adce5f765852b4d9d0af781e9
Signed-off-by: Wook Song <wook16.song@samsung.com>
6 years agohal: Remove unused version info 52/147652/1
Chanwoo Choi [Tue, 5 Sep 2017 05:20:58 +0000 (14:20 +0900)]
hal: Remove unused version info

This patch removes the unused version info

Change-Id: I406ec9fe5df88bfc95fb0d7d0578ea73d894e1f8
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
6 years agopass: Skip exit process for uninitialized resources 62/146162/5 accepted/tizen/4.0/unified/20170901.202640 accepted/tizen/unified/20170829.053236 submit/tizen/20170828.071557 submit/tizen_4.0/20170901.015952
Dongwoo Lee [Fri, 25 Aug 2017 06:43:34 +0000 (15:43 +0900)]
pass: Skip exit process for uninitialized resources

Even in the case that the resource is not initialized due to any
reason, pass tries to exit that resource during service stop, and
thus it causes failure on exit process. To resolve it, this patch
adds the state of resource and set UNUSED state to resource on error
case. After that, exit process for the resource in UNUSED state will
be skipped.

Change-Id: Id635471d39b3d19378613935666cfd911813baf3
Signed-off-by: Dongwoo Lee <dwoo08.lee@samsung.com>
6 years agopass: parser: Fix memory leakage for resource list 61/146161/2
Dongwoo Lee [Fri, 25 Aug 2017 06:12:02 +0000 (15:12 +0900)]
pass: parser: Fix memory leakage for resource list

Resource list is allocated during pass configuration is parsed. But,
nowhere is deallocation function for freeing it. To protect memory
leakage, resource will be freed properly.

Change-Id: I6125c06604e2b0c6824c258b2a4d4f6ce4a2d902
Signed-off-by: Dongwoo Lee <dwoo08.lee@samsung.com>
6 years agoCREDITS: Add main contributor info 62/145862/2 accepted/tizen/unified/20170824.172538 submit/tizen/20170824.064003
Chanwoo Choi [Thu, 24 Aug 2017 05:49:34 +0000 (14:49 +0900)]
CREDITS: Add main contributor info

Dongwoo Lee <dwoo08.lee@samsung.com> develops the PASS's features
and fixes the bugs. He is main contributor of PASS.

Change-Id: Ie140c688650fb94b9c35f2c9b69b96481f8b5fd2
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
6 years agopass: hal: Fix the bug when putting the nonstandard resource 44/144844/1
Chanwoo Choi [Fri, 18 Aug 2017 05:08:13 +0000 (14:08 +0900)]
pass: hal: Fix the bug when putting the nonstandard resource

The commit 9eabff35831a ("pass: Add the support for new struct
pass_resource_nonstandard type") missed adding the 'break' when
putting the nonstandard resource. So, the error happen when
releasing the nonstandard resource.

This patch adds the missing 'break' to fix the bug.

Change-Id: I867c820411e34e42d3ebc4afd06f7f9c2071a5ec
Fixes: commit 9eabff35831a ("pass: Add the support for new struct pass_resource_nonstandard type")
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
6 years agocore: Refactor macros which wrap the g_list functions in list.h 41/141041/7 accepted/tizen/4.0/unified/20170829.020255 accepted/tizen/unified/20170822.023808 submit/tizen/20170821.043932 submit/tizen_4.0/20170828.100004 submit/tizen_4.0/20170828.110004
Wook Song [Thu, 27 Jul 2017 23:39:58 +0000 (08:39 +0900)]
core: Refactor macros which wrap the g_list functions in list.h

In list.h, there are a group of macro definitions started with the prefix
'DD_LIST'. Most of these macros are neither meaningful nor necessary
since they just wrap the corresponding g_list functions. For this
reason, this patch removes those wrapping macros. In addition, the
prefix 'DD_LIST' is ambiguous. This patch also changes the prefix
'DD_LIST' to more direct prefix "G_LIST".

Change-Id: Iaa1aa4b5ed89e62ab93c0f4569b735a8f807793c
Signed-off-by: Wook Song <wook16.song@samsung.com>
6 years agopass: hal: Replace the function to get initial maximum frequency 46/143146/5
Dongwoo Lee [Mon, 7 Aug 2017 05:53:09 +0000 (14:53 +0900)]
pass: hal: Replace the function to get initial maximum frequency

The current maximum frequency is used for saving initial data of
frequency. However, it is affected by other factor such as thermal
throttling, thus the initial value can be lower than expected.
To prevent this problem, the available maximum frequency will be
used to get initial frequency data.

Change-Id: If8d65da8896a547d66abc0c2e053585468d3c346
Reported-by: Wook Song <wook16.song@samsung.com>
Signed-off-by: Dongwoo Lee <dwoo08.lee@samsung.com>
6 years agopass: hal: Add functions for getting available min/max frequency 45/143145/6
Dongwoo Lee [Mon, 7 Aug 2017 05:16:24 +0000 (14:16 +0900)]
pass: hal: Add functions for getting available min/max frequency

This patch adds the new functions to HAL dvfs callbacks to get
available minimum and maximum frequency. Available frequency means
that the frequency which can be set to the resource. Thus,
HAL implementation for these function should return the proper value
as following the resource's available frequency list.

Change-Id: Ie39eef51c115e12bb5c2f82d07c557328a8a0e2b
Signed-off-by: Dongwoo Lee <dwoo08.lee@samsung.com>
6 years agopass: Use error log macro with _E when error happen 81/142981/2
Chanwoo Choi [Tue, 8 Aug 2017 06:16:13 +0000 (15:16 +0900)]
pass: Use error log macro with _E when error happen

The PASS has the following log macros. When error happen,
the modules have to use the _E macro.
- _I : info
- _D : debug
- _E : error
- _W : warning

Change-Id: I02ac5b6ce4d59519964bc7af78910d8231d98535
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
6 years agoshared: Remove unused log macro 80/142980/1
Chanwoo Choi [Tue, 8 Aug 2017 06:06:53 +0000 (15:06 +0900)]
shared: Remove unused log macro

This patch just removes the unused log macro.

Change-Id: Icf707417845f27c8905e6f538c0f864bf57c919b
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
6 years agopmqos: Move pass-pmqos.conf to scripts directory 51/142451/1
Chanwoo Choi [Fri, 4 Aug 2017 02:01:35 +0000 (11:01 +0900)]
pmqos: Move pass-pmqos.conf to scripts directory

The 'scripts' directory includes the configuration files.
So, this patch moves 'pass-pmqos.conf' from ./src/pmqos to ./scripts.

Change-Id: I2e056571a86173a7d0255bf40e8e06ab4b9689f3
Suggested-by: Dongwoo Lee <dwoo08.lee@samsung.com>
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
6 years agocore: Remove unused device-idler files 14/141514/3
Wook Song [Tue, 1 Aug 2017 02:10:15 +0000 (11:10 +0900)]
core: Remove unused device-idler files

The functions in the device-idler source and header files are not used
outside of them. Therefore, this patch removes these files and excludes
them from the build of PASS.

Change-Id: I78c3b39f898edf23ebe6da7625c7d4ff455bf98b
Signed-off-by: Wook Song <wook16.song@samsung.com>
6 years agopass: parser: Eliminate unnecessary whitespaces 18/141118/3
Wook Song [Fri, 28 Jul 2017 07:35:46 +0000 (16:35 +0900)]
pass: parser: Eliminate unnecessary whitespaces

This patch eliminates unnecessary whitespaces at pass_parse_level and
pass_resource_data.

Change-Id: Ib669f266d65f79bc5eaf1139f04417568a7fdaf6
Signed-off-by: Wook Song <wook16.song@samsung.com>
6 years agopass: hal: Fix build warning caused by a wrong scanf format specifier 43/141043/8
Wook Song [Fri, 28 Jul 2017 02:05:52 +0000 (11:05 +0900)]
pass: hal: Fix build warning caused by a wrong scanf format specifier

The original type of int64_t depends on whether 32-bit or 64-bit
environment. In detail, on the 32-bit environment, int64_t is long long
int while, on the 64-bit environment, it is long int. Therefore, using
%lld for the scanf format specifier of int64_t on the 64-bit environment
causes a build warning. This patch fixes the following build warning [1]
using the special purpose format specifier, SCNd64, for int64_t.

[1] "warning: format '%lld' expects
argument of type 'long long int *', but argument 3 has type 'int64_t *
{aka long int *}' [-Wformat=]"

Change-Id: I6a4cb301858635b2cef91fdee8d04540413f7bec
Signed-off-by: Wook Song <wook16.song@samsung.com>
Reviewed-by: Chanwoo Choi <cw00.choi@samsung.com>
6 years agopmqos: Fix build warning caused by mis-type casting 42/141042/7
Wook Song [Fri, 28 Jul 2017 01:23:39 +0000 (10:23 +0900)]
pmqos: Fix build warning caused by mis-type casting

This patch fixes a build warning caused by mis-type casting from a
pointer to a int type while building the package for aarch64. On the
32-bit environment, the size of a pointer is 4 bytes which is the same
size of a int type. However, on the other hand, on the 64-bit
environment, the size of a pointer is 8 bytes while the size of a int
type is still 4 bytes. This is the main reason of the build warning.

According to the booting_done_received function in sre/core/boot.c, a
pointer of the int variable, done, is passed as the first argument, a
void pointer, of the notifier call back functions. Therefore, such type
casting from a void pointer to int is unnecssary and seems to be buggy.
This patch modifies it to cast the type from void pointer to int
pointer.

Change-Id: I1dc9932b11a2800c56de23bbdb4a3dd66cee854f
Signed-off-by: Wook Song <wook16.song@samsung.com>
Reviewed-by: Chanwoo Choi <cw00.choi@samsung.com>
6 years agopass: rescon: Separate pass-rescon module from pass-gov module 21/139921/1 accepted/tizen/4.0/unified/20170816.011839 accepted/tizen/4.0/unified/20170816.014952 accepted/tizen/unified/20170804.025536 submit/tizen/20170802.103729 submit/tizen_4.0/20170811.094300 submit/tizen_4.0/20170814.115522 submit/tizen_4.0_unified/20170814.115522
Chanwoo Choi [Fri, 14 Jul 2017 01:37:18 +0000 (10:37 +0900)]
pass: rescon: Separate pass-rescon module from pass-gov module

The existing pass-gov module has the three features as following:
- Resource Controller to change the current/min/max 'PASS Level' -> rescon.
- Resource Monitor to collect the current system status -> resmon.
- Runtime governor for CPU hotplug policy.

In order to make the pass-rescon as the separate module,
this patch creates the pass-rescon.c module from pass-gov module separately.

Change-Id: I2f4e96fa47e95b0f503638cf4c944699fbea44c5
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
6 years agopass: hal: Move get_time_ms() pass-hal.c to pass-pmqos.c 20/139920/1
Chanwoo Choi [Fri, 14 Jul 2017 02:47:55 +0000 (11:47 +0900)]
pass: hal: Move get_time_ms() pass-hal.c to pass-pmqos.c

The existing get_time_ms() is only used on pass-pmqos.c.
So, this patch moves the definition of get_time_ms()
from pass-hal.c to pass-pmqos.c.

Change-Id: Ic89cb705071633b5093722a4ab26e71133c444cb
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
6 years agopass: hal: Fix build warning of unused variable 19/139919/1
Chanwoo Choi [Thu, 20 Jul 2017 09:17:55 +0000 (18:17 +0900)]
pass: hal: Fix build warning of unused variable

The commit ac65764c65d8 ("pass: hal: Assign resource name directly
instead of copying it) doesn't remove the unused variable. This patch
removes the unused variable to remove the build warning.

Change-Id: Ice9fe962c6ad5a4ec3941baabe0323b1d6748858
Fixes: ac65764c65d8 ("pass: hal: Assign resource name directly instead of copying it)
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
6 years agopass: Fix bug to check return value of pass_get_resource() 18/139918/1
Chanwoo Choi [Fri, 14 Jul 2017 01:48:15 +0000 (10:48 +0900)]
pass: Fix bug to check return value of pass_get_resource()

The commit 0e039c5ce2677 ("pass: hal: Modify the definition of
pass_get/put_resource()") add the wrong code related to checking
the return value of pass_get_resource(). This patch fixes the bug
of checking the return value of pass_get_resource().

Change-Id: Ia9704ee96ddec0eecc183fad96fd8583a46b47f9
Fixes: 0e039c5ce2677 ("pass: hal: Modify the definition of pass_get/put_resource()")
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
6 years agoscripts: Apply dbus security policy using xml-based conf file 83/139783/2
Wook Song [Thu, 20 Jul 2017 09:52:51 +0000 (18:52 +0900)]
scripts: Apply dbus security policy using xml-based conf file

Until now, there is no specific dbus security policy in PASS. Therefore,
any processes which do not have the root or special privileges can send
dbus messages to the pass daemon. This could be a serious security hole.
In order to solve such problem, this patch applies a dbus security
policy by using the pass.conf file, which is formed in XML format.

From now, without the root privileges, it is not allowed to send dbus
messages to the pass daemon. Only dbus messages sent from the processes
whose user ids are *app_fw* to the pmqos interface can be received by
the pass daemon.

Change-Id: I583eb3a097e1181e9b02b896bd97d54771c63f9c
Signed-off-by: Wook Song <wook16.song@samsung.com>
6 years agopass: Restore resource state after PASS service is stopped 93/138593/12
Dongwoo Lee [Tue, 11 Jul 2017 08:00:44 +0000 (17:00 +0900)]
pass: Restore resource state after PASS service is stopped

The resource state can be changed during PASS operation, but it
should be restored to default state after PASS is over. To do this,
PASS saves initdata of each resource during initalization process
and restores it before putting resources.

Change-Id: If9f3d712cd3288d508187295c5b3def88043c509
Signed-off-by: Dongwoo Lee <dwoo08.lee@samsung.com>
Reviewed-by: Chanwoo Choi <cw00.choi@samsung.com>
Reviewed-by: Wook Song <wook16.song@samsung.com>
7 years agocore: Remove unused /var/run/.pass.pid file 13/139413/2 accepted/tizen/unified/20170720.164745 submit/tizen/20170719.015733
Chanwoo Choi [Wed, 19 Jul 2017 01:27:29 +0000 (10:27 +0900)]
core: Remove unused /var/run/.pass.pid file

PASS stores the pid to the /var/run/.pass.pid. But it is not used
and it has the security issue if the path is symbolic link.

This patch removes the /var/run/.pass.pid file.

Change-Id: I816da948f9ebe9203119bc4b21041d0a926aa338
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
7 years agopass: hal: Assign resource name directly instead of copying it
Dongwoo Lee [Mon, 17 Jul 2017 01:55:15 +0000 (10:55 +0900)]
pass: hal: Assign resource name directly instead of copying it

The resource name is copied from .rodata region, but it is local
variable and is not assigned to other structure or global variable.
Thus, we can easily assign the name instead of copying it.

Change-Id: I6f911d2e35ed52fb0d3a39700e3735d0986360da
Signed-off-by: Dongwoo Lee <dwoo08.lee@samsung.com>
7 years agocore: Remove unused log.c file 33/138833/3
Wook Song [Fri, 14 Jul 2017 04:04:25 +0000 (13:04 +0900)]
core: Remove unused log.c file

For the debugging purpose, in the log.c, there are several functions
which PASS does not use. This patch simply removes the log.c file and
elminates the DEBUG macro, which is not used anywhere but log.c.

Change-Id: Ib40c16f41fd2465bbf5bb48e16559ed7b1c7f209
Signed-off-by: Wook Song <wook16.song@samsung.com>
7 years agopass: hal: Check whether parameter is valid or not 03/138803/2
Chanwoo Choi [Fri, 14 Jul 2017 01:08:21 +0000 (10:08 +0900)]
pass: hal: Check whether parameter is valid or not

This patch checks whether the parameter is valid or not
in order to prevent the unexpected behavior.

Change-Id: Idb0a3c97f15a95231f39569ac528ab4b1001eded
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
7 years agopass: hal: Permit zero value for setting dvfs data 98/138798/1
Dongwoo Lee [Thu, 13 Jul 2017 04:10:05 +0000 (13:10 +0900)]
pass: hal: Permit zero value for setting dvfs data

Now several set-functions cannot take zero for target value. However,
zero is acceptable value whether it is reasonable or not. Thus, zero
is permitted for function parameter, and functions will only reject
negative value.

Change-Id: Ic363abc239ab521577165768f1e41a61e502f4c3
Signed-off-by: Dongwoo Lee <dwoo08.lee@samsung.com>
7 years agopass: Clean-up code to remove unneded prefix (pass_res -> res) 37/138637/1
Chanwoo Choi [Thu, 13 Jul 2017 05:20:00 +0000 (14:20 +0900)]
pass: Clean-up code to remove unneded prefix (pass_res -> res)

The pass core uses the 'pass_res' variable name to indicate the instance
of 'struct pass_resource'. 'pass_' prefix is not beneficial and not necessary.
This patch alters 'pass_res' to 'res' simply and use the 'res_type' name
insted of 'id' variable name in order to improve the understanding
what is meaning of variable.

Change-Id: Idf2a2a8ea1f48d1724d40dc50488097946113d57
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
7 years agopass: Change the name of pass_resource_init/exit() 36/138636/1
Chanwoo Choi [Thu, 13 Jul 2017 04:29:52 +0000 (13:29 +0900)]
pass: Change the name of pass_resource_init/exit()

The defined function used the following format to make the function name:
- "pass_[verb]_[object]()"

In order to maintain the consistency, this patch changes the function name
as following:
- pass_resource_init() -> pass_init_resource()
- pass_resource_exit() -> pass_exit_resource()

Change-Id: I2438906539c14931681c5883d702dd05a786234f
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
7 years agopass: Remove unnecessary continue statement 53/138453/2
Dongwoo Lee [Wed, 12 Jul 2017 07:45:04 +0000 (16:45 +0900)]
pass: Remove unnecessary continue statement

There is continue statement at the end of while block which have no
meaning. Unnecessary continue statement will be removed.

Change-Id: Ifd014b397bfb867d9fbc13c78e39ee613601fec3
Signed-off-by: Dongwoo Lee <dwoo08.lee@samsung.com>
7 years agopass: Put resource properly to prevent memory leak 10/138110/3
Dongwoo Lee [Tue, 11 Jul 2017 05:54:57 +0000 (14:54 +0900)]
pass: Put resource properly to prevent memory leak

There are two cases which can cause memory leak during pass init/exit:
 1. When resource initialization is failed, it just skips that
    resource without putting it.
 2. In the case of failure while freeing resources, it is also skipped
    putting that resource.

To prevent memory leak, the resource will be put on both cases.

Change-Id: I4008b7785e0dbbc318b38eb573bf739e0a848b6c
Signed-off-by: Dongwoo Lee <dwoo08.lee@samsung.com>
7 years agopass: hal: Rename 'pass_get_policy' to 'pass_get_tmu_policy' 33/137633/3
Wook Song [Fri, 7 Jul 2017 02:14:39 +0000 (11:14 +0900)]
pass: hal: Rename 'pass_get_policy' to 'pass_get_tmu_policy'

This patch renames a HAL interfaces named 'pass_get_policy' to
'pass_get_tmu_policy' because of the ambiguous meaning of its original
function name.

Change-Id: I533191deb87933e8c0d779883fb41f90ceb3d3e8
Signed-off-by: Wook Song <wook16.song@samsung.com>
7 years agohal: Remove author entry from struct pass_resource_info 35/137635/2 accepted/tizen/unified/20170711.180630 submit/tizen/20170710.060912
Chanwoo Choi [Fri, 7 Jul 2017 02:15:24 +0000 (11:15 +0900)]
hal: Remove author entry from struct pass_resource_info

This patch just removes the author entry because it is not good
to fix the specific person in charge of the h/w resource.
So, all files of pass git repo doesn't have the any author information
for each *.c file.

Change-Id: I1d6b4eaccf2c4410ac07681a327906195c6c818e
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
7 years agopass: hal: Use 'res_thermal_name' as the first argument for TMU HAL 32/137632/6
Wook Song [Fri, 7 Jul 2017 02:03:37 +0000 (11:03 +0900)]
pass: hal: Use 'res_thermal_name' as the first argument for TMU HAL

This patch makes the TMU HAL functions use 'res_thermal_name' as the
first argument, which is previously 'res_name'. This change will allow
the TMU HAL function bodies to be implemented without any hard-coded
sysfs node names.

Change-Id: I702d28bfab3b110a7bdba9c3bb7601bf0e250a23
Signed-off-by: Wook Song <wook16.song@samsung.com>
Reviewed-by: Chanwoo Choi <cw00.choi@samsung.com>
7 years agopass: parser: Add parsing of pass_res_thermal_name 31/137631/8
Wook Song [Thu, 6 Jul 2017 08:43:59 +0000 (17:43 +0900)]
pass: parser: Add parsing of pass_res_thermal_name

This patch adds a parsing mechanism for the new mandatory entry,
pass_res_thermal_name, in the PassResource section of the pass.conf
file. The value of this property will be used by the TMU HAL interfaces.

Change-Id: I4f063aea6941a82322c3c3a6f1fde153c97061bc
Signed-off-by: Wook Song <wook16.song@samsung.com>
Reviewed-by: Chanwoo Choi <cw00.choi@samsung.com>
7 years agopass: parser: Remove hard-coded length of path strings in pass_conf_data 54/137454/7
Wook Song [Thu, 6 Jul 2017 04:20:34 +0000 (13:20 +0900)]
pass: parser: Remove hard-coded length of path strings in pass_conf_data

This patch removes the hard-coded length of character arrays, which
indicates file paths, in the pass_conf_data structure.

Change-Id: I3fd48d645560b004a7609a90a97fcf8d4cd3ec32
Signed-off-by: Wook Song <wook16.song@samsung.com>
Reviewed-by: Chanwoo Choi <cw00.choi@samsung.com>
7 years agopass: Modify the definition of pass_resource_init/exit() 88/137488/5
Chanwoo Choi [Thu, 6 Jul 2017 05:38:22 +0000 (14:38 +0900)]
pass: Modify the definition of pass_resource_init/exit()

This patch uses the 'struct pass_resource *' on pass_resource_init/exit()
instead of 'struct pass_policy' because the 'struct pass_resource' indicates
each h/w resource. Also, this patch maintains the same format for argument
when calling the pass_resource_*() function.

[Before]
pass_resource_init(struct pass_policy *policy)
pass_resource_exit(struct pass_policy *policy)

[After]
pass_resource_init(struct pass_resource *pass_res)
pass_resource_exit(struct pass_resource *pass_res)

Change-Id: I457f02b6a67df5e5c8b484fdea5f83587a2f9b67
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
7 years agopass: Handle each h/w resource as the independent element 87/137487/5
Chanwoo Choi [Thu, 6 Jul 2017 04:49:38 +0000 (13:49 +0900)]
pass: Handle each h/w resource as the independent element

PASS handles each h/w resource independently. When PASS fail
to initialize or load the library, it should not affect anything else.

So, this patch tries to initialize/exit each h/w resource continuously
when other h/w resource faild to initialize/exit because each h/w resource
is independent.

Change-Id: Ibc0d40347c6b6dbbf4c2576659d937e171fa362e
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
7 years agopass: hal: Modify the definition of pass_get/put_resource() 86/137486/5
Chanwoo Choi [Thu, 6 Jul 2017 04:45:42 +0000 (13:45 +0900)]
pass: hal: Modify the definition of pass_get/put_resource()

The existing pass_get/put_resource() handles the all of resources
with 'struct pass *pass' argument which includes the information
of all h/w resources.

So, this patch modifies the definition of pass_get/put_resrouce()
in order to handle the each h/w resource with 'struct pass_resource *'
argument. And this patch changes the log message in the pass_init/exit_done()
in order to keep the same log format.

And this patch removes the unnecessary log of pass_get/put_resource().

[Before]
- pass_get_resource(struct pass *pass)
- pass_put_resource(struct pass *pass)

[After]
- pass_get_resource(struct pass_resource *pass_res)
- pass_put_resource(struct pass_resource *pass_res)

Change-Id: I704d1b1d9bc2cfe84fd3af05fe12ab8364b21df7
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
7 years agoshared: Remove unused dbus inferface (sysnoti) 85/137485/2
Chanwoo Choi [Thu, 6 Jul 2017 05:49:13 +0000 (14:49 +0900)]
shared: Remove unused dbus inferface (sysnoti)

This patch removes the unused dbus interface (sysnoti).

Change-Id: I8f1b35d6def8a615502da0282ffad81f7b25a576
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
7 years agoshared: Remove unused header file 84/137484/2
Chanwoo Choi [Thu, 6 Jul 2017 05:47:16 +0000 (14:47 +0900)]
shared: Remove unused header file

This patch removes the unused header file (deviced-priv.h).

Change-Id: If3651171e2d1b9ec19dccf07fd4c31f489f7aa51
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
7 years agopass: gov: Set the raw data of PMQoS to HAL 78/136378/4 accepted/tizen/unified/20170706.193437 submit/tizen/20170705.081057
Chanwoo Choi [Tue, 27 Jun 2017 06:19:55 +0000 (15:19 +0900)]
pass: gov: Set the raw data of PMQoS to HAL

This patch calls the pass_set_pmqos_data() in order to set
the raw data from platform to HAL layer because of supporting
the backward compatibility.

Change-Id: I49b03382596f66682895b8cbd005cfeb7fd921cb
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
7 years agopass: Add the support for new struct pass_resource_nonstandard type 77/136377/4
Chanwoo Choi [Mon, 26 Jun 2017 08:56:28 +0000 (17:56 +0900)]
pass: Add the support for new struct pass_resource_nonstandard type

This patch support the new 'struct pass_resource_nonstandard'
in order to handle the nonstandard devices except for cpu/bus/gpu.
This h/w resource has the following functions:
- int set_pmqos_data(char *res_name, void *data)

And this patch adds the pass_set_pmqos_data() helper function
in order to bypass the PMQoS's data (scearnio name + 'Lock' or 'Unlock')
from platform to HAL layer. This function calls the .set_pmqos_data()
in the HAL pacakge.

Change-Id: I80f06f7e6bd29c30b9f7ace561642298636230f1
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
7 years agopass: hal: Add description for helper functions 76/136376/3
Chanwoo Choi [Mon, 26 Jun 2017 09:00:34 +0000 (18:00 +0900)]
pass: hal: Add description for helper functions

This patch adds the simple description for helper functions
in order to improve the readability for the supported range of functions.

Change-Id: Ibbddda47c1f7560291d9fee709bb5da8573fcc93
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
7 years agohal: Add new struct pass_resource_nonstandard for nonstandard device 75/136375/3
Chanwoo Choi [Mon, 26 Jun 2017 08:21:20 +0000 (17:21 +0900)]
hal: Add new struct pass_resource_nonstandard for nonstandard device

This patch adds new 'struct pass_resource_nonstandard' in order to
support the nonstandard devices except for cpu/bus/gpu.

This patch just adds the following function in order to support
the backwards compatibility. This function will be removed
after finding the proper method.
- int (*set_pmqos_data)(char *res_name, void*) : Set PMQoS's data to HAL.

Change-Id: Ia0310c43226b0ab000c9470784e9d55ec507d119
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
7 years agohal: Add separate description for each struct pass_resource_* 74/136374/1
Chanwoo Choi [Tue, 27 Jun 2017 03:45:47 +0000 (12:45 +0900)]
hal: Add separate description for each struct pass_resource_*

This patch adds the seprate description for each h/w resource
in order to improve the readability of the meaning of struct pass_resource_*.

Change-Id: I44e6a2be7adc7a6e1136d9893f22a168de7588d2
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
7 years agopmqos: Remove unsupported scenarios 73/136373/1
Chanwoo Choi [Tue, 27 Jun 2017 10:29:38 +0000 (19:29 +0900)]
pmqos: Remove unsupported scenarios

This patch removes the unsupported scenarios on platform.

Change-Id: I43f1a19d6332709005b8a493a3d44e6e45533c52
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
7 years agopass: parser: Change pass_res_type in pass.conf from number to string 97/134897/2 submit/tizen/20170629.044637
Wook Song [Tue, 20 Jun 2017 08:10:07 +0000 (17:10 +0900)]
pass: parser: Change pass_res_type in pass.conf from number to string

This patch changes the type of the value of "pass_res_type" in each
PassResource section of the pass.conf file from a number to a meaningful
string like cpu, bus, and gpu.

Change-Id: I1d3a33d7a16b93f44b422ca470cd60c70198e3fc
Signed-off-by: Wook Song <wook16.song@samsung.com>
7 years agopmqos: Add 'scenario_max_timeout_ms' property to set the maximum timeout 55/134555/5
Chanwoo Choi [Mon, 19 Jun 2017 05:13:35 +0000 (14:13 +0900)]
pmqos: Add 'scenario_max_timeout_ms' property to set the maximum timeout

Each scenario wants to lock the h/w resources within their own timeout.
If the specific scenario wants to lock the h/w resources for so long time,
it is not reasonable. So, PMQoS core has the maximum timeout in order to
protect the excessive occupation of h/w resources.

This patch adds the new 'scenario_max_timeout_ms' property which means
the maximum timeout for the scenarios on specific h/w board. The owner
of PASS daemon can adjust the maximum timeout according to the h/w board.

Change-Id: Ic38137f667c34230b90e9217d33549d5859fd5fa
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
7 years agopass: core: Remove unused udev module
Wook Song [Mon, 19 Jun 2017 03:57:31 +0000 (12:57 +0900)]
pass: core: Remove unused udev module

This patch removes currently unused udev module.

Change-Id: If230c74e12e42d253677c0e54aeb23ad66655f28
Signed-off-by: Wook Song <wook16.song@samsung.com>
7 years agopass: Remove unused pass.socket file
Chanwoo Choi [Fri, 16 Jun 2017 07:47:19 +0000 (16:47 +0900)]
pass: Remove unused pass.socket file

This patch just removes the unused pass.socket file.

Change-Id: I76a84018b81d0c6290d10a4b7becc8849709e7de
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
7 years agopass: Change permission from root to 'system_fw' uid/gid
Chanwoo Choi [Thu, 15 Jun 2017 10:00:56 +0000 (19:00 +0900)]
pass: Change permission from root to 'system_fw' uid/gid

This patch changes the permission from root to 'system_fw' uid/gid for PASS.
Basically, Tizen has the policy to reduce the number of root daemon
to protect the security issues. If PASS has the system_fw uid, it is enough
to handle the h/w resources.

Change-Id: I48aef3da083b6f1f4160ed166fdad89293acc5b6
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
7 years agopass: gov: Fix build warnings caused by unused variables 30/133630/3 accepted/tizen/unified/20170615.020700 submit/tizen/20170614.020920
Wook Song [Tue, 13 Jun 2017 03:03:13 +0000 (12:03 +0900)]
pass: gov: Fix build warnings caused by unused variables

This patch fixes build warnings, which are caused by unused variables,
in the __pass_governor_init and __pass_governor_exit functions.

Change-Id: I9609991e1ef3e2b8136467171a595a68ec000bc3
Signed-off-by: Wook Song <wook16.song@samsung.com>
7 years agocore: edbus-handler: Eliminate unused code and dynamic memory allocation 29/133629/2
Wook Song [Tue, 13 Jun 2017 02:22:44 +0000 (11:22 +0900)]
core: edbus-handler: Eliminate unused code and dynamic memory allocation

This patch removes the unused code from edbus-handler. In addition,
dynamic memory allocation is also eliminated in order to avoid the
possibility of memory leak.

Change-Id: I7d16b4aac56e2cb59b920db52db6c70a5b445147
Signed-off-by: Wook Song <wook16.song@samsung.com>
7 years agopass: pmqos: Modify log when the received scenario is not supported 86/133486/4
Chanwoo Choi [Mon, 12 Jun 2017 11:03:15 +0000 (20:03 +0900)]
pass: pmqos: Modify log when the received scenario is not supported

This patch modifies the log when the received scenario is not supported
as following:

1. Remove 'Lock' and 'Unlock' word from scenario name.
- Before : "Unknown scenario (SIOPLock) for 'cpu0' resource"
- After  : "Unknown scenario (SIOP) for 'cpu0' resource"

2. Use 'Not supported' instead of 'cannot support'.
- Before : "cannot support 'AppLaunch' scenario for 'cpu0' resource"
- After  : "Not supported 'AppLaunch' scenario for 'cpu0' resource"

Change-Id: Ibeeb0f2fba3fc46e27fc1e2b16b74d167d83c3e7
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
7 years agopmqos: Fix bug of 'support' property of pass-pmqos.conf 75/133475/1
Chanwoo Choi [Mon, 12 Jun 2017 10:28:43 +0000 (19:28 +0900)]
pmqos: Fix bug of 'support' property of pass-pmqos.conf

This patch fixes the bug related to 'support' property of pass-pmqos.conf.

PASS PMQoS has the pass-pmqos.conf which contains the supported scenario
name and the number of supported scenarios. Each scenario has the 'support'
property indicating whether scenario is supported or not on platform.

If the 'support' property value is changed from 'yes' to 'no',
PASS shows the following error log during the init step.
[error log]
 edbus-handler.c: register_method(713) > fail to add method (null)!
 edbus-handler.c: register_edbus_method(862) > fail to register /Org/Tizen/System/Pass/Pmqos method(-22)
 pmqos.c: pmqos_init_done(395) > fail to init edbus method from conf(-22)

Change-Id: Icbb0d29c941345f21c3bcc4ae513ff73095a3aff
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
7 years agopmqos: Remove hard-coded scenario names 74/133474/1
Chanwoo Choi [Fri, 9 Jun 2017 08:49:53 +0000 (17:49 +0900)]
pmqos: Remove hard-coded scenario names

This patch removes the hard-coded scenario names and unused functions.
When you want to add or remove the scenarios, you have to modify
the /etc/pass/pass-pmqos.conf file without any changes of pmqos code.

Change-Id: Ia267b4de362746aa370b94ed53ad783ad7ff6954
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
7 years agopass: Remove unneeded log message 08/133208/1
Chanwoo Choi [Fri, 9 Jun 2017 07:32:44 +0000 (16:32 +0900)]
pass: Remove unneeded log message

This patch removes the unneeded and duplicate log messages
in order to simplify the log during init/exit of PASS.

Also, this patch shows the supported scenarios except for un-supported
scenarios.

Change-Id: I5053e9b5b323ed2eb3a83c4ec0418995cbecf9a7
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
7 years agopmqos: Staticize set_pmqos function 98/133198/1
Chanwoo Choi [Fri, 9 Jun 2017 06:58:46 +0000 (15:58 +0900)]
pmqos: Staticize set_pmqos function

The set_pmqos is accessed only in this file so it can be made as static.

Change-Id: I3e836c8a4d4c3a17621a21b6ad3cc57767397df0
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
7 years agopass: pmqos: Specify the resource name on log message 97/133197/1
Chanwoo Choi [Fri, 9 Jun 2017 06:50:04 +0000 (15:50 +0900)]
pass: pmqos: Specify the resource name on log message

This patch just adds the correct resource name to pmqos's log message
in order to improve the readability of pmqos's operation.

Example,
- Before: "cannot support 'AppLaunch' scenario (support=0)"
- After : "cannot support 'AppLaunch' scenario for 'cpu0' resource"

Change-Id: Ie337e73a5b310fc72428a7bfce1d5690f07a2863
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
7 years agocore: Modify device notifier registering/unregistering mechanism 83/129883/4
Wook Song [Thu, 18 May 2017 08:07:37 +0000 (17:07 +0900)]
core: Modify device notifier registering/unregistering mechanism

This patch modifies the registering and unregistering mechanism of
device_notifier to use a static array instead of dynamically allocated
memory. A bug in the unregister_notifier function is also fixed. Since
the prototype of the function is changed, all locations where this
function is called are also slightly modified.

Change-Id: Iac5afc5f5c283f277220ac49d173bf420e3fb4ee
Signed-off-by: Wook Song <wook16.song@samsung.com>
Reviewed-by: Chanwoo Choi <cw00.choi@samsung.com>
7 years agohal: Add new argument of resource name to close and open function 98/127098/2 accepted/tizen/unified/20170426.200227 submit/tizen/20170426.080126 tizen_4.0.m1_release
Chanwoo Choi [Wed, 26 Apr 2017 07:09:44 +0000 (16:09 +0900)]
hal: Add new argument of resource name to close and open function

The open and close functions in the struct pass_resource_info
are used to get/put the h/w resource. And the open and close
functions in the hal implementation save/restore the h/w
resource state. In this case, these functions need the unique
resource name in order to identify the h/w resource.

Change-Id: Icd7977619ed1f09186756a7cacf2c801c4284f1a
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
7 years agopass: hal: Add a function for putting resource 88/121688/3
Wook Song [Tue, 28 Mar 2017 08:08:36 +0000 (17:08 +0900)]
pass: hal: Add a function for putting resource

This patch adds the pass_put_resource function, which is paired up with
pass_get_resource(). When the main daemon is terminated, every hardware
resources resources (which are opened by pass_get_resource()) are closed
via HAL by this function.

Change-Id: I454d931979c5753ad070c44e58e9256429e6f7f7
Signed-off-by: Wook Song <wook16.song@samsung.com>
Reviewed-by: Chanwoo Choi <cw00.choi@samsung.com>
7 years agopackaging: Remove the ExclusiveArch keyword from pass.spec 25/125125/1 accepted/tizen/unified/20170414.042950 submit/tizen/20170414.022712
Chanwoo Choi [Fri, 14 Apr 2017 01:07:05 +0000 (10:07 +0900)]
packaging: Remove the ExclusiveArch keyword from pass.spec

The commit c2af7de627fef ("packaging: Remove unneeded script code")
used the 'ExclusiveArch' keyword for both armv7l and aarch64 architecture.
It is wrong patch because PASS is common daemon for all profiles and
architectures.

So, this patch remove the specific ExclusiveArch keyword
in order to remove the specific build dependency.

Change-Id: Ia3d33fe2ca2a2ad40d4ed729f42725ae89fe70a9
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
7 years agopass: Remove duplicate log when failed to read configuration file 69/124969/3
Chanwoo Choi [Thu, 13 Apr 2017 06:38:12 +0000 (15:38 +0900)]
pass: Remove duplicate log when failed to read configuration file

This patch just removes the duplicate log message. The same meaning logs
makes the confusion.

[Before]
config-parser.c: config_parse(66) > Failed to open file /etc/pass/pass.conf
config-parser.c: config_parse(126) > Failed to read /etc/pass/pass.conf:0!
pass-parser.c: pass_parse_resource(637) > cannot parse /etc/pass/pass.conf
pass.c: pass_init_done(226) > cannot parse /etc/pass/pass.conf
config-parser.c: config_parse(66) > Failed to open file /etc/pass/pass-pmqos.conf
config-parser.c: config_parse(126) > Failed to read /etc/pass/pass-pmqos.conf:0!
pmqos-parser.c: pmqos_get_scenario(156) > failed to load conficuration file(/etc/pass/pass-pmqos.conf) : -5
pmqos.c: pmqos_init_done(497) > failed to load configuration file(/etc/pass/pass-pmqos.conf)

[After]
pass.c: pass_init_done(226) > cannot parse /etc/pass/pass.conf
pmqos.c: pmqos_init_done(497) > failed to load configuration file(/etc/pass/pass-pmqos.conf)

Change-Id: I5b40c199811abf3db9b51d2801e523f8eedaf8a6
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
7 years agocore: Remove unused code related to run child process 66/124266/1 accepted/tizen/unified/20170412.153331 submit/tizen/20170412.073908
Chanwoo Choi [Tue, 11 Apr 2017 04:24:55 +0000 (13:24 +0900)]
core: Remove unused code related to run child process

This patch just removes the unused code related to run child process.

Change-Id: I563ec183733520a4dd391d5c7f5c02b386bf04b7
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
7 years agopackaging: Remove unneeded script code 07/121207/2 accepted/tizen_mobile accepted/tizen/mobile/20170328.053617 accepted/tizen/unified/20170328.053650 submit/tizen/20170328.004502
Chanwoo Choi [Mon, 27 Mar 2017 08:16:20 +0000 (17:16 +0900)]
packaging: Remove unneeded script code

This patch removes the unneeded script code in the pass.spec file
and add the 'ExclusiveArch' defintion to build the pass only for
both {arm} and aarch64 architecture.

Change-Id: Id3cbb54b2fd4e18d9e909dbf54165ecbf2a7403d
Suggested-by: Seung-Woo Kim <sw0312.kim@samsung.com>
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
7 years agoshared: systemd: Fix use-after-free and double-free defects 74/120074/5
Wook Song [Tue, 21 Mar 2017 06:51:12 +0000 (15:51 +0900)]
shared: systemd: Fix use-after-free and double-free defects

This patch fixes the following code-leve defects according to static
program analysis result:

1. USE_AFTER_FREE: A pointer variable is used after the referenced
memory was deallocated by calling function 'free'.
2. DOUBLE_FREE.EX: A pointer is passed to the function 'free' after the
referenced memory was deallocated.

Change-Id: Ieef15d3432fb72068b9186c5807fedd1685ee79a
Signed-off-by: Wook Song <wook16.song@samsung.com>
Reviewed-by: Chanwoo Choi <cw00.choi@samsung.com>
7 years agocore: common: Fix defects including integer overflow case 89/119489/5
Wook Song [Fri, 17 Mar 2017 05:31:52 +0000 (14:31 +0900)]
core: common: Fix defects including integer overflow case

This patch fixes the following code-level defects according to static
program analysis result:

1. NONTERMINATED_STRING: Copying from string to a buffer without null
termination by calling function 'strncpy'.
2. INTEGER_OVERFLOW: Possible integer overflow.

Change-Id: Iee3ed333393fa44cd0c2f4c38431fc833898b30c
Signed-off-by: Wook Song <wook16.song@samsung.com>
Reviewed-by: Chanwoo Choi <cw00.choi@samsung.com>
7 years agopass: hal: Fix defects including the case that the handle could be lost 88/119488/4
Wook Song [Fri, 17 Mar 2017 01:53:50 +0000 (10:53 +0900)]
pass: hal: Fix defects including the case that the handle could be lost

This patch fixes the following code-level defects according to static
program analysis result:

1. NULL_AFTER_DEREF: A pointer which was dereferenced is compared to
NULL value.
2. HANDLE_LEAK: A handle was created by calling function 'fopen' and
lost at some point.
3. NO_EFFECT: the entire array is compared to 0.
4. NO_CAST.INTEGER_OVERFLOW: Values of an arithmetic expression could be
subject to overflow due to a failure to cast operands to a larger data
type before perfoming arithmetic overflow before widen.

Change-Id: Icd25de37efc3b52aacece3476e697486a1934c3a
Signed-off-by: Wook Song <wook16.song@samsung.com>
Reviewed-by: Chanwoo Choi <cw00.choi@samsung.com>
7 years agopmqos: Fix strcpy use and memory leak defects 87/119487/4
Wook Song [Thu, 16 Mar 2017 09:25:06 +0000 (18:25 +0900)]
pmqos: Fix strcpy use and memory leak defects

This patch fixes the following code-level defects according to static
program analysis result:

1. PROC_USE.VULNERABLE: Use of vulnerable function 'strcpy'. For better
security, using strncpy is recommended instead of strcpy.
2. MEMORY_LEAK.EX: Dynamic memory was allocated by calling function
'calloc' and lost at some point.

Change-Id: Ie58bb7073254935b24257f8c9db19dd04c8b25f8
Signed-off-by: Wook Song <wook16.song@samsung.com>
Reviewed-by: Chanwoo Choi <cw00.choi@samsung.com>
7 years agopass: parser: Fix various defects including nonterminated string cases 66/119266/5
Wook Song [Thu, 16 Mar 2017 06:56:10 +0000 (15:56 +0900)]
pass: parser: Fix various defects including nonterminated string cases

This patch fixes the following code-level defects according to static
program analysis result:

1. PROC_USE.VULNERABLE: Use of vulnerable function 'strcpy'. For better
security, using strncpy is recommended instead of strcpy.
2. UNREACHABLE_CODE: The statement in the source code might be
unreachable during program execution.
3. DEREF_AFTER_NULL.EX: After having been compared to NULL value, some
pointers are dereferenced.
4. NONTERMINATED_STRING: Copying from string to a buffer without null
termination by calling function 'strncpy'.
5. TAINTED_INT.LOOP.MIGHT: Integer value obtained from untrusted source
without checking its higher bound is used as a loop bound.
6. TAINTED_INT/TAINTED_INT.MIGHT: Integer value obtained from untrusted
source without checking its higher bound is used in a trusted operation
by calling function 'calloc'.

Change-Id: Ic24ac658af88c109a22664c7c03eb2c43e8e23c4
Signed-off-by: Wook Song <wook16.song@samsung.com>
Reviewed-by: Chanwoo Choi <cw00.choi@samsung.com>
7 years agopmqos: parser: Fix defects such as tainted integer and use of strcpy 53/118953/5
Wook Song [Wed, 15 Mar 2017 02:00:17 +0000 (11:00 +0900)]
pmqos: parser: Fix defects such as tainted integer and use of strcpy

This patch fixes the following code-level defects according to static
program analysis result:

1. PROC_USE.VULNERABLE: Use of vulnerable function 'strcpy'. For better
security, using strncpy is recommended.
2. TAINTED_INT: Integer value obtained from untrusted source without checking
its higher bound is used in a trusted operation by calling function 'calloc'.

Change-Id: I423c8dcc6cb720673f2c754a39204e140fdb9e79
Signed-off-by: Wook Song <wook16.song@samsung.com>
Reviewed-by: Chanwoo Choi <cw00.choi@samsung.com>
7 years agopass: Remove dead-code related to the number of cpu 98/118398/1
Chanwoo Choi [Fri, 10 Mar 2017 07:33:17 +0000 (16:33 +0900)]
pass: Remove dead-code related to the number of cpu

This patch just removes the dead code which is related to the number of CPU
in the same cluster. The pass uses the 'num_cpus' variable of the 'struct
pass_hotplug'.

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