From a1c21896f381c4ee36e842f7f399126d5b2d9ec7 Mon Sep 17 00:00:00 2001 From: Chanwoo Choi Date: Mon, 6 Nov 2017 10:23:01 +0900 Subject: [PATCH 01/16] 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 --- src/pass/pass.h | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/pass/pass.h b/src/pass/pass.h index 7bcbed5..b959a70 100644 --- a/src/pass/pass.h +++ b/src/pass/pass.h @@ -16,7 +16,6 @@ * limitations under the License. */ - #ifndef __PASS__ #define __PASS__ @@ -34,10 +33,6 @@ #define PASS_LEVEL_COND_MAX 3 #define PASS_CPU_STATS_DEFAULT 20 #define PASS_MIN_GOV_TIMEOUT 0.2 -#define PASS_RESOURCE_MAX 10 - -#define PASS_CLUSTER_0 0 -#define PASS_CLUSTER_1 1 struct pass_policy; -- 2.7.4 From 69653de0116824ba743a941f8324feda82ad7137 Mon Sep 17 00:00:00 2001 From: Chanwoo Choi Date: Mon, 6 Nov 2017 10:29:38 +0900 Subject: [PATCH 02/16] 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 --- src/pass/pass-parser.c | 9 +++++---- src/pass/pass.c | 1 + src/pass/pass.h | 2 -- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/pass/pass-parser.c b/src/pass/pass-parser.c index e7eda1a..eb8e71a 100644 --- a/src/pass/pass-parser.c +++ b/src/pass/pass-parser.c @@ -30,6 +30,7 @@ #define BUFF_MAX 255 #define MAX_NUM 255 +#define MIN_TIMEOUT_SEC 0.2 static enum pass_state is_supported(char *value) { @@ -181,8 +182,8 @@ static int pass_parse_level(struct parse_result *result, else if (MATCH(result->name, "gov_timeout")) { double gov_timeout = atof(result->value); - if (gov_timeout < PASS_MIN_GOV_TIMEOUT) - gov_timeout = PASS_MIN_GOV_TIMEOUT; + if (gov_timeout < MIN_TIMEOUT_SEC) + gov_timeout = MIN_TIMEOUT_SEC; policy->levels[level].gov_timeout = gov_timeout; } @@ -238,8 +239,8 @@ static int pass_parse_core(struct parse_result *result, void *user_data) else if (MATCH(result->name, "pass_governor_timeout")) { policy->gov_timeout = atof(result->value); - if (PASS_MIN_GOV_TIMEOUT > policy->gov_timeout) - policy->gov_timeout = PASS_MIN_GOV_TIMEOUT; + if (MIN_TIMEOUT_SEC > policy->gov_timeout) + policy->gov_timeout = MIN_TIMEOUT_SEC; } if (policy->num_levels > 0 && !policy->levels) { diff --git a/src/pass/pass.c b/src/pass/pass.c index 2af60b7..bb32453 100644 --- a/src/pass/pass.c +++ b/src/pass/pass.c @@ -42,6 +42,7 @@ #define PASS_DEFAULT_CPU_THRESHOLD 20 #define PASS_DEFAULT_LEVEL_UP_THRESHOLD 30 #define PASS_DEFAULT_LEVEL_DOWN_THRESHOLD 80 +#define PASS_CPU_STATS_DEFAULT 20 static struct pass g_pass; static SystemPassCore *g_gdbus_instance = NULL; diff --git a/src/pass/pass.h b/src/pass/pass.h index b959a70..892a2c2 100644 --- a/src/pass/pass.h +++ b/src/pass/pass.h @@ -31,8 +31,6 @@ ******************************************************/ #define PASS_NAME_LEN 128 #define PASS_LEVEL_COND_MAX 3 -#define PASS_CPU_STATS_DEFAULT 20 -#define PASS_MIN_GOV_TIMEOUT 0.2 struct pass_policy; -- 2.7.4 From be07604fcbe7061fe5f4e05b3c276b48b849ea93 Mon Sep 17 00:00:00 2001 From: Chanwoo Choi Date: Mon, 6 Nov 2017 10:40:00 +0900 Subject: [PATCH 03/16] 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 --- src/core/config-parser.c | 6 +++--- src/pass/pass-gov.h | 2 +- src/pass/pass-parser.c | 11 +++++------ src/pass/pass-pmqos.c | 2 +- src/pass/pass.h | 15 ++++++++------- 5 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/core/config-parser.c b/src/core/config-parser.c index f1bc6f9..d0e2632 100644 --- a/src/core/config-parser.c +++ b/src/core/config-parser.c @@ -24,7 +24,7 @@ #include "config-parser.h" -#define MAX_LINE 128 +#define BUFF_MAX 255 #define MAX_SECTION 64 #define WHITESPACE " \t" #define NEWLINE "\n\r" @@ -50,7 +50,7 @@ int config_parse(const char *file_name, int cb(struct parse_result *result, FILE *f = NULL; struct parse_result result; /* use stack for parsing */ - char line[MAX_LINE]; + char line[BUFF_MAX]; char section[MAX_SECTION]; char *start, *end, *name, *value; int lineno = 0, ret = 0; @@ -68,7 +68,7 @@ int config_parse(const char *file_name, int cb(struct parse_result *result, } /* parsing line by line */ - while (fgets(line, MAX_LINE, f) != NULL) { + while (fgets(line, BUFF_MAX, f) != NULL) { lineno++; start = line; diff --git a/src/pass/pass-gov.h b/src/pass/pass-gov.h index 6f17665..9bbbada 100644 --- a/src/pass/pass-gov.h +++ b/src/pass/pass-gov.h @@ -26,7 +26,7 @@ enum pass_gov_state { }; struct pass_governor { - char name[PASS_NAME_LEN]; + char name[BUFF_MAX]; enum pass_gov_state gov_state; int (*init)(struct pass_policy *); diff --git a/src/pass/pass-parser.c b/src/pass/pass-parser.c index eb8e71a..121a606 100644 --- a/src/pass/pass-parser.c +++ b/src/pass/pass-parser.c @@ -28,7 +28,6 @@ #include "core/config-parser.h" #include "hal/hal.h" -#define BUFF_MAX 255 #define MAX_NUM 255 #define MIN_TIMEOUT_SEC 0.2 @@ -101,7 +100,7 @@ static int pass_parse_pmqos(struct parse_result *result, void *user_data, /* Parse 'Scenario' section */ if (MATCH(result->name, "name")) { - snprintf(pmqos->scenarios[index].name, PASS_NAME_LEN, "%s", + snprintf(pmqos->scenarios[index].name, BUFF_MAX, "%s", result->value); } else if (MATCH(result->name, "support")) { pmqos->scenarios[index].state = is_supported(result->value); @@ -520,13 +519,13 @@ static int pass_parse_resource_data(struct parse_result *result, else return -EINVAL; } else if (MATCH(result->name, "pass_res_name")) { - snprintf(conf_data->res_name, PASS_NAME_LEN, "%s", result->value); + snprintf(conf_data->res_name, BUFF_MAX, "%s", result->value); } else if (MATCH(result->name, "pass_res_thermal_name")) { - snprintf(conf_data->res_thermal_name, PASS_NAME_LEN, "%s", result->value); + snprintf(conf_data->res_thermal_name, BUFF_MAX, "%s", result->value); } else if (MATCH(result->name, "pass_path_conf_file")) { - snprintf(conf_data->path_conf_file, PASS_NAME_LEN, "%s", result->value); + snprintf(conf_data->path_conf_file, BUFF_MAX, "%s", result->value); } else if (MATCH(result->name, "pass_path_load_table")) { - snprintf(conf_data->path_load_table, PASS_NAME_LEN, "%s", result->value); + snprintf(conf_data->path_load_table, BUFF_MAX, "%s", result->value); } else if (MATCH(result->name, "pass_first_cpu")) { int res_type = conf_data->res_type; diff --git a/src/pass/pass-pmqos.c b/src/pass/pass-pmqos.c index da9fb77..ba9b7e7 100644 --- a/src/pass/pass-pmqos.c +++ b/src/pass/pass-pmqos.c @@ -107,7 +107,7 @@ int pass_notifier_pmqos_func(struct pass_policy *policy, void *data) struct pass_pmqos *pmqos; struct pass_scenario *scn = NULL; enum pass_state locked = PASS_UNUSED; - char name[PASS_NAME_LEN] = {""}; + char name[BUFF_MAX] = {""}; unsigned int new_level = 0; unsigned int min_level = 0; unsigned int max_level = 0; diff --git a/src/pass/pass.h b/src/pass/pass.h index 892a2c2..9f18fe1 100644 --- a/src/pass/pass.h +++ b/src/pass/pass.h @@ -26,10 +26,11 @@ #include "shared/log.h" +#define BUFF_MAX 255 + /****************************************************** * PASS Governors * ******************************************************/ -#define PASS_NAME_LEN 128 #define PASS_LEVEL_COND_MAX 3 struct pass_policy; @@ -181,7 +182,7 @@ struct pass_level { * @sequence: the sequence to turn on/off cpu */ struct pass_hotplug { - char name[PASS_NAME_LEN]; + char name[BUFF_MAX]; unsigned int num_cpus; unsigned int online; unsigned int *sequence; @@ -196,7 +197,7 @@ struct pass_freq_policy { }; struct pass_scenario { - char name[PASS_NAME_LEN]; + char name[BUFF_MAX]; enum pass_state state; enum pass_state locked; int64_t locked_time; @@ -290,10 +291,10 @@ struct pass_policy { */ struct pass_conf_data { unsigned int res_type; - char res_name[PASS_NAME_LEN]; - char res_thermal_name[PASS_NAME_LEN]; - char path_conf_file[PASS_NAME_LEN]; - char path_load_table[PASS_NAME_LEN]; + char res_name[BUFF_MAX]; + char res_thermal_name[BUFF_MAX]; + char path_conf_file[BUFF_MAX]; + char path_load_table[BUFF_MAX]; unsigned int num_cpus; unsigned int cpu; -- 2.7.4 From c158d90278ab0ddf5f6a8b19e8b41f65218304eb Mon Sep 17 00:00:00 2001 From: Wook Song Date: Thu, 16 Nov 2017 15:48:48 +0900 Subject: [PATCH 04/16] pmqos: Do not send DBus method return message when PMQoS is not started When the PMQoS module receives PMQoS requests via DBus methods invocation before its initialization, the module displays out the message about that the module is not started yet and it returns a DBus message to the sender. The following log message is displayed in the systemd journal because of this DBus method return message sending: pass[2132]: g_object_unref: assertion 'G_IS_OBJECT (object)' failed Although this warning may not harm any parts of the system, it is fixed by this patch as well. Change-Id: I4f22e4b429c2dcbbd2f1834ec485dc06bfdf24a2 Signed-off-by: Wook Song --- src/pmqos/pmqos.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/pmqos/pmqos.c b/src/pmqos/pmqos.c index bf6120f..78854dd 100644 --- a/src/pmqos/pmqos.c +++ b/src/pmqos/pmqos.c @@ -151,7 +151,7 @@ static gboolean dbus_cb_pmqos_legacy_scenario(SystemPassPmqos *obj, _E("cannot set the PMQoS sceanrio: " "%s is not supported\n", name_from); ret_out = FALSE; - goto out; + goto out_dbus; } } @@ -160,9 +160,10 @@ static gboolean dbus_cb_pmqos_legacy_scenario(SystemPassPmqos *obj, else ret = pmqos_cancel(name_from); -out: +out_dbus: g_dbus_method_invocation_return_value(invoc, g_variant_new("(i)", ret)); +out: return ret_out; } -- 2.7.4 From 437ac9adcbe85628b67d858079c94c4f8f6286bd Mon Sep 17 00:00:00 2001 From: Chanwoo Choi Date: Mon, 6 Nov 2017 10:47:24 +0900 Subject: [PATCH 05/16] pass: Replace struct pass_policy to pass_resource for representing h/w resource The commit 86cd810d6e1ae ("pass: Add new helper function to handle the h/w resource through hal interface") introduced the 'struct pass_resource' which represents the each h/w resource such as CPU/GPU/BUS, memory and so on. Before applied commit 86cd810d6e1ae, PASS used the 'struct pass_policy' which represented the each h/w resource. So, this patch replaces 'struct pass_policy' to 'struct pass_resource' for representing the each h/w resource. Change-Id: I714c633255696af2cbf4719ce2892f15b37e1b25 Signed-off-by: Chanwoo Choi --- src/pass/pass-gov.c | 181 +++++++++++++++++++++++++++---------------------- src/pass/pass-gov.h | 29 +++----- src/pass/pass-hal.c | 9 +-- src/pass/pass-hal.h | 2 +- src/pass/pass-parser.c | 20 +++++- src/pass/pass-parser.h | 5 +- src/pass/pass-pmqos.c | 13 ++-- src/pass/pass-pmqos.h | 3 +- src/pass/pass-rescon.c | 39 +++++++---- src/pass/pass-rescon.h | 4 +- src/pass/pass.c | 20 +++--- src/pass/pass.h | 6 +- 12 files changed, 188 insertions(+), 143 deletions(-) diff --git a/src/pass/pass-gov.c b/src/pass/pass-gov.c index e388788..aa511a9 100644 --- a/src/pass/pass-gov.c +++ b/src/pass/pass-gov.c @@ -32,18 +32,25 @@ #define PASS_CPU_STATS_MAX_COUNT 20 +struct pass_governor { + char name[BUFF_MAX]; + enum pass_gov_state gov_state; + + int (*init)(struct pass_resource *res); + int (*exit)(struct pass_resource *res); + int (*update)(struct pass_resource *res, enum pass_gov_state state); + int (*governor)(struct pass_resource *res); +}; + /* * is_enabled - Check the state of PASS governor - * @policy: instance of pass_policy structure + * @policy: the instance of struct pass_policy * * Return true if the state of PASS is PASS_GOV_START * Return false if the state of PASS is PASS_GOV_STOP */ static bool is_enabled(struct pass_policy *policy) { - if (!policy) - return false; - if (policy->governor->gov_state != PASS_GOV_START) return false; @@ -53,38 +60,38 @@ static bool is_enabled(struct pass_policy *policy) /* * pass_notifier_pmqos - Callback func of DEVICE_NOTIFIER_PMQOS * @data: the scenario name - * @user_data: the instance of struct pass_policy + * @user_data: the instance of struct pass_resource */ static int pass_notifier_pmqos(void *data, void *user_data) { - struct pass_policy *policy = user_data; + struct pass_resource *res = user_data; - if (policy->state == PASS_ON) - pass_notifier_pmqos_func(policy, data); + if (res->policy.state == PASS_ON) + pass_notifier_pmqos_func(res, data); return 0; } /* * pass_notifier_init - Register notifiers and init - * @policy: the instance of pass_policy structure + * @res: the instance of struct pass_resource */ -static int pass_notifier_init(struct pass_policy *policy) +static int pass_notifier_init(struct pass_resource *res) { /* Register DEVICE_NOTIFIER_PMQOS */ return register_notifier(DEVICE_NOTIFIER_PMQOS, pass_notifier_pmqos, - policy); + res); } /* * pass_notifier_exit - Un-register notifiers and exit - * @policy: the instance of pass_policy structure + * @res: the instance of struct pass_resource */ -static int pass_notifier_exit(struct pass_policy *policy) +static int pass_notifier_exit(struct pass_resource *res) { /* Un-register DEVICE_NOTIFIER_PMQOS */ unregister_notifier(DEVICE_NOTIFIER_PMQOS, pass_notifier_pmqos, - policy); + res); return 0; } @@ -95,11 +102,11 @@ static int pass_notifier_exit(struct pass_policy *policy) /* * pass_hotplug_stop - Stop PASS hotplug - * - * @policy: the instance of struct pass_policy + * @res: the instance of struct pass_resource */ -static void pass_hotplug_stop(struct pass_policy *policy) +static void pass_hotplug_stop(struct pass_resource *res) { + struct pass_policy *policy = &res->policy; struct pass_level *levels = policy->levels; int level = policy->max_level; @@ -109,8 +116,9 @@ static void pass_hotplug_stop(struct pass_policy *policy) policy->hotplug->online = levels[level].limit_min_cpu; } -static int pass_hotplug_dummy_governor(struct pass_policy *policy) +static int pass_hotplug_dummy_governor(struct pass_resource *res) { + struct pass_policy *policy = &res->policy; int level = policy->curr_level; return policy->levels[level].limit_min_cpu; @@ -118,10 +126,10 @@ static int pass_hotplug_dummy_governor(struct pass_policy *policy) /* * pass_get_governor - Return specific hotplug instance according to type - * + * @res: the instance of struct pass_resource * @type: the type of PASS hotplug */ -struct pass_hotplug* pass_get_hotplug(struct pass_policy *policy, +struct pass_hotplug* pass_get_hotplug(struct pass_resource *res, enum pass_gov_type type) { struct pass_hotplug *hotplug; @@ -157,13 +165,12 @@ struct pass_hotplug* pass_get_hotplug(struct pass_policy *policy, /* * pass_calculate_busy_cpu - Count a number of busy cpu among NR_CPUS by using * runnable_avg_sum/runnable_avg_period - * - * @policy: the instance of struct pass_policy + * @res: the instance of struct pass_resource */ -static void pass_calculate_busy_cpu(struct pass_policy *policy) +static void pass_calculate_busy_cpu(struct pass_resource *res) { + struct pass_policy *policy = &res->policy; struct pass_cpu_stats *stats = policy->pass_cpu_stats; - struct pass_resource *res = to_pass_resource(policy); struct pass_level *levels = policy->levels; struct pass_conf_data *cdata = &res->cdata; unsigned int level = policy->curr_level; @@ -224,17 +231,17 @@ static void pass_calculate_busy_cpu(struct pass_policy *policy) /* * pass_governor_timeout_cb - Callback for each timeout interval of the governor - * - * @data: the instance of struct pass_policy + * @data: the instance of struct pass_resource */ static gboolean pass_governor_timeout_cb(gpointer data) { - struct pass_policy *policy = (struct pass_policy *) data; + struct pass_resource *res = (struct pass_resource *)data; + struct pass_policy *policy = &res->policy; static int count = 0; double curr_gov_timeout, next_gov_timeout; int level, ret; - if (!policy) { + if (!res) { _E("cannot call the governor timeout callback\n"); return FALSE; } @@ -245,7 +252,7 @@ static gboolean pass_governor_timeout_cb(gpointer data) * - the number of nr_running * - the resource utilization */ - ret = pass_get_cpu_stats(policy); + ret = pass_get_cpu_stats(res); if (ret < 0) { if (count++ < PASS_CPU_STATS_MAX_COUNT) return TRUE; @@ -253,25 +260,25 @@ static gboolean pass_governor_timeout_cb(gpointer data) count = 0; _E("cannot read the 'pass_cpu_stats' sysfs entry"); - pass_governor_update(policy, PASS_GOV_STOP); + pass_governor_update(res, PASS_GOV_STOP); return FALSE; } /* Calculate the number of busy cpu */ - pass_calculate_busy_cpu(policy); + pass_calculate_busy_cpu(res); /* Store current governor timeout */ curr_gov_timeout = policy->levels[policy->curr_level].gov_timeout; /* Determine the amount of proper resource */ if (policy->governor->governor) { - level = policy->governor->governor(policy); + level = policy->governor->governor(res); - pass_rescon_set_level(policy, level); + pass_rescon_set_level(res, level); } else { _E("cannot call the governor function"); - pass_governor_update(policy, PASS_GOV_STOP); + pass_governor_update(res, PASS_GOV_STOP); return FALSE; } @@ -290,7 +297,7 @@ static gboolean pass_governor_timeout_cb(gpointer data) policy->gov_timeout_id = g_timeout_add( (guint)(next_gov_timeout * 1000), pass_governor_timeout_cb, - (gpointer)policy); + (gpointer)res); } return TRUE; @@ -298,12 +305,11 @@ static gboolean pass_governor_timeout_cb(gpointer data) /* * __pass_governor_start - Start PASS governor through D-Bus - * - * @policy: the instance of struct pass_policy + * @res: the instance of struct pass_resource */ -static void __pass_governor_start(struct pass_policy *policy) +static void __pass_governor_start(struct pass_resource *res) { - struct pass_resource *res = to_pass_resource(policy); + struct pass_policy *policy = &res->policy; struct pass_conf_data *cdata = &res->cdata; if (!policy->governor) { @@ -321,10 +327,10 @@ static void __pass_governor_start(struct pass_policy *policy) policy->gov_timeout_id = g_timeout_add( (guint)(policy->gov_timeout * 1000), (GSourceFunc)pass_governor_timeout_cb, - (gpointer)policy); + (gpointer)res); if (!policy->gov_timeout_id) { _E("cannot add core timer for governor"); - pass_governor_update(policy, PASS_GOV_STOP); + pass_governor_update(res, PASS_GOV_STOP); return; } } else { @@ -339,7 +345,7 @@ static void __pass_governor_start(struct pass_policy *policy) if (policy->init_level > policy->max_level) policy->init_level = policy->max_level; - pass_rescon_set_level(policy, policy->init_level); + pass_rescon_set_level(res, policy->init_level); /* Set PASS state as PASS_GOV_START */ policy->governor->gov_state = PASS_GOV_START; @@ -349,12 +355,11 @@ static void __pass_governor_start(struct pass_policy *policy) /* * __pass_governor_stop - Stop PASS governor through D-Bus - * - * @policy: the instance of struct pass_policy + * @res: the instance of struct pass_resource */ -static void __pass_governor_stop(struct pass_policy *policy) +static void __pass_governor_stop(struct pass_resource *res) { - struct pass_resource *res = to_pass_resource(policy); + struct pass_policy *policy = &res->policy; struct pass_conf_data *cdata = &res->cdata; if (!policy->governor) { @@ -367,7 +372,7 @@ static void __pass_governor_stop(struct pass_policy *policy) return; } - pass_hotplug_stop(policy); + pass_hotplug_stop(res); if (policy->gov_timeout_id) { g_source_remove(policy->gov_timeout_id); @@ -380,42 +385,44 @@ static void __pass_governor_stop(struct pass_policy *policy) _I("Stop governor for '%s' resource", cdata->res_name); } -static int __pass_governor_init(struct pass_policy *policy) +static int __pass_governor_init(struct pass_resource *res) { + struct pass_policy *policy = &res->policy; int ret; if (policy->gov_timeout < 0) { _E("invalid timeout value [%d]!", policy->gov_timeout); - pass_governor_update(policy, PASS_GOV_STOP); + pass_governor_update(res, PASS_GOV_STOP); return -EINVAL; } /* Set default PASS state */ policy->governor->gov_state = PASS_GOV_STOP; - ret = pass_notifier_init(policy); + ret = pass_notifier_init(res); if (ret < 0) { _E("cannot initialize notifier for the pmqos (%d)\n", ret); return ret; } if (policy->state == PASS_ON) - pass_governor_update(policy, PASS_GOV_START); + pass_governor_update(res, PASS_GOV_START); return 0; } -static int __pass_governor_exit(struct pass_policy *policy) +static int __pass_governor_exit(struct pass_resource *res) { + struct pass_policy *policy = &res->policy; int i; /* Exit notifier */ - pass_notifier_exit(policy); + pass_notifier_exit(res); /* * Stop timer and * Restore the frequency and the number of online resources */ - pass_governor_update(policy, PASS_GOV_STOP); + pass_governor_update(res, PASS_GOV_STOP); /* Free allocated memory */ for (i = 0; i < policy->num_pass_cpu_stats; i++) { @@ -448,20 +455,15 @@ static int __pass_governor_exit(struct pass_policy *policy) return 0; } -static int __pass_governor_update(struct pass_policy *policy, +static int __pass_governor_update(struct pass_resource *res, enum pass_gov_state state) { - if (!policy) { - _E("cannot update PASS governor"); - return -EINVAL; - } - switch (state) { case PASS_GOV_START: - __pass_governor_start(policy); + __pass_governor_start(res); break; case PASS_GOV_STOP: - __pass_governor_stop(policy); + __pass_governor_stop(res); break; default: _E("Unknown governor state"); @@ -505,10 +507,9 @@ static struct pass_governor pass_gov_radiation = { /* * pass_get_governor - Return specific governor instance according to type - * * @type: the type of PASS governor */ -struct pass_governor* pass_get_governor(struct pass_policy *policy, +struct pass_governor* pass_get_governor(struct pass_resource *res, enum pass_gov_type type) { switch (type) { @@ -533,42 +534,62 @@ struct pass_governor* pass_get_governor(struct pass_policy *policy, } /* - * __pass_governor_init - Initialize PASS governor - * - * @policy: the instance of struct pass_policy + * pass_governor_init - Initialize PASS governor + * @res: the instance of struct pass_resource */ -int pass_governor_init(struct pass_policy *policy) +int pass_governor_init(struct pass_resource *res) { - if (!policy || !policy->governor || !policy->governor->init) + struct pass_policy *policy; + + if (!res) return -EINVAL; - return policy->governor->init(policy); + policy = &res->policy; + + if (!policy->governor || !policy->governor->init) + return -EINVAL; + + return policy->governor->init(res); } /* - * __pass_governor_exit - Exit PASS governor + * pass_governor_exit - Exit PASS governor + * @res: the instance of struct pass_resource */ -int pass_governor_exit(struct pass_policy *policy) +int pass_governor_exit(struct pass_resource *res) { - if (!policy || !policy->governor || !policy->governor->exit) + struct pass_policy *policy; + + if (!res) return -EINVAL; - return policy->governor->exit(policy); + policy = &res->policy; + + if (!policy->governor || !policy->governor->exit) + return -EINVAL; + + return policy->governor->exit(res); } /* - * __pass_governor_update - Restart/Pause PASS governor - * - * @policy: the instance of struct pass_policy + * pass_governor_update - Restart/Pause PASS governor + * @res: the instance of struct pass_resource * @state: the state of governor * PASS_GOV_START : start governor * PASS_GOV_STOP: stop governor */ -int pass_governor_update(struct pass_policy *policy, +int pass_governor_update(struct pass_resource *res, enum pass_gov_state state) { - if (!policy || !policy->governor || !policy->governor->update) + struct pass_policy *policy; + + if (!res) + return -EINVAL; + + policy = &res->policy; + + if (!policy->governor || !policy->governor->update) return -EINVAL; - return policy->governor->update(policy, state); + return policy->governor->update(res, state); } diff --git a/src/pass/pass-gov.h b/src/pass/pass-gov.h index 9bbbada..f91e678 100644 --- a/src/pass/pass-gov.h +++ b/src/pass/pass-gov.h @@ -25,29 +25,20 @@ enum pass_gov_state { PASS_GOV_STOP, }; -struct pass_governor { - char name[BUFF_MAX]; - enum pass_gov_state gov_state; - - int (*init)(struct pass_policy *); - int (*exit)(struct pass_policy *); - int (*update)(struct pass_policy *, enum pass_gov_state state); - int (*governor)(struct pass_policy *); -}; - /* Init, exit and update the governor */ -int pass_governor_init(struct pass_policy *policy); -int pass_governor_exit(struct pass_policy *policy); -int pass_governor_update(struct pass_policy *policy, enum pass_gov_state state); +int pass_governor_init(struct pass_resource *res); +int pass_governor_exit(struct pass_resource *res); +int pass_governor_update(struct pass_resource *res, + enum pass_gov_state state); /* Get the governor/hotplug instance according to enum pass_gov_type */ -struct pass_governor* pass_get_governor(struct pass_policy *policy, - enum pass_gov_type type); -struct pass_hotplug* pass_get_hotplug(struct pass_policy *policy, - enum pass_gov_type type); +struct pass_governor* pass_get_governor(struct pass_resource *res, + enum pass_gov_type type); +struct pass_hotplug* pass_get_hotplug(struct pass_resource *res, + enum pass_gov_type type); /* Function for radiation and step governor */ -int pass_step_governor(struct pass_policy *policy); -int pass_radiation_governor(struct pass_policy *policy); +int pass_step_governor(struct pass_resource *res); +int pass_radiation_governor(struct pass_resource *res); #endif /* __PASS_GOV__ */ diff --git a/src/pass/pass-hal.c b/src/pass/pass-hal.c index fb9fe0e..78bb2d6 100644 --- a/src/pass/pass-hal.c +++ b/src/pass/pass-hal.c @@ -989,21 +989,22 @@ int pass_put_resource(struct pass_resource *res) * FXIME: Following function is not standard interface. * Following functions will be altered by the standard interface on later. * - * - int pass_get_cpu_stats(struct pass_policy *policy) + * - int pass_get_cpu_stats(struct pass_resource *res) * - int64_t pass_get_time_ms(void) */ /* Get the load_table of each resource to estimate the system load. */ -int pass_get_cpu_stats(struct pass_policy *policy) +int pass_get_cpu_stats(struct pass_resource *res) { + struct pass_policy *policy; struct pass_cpu_stats *stats; - struct pass_resource *res; char str[BUFF_MAX]; FILE *fp_stats = NULL; int i, j, ret; - if (!policy) + if (!res) return -EINVAL; + policy = &res->policy; stats = policy->pass_cpu_stats; res = to_pass_resource(policy); diff --git a/src/pass/pass-hal.h b/src/pass/pass-hal.h index c5c0da0..172b0a4 100644 --- a/src/pass/pass-hal.h +++ b/src/pass/pass-hal.h @@ -79,7 +79,7 @@ int pass_set_online_max_num(struct pass_resource *res, int num); * FXIME: Following function is not standard interface. * These functions will be altered by the standard interface on later. */ -int pass_get_cpu_stats(struct pass_policy *policy); +int pass_get_cpu_stats(struct pass_resource *res); /*** * Functions for Memory h/w resource diff --git a/src/pass/pass-parser.c b/src/pass/pass-parser.c index 121a606..ade6407 100644 --- a/src/pass/pass-parser.c +++ b/src/pass/pass-parser.c @@ -324,10 +324,16 @@ out: return 0; } -int pass_get_table(struct pass_policy *policy, char *pass_conf_path) +int pass_get_table(struct pass_resource *res, char *pass_conf_path) { + struct pass_policy *policy; int ret; + if (!res) + return -EINVAL; + + policy = &res->policy; + policy->state = PASS_UNUSED; policy->pmqos.state = PASS_UNUSED; @@ -353,7 +359,6 @@ int pass_get_table(struct pass_policy *policy, char *pass_conf_path) } /* - struct pass_resource *res = to_pass_resource(policy); int level; _I("%s| policy->state : %d\n", @@ -474,8 +479,17 @@ int pass_get_table(struct pass_policy *policy, char *pass_conf_path) return 0; } -void pass_put_table(struct pass_policy *policy) +void pass_put_table(struct pass_resource *res) { + struct pass_policy *policy; + + if (!res) { + _E("cannot put pass table\n"); + return; + } + + policy = &res->policy; + if (policy->levels) { free(policy->levels); policy->levels = NULL; diff --git a/src/pass/pass-parser.h b/src/pass/pass-parser.h index 81c6674..5de7643 100644 --- a/src/pass/pass-parser.h +++ b/src/pass/pass-parser.h @@ -21,8 +21,9 @@ #include "pass.h" -int pass_get_table(struct pass_policy *policy, char *pass_conf_path); -void pass_put_table(struct pass_policy *policy); +int pass_get_table(struct pass_resource *res, char *pass_conf_path); +void pass_put_table(struct pass_resource *res); + int pass_get_resource_config(struct pass *pass, char *pass_conf_path); void pass_put_resource_config(struct pass *pass); diff --git a/src/pass/pass-pmqos.c b/src/pass/pass-pmqos.c index ba9b7e7..22668b2 100644 --- a/src/pass/pass-pmqos.c +++ b/src/pass/pass-pmqos.c @@ -100,9 +100,9 @@ static int find_scenario_index(struct pass_pmqos *pmqos, char *name) * pass_notifier_pmqos - Callback function of DEVICE_NOTIFIER_PMQOS notifier * @data: the scenario name */ -int pass_notifier_pmqos_func(struct pass_policy *policy, void *data) +int pass_notifier_pmqos_func(struct pass_resource *res, void *data) { - struct pass_resource *res; + struct pass_policy *policy; struct pass_conf_data *cdata; struct pass_pmqos *pmqos; struct pass_scenario *scn = NULL; @@ -113,10 +113,14 @@ int pass_notifier_pmqos_func(struct pass_policy *policy, void *data) unsigned int max_level = 0; int index = -1; + if (!res) + return -EINVAL; + + policy = &res->policy; + if (!is_pmqos_enabled(policy)) return 0; - res = to_pass_resource(policy); cdata = &res->cdata; pmqos = &policy->pmqos; @@ -188,8 +192,7 @@ int pass_notifier_pmqos_func(struct pass_policy *policy, void *data) } } - pass_rescon_set_level_scope(policy, new_level, - min_level, max_level, data); + pass_rescon_set_level_scope(res, new_level, min_level, max_level, data); if (scn->locked) { _I("Lock '%s' scenario for '%s' resource\n", diff --git a/src/pass/pass-pmqos.h b/src/pass/pass-pmqos.h index 6d8e4c0..4505479 100644 --- a/src/pass/pass-pmqos.h +++ b/src/pass/pass-pmqos.h @@ -21,8 +21,9 @@ /* * pass_notifier_pmqos - Callback function of DEVICE_NOTIFIER_PMQOS notifier + * @res : the instance of pass_resource * @data: the scenario name */ -int pass_notifier_pmqos_func(struct pass_policy *policy, void *data); +int pass_notifier_pmqos_func(struct pass_resource *res, void *data); #endif /* __PASS_PMQOS__ */ diff --git a/src/pass/pass-rescon.c b/src/pass/pass-rescon.c index 55dd8b5..120b430 100644 --- a/src/pass/pass-rescon.c +++ b/src/pass/pass-rescon.c @@ -63,22 +63,32 @@ static void hotplug_set_online(struct pass_policy *policy, /* * pass_rescon_set_level - Change frequency and number of online resources * - * @policy: the instance of struct pass_policy + * @res: the instance of struct pass_resource * @new_level: the desired pass level */ -int pass_rescon_set_level(struct pass_policy *policy, int new_level) +int pass_rescon_set_level(struct pass_resource *res, int new_level) { - struct pass_resource *res = to_pass_resource(policy); - struct pass_conf_data *cdata = &res->cdata; - struct pass_level *levels = policy->levels; - struct pass_hotplug *hotplug = policy->hotplug; - int curr_level = policy->curr_level; + struct pass_policy *policy; + struct pass_conf_data *cdata; + struct pass_level *levels; + struct pass_hotplug *hotplug; + int curr_level; int limit_max_freq; int limit_min_freq; int limit_min_cpu; int fault_around_bytes; int ret; + if (!res) + return -EINVAL; + + policy = &res->policy; + + cdata = &res->cdata; + levels = policy->levels; + hotplug = policy->hotplug; + curr_level = policy->curr_level; + if (new_level > policy->max_level) new_level = policy->max_level; @@ -99,7 +109,7 @@ int pass_rescon_set_level(struct pass_policy *policy, int new_level) /* Turn on/off CPUs according the maximum number of online CPU */ if (hotplug) { if (hotplug->governor) - limit_min_cpu = hotplug->governor(policy); + limit_min_cpu = hotplug->governor(res); else limit_min_cpu = 1; @@ -150,17 +160,20 @@ int pass_rescon_set_level(struct pass_policy *policy, int new_level) /* * pass_rescon_set_level_scope - Change the scope of pass level * - * @policy: the instance of struct pass_policy + * @res: the instance of struct pass_resource * @new_level: the desirous pass level * @min_level: the minimum pass level * @max_level: the maximum pass level * @data: the PMQoS's data containing the scenario name and lock state */ -int pass_rescon_set_level_scope(struct pass_policy *policy, int new_level, +int pass_rescon_set_level_scope(struct pass_resource *res, int new_level, int min_level, int max_level, void *data) { - if (!policy) + struct pass_policy *policy; + + if (!res) return -EINVAL; + policy = &res->policy; /* * FIXME: PMQoS core sends the raw data to the HAL in order to @@ -168,7 +181,7 @@ int pass_rescon_set_level_scope(struct pass_policy *policy, int new_level, * be removed after finding the proper method. */ if (data) - pass_set_pmqos_data(to_pass_resource(policy), data); + pass_set_pmqos_data(res, data); if (min_level > max_level) { _E("min_level(%d) have to be smaller than max_level(%d)\n", @@ -184,7 +197,7 @@ int pass_rescon_set_level_scope(struct pass_policy *policy, int new_level, policy->min_level = min_level; policy->max_level = max_level; - pass_rescon_set_level(policy, new_level); + pass_rescon_set_level(res, new_level); return 0; } diff --git a/src/pass/pass-rescon.h b/src/pass/pass-rescon.h index 00bbcce..e98a407 100644 --- a/src/pass/pass-rescon.h +++ b/src/pass/pass-rescon.h @@ -19,7 +19,7 @@ #ifndef __PASS_RESCON__ #define __PASS_RESCON__ -int pass_rescon_set_level(struct pass_policy *policy, int new_level); -int pass_rescon_set_level_scope(struct pass_policy *policy, int new_level, +int pass_rescon_set_level(struct pass_resource *res, int new_level); +int pass_rescon_set_level_scope(struct pass_resource *res, int new_level, int min_level, int max_level, void *data); #endif /* __PASS_RESCON__ */ diff --git a/src/pass/pass.c b/src/pass/pass.c index bb32453..3d96a21 100644 --- a/src/pass/pass.c +++ b/src/pass/pass.c @@ -124,10 +124,8 @@ static int pass_init_resource(struct pass_resource *res) int ret; int i; - /* - * Initialize pass-table by parsing pass.conf - */ - ret = pass_get_table(policy, res->cdata.path_conf_file); + /* Get configuration of each resource from pass-resource*.conf */ + ret = pass_get_table(res, res->cdata.path_conf_file); if (ret < 0) { _E("cannot parse %s\n", res->cdata.path_conf_file); return -1; @@ -191,14 +189,14 @@ static int pass_init_resource(struct pass_resource *res) } /* Get the instance of PASS governor */ - policy->governor = pass_get_governor(policy, policy->gov_type); + policy->governor = pass_get_governor(res, policy->gov_type); if (!policy->governor) { _E("cannot get the instance of PASS governor"); return -1; } /* Get the instance of PASS hotplug */ - policy->hotplug = pass_get_hotplug(policy, policy->gov_type); + policy->hotplug = pass_get_hotplug(res, policy->gov_type); if (policy->hotplug) { policy->hotplug->sequence = calloc(res->cdata.num_cpus, sizeof(int)); @@ -208,7 +206,7 @@ static int pass_init_resource(struct pass_resource *res) policy->hotplug->num_cpus = res->cdata.num_cpus; } - ret = pass_governor_init(policy); + ret = pass_governor_init(res); if (ret < 0) { _E("cannot initialize PASS governor"); return -1; @@ -222,9 +220,10 @@ static int pass_exit_resource(struct pass_resource *res) struct pass_policy *policy = &res->policy; int ret; - pass_put_table(policy); + /* Put configuration of each resource from pass-resource*.conf */ + pass_put_table(res); - ret = pass_governor_exit(policy); + ret = pass_governor_exit(res); if (ret < 0) { _E("cannot exit PASS governor"); return -1; @@ -239,7 +238,7 @@ static int pass_init_done(void *data, void *user_data) { int i, ret; - /* Parse configuration file (/etc/pass/pass.conf) */ + /* Get configuration of resource list from pass.conf */ ret = pass_get_resource_config(&g_pass, PASS_CONF_PATH); if (ret < 0) { _E("cannot parse %s\n", PASS_CONF_PATH); @@ -344,6 +343,7 @@ static int pass_exit_done(void) res->state = PASS_OFF; } + /* Put configuration of resource list from pass.conf */ pass_put_resource_config(&g_pass); g_pass.state = PASS_OFF; diff --git a/src/pass/pass.h b/src/pass/pass.h index 9f18fe1..e16420b 100644 --- a/src/pass/pass.h +++ b/src/pass/pass.h @@ -33,7 +33,9 @@ ******************************************************/ #define PASS_LEVEL_COND_MAX 3 +struct pass_resource; struct pass_policy; +struct pass_governor; /* * PASS state @@ -68,8 +70,6 @@ enum pass_gov_type { PASS_GOV_END, }; -struct pass_governor; - /****************************************************** * PASS basic data * ******************************************************/ @@ -186,7 +186,7 @@ struct pass_hotplug { unsigned int num_cpus; unsigned int online; unsigned int *sequence; - int (*governor)(struct pass_policy *); + int (*governor)(struct pass_resource *res); }; -- 2.7.4 From 5b90258d3e62566df71e68d502ad777eeb054c56 Mon Sep 17 00:00:00 2001 From: Jinhee Choi Date: Wed, 20 Dec 2017 10:52:30 +0900 Subject: [PATCH 06/16] pass: hal: Fix wrong format string of stat.load variable This patch fixes the wrong format string of stat.load variable from "%d" to "%u" because stat.load[] variable is unsigned integer. Change-Id: Ic8d28782b36690242a3503f6967e9fd8bf550f11 Signed-off-by: Jinhee Choi [cw00.choi: Add the patch description' Signed-off-by: Chanwoo Choi --- src/pass/pass-hal.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pass/pass-hal.c b/src/pass/pass-hal.c index 78bb2d6..aec3fd2 100644 --- a/src/pass/pass-hal.c +++ b/src/pass/pass-hal.c @@ -1036,7 +1036,7 @@ int pass_get_cpu_stats(struct pass_resource *res) } for (j = 0; j < res->cdata.num_cpus; j++) { - ret = fscanf(fp_stats, "%d", &stats[i].load[j]); + ret = fscanf(fp_stats, "%u", &stats[i].load[j]); if (ret < 0) { fclose(fp_stats); return -EIO; -- 2.7.4 From 0aad62b41efe33eef122ce10e77b5f7c40a98941 Mon Sep 17 00:00:00 2001 From: Chanwoo Choi Date: Wed, 20 Dec 2017 10:55:00 +0900 Subject: [PATCH 07/16] pass: hal: Fix wrong format string of variables in struct pass_cpu_stats This patch fixes the wrong format string of variables in the struct pass_cpu_stats from "%d" to "%u" because variables are unsigned integer. Change-Id: Iff5fceccd641a8146667e66322538464871f0e43 Signed-off-by: Chanwoo Choi --- src/pass/pass-hal.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pass/pass-hal.c b/src/pass/pass-hal.c index aec3fd2..f9ddf36 100644 --- a/src/pass/pass-hal.c +++ b/src/pass/pass-hal.c @@ -1025,7 +1025,7 @@ int pass_get_cpu_stats(struct pass_resource *res) } for (i = 0; i < policy->num_pass_cpu_stats; i++) { - ret = fscanf(fp_stats, "%" SCNd64 "%d %d %d", + ret = fscanf(fp_stats, "%" SCNd64 "%u %u %u", &stats[i].time, &stats[i].freq, &stats[i].freq_new, -- 2.7.4 From 266add1406553d547a40a4bf6b6259c40c6dc86a Mon Sep 17 00:00:00 2001 From: Chanwoo Choi Date: Wed, 20 Dec 2017 13:47:22 +0900 Subject: [PATCH 08/16] pass: gov: Fix bug for governor state of each h/w resource The commit 6133e7040ab49 ("pass: gov: Move private structure from pass.h to pass-gov.h") moved the 'gov_state' variable from 'struct pass_policy' to 'struct pass_governor'. It was wrong because each pass_policy should contain the their own state of governor. So, this patch moves the 'gov_state' variable to the 'struct pass_policy'. Change-Id: I840c3ccf727ede1fc94de489b13c1703dc0d5d57 Fixes: 6133e7040ab49 ("pass: gov: Move private structure from pass.h to pass-gov.h") Signed-off-by: Chanwoo Choi --- src/pass/pass-gov.c | 10 +++++----- src/pass/pass-gov.h | 6 ------ src/pass/pass.h | 7 +++++++ 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/src/pass/pass-gov.c b/src/pass/pass-gov.c index aa511a9..19febfd 100644 --- a/src/pass/pass-gov.c +++ b/src/pass/pass-gov.c @@ -51,7 +51,7 @@ struct pass_governor { */ static bool is_enabled(struct pass_policy *policy) { - if (policy->governor->gov_state != PASS_GOV_START) + if (policy->gov_state != PASS_GOV_START) return false; return true; @@ -348,7 +348,7 @@ static void __pass_governor_start(struct pass_resource *res) pass_rescon_set_level(res, policy->init_level); /* Set PASS state as PASS_GOV_START */ - policy->governor->gov_state = PASS_GOV_START; + policy->gov_state = PASS_GOV_START; _I("Start governor for '%s' resource", cdata->res_name); } @@ -367,7 +367,7 @@ static void __pass_governor_stop(struct pass_resource *res) return; } - if (policy->governor->gov_state == PASS_GOV_STOP) { + if (policy->gov_state == PASS_GOV_STOP) { _E("PASS governor is already inactive state"); return; } @@ -380,7 +380,7 @@ static void __pass_governor_stop(struct pass_resource *res) } /* Set PASS state as PASS_GOV_STOP */ - policy->governor->gov_state = PASS_GOV_STOP; + policy->gov_state = PASS_GOV_STOP; _I("Stop governor for '%s' resource", cdata->res_name); } @@ -397,7 +397,7 @@ static int __pass_governor_init(struct pass_resource *res) } /* Set default PASS state */ - policy->governor->gov_state = PASS_GOV_STOP; + policy->gov_state = PASS_GOV_STOP; ret = pass_notifier_init(res); if (ret < 0) { _E("cannot initialize notifier for the pmqos (%d)\n", ret); diff --git a/src/pass/pass-gov.h b/src/pass/pass-gov.h index f91e678..8221898 100644 --- a/src/pass/pass-gov.h +++ b/src/pass/pass-gov.h @@ -19,12 +19,6 @@ #ifndef __PASS_GOV__ #define __PASS_GOV__ -enum pass_gov_state { - PASS_GOV_NONE = 0, - PASS_GOV_START, - PASS_GOV_STOP, -}; - /* Init, exit and update the governor */ int pass_governor_init(struct pass_resource *res); int pass_governor_exit(struct pass_resource *res); diff --git a/src/pass/pass.h b/src/pass/pass.h index e16420b..c5959fd 100644 --- a/src/pass/pass.h +++ b/src/pass/pass.h @@ -70,6 +70,12 @@ enum pass_gov_type { PASS_GOV_END, }; +enum pass_gov_state { + PASS_GOV_NONE = 0, + PASS_GOV_START, + PASS_GOV_STOP, +}; + /****************************************************** * PASS basic data * ******************************************************/ @@ -225,6 +231,7 @@ struct pass_pmqos { struct pass_policy { enum pass_state state; enum pass_gov_type gov_type; + enum pass_gov_state gov_state; unsigned int pass_cpu_threshold; unsigned int up_threshold; unsigned int down_threshold; -- 2.7.4 From 7a813b1906af07dbc43c6a2934afe0f6b855c530 Mon Sep 17 00:00:00 2001 From: Dongwoo Lee Date: Thu, 25 Jan 2018 09:34:13 +0900 Subject: [PATCH 09/16] pass: parser: Simplify parsing function of 'Level' section The pass_parse_level() function is used for parsing 'Level%d' section. Simplify the function's definition as following. Now, PASS uses the 'level' concept which indicating the basic unit in order to initialize the h/w resource. In the next time, PASS will use both 'global level' and 'local level' concept. The changed pass_parse_level() is better to support both 'global level' and 'local level'. [Before] - pass_parse_level(struct parse_result *result, void *user_data, int level) [After] - pass_parse_level(struct parse_result *result, struct pass_level level) Change-Id: Ib98b419d14e46f36de559b0f2b32c9fe63fc5bf4 Signed-off-by: Dongwoo Lee [cw00.choi: Apply dongwoo's patch and document the description] Signed-off-by: Chanwoo Choi --- src/pass/pass-parser.c | 52 ++++++++++++++++++++++++-------------------------- 1 file changed, 25 insertions(+), 27 deletions(-) diff --git a/src/pass/pass-parser.c b/src/pass/pass-parser.c index ade6407..0ca513a 100644 --- a/src/pass/pass-parser.c +++ b/src/pass/pass-parser.c @@ -116,11 +116,9 @@ static int pass_parse_pmqos(struct parse_result *result, void *user_data, } static int pass_parse_level(struct parse_result *result, - void *user_data, int level) + struct pass_level *level) { - struct pass_policy *policy = user_data; - - if (!result) + if (!result || !level) return 0; if (!result->section || !result->name || !result->value) @@ -133,58 +131,58 @@ static int pass_parse_level(struct parse_result *result, * - PASS_RESOURCE_GPU_ID */ if (MATCH(result->name, "limit_max_freq")) - policy->levels[level].limit_max_freq = atoi(result->value); + level->limit_max_freq = atoi(result->value); else if (MATCH(result->name, "limit_min_freq")) - policy->levels[level].limit_min_freq = atoi(result->value); + level->limit_min_freq = atoi(result->value); else if (MATCH(result->name, "limit_min_cpu")) - policy->levels[level].limit_min_cpu = atoi(result->value); + level->limit_min_cpu = atoi(result->value); /* * Properties for the following h/w resources: * - PASS_RESOURCE_CPU_ID */ else if (MATCH(result->name, "num_down_cond")) - policy->levels[level].num_down_cond = atoi(result->value); + level->num_down_cond = atoi(result->value); else if (MATCH(result->name, "num_down_cond_freq")) - policy->levels[level].down_cond[0].freq = atoi(result->value); + level->down_cond[0].freq = atoi(result->value); else if (MATCH(result->name, "num_down_cond_nr_running")) - policy->levels[level].down_cond[0].nr_running = atoi(result->value); + level->down_cond[0].nr_running = atoi(result->value); else if (MATCH(result->name, "num_down_cond_busy_cpu")) - policy->levels[level].down_cond[0].busy_cpu = atoi(result->value); + level->down_cond[0].busy_cpu = atoi(result->value); else if (MATCH(result->name, "num_up_cond")) - policy->levels[level].num_up_cond = atoi(result->value); + level->num_up_cond = atoi(result->value); else if (MATCH(result->name, "num_up_cond_freq")) - policy->levels[level].up_cond[0].freq = atoi(result->value); + level->up_cond[0].freq = atoi(result->value); else if (MATCH(result->name, "num_up_cond_nr_running")) - policy->levels[level].up_cond[0].nr_running = atoi(result->value); + level->up_cond[0].nr_running = atoi(result->value); else if (MATCH(result->name, "num_up_cond_busy_cpu")) - policy->levels[level].up_cond[0].busy_cpu = atoi(result->value); + level->up_cond[0].busy_cpu = atoi(result->value); else if (MATCH(result->name, "num_left_cond")) - policy->levels[level].num_left_cond = atoi(result->value); + level->num_left_cond = atoi(result->value); else if (MATCH(result->name, "num_left_cond_freq")) - policy->levels[level].left_cond[0].freq = atoi(result->value); + level->left_cond[0].freq = atoi(result->value); else if (MATCH(result->name, "num_left_cond_nr_running")) - policy->levels[level].left_cond[0].nr_running = atoi(result->value); + level->left_cond[0].nr_running = atoi(result->value); else if (MATCH(result->name, "num_left_cond_busy_cpu")) - policy->levels[level].left_cond[0].busy_cpu = atoi(result->value); + level->left_cond[0].busy_cpu = atoi(result->value); else if (MATCH(result->name, "num_right_cond")) - policy->levels[level].num_right_cond = atoi(result->value); + level->num_right_cond = atoi(result->value); else if (MATCH(result->name, "num_right_cond_freq")) - policy->levels[level].right_cond[0].freq = atoi(result->value); + level->right_cond[0].freq = atoi(result->value); else if (MATCH(result->name, "num_right_cond_nr_running")) - policy->levels[level].right_cond[0].nr_running = atoi(result->value); + level->right_cond[0].nr_running = atoi(result->value); else if (MATCH(result->name, "num_right_cond_busy_cpu")) - policy->levels[level].right_cond[0].busy_cpu = atoi(result->value); + level->right_cond[0].busy_cpu = atoi(result->value); else if (MATCH(result->name, "gov_timeout")) { double gov_timeout = atof(result->value); if (gov_timeout < MIN_TIMEOUT_SEC) gov_timeout = MIN_TIMEOUT_SEC; - policy->levels[level].gov_timeout = gov_timeout; + level->gov_timeout = gov_timeout; } /* @@ -192,7 +190,7 @@ static int pass_parse_level(struct parse_result *result, * - PASS_RESOURCE_MEMORY_ID */ else if (MATCH(result->name, "fault_around_bytes")) - policy->levels[level].fault_around_bytes = atoi(result->value); + level->fault_around_bytes = atoi(result->value); return 0; } @@ -279,12 +277,12 @@ static int pass_load_config(struct parse_result *result, void *user_data) goto out; } - /* Parsing 'Level' section to get pass-table */ + /* Parsing 'Level' section */ for (level = 0; level < policy->num_levels; level++) { ret = snprintf(section_name, BUFF_MAX, "Level%d", level); if (MATCH(result->section, section_name)) { - ret = pass_parse_level(result, user_data, level); + ret = pass_parse_level(result, &policy->levels[level]); if (ret < 0) { _E("cannot parse 'Level' section\n"); return ret; -- 2.7.4 From 348b9916269091b15520e1a5c699f00d1dd4023a Mon Sep 17 00:00:00 2001 From: Chanwoo Choi Date: Thu, 25 Jan 2018 10:49:46 +0900 Subject: [PATCH 10/16] pass: parser: Clean-up exported parsing function to improve readability Clean-up exported parsing function in order to improve readability and keep the consistency. Describe the detailed clean-up as following: - Reorder exported functions into pass-parser.c - Change the function name to improve readability and keep the consistency like pass_get/put_resource_config() as following: pass_get_table() -> pass_get_each_resource_config() pass_put_table() -> pass_put_each_resource_config() - Modify argument name from 'path_conf_path' to 'path' Change-Id: Ic8d517855c95e1a29ba5d6e4b62693c7b150e223 Signed-off-by: Chanwoo Choi --- src/pass/pass-parser.c | 387 ++++++++++++++++++++++++++----------------------- src/pass/pass-parser.h | 8 +- src/pass/pass.c | 4 +- 3 files changed, 211 insertions(+), 188 deletions(-) diff --git a/src/pass/pass-parser.c b/src/pass/pass-parser.c index 0ca513a..125f341 100644 --- a/src/pass/pass-parser.c +++ b/src/pass/pass-parser.c @@ -322,185 +322,6 @@ out: return 0; } -int pass_get_table(struct pass_resource *res, char *pass_conf_path) -{ - struct pass_policy *policy; - int ret; - - if (!res) - return -EINVAL; - - policy = &res->policy; - - policy->state = PASS_UNUSED; - policy->pmqos.state = PASS_UNUSED; - - policy->state = 0; - policy->gov_type = 0; - policy->num_levels = 0; - policy->min_level = 0; - policy->max_level = 0; - policy->num_pass_cpu_stats = 0; - policy->pass_cpu_threshold = 0; - policy->up_threshold = 0; - policy->down_threshold = 0; - policy->init_level = 0; - policy->prev_level = policy->init_level; - policy->level_up_threshold = 0; - policy->gov_timeout = 0; - policy->last_time = 0; - - ret = config_parse(pass_conf_path, pass_load_config, policy); - if (ret < 0) { - _E("cannot parse %s\n", pass_conf_path); - return -EINVAL; - } - - /* - int level; - - _I("%s| policy->state : %d\n", - res->cdata.res_name, policy->state); - _I("%s| policy->gov_type : %d\n", - res->cdata.res_name, policy->gov_type); - _I("%s| policy->num_levels : %d\n", - res->cdata.res_name, policy->num_levels); - _I("%s| policy->min_level : %d\n", - res->cdata.res_name, policy->min_level); - _I("%s| policy->max_level : %d\n", - res->cdata.res_name, policy->max_level); - _I("%s| policy->num_pass_cpu_stats : %d\n", - res->cdata.res_name, policy->num_pass_cpu_stats); - _I("%s| policy->pass_cpu_threshold : %d\n", - res->cdata.res_name, policy->pass_cpu_threshold); - _I("%s| policy->up_threshold : %d\n", - res->cdata.res_name, policy->up_threshold); - _I("%s| policy->down_threshold : %d\n", - res->cdata.res_name, policy->down_threshold); - _I("%s| policy->init_level : %d\n", - res->cdata.res_name, policy->init_level); - _I("%s| policy->level_up_threshold : %d\n", - res->cdata.res_name, policy->level_up_threshold); - _I("%s| policy->gov_timeout : %f\n", - res->cdata.res_name, policy->gov_timeout); - - for (level = 0; level < policy->num_levels; level++) { - _I("================================================\n"); - if (policy->levels[level].limit_max_freq) - _I("%s| policy->levels[%d].limit_max_freq : %d\n", - res->cdata.res_name, level, - policy->levels[level].limit_max_freq); - if (policy->levels[level].limit_min_freq) - _I("%s| policy->levels[%d].limit_min_freq : %d\n", - res->cdata.res_name, level, - policy->levels[level].limit_min_freq); - if (policy->levels[level].limit_min_cpu) - _I("%s| policy->levels[%d].limit_min_cpu : %d\n", - res->cdata.res_name, level, - policy->levels[level].limit_min_cpu); - if (policy->levels[level].gov_timeout) - _I("%s| policy->levels[%d].gov_timeout : %f\n", - res->cdata.res_name, level, - policy->levels[level].gov_timeout); - - if (policy->levels[level].num_down_cond) - _I("%s| policy->levels[%d].num_down_cond : %d\n", - res->cdata.res_name, level, - policy->levels[level].num_down_cond); - if (policy->levels[level].down_cond[0].freq) - _I("%s| policy->levels[%d].down_cond[0].freq : %d\n", - res->cdata.res_name, level, - policy->levels[level].down_cond[0].freq); - if (policy->levels[level].down_cond[0].nr_running) - _I("%s| policy->levels[%d].down_cond[0].nr_running : %d\n", - res->cdata.res_name, level, - policy->levels[level].down_cond[0].nr_running); - if (policy->levels[level].down_cond[0].busy_cpu) - _I("%s| policy->levels[%d].down_cond[0].busy_cpu : %d\n", - res->cdata.res_name, level, - policy->levels[level].down_cond[0].busy_cpu); - - if (policy->levels[level].num_up_cond) - _I("%s| policy->levels[%d].num_up_cond : %d\n", - res->cdata.res_name, level, - policy->levels[level].num_up_cond); - if (policy->levels[level].up_cond[0].freq) - _I("%s| policy->levels[%d].up_cond[0].freq : %d\n", - res->cdata.res_name, level, - policy->levels[level].up_cond[0].freq); - if (policy->levels[level].up_cond[0].nr_running) - _I("%s| policy->levels[%d].up_cond[0].nr_running : %d\n", - res->cdata.res_name, level, - policy->levels[level].up_cond[0].nr_running); - if (policy->levels[level].up_cond[0].busy_cpu) - _I("%s| policy->levels[%d].up_cond[0].busy_cpu : %d\n", - res->cdata.res_name, level, - policy->levels[level].up_cond[0].busy_cpu); - - if (policy->levels[level].num_left_cond) - _I("%s| policy->levels[%d].num_left_cond : %d\n", - res->cdata.res_name, level, - policy->levels[level].num_left_cond); - if (policy->levels[level].left_cond[0].freq) - _I("%s| policy->levels[%d].left_cond[0].freq : %d\n", - res->cdata.res_name, level, policy->levels[level].left_cond[0].freq); - if (policy->levels[level].left_cond[0].nr_running) - _I("%s| policy->levels[%d].left_cond[0].nr_running : %d\n", - res->cdata.res_name, level, policy->levels[level].left_cond[0].nr_running); - if (policy->levels[level].left_cond[0].busy_cpu) - _I("%s| policy->levels[%d].left_cond[0].busy_cpu : %d\n", - res->cdata.res_name, level, policy->levels[level].left_cond[0].busy_cpu); - - if (policy->levels[level].num_right_cond) - _I("%s| policy->levels[%d].num_right_cond : %d\n", - res->cdata.res_name, level, policy->levels[level].num_right_cond); - if (policy->levels[level].right_cond[0].freq) - _I("%s| policy->levels[%d].right_cond[0].freq : %d\n", - res->cdata.res_name, level, policy->levels[level].right_cond[0].freq); - if (policy->levels[level].right_cond[0].nr_running) - _I("%s| policy->levels[%d].right_cond[0].nr_running : %d\n", - res->cdata.res_name, level, policy->levels[level].right_cond[0].nr_running); - if (policy->levels[level].right_cond[0].busy_cpu) - _I("%s| policy->levels[%d].right_cond[0].busy_cpu : %d\n", - res->cdata.res_name, level, policy->levels[level].right_cond[0].busy_cpu); - } - */ - - if (policy->state == PASS_UNUSED) - return -EINVAL; - - if (policy->pmqos.state == PASS_UNUSED) - _W("%s don't include the list of pass-scenario\n"); - else if (policy->pmqos.state == PASS_OFF) - _I("cannot use pass-scenario"); - - return 0; -} - -void pass_put_table(struct pass_resource *res) -{ - struct pass_policy *policy; - - if (!res) { - _E("cannot put pass table\n"); - return; - } - - policy = &res->policy; - - if (policy->levels) { - free(policy->levels); - policy->levels = NULL; - } - - if (policy->pmqos.scenarios) { - free(policy->pmqos.scenarios); - policy->pmqos.scenarios = NULL; - } - - policy->pmqos.num_scenarios = 0; -} - static int pass_parse_resource_data(struct parse_result *result, void *user_data, int id) { @@ -562,6 +383,7 @@ static int pass_parse_resource_data(struct parse_result *result, return 0; } + static int check_compatible(char *compatible, char *path_compatible) { char buf[BUFF_MAX]; @@ -596,7 +418,7 @@ static int check_compatible(char *compatible, char *path_compatible) return 0; } -static int pass_resource_config(struct parse_result *result, void *user_data) +static int parse_resource(struct parse_result *result, void *user_data) { static char path_compatible[BUFF_MAX]; static bool is_compatible = false; @@ -700,14 +522,215 @@ static int pass_resource_config(struct parse_result *result, void *user_data) return 0; } -int pass_get_resource_config(struct pass *pass, char *pass_conf_path) +/* + * pass_get_resource_config - Get all h/w resource information + * + * @pass: the instance of struct pass which contains all information + * @path: the path of configuration files (e.g., /etc/pass/pass.conf) + */ +int pass_get_resource_config(struct pass *pass, char *path) { - return config_parse(pass_conf_path, pass_resource_config, pass); + return config_parse(path, parse_resource, pass); } +/* + * pass_get_resource_config - Free h/w resource information + * + * @pass: the instance of struct pass which contains all information + */ void pass_put_resource_config(struct pass *pass) { free(pass->res); pass->res = NULL; pass->num_resources = 0; } + +/* + * pass_get_each_resource_config - Get each h/w resource information + * + * @res: the instance of struct pass_resource + * @path: the path of configuration file for each h/w resource + */ +int pass_get_each_resource_config(struct pass_resource *res, char *path) +{ + struct pass_policy *policy; + int ret; + + if (!res) + return -EINVAL; + + policy = &res->policy; + + policy->state = PASS_UNUSED; + policy->pmqos.state = PASS_UNUSED; + + policy->state = 0; + policy->gov_type = 0; + policy->num_levels = 0; + policy->min_level = 0; + policy->max_level = 0; + policy->num_pass_cpu_stats = 0; + policy->pass_cpu_threshold = 0; + policy->up_threshold = 0; + policy->down_threshold = 0; + policy->init_level = 0; + policy->prev_level = policy->init_level; + policy->level_up_threshold = 0; + policy->gov_timeout = 0; + policy->last_time = 0; + + ret = config_parse(path, pass_load_config, policy); + if (ret < 0) { + _E("cannot parse %s\n", path); + return -EINVAL; + } + + /* + int level; + + _I("%s| policy->state : %d\n", + res->cdata.res_name, policy->state); + _I("%s| policy->gov_type : %d\n", + res->cdata.res_name, policy->gov_type); + _I("%s| policy->num_levels : %d\n", + res->cdata.res_name, policy->num_levels); + _I("%s| policy->min_level : %d\n", + res->cdata.res_name, policy->min_level); + _I("%s| policy->max_level : %d\n", + res->cdata.res_name, policy->max_level); + _I("%s| policy->num_pass_cpu_stats : %d\n", + res->cdata.res_name, policy->num_pass_cpu_stats); + _I("%s| policy->pass_cpu_threshold : %d\n", + res->cdata.res_name, policy->pass_cpu_threshold); + _I("%s| policy->up_threshold : %d\n", + res->cdata.res_name, policy->up_threshold); + _I("%s| policy->down_threshold : %d\n", + res->cdata.res_name, policy->down_threshold); + _I("%s| policy->init_level : %d\n", + res->cdata.res_name, policy->init_level); + _I("%s| policy->level_up_threshold : %d\n", + res->cdata.res_name, policy->level_up_threshold); + _I("%s| policy->gov_timeout : %f\n", + res->cdata.res_name, policy->gov_timeout); + + for (level = 0; level < policy->num_levels; level++) { + _I("================================================\n"); + if (policy->levels[level].limit_max_freq) + _I("%s| policy->levels[%d].limit_max_freq : %d\n", + res->cdata.res_name, level, + policy->levels[level].limit_max_freq); + if (policy->levels[level].limit_min_freq) + _I("%s| policy->levels[%d].limit_min_freq : %d\n", + res->cdata.res_name, level, + policy->levels[level].limit_min_freq); + if (policy->levels[level].limit_min_cpu) + _I("%s| policy->levels[%d].limit_min_cpu : %d\n", + res->cdata.res_name, level, + policy->levels[level].limit_min_cpu); + if (policy->levels[level].gov_timeout) + _I("%s| policy->levels[%d].gov_timeout : %f\n", + res->cdata.res_name, level, + policy->levels[level].gov_timeout); + + if (policy->levels[level].num_down_cond) + _I("%s| policy->levels[%d].num_down_cond : %d\n", + res->cdata.res_name, level, + policy->levels[level].num_down_cond); + if (policy->levels[level].down_cond[0].freq) + _I("%s| policy->levels[%d].down_cond[0].freq : %d\n", + res->cdata.res_name, level, + policy->levels[level].down_cond[0].freq); + if (policy->levels[level].down_cond[0].nr_running) + _I("%s| policy->levels[%d].down_cond[0].nr_running : %d\n", + res->cdata.res_name, level, + policy->levels[level].down_cond[0].nr_running); + if (policy->levels[level].down_cond[0].busy_cpu) + _I("%s| policy->levels[%d].down_cond[0].busy_cpu : %d\n", + res->cdata.res_name, level, + policy->levels[level].down_cond[0].busy_cpu); + + if (policy->levels[level].num_up_cond) + _I("%s| policy->levels[%d].num_up_cond : %d\n", + res->cdata.res_name, level, + policy->levels[level].num_up_cond); + if (policy->levels[level].up_cond[0].freq) + _I("%s| policy->levels[%d].up_cond[0].freq : %d\n", + res->cdata.res_name, level, + policy->levels[level].up_cond[0].freq); + if (policy->levels[level].up_cond[0].nr_running) + _I("%s| policy->levels[%d].up_cond[0].nr_running : %d\n", + res->cdata.res_name, level, + policy->levels[level].up_cond[0].nr_running); + if (policy->levels[level].up_cond[0].busy_cpu) + _I("%s| policy->levels[%d].up_cond[0].busy_cpu : %d\n", + res->cdata.res_name, level, + policy->levels[level].up_cond[0].busy_cpu); + + if (policy->levels[level].num_left_cond) + _I("%s| policy->levels[%d].num_left_cond : %d\n", + res->cdata.res_name, level, + policy->levels[level].num_left_cond); + if (policy->levels[level].left_cond[0].freq) + _I("%s| policy->levels[%d].left_cond[0].freq : %d\n", + res->cdata.res_name, level, policy->levels[level].left_cond[0].freq); + if (policy->levels[level].left_cond[0].nr_running) + _I("%s| policy->levels[%d].left_cond[0].nr_running : %d\n", + res->cdata.res_name, level, policy->levels[level].left_cond[0].nr_running); + if (policy->levels[level].left_cond[0].busy_cpu) + _I("%s| policy->levels[%d].left_cond[0].busy_cpu : %d\n", + res->cdata.res_name, level, policy->levels[level].left_cond[0].busy_cpu); + + if (policy->levels[level].num_right_cond) + _I("%s| policy->levels[%d].num_right_cond : %d\n", + res->cdata.res_name, level, policy->levels[level].num_right_cond); + if (policy->levels[level].right_cond[0].freq) + _I("%s| policy->levels[%d].right_cond[0].freq : %d\n", + res->cdata.res_name, level, policy->levels[level].right_cond[0].freq); + if (policy->levels[level].right_cond[0].nr_running) + _I("%s| policy->levels[%d].right_cond[0].nr_running : %d\n", + res->cdata.res_name, level, policy->levels[level].right_cond[0].nr_running); + if (policy->levels[level].right_cond[0].busy_cpu) + _I("%s| policy->levels[%d].right_cond[0].busy_cpu : %d\n", + res->cdata.res_name, level, policy->levels[level].right_cond[0].busy_cpu); + } + */ + + if (policy->state == PASS_UNUSED) + return -EINVAL; + + if (policy->pmqos.state == PASS_UNUSED) + _W("%s don't include the list of pass-scenario\n"); + else if (policy->pmqos.state == PASS_OFF) + _I("cannot use pass-scenario"); + + return 0; +} + +/* + * pass_put_each_resource_config - Free each h/w resource information + * + * @res: the instance of struct pass_resource + */ +void pass_put_each_resource_config(struct pass_resource *res) +{ + struct pass_policy *policy; + + if (!res) { + _E("cannot put pass table\n"); + return; + } + + policy = &res->policy; + + if (policy->levels) { + free(policy->levels); + policy->levels = NULL; + } + + if (policy->pmqos.scenarios) { + free(policy->pmqos.scenarios); + policy->pmqos.scenarios = NULL; + } + + policy->pmqos.num_scenarios = 0; +} diff --git a/src/pass/pass-parser.h b/src/pass/pass-parser.h index 5de7643..92726e1 100644 --- a/src/pass/pass-parser.h +++ b/src/pass/pass-parser.h @@ -21,10 +21,10 @@ #include "pass.h" -int pass_get_table(struct pass_resource *res, char *pass_conf_path); -void pass_put_table(struct pass_resource *res); - -int pass_get_resource_config(struct pass *pass, char *pass_conf_path); +int pass_get_resource_config(struct pass *pass, char *path); void pass_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); + #endif /* __PASS_PARSER__ */ diff --git a/src/pass/pass.c b/src/pass/pass.c index 3d96a21..9cf90d2 100644 --- a/src/pass/pass.c +++ b/src/pass/pass.c @@ -125,7 +125,7 @@ static int pass_init_resource(struct pass_resource *res) int i; /* Get configuration of each resource from pass-resource*.conf */ - ret = pass_get_table(res, res->cdata.path_conf_file); + ret = pass_get_each_resource_config(res, res->cdata.path_conf_file); if (ret < 0) { _E("cannot parse %s\n", res->cdata.path_conf_file); return -1; @@ -221,7 +221,7 @@ static int pass_exit_resource(struct pass_resource *res) int ret; /* Put configuration of each resource from pass-resource*.conf */ - pass_put_table(res); + pass_put_each_resource_config(res); ret = pass_governor_exit(res); if (ret < 0) { -- 2.7.4 From 08b38a7fa69b0d7ddb3b9a7c50fb6fdabb4f1d7c Mon Sep 17 00:00:00 2001 From: Chanwoo Choi Date: Thu, 25 Jan 2018 11:47:06 +0900 Subject: [PATCH 11/16] pass: parser: Clean-up internal parsing functions to improve readability Clean-up the internal parsing functions to improve the readability and consider the extensibility because 'parse_level' and 'parse_scenario' will be used on other features. Describe what are modified as following: - Remove 'pass_' prefix from internal function - Rename from check_compatible() to compare_compatible_name() - Split out parse_scenario() function from parse_pmqos() - Remove unneeded strlen() in the compare_compatible_name() - Remove unnedded semiconlon from switch statement [Detailed description of internal functions] - parse_core(): Parse 'Pass' section including info of CPUHP feature - parse_pmqos(): Parse 'PassScenario' section including info of PMQoS feature - parse_level(): Parse 'Level' section including info of each scenario - parse_scenario(): Parse 'Scenario' section including info of each level Change-Id: Ibc3d8a3a546b322ec610a5f84646ae46e545641c Signed-off-by: Chanwoo Choi --- src/pass/pass-parser.c | 215 +++++++++++++++++++++++-------------------------- src/pass/pass-parser.h | 2 +- 2 files changed, 104 insertions(+), 113 deletions(-) diff --git a/src/pass/pass-parser.c b/src/pass/pass-parser.c index 125f341..12e6ce7 100644 --- a/src/pass/pass-parser.c +++ b/src/pass/pass-parser.c @@ -1,7 +1,7 @@ /* * PASS (Power Aware System Service) Parser * - * Copyright (c) 2017 Samsung Electronics Co., Ltd. + * Copyright (c) 2017 - 2018 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. @@ -31,6 +31,33 @@ #define MAX_NUM 255 #define MIN_TIMEOUT_SEC 0.2 +static int compare_compatible_name(char *compatible, char *path_compatible) +{ + char buf[BUFF_MAX]; + int len, ret; + + ret = sys_get_str(path_compatible, buf); + if (ret < 0) { + _E("cannot read compatible path: %s\n", + path_compatible); + return -EINVAL; + } + + len = strlen(compatible); + if (!len) { + _E("cannot parse compatible\n"); + return -EINVAL; + } + + if (strncmp(compatible, buf, len)) { + _E("cannot match compatible pairs: conf = %s, read = %s\n", + compatible, buf); + return -EINVAL; + } + + return 0; +} + static enum pass_state is_supported(char *value) { enum pass_state state; @@ -48,74 +75,32 @@ static enum pass_state is_supported(char *value) return state; } -static int pass_parse_pmqos(struct parse_result *result, void *user_data, - unsigned int index) +static int parse_scenario(struct parse_result *result, + struct pass_scenario *scenario) { - struct pass_policy *policy = user_data; - struct pass_pmqos *pmqos = &policy->pmqos; - - if (!policy || !result) + if (!result || !scenario) return 0; if (!result->section || !result->name || !result->value) return 0; - /* Parse 'PassScenario' section */ - if (MATCH(result->section, "PassScenario")) { - if (MATCH(result->name, "pass_scenario_support")) { - pmqos->state = is_supported(result->value); - if (pmqos->state < 0) - return -EINVAL; - - } else if (MATCH(result->name, "pass_num_scenarios")) { - unsigned int num_scenarios; - - num_scenarios = atoi(result->value); - if (num_scenarios > MAX_NUM) { - _E("cannot parse %s\n", result->name); - return -EINVAL; - } - - if (num_scenarios > 0 && !pmqos->scenarios) { - pmqos->scenarios = calloc(num_scenarios, - sizeof(struct pass_scenario)); - if (!pmqos->scenarios) { - _E("cannot allocate memory for Scenario\n"); - return -EINVAL; - } - - pmqos->num_scenarios = num_scenarios; - } - } - } - - if (pmqos->state != PASS_ON) - return 0; - - if (!pmqos->num_scenarios) - return 0; - - if (index > pmqos->num_scenarios || index == PASS_UNUSED) - return 0; - /* Parse 'Scenario' section */ if (MATCH(result->name, "name")) { - snprintf(pmqos->scenarios[index].name, BUFF_MAX, "%s", - result->value); + snprintf(scenario->name, BUFF_MAX, "%s", result->value); } else if (MATCH(result->name, "support")) { - pmqos->scenarios[index].state = is_supported(result->value); - if (pmqos->scenarios[index].state < 0) + scenario->state = is_supported(result->value); + if (scenario->state < 0) return -EINVAL; } else if (MATCH(result->name, "min_level")) { - pmqos->scenarios[index].min_level = atoi(result->value); + scenario->min_level = atoi(result->value); } else if (MATCH(result->name, "max_level")) { - pmqos->scenarios[index].max_level = atoi(result->value); + scenario->max_level = atoi(result->value); } return 0; } -static int pass_parse_level(struct parse_result *result, +static int parse_level(struct parse_result *result, struct pass_level *level) { if (!result || !level) @@ -195,7 +180,48 @@ static int pass_parse_level(struct parse_result *result, return 0; } -static int pass_parse_core(struct parse_result *result, void *user_data) +static int parse_pmqos(struct parse_result *result, void *user_data) +{ + struct pass_policy *policy = user_data; + struct pass_pmqos *pmqos = &policy->pmqos; + + if (!policy || !result) + return 0; + + if (!result->section || !result->name || !result->value) + return 0; + + /* Parse 'PassScenario' section */ + if (MATCH(result->name, "pass_scenario_support")) { + pmqos->state = is_supported(result->value); + if (pmqos->state < 0) + return -EINVAL; + + } else if (MATCH(result->name, "pass_num_scenarios")) { + unsigned int num_scenarios; + + num_scenarios = atoi(result->value); + if (num_scenarios > MAX_NUM) { + _E("cannot parse %s\n", result->name); + return -EINVAL; + } + + if (num_scenarios > 0 && !pmqos->scenarios) { + pmqos->scenarios = calloc(num_scenarios, + sizeof(struct pass_scenario)); + if (!pmqos->scenarios) { + _E("cannot allocate memory for Scenario\n"); + return -EINVAL; + } + + pmqos->num_scenarios = num_scenarios; + } + } + + return 0; +} + +static int parse_core(struct parse_result *result, void *user_data) { struct pass_policy *policy = user_data; @@ -252,13 +278,12 @@ static int pass_parse_core(struct parse_result *result, void *user_data) return 0; } -static int pass_load_config(struct parse_result *result, void *user_data) +static int parse_each_resource(struct parse_result *result, void *user_data) { struct pass_policy *policy = user_data; + struct pass_pmqos *pmqos = &policy->pmqos; char section_name[BUFF_MAX]; - int level = PASS_UNUSED; - int index = PASS_UNUSED; - int ret; + int i, ret; if (!result) return 0; @@ -268,7 +293,7 @@ static int pass_load_config(struct parse_result *result, void *user_data) /* Parsing 'PASS' section */ if (MATCH(result->section, "Pass")) { - ret = pass_parse_core(result, user_data); + ret = parse_core(result, user_data); if (ret < 0) { _E("cannot parse the core part\n"); return ret; @@ -278,13 +303,13 @@ static int pass_load_config(struct parse_result *result, void *user_data) } /* Parsing 'Level' section */ - for (level = 0; level < policy->num_levels; level++) { - ret = snprintf(section_name, BUFF_MAX, "Level%d", level); + for (i = 0; i < policy->num_levels; i++) { + ret = snprintf(section_name, BUFF_MAX, "Level%d", i); if (MATCH(result->section, section_name)) { - ret = pass_parse_level(result, &policy->levels[level]); + ret = parse_level(result, &policy->levels[i]); if (ret < 0) { - _E("cannot parse 'Level' section\n"); + _E("cannot parse 'Level%d' section\n", i); return ret; } @@ -294,7 +319,7 @@ static int pass_load_config(struct parse_result *result, void *user_data) /* Parsing 'PassScenario' section */ if (MATCH(result->section, "PassScenario")) { - ret = pass_parse_pmqos(result, user_data, PASS_UNUSED); + ret = parse_pmqos(result, user_data); if (ret < 0) { _E("cannot parse 'PassScenario' section\n"); return ret; @@ -304,13 +329,13 @@ static int pass_load_config(struct parse_result *result, void *user_data) } /* Parsing 'Scenario' section */ - for (index = 0; index < policy->pmqos.num_scenarios; index++) { - ret = snprintf(section_name, BUFF_MAX, "Scenario%d", index); + for (i = 0; i < pmqos->num_scenarios; i++) { + ret = snprintf(section_name, BUFF_MAX, "Scenario%d", i); if (MATCH(result->section, section_name)) { - ret = pass_parse_pmqos(result, user_data, index); + ret = parse_scenario(result, &pmqos->scenarios[i]); if (ret < 0) { - _E("cannot parse 'Scenario' section\n"); + _E("cannot parse 'Scenario%d' section\n", i); return ret; } @@ -322,7 +347,7 @@ out: return 0; } -static int pass_parse_resource_data(struct parse_result *result, +static int parse_resource_data(struct parse_result *result, void *user_data, int id) { char buf[BUFF_MAX]; @@ -368,7 +393,7 @@ static int pass_parse_resource_data(struct parse_result *result, break; default: return -EINVAL; - }; + } } else if (MATCH(result->name, "pass_num_cpus")) { int res_type = conf_data->res_type; @@ -378,41 +403,7 @@ static int pass_parse_resource_data(struct parse_result *result, break; default: return -EINVAL; - }; - } - - return 0; -} - -static int check_compatible(char *compatible, char *path_compatible) -{ - char buf[BUFF_MAX]; - int len, ret; - - len = strlen(compatible); - if (!len) { - _E("cannot parse compatible\n"); - return -EINVAL; - } - - len = strlen(path_compatible); - if (!len) { - _E("cannot parse path_compatible\n"); - return -EINVAL; - } - - ret = sys_get_str(path_compatible, buf); - if (ret < 0) { - _E("cannot read compatible path: %s\n", - path_compatible); - return -EINVAL; - } - - len = strlen(compatible); - if (strncmp(compatible, buf, len)) { - _E("cannot match compatible pairs: conf = %s, read = %s\n", - compatible, buf); - return -EINVAL; + } } return 0; @@ -420,7 +411,7 @@ static int check_compatible(char *compatible, char *path_compatible) static int parse_resource(struct parse_result *result, void *user_data) { - static char path_compatible[BUFF_MAX]; + static char path[BUFF_MAX]; static bool is_compatible = false; static char compatible[BUFF_MAX]; struct pass *pass = user_data; @@ -439,9 +430,9 @@ static int parse_resource(struct parse_result *result, void *user_data) len = strlen(result->value); snprintf(compatible, len + 1, "%s", result->value); - len = strlen(path_compatible); + len = strlen(path); if (len > 0) { - ret = check_compatible(compatible, path_compatible); + ret = compare_compatible_name(compatible, path); if (ret < 0) return ret; @@ -449,11 +440,11 @@ static int parse_resource(struct parse_result *result, void *user_data) } } else if (MATCH(result->name, "pass_path_compatible")) { len = strlen(result->value); - snprintf(path_compatible, len + 1, "%s", result->value); + snprintf(path, len + 1, "%s", result->value); len = strlen(compatible); if (len > 0) { - ret = check_compatible(compatible, path_compatible); + ret = compare_compatible_name(compatible, path); if (ret < 0) return ret; @@ -507,10 +498,10 @@ static int parse_resource(struct parse_result *result, void *user_data) if (MATCH(section_name, result->section)) { if (!is_compatible) { - _E("cannot match [compatible] with the string read from [path_compatible]\n"); + _E("cannot match [compatible] with the string read from [path]\n"); return -EINVAL; } - ret = pass_parse_resource_data(result, pass, id); + ret = parse_resource_data(result, pass, id); if (ret < 0) { _E("cannot parse 'PassResource%d' section\n", id); @@ -579,7 +570,7 @@ int pass_get_each_resource_config(struct pass_resource *res, char *path) policy->gov_timeout = 0; policy->last_time = 0; - ret = config_parse(path, pass_load_config, policy); + ret = config_parse(path, parse_each_resource, policy); if (ret < 0) { _E("cannot parse %s\n", path); return -EINVAL; diff --git a/src/pass/pass-parser.h b/src/pass/pass-parser.h index 92726e1..1c5a440 100644 --- a/src/pass/pass-parser.h +++ b/src/pass/pass-parser.h @@ -1,7 +1,7 @@ /* * PASS (Power Aware System Service) Parser * - * Copyright (c) 2012 - 2017 Samsung Electronics Co., Ltd. + * Copyright (c) 2012 - 2018 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. -- 2.7.4 From 2b56936352562dad825c5d889fd99a97435e6618 Mon Sep 17 00:00:00 2001 From: Chanwoo Choi Date: Thu, 25 Jan 2018 17:11:07 +0900 Subject: [PATCH 12/16] pass: hal: Remove duplicate header file Remove the duplicate hal/hal.h header file because pass/pass-hal.h already includes the hal/hal.h header files. Change-Id: I06f6b26835c9efcd663074d502d9f431ddb9422f Signed-off-by: Chanwoo Choi --- src/pass/pass-hal.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/pass/pass-hal.c b/src/pass/pass-hal.c index f9ddf36..5ddc2a9 100644 --- a/src/pass/pass-hal.c +++ b/src/pass/pass-hal.c @@ -23,7 +23,6 @@ #include #include "pass.h" -#include "hal/hal.h" #include "pass-hal.h" #include "core/common.h" -- 2.7.4 From d79aa1b2103eebcd32cdf0ca1b2edb766d3fac26 Mon Sep 17 00:00:00 2001 From: Chanwoo Choi Date: Fri, 26 Jan 2018 08:58:40 +0900 Subject: [PATCH 13/16] pass: hal: Remove inefficient local variables Almost PASS hal function defines the 'res_type' and 'res_name' local variables. It is not efficient method. Use the variable of struct pass_resource directly instead of defining the separate local variables on each hal functions. Change-Id: Ia6719d65639777a4d90df0326adb0e2c66807e85 Signed-off-by: Chanwoo Choi --- src/pass/pass-hal.c | 301 +++++++++++++++------------------------------------- 1 file changed, 83 insertions(+), 218 deletions(-) diff --git a/src/pass/pass-hal.c b/src/pass/pass-hal.c index 5ddc2a9..48d1e33 100644 --- a/src/pass/pass-hal.c +++ b/src/pass/pass-hal.c @@ -89,451 +89,349 @@ static struct pass_resource_hotplug_ops *get_hotplug(struct pass_resource *res, int pass_get_curr_governor(struct pass_resource *res, char *governor) { struct pass_resource_dvfs_ops *dvfs; - char *res_name; - int res_type; if (!res || !governor) return -EINVAL; - res_name = res->cdata.res_name; - res_type = res->cdata.res_type; - - dvfs = get_dvfs(res, res_type); + dvfs = get_dvfs(res, res->cdata.res_type); if (!dvfs) return -EINVAL; if (!dvfs->get_curr_governor) return -EINVAL; - return dvfs->get_curr_governor(res_name, governor); + return dvfs->get_curr_governor(res->cdata.res_name, governor); } int pass_set_curr_governor(struct pass_resource *res, char *governor) { struct pass_resource_dvfs_ops *dvfs; - char *res_name; - int res_type; if (!res || !governor) return -EINVAL; - res_name = res->cdata.res_name; - res_type = res->cdata.res_type; - - dvfs = get_dvfs(res, res_type); + dvfs = get_dvfs(res, res->cdata.res_type); if (!dvfs) return -EINVAL; if (!dvfs->set_curr_governor) return -EINVAL; - return dvfs->set_curr_governor(res_name, governor); + return dvfs->set_curr_governor(res->cdata.res_name, governor); } /* Get and set the current/min/max frequency for DVFS resource. */ int pass_get_curr_freq(struct pass_resource *res) { struct pass_resource_dvfs_ops *dvfs; - char *res_name; - int res_type; if (!res) return -EINVAL; - res_name = res->cdata.res_name; - res_type = res->cdata.res_type; - - dvfs = get_dvfs(res, res_type); + dvfs = get_dvfs(res, res->cdata.res_type); if (!dvfs) return -EINVAL; if (!dvfs->get_curr_freq) return -EINVAL; - return dvfs->get_curr_freq(res_name); + return dvfs->get_curr_freq(res->cdata.res_name); } int pass_get_min_freq(struct pass_resource *res) { struct pass_resource_dvfs_ops *dvfs; - char *res_name; - int res_type; if (!res) return -EINVAL; - res_name = res->cdata.res_name; - res_type = res->cdata.res_type; - - dvfs = get_dvfs(res, res_type); + dvfs = get_dvfs(res, res->cdata.res_type); if (!dvfs) return -EINVAL; if (!dvfs->get_min_freq) return -EINVAL; - return dvfs->get_min_freq(res_name); + return dvfs->get_min_freq(res->cdata.res_name); } int pass_set_min_freq(struct pass_resource *res, int freq) { struct pass_resource_dvfs_ops *dvfs; - char *res_name; - int res_type; if (!res || freq < 0) return -EINVAL; - res_name = res->cdata.res_name; - res_type = res->cdata.res_type; - - dvfs = get_dvfs(res, res_type); + dvfs = get_dvfs(res, res->cdata.res_type); if (!dvfs) return -EINVAL; if (!dvfs->set_min_freq) return -EINVAL; - return dvfs->set_min_freq(res_name, freq); + return dvfs->set_min_freq(res->cdata.res_name, freq); } int pass_get_max_freq(struct pass_resource *res) { struct pass_resource_dvfs_ops *dvfs; - char *res_name; - int res_type; if (!res) return -EINVAL; - res_name = res->cdata.res_name; - res_type = res->cdata.res_type; - - dvfs = get_dvfs(res, res_type); + dvfs = get_dvfs(res, res->cdata.res_type); if (!dvfs) return -EINVAL; if (!dvfs->get_max_freq) return -EINVAL; - return dvfs->get_max_freq(res_name); + return dvfs->get_max_freq(res->cdata.res_name); } int pass_set_max_freq(struct pass_resource *res, int freq) { struct pass_resource_dvfs_ops *dvfs; - char *res_name; - int res_type; if (!res || freq < 0) return -EINVAL; - res_name = res->cdata.res_name; - res_type = res->cdata.res_type; - - dvfs = get_dvfs(res, res_type); + dvfs = get_dvfs(res, res->cdata.res_type); if (!dvfs) return -EINVAL; if (!dvfs->set_max_freq) return -EINVAL; - return dvfs->set_max_freq(res_name, freq); + return dvfs->set_max_freq(res->cdata.res_name, freq); } /* Get the minimum/maximum frequency which can be set to resource. */ int pass_get_available_min_freq(struct pass_resource *res) { struct pass_resource_dvfs_ops *dvfs; - char *res_name; - int res_type; if (!res) return -EINVAL; - res_name = res->cdata.res_name; - res_type = res->cdata.res_type; - - dvfs = get_dvfs(res, res_type); + dvfs = get_dvfs(res, res->cdata.res_type); if (!dvfs) return -EINVAL; if (!dvfs->get_available_min_freq) return -EINVAL; - return dvfs->get_available_min_freq(res_name); + return dvfs->get_available_min_freq(res->cdata.res_name); } int pass_get_available_max_freq(struct pass_resource *res) { struct pass_resource_dvfs_ops *dvfs; - char *res_name; - int res_type; if (!res) return -EINVAL; - res_name = res->cdata.res_name; - res_type = res->cdata.res_type; - - dvfs = get_dvfs(res, res_type); + dvfs = get_dvfs(res, res->cdata.res_type); if (!dvfs) return -EINVAL; if (!dvfs->get_available_max_freq) return -EINVAL; - return dvfs->get_available_max_freq(res_name); + return dvfs->get_available_max_freq(res->cdata.res_name); } /* Get and set the up_threshold for DVFS resource. */ int pass_get_up_threshold(struct pass_resource *res) { struct pass_resource_dvfs_ops *dvfs; - char *res_name; - int res_type; if (!res) return -EINVAL; - res_name = res->cdata.res_name; - res_type = res->cdata.res_type; - - dvfs = get_dvfs(res, res_type); + dvfs = get_dvfs(res, res->cdata.res_type); if (!dvfs) return -EINVAL; if (!dvfs->get_up_threshold) return -EINVAL; - return dvfs->get_up_threshold(res_name); + return dvfs->get_up_threshold(res->cdata.res_name); } int pass_set_up_threshold(struct pass_resource *res, int up_threshold) { struct pass_resource_dvfs_ops *dvfs; - char *res_name; - int res_type; if (!res || up_threshold < 0) return -EINVAL; - res_name = res->cdata.res_name; - res_type = res->cdata.res_type; - - dvfs = get_dvfs(res, res_type); + dvfs = get_dvfs(res, res->cdata.res_type); if (!dvfs) return -EINVAL; if (!dvfs->set_up_threshold) return -EINVAL; - return dvfs->set_up_threshold(res_name, up_threshold); + return dvfs->set_up_threshold(res->cdata.res_name, up_threshold); } /* Get and set the online state of HOTPLUG resource (e.g., CPU). */ int pass_get_online_state(struct pass_resource *res, int cpu) { struct pass_resource_hotplug_ops *hotplug; - char *res_name; - int res_type; if (!res || cpu < 0) return -EINVAL; - res_name = res->cdata.res_name; - res_type = res->cdata.res_type; - - hotplug = get_hotplug(res, res_type); + hotplug = get_hotplug(res, res->cdata.res_type); if (!hotplug) return -EINVAL; if (!hotplug->get_online_state) return -EINVAL; - return hotplug->get_online_state(res_name, cpu); + return hotplug->get_online_state(res->cdata.res_name, cpu); } int pass_set_online_state(struct pass_resource *res, int cpu, int on) { struct pass_resource_hotplug_ops *hotplug; - char *res_name; - int res_type; if (!res || cpu < 0 || on < 0) return -EINVAL; - res_name = res->cdata.res_name; - res_type = res->cdata.res_type; - - hotplug = get_hotplug(res, res_type); + hotplug = get_hotplug(res, res->cdata.res_type); if (!hotplug) return -EINVAL; if (!hotplug->set_online_state) return -EINVAL; - return hotplug->set_online_state(res_name, cpu, on); + return hotplug->set_online_state(res->cdata.res_name, cpu, on); } int pass_get_online_min_num(struct pass_resource *res) { struct pass_resource_hotplug_ops *hotplug; - char *res_name; - int res_type; if (!res) return -EINVAL; - res_name = res->cdata.res_name; - res_type = res->cdata.res_type; - - hotplug = get_hotplug(res, res_type); + hotplug = get_hotplug(res, res->cdata.res_type); if (!hotplug) return -EINVAL; if (!hotplug->get_online_min_num) return -EINVAL; - return hotplug->get_online_min_num(res_name); + return hotplug->get_online_min_num(res->cdata.res_name); } int pass_set_online_min_num(struct pass_resource *res, int num) { struct pass_resource_hotplug_ops *hotplug; - char *res_name; - int res_type; if ((!res) || (num < 0)) return -EINVAL; - res_name = res->cdata.res_name; - res_type = res->cdata.res_type; - - hotplug = get_hotplug(res, res_type); + hotplug = get_hotplug(res, res->cdata.res_type); if (!hotplug) return -EINVAL; if (!hotplug->set_online_min_num) return -EINVAL; - return hotplug->set_online_min_num(res_name, num); + return hotplug->set_online_min_num(res->cdata.res_name, num); } int pass_get_online_max_num(struct pass_resource *res) { struct pass_resource_hotplug_ops *hotplug; - char *res_name; - int res_type; if (!res) return -EINVAL; - res_name = res->cdata.res_name; - res_type = res->cdata.res_type; - - hotplug = get_hotplug(res, res_type); + hotplug = get_hotplug(res, res->cdata.res_type); if (!hotplug) return -EINVAL; if (!hotplug->get_online_max_num) return -EINVAL; - return hotplug->get_online_max_num(res_name); + return hotplug->get_online_max_num(res->cdata.res_name); } int pass_set_online_max_num(struct pass_resource *res, int num) { struct pass_resource_hotplug_ops *hotplug; - char *res_name; - int res_type; if ((!res) || (num < 0)) return -EINVAL; - res_name = res->cdata.res_name; - res_type = res->cdata.res_type; - - hotplug = get_hotplug(res, res_type); + hotplug = get_hotplug(res, res->cdata.res_type); if (!hotplug) return -EINVAL; if (!hotplug->set_online_max_num) return -EINVAL; - return hotplug->set_online_max_num(res_name, num); + return hotplug->set_online_max_num(res->cdata.res_name, num); } /* Get the temperature and thermal policy for Thermal resource. */ int pass_get_temp(struct pass_resource *res) { struct pass_resource_tmu_ops *tmu; - char *res_thermal_name; - int res_type; if (!res) return -EINVAL; - /* - * In the case of the HAL TMU ops, - * res_thermal_name is used as the first argument, - * instead of res_name. - */ - res_thermal_name = res->cdata.res_thermal_name; - res_type = res->cdata.res_type; - - tmu = get_tmu(res, res_type); + tmu = get_tmu(res, res->cdata.res_type); if (!tmu) return -EINVAL; if (!tmu->get_temp) return -EINVAL; - return tmu->get_temp(res_thermal_name); + /* + * 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->cdata.res_thermal_name); } int pass_get_tmu_policy(struct pass_resource *res, char *policy) { struct pass_resource_tmu_ops *tmu; - char *res_thermal_name; - int res_type; if (!res || !policy) return -EINVAL; - /* - * In the case of the HAL TMU ops, - * res_thermal_name is used as the first argument, - * instead of res_name. - */ - res_thermal_name = res->cdata.res_thermal_name; - res_type = res->cdata.res_type; - - tmu = get_tmu(res, res_type); + tmu = get_tmu(res, res->cdata.res_type); if (!tmu) return -EINVAL; if (!tmu->get_policy) return -EINVAL; - return tmu->get_policy(res_thermal_name, policy); + /* + * 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->cdata.res_thermal_name, policy); } int pass_set_fault_around_bytes(struct pass_resource *res, int fault_around_bytes) { struct pass_resource_memory *memory; - char *res_name; - int res_type; if (!res) return -EINVAL; - res_name = res->cdata.res_name; - res_type = res->cdata.res_type; - - switch (res_type) { + switch (res->cdata.res_type) { case PASS_RESOURCE_MEMORY_ID: memory = res->hal.memory; break; @@ -544,22 +442,17 @@ int pass_set_fault_around_bytes(struct pass_resource *res, if (!memory->set_fault_around_bytes) return -EINVAL; - return memory->set_fault_around_bytes(res_name, fault_around_bytes); + return memory->set_fault_around_bytes(res->cdata.res_name, fault_around_bytes); } int pass_get_fault_around_bytes(struct pass_resource *res) { struct pass_resource_memory *memory; - char *res_name; - int res_type; if (!res) return -EINVAL; - res_name = res->cdata.res_name; - res_type = res->cdata.res_type; - - switch (res_type) { + switch (res->cdata.res_type) { case PASS_RESOURCE_MEMORY_ID: memory = res->hal.memory; break; @@ -570,22 +463,17 @@ int pass_get_fault_around_bytes(struct pass_resource *res) if (!memory->get_fault_around_bytes) return -EINVAL; - return memory->get_fault_around_bytes(res_name); + return memory->get_fault_around_bytes(res->cdata.res_name); } int pass_set_pmqos_data(struct pass_resource *res, void *data) { struct pass_resource_nonstandard *nonstandard = NULL; - char *res_name; - int res_type; if (!res) return -EINVAL; - res_name = res->cdata.res_name; - res_type = res->cdata.res_type; - - switch (res_type) { + switch (res->cdata.res_type) { case PASS_RESOURCE_NONSTANDARD_ID: nonstandard = (res->hal.nonstandard); break; @@ -596,7 +484,7 @@ int pass_set_pmqos_data(struct pass_resource *res, void *data) if (!nonstandard->set_pmqos_data || !data) return -EINVAL; - return nonstandard->set_pmqos_data(res_name, data); + return nonstandard->set_pmqos_data(res->cdata.res_name, data); } static int pass_save_dvfs_initdata(struct pass_resource *res) @@ -751,24 +639,17 @@ static int pass_restore_memory_initdata(struct pass_resource *res) int pass_save_initdata(struct pass_resource *res) { - struct pass_conf_data *cdata; - char *res_name; - int res_type; int ret; if (!res) return -EINVAL; - cdata = &res->cdata; - res_name = cdata->res_name; - res_type = cdata->res_type; - - switch (res_type) { + switch (res->cdata.res_type) { case PASS_RESOURCE_CPU_ID: ret = pass_save_hotplug_initdata(res); if (ret < 0) { _E("Failed to save hp initdata for '%s' resource", - res_name); + res->cdata.res_name); return ret; } /* fall through */ @@ -777,7 +658,7 @@ int pass_save_initdata(struct pass_resource *res) ret = pass_save_dvfs_initdata(res); if (ret < 0) { _E("Failed to save dvfs initdata for '%s' resource", - res_name); + res->cdata.res_name); return ret; } break; @@ -785,14 +666,15 @@ int pass_save_initdata(struct pass_resource *res) ret = pass_save_memory_initdata(res); if (ret < 0) { _E("Failed to save memory initdata for '%s' resource", - res_name); + res->cdata.res_name); return ret; } break; case PASS_RESOURCE_NONSTANDARD_ID: break; default: - _E("Unsupported resource type (type: %d)\n", res_type); + _E("Unsupported resource type (type: %d)\n", + res->cdata.res_type); return -EINVAL; } @@ -801,24 +683,17 @@ int pass_save_initdata(struct pass_resource *res) int pass_restore_initdata(struct pass_resource *res) { - struct pass_conf_data *cdata; - char *res_name; - int res_type; int ret; if (!res) return -EINVAL; - cdata = &res->cdata; - res_name = cdata->res_name; - res_type = cdata->res_type; - - switch (res_type) { + switch (res->cdata.res_type) { case PASS_RESOURCE_CPU_ID: ret = pass_restore_hotplug_initdata(res); if (ret < 0) { _E("Failed to restore hp initdata for '%s' resource", - res_name); + res->cdata.res_name); return ret; } /* fall through */ @@ -827,7 +702,7 @@ int pass_restore_initdata(struct pass_resource *res) ret = pass_restore_dvfs_initdata(res); if (ret < 0) { _E("Failed to restore dvfs initdata for '%s' resource", - res_name); + res->cdata.res_name); return ret; } break; @@ -835,14 +710,15 @@ int pass_restore_initdata(struct pass_resource *res) ret = pass_restore_memory_initdata(res); if (ret < 0) { _E("Failed to restore memory data for '%s' resource", - res_name); + res->cdata.res_name); return ret; } break; case PASS_RESOURCE_NONSTANDARD_ID: break; default: - _E("Unsupported resource type (type: %d)\n", res_type); + _E("Unsupported resource type (type: %d)\n", + res->cdata.res_type); return -EINVAL; } @@ -851,20 +727,14 @@ int pass_restore_initdata(struct pass_resource *res) int pass_get_resource(struct pass_resource *res) { - struct pass_conf_data *cdata; struct pass_resource_info *info; - char *res_name; const char *name; - int res_type; int ret; if (!res) return -EINVAL; - cdata = &res->cdata; - res_name = cdata->res_name; - res_type = cdata->res_type; - switch (res_type) { + switch (res->cdata.res_type) { case PASS_RESOURCE_CPU_ID: name = PASS_RESOURCE_CPU_NAME; break; @@ -881,7 +751,8 @@ int pass_get_resource(struct pass_resource *res) name = PASS_RESOURCE_NONSTANDARD_NAME; break; default: - _E("Unsupported resource type (type: %d)\n", res_type); + _E("Unsupported resource type (type: %d)\n", + res->cdata.res_type); return -EINVAL; }; @@ -889,42 +760,42 @@ int pass_get_resource(struct pass_resource *res) (const struct pass_resource_info **)&info); if (ret < 0) { _E("Failed to get %s.so for '%s' resource\n", - name, res_name); + name, res->cdata.res_name); return -EINVAL; } if (!info->open || !info->close) { _E("Failed to get functions of %s.so for '%s' resource\n", - name, res_name); + name, res->cdata.res_name); return -EPERM; } - switch (res_type) { + switch (res->cdata.res_type) { case PASS_RESOURCE_CPU_ID: - ret = info->open(res_name, info, + ret = info->open(res->cdata.res_name, info, (struct pass_resource_common**)&res->hal.cpu); break; case PASS_RESOURCE_BUS_ID: - ret = info->open(res_name, info, + ret = info->open(res->cdata.res_name, info, (struct pass_resource_common**)&res->hal.bus); break; case PASS_RESOURCE_GPU_ID: - ret = info->open(res_name, info, + ret = info->open(res->cdata.res_name, info, (struct pass_resource_common**)&res->hal.gpu); break; case PASS_RESOURCE_MEMORY_ID: - ret = info->open(res_name, info, + ret = info->open(res->cdata.res_name, info, (struct pass_resource_common**)&res->hal.memory); break; case PASS_RESOURCE_NONSTANDARD_ID: - ret = info->open(res_name, info, + ret = info->open(res->cdata.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_name); + name, res->cdata.res_name); return -EINVAL; } @@ -933,44 +804,38 @@ int pass_get_resource(struct pass_resource *res) int pass_put_resource(struct pass_resource *res) { - struct pass_conf_data *cdata; struct pass_resource_common *common; struct pass_resource_info *info; - char *res_name; - int res_type; int ret; if (!res) return -EINVAL; - cdata = &res->cdata; - res_name = cdata->res_name; - res_type = cdata->res_type; - switch (res_type) { + switch (res->cdata.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_name, common); + ret = info->close(res->cdata.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_name, common); + ret = info->close(res->cdata.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_name, common); + ret = info->close(res->cdata.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_name, common); + ret = info->close(res->cdata.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_name, common); + ret = info->close(res->cdata.res_name, common); break; default: return -EINVAL; @@ -978,7 +843,7 @@ int pass_put_resource(struct pass_resource *res) if (ret < 0) { _E("Failed to close %s.so for '%s' resource\n", - info->name, res_name); + info->name, res->cdata.res_name); return -EINVAL; } -- 2.7.4 From 5e45392dfefd5aec3a4d665243abef2324e99f2c Mon Sep 17 00:00:00 2001 From: Chanwoo Choi Date: Fri, 26 Jan 2018 09:57:48 +0900 Subject: [PATCH 14/16] pass: Make include directory containing the exported header files Existing *.[ch] files uses the following type in order to include the header file which is located in the outside directory. But it is not proper method for including the header file. - #include "core/*.h: Make 'include' directory containing the all exported header files and move the exported header files under 'include/' as following: - src/core/*.h -> include/pass/log.h - src/shared/*.h -> include/pass/*.h - src/hal/hal.h -> include/pass/hal/hal.h Change-Id: I68f6ad4c711b50a1d48bee3785d5657a8b58c963 Signed-off-by: Chanwoo Choi --- CMakeLists.txt | 3 +-- {src/core => include/pass}/common.h | 0 {src/core => include/pass}/config-parser.h | 0 {src/core => include/pass}/device-notifier.h | 0 {src/core => include/pass}/devices.h | 0 {src/core => include/pass}/gdbus-util.h | 0 {src => include/pass}/hal/hal.h | 0 {src/shared => include/pass}/log.h | 0 src/core/common.c | 5 ++--- src/core/config-parser.c | 5 ++--- src/core/device-notifier.c | 7 +++---- src/core/devices.c | 7 +++---- src/core/gdbus-util.c | 4 ++-- src/core/main.c | 11 +++++------ src/hal/CMakeLists.txt | 2 +- src/hal/hal.c | 3 ++- src/pass/pass-gov.c | 6 +++--- src/pass/pass-hal.c | 4 ++-- src/pass/pass-hal.h | 2 +- src/pass/pass-parser.c | 8 ++++---- src/pass/pass-pmqos.c | 6 +++--- src/pass/pass.c | 10 +++++----- src/pass/pass.h | 2 +- src/pmqos/pmqos-parser.c | 4 ++-- src/pmqos/pmqos.c | 10 +++++----- 25 files changed, 47 insertions(+), 52 deletions(-) rename {src/core => include/pass}/common.h (100%) rename {src/core => include/pass}/config-parser.h (100%) rename {src/core => include/pass}/device-notifier.h (100%) rename {src/core => include/pass}/devices.h (100%) rename {src/core => include/pass}/gdbus-util.h (100%) rename {src => include/pass}/hal/hal.h (100%) rename {src/shared => include/pass}/log.h (100%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 048523b..1b6053f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -87,8 +87,7 @@ SET(SRCS INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}) INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/src) -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/src/pass) -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/src/hal) +INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/include) SET(PKG_MODULES vconf diff --git a/src/core/common.h b/include/pass/common.h similarity index 100% rename from src/core/common.h rename to include/pass/common.h diff --git a/src/core/config-parser.h b/include/pass/config-parser.h similarity index 100% rename from src/core/config-parser.h rename to include/pass/config-parser.h diff --git a/src/core/device-notifier.h b/include/pass/device-notifier.h similarity index 100% rename from src/core/device-notifier.h rename to include/pass/device-notifier.h diff --git a/src/core/devices.h b/include/pass/devices.h similarity index 100% rename from src/core/devices.h rename to include/pass/devices.h diff --git a/src/core/gdbus-util.h b/include/pass/gdbus-util.h similarity index 100% rename from src/core/gdbus-util.h rename to include/pass/gdbus-util.h diff --git a/src/hal/hal.h b/include/pass/hal/hal.h similarity index 100% rename from src/hal/hal.h rename to include/pass/hal/hal.h diff --git a/src/shared/log.h b/include/pass/log.h similarity index 100% rename from src/shared/log.h rename to include/pass/log.h diff --git a/src/core/common.c b/src/core/common.c index b75a016..a0ee779 100644 --- a/src/core/common.c +++ b/src/core/common.c @@ -34,9 +34,8 @@ #include #include -#include "shared/log.h" - -#include "common.h" +#include +#include #define BUFF_MAX 255 diff --git a/src/core/config-parser.c b/src/core/config-parser.c index d0e2632..b13a5b2 100644 --- a/src/core/config-parser.c +++ b/src/core/config-parser.c @@ -20,9 +20,8 @@ #include #include -#include "shared/log.h" - -#include "config-parser.h" +#include +#include #define BUFF_MAX 255 #define MAX_SECTION 64 diff --git a/src/core/device-notifier.c b/src/core/device-notifier.c index 4a03ead..2c6e99b 100644 --- a/src/core/device-notifier.c +++ b/src/core/device-notifier.c @@ -18,10 +18,9 @@ #include -#include "shared/log.h" - -#include "device-notifier.h" -#include "common.h" +#include +#include +#include #define DEVICE_NOTIFIER_MAX_COUNT 255 diff --git a/src/core/devices.c b/src/core/devices.c index 46ca468..42e193c 100644 --- a/src/core/devices.c +++ b/src/core/devices.c @@ -19,10 +19,9 @@ #include #include -#include "shared/log.h" - -#include "common.h" -#include "devices.h" +#include +#include +#include static const struct device_ops default_ops = { .name = "default-ops", diff --git a/src/core/gdbus-util.c b/src/core/gdbus-util.c index 0702dc2..42d21b8 100644 --- a/src/core/gdbus-util.c +++ b/src/core/gdbus-util.c @@ -19,8 +19,8 @@ #include #include -#include "gdbus-util.h" -#include "shared/log.h" +#include +#include static GDBusConnection *g_dbus_sys_conn = NULL; diff --git a/src/core/main.c b/src/core/main.c index 9b56d8c..a3c2542 100644 --- a/src/core/main.c +++ b/src/core/main.c @@ -23,12 +23,11 @@ #include #include -#include "shared/log.h" - -#include "common.h" -#include "device-notifier.h" -#include "devices.h" -#include "gdbus-util.h" +#include +#include +#include +#include +#include #define PASS_DBUS_BUS_NAME "org.tizen.system.pass" diff --git a/src/hal/CMakeLists.txt b/src/hal/CMakeLists.txt index ade8159..c0f1fbc 100755 --- a/src/hal/CMakeLists.txt +++ b/src/hal/CMakeLists.txt @@ -2,7 +2,7 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.6) PROJECT(pass-hal-devel C) SET(HAL_HEADERS - hal.h + ../../include/pass/hal/hal.h hal-log.h ) diff --git a/src/hal/hal.c b/src/hal/hal.c index 2f65a71..beadab5 100644 --- a/src/hal/hal.c +++ b/src/hal/hal.c @@ -24,7 +24,8 @@ #include #include -#include "hal.h" +#include + #include "hal-log.h" #ifndef EXPORT diff --git a/src/pass/pass-gov.c b/src/pass/pass-gov.c index 19febfd..6601220 100644 --- a/src/pass/pass-gov.c +++ b/src/pass/pass-gov.c @@ -21,15 +21,15 @@ #include #include +#include +#include + #include "pass.h" #include "pass-gov.h" #include "pass-pmqos.h" #include "pass-hal.h" #include "pass-rescon.h" -#include "core/device-notifier.h" -#include "core/config-parser.h" - #define PASS_CPU_STATS_MAX_COUNT 20 struct pass_governor { diff --git a/src/pass/pass-hal.c b/src/pass/pass-hal.c index 48d1e33..0d91fcc 100644 --- a/src/pass/pass-hal.c +++ b/src/pass/pass-hal.c @@ -22,11 +22,11 @@ #include #include +#include + #include "pass.h" #include "pass-hal.h" -#include "core/common.h" - static struct pass_resource_dvfs_ops *get_dvfs(struct pass_resource *res, int res_type) { diff --git a/src/pass/pass-hal.h b/src/pass/pass-hal.h index 172b0a4..8d1fd6f 100644 --- a/src/pass/pass-hal.h +++ b/src/pass/pass-hal.h @@ -20,7 +20,7 @@ #ifndef __PASS_HAL__ #define __PASS_HAL__ -#include "hal/hal.h" +#include /*** * Functions for all H/W resources diff --git a/src/pass/pass-parser.c b/src/pass/pass-parser.c index 12e6ce7..57a08cc 100644 --- a/src/pass/pass-parser.c +++ b/src/pass/pass-parser.c @@ -22,11 +22,11 @@ #include #include -#include "pass.h" +#include +#include +#include -#include "core/common.h" -#include "core/config-parser.h" -#include "hal/hal.h" +#include "pass.h" #define MAX_NUM 255 #define MIN_TIMEOUT_SEC 0.2 diff --git a/src/pass/pass-pmqos.c b/src/pass/pass-pmqos.c index 22668b2..64606f0 100644 --- a/src/pass/pass-pmqos.c +++ b/src/pass/pass-pmqos.c @@ -21,13 +21,13 @@ #include #include +#include +#include + #include "pass.h" #include "pass-gov.h" #include "pass-rescon.h" -#include "core/device-notifier.h" -#include "core/config-parser.h" - /**************************************************************************** * PASS Notifier * * - DEVICE_NOTIFIER_PMQOS * diff --git a/src/pass/pass.c b/src/pass/pass.c index 9cf90d2..c85d440 100644 --- a/src/pass/pass.c +++ b/src/pass/pass.c @@ -22,16 +22,16 @@ #include #include +#include +#include +#include +#include + #include "pass.h" #include "pass-parser.h" #include "pass-hal.h" #include "pass-gov.h" -#include "core/device-notifier.h" -#include "core/devices.h" -#include "core/common.h" -#include "core/gdbus-util.h" - #define DBUS_CORE_I_START_HANDLER "handle_start" #define DBUS_CORE_I_STOP_HANDLER "handle_stop" #define DBUS_CORE_I_NUM_SIGNALS 2 diff --git a/src/pass/pass.h b/src/pass/pass.h index c5959fd..adaffcd 100644 --- a/src/pass/pass.h +++ b/src/pass/pass.h @@ -24,7 +24,7 @@ #include #include -#include "shared/log.h" +#include #define BUFF_MAX 255 diff --git a/src/pmqos/pmqos-parser.c b/src/pmqos/pmqos-parser.c index 6d6b83c..8352f08 100644 --- a/src/pmqos/pmqos-parser.c +++ b/src/pmqos/pmqos-parser.c @@ -24,8 +24,8 @@ #include #include -#include "core/config-parser.h" -#include "shared/log.h" +#include +#include #include "pmqos.h" diff --git a/src/pmqos/pmqos.c b/src/pmqos/pmqos.c index 78854dd..88d19ab 100644 --- a/src/pmqos/pmqos.c +++ b/src/pmqos/pmqos.c @@ -20,11 +20,11 @@ #include #include -#include "core/gdbus-util.h" -#include "core/devices.h" -#include "core/common.h" -#include "core/device-notifier.h" -#include "shared/log.h" +#include +#include +#include +#include +#include #include "pmqos.h" -- 2.7.4 From 807a8bf20b0c23f04d336c7b895e1e3dad9e1992 Mon Sep 17 00:00:00 2001 From: Chanwoo Choi Date: Fri, 26 Jan 2018 10:24:18 +0900 Subject: [PATCH 15/16] pass: hal: Remove example code for hal implementation Remove example code for hal implementation because example is not updated constantly and pass-hal-standard.git has the well-made hal implementation for all h/w resources which are controlled in PASS framework. [1] https://git.tizen.org/cgit/platform/adaptation/pass-hal-standard/ Change-Id: I3ceb46aecfd11abebf2055d32e865e67d5bb7471 Signed-off-by: Chanwoo Choi --- src/hal/hal-cpu-example.c | 170 ---------------------------------------------- 1 file changed, 170 deletions(-) delete mode 100644 src/hal/hal-cpu-example.c diff --git a/src/hal/hal-cpu-example.c b/src/hal/hal-cpu-example.c deleted file mode 100644 index 6817d87..0000000 --- a/src/hal/hal-cpu-example.c +++ /dev/null @@ -1,170 +0,0 @@ -/* - * PASS 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 requcpued 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. - */ - - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - - -static int get_curr_governor(char *res_name, char *governor) -{ - /* TODO */ - return 0; -} - -static int set_curr_governor(char *res_name, char *governor) -{ - /* TODO */ - return 0; -} - -static int get_avail_governor(char *res_name, char **avail_governor) -{ - /* TODO */ - return 0; -} - -static int get_curr_freq(char *res_name) -{ - /* TODO */ - return 0; -} - -static int get_min_freq(char *res_name) -{ - /* TODO */ - return 0; -} - -static int set_min_freq(char *res_name, int freq) -{ - /* TODO */ - return 0; -} - -static int get_max_freq(char *res_name) -{ - /* TODO */ - return 0; -} - -static int set_max_freq(char *res_name, int freq) -{ - /* TODO */ - return 0; -} - -static int get_up_threshold(char *res_name) -{ - /* TODO */ - return 0; -} - -static int set_up_threshold(char *res_name, int up_threshold) -{ - /* TODO */ - return 0; -} - -static int get_online_state(char *res_name, int cpu) -{ - /* TODO */ - return 0; -} - -static int set_online_state(char *res_name, int cpu, int on) -{ - /* TODO */ - return 0; -} - -static int get_tmu_temp(char *res_name) -{ - /* TODO */ - return 0; -} - -static int get_tmu_policy(char *res_name, char *policy) -{ - /* TODO */ - return 0; -} - -static int pass_open(struct pass_resource_info *info, - struct pass_resource_common **common) -{ - struct pass_resource_cpu *res; - - if (!info || !common) - return -EINVAL; - - res = calloc(1, sizeof(*res)); - if (!res) - return -ENOMEM; - - res->common.info = info; - - res->dvfs.get_curr_governor = get_curr_governor; - res->dvfs.set_curr_governor = set_curr_governor; - res->dvfs.get_avail_governor = get_avail_governor; - res->dvfs.get_curr_freq = get_curr_freq; - res->dvfs.get_min_freq = get_min_freq; - res->dvfs.set_min_freq = set_min_freq; - res->dvfs.get_max_freq = get_max_freq; - res->dvfs.set_max_freq = set_max_freq; - res->dvfs.get_up_threshold = get_up_threshold; - res->dvfs.set_up_threshold = set_up_threshold; - - res->tmu.get_temp = get_tmu_temp; - res->tmu.get_policy = get_tmu_policy; - - res->hotplug.get_online_state = get_online_state; - res->hotplug.set_online_state = set_online_state; - - *common = (struct pass_resource_common *)res; - return 0; -} - -static int pass_close(struct pass_resource_common *common) -{ - if (!common) - return -EINVAL; - - free(common); - return 0; -} - -HAL_MODULE_STRUCTURE = { - .magic = HAL_INFO_TAG, - .hal_version = HAL_INFO_VERSION, - .device_version = HARDWARE_INFO_VERSION_CPU, - .id = PASS_RESOURCE_CPU_ID, - .name = PASS_RESOURCE_CPU_NAME, - .open = pass_open, - .close = pass_close, -}; -- 2.7.4 From 130332a619b22da5d1df539c2e5ebcaf0ac66022 Mon Sep 17 00:00:00 2001 From: Seung-Woo Kim Date: Fri, 26 Jan 2018 11:04:37 +0900 Subject: [PATCH 16/16] pass: Remove unused script from makefile Except for pass-hal-devel package, PASS doesn't make the devel package including the header file and library. Remove unused script related to installing the header file. Change-Id: Ic9b24b7f81319c0e55e70620f4dea847ecbafbf3 Signed-off-by: Seung-Woo Kim [cw00.choi: Apply patch and write the patch description] Signed-off-by: Chanwoo Choi --- CMakeLists.txt | 6 ------ 1 file changed, 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1b6053f..fae7d38 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -155,12 +155,6 @@ ADD_CUSTOM_COMMAND( ADD_EXECUTABLE(${PROJECT_NAME} ${SRCS}) TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${pkgs_LDFLAGS} "-ldl" "-lm") INSTALL(TARGETS ${PROJECT_NAME} DESTINATION bin) - -INSTALL(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/src/pass/ DESTINATION include/${PROJECT_NAME} - FILES_MATCHING - PATTERN "*_doc.h" EXCLUDE - PATTERN "*.h") - 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) -- 2.7.4