From 3ad5462176ca02a32518148af5bf30fb44a7d203 Mon Sep 17 00:00:00 2001 From: Chanwoo Choi Date: Tue, 11 Feb 2020 16:49:47 +0900 Subject: [PATCH 01/16] pass: parser: Rename parser API for the readability Rename all parser API from "pass_*()" to "pass_parser_*()" to improve the readability. Change-Id: Iade47afa9463093698612bb2d81004ae918695f9 Signed-off-by: Chanwoo Choi --- src/pass/pass-parser.c | 8 ++++---- src/pass/pass-parser.h | 8 ++++---- src/pass/pass.c | 8 ++++---- unittest/pass_haltests.cpp | 4 ++-- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/pass/pass-parser.c b/src/pass/pass-parser.c index 26292a6..acaca3c 100644 --- a/src/pass/pass-parser.c +++ b/src/pass/pass-parser.c @@ -961,7 +961,7 @@ static int parse_resource(struct parse_result *result, void *user_data) * @param [in] path Path of configuration files (/etc/pass/pass.conf) * @return @c 0 on success, otherwise error value */ -int pass_get_resource_config(struct pass *pass, char *path) +int pass_parser_get_resource_config(struct pass *pass, char *path) { return config_parse(path, parse_resource, pass); } @@ -971,7 +971,7 @@ int pass_get_resource_config(struct pass *pass, char *path) * @param [in] pass Instance of 'struct pass' contains all information * @return N/A */ -void pass_put_resource_config(struct pass *pass) +void pass_parser_put_resource_config(struct pass *pass) { free(pass->res); pass->res = NULL; @@ -984,7 +984,7 @@ void pass_put_resource_config(struct pass *pass) * @param [in] path Path of configuration file for each h/w resource * @return @c 0 on success, otherwise error value */ -int pass_get_each_resource_config(struct pass_resource *res, char *path) +int pass_parser_get_each_resource_config(struct pass_resource *res, char *path) { struct pass_cpuhp *cpuhp; struct pass_pmqos *pmqos; @@ -1068,7 +1068,7 @@ int pass_get_each_resource_config(struct pass_resource *res, char *path) * @param [in] res Instance of h/w resource * @return N/A */ -void pass_put_each_resource_config(struct pass_resource *res) +void pass_parser_put_each_resource_config(struct pass_resource *res) { if (!res) { _E("cannot put pass table\n"); diff --git a/src/pass/pass-parser.h b/src/pass/pass-parser.h index bd554b5..538c6d7 100644 --- a/src/pass/pass-parser.h +++ b/src/pass/pass-parser.h @@ -38,10 +38,10 @@ #include "pass.h" -int pass_get_resource_config(struct pass *pass, char *path); -void pass_put_resource_config(struct pass *pass); +int pass_parser_get_resource_config(struct pass *pass, char *path); +void pass_parser_put_resource_config(struct pass *pass); -int pass_get_each_resource_config(struct pass_resource *res, char *path); -void pass_put_each_resource_config(struct pass_resource *res); +int pass_parser_get_each_resource_config(struct pass_resource *res, char *path); +void pass_parser_put_each_resource_config(struct pass_resource *res); #endif /* __PASS_PARSER__ */ diff --git a/src/pass/pass.c b/src/pass/pass.c index 9038f25..764df84 100644 --- a/src/pass/pass.c +++ b/src/pass/pass.c @@ -205,7 +205,7 @@ static int pass_init_resource(struct pass_resource *res) int i; /* Get configuration of each resource from pass-resource*.conf */ - ret = pass_get_each_resource_config(res, res->config_data.path_conf_file); + ret = pass_parser_get_each_resource_config(res, res->config_data.path_conf_file); if (ret < 0) { _E("cannot parse %s\n", res->config_data.path_conf_file); return -1; @@ -300,7 +300,7 @@ static int pass_exit_resource(struct pass_resource *res) int ret; /* Put configuration of each resource from pass-resource*.conf */ - pass_put_each_resource_config(res); + pass_parser_put_each_resource_config(res); if (is_supported_module(res, PASS_MODULE_CPUHP)) { ret = pass_cpuhp_exit(res); @@ -361,7 +361,7 @@ static int pass_init_done(void *data, void *user_data) int i, ret; /* Get configuration of resource list from pass.conf */ - ret = pass_get_resource_config(&g_pass, PASS_CONF_PATH); + ret = pass_parser_get_resource_config(&g_pass, PASS_CONF_PATH); if (ret < 0) { _E("cannot parse %s\n", PASS_CONF_PATH); return ret; @@ -449,7 +449,7 @@ static void pass_exit_done(void) } /* Put configuration of resource list from pass.conf */ - pass_put_resource_config(&g_pass); + pass_parser_put_resource_config(&g_pass); g_pass.state = PASS_OFF; } diff --git a/unittest/pass_haltests.cpp b/unittest/pass_haltests.cpp index 4fbde96..de98ee0 100644 --- a/unittest/pass_haltests.cpp +++ b/unittest/pass_haltests.cpp @@ -63,7 +63,7 @@ TEST_F(PowerMgntHalTest, GetResourceConfig_HandlesValidInput) ret = system("/bin/systemctl stop pass.service"); ASSERT_EQ(ret, 0) << "PassServiceStop Failed"; - ret = pass_get_resource_config(&g_pass, path); + ret = pass_parser_get_resource_config(&g_pass, path); ASSERT_EQ(ret, 0) << "GetResourceConfig Failed"; for (i = 0; i < g_pass.num_resources; i++) { @@ -491,7 +491,7 @@ TEST_F(PowerMgntHalTest, PutResourceConfig_HandlesValidInput) ret = pass_hal_put_resource(res); if (ret < 0) { - pass_put_resource_config(&g_pass); + pass_parser_put_resource_config(&g_pass); ASSERT_EQ(ret, 0) << "PutResourceConfig Failed"; } } -- 2.7.4 From 87b2ae337e65f3bba41a25a2ac090fc95a98c515 Mon Sep 17 00:00:00 2001 From: Chanwoo Choi Date: Mon, 24 Feb 2020 20:05:21 +0900 Subject: [PATCH 02/16] pass: parser: Clean-up code to remove warning from static code analyzer Change-Id: I627fc5e55497a34b318273bbb06af2664cdc2b03 Signed-off-by: Chanwoo Choi --- src/pass/pass-parser.c | 10 ++++------ src/pass/pass.h | 2 +- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/pass/pass-parser.c b/src/pass/pass-parser.c index acaca3c..38c6392 100644 --- a/src/pass/pass-parser.c +++ b/src/pass/pass-parser.c @@ -532,13 +532,11 @@ static int parse_core(struct parse_result *result, void *user_data) return gov_type; res->config_data.gov_type = gov_type; } else if (MATCH(result->name, "pass_num_levels")) { - unsigned int num_levels; - - ret = sys_strtol(result->value); - if (ret < 0) - return ret; - num_levels = ret; + int num_levels; + num_levels = sys_strtol(result->value); + if (num_levels < 0) + return num_levels; if (num_levels > MAX_NUM) { _E("cannot parse %s\n", result->name); return -EINVAL; diff --git a/src/pass/pass.h b/src/pass/pass.h index 89a5494..2bf4a93 100644 --- a/src/pass/pass.h +++ b/src/pass/pass.h @@ -474,7 +474,7 @@ struct pass_resource_config_data { unsigned int default_max_level; /** The number of pass_levels */ - unsigned int num_levels; + int num_levels; /** List of pass_levels */ struct pass_level *levels; -- 2.7.4 From 285156de48918aebbd9d574d99eb4439ae9e0017 Mon Sep 17 00:00:00 2001 From: Chanwoo Choi Date: Tue, 4 Aug 2020 11:05:41 +0900 Subject: [PATCH 03/16] scripts: dbus: Allow root to use d-bus interface Allow 'root' to use d-bus interface provided by PASS. The 'root' have to control all d-bus interface without any restrictions. Change-Id: I18d467f2745741c7c4b990b64210dfd16692d39c Signed-off-by: Chanwoo Choi --- scripts/pass.conf | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/scripts/pass.conf b/scripts/pass.conf index 40c543e..b96f2af 100644 --- a/scripts/pass.conf +++ b/scripts/pass.conf @@ -1,6 +1,12 @@ + + + + -- 2.7.4 From 37ac960a5cbff46eb5536dfb6bc9c26c9584f58a Mon Sep 17 00:00:00 2001 From: Chanwoo Choi Date: Fri, 7 Aug 2020 15:03:47 +0900 Subject: [PATCH 04/16] pmqos: Fix wrong unlocked issue when pmqos list contains only one scenario The pmqos list contains only one scenario like UltraPowerSaving and when receiving the unmated scenario name like AppLaunch with unlock info with that duration is zero, the last scenario will be unlocked. In order to fix this issuse, correct the conditional statement. Change-Id: Ica2a3a3f44d02dfd07e3cb57e1dab300decee9d0 Signed-off-by: Chanwoo Choi --- src/pmqos/pmqos.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/pmqos/pmqos.c b/src/pmqos/pmqos.c index de1f2a6..e14e882 100644 --- a/src/pmqos/pmqos.c +++ b/src/pmqos/pmqos.c @@ -332,11 +332,10 @@ static void pmqos_unlock_timeout_update(void) */ static int pmqos_cancel(const char *name) { - GList *elem; + GList *elem = NULL; struct pmqos_cpu *cpu; /* Find previous request */ - cpu = NULL; for (elem = pmqos_head; elem != NULL; elem = elem->next) { cpu = elem->data; if (!strcmp(cpu->name, name)) @@ -344,7 +343,7 @@ static int pmqos_cancel(const char *name) } /* no cpu */ - if (!cpu) + if (!elem) return 0; /* unlock cpu */ -- 2.7.4 From d34dc7968dedf5440decd21032cdb759cd0cb1c3 Mon Sep 17 00:00:00 2001 From: Chanwoo Choi Date: Fri, 7 Aug 2020 15:22:56 +0900 Subject: [PATCH 05/16] pmqos: Fix issue when the part of scenario name is same with supported scenario If the part of scenario name sent from client is same with among the supported scenario name, strncmp() causes the issue. In order to fix this issue, compare the full scenario name with strcmp(): Change-Id: Ibc712b0b4be2cb752506ac7094b27abd88e587b5 Reported-by: Seung-Woo Kim Signed-off-by: Chanwoo Choi --- src/pmqos/pmqos.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/pmqos/pmqos.c b/src/pmqos/pmqos.c index e14e882..2ed67f7 100644 --- a/src/pmqos/pmqos.c +++ b/src/pmqos/pmqos.c @@ -175,8 +175,7 @@ static gboolean dbus_cb_pmqos_legacy_scenario(SystemPassPmqos *obj, for (i = 0; i < g_pmqos->num; i++) { name = g_pmqos->list[i].name; support = g_pmqos->list[i].support; - if (!strncmp(name, name_from, strlen(name)) && - support) { + if (!strcmp(name, name_from) && support) { ret = 0; break; } @@ -352,7 +351,7 @@ static int pmqos_cancel(const char *name) pmqos_head = g_list_remove(pmqos_head, (gconstpointer)cpu); free(cpu); - if (strncmp(unlock_timer_owner.name, name, strlen(name))) + if (strcmp(unlock_timer_owner.name, name)) goto out; /* undata cpu */ pmqos_unlock_timeout_update(); -- 2.7.4 From dd8f02c59678ef2b72c496847248905df13b0014 Mon Sep 17 00:00:00 2001 From: Chanwoo Choi Date: Thu, 6 Aug 2020 17:40:28 +0900 Subject: [PATCH 06/16] pmqos: Set max_duration_ms for each scenario Until now, only support global max_duration_ms time. But, if each scenario need to set the different maximum duration time, it is not supported. Allow each scenario to set the default maximume duration time. Change-Id: I6f294ab55d2157c251593c300cb04eefb598b751 Signed-off-by: Chanwoo Choi --- scripts/pass-pmqos.conf | 5 ++-- src/pmqos/pmqos-parser.c | 26 ++++++++++++--------- src/pmqos/pmqos.c | 59 ++++++++++++++++++------------------------------ src/pmqos/pmqos.h | 3 +-- 4 files changed, 41 insertions(+), 52 deletions(-) diff --git a/scripts/pass-pmqos.conf b/scripts/pass-pmqos.conf index a47733c..53c7377 100644 --- a/scripts/pass-pmqos.conf +++ b/scripts/pass-pmqos.conf @@ -1,19 +1,20 @@ [PassScenario] # set to "yes" scenario_support (Default value is no) # set scenario_num to be tested -# set scenario_max_timeout_ms (unit:millisecond, default timeout is 3000ms) scenario_support=yes scenario_num=2 -scenario_max_timeout_ms=3000 # describe the scenario section as follows #[Scenario0] #name=AppLaunch # (dbus method name) +#max_duration_ms=3000 # (unit:millisecond, max dururation is 3000ms) #support=yes [Scenario0] name=AppLaunch +max_duration_ms=3000 support=yes [Scenario1] name=UltraPowerSaving +max_duration_ms=3000 support=yes diff --git a/src/pmqos/pmqos-parser.c b/src/pmqos/pmqos-parser.c index 5b32bae..3e8ee97 100644 --- a/src/pmqos/pmqos-parser.c +++ b/src/pmqos/pmqos-parser.c @@ -90,15 +90,6 @@ static int pmqos_parse_scenario(struct parse_result *result, void *user_data, un scenarios->num = num; } - } else if (MATCH(result->name, "scenario_max_timeout_ms")) { - int max_timeout_ms; - - max_timeout_ms = sys_strtol(result->value); - if (max_timeout_ms < 0) { - _E("failed to get maximum timeout of scenario"); - return -ERANGE; - } - scenarios->max_timeout_ms = max_timeout_ms; } } @@ -120,6 +111,21 @@ static int pmqos_parse_scenario(struct parse_result *result, void *user_data, un "%s", result->value); else if (MATCH(result->name, "support")) scenarios->list[index].support = is_supported(result->value); + else if (MATCH(result->name, "max_duration_ms")) { + int max_duration_ms = sys_strtol(result->value); + + if (max_duration_ms < 0) { + _E("failed to parse max_duration_ms property (%d)\n", + max_duration_ms); + return -EINVAL; + } + + /* + * If maximum duration is zero, it measn that this scenario is + * mode without any maximum duration. + */ + scenarios->list[index].max_duration_ms = max_duration_ms; + } return 0; } @@ -186,7 +192,6 @@ int pmqos_put_scenario(struct pmqos_scenario *scenarios) if (scenarios->num > 0 && scenarios->list) { scenarios->num = 0; - scenarios->max_timeout_ms = 0; free(scenarios->list); scenarios->list = NULL; } @@ -207,7 +212,6 @@ int pmqos_get_scenario(const char *path, struct pmqos_scenario *scenarios) /* Initialize the variables before parsing the pass-pmqos.conf */ scenarios->num = 0; - scenarios->max_timeout_ms = 0; /* get configuration file */ ret = config_parse(path, pmqos_load_config, scenarios); diff --git a/src/pmqos/pmqos.c b/src/pmqos/pmqos.c index 2ed67f7..3deae6e 100644 --- a/src/pmqos/pmqos.c +++ b/src/pmqos/pmqos.c @@ -39,8 +39,6 @@ #include "pmqos.h" -#define DEFAULT_PMQOS_TIMER 3000 - #define PMQOS_CONF_PATH "/etc/pass/pass-pmqos.conf" #define MILLISECONDS(tv) ((tv.tv_sec)*1000 + (tv.tv_nsec)/1000000) #define DELTA(a, b) (MILLISECONDS(a) - MILLISECONDS(b)) @@ -64,7 +62,6 @@ struct pmqos_cpu { static GList *pmqos_head; guint g_unlock_timeout_id; -static int unlock_max_timeout_ms; static struct timespec unlock_timer_start_st; static struct timespec unlock_timer_end_st; static struct pmqos_cpu unlock_timer_owner = {"", 0}; @@ -161,6 +158,7 @@ static gboolean dbus_cb_pmqos_legacy_scenario(SystemPassPmqos *obj, const char *name_from; char *name; bool support; + int max_duration_ms; int i, ret = 0; gboolean ret_out = TRUE; @@ -168,26 +166,30 @@ static gboolean dbus_cb_pmqos_legacy_scenario(SystemPassPmqos *obj, _E("PASS PMQoS is stopped\n"); ret_out = FALSE; goto out; - } else { - name_from = g_dbus_method_invocation_get_method_name(invoc); - ret = -ENOTSUP; - if (g_pmqos) { - for (i = 0; i < g_pmqos->num; i++) { - name = g_pmqos->list[i].name; - support = g_pmqos->list[i].support; - if (!strcmp(name, name_from) && support) { - ret = 0; - break; - } + } + + name_from = g_dbus_method_invocation_get_method_name(invoc); + ret = -ENOTSUP; + if (g_pmqos) { + for (i = 0; i < g_pmqos->num; i++) { + name = g_pmqos->list[i].name; + support = g_pmqos->list[i].support; + max_duration_ms = g_pmqos->list[i].max_duration_ms; + + if (!strcmp(name, name_from) && support) { + ret = 0; + if (duration > max_duration_ms) + duration = max_duration_ms; + break; } } + } - if (ret < 0) { - _E("cannot set the PMQoS scenario: " - "%s is not supported\n", name_from); - ret_out = FALSE; - goto out_dbus; - } + if (ret < 0) { + _E("cannot set the PMQoS scenario: " + "%s is not supported\n", name_from); + ret_out = FALSE; + goto out_dbus; } if (duration) @@ -413,13 +415,6 @@ static int pmqos_request(const char *name, int val) int found = 0; int ret; - /* Check valid parameter */ - if (val > unlock_max_timeout_ms) { - _I("Timeout cannot be higher than maximum timeout (%d ms)", - unlock_max_timeout_ms); - val = unlock_max_timeout_ms; - } - /* find cpu */ for (elem = pmqos_head; elem != NULL; elem = elem->next) { cpu = elem->data; @@ -497,16 +492,6 @@ static int pmqos_init_done(void *data, void *user_data) g_pmqos->list[i].name); } - /* - * Set maximum timeout for the scenario by using the parsed data from - * pass-pmqos.conf. But, if there is no setting from pass-pmqos.conf - * pmqos uses the default timeout value (3000 millisecond). - */ - if (g_pmqos->max_timeout_ms) - unlock_max_timeout_ms = g_pmqos->max_timeout_ms; - else - unlock_max_timeout_ms = DEFAULT_PMQOS_TIMER; - return 0; } diff --git a/src/pmqos/pmqos.h b/src/pmqos/pmqos.h index 4058d4c..ffacd10 100644 --- a/src/pmqos/pmqos.h +++ b/src/pmqos/pmqos.h @@ -41,12 +41,11 @@ struct pmqos_scenario { struct scenario { char name[NAME_MAX]; /** Unique scenario name */ bool support; /** State is either supported or not */ + int max_duration_ms; /** Maximum duration */ } *list; /** The number of supported PMQoS scenarios */ int num; - /** Maximum duration */ - int max_timeout_ms; /** State of PMQoS feature is either supported or not*/ bool support; }; -- 2.7.4 From a6bf74920a269f150e4cb139e1f01b76171abc62 Mon Sep 17 00:00:00 2001 From: Chanwoo Choi Date: Thu, 6 Aug 2020 18:14:27 +0900 Subject: [PATCH 07/16] pass: Adjust indentation to show current resource statues for readability Adjust indentation to show current resource statues and remove unneeded blank line for readability. And remove unneeded comment and blank line. Change-Id: Ibb2e660374626b942a2dd14c3bdb59caa5725162 Signed-off-by: Chanwoo Choi --- src/pass/pass-rescon.c | 11 ++++------- src/pmqos/pmqos.c | 11 +++-------- 2 files changed, 7 insertions(+), 15 deletions(-) diff --git a/src/pass/pass-rescon.c b/src/pass/pass-rescon.c index 4908916..be4e06d 100644 --- a/src/pass/pass-rescon.c +++ b/src/pass/pass-rescon.c @@ -44,29 +44,26 @@ static void rescon_print_level(struct pass_resource *res, if (!res || !level) return; - /* Add blank line for improving the readability on dlog */ - _D(""); - if (level->limit_min_freq > 0) { - _D("MIN Frequency is %10d of '%s' resource \n", + _D("MIN Frequency is %10d of '%s' resource \n", level->limit_min_freq, res->config_data.res_name); } if (level->limit_max_freq > 0) { - _D("MAX Frequency is %10d of '%s' resource\n", + _D("MAX Frequency is %10d of '%s' resource\n", level->limit_max_freq, res->config_data.res_name); } if (level->limit_min_cpu >= 0) { - _D("MIN CPU number is %10d of '%s' resource\n", + _D("MIN CPU number is %10d of '%s' resource\n", level->limit_min_cpu, res->config_data.res_name); } if (level->limit_max_cpu >= 0) { - _D("MAX CPU number is %10d of '%s' resource\n", + _D("MAX CPU number is %10d of '%s' resource\n", level->limit_max_cpu, res->config_data.res_name); } diff --git a/src/pmqos/pmqos.c b/src/pmqos/pmqos.c index 3deae6e..27a3e5f 100644 --- a/src/pmqos/pmqos.c +++ b/src/pmqos/pmqos.c @@ -343,19 +343,17 @@ static int pmqos_cancel(const char *name) break; } - /* no cpu */ if (!elem) return 0; - /* unlock cpu */ set_pmqos(cpu->name, false); - /* delete cpu */ + pmqos_head = g_list_remove(pmqos_head, (gconstpointer)cpu); free(cpu); if (strcmp(unlock_timer_owner.name, name)) goto out; - /* undata cpu */ + pmqos_unlock_timeout_update(); pmqos_unlock_timer_start(); out: @@ -415,7 +413,6 @@ static int pmqos_request(const char *name, int val) int found = 0; int ret; - /* find cpu */ for (elem = pmqos_head; elem != NULL; elem = elem->next) { cpu = elem->data; if (!strcmp(cpu->name, name)) { @@ -425,7 +422,6 @@ static int pmqos_request(const char *name, int val) } } - /* add cpu */ if (!found) { cpu = calloc(1, sizeof(struct pmqos_cpu)); if (!cpu) @@ -435,14 +431,13 @@ static int pmqos_request(const char *name, int val) cpu->timeout = val; pmqos_head = g_list_append(pmqos_head, (gpointer)cpu); } - /* sort cpu */ + pmqos_head = g_list_sort(pmqos_head, compare_timeout); ret = pmqos_unlock_timer_start(); if (ret < 0) goto err; - /* Set cpu lock */ set_pmqos(cpu->name, true); return 0; err: -- 2.7.4 From 6c5032e3886c05880ec169eef0707fa507892865 Mon Sep 17 00:00:00 2001 From: Chanwoo Choi Date: Thu, 6 Aug 2020 18:57:01 +0900 Subject: [PATCH 08/16] pmqos: Add new SetScenario method for pmqos dbus interface When add new scenario to pmqos, it have to edit the code. It is not extensible. In order to improve the extensiblity without code changes, add new SetScenario method for pmqos dbus interface as following: When need to add new scenario, just add new scenario info. to scripts/pass-pmqos.conf (/etc/pass/pass-pmqos.conf) without any code changes. [Interface for new SetScenario method of pmqos dbus] - dbus interface : org.tizen.system.pass.pmqos.SetScenario - parameter 1: scenario name like AppLaunch - parameter 2: duration time like 3000 means 3 second Change-Id: I5ee8da4ec62a9cf1d55ea51f6c7fb8ca9ce7b9e7 Signed-off-by: Chanwoo Choi --- include/pass/gdbus-definition.h | 1 + scripts/pmqos-dbus.xml | 5 +++ src/pmqos/pmqos.c | 72 +++++++++++++++++++++++++++-------------- 3 files changed, 54 insertions(+), 24 deletions(-) diff --git a/include/pass/gdbus-definition.h b/include/pass/gdbus-definition.h index fbf4afd..5072341 100644 --- a/include/pass/gdbus-definition.h +++ b/include/pass/gdbus-definition.h @@ -40,6 +40,7 @@ typedef enum { #define DBUS_PMQOS_I_STOP_HANDLER "handle_stop" #define DBUS_PMQOS_I_APPLAUNCH_HANDLER "handle_app_launch" #define DBUS_PMQOS_I_ULTRAPOWERSAVING_HANDLER "handle_ultra_power_saving" +#define DBUS_PMQOS_I_SET_SCENARIO_HANDLER "handle_set_scenario" #define DBUS_THERMAL_BUS_NAME "org.tizen.system.thermal" #define DBUS_THERMAL_INTERFACE "org.tizen.system.thermal" diff --git a/scripts/pmqos-dbus.xml b/scripts/pmqos-dbus.xml index f373ddd..271d775 100644 --- a/scripts/pmqos-dbus.xml +++ b/scripts/pmqos-dbus.xml @@ -7,6 +7,11 @@ + + + + + diff --git a/src/pmqos/pmqos.c b/src/pmqos/pmqos.c index 27a3e5f..7c95054 100644 --- a/src/pmqos/pmqos.c +++ b/src/pmqos/pmqos.c @@ -146,20 +146,18 @@ static gboolean dbus_cb_pmqos_stop(SystemPassPmqos *obj, * UltraPowerSaving through D-bus interface. * @param [in] obj Instance of SystemPassPmqos * @param [in] invoc Instance of GDBusMethodInvocation + * @param [in] name Specific scenario name or mode name * @param [in] duration Duration to keep scenario during demanded time * @param [in] user_data Unused parameter * @return @c true if success, otherwise @c false if fail */ -static gboolean dbus_cb_pmqos_legacy_scenario(SystemPassPmqos *obj, +static gboolean dbus_cb_pmqos_set_scenario(SystemPassPmqos *obj, GDBusMethodInvocation *invoc, + const char *name, int duration, gpointer user_data) { - const char *name_from; - char *name; - bool support; - int max_duration_ms; - int i, ret = 0; + int i, ret = -ENOTSUP; gboolean ret_out = TRUE; if (!g_pmqos) { @@ -168,43 +166,64 @@ static gboolean dbus_cb_pmqos_legacy_scenario(SystemPassPmqos *obj, goto out; } - name_from = g_dbus_method_invocation_get_method_name(invoc); - ret = -ENOTSUP; - if (g_pmqos) { - for (i = 0; i < g_pmqos->num; i++) { - name = g_pmqos->list[i].name; - support = g_pmqos->list[i].support; - max_duration_ms = g_pmqos->list[i].max_duration_ms; - - if (!strcmp(name, name_from) && support) { - ret = 0; - if (duration > max_duration_ms) - duration = max_duration_ms; - break; - } + for (i = 0; i < g_pmqos->num; i++) { + char *supported_name = g_pmqos->list[i].name; + bool support = g_pmqos->list[i].support; + + if (!strcmp(supported_name, name) && support) { + int max_duration_ms = g_pmqos->list[i].max_duration_ms; + + if (duration > max_duration_ms) + duration = max_duration_ms; + ret = 0; + break; } } if (ret < 0) { _E("cannot set the PMQoS scenario: " - "%s is not supported\n", name_from); + "%s is not supported\n", name); ret_out = FALSE; goto out_dbus; } if (duration) - ret = pmqos_request(name_from, duration); + ret = pmqos_request(name, duration); else - ret = pmqos_cancel(name_from); + ret = pmqos_cancel(name); out_dbus: g_dbus_method_invocation_return_value(invoc, g_variant_new("(i)", ret)); - out: return ret_out; } /** + * @brief Callback function when receive the scenario like AppLaunch, + * UltraPowerSaving through D-bus interface. + * @param [in] obj Instance of SystemPassPmqos + * @param [in] invoc Instance of GDBusMethodInvocation + * @param [in] duration Duration to keep scenario during demanded time + * @param [in] user_data Unused parameter + * @return @c true if success, otherwise @c false if fail + */ +static gboolean dbus_cb_pmqos_legacy_scenario(SystemPassPmqos *obj, + GDBusMethodInvocation *invoc, + int duration, + gpointer user_data) +{ + const char *name; + + if (!g_pmqos) { + _E("PASS PMQoS is stopped\n"); + return FALSE; + } + + name = g_dbus_method_invocation_get_method_name(invoc); + return dbus_cb_pmqos_set_scenario(obj, invoc, name, duration, user_data); +} + +/** * @brief Define the supported D-bus signal information for PMQoS * feature. It contains the signal name and callback function * pointer which is executed when receives the defined signal. @@ -221,6 +240,11 @@ static struct pass_gdbus_signal_info g_gdbus_signal_infos[] = { .cb_data = NULL, .ret_id = 0, }, { + .handler = DBUS_PMQOS_I_SET_SCENARIO_HANDLER, + .cb = G_CALLBACK(dbus_cb_pmqos_set_scenario), + .cb_data = NULL, + .ret_id = 0, + }, { .handler = DBUS_PMQOS_I_START_HANDLER, .cb = G_CALLBACK(dbus_cb_pmqos_start), .cb_data = NULL, -- 2.7.4 From efe509f9f0246a5776702e0add578c0eebf49d0a Mon Sep 17 00:00:00 2001 From: Chanwoo Choi Date: Fri, 7 Aug 2020 11:16:25 +0900 Subject: [PATCH 09/16] pmqos: Add support of 'mode' like UltraPowerSaving Priot to that support only 'scenario' with the maximum duration time in order to prevent the misuse of scenario from client. Additionally, 'mode' is required to change the system status until receiving the unlock request without any maximum duration time. So, make 'max_duration_ms' property optional. If some scenario in /etc/pass/pass-pmqos.conf' don't have the 'max_duration_ms' property it considers the 'mode'. Difference of both scenario and mode as following: 1. 'scenario' with the maximum duration time like AppLaunch - Lock case a. Client send dbus signal with both 'scenario' name and duration - Unlock case a. Client send dbus signal with both 'scenario' name and 0 a. When timer with specific duration from client is expired, unlock scenario automatically. a. When timer with maximum duration is expired, unlock scenario automatically. 2. 'mode' without any duration time like UltraPowerSaving - Lock case a. Client send dbus signal with both 'mode' name and 1 - Unlock case a. Client send dbus signal with both 'mode' name and 0 Change-Id: I02cac0820b3085f7046689aecf8dc679f5f381c4 Signed-off-by: Chanwoo Choi --- scripts/pass-pmqos.conf | 9 +++++---- src/pmqos/pmqos.c | 40 ++++++++++++++++++++++++++++++++++------ 2 files changed, 39 insertions(+), 10 deletions(-) diff --git a/scripts/pass-pmqos.conf b/scripts/pass-pmqos.conf index 53c7377..be9a4ef 100644 --- a/scripts/pass-pmqos.conf +++ b/scripts/pass-pmqos.conf @@ -6,9 +6,11 @@ scenario_num=2 # describe the scenario section as follows #[Scenario0] -#name=AppLaunch # (dbus method name) -#max_duration_ms=3000 # (unit:millisecond, max dururation is 3000ms) -#support=yes +#[Mandatory properties] +# name=AppLaunch # (dbus method name) +# support=yes +#[Optional properties] +# max_duration_ms=3000 # (unit:millisecond, max dururation is 3000ms) [Scenario0] name=AppLaunch max_duration_ms=3000 @@ -16,5 +18,4 @@ support=yes [Scenario1] name=UltraPowerSaving -max_duration_ms=3000 support=yes diff --git a/src/pmqos/pmqos.c b/src/pmqos/pmqos.c index 7c95054..7ea160f 100644 --- a/src/pmqos/pmqos.c +++ b/src/pmqos/pmqos.c @@ -158,6 +158,7 @@ static gboolean dbus_cb_pmqos_set_scenario(SystemPassPmqos *obj, gpointer user_data) { int i, ret = -ENOTSUP; + int max_duration_ms = -1; gboolean ret_out = TRUE; if (!g_pmqos) { @@ -171,10 +172,7 @@ static gboolean dbus_cb_pmqos_set_scenario(SystemPassPmqos *obj, bool support = g_pmqos->list[i].support; if (!strcmp(supported_name, name) && support) { - int max_duration_ms = g_pmqos->list[i].max_duration_ms; - - if (duration > max_duration_ms) - duration = max_duration_ms; + max_duration_ms = g_pmqos->list[i].max_duration_ms; ret = 0; break; } @@ -187,10 +185,25 @@ static gboolean dbus_cb_pmqos_set_scenario(SystemPassPmqos *obj, goto out_dbus; } - if (duration) + /* Reqeust pmqos scenario with the maximum duration */ + if (max_duration_ms > 0 && duration > 0) { + duration = (duration < max_duration_ms) + ? duration : max_duration_ms; ret = pmqos_request(name, duration); - else + + /* + * Request pmqos mode without the maximum duration. + * Instead, enter the minus value (-1). When entering the minus value, + * doesn't create the timeout timer for pmqos mode. Until receiving + * the cancel request, keep the pmqos mode like UltraPowerSaving. + */ + } else if (max_duration_ms == 0 && duration > 0) { + ret = pmqos_request(name, INT_MAX); + + /* Cancel both scenario and mode for pmqos */ + } else { ret = pmqos_cancel(name); + } out_dbus: g_dbus_method_invocation_return_value(invoc, g_variant_new("(i)", ret)); @@ -326,6 +339,15 @@ static void pmqos_unlock_timeout_update(void) for (elem = pmqos_head; elem != NULL; elem = elem->next) { cpu = elem->data; cpu->timeout -= delta; + + /* + * If timeout is INT_MAX, indicatte 'mode'. + * Don't need to update the timeout and cancel pmqos for mode + * until receiving the cancel request. + */ + if (cpu->timeout == INT_MAX) + continue; + if (cpu->timeout < 0) cpu->timeout = 0; if (cpu->timeout > 0) @@ -406,6 +428,12 @@ static int pmqos_unlock_timer_start(void) for (elem = pmqos_head; elem != NULL; elem = elem->next) { cpu = elem->data; + /* + * If timeout is INT_MAX, indicate 'mode'. + * Don't need to add the timre for 'mode'. + */ + if (cpu->timeout == INT_MAX) + continue; if (cpu->timeout <= 0) continue; memcpy(&unlock_timer_owner, cpu, sizeof(struct pmqos_cpu)); -- 2.7.4 From bd35208a250f52efeaddbbbd5c80e6ad4ae7bc21 Mon Sep 17 00:00:00 2001 From: Chanwoo Choi Date: Fri, 7 Aug 2020 13:08:23 +0900 Subject: [PATCH 10/16] scripts: pmqos: Add new Doze mode Add new Doze scenario which handles h/w resources like CPU frequency when right after LCD off and before entering the suspend-to-RAM for reducing the idle power-consumption. [How to hanel 'Doze' mode] - Enable 'Doze' mode dbus-send --system --type=method_call --print-reply --reply-timeout=5000 \ --dest=org.tizen.system.pass /Org/Tizen/System/Pass/Pmqos \ org.tizen.system.pass.pmqos.SetScenario \ string:Doze int32:1; - Disable 'Doze' mode dbus-send --system --type=method_call --print-reply --reply-timeout=5000 \ --dest=org.tizen.system.pass /Org/Tizen/System/Pass/Pmqos \ org.tizen.system.pass.pmqos.SetScenario \ string:Doze int32:0; Change-Id: I536acbb36f663e4ad0ffa474f0a0981351428f0e Signed-off-by: Chanwoo Choi --- scripts/pass-pmqos.conf | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/scripts/pass-pmqos.conf b/scripts/pass-pmqos.conf index be9a4ef..c616e62 100644 --- a/scripts/pass-pmqos.conf +++ b/scripts/pass-pmqos.conf @@ -2,7 +2,7 @@ # set to "yes" scenario_support (Default value is no) # set scenario_num to be tested scenario_support=yes -scenario_num=2 +scenario_num=3 # describe the scenario section as follows #[Scenario0] @@ -19,3 +19,7 @@ support=yes [Scenario1] name=UltraPowerSaving support=yes + +[Scenario2] +name=Doze +support=yes -- 2.7.4 From befe5bc481f3a3b3ef2c42d7cebdadec5e459722 Mon Sep 17 00:00:00 2001 From: Chanwoo Choi Date: Tue, 28 Apr 2020 10:07:23 +0900 Subject: [PATCH 11/16] PASS v1.1.0 In order to support 'scenario pass_level', the format of pass configuration are changed. It affects the pass-hal packages. So, it needs to increse the version up to prevent the confusion between pass and pass-hal packages. - Changes from v1.0.0 1. Support 'scenario' pass_level' for PMQoS and Thermal Monitor 2. Support 'scenario' with maximum duration and 'mode' without maximum duration 3. Add new 'SetScenario' method - org.tizen.system.pass.pmqos.SetScenario 4. Add new 'Doze' mode Change-Id: I429e79171a22f7e1ce7b3248e04a0e1e1fe33f82 Signed-off-by: Chanwoo Choi --- packaging/pass.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/pass.spec b/packaging/pass.spec index 87bb13a..89d837b 100644 --- a/packaging/pass.spec +++ b/packaging/pass.spec @@ -7,7 +7,7 @@ Name: %{daemon_name} Summary: Power Aware System Service -Version: 1.0.0 +Version: 1.1.0 Release: 1 Group: System/Kernel License: Apache-2.0 -- 2.7.4 From 0757e12dd0688d25a1f4d000e58fb5fb125d0ed0 Mon Sep 17 00:00:00 2001 From: Chanwoo Choi Date: Wed, 25 Nov 2020 14:43:30 +0900 Subject: [PATCH 12/16] pmqos: Edit the unproper expression of pmqos data structure The pmqos module supports the multiple h/w resources like CPU, GPU, bus and memory. In order to express the correct meaning, edit the unproper expression of pmqos data structure from 'pmqos_cpu' and 'pmqos_data' and change the local variable name from 'cpu' to 'pmqos'. Change-Id: I25151a22b417c697b74758c531c5d11ab15e5430 Signed-off-by: Chanwoo Choi --- src/pmqos/pmqos.c | 86 +++++++++++++++++++++++++++---------------------------- 1 file changed, 43 insertions(+), 43 deletions(-) diff --git a/src/pmqos/pmqos.c b/src/pmqos/pmqos.c index 7ea160f..eb40199 100644 --- a/src/pmqos/pmqos.c +++ b/src/pmqos/pmqos.c @@ -55,7 +55,7 @@ static SystemPassPmqos *g_gdbus_instance = NULL; */ static struct pmqos_scenario *g_pmqos = NULL; -struct pmqos_cpu { +struct pmqos_data { char name[NAME_MAX]; int timeout; }; @@ -64,7 +64,7 @@ static GList *pmqos_head; guint g_unlock_timeout_id; static struct timespec unlock_timer_start_st; static struct timespec unlock_timer_end_st; -static struct pmqos_cpu unlock_timer_owner = {"", 0}; +static struct pmqos_data unlock_timer_owner = {"", 0}; /****************************************************** * PMQOS callback functions for Init/Exit * @@ -283,8 +283,8 @@ static gboolean pmqos_timer(gpointer data) static int compare_timeout(const void *a, const void *b) { - const struct pmqos_cpu *pmqos_a = (const struct pmqos_cpu *)a; - const struct pmqos_cpu *pmqos_b = (const struct pmqos_cpu *)b; + const struct pmqos_data *pmqos_a = (const struct pmqos_data *)a; + const struct pmqos_data *pmqos_b = (const struct pmqos_data *)b; if (!pmqos_a) return 1; @@ -327,7 +327,7 @@ static int set_pmqos(const char *name, int val) static void pmqos_unlock_timeout_update(void) { GList *elem, *next; - struct pmqos_cpu *cpu; + struct pmqos_data *pmqos; int delta = 0; clock_gettime(CLOCK_REALTIME, &unlock_timer_end_st); @@ -337,36 +337,36 @@ static void pmqos_unlock_timeout_update(void) return; for (elem = pmqos_head; elem != NULL; elem = elem->next) { - cpu = elem->data; - cpu->timeout -= delta; + pmqos = elem->data; + pmqos->timeout -= delta; /* * If timeout is INT_MAX, indicatte 'mode'. * Don't need to update the timeout and cancel pmqos for mode * until receiving the cancel request. */ - if (cpu->timeout == INT_MAX) + if (pmqos->timeout == INT_MAX) continue; - if (cpu->timeout < 0) - cpu->timeout = 0; - if (cpu->timeout > 0) + if (pmqos->timeout < 0) + pmqos->timeout = 0; + if (pmqos->timeout > 0) continue; - /* Set cpu unlock */ - set_pmqos(cpu->name, false); + /* Set pmqos unlock */ + set_pmqos(pmqos->name, false); } /* Remove all the requests of which timeout are over from the list */ elem = pmqos_head; while (elem != NULL) { - cpu = elem->data; + pmqos = elem->data; next = elem->next; - if (cpu->timeout <= 0) { + if (pmqos->timeout <= 0) { pmqos_head = g_list_remove(pmqos_head, - (gconstpointer)cpu); - free(cpu); - cpu = NULL; + (gconstpointer)pmqos); + free(pmqos); + pmqos = NULL; } elem = next; } @@ -380,22 +380,22 @@ static void pmqos_unlock_timeout_update(void) static int pmqos_cancel(const char *name) { GList *elem = NULL; - struct pmqos_cpu *cpu; + struct pmqos_data *pmqos; /* Find previous request */ for (elem = pmqos_head; elem != NULL; elem = elem->next) { - cpu = elem->data; - if (!strcmp(cpu->name, name)) + pmqos = elem->data; + if (!strcmp(pmqos->name, name)) break; } if (!elem) return 0; - set_pmqos(cpu->name, false); + set_pmqos(pmqos->name, false); - pmqos_head = g_list_remove(pmqos_head, (gconstpointer)cpu); - free(cpu); + pmqos_head = g_list_remove(pmqos_head, (gconstpointer)pmqos); + free(pmqos); if (strcmp(unlock_timer_owner.name, name)) goto out; @@ -415,7 +415,7 @@ static int pmqos_unlock_timer_start(void) { int ret; GList *elem; - struct pmqos_cpu *cpu; + struct pmqos_data *pmqos; if (g_unlock_timeout_id) { g_source_remove(g_unlock_timeout_id); @@ -427,16 +427,16 @@ static int pmqos_unlock_timer_start(void) return 0; for (elem = pmqos_head; elem != NULL; elem = elem->next) { - cpu = elem->data; + pmqos = elem->data; /* * If timeout is INT_MAX, indicate 'mode'. * Don't need to add the timre for 'mode'. */ - if (cpu->timeout == INT_MAX) + if (pmqos->timeout == INT_MAX) continue; - if (cpu->timeout <= 0) + if (pmqos->timeout <= 0) continue; - memcpy(&unlock_timer_owner, cpu, sizeof(struct pmqos_cpu)); + memcpy(&unlock_timer_owner, pmqos, sizeof(struct pmqos_data)); clock_gettime(CLOCK_REALTIME, &unlock_timer_start_st); g_unlock_timeout_id = g_timeout_add( /* FIXME: this is int to uint conversion. */ @@ -446,7 +446,7 @@ static int pmqos_unlock_timer_start(void) if (g_unlock_timeout_id) break; - _E("fail init pmqos unlock %s %d", cpu->name, cpu->timeout); + _E("fail init pmqos unlock %s %d", pmqos->name, pmqos->timeout); return -EPERM; } return 0; @@ -461,27 +461,27 @@ static int pmqos_unlock_timer_start(void) static int pmqos_request(const char *name, int val) { GList *elem; - struct pmqos_cpu *cpu; + struct pmqos_data *pmqos; int found = 0; int ret; for (elem = pmqos_head; elem != NULL; elem = elem->next) { - cpu = elem->data; - if (!strcmp(cpu->name, name)) { - cpu->timeout = val; + pmqos = elem->data; + if (!strcmp(pmqos->name, name)) { + pmqos->timeout = val; found = 1; break; } } if (!found) { - cpu = calloc(1, sizeof(struct pmqos_cpu)); - if (!cpu) + pmqos = calloc(1, sizeof(struct pmqos_data)); + if (!pmqos) return -ENOMEM; - snprintf(cpu->name, sizeof(cpu->name), "%s", name); - cpu->timeout = val; - pmqos_head = g_list_append(pmqos_head, (gpointer)cpu); + snprintf(pmqos->name, sizeof(pmqos->name), "%s", name); + pmqos->timeout = val; + pmqos_head = g_list_append(pmqos_head, (gpointer)pmqos); } pmqos_head = g_list_sort(pmqos_head, compare_timeout); @@ -490,12 +490,12 @@ static int pmqos_request(const char *name, int val) if (ret < 0) goto err; - set_pmqos(cpu->name, true); + set_pmqos(pmqos->name, true); return 0; err: if (!found) { - pmqos_head = g_list_remove(pmqos_head, (gconstpointer)cpu); - free(cpu); + pmqos_head = g_list_remove(pmqos_head, (gconstpointer)pmqos); + free(pmqos); } return ret; @@ -564,7 +564,7 @@ static void pmqos_free(void) memset(&unlock_timer_start_st, 0, sizeof(struct timespec)); memset(&unlock_timer_end_st, 0, sizeof(struct timespec)); - memset(&unlock_timer_owner, 0, sizeof(struct pmqos_cpu)); + memset(&unlock_timer_owner, 0, sizeof(struct pmqos_data)); if (pmqos_head) { g_list_free_full(pmqos_head, free); -- 2.7.4 From f0036548775393de3438f6108afc3b091378bd7f Mon Sep 17 00:00:00 2001 From: Chanwoo Choi Date: Thu, 3 Dec 2020 19:00:09 +0900 Subject: [PATCH 13/16] pass: pmqos: Change the log level to debug for removing confusion When the following case, it is not error. But, need to print the log message for debugging. - Unknown scearnio for each h/w resource - Nost supported scenario for each h/w resource - The some scenario is already locked. Change-Id: Ib4280a4feae6d7fdfcc35ca1be89526d42be1d1c Signed-off-by: Chanwoo Choi --- src/pass/pass-pmqos.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/pass/pass-pmqos.c b/src/pass/pass-pmqos.c index 3fd69a8..8ac9187 100644 --- a/src/pass/pass-pmqos.c +++ b/src/pass/pass-pmqos.c @@ -111,15 +111,15 @@ static int pmqos_notifier_cb(void *data, void *user_data) index = find_scenario_index(pmqos, name); if (index < 0) { - _W("Unknown scenario (%s) for '%s' resource\n", + _D("Unknown scenario (%s) for '%s' resource\n", name, config_data->res_name); - return -EINVAL; + return 0; } scn = &pmqos->scenarios[index]; /* Check the state of each scenario whether to support or not */ if (scn->state != PASS_ON) { - _W("Not supported '%s' scenario for '%s' resource\n", + _D("Not supported '%s' scenario for '%s' resource\n", name, config_data->res_name); return 0; } @@ -129,7 +129,7 @@ static int pmqos_notifier_cb(void *data, void *user_data) * if state is same as existing state */ if (scn->pmqos.locked == locked) { - _E("'%s' scenario is already %s for '%s' resource\n", name, + _D("'%s' scenario is already %s for '%s' resource\n", name, (locked == PASS_ON) ? "Locked" : "Unlocked", config_data->res_name); return 0; -- 2.7.4 From eaea4935881e70ac25529ba3168238c62ce386d9 Mon Sep 17 00:00:00 2001 From: Chanwoo Choi Date: Tue, 15 Dec 2020 15:21:52 +0900 Subject: [PATCH 14/16] pass: resmon: Fix memory leak of udev instance In order to fix the memory leak, call udev_device_unref when error happen. Change-Id: Ic5919eeb07c34e564bf5ad7cf357ff8ae35c2733 Signed-off-by: Chanwoo Choi --- src/pass/pass-resmon.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/src/pass/pass-resmon.c b/src/pass/pass-resmon.c index b81a868..dab9f00 100644 --- a/src/pass/pass-resmon.c +++ b/src/pass/pass-resmon.c @@ -468,13 +468,7 @@ static gboolean resmon_uevent_func(gint fd, GIOCondition cond, void *data) if (!dev) return G_SOURCE_CONTINUE; - dev = udev_device_ref(dev); - if (!dev) { - _E("failed to refer uevent device " \ - "(res_name:%s, src_type: 0x%x)\n", - res->config_data.res_name, monitor->src_type); - return G_SOURCE_CONTINUE; - } + udev_device_ref(dev); /* Collect resource data according to enum resmon_src_type */ if (monitor->ops && monitor->ops->uevent_handler) { @@ -483,7 +477,7 @@ static gboolean resmon_uevent_func(gint fd, GIOCondition cond, void *data) _E("failed to invoke uevent_handler " \ "(res_name:%s, src_type: 0x%x)\n", res->config_data.res_name, monitor->src_type); - return G_SOURCE_CONTINUE; + goto out; } } @@ -494,10 +488,11 @@ static gboolean resmon_uevent_func(gint fd, GIOCondition cond, void *data) _E("failed to invoke user_func " \ "(res_name:%s, src_type: 0x%x)\n", res->config_data.res_name, monitor->src_type); - return G_SOURCE_CONTINUE; + goto out; } } +out: udev_device_unref(dev); return G_SOURCE_CONTINUE; -- 2.7.4 From 5c6f41ca4f0072f0349edadce148241ff636039d Mon Sep 17 00:00:00 2001 From: Chanwoo Choi Date: Tue, 22 Dec 2020 16:09:00 +0900 Subject: [PATCH 15/16] pass: resmon: Fix memory leak of udev_monitor instance In order to fix the memory leak, jump exception handling code when error happen. Change-Id: I0b288b602d61cab6ebdce3c5e53ff808e0b2d001 Signed-off-by: Chanwoo Choi --- src/pass/pass-resmon.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/pass/pass-resmon.c b/src/pass/pass-resmon.c index dab9f00..faf7fc7 100644 --- a/src/pass/pass-resmon.c +++ b/src/pass/pass-resmon.c @@ -531,7 +531,8 @@ static int resmon_uevent_add(struct resmon *monitor) _E("failed to add filter due to subsystem/devtype are NULL " \ "(res_name:%s, src_type: 0x%x)\n", res->config_data.res_name, monitor->src_type); - return -EINVAL; + ret = -EINVAL; + goto err_udev_monitor; } /* Update the kernel's subsystem and devtype for filtering */ -- 2.7.4 From 469051e30f8207d2067b8354de3bb226cd62dc4e Mon Sep 17 00:00:00 2001 From: Chanwoo Choi Date: Wed, 6 Jan 2021 13:55:33 +0900 Subject: [PATCH 16/16] pass: hal: Replace HAL interface with hal-api-power Tizen 6.5 provides new HAL API layer to make tizen porting easy. Power HAL API (hal-api-power) provides HAL C API for controlling the h/w resources such as CPU/GPU/Memory Bus/Memory devices and provides HAL interface for HAL backend developer for using Tizen platform on new h/w device. PASS daemon just calls the Power HAL API without handling the HAL backend anymore. Describe the detailed changes as following: 1. Remove self-defined HAL functions and don't open HAL backend library directly. Instead, use hal-api-power to control the h/w resources. PASS deamon doesn't need to handle the HAL backend library anymore. 2. Remove pass-hal-devel package because of moving HAL interface defintion (src/hal/hal.h) into hal-api-power (hal-power-interface.h). 3. Change the open path of pass configuration files. - /etc/pass/ -> /hal/etc/pass/ Change-Id: I73a1c29c7af000335021faac62157b5342065682 Signed-off-by: Chanwoo Choi --- CMakeLists.txt | 11 +- include/pass/hal/hal.h | 245 --------------- packaging/pass.spec | 21 +- src/hal/CMakeLists.txt | 15 - src/hal/hal-log.h | 29 -- src/hal/hal.c | 92 ------ src/pass/pass-hal.c | 502 +++++------------------------- src/pass/pass-hal.h | 4 +- src/pass/pass-parser.c | 2 +- src/pass/pass-resmon.c | 2 +- src/pass/pass-thermal.c | 2 +- src/pass/pass.c | 2 +- systemd/{pass.service => pass.service.in} | 1 + unittest/CMakeLists.txt | 14 +- unittest/pass_haltests.cpp | 2 +- 15 files changed, 106 insertions(+), 838 deletions(-) delete mode 100644 include/pass/hal/hal.h delete mode 100755 src/hal/CMakeLists.txt delete mode 100644 src/hal/hal-log.h delete mode 100644 src/hal/hal.c rename systemd/{pass.service => pass.service.in} (84%) diff --git a/CMakeLists.txt b/CMakeLists.txt index a069f15..d8f2591 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,7 +7,6 @@ PROJECT(pass C) SET(EXEC_PREFIX "${CMAKE_INSTALL_PREFIX}/bin") SET(INCLUDEDIR "${CMAKE_INSTALL_PREFIX}/include/${PROJECT_NAME}") SET(VERSION 0.1.0) -SET(PASS_HAL_NAME pass-hal-devel) SET(SRCS src/pass/pass.c @@ -25,7 +24,6 @@ SET(SRCS src/pmqos/pmqos-parser.c src/thermal/thermal.c src/thermal/thermal-parser.c - src/hal/hal.c src/core/common.c src/core/config-parser.c src/core/device-notifier.c @@ -52,6 +50,8 @@ SET(PKG_MODULES gio-unix-2.0 libudev libsystemd + hal-api-common + hal-api-power ) INCLUDE(FindPkgConfig) @@ -65,6 +65,7 @@ SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fvisibility=hidden -fPIE") SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -g -fno-omit-frame-pointer -finstrument-functions") SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -lrt") SET(CMAKE_EXE_LINKER_FLAGS "-pie") +SET(LIBDIR ${CMAKE_LIBDIR_PREFIX}) ADD_DEFINITIONS("-DLOG_TAG=\"PASS\"") ADD_DEFINITIONS("-DPREFIX=\"${CMAKE_INSTALL_PREFIX}\"") @@ -94,23 +95,21 @@ ADD_CUSTOM_COMMAND( COMMENT "Generating GDBus stub for thermal interface") ADD_EXECUTABLE(${PROJECT_NAME} ${SRCS}) -TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${pkgs_LDFLAGS} "-ldl" "-lm") +TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${pkgs_LDFLAGS} -ldl -lm) INSTALL(TARGETS ${PROJECT_NAME} DESTINATION bin) INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/scripts/${PROJECT_NAME}.conf DESTINATION /etc/dbus-1/system.d) INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/scripts/pass-pmqos.conf DESTINATION /etc/pass) INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/scripts/pass-thermal.conf DESTINATION /etc/pass) +CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/systemd/${PROJECT_NAME}.service.in ${CMAKE_SOURCE_DIR}/systemd/${PROJECT_NAME}.service @ONLY) INSTALL(FILES ${CMAKE_SOURCE_DIR}/systemd/org.tizen.system.pass.service DESTINATION /usr/share/dbus-1/system-services) INSTALL(FILES ${CMAKE_SOURCE_DIR}/systemd/org.tizen.system.thermal.service DESTINATION /usr/share/dbus-1/system-services) CONFIGURE_FILE(${PROJECT_NAME}.pc.in ${PROJECT_NAME}.pc @ONLY) INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.pc DESTINATION ${LIB_INSTALL_DIR}/pkgconfig) -CONFIGURE_FILE(${PASS_HAL_NAME}.pc.in ${PASS_HAL_NAME}.pc @ONLY) -INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PASS_HAL_NAME}.pc DESTINATION ${LIB_INSTALL_DIR}/pkgconfig) INSTALL(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/systemd/ DESTINATION lib/systemd/system FILES_MATCHING PATTERN "*.service" ) -ADD_SUBDIRECTORY(src/hal) ADD_SUBDIRECTORY(unittest) diff --git a/include/pass/hal/hal.h b/include/pass/hal/hal.h deleted file mode 100644 index 3e41493..0000000 --- a/include/pass/hal/hal.h +++ /dev/null @@ -1,245 +0,0 @@ -/* - * Copyright (c) 2017 Samsung Electronics Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef _PASS_HAL_H_ -#define _PASS_HAL_H_ - -#include -#include -#include - -#define BUFF_MAX 255 - -#define MAKE_4B_CODE_4(A, B, C, D) \ - ((((A) & 0xff) << 24) | (((B) & 0xff) << 16) | \ - (((C) & 0xff) << 8) | (((D) & 0xff))) -#define MAKE_TAG_CONSTANT(A, B, C, D) MAKE_4B_CODE_4(A, B, C, D) - -#define HAL_INFO_TAG MAKE_TAG_CONSTANT('P', 'A', 'S', 'S') - -/* Symbolic name of the HAL info (PASS HAL Info) */ -#define HAL_INFO_SYM PassHalInfo - -#define PASS_RESOURCE_UNKNOWN 0 -#define PASS_RESOURCE_CPU_ID 1 -#define PASS_RESOURCE_BUS_ID 2 -#define PASS_RESOURCE_GPU_ID 3 -#define PASS_RESOURCE_MEMORY_ID 4 -#define PASS_RESOURCE_NONSTANDARD_ID 99 - -#define PASS_RESOURCE_CPU_NAME "cpu" -#define PASS_RESOURCE_BUS_NAME "bus" -#define PASS_RESOURCE_GPU_NAME "gpu" -#define PASS_RESOURCE_MEMORY_NAME "memory" -#define PASS_RESOURCE_NONSTANDARD_NAME "nonstandard" - -/** - * Define the common structure - */ - -struct pass_resource_common; - -/* - * pass_resource_info - Define the information structure for the resource. - * - * @magic : magic must be initialized to HAL_INFO_TAG - * @hal_version : HAL version - * @device_version: device version - * @id : device id, can have the following value. - * - PASS_RESOURCE_CPU_ID - * - PASS_RESOURCE_BUS_ID - * - PASS_RESOURCE_GPU_ID - * - PASS_RESOURCE_MEMORY_ID - * - PASS_RESOURCE_NONSTANDARD_ID - * @name : device name, can have the following value. - * - PASS_RESOURCE_CPU_NAME - * - PASS_RESOURCE_BUS_NAME - * - PASS_RESOURCE_GPU_NAME - * - PASS_RESOURCE_MEMORY_NAME - * - PASS_RESOURCE_NONSTANDARD_NAME - * @dso : module's dso - * @resourced[] : reserved for future use - * @open : function pointer to open device - * @close : function pointer to close device - */ -struct pass_resource_info { - uint32_t magic; - uint16_t hal_version; - uint16_t device_version; - const int id; - const char *name; - void *dso; - uint32_t reserved[8]; - - int (*open)(char *res_name, struct pass_resource_info *info, - struct pass_resource_common **common); - int (*close)(char *res_name, struct pass_resource_common *common); -}; - -struct pass_resource_common { - /* indicate to this device information structure */ - struct pass_resource_info *info; -}; - -/* - * Define the ops (operations) structure which are used on specific resource. - */ -struct pass_resource_dvfs_ops { - /* Get and set the current governor. */ - int (*get_curr_governor)(char *res_name, char *governor); - int (*set_curr_governor)(char *res_name, char *governor); - - int (*get_avail_governor)(char *res_name, char **avail_governor); - - /* Get the current frequency. */ - int (*get_curr_freq)(char *res_name); - - /* Get and set the minimum frequency. */ - int (*get_min_freq)(char *res_name); - int (*set_min_freq)(char *res_name, int freq); - - /* Get and set the maximum frequency. */ - int (*get_max_freq)(char *res_name); - int (*set_max_freq)(char *res_name, int freq); - - /* Get the minimum/maximum frequency which can be set to resource. */ - int (*get_available_min_freq)(char *res_name); - int (*get_available_max_freq)(char *res_name); - - /* Get and set the up_threshold to support boosting. */ - int (*get_up_threshold)(char *res_name); - int (*set_up_threshold)(char *res_name, int up_threshold); - - /* Get the load_table of each resource to estimate the system load. */ - int (*get_load_table)(char *name, void *pass_cpu_load_table); -}; - -struct pass_resource_hotplug_ops { - /* Get and set the online status of resource. */ - int (*get_online_state)(char *res_name, int cpu); - int (*set_online_state)(char *res_name, int cpu, int on); - /* Get and set the minimum number of online CPUs */ - int (*get_online_min_num) (char *res_name); - int (*set_online_min_num) (char *res_name, int min_num); - /* Get and set the maximum number of online CPUs */ - int (*get_online_max_num) (char *res_name); - int (*set_online_max_num) (char *res_name, int max_num); -}; - -struct pass_resource_tmu_ops { - /* Get the current temperature of resource. */ - int (*get_temp)(char *res_thermal_name); - - /* Get the policy of thermal management unit. */ - int (*get_policy)(char *res_thermal_name, char *policy); -}; - -/* - * Define the resource structure for CPU H/W. - * - * @common : common resource structure. - * @dvfs : function lists for the DVFS (Dynamic Volt. & Freq. Scaling). - * @tmu : function lists for the TMU (Thermal Management Unit). - * @hotplug : function lists for the CPU on/off. - */ -struct pass_resource_cpu { - struct pass_resource_common common; - - struct pass_resource_dvfs_ops dvfs; - struct pass_resource_tmu_ops tmu; - struct pass_resource_hotplug_ops hotplug; -}; - -/* - * Define the resource structure for Memory Bus H/W. - * - * @common : common resource structure. - * @dvfs : function lists for the DVFS (Dynamic Volt. & Freq. Scaling). - * @tmu : function lists for the TMU (Thermal Management Unit). - */ -struct pass_resource_bus { - struct pass_resource_common common; - - struct pass_resource_dvfs_ops dvfs; - struct pass_resource_tmu_ops tmu; -}; - -/* - * Define the resource structure for GPU H/W. - * - * @common : common resource structure. - * @dvfs : function lists for the DVFS (Dynamic Volt. & Freq. Scaling). - * @tmu : function lists for the TMU (Thermal Management Unit). - */ -struct pass_resource_gpu { - struct pass_resource_common common; - - struct pass_resource_dvfs_ops dvfs; - struct pass_resource_tmu_ops tmu; -}; - -/* - * Define the resource structure for Memory H/W. - * - * @common : common resource structure. - */ -struct pass_resource_memory { - struct pass_resource_common common; - - /* Get and set the /sys/kernel/debug/fault_around_bytes */ - int (*get_fault_around_bytes)(char *res_name); - int (*set_fault_around_bytes)(char *res_name, int fault_around_bytes); -}; - -/* - * Define the resource structure for nonstandard H/W. - * - * Following function is Deprecated. (Not recommended for use) - * @set_pmqos_data : function to bypass the scenario data to HAL. - * - * This structure indicates the nonstandard H/W which doesn't have - * the official supported framework (e.g., cpufreq, devfreq and so on) - * in Linux Kernel. But, the specific device might be controlled - * according to PMQoS scenario or other cases. - */ -struct pass_resource_nonstandard { - struct pass_resource_common common; - - /* - * NOTE: It is not propper method. But PASS must need to keep - * the backwards compatibility, set the PMQoS's data from - * platform to hal. So, It is not recommended to use it. - * - * This function will be removed after finding the proper method. - */ - int (*set_pmqos_data)(char *res_name, void *data); -}; - -int pass_get_hal_info(const char *id, const struct pass_resource_info **info); - -/** - * Structure define of HAL info module - * - * All HAL module should be use below define to make a specific - * structure for Tizen HAL. pass_get_resource_info function - * will load a pass_resource_data structure by using TizenHwInfo name - * at runtime. TizenHwInfo means Tizen Hardware Info. - */ -#define HAL_MODULE_STRUCTURE \ - __attribute__ ((visibility("default"))) \ - struct pass_resource_info HAL_INFO_SYM - -#endif /* _PASS_HAL_H_ */ diff --git a/packaging/pass.spec b/packaging/pass.spec index 89d837b..9e16a7a 100644 --- a/packaging/pass.spec +++ b/packaging/pass.spec @@ -1,7 +1,6 @@ %define _unpackaged_files_terminate_build 0 %define daemon_name pass -%define hal_name pass-hal-devel %define haltest_name pass-haltests %define unittest_name pass-unittest @@ -13,7 +12,6 @@ Group: System/Kernel License: Apache-2.0 Source0: %{name}-%{version}.tar.gz Source1: %{name}.manifest -Source2: %{hal_name}.manifest BuildRequires: cmake BuildRequires: pkgconfig(dlog) @@ -24,6 +22,8 @@ BuildRequires: pkgconfig(glib-2.0) BuildRequires: pkgconfig(gmock) BuildRequires: pkgconfig(libudev) BuildRequires: pkgconfig(libsystemd) +BuildRequires: pkgconfig(hal-api-common) +BuildRequires: pkgconfig(hal-api-power) %description PASS (Power-Aware System Service) @@ -35,14 +35,6 @@ Group: main %description %{daemon_name} PASS systemd daemon. -%package -n %{hal_name} -Summary: PASS HAL Header files -Group: Development/Library -Requires: pass = %{version}-%{release} - -%description -n %{hal_name} -Header files required to build pass-hal packages for specific boards. - %package -n %{haltest_name} Summary: PASS HAL test package with gtest Group: Development/Tools @@ -65,11 +57,11 @@ PASS unit test package with gtest %cmake . \ -DTZ_SYS_ETC=%TZ_SYS_ETC \ -DCMAKE_INSTALL_PREFIX=%{_prefix} \ + -DCMAKE_LIBDIR_PREFIX=%{_libdir} \ #eol %build cp %{SOURCE1} . -cp %{SOURCE2} . make %{?jobs:-j%jobs} %install @@ -106,13 +98,6 @@ systemctl daemon-reload %{_datadir}/dbus-1/system-services/org.tizen.system.pass.service %{_datadir}/dbus-1/system-services/org.tizen.system.thermal.service -%files -n %{hal_name} -%defattr(-,root,root,-) -%manifest %{hal_name}.manifest -%{_includedir}/%{daemon_name}/hal.h -%{_includedir}/%{daemon_name}/hal-log.h -%{_libdir}/pkgconfig/%{hal_name}.pc - %files -n %{haltest_name} %defattr(-,root,root,-) %{_bindir}/pass_haltests diff --git a/src/hal/CMakeLists.txt b/src/hal/CMakeLists.txt deleted file mode 100755 index c0f1fbc..0000000 --- a/src/hal/CMakeLists.txt +++ /dev/null @@ -1,15 +0,0 @@ -CMAKE_MINIMUM_REQUIRED(VERSION 2.6) -PROJECT(pass-hal-devel C) - -SET(HAL_HEADERS - ../../include/pass/hal/hal.h - hal-log.h -) - -INCLUDE(FindPkgConfig) -pkg_check_modules(pkgs REQUIRED - dlog) - -FOREACH(hheader ${HAL_HEADERS}) - INSTALL(FILES ${hheader} DESTINATION ${INCLUDEDIR}) -ENDFOREACH(hheader) diff --git a/src/hal/hal-log.h b/src/hal/hal-log.h deleted file mode 100644 index 4b43f61..0000000 --- a/src/hal/hal-log.h +++ /dev/null @@ -1,29 +0,0 @@ -/* - * PASS (Power Aware System Service) - * - * Copyright (c) 2017 Samsung Electronics Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef __HAL_LOG_H__ -#define __HAL_LOG_H__ - -#include - -#define _D(fmt, arg...) do { SLOGD(fmt, ##arg); } while (0) -#define _I(fmt, arg...) do { SLOGI(fmt, ##arg); } while (0) -#define _W(fmt, arg...) do { SLOGW(fmt, ##arg); } while (0) -#define _E(fmt, arg...) do { SLOGE(fmt, ##arg); } while (0) - -#endif /* __HAL_LOG_H__ */ diff --git a/src/hal/hal.c b/src/hal/hal.c deleted file mode 100644 index 0b2cffa..0000000 --- a/src/hal/hal.c +++ /dev/null @@ -1,92 +0,0 @@ -/* - * PASS (Power Aware System Service) HAL - * - * Copyright (c) 2017 Samsung Electronics Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * @file hal.c - * @brief Provide a helper function to load shared library, like cpu.so - * /gpu.so/bus.so etc, from HAL (Hardware Abstract Layer) - * package according to the type of h/w resource. - * @ingroup COM_POWER_MGNT - */ - -#include -#include -#include -#include -#include -#include -#include - -#include - -#include "hal-log.h" - -#ifndef EXPORT -#define EXPORT __attribute__ ((visibility("default"))) -#endif - -#ifndef LIBPATH -#error LIBPATH is not defined. -#endif - -#define MODULE_PATH LIBPATH"/pass" - -#define STRINGIZE2(s) #s -#define STRINGIZE(s) STRINGIZE2(s) - -EXPORT -int pass_get_hal_info(const char *name, const struct pass_resource_info **info) -{ - char path[PATH_MAX]; - void *handle; - struct pass_resource_info *it; - - if (!info || !name) - return -EINVAL; - - /* Load module */ - snprintf(path, sizeof(path), "%s/%s.so", MODULE_PATH, name); - handle = dlopen(path, RTLD_NOW); - if (!handle) { - _E("fail to open module : %s", dlerror()); - goto error; - } - - it = dlsym(handle, STRINGIZE(HAL_INFO_SYM)); - if (!it) { - _E("fail to find symbol : %s", dlerror()); - goto error; - } - - /* Check id */ - if (strncmp(name, it->name, strlen(name)) != 0) { - _E("fail to match name : name(%s), it->name(%s)", name, - it->name); - goto error; - } - - it->dso = handle; - *info = it; - return 0; - -error: - if (handle) - dlclose(handle); - - return -ENOENT; -} diff --git a/src/pass/pass-hal.c b/src/pass/pass-hal.c index 0ba680f..f2229f7 100644 --- a/src/pass/pass-hal.c +++ b/src/pass/pass-hal.c @@ -38,64 +38,6 @@ #include "pass.h" #include "pass-hal.h" -static struct pass_resource_dvfs_ops *get_dvfs(struct pass_resource *res, - int res_type) -{ - struct pass_resource_dvfs_ops *dvfs = NULL; - - switch (res_type) { - case PASS_RESOURCE_CPU_ID: - dvfs = &(res->hal.cpu->dvfs); - break; - case PASS_RESOURCE_BUS_ID: - dvfs = &(res->hal.bus->dvfs); - break; - case PASS_RESOURCE_GPU_ID: - dvfs = &(res->hal.gpu->dvfs); - break; - } - - return dvfs; -} - -static struct pass_resource_tmu_ops *get_tmu(struct pass_resource *res, - int res_type) -{ - struct pass_resource_tmu_ops *tmu = NULL; - - switch (res_type) { - case PASS_RESOURCE_CPU_ID: - tmu = &(res->hal.cpu->tmu); - break; - case PASS_RESOURCE_BUS_ID: - tmu = &(res->hal.bus->tmu); - break; - case PASS_RESOURCE_GPU_ID: - tmu = &(res->hal.gpu->tmu); - break; - } - - return tmu; -} - -static struct pass_resource_hotplug_ops *get_hotplug(struct pass_resource *res, - int res_type) -{ - struct pass_resource_hotplug_ops *hotplug = NULL; - - switch (res_type) { - case PASS_RESOURCE_CPU_ID: - hotplug = &(res->hal.cpu->hotplug); - break; - case PASS_RESOURCE_BUS_ID: - case PASS_RESOURCE_GPU_ID: - hotplug = NULL; - break; - } - - return hotplug; -} - /** * @brief Get the current governor for DVFS(Dynamic Voltage and Frequency * Scaling) resource @@ -104,23 +46,16 @@ static struct pass_resource_hotplug_ops *get_hotplug(struct pass_resource *res, * @return @c 0 on success, otherwise error value * @retval -22 Invalid argument (-EINVAL) * @retval -1 Operation not permitted (-EPERM) - * @retval -19 Operation not supported (-ENODEV) + * @retval -19 Operation not supported (-ENOTSUP) */ int pass_hal_get_curr_governor(struct pass_resource *res, char *governor) { - struct pass_resource_dvfs_ops *dvfs; - if (!res || !governor) return -EINVAL; - dvfs = get_dvfs(res, res->config_data.res_type); - if (!dvfs) - return -EPERM; - - if (!dvfs->get_curr_governor) - return -ENODEV; - - return dvfs->get_curr_governor(res->config_data.res_name, governor); + return hal_power_dvfs_get_curr_governor(res->config_data.res_type, + res->config_data.res_name, + governor); } /** @@ -131,23 +66,16 @@ int pass_hal_get_curr_governor(struct pass_resource *res, char *governor) * @return @c 0 on success, otherwise error value * @retval -22 Invalid argument (-EINVAL) * @retval -1 Operation not permitted (-EPERM) - * @retval -19 Operation not supported (-ENODEV) + * @retval -19 Operation not supported (-ENOTSUP) */ int pass_hal_set_curr_governor(struct pass_resource *res, char *governor) { - struct pass_resource_dvfs_ops *dvfs; - if (!res || !governor) return -EINVAL; - dvfs = get_dvfs(res, res->config_data.res_type); - if (!dvfs) - return -EPERM; - - if (!dvfs->set_curr_governor) - return -ENODEV; - - return dvfs->set_curr_governor(res->config_data.res_name, governor); + return hal_power_dvfs_set_curr_governor(res->config_data.res_type, + res->config_data.res_name, + governor); } /** @@ -157,23 +85,15 @@ int pass_hal_set_curr_governor(struct pass_resource *res, char *governor) * @return @c positive integer on success, otherwise error value * @retval -22 Invalid argument (-EINVAL) * @retval -1 Operation not permitted (-EPERM) - * @retval -19 Operation not supported (-ENODEV) + * @retval -19 Operation not supported (-ENOTSUP) */ int pass_hal_get_curr_freq(struct pass_resource *res) { - struct pass_resource_dvfs_ops *dvfs; - if (!res) return -EINVAL; - dvfs = get_dvfs(res, res->config_data.res_type); - if (!dvfs) - return -EPERM; - - if (!dvfs->get_curr_freq) - return -ENODEV; - - return dvfs->get_curr_freq(res->config_data.res_name); + return hal_power_dvfs_get_curr_freq(res->config_data.res_type, + res->config_data.res_name); } /** @@ -183,23 +103,15 @@ int pass_hal_get_curr_freq(struct pass_resource *res) * @return @c positive integer on success, otherwise error value * @retval -22 Invalid argument (-EINVAL) * @retval -1 Operation not permitted (-EPERM) - * @retval -19 Operation not supported (-ENODEV) + * @retval -19 Operation not supported (-ENOTSUP) */ int pass_hal_get_min_freq(struct pass_resource *res) { - struct pass_resource_dvfs_ops *dvfs; - if (!res) return -EINVAL; - dvfs = get_dvfs(res, res->config_data.res_type); - if (!dvfs) - return -EPERM; - - if (!dvfs->get_min_freq) - return -ENODEV; - - return dvfs->get_min_freq(res->config_data.res_name); + return hal_power_dvfs_get_min_freq(res->config_data.res_type, + res->config_data.res_name); } /** @@ -210,23 +122,16 @@ int pass_hal_get_min_freq(struct pass_resource *res) * @return @c positive integer on success, otherwise error value * @retval -22 Invalid argument (-EINVAL) * @retval -1 Operation not permitted (-EPERM) - * @retval -19 Operation not supported (-ENODEV) + * @retval -19 Operation not supported (-ENOTSUP) */ int pass_hal_set_min_freq(struct pass_resource *res, int freq) { - struct pass_resource_dvfs_ops *dvfs; - if (!res || freq < 0) return -EINVAL; - dvfs = get_dvfs(res, res->config_data.res_type); - if (!dvfs) - return -EPERM; - - if (!dvfs->set_min_freq) - return -ENODEV; - - return dvfs->set_min_freq(res->config_data.res_name, freq); + return hal_power_dvfs_set_min_freq(res->config_data.res_type, + res->config_data.res_name, + freq); } /** @@ -236,23 +141,15 @@ int pass_hal_set_min_freq(struct pass_resource *res, int freq) * @return @c positive integer on success, otherwise error value * @retval -22 Invalid argument (-EINVAL) * @retval -1 Operation not permitted (-EPERM) - * @retval -19 Operation not supported (-ENODEV) + * @retval -19 Operation not supported (-ENOTSUP) */ int pass_hal_get_max_freq(struct pass_resource *res) { - struct pass_resource_dvfs_ops *dvfs; - if (!res) return -EINVAL; - dvfs = get_dvfs(res, res->config_data.res_type); - if (!dvfs) - return -EPERM; - - if (!dvfs->get_max_freq) - return -ENODEV; - - return dvfs->get_max_freq(res->config_data.res_name); + return hal_power_dvfs_get_max_freq(res->config_data.res_type, + res->config_data.res_name); } /** @@ -263,23 +160,16 @@ int pass_hal_get_max_freq(struct pass_resource *res) * @return @c positive integer on success, otherwise error value * @retval -22 Invalid argument (-EINVAL) * @retval -1 Operation not permitted (-EPERM) - * @retval -19 Operation not supported (-ENODEV) + * @retval -19 Operation not supported (-ENOTSUP) */ int pass_hal_set_max_freq(struct pass_resource *res, int freq) { - struct pass_resource_dvfs_ops *dvfs; - if (!res || freq < 0) return -EINVAL; - dvfs = get_dvfs(res, res->config_data.res_type); - if (!dvfs) - return -EPERM; - - if (!dvfs->set_max_freq) - return -ENODEV; - - return dvfs->set_max_freq(res->config_data.res_name, freq); + return hal_power_dvfs_set_max_freq(res->config_data.res_type, + res->config_data.res_name, + freq); } /** @@ -289,23 +179,15 @@ int pass_hal_set_max_freq(struct pass_resource *res, int freq) * @return @c positive integer on success, otherwise error value * @retval -22 Invalid argument (-EINVAL) * @retval -1 Operation not permitted (-EPERM) - * @retval -19 Operation not supported (-ENODEV) + * @retval -19 Operation not supported (-ENOTSUP) */ int pass_hal_get_available_min_freq(struct pass_resource *res) { - struct pass_resource_dvfs_ops *dvfs; - if (!res) return -EINVAL; - dvfs = get_dvfs(res, res->config_data.res_type); - if (!dvfs) - return -EPERM; - - if (!dvfs->get_available_min_freq) - return -ENODEV; - - return dvfs->get_available_min_freq(res->config_data.res_name); + return hal_power_dvfs_get_available_min_freq(res->config_data.res_type, + res->config_data.res_name); } /** @@ -315,23 +197,15 @@ int pass_hal_get_available_min_freq(struct pass_resource *res) * @return @c positive integer on success, otherwise error value * @retval -22 Invalid argument (-EINVAL) * @retval -1 Operation not permitted (-EPERM) - * @retval -19 Operation not supported (-ENODEV) + * @retval -19 Operation not supported (-ENOTSUP) */ int pass_hal_get_available_max_freq(struct pass_resource *res) { - struct pass_resource_dvfs_ops *dvfs; - if (!res) return -EINVAL; - dvfs = get_dvfs(res, res->config_data.res_type); - if (!dvfs) - return -EPERM; - - if (!dvfs->get_available_max_freq) - return -ENODEV; - - return dvfs->get_available_max_freq(res->config_data.res_name); + return hal_power_dvfs_get_available_max_freq(res->config_data.res_type, + res->config_data.res_name); } /** @@ -341,23 +215,15 @@ int pass_hal_get_available_max_freq(struct pass_resource *res) * @return @c positive integer on success, otherwise error value * @retval -22 Invalid argument (-EINVAL) * @retval -1 Operation not permitted (-EPERM) - * @retval -19 Operation not supported (-ENODEV) + * @retval -19 Operation not supported (-ENOTSUP) */ int pass_hal_get_up_threshold(struct pass_resource *res) { - struct pass_resource_dvfs_ops *dvfs; - if (!res) return -EINVAL; - dvfs = get_dvfs(res, res->config_data.res_type); - if (!dvfs) - return -EPERM; - - if (!dvfs->get_up_threshold) - return -ENODEV; - - return dvfs->get_up_threshold(res->config_data.res_name); + return hal_power_dvfs_get_up_threshold(res->config_data.res_type, + res->config_data.res_name); } /** @@ -368,23 +234,16 @@ int pass_hal_get_up_threshold(struct pass_resource *res) * @return @c positive integer on success, otherwise error value * @retval -22 Invalid argument (-EINVAL) * @retval -1 Operation not permitted (-EPERM) - * @retval -19 Operation not supported (-ENODEV) + * @retval -19 Operation not supported (-ENOTSUP) */ int pass_hal_set_up_threshold(struct pass_resource *res, int up_threshold) { - struct pass_resource_dvfs_ops *dvfs; - if (!res || up_threshold < 0) return -EINVAL; - dvfs = get_dvfs(res, res->config_data.res_type); - if (!dvfs) - return -EPERM; - - if (!dvfs->set_up_threshold) - return -ENODEV; - - return dvfs->set_up_threshold(res->config_data.res_name, up_threshold); + return hal_power_dvfs_set_up_threshold(res->config_data.res_type, + res->config_data.res_name, + up_threshold); } /** @@ -394,23 +253,16 @@ int pass_hal_set_up_threshold(struct pass_resource *res, int up_threshold) * @return @c positive integer on success, otherwise error value * @retval -22 Invalid argument (-EINVAL) * @retval -1 Operation not permitted (-EPERM) - * @retval -19 Operation not supported (-ENODEV) + * @retval -19 Operation not supported (-ENOTSUP) */ int pass_hal_get_online_state(struct pass_resource *res, int cpu) { - struct pass_resource_hotplug_ops *hotplug; - if (!res || cpu < 0) return -EINVAL; - hotplug = get_hotplug(res, res->config_data.res_type); - if (!hotplug) - return -EPERM; - - if (!hotplug->get_online_state) - return -ENODEV; - - return hotplug->get_online_state(res->config_data.res_name, cpu); + return hal_power_hotplug_get_online_state(res->config_data.res_type, + res->config_data.res_name, + cpu); } /** @@ -421,23 +273,16 @@ int pass_hal_get_online_state(struct pass_resource *res, int cpu) * @return @c 0 on success, otherwise error value * @retval -22 Invalid argument (-EINVAL) * @retval -1 Operation not permitted (-EPERM) - * @retval -19 Operation not supported (-ENODEV) + * @retval -19 Operation not supported (-ENOTSUP) */ int pass_hal_set_online_state(struct pass_resource *res, int cpu, int on) { - struct pass_resource_hotplug_ops *hotplug; - if (!res || cpu < 0 || on < 0) return -EINVAL; - hotplug = get_hotplug(res, res->config_data.res_type); - if (!hotplug) - return -EPERM; - - if (!hotplug->set_online_state) - return -ENODEV; - - return hotplug->set_online_state(res->config_data.res_name, cpu, on); + return hal_power_hotplug_set_online_state(res->config_data.res_type, + res->config_data.res_name, + cpu, on); } /** @@ -446,23 +291,15 @@ int pass_hal_set_online_state(struct pass_resource *res, int cpu, int on) * @return @c positive integer on success, otherwise error value * @retval -22 Invalid argument (-EINVAL) * @retval -1 Operation not permitted (-EPERM) - * @retval -19 Operation not supported (-ENODEV) + * @retval -19 Operation not supported (-ENOTSUP) */ int pass_hal_get_online_min_num(struct pass_resource *res) { - struct pass_resource_hotplug_ops *hotplug; - if (!res) return -EINVAL; - hotplug = get_hotplug(res, res->config_data.res_type); - if (!hotplug) - return -EPERM; - - if (!hotplug->get_online_min_num) - return -ENODEV; - - return hotplug->get_online_min_num(res->config_data.res_name); + return hal_power_hotplug_get_online_min_num(res->config_data.res_type, + res->config_data.res_name); } /** @@ -472,23 +309,16 @@ int pass_hal_get_online_min_num(struct pass_resource *res) * @return @c 0 on success, otherwise error value * @retval -22 Invalid argument (-EINVAL) * @retval -1 Operation not permitted (-EPERM) - * @retval -19 Operation not supported (-ENODEV) + * @retval -19 Operation not supported (-ENOTSUP) */ int pass_hal_set_online_min_num(struct pass_resource *res, int num) { - struct pass_resource_hotplug_ops *hotplug; - if ((!res) || (num < 0)) return -EINVAL; - hotplug = get_hotplug(res, res->config_data.res_type); - if (!hotplug) - return -EPERM; - - if (!hotplug->set_online_min_num) - return -ENODEV; - - return hotplug->set_online_min_num(res->config_data.res_name, num); + return hal_power_hotplug_set_online_min_num(res->config_data.res_type, + res->config_data.res_name, + num); } /** @@ -497,23 +327,15 @@ int pass_hal_set_online_min_num(struct pass_resource *res, int num) * @return @c positive integer on success, otherwise error value * @retval -22 Invalid argument (-EINVAL) * @retval -1 Operation not permitted (-EPERM) - * @retval -19 Operation not supported (-ENODEV) + * @retval -19 Operation not supported (-ENOTSUP) */ int pass_hal_get_online_max_num(struct pass_resource *res) { - struct pass_resource_hotplug_ops *hotplug; - if (!res) return -EINVAL; - hotplug = get_hotplug(res, res->config_data.res_type); - if (!hotplug) - return -EPERM; - - if (!hotplug->get_online_max_num) - return -ENODEV; - - return hotplug->get_online_max_num(res->config_data.res_name); + return hal_power_hotplug_get_online_max_num(res->config_data.res_type, + res->config_data.res_name); } /** @@ -523,23 +345,16 @@ int pass_hal_get_online_max_num(struct pass_resource *res) * @return @c 0 on success, otherwise error value * @retval -22 Invalid argument (-EINVAL) * @retval -1 Operation not permitted (-EPERM) - * @retval -19 Operation not supported (-ENODEV) + * @retval -19 Operation not supported (-ENOTSUP) */ int pass_hal_set_online_max_num(struct pass_resource *res, int num) { - struct pass_resource_hotplug_ops *hotplug; - if ((!res) || (num < 0)) return -EINVAL; - hotplug = get_hotplug(res, res->config_data.res_type); - if (!hotplug) - return -EPERM; - - if (!hotplug->set_online_max_num) - return -ENODEV; - - return hotplug->set_online_max_num(res->config_data.res_name, num); + return hal_power_hotplug_set_online_max_num(res->config_data.res_type, + res->config_data.res_name, + num); } /** @@ -548,27 +363,19 @@ int pass_hal_set_online_max_num(struct pass_resource *res, int num) * @return @c integer (both positive and negative are possible) on success * @retval -22 Invalid argument (-EINVAL) * @retval -1 Operation not permitted (-EPERM) - * @retval -19 Operation not supported (-ENODEV) + * @retval -19 Operation not supported (-ENOTSUP) */ int pass_hal_get_temp(struct pass_resource *res) { - struct pass_resource_tmu_ops *tmu; - if (!res) return -EINVAL; - tmu = get_tmu(res, res->config_data.res_type); - if (!tmu) - return -EPERM; - - if (!tmu->get_temp) - return -ENODEV; - /* * In the case of the HAL TMU ops, res_thermal_name is used * as the first argument instead of res_name. */ - return tmu->get_temp(res->config_data.res_thermal_name); + return hal_power_thermal_get_temp(res->config_data.res_type, + res->config_data.res_thermal_name); } /** @@ -578,27 +385,20 @@ int pass_hal_get_temp(struct pass_resource *res) * @return @c 0 on success, otherwise error value * @retval -22 Invalid argument (-EINVAL) * @retval -1 Operation not permitted (-EPERM) - * @retval -19 Operation not supported (-ENODEV) + * @retval -19 Operation not supported (-ENOTSUP) */ int pass_hal_get_tmu_policy(struct pass_resource *res, char *policy) { - struct pass_resource_tmu_ops *tmu; - if (!res || !policy) return -EINVAL; - tmu = get_tmu(res, res->config_data.res_type); - if (!tmu) - return -EPERM; - - if (!tmu->get_policy) - return -ENODEV; - /* * In the case of the HAL TMU ops, res_thermal_name is used * as the first argument instead of res_name. */ - return tmu->get_policy(res->config_data.res_thermal_name, policy); + return hal_power_thermal_get_policy(res->config_data.res_type, + res->config_data.res_thermal_name, + policy); } /** @@ -609,28 +409,17 @@ int pass_hal_get_tmu_policy(struct pass_resource *res, char *policy) * @return @c 0 on success, otherwise error value * @retval -22 Invalid argument (-EINVAL) * @retval -1 Operation not permitted (-EPERM) - * @retval -19 Operation not supported (-ENODEV) + * @retval -19 Operation not supported (-ENOTSUP) */ int pass_hal_set_fault_around_bytes(struct pass_resource *res, int fault_around_bytes) { - struct pass_resource_memory *memory; - if (!res) return -EINVAL; - switch (res->config_data.res_type) { - case PASS_RESOURCE_MEMORY_ID: - memory = res->hal.memory; - break; - default: - return -EPERM; - } - - if (!memory->set_fault_around_bytes) - return -ENODEV; - - return memory->set_fault_around_bytes(res->config_data.res_name, fault_around_bytes); + return hal_power_memory_set_fault_around_bytes(res->config_data.res_type, + res->config_data.res_name, + fault_around_bytes); } /** @@ -639,27 +428,15 @@ int pass_hal_set_fault_around_bytes(struct pass_resource *res, * @return @c positive integer on success, otherwise error value * @retval -22 Invalid argument (-EINVAL) * @retval -1 Operation not permitted (-EPERM) - * @retval -19 Operation not supported (-ENODEV) + * @retval -19 Operation not supported (-ENOTSUP) */ int pass_hal_get_fault_around_bytes(struct pass_resource *res) { - struct pass_resource_memory *memory; - if (!res) return -EINVAL; - switch (res->config_data.res_type) { - case PASS_RESOURCE_MEMORY_ID: - memory = res->hal.memory; - break; - default: - return -EPERM; - } - - if (!memory->get_fault_around_bytes) - return -ENODEV; - - return memory->get_fault_around_bytes(res->config_data.res_name); + return hal_power_memory_get_fault_around_bytes(res->config_data.res_type, + res->config_data.res_name); } /** @@ -668,27 +445,15 @@ int pass_hal_get_fault_around_bytes(struct pass_resource *res) * @return @c 0 on success, otherwise error value * @retval -22 Invalid argument (-EINVAL) * @retval -1 Operation not permitted (-EPERM) - * @retval -19 Operation not supported (-ENODEV) + * @retval -19 Operation not supported (-ENOTSUP) */ int pass_hal_set_pmqos_data(struct pass_resource *res, void *data) { - struct pass_resource_nonstandard *nonstandard = NULL; - if (!res || !data) return -EINVAL; - switch (res->config_data.res_type) { - case PASS_RESOURCE_NONSTANDARD_ID: - nonstandard = (res->hal.nonstandard); - break; - default: - return -EPERM; - } - - if (!nonstandard->set_pmqos_data) - return -ENODEV; - - return nonstandard->set_pmqos_data(res->config_data.res_name, data); + return hal_power_misc_set_pmqos_data(res->config_data.res_type, + res->config_data.res_name, data); } /** @@ -990,79 +755,10 @@ int pass_hal_restore_initdata(struct pass_resource *res) */ int pass_hal_get_resource(struct pass_resource *res) { - struct pass_resource_info *info; - const char *name; - int ret; - if (!res) return -EINVAL; - switch (res->config_data.res_type) { - case PASS_RESOURCE_CPU_ID: - name = PASS_RESOURCE_CPU_NAME; - break; - case PASS_RESOURCE_BUS_ID: - name = PASS_RESOURCE_BUS_NAME; - break; - case PASS_RESOURCE_GPU_ID: - name = PASS_RESOURCE_GPU_NAME; - break; - case PASS_RESOURCE_MEMORY_ID: - name = PASS_RESOURCE_MEMORY_NAME; - break; - case PASS_RESOURCE_NONSTANDARD_ID: - name = PASS_RESOURCE_NONSTANDARD_NAME; - break; - default: - _E("Unsupported resource type (type: %d)\n", - res->config_data.res_type); - return -EINVAL; - }; - - ret = pass_get_hal_info(name, - (const struct pass_resource_info **)&info); - if (ret < 0) { - _E("Failed to get %s.so for '%s' resource\n", - name, res->config_data.res_name); - return -EINVAL; - } - - if (!info->open || !info->close) { - _E("Failed to get functions of %s.so for '%s' resource\n", - name, res->config_data.res_name); - return -EPERM; - } - - switch (res->config_data.res_type) { - case PASS_RESOURCE_CPU_ID: - ret = info->open(res->config_data.res_name, info, - (struct pass_resource_common**)&res->hal.cpu); - break; - case PASS_RESOURCE_BUS_ID: - ret = info->open(res->config_data.res_name, info, - (struct pass_resource_common**)&res->hal.bus); - break; - case PASS_RESOURCE_GPU_ID: - ret = info->open(res->config_data.res_name, info, - (struct pass_resource_common**)&res->hal.gpu); - break; - case PASS_RESOURCE_MEMORY_ID: - ret = info->open(res->config_data.res_name, info, - (struct pass_resource_common**)&res->hal.memory); - break; - case PASS_RESOURCE_NONSTANDARD_ID: - ret = info->open(res->config_data.res_name, info, - (struct pass_resource_common**)&res->hal.nonstandard); - break; - }; - - if (ret < 0) { - _E("Failed to open %s.so for '%s' resource\n", - name, res->config_data.res_name); - return -EINVAL; - } - - return 0; + return hal_power_get_backend(res->config_data.res_type); } /** @@ -1073,48 +769,8 @@ int pass_hal_get_resource(struct pass_resource *res) */ int pass_hal_put_resource(struct pass_resource *res) { - struct pass_resource_common *common; - struct pass_resource_info *info; - int ret; - if (!res) return -EINVAL; - switch (res->config_data.res_type) { - case PASS_RESOURCE_CPU_ID: - common = (struct pass_resource_common*)res->hal.cpu; - info = res->hal.cpu->common.info; - ret = info->close(res->config_data.res_name, common); - break; - case PASS_RESOURCE_BUS_ID: - common = (struct pass_resource_common*)res->hal.bus; - info = res->hal.bus->common.info; - ret = info->close(res->config_data.res_name, common); - break; - case PASS_RESOURCE_GPU_ID: - common = (struct pass_resource_common*)res->hal.gpu; - info = res->hal.gpu->common.info; - ret = info->close(res->config_data.res_name, common); - break; - case PASS_RESOURCE_MEMORY_ID: - common = (struct pass_resource_common*)res->hal.memory; - info = res->hal.memory->common.info; - ret = info->close(res->config_data.res_name, common); - break; - case PASS_RESOURCE_NONSTANDARD_ID: - common = (struct pass_resource_common*)res->hal.nonstandard; - info = res->hal.nonstandard->common.info; - ret = info->close(res->config_data.res_name, common); - break; - default: - return -EINVAL; - }; - - if (ret < 0) { - _E("Failed to close %s.so for '%s' resource\n", - info->name, res->config_data.res_name); - return -EINVAL; - } - - return 0; + return hal_power_put_backend(); } diff --git a/src/pass/pass-hal.h b/src/pass/pass-hal.h index 6329602..43b45e3 100644 --- a/src/pass/pass-hal.h +++ b/src/pass/pass-hal.h @@ -31,7 +31,9 @@ #ifndef __PASS_HAL__ #define __PASS_HAL__ -#include +#include + +struct pass_resource; /*** * Functions for all H/W resources diff --git a/src/pass/pass-parser.c b/src/pass/pass-parser.c index 38c6392..dac9724 100644 --- a/src/pass/pass-parser.c +++ b/src/pass/pass-parser.c @@ -40,7 +40,7 @@ #include #include -#include +#include #include "pass.h" diff --git a/src/pass/pass-resmon.c b/src/pass/pass-resmon.c index faf7fc7..8c42e08 100644 --- a/src/pass/pass-resmon.c +++ b/src/pass/pass-resmon.c @@ -40,7 +40,7 @@ #include #include -#include +#include #include "pass.h" #include "pass-hal.h" diff --git a/src/pass/pass-thermal.c b/src/pass/pass-thermal.c index fc3b088..5ef9eb3 100644 --- a/src/pass/pass-thermal.c +++ b/src/pass/pass-thermal.c @@ -26,8 +26,8 @@ */ #include -#include #include +#include #include "pass.h" #include "pass-rescon.h" diff --git a/src/pass/pass.c b/src/pass/pass.c index 764df84..ae9592f 100644 --- a/src/pass/pass.c +++ b/src/pass/pass.c @@ -42,7 +42,7 @@ #include "pass-parser.h" #include "pass-hal.h" -#define PASS_CONF_PATH "/etc/pass/pass.conf" +#define PASS_CONF_PATH "/hal/etc/pass/pass.conf" /** * @brief Specify the supported modules according to the type of h/w diff --git a/systemd/pass.service b/systemd/pass.service.in similarity index 84% rename from systemd/pass.service rename to systemd/pass.service.in index 13b8bcf..a774f5f 100644 --- a/systemd/pass.service +++ b/systemd/pass.service.in @@ -10,6 +10,7 @@ RestartSec=0 KillSignal=SIGUSR1 User=system_fw Group=system_fw +Environment=LD_LIBRARY_PATH=@LIBDIR@/hal [Install] WantedBy=delayed.target diff --git a/unittest/CMakeLists.txt b/unittest/CMakeLists.txt index 99c5bdc..7aeae05 100644 --- a/unittest/CMakeLists.txt +++ b/unittest/CMakeLists.txt @@ -1,7 +1,6 @@ PROJECT(pass C CXX) -SET(SRCS ${CMAKE_SOURCE_DIR}/src/hal/hal.c - ${CMAKE_SOURCE_DIR}/src/pass/pass-hal.c +SET(SRCS ${CMAKE_SOURCE_DIR}/src/pass/pass-hal.c ${CMAKE_SOURCE_DIR}/src/pass/pass-parser.c ${CMAKE_SOURCE_DIR}/src/core/common.c ${CMAKE_SOURCE_DIR}/src/core/config-parser.c @@ -13,7 +12,14 @@ INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/src/pass) INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include) INCLUDE(FindPkgConfig) -pkg_check_modules(gtest_pkgs REQUIRED glib-2.0 gio-2.0 gmock dlog) +pkg_check_modules(gtest_pkgs REQUIRED + glib-2.0 + gio-2.0 + gmock + dlog + hal-api-common + hal-api-power +) FOREACH(flag ${gtest_pkgs_CFLAGS}) SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") @@ -29,6 +35,6 @@ FOREACH(src ${sources}) GET_FILENAME_COMPONENT(src_name ${src} NAME_WE) MESSAGE("${src_name}") ADD_EXECUTABLE(${src_name} ${SRCS} ${src}) - TARGET_LINK_LIBRARIES(${src_name} ${gtest_LDFLAGS} ${gtest_pkgs_LDFLAGS} -ldl) + TARGET_LINK_LIBRARIES(${src_name} ${gtest_LDFLAGS} ${gtest_pkgs_LDFLAGS} -ldl -L${LIBDIR}/hal) INSTALL(TARGETS ${src_name} DESTINATION bin) ENDFOREACH() diff --git a/unittest/pass_haltests.cpp b/unittest/pass_haltests.cpp index de98ee0..3cb6f7b 100644 --- a/unittest/pass_haltests.cpp +++ b/unittest/pass_haltests.cpp @@ -57,7 +57,7 @@ TEST_F(PowerMgntHalTest, GetResourceConfig_HandlesValidInput) { int ret = 0; unsigned int i; - char path[] = "/etc/pass/pass.conf"; + char path[] = "/hal/etc/pass/pass.conf"; /* Stop PASS daemon before HAL testing */ ret = system("/bin/systemctl stop pass.service"); -- 2.7.4