/*
* PASS (Power Aware Systerm Service) Radiation governor
*
- * 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.
* - the number of nr_running
* - the number of busy_cpu
*/
-int pass_radiation_governor(struct pass_policy *policy)
+int pass_radiation_governor(struct pass_resource *res)
{
- struct pass_level *levels = policy->levels;
- struct pass_cpu_stats *cpu_stats = policy->pass_cpu_stats;
- int up_threshold = policy->up_threshold;
- int down_threshold = policy->down_threshold;
+ struct pass_level *levels = res->config_data.levels;
+ struct pass_cpuhp *cpuhp = &res->cpuhp;
+ struct pass_cpu_stats *cpu_stats = cpuhp->pass_cpu_stats;
+ int up_threshold = cpuhp->up_threshold;
+ int down_threshold = cpuhp->down_threshold;
int num_pass_gov = 0;
- int level = policy->curr_level;
+ int level = res->rescon.curr_level;
int up_count = 0;
int down_count = 0;
int left_count = 0;
int j;
int64_t time;
- for (i = 0; i < policy->num_pass_cpu_stats; i++) {
+ for (i = 0; i < cpuhp->num_pass_cpu_stats; i++) {
time = cpu_stats[i].time;
freq = cpu_stats[i].freq;
nr_running = cpu_stats[i].nr_runnings;
left_condition = true;
right_condition = true;
- if (policy->last_time >= time)
+ if (cpuhp->last_time >= time)
continue;
- policy->last_time = time;
+ cpuhp->last_time = time;
num_pass_gov++;
/*
return level;
if (up_count * 100 >= num_pass_gov * up_threshold) {
- level += policy->hotplug->num_cpus;
+ level += cpuhp->hotplug->num_cpus;
- if (level > policy->max_level)
- level -= policy->hotplug->num_cpus;
+ if (level > res->rescon.max_level)
+ level -= cpuhp->hotplug->num_cpus;
} else if (down_count * 100 >= num_pass_gov * down_threshold) {
- level -= policy->hotplug->num_cpus;
+ level -= cpuhp->hotplug->num_cpus;
}
if (right_count * 100 >= num_pass_gov * up_threshold) {
level += 1;
- if (level > policy->max_level)
+ if (level > res->rescon.max_level)
level -= 1;
} else if (left_count * 100 >= num_pass_gov * down_threshold) {
level -= 1;
}
/*
- if (level == policy->prev_level) {
- for (i = num_pass_gov; i < policy->num_pass_cpu_stats; i++) {
+ if (level == res->prev_level) {
+ for (i = num_pass_gov; i < cpuhp->num_pass_cpu_stats; i++) {
time = cpu_stats[i].time;
freq = cpu_stats[i].freq;
nr_running = cpu_stats[i].nr_runnings;
}
}
- if (level != policy->curr_level) {
+ if (level != res->rescon.curr_level) {
_I("\n[Level%d] num_pass_gov: [%2d]", level, num_pass_gov);
_I("[Level%d] down_count : %2d (%3d >= %3d)", level, down_count,
down_count * 100, num_pass_gov * down_threshold);
/*
* PASS (Power Aware System Service) Step governor
*
- * 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.
* - the number of nr_running
* - the number of busy_cpu
*/
-int pass_step_governor(struct pass_policy *policy)
+int pass_step_governor(struct pass_resource *res)
{
- struct pass_level *levels = policy->levels;
- struct pass_cpu_stats *cpu_stats = policy->pass_cpu_stats;
- int up_threshold = policy->up_threshold;
- int down_threshold = policy->down_threshold;
+ struct pass_level *levels = res->config_data.levels;
+ struct pass_cpuhp *cpuhp = &res->cpuhp;
+ struct pass_cpu_stats *cpu_stats = cpuhp->pass_cpu_stats;
+ int up_threshold = cpuhp->up_threshold;
+ int down_threshold = cpuhp->down_threshold;
int num_pass_gov = 0;
- int level = policy->curr_level;
+ int level = res->rescon.curr_level;
int up_count = 0;
int up_max_count = 0;
int down_count = 0;
int j;
int64_t time;
- for (i = 0; i < policy->num_pass_cpu_stats; i++) {
+ for (i = 0; i < cpuhp->num_pass_cpu_stats; i++) {
time = cpu_stats[i].time;
freq = cpu_stats[i].freq;
nr_running = cpu_stats[i].nr_runnings;
up_condition = false;
down_condition = false;
- if (policy->last_time >= time)
+ if (cpuhp->last_time >= time)
continue;
- policy->last_time = time;
+ cpuhp->last_time = time;
num_pass_gov++;
/* Check level up condition */
*/
}
- if (level < policy->max_level &&
+ if (level < res->rescon.max_level &&
freq == levels[level].limit_max_freq)
up_max_count++;
}
if (!num_pass_gov)
return level;
- if (up_count && level < policy->max_level &&
+ if (up_count && level < res->rescon.max_level &&
up_count * 100 >= num_pass_gov * up_threshold) {
level += 1;
- } else if (down_count && level > policy->min_level &&
+ } else if (down_count && level > res->rescon.min_level &&
down_count * 100 >= num_pass_gov * down_threshold) {
level -= 1;
}
/*
* PASS (Power Aware System Service) Governor
*
- * 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.
struct pass_governor {
char name[BUFF_MAX];
- enum pass_gov_state gov_state;
+ enum pass_state 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 (*update)(struct pass_resource *res, enum pass_state state);
int (*governor)(struct pass_resource *res);
};
/*
* is_enabled - Check the state of PASS governor
- * @policy: the instance of struct pass_policy
+ * @cpuhp: the instance of struct pass_cpuhp
*
- * Return true if the state of PASS is PASS_GOV_START
- * Return false if the state of PASS is PASS_GOV_STOP
+ * Return true if the state of PASS is PASS_ON
+ * Return false if the state of PASS is PASS_OFF
*/
-static bool is_enabled(struct pass_policy *policy)
+static bool is_enabled(struct pass_cpuhp *cpuhp)
{
- if (policy->gov_state != PASS_GOV_START)
+ if (cpuhp->state != PASS_ON)
return false;
return true;
*/
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;
+ struct pass_level *levels = res->config_data.levels;
+ int level = res->rescon.max_level;
- if (!policy->hotplug || !levels)
+ if (!res->cpuhp.hotplug || !levels)
return;
- policy->hotplug->online = levels[level].limit_min_cpu;
+ res->cpuhp.hotplug->online = levels[level].limit_min_cpu;
}
static int pass_hotplug_dummy_governor(struct pass_resource *res)
{
- struct pass_policy *policy = &res->policy;
- int level = policy->curr_level;
+ int level = res->rescon.curr_level;
- return policy->levels[level].limit_min_cpu;
+ return res->config_data.levels[level].limit_min_cpu;
}
/*
*/
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_level *levels = policy->levels;
- struct pass_conf_data *cdata = &res->cdata;
- unsigned int level = policy->curr_level;
+ struct pass_cpuhp *cpuhp = &res->cpuhp;
+ struct pass_level *levels = res->config_data.levels;
+ struct pass_resource_config_data *config_data = &res->config_data;
+ struct pass_cpu_stats *stats = cpuhp->pass_cpu_stats;
+ unsigned int level = res->rescon.curr_level;
unsigned int cpu_threshold = 0;
unsigned int busy_cpu;
unsigned int cur_freq;
limit_min_cpu = levels[level].limit_min_cpu;
- for (i = 0; i < policy->num_pass_cpu_stats; i++) {
+ for (i = 0; i < cpuhp->num_pass_cpu_stats; i++) {
cur_freq = stats[i].freq;
nr_runnings = stats[i].nr_runnings;
sum_runnable_load = 0;
/* Calculate the number of busy cpu */
- for (j = 0; j < cdata->num_cpus; j++) {
+ for (j = 0; j < config_data->num_cpus; j++) {
load = stats[i].load[j];
sum_load += stats[i].load[j];
sum_runnable_load += stats[i].runnable_load[j];
cpu_threshold =
(unsigned int)(cur_freq * load)
- / policy->freq.max_freq;
+ / cpuhp->freq.max_freq;
if (load == 100
- || cpu_threshold >= policy->pass_cpu_threshold)
+ || cpu_threshold >= cpuhp->pass_cpu_threshold)
busy_cpu++;
}
static gboolean pass_governor_timeout_cb(gpointer data)
{
struct pass_resource *res = (struct pass_resource *)data;
- struct pass_policy *policy = &res->policy;
+ struct pass_level *levels = res->config_data.levels;
+ struct pass_cpuhp *cpuhp = &res->cpuhp;
static int count = 0;
double curr_gov_timeout, next_gov_timeout;
int level, ret;
count = 0;
_E("cannot read the 'pass_cpu_stats' sysfs entry");
- pass_governor_update(res, PASS_GOV_STOP);
+ pass_governor_update(res, PASS_OFF);
return FALSE;
}
pass_calculate_busy_cpu(res);
/* Store current governor timeout */
- curr_gov_timeout = policy->levels[policy->curr_level].gov_timeout;
+ curr_gov_timeout = levels[res->rescon.curr_level].gov_timeout;
/* Determine the amount of proper resource */
- if (policy->governor->governor) {
- level = policy->governor->governor(res);
+ if (cpuhp->governor->governor) {
+ level = cpuhp->governor->governor(res);
pass_rescon_set_level(res, level);
} else {
_E("cannot call the governor function");
- pass_governor_update(res, PASS_GOV_STOP);
+ pass_governor_update(res, PASS_OFF);
return FALSE;
}
/* Get the governor timeout interval for the next */
- next_gov_timeout = policy->levels[policy->curr_level].gov_timeout;
+ next_gov_timeout = levels[res->rescon.curr_level].gov_timeout;
/*
* Change the governor timeout interval when the next interval is not
_I("Change the period of governor timer from %fs to %fs\n",
curr_gov_timeout,
next_gov_timeout);
- g_source_remove(policy->gov_timeout_id);
- policy->gov_timeout_id = g_timeout_add(
+ g_source_remove(cpuhp->gov_timeout_id);
+ cpuhp->gov_timeout_id = g_timeout_add(
(guint)(next_gov_timeout * 1000),
pass_governor_timeout_cb,
(gpointer)res);
*/
static void __pass_governor_start(struct pass_resource *res)
{
- struct pass_policy *policy = &res->policy;
- struct pass_conf_data *cdata = &res->cdata;
+ struct pass_cpuhp *cpuhp = &res->cpuhp;
- if (!policy->governor) {
+ if (!cpuhp->governor) {
_E("cannot start PASS governor");
return;
}
- if (is_enabled(policy)) {
+ if (is_enabled(cpuhp)) {
_E("PASS governor is already active state");
return;
}
/* Add callback function for each governor timeout */
- if (policy->gov_timeout > 0) {
- policy->gov_timeout_id = g_timeout_add(
- (guint)(policy->gov_timeout * 1000),
+ if (res->config_data.gov_timeout > 0) {
+ cpuhp->gov_timeout_id = g_timeout_add(
+ (guint)(res->config_data.gov_timeout * 1000),
(GSourceFunc)pass_governor_timeout_cb,
(gpointer)res);
- if (!policy->gov_timeout_id) {
+ if (!cpuhp->gov_timeout_id) {
_E("cannot add core timer for governor");
- pass_governor_update(res, PASS_GOV_STOP);
+ pass_governor_update(res, PASS_OFF);
return;
}
} else {
- policy->gov_timeout_id = 0;
+ cpuhp->gov_timeout_id = 0;
}
/*
* Set default pass level when starting pass
- * - default pass level according to policy->init_level
+ * - default pass level according to res->init_level
*/
- policy->curr_level = -1;
- if (policy->init_level > policy->max_level)
- policy->init_level = policy->max_level;
+ res->rescon.curr_level = -1;
+ if (res->rescon.init_level > res->rescon.max_level)
+ res->rescon.init_level = res->rescon.max_level;
- pass_rescon_set_level(res, policy->init_level);
+ pass_rescon_set_level(res, res->rescon.init_level);
- /* Set PASS state as PASS_GOV_START */
- policy->gov_state = PASS_GOV_START;
+ /* Set PASS state as PASS_ON */
+ cpuhp->state = PASS_ON;
- _I("Start governor for '%s' resource", cdata->res_name);
+ _I("Start governor for '%s' resource", res->config_data.res_name);
}
/*
*/
static void __pass_governor_stop(struct pass_resource *res)
{
- struct pass_policy *policy = &res->policy;
- struct pass_conf_data *cdata = &res->cdata;
+ struct pass_cpuhp *cpuhp = &res->cpuhp;
+ struct pass_resource_config_data *config_data = &res->config_data;
- if (!policy->governor) {
+ if (!cpuhp->governor) {
_E("cannot stop PASS governor");
return;
}
- if (policy->gov_state == PASS_GOV_STOP) {
+ if (cpuhp->state == PASS_OFF) {
_E("PASS governor is already inactive state");
return;
}
pass_hotplug_stop(res);
- if (policy->gov_timeout_id) {
- g_source_remove(policy->gov_timeout_id);
- policy->gov_timeout_id = 0;
+ if (cpuhp->gov_timeout_id) {
+ g_source_remove(cpuhp->gov_timeout_id);
+ cpuhp->gov_timeout_id = 0;
}
- /* Set PASS state as PASS_GOV_STOP */
- policy->gov_state = PASS_GOV_STOP;
+ /* Set PASS state as PASS_OFF */
+ cpuhp->state = PASS_OFF;
- _I("Stop governor for '%s' resource", cdata->res_name);
+ _I("Stop governor for '%s' resource", config_data->res_name);
}
static int __pass_governor_init(struct pass_resource *res)
{
- struct pass_policy *policy = &res->policy;
+ struct pass_cpuhp *cpuhp = &res->cpuhp;
- if (policy->gov_timeout < 0) {
- _E("invalid timeout value [%d]!", policy->gov_timeout);
- pass_governor_update(res, PASS_GOV_STOP);
+ if (res->config_data.gov_timeout < 0) {
+ _E("invalid timeout value [%d]!", res->config_data.gov_timeout);
+ pass_governor_update(res, PASS_OFF);
return -EINVAL;
}
/* Set default PASS state */
- policy->gov_state = PASS_GOV_STOP;
+ cpuhp->state = PASS_OFF;
- if (policy->state == PASS_ON)
- pass_governor_update(res, PASS_GOV_START);
+ if (res->config_data.state == PASS_ON)
+ pass_governor_update(res, PASS_ON);
return 0;
}
static int __pass_governor_exit(struct pass_resource *res)
{
- struct pass_policy *policy = &res->policy;
+ struct pass_cpuhp *cpuhp = &res->cpuhp;
int i;
/*
* Stop timer and
* Restore the frequency and the number of online resources
*/
- pass_governor_update(res, PASS_GOV_STOP);
+ pass_governor_update(res, PASS_OFF);
/* Free allocated memory */
- for (i = 0; i < policy->num_pass_cpu_stats; i++) {
- free(policy->pass_cpu_stats[i].load);
- free(policy->pass_cpu_stats[i].nr_running);
- free(policy->pass_cpu_stats[i].runnable_load);
+ for (i = 0; i < cpuhp->num_pass_cpu_stats; i++) {
+ free(cpuhp->pass_cpu_stats[i].load);
+ free(cpuhp->pass_cpu_stats[i].nr_running);
+ free(cpuhp->pass_cpu_stats[i].runnable_load);
}
- free(policy->pass_cpu_stats);
+ free(cpuhp->pass_cpu_stats);
- if (policy->hotplug)
- free(policy->hotplug->sequence);
+ if (cpuhp->hotplug)
+ free(cpuhp->hotplug->sequence);
- /* Set pass_policy structure as default value */
- policy->pass_cpu_threshold = 0;
- policy->up_threshold = 0;
- policy->down_threshold = 0;
+ /* Set pass_cpuhp structure as default value */
+ cpuhp->pass_cpu_threshold = 0;
+ cpuhp->up_threshold = 0;
+ cpuhp->down_threshold = 0;
+ cpuhp->level_up_threshold = 0;
+ cpuhp->num_pass_cpu_stats = 0;
+ cpuhp->governor = NULL;
- policy->prev_level = 0;
- policy->curr_level = 0;
- policy->min_level = 0;
- policy->max_level = 0;
- policy->level_up_threshold = 0;
-
- policy->num_pass_cpu_stats = 0;
-
- policy->gov_timeout = 0;
-
- policy->governor = NULL;
+ res->rescon.prev_level = 0;
+ res->rescon.curr_level = 0;
+ res->rescon.min_level = 0;
+ res->rescon.max_level = 0;
return 0;
}
static int __pass_governor_update(struct pass_resource *res,
- enum pass_gov_state state)
+ enum pass_state state)
{
switch (state) {
- case PASS_GOV_START:
+ case PASS_ON:
__pass_governor_start(res);
break;
- case PASS_GOV_STOP:
+ case PASS_OFF:
__pass_governor_stop(res);
break;
default:
*/
int pass_governor_init(struct pass_resource *res)
{
- struct pass_policy *policy;
+ struct pass_cpuhp *cpuhp;
if (!res)
return -EINVAL;
- policy = &res->policy;
+ cpuhp = &res->cpuhp;
- if (!policy->governor || !policy->governor->init)
+ if (!cpuhp->governor || !cpuhp->governor->init)
return -EINVAL;
- return policy->governor->init(res);
+ return cpuhp->governor->init(res);
}
/*
*/
int pass_governor_exit(struct pass_resource *res)
{
- struct pass_policy *policy;
+ struct pass_cpuhp *cpuhp;
if (!res)
return -EINVAL;
- policy = &res->policy;
+ cpuhp = &res->cpuhp;
- if (!policy->governor || !policy->governor->exit)
+ if (!cpuhp->governor || !cpuhp->governor->exit)
return -EINVAL;
- return policy->governor->exit(res);
+ return cpuhp->governor->exit(res);
}
/*
* 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_resource *res,
- enum pass_gov_state state)
+int pass_governor_update(struct pass_resource *res, enum pass_state state)
{
- struct pass_policy *policy;
+ struct pass_cpuhp *cpuhp;
if (!res)
return -EINVAL;
- policy = &res->policy;
+ cpuhp = &res->cpuhp;
- if (!policy->governor || !policy->governor->update)
+ if (!cpuhp->governor || !cpuhp->governor->update)
return -EINVAL;
- return policy->governor->update(res, state);
+ return cpuhp->governor->update(res, state);
}
/*
* PASS (Power Aware System Service) Governor
*
- * 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.
/* Init, exit and update the governor */
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);
+int pass_governor_update(struct pass_resource *res, enum pass_state state);
/* Get the governor/hotplug instance according to enum pass_gov_type */
struct pass_governor* pass_get_governor(struct pass_resource *res,
/*
* PASS (Power Aware System Service) HAL
*
- * 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.
if (!res || !governor)
return -EINVAL;
- dvfs = get_dvfs(res, res->cdata.res_type);
+ dvfs = get_dvfs(res, res->config_data.res_type);
if (!dvfs)
return -EINVAL;
if (!dvfs->get_curr_governor)
return -EINVAL;
- return dvfs->get_curr_governor(res->cdata.res_name, governor);
+ return dvfs->get_curr_governor(res->config_data.res_name, governor);
}
int pass_set_curr_governor(struct pass_resource *res, char *governor)
if (!res || !governor)
return -EINVAL;
- dvfs = get_dvfs(res, res->cdata.res_type);
+ dvfs = get_dvfs(res, res->config_data.res_type);
if (!dvfs)
return -EINVAL;
if (!dvfs->set_curr_governor)
return -EINVAL;
- return dvfs->set_curr_governor(res->cdata.res_name, governor);
+ return dvfs->set_curr_governor(res->config_data.res_name, governor);
}
/* Get and set the current/min/max frequency for DVFS resource. */
if (!res)
return -EINVAL;
- dvfs = get_dvfs(res, res->cdata.res_type);
+ dvfs = get_dvfs(res, res->config_data.res_type);
if (!dvfs)
return -EINVAL;
if (!dvfs->get_curr_freq)
return -EINVAL;
- return dvfs->get_curr_freq(res->cdata.res_name);
+ return dvfs->get_curr_freq(res->config_data.res_name);
}
if (!res)
return -EINVAL;
- dvfs = get_dvfs(res, res->cdata.res_type);
+ dvfs = get_dvfs(res, res->config_data.res_type);
if (!dvfs)
return -EINVAL;
if (!dvfs->get_min_freq)
return -EINVAL;
- return dvfs->get_min_freq(res->cdata.res_name);
+ return dvfs->get_min_freq(res->config_data.res_name);
}
int pass_set_min_freq(struct pass_resource *res, int freq)
if (!res || freq < 0)
return -EINVAL;
- dvfs = get_dvfs(res, res->cdata.res_type);
+ dvfs = get_dvfs(res, res->config_data.res_type);
if (!dvfs)
return -EINVAL;
if (!dvfs->set_min_freq)
return -EINVAL;
- return dvfs->set_min_freq(res->cdata.res_name, freq);
+ return dvfs->set_min_freq(res->config_data.res_name, freq);
}
int pass_get_max_freq(struct pass_resource *res)
if (!res)
return -EINVAL;
- dvfs = get_dvfs(res, res->cdata.res_type);
+ dvfs = get_dvfs(res, res->config_data.res_type);
if (!dvfs)
return -EINVAL;
if (!dvfs->get_max_freq)
return -EINVAL;
- return dvfs->get_max_freq(res->cdata.res_name);
+ return dvfs->get_max_freq(res->config_data.res_name);
}
int pass_set_max_freq(struct pass_resource *res, int freq)
if (!res || freq < 0)
return -EINVAL;
- dvfs = get_dvfs(res, res->cdata.res_type);
+ dvfs = get_dvfs(res, res->config_data.res_type);
if (!dvfs)
return -EINVAL;
if (!dvfs->set_max_freq)
return -EINVAL;
- return dvfs->set_max_freq(res->cdata.res_name, freq);
+ return dvfs->set_max_freq(res->config_data.res_name, freq);
}
/* Get the minimum/maximum frequency which can be set to resource. */
if (!res)
return -EINVAL;
- dvfs = get_dvfs(res, res->cdata.res_type);
+ dvfs = get_dvfs(res, res->config_data.res_type);
if (!dvfs)
return -EINVAL;
if (!dvfs->get_available_min_freq)
return -EINVAL;
- return dvfs->get_available_min_freq(res->cdata.res_name);
+ return dvfs->get_available_min_freq(res->config_data.res_name);
}
int pass_get_available_max_freq(struct pass_resource *res)
if (!res)
return -EINVAL;
- dvfs = get_dvfs(res, res->cdata.res_type);
+ dvfs = get_dvfs(res, res->config_data.res_type);
if (!dvfs)
return -EINVAL;
if (!dvfs->get_available_max_freq)
return -EINVAL;
- return dvfs->get_available_max_freq(res->cdata.res_name);
+ return dvfs->get_available_max_freq(res->config_data.res_name);
}
/* Get and set the up_threshold for DVFS resource. */
if (!res)
return -EINVAL;
- dvfs = get_dvfs(res, res->cdata.res_type);
+ dvfs = get_dvfs(res, res->config_data.res_type);
if (!dvfs)
return -EINVAL;
if (!dvfs->get_up_threshold)
return -EINVAL;
- return dvfs->get_up_threshold(res->cdata.res_name);
+ return dvfs->get_up_threshold(res->config_data.res_name);
}
int pass_set_up_threshold(struct pass_resource *res, int up_threshold)
if (!res || up_threshold < 0)
return -EINVAL;
- dvfs = get_dvfs(res, res->cdata.res_type);
+ dvfs = get_dvfs(res, res->config_data.res_type);
if (!dvfs)
return -EINVAL;
if (!dvfs->set_up_threshold)
return -EINVAL;
- return dvfs->set_up_threshold(res->cdata.res_name, up_threshold);
+ return dvfs->set_up_threshold(res->config_data.res_name, up_threshold);
}
/* Get and set the online state of HOTPLUG resource (e.g., CPU). */
if (!res || cpu < 0)
return -EINVAL;
- hotplug = get_hotplug(res, res->cdata.res_type);
+ hotplug = get_hotplug(res, res->config_data.res_type);
if (!hotplug)
return -EINVAL;
if (!hotplug->get_online_state)
return -EINVAL;
- return hotplug->get_online_state(res->cdata.res_name, cpu);
+ return hotplug->get_online_state(res->config_data.res_name, cpu);
}
int pass_set_online_state(struct pass_resource *res, int cpu, int on)
if (!res || cpu < 0 || on < 0)
return -EINVAL;
- hotplug = get_hotplug(res, res->cdata.res_type);
+ hotplug = get_hotplug(res, res->config_data.res_type);
if (!hotplug)
return -EINVAL;
if (!hotplug->set_online_state)
return -EINVAL;
- return hotplug->set_online_state(res->cdata.res_name, cpu, on);
+ return hotplug->set_online_state(res->config_data.res_name, cpu, on);
}
int pass_get_online_min_num(struct pass_resource *res)
if (!res)
return -EINVAL;
- hotplug = get_hotplug(res, res->cdata.res_type);
+ hotplug = get_hotplug(res, res->config_data.res_type);
if (!hotplug)
return -EINVAL;
if (!hotplug->get_online_min_num)
return -EINVAL;
- return hotplug->get_online_min_num(res->cdata.res_name);
+ return hotplug->get_online_min_num(res->config_data.res_name);
}
int pass_set_online_min_num(struct pass_resource *res, int num)
if ((!res) || (num < 0))
return -EINVAL;
- hotplug = get_hotplug(res, res->cdata.res_type);
+ hotplug = get_hotplug(res, res->config_data.res_type);
if (!hotplug)
return -EINVAL;
if (!hotplug->set_online_min_num)
return -EINVAL;
- return hotplug->set_online_min_num(res->cdata.res_name, num);
+ return hotplug->set_online_min_num(res->config_data.res_name, num);
}
int pass_get_online_max_num(struct pass_resource *res)
if (!res)
return -EINVAL;
- hotplug = get_hotplug(res, res->cdata.res_type);
+ hotplug = get_hotplug(res, res->config_data.res_type);
if (!hotplug)
return -EINVAL;
if (!hotplug->get_online_max_num)
return -EINVAL;
- return hotplug->get_online_max_num(res->cdata.res_name);
+ return hotplug->get_online_max_num(res->config_data.res_name);
}
int pass_set_online_max_num(struct pass_resource *res, int num)
if ((!res) || (num < 0))
return -EINVAL;
- hotplug = get_hotplug(res, res->cdata.res_type);
+ hotplug = get_hotplug(res, res->config_data.res_type);
if (!hotplug)
return -EINVAL;
if (!hotplug->set_online_max_num)
return -EINVAL;
- return hotplug->set_online_max_num(res->cdata.res_name, num);
+ return hotplug->set_online_max_num(res->config_data.res_name, num);
}
/* Get the temperature and thermal policy for Thermal resource. */
if (!res)
return -EINVAL;
- tmu = get_tmu(res, res->cdata.res_type);
+ tmu = get_tmu(res, res->config_data.res_type);
if (!tmu)
return -EINVAL;
* 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);
+ return tmu->get_temp(res->config_data.res_thermal_name);
}
int pass_get_tmu_policy(struct pass_resource *res, char *policy)
if (!res || !policy)
return -EINVAL;
- tmu = get_tmu(res, res->cdata.res_type);
+ tmu = get_tmu(res, res->config_data.res_type);
if (!tmu)
return -EINVAL;
* 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);
+ return tmu->get_policy(res->config_data.res_thermal_name, policy);
}
int pass_set_fault_around_bytes(struct pass_resource *res,
if (!res)
return -EINVAL;
- switch (res->cdata.res_type) {
+ switch (res->config_data.res_type) {
case PASS_RESOURCE_MEMORY_ID:
memory = res->hal.memory;
break;
if (!memory->set_fault_around_bytes)
return -EINVAL;
- return memory->set_fault_around_bytes(res->cdata.res_name, fault_around_bytes);
+ return memory->set_fault_around_bytes(res->config_data.res_name, fault_around_bytes);
}
int pass_get_fault_around_bytes(struct pass_resource *res)
if (!res)
return -EINVAL;
- switch (res->cdata.res_type) {
+ switch (res->config_data.res_type) {
case PASS_RESOURCE_MEMORY_ID:
memory = res->hal.memory;
break;
if (!memory->get_fault_around_bytes)
return -EINVAL;
- return memory->get_fault_around_bytes(res->cdata.res_name);
+ return memory->get_fault_around_bytes(res->config_data.res_name);
}
int pass_set_pmqos_data(struct pass_resource *res, void *data)
if (!res)
return -EINVAL;
- switch (res->cdata.res_type) {
+ switch (res->config_data.res_type) {
case PASS_RESOURCE_NONSTANDARD_ID:
nonstandard = (res->hal.nonstandard);
break;
if (!nonstandard->set_pmqos_data || !data)
return -EINVAL;
- return nonstandard->set_pmqos_data(res->cdata.res_name, data);
+ return nonstandard->set_pmqos_data(res->config_data.res_name, data);
}
static int pass_save_dvfs_initdata(struct pass_resource *res)
{
- struct pass_resource_initdata *initdata = &res->initdata;
+ struct pass_resource_init_data *initdata = &res->init_data;
int ret;
ret = pass_get_curr_governor(res, initdata->dvfs.governor);
static int pass_save_hotplug_initdata(struct pass_resource *res)
{
- struct pass_resource_initdata *initdata = &res->initdata;
- struct pass_conf_data *cdata = &res->cdata;
+ struct pass_resource_init_data *initdata = &res->init_data;
+ struct pass_resource_config_data *config_data = &res->config_data;
int *online_state;
- int first_cpu = cdata->cpu;
- int num_cpus = cdata->num_cpus;
+ int first_cpu = config_data->cpu;
+ int num_cpus = config_data->num_cpus;
int i;
int ret;
static int pass_save_memory_initdata(struct pass_resource *res)
{
- struct pass_resource_initdata *initdata = &res->initdata;
+ struct pass_resource_init_data *initdata = &res->init_data;
initdata->memory.fault_around_bytes = pass_get_fault_around_bytes(res);
static int pass_restore_dvfs_initdata(struct pass_resource *res)
{
- struct pass_resource_initdata *initdata = &res->initdata;
+ struct pass_resource_init_data *initdata = &res->init_data;
int ret;
if (initdata->dvfs.governor) {
static int pass_restore_hotplug_initdata(struct pass_resource *res)
{
- struct pass_resource_initdata *initdata = &res->initdata;
- struct pass_conf_data *cdata = &res->cdata;
+ struct pass_resource_init_data *initdata = &res->init_data;
+ struct pass_resource_config_data *config_data = &res->config_data;
int *online_state = initdata->hotplug.online_state;
- int first_cpu = cdata->cpu;
- int num_cpus = cdata->num_cpus;
+ int first_cpu = config_data->cpu;
+ int num_cpus = config_data->num_cpus;
int online_min_num = initdata->hotplug.online_min_num;
int online_max_num = initdata->hotplug.online_max_num;
int i;
static int pass_restore_memory_initdata(struct pass_resource *res)
{
- struct pass_resource_initdata *initdata = &res->initdata;
+ struct pass_resource_init_data *initdata = &res->init_data;
int fault_around_bytes = initdata->memory.fault_around_bytes;
int ret;
if (!res)
return -EINVAL;
- switch (res->cdata.res_type) {
+ switch (res->config_data.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->cdata.res_name);
+ res->config_data.res_name);
return ret;
}
/* fall through */
ret = pass_save_dvfs_initdata(res);
if (ret < 0) {
_E("Failed to save dvfs initdata for '%s' resource",
- res->cdata.res_name);
+ res->config_data.res_name);
return ret;
}
break;
ret = pass_save_memory_initdata(res);
if (ret < 0) {
_E("Failed to save memory initdata for '%s' resource",
- res->cdata.res_name);
+ res->config_data.res_name);
return ret;
}
break;
break;
default:
_E("Unsupported resource type (type: %d)\n",
- res->cdata.res_type);
+ res->config_data.res_type);
return -EINVAL;
}
if (!res)
return -EINVAL;
- switch (res->cdata.res_type) {
+ switch (res->config_data.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->cdata.res_name);
+ res->config_data.res_name);
return ret;
}
/* fall through */
ret = pass_restore_dvfs_initdata(res);
if (ret < 0) {
_E("Failed to restore dvfs initdata for '%s' resource",
- res->cdata.res_name);
+ res->config_data.res_name);
return ret;
}
break;
ret = pass_restore_memory_initdata(res);
if (ret < 0) {
_E("Failed to restore memory data for '%s' resource",
- res->cdata.res_name);
+ res->config_data.res_name);
return ret;
}
break;
break;
default:
_E("Unsupported resource type (type: %d)\n",
- res->cdata.res_type);
+ res->config_data.res_type);
return -EINVAL;
}
if (!res)
return -EINVAL;
- switch (res->cdata.res_type) {
+ switch (res->config_data.res_type) {
case PASS_RESOURCE_CPU_ID:
name = PASS_RESOURCE_CPU_NAME;
break;
break;
default:
_E("Unsupported resource type (type: %d)\n",
- res->cdata.res_type);
+ res->config_data.res_type);
return -EINVAL;
};
(const struct pass_resource_info **)&info);
if (ret < 0) {
_E("Failed to get %s.so for '%s' resource\n",
- name, res->cdata.res_name);
+ name, res->config_data.res_name);
return -EINVAL;
}
if (!info->open || !info->close) {
_E("Failed to get functions of %s.so for '%s' resource\n",
- name, res->cdata.res_name);
+ name, res->config_data.res_name);
return -EPERM;
}
- switch (res->cdata.res_type) {
+ switch (res->config_data.res_type) {
case PASS_RESOURCE_CPU_ID:
- ret = info->open(res->cdata.res_name, info,
+ ret = info->open(res->config_data.res_name, info,
(struct pass_resource_common**)&res->hal.cpu);
break;
case PASS_RESOURCE_BUS_ID:
- ret = info->open(res->cdata.res_name, info,
+ ret = info->open(res->config_data.res_name, info,
(struct pass_resource_common**)&res->hal.bus);
break;
case PASS_RESOURCE_GPU_ID:
- ret = info->open(res->cdata.res_name, info,
+ ret = info->open(res->config_data.res_name, info,
(struct pass_resource_common**)&res->hal.gpu);
break;
case PASS_RESOURCE_MEMORY_ID:
- ret = info->open(res->cdata.res_name, info,
+ ret = info->open(res->config_data.res_name, info,
(struct pass_resource_common**)&res->hal.memory);
break;
case PASS_RESOURCE_NONSTANDARD_ID:
- ret = info->open(res->cdata.res_name, info,
+ ret = info->open(res->config_data.res_name, info,
(struct pass_resource_common**)&res->hal.nonstandard);
break;
};
if (ret < 0) {
_E("Failed to open %s.so for '%s' resource\n",
- name, res->cdata.res_name);
+ name, res->config_data.res_name);
return -EINVAL;
}
if (!res)
return -EINVAL;
- switch (res->cdata.res_type) {
+ switch (res->config_data.res_type) {
case PASS_RESOURCE_CPU_ID:
common = (struct pass_resource_common*)res->hal.cpu;
info = res->hal.cpu->common.info;
- ret = info->close(res->cdata.res_name, common);
+ ret = info->close(res->config_data.res_name, common);
break;
case PASS_RESOURCE_BUS_ID:
common = (struct pass_resource_common*)res->hal.bus;
info = res->hal.bus->common.info;
- ret = info->close(res->cdata.res_name, common);
+ ret = info->close(res->config_data.res_name, common);
break;
case PASS_RESOURCE_GPU_ID:
common = (struct pass_resource_common*)res->hal.gpu;
info = res->hal.gpu->common.info;
- ret = info->close(res->cdata.res_name, common);
+ ret = info->close(res->config_data.res_name, common);
break;
case PASS_RESOURCE_MEMORY_ID:
common = (struct pass_resource_common*)res->hal.memory;
info = res->hal.memory->common.info;
- ret = info->close(res->cdata.res_name, common);
+ ret = info->close(res->config_data.res_name, common);
break;
case PASS_RESOURCE_NONSTANDARD_ID:
common = (struct pass_resource_common*)res->hal.nonstandard;
info = res->hal.nonstandard->common.info;
- ret = info->close(res->cdata.res_name, common);
+ ret = info->close(res->config_data.res_name, common);
break;
default:
return -EINVAL;
if (ret < 0) {
_E("Failed to close %s.so for '%s' resource\n",
- info->name, res->cdata.res_name);
+ info->name, res->config_data.res_name);
return -EINVAL;
}
/* Get the load_table of each resource to estimate the system load. */
int pass_get_cpu_stats(struct pass_resource *res)
{
- struct pass_policy *policy;
struct pass_cpu_stats *stats;
char str[BUFF_MAX];
FILE *fp_stats = NULL;
if (!res)
return -EINVAL;
- policy = &res->policy;
-
- stats = policy->pass_cpu_stats;
- res = to_pass_resource(policy);
+ stats = res->cpuhp.pass_cpu_stats;
if (!stats) {
_E("invalid parameter of structure pass_cpu_stats");
return -EINVAL;
}
- fp_stats = fopen(res->cdata.path_load_table, "r");
+ fp_stats = fopen(res->config_data.path_load_table, "r");
if (fp_stats == NULL)
return -EIO;
return -EIO;
}
- for (i = 0; i < policy->num_pass_cpu_stats; i++) {
+ for (i = 0; i < res->cpuhp.num_pass_cpu_stats; i++) {
ret = fscanf(fp_stats, "%" SCNd64 "%u %u %u",
&stats[i].time,
&stats[i].freq,
return -EIO;
}
- for (j = 0; j < res->cdata.num_cpus; j++) {
+ for (j = 0; j < res->config_data.num_cpus; j++) {
ret = fscanf(fp_stats, "%u", &stats[i].load[j]);
if (ret < 0) {
fclose(fp_stats);
static int parse_pmqos(struct parse_result *result, void *user_data)
{
- struct pass_policy *policy = user_data;
- struct pass_pmqos *pmqos = &policy->pmqos;
+ struct pass_resource *res = user_data;
+ struct pass_pmqos *pmqos = &res->pmqos;
- if (!policy || !result)
+ if (!result)
return 0;
if (!result->section || !result->name || !result->value)
static int parse_core(struct parse_result *result, void *user_data)
{
- struct pass_policy *policy = user_data;
+ struct pass_resource *res = user_data;
if (!result)
return 0;
return 0;
if (MATCH(result->name, "pass_support"))
- policy->state = atoi(result->value);
+ res->config_data.state = atoi(result->value);
else if (MATCH(result->name, "pass_gov_type"))
- policy->gov_type = atoi(result->value);
+ res->config_data.gov_type = atoi(result->value);
else if (MATCH(result->name, "pass_num_levels")) {
unsigned int num_levels = atoi(result->value);
_E("cannot parse %s\n", result->name);
return -EINVAL;
}
- policy->num_levels = num_levels;
+ res->config_data.num_levels = num_levels;
} else if (MATCH(result->name, "pass_min_level"))
- policy->min_level = atoi(result->value);
+ res->rescon.min_level = atoi(result->value);
else if (MATCH(result->name, "pass_max_level"))
- policy->max_level = atoi(result->value);
+ res->rescon.max_level = atoi(result->value);
+ else if (MATCH(result->name, "pass_init_level"))
+ res->rescon.init_level = atoi(result->value);
+
else if (MATCH(result->name, "pass_num_cpu_stats"))
- policy->num_pass_cpu_stats = atoi(result->value);
+ res->cpuhp.num_pass_cpu_stats = atoi(result->value);
else if (MATCH(result->name, "pass_cpu_threshold"))
- policy->pass_cpu_threshold = atoi(result->value);
+ res->cpuhp.pass_cpu_threshold = atoi(result->value);
else if (MATCH(result->name, "pass_up_threshold"))
- policy->up_threshold = atoi(result->value);
+ res->cpuhp.up_threshold = atoi(result->value);
else if (MATCH(result->name, "pass_down_threshold"))
- policy->down_threshold = atoi(result->value);
- else if (MATCH(result->name, "pass_init_level"))
- policy->init_level = atoi(result->value);
+ res->cpuhp.down_threshold = atoi(result->value);
else if (MATCH(result->name, "pass_level_up_threshold"))
- policy->level_up_threshold = atoi(result->value);
+ res->cpuhp.level_up_threshold = atoi(result->value);
else if (MATCH(result->name, "pass_governor_timeout")) {
- policy->gov_timeout = atof(result->value);
+ res->config_data.gov_timeout = atof(result->value);
- if (MIN_TIMEOUT_SEC > policy->gov_timeout)
- policy->gov_timeout = MIN_TIMEOUT_SEC;
+ if (MIN_TIMEOUT_SEC > res->config_data.gov_timeout)
+ res->config_data.gov_timeout = MIN_TIMEOUT_SEC;
}
- if (policy->num_levels > 0 && !policy->levels) {
- policy->levels = calloc(policy->num_levels,
+ if (res->config_data.num_levels > 0 && !res->config_data.levels) {
+ res->config_data.levels = calloc(res->config_data.num_levels,
sizeof(struct pass_level));
- if (!policy->levels) {
+ if (!res->config_data.levels) {
_E("cannot allocate memory for levels\n");
return -EINVAL;
}
static int parse_each_resource(struct parse_result *result, void *user_data)
{
- struct pass_policy *policy = user_data;
- struct pass_pmqos *pmqos = &policy->pmqos;
+ struct pass_resource *res = user_data;
+ struct pass_pmqos *pmqos = &res->pmqos;
char section_name[BUFF_MAX];
int i, ret;
}
/* Parsing 'Level' section */
- for (i = 0; i < policy->num_levels; i++) {
+ for (i = 0; i < res->config_data.num_levels; i++) {
ret = snprintf(section_name, BUFF_MAX, "Level%d", i);
if (MATCH(result->section, section_name)) {
- ret = parse_level(result, &policy->levels[i]);
+ ret = parse_level(result, &res->config_data.levels[i]);
if (ret < 0) {
_E("cannot parse 'Level%d' section\n", i);
return ret;
{
char buf[BUFF_MAX];
struct pass *pass = user_data;
- struct pass_conf_data *conf_data = &(pass->res[id].cdata);
+ struct pass_resource_config_data *config_data
+ = &(pass->res[id].config_data);
if (!result)
return 0;
buf[i] = tolower(result->value[i]);
if (!strncmp(buf, PASS_RESOURCE_CPU_NAME, strlen(buf)))
- conf_data->res_type = PASS_RESOURCE_CPU_ID;
+ config_data->res_type = PASS_RESOURCE_CPU_ID;
else if (!strncmp(buf, PASS_RESOURCE_GPU_NAME, strlen(buf)))
- conf_data->res_type = PASS_RESOURCE_GPU_ID;
+ config_data->res_type = PASS_RESOURCE_GPU_ID;
else if (!strncmp(buf, PASS_RESOURCE_BUS_NAME, strlen(buf)))
- conf_data->res_type = PASS_RESOURCE_BUS_ID;
+ config_data->res_type = PASS_RESOURCE_BUS_ID;
else if (!strncmp(buf, PASS_RESOURCE_MEMORY_NAME, strlen(buf)))
- conf_data->res_type = PASS_RESOURCE_MEMORY_ID;
+ config_data->res_type = PASS_RESOURCE_MEMORY_ID;
else if (!strncmp(buf, PASS_RESOURCE_NONSTANDARD_NAME, strlen(buf)))
- conf_data->res_type = PASS_RESOURCE_NONSTANDARD_ID;
+ config_data->res_type = PASS_RESOURCE_NONSTANDARD_ID;
else
return -EINVAL;
} else if (MATCH(result->name, "pass_res_name")) {
- snprintf(conf_data->res_name, BUFF_MAX, "%s", result->value);
+ snprintf(config_data->res_name, BUFF_MAX, "%s", result->value);
} else if (MATCH(result->name, "pass_res_thermal_name")) {
- snprintf(conf_data->res_thermal_name, BUFF_MAX, "%s", result->value);
+ snprintf(config_data->res_thermal_name, BUFF_MAX, "%s", result->value);
} else if (MATCH(result->name, "pass_path_conf_file")) {
- snprintf(conf_data->path_conf_file, BUFF_MAX, "%s", result->value);
+ snprintf(config_data->path_conf_file, BUFF_MAX, "%s", result->value);
} else if (MATCH(result->name, "pass_path_load_table")) {
- snprintf(conf_data->path_load_table, BUFF_MAX, "%s", result->value);
+ snprintf(config_data->path_load_table, BUFF_MAX, "%s", result->value);
} else if (MATCH(result->name, "pass_first_cpu")) {
- int res_type = conf_data->res_type;
+ int res_type = config_data->res_type;
switch (res_type) {
case PASS_RESOURCE_CPU_ID:
- conf_data->cpu = atoi(result->value);
+ config_data->cpu = atoi(result->value);
break;
default:
return -EINVAL;
}
} else if (MATCH(result->name, "pass_num_cpus")) {
- int res_type = conf_data->res_type;
+ int res_type = config_data->res_type;
switch (res_type) {
case PASS_RESOURCE_CPU_ID:
- conf_data->num_cpus = atoi(result->value);
+ config_data->num_cpus = atoi(result->value);
break;
default:
return -EINVAL;
cur = &pass->res[i];
- cur->initdata.dvfs.governor = NULL;
- cur->initdata.dvfs.min_freq = -1;
- cur->initdata.dvfs.max_freq = -1;
- cur->initdata.dvfs.up_threshold = -1;
+ cur->init_data.dvfs.governor = NULL;
+ cur->init_data.dvfs.min_freq = -1;
+ cur->init_data.dvfs.max_freq = -1;
+ cur->init_data.dvfs.up_threshold = -1;
- cur->initdata.hotplug.online_state = NULL;
- cur->initdata.hotplug.online_min_num = -1;
- cur->initdata.hotplug.online_max_num = -1;
+ cur->init_data.hotplug.online_state = NULL;
+ cur->init_data.hotplug.online_min_num = -1;
+ cur->init_data.hotplug.online_max_num = -1;
- cur->initdata.memory.fault_around_bytes = -1;
+ cur->init_data.memory.fault_around_bytes = -1;
}
} else {
_E("cannot parse the number of resource\n");
*/
int pass_get_each_resource_config(struct pass_resource *res, char *path)
{
- struct pass_policy *policy;
+ struct pass_cpuhp *cpuhp;
+ struct pass_pmqos *pmqos;
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, parse_each_resource, policy);
+ cpuhp = &res->cpuhp;
+ pmqos = &res->pmqos;
+
+ res->config_data.state = PASS_UNUSED;
+ res->config_data.gov_type = 0;
+ res->config_data.gov_timeout = 0;
+ res->config_data.num_levels = 0;
+ res->config_data.levels = NULL;
+
+ /* Initialize the ResCon's data */
+ res->rescon.init_level = 0;
+ res->rescon.prev_level = 0;
+ res->rescon.min_level = 0;
+ res->rescon.max_level = 0;
+
+ /* Initialize the CPUHP's data */
+ cpuhp->num_pass_cpu_stats = 0;
+ cpuhp->pass_cpu_threshold = 0;
+ cpuhp->up_threshold = 0;
+ cpuhp->down_threshold = 0;
+ cpuhp->level_up_threshold = 0;
+ cpuhp->last_time = 0;
+
+ /* Initialize the PMQoS's data */
+ pmqos->state = PASS_UNUSED;
+
+ ret = config_parse(path, parse_each_resource, res);
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)
+ if (res->config_data.state == PASS_UNUSED)
return -EINVAL;
- if (policy->pmqos.state == PASS_UNUSED)
+ if (pmqos->state == PASS_UNUSED)
_W("%s don't include the list of pass-scenario\n");
- else if (policy->pmqos.state == PASS_OFF)
+ else if (pmqos->state == PASS_OFF)
_I("cannot use pass-scenario");
return 0;
*/
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 (res->config_data.levels) {
+ free(res->config_data.levels);
+ res->config_data.levels = NULL;
}
- if (policy->pmqos.scenarios) {
- free(policy->pmqos.scenarios);
- policy->pmqos.scenarios = NULL;
+ if (res->pmqos.scenarios) {
+ free(res->pmqos.scenarios);
+ res->pmqos.scenarios = NULL;
}
- policy->pmqos.num_scenarios = 0;
+ res->pmqos.num_scenarios = 0;
}
/*
* PASS (Power Aware System Service) PMQoS
*
- * 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.
static int pmqos_notifier_cb(void *data, void *user_data)
{
struct pass_resource *res = user_data;
- struct pass_policy *policy;
- struct pass_conf_data *cdata;
+ struct pass_resource_config_data *config_data;
struct pass_pmqos *pmqos;
struct pass_scenario *scn = NULL;
enum pass_state locked = PASS_UNUSED;
if (!res)
return -EINVAL;
- policy = &res->policy;
+ config_data = &res->config_data;
+ pmqos = &res->pmqos;
- if (!policy->pmqos.scenarios || policy->pmqos.state != PASS_ON)
+ if (pmqos->state != PASS_ON || !pmqos->scenarios)
return 0;
- cdata = &res->cdata;
- pmqos = &policy->pmqos;
-
/*
* Parse scenario name(data) whether to include 'Lock' or 'Unlock'
* string and divide correct scenario name.
index = find_scenario_index(pmqos, name);
if (index < 0) {
_W("Unknown scenario (%s) for '%s' resource\n",
- name, cdata->res_name);
+ name, config_data->res_name);
return -EINVAL;
}
scn = &pmqos->scenarios[index];
/* Check the state of each scenario whether to support or not */
if (scn->state != PASS_ON) {
_W("Not supported '%s' scenario for '%s' resource\n",
- name, cdata->res_name);
+ name, config_data->res_name);
return 0;
}
if (scn->locked == locked) {
_E("'%s' scenario is already %s for '%s' resource\n", name,
(locked == PASS_ON) ? "Locked" : "Unlocked",
- cdata->res_name);
+ config_data->res_name);
return 0;
}
scn->locked = locked;
if (scn->locked) {
if (pmqos->num_locked_scenarios == 0)
- new_level = pmqos->init_level = policy->curr_level;
+ new_level = pmqos->init_level = res->rescon.curr_level;
else
new_level = pmqos->curr_level;
min_level = MAX(scn->min_level, pmqos->min_level);
if (pmqos->num_locked_scenarios == 0) {
new_level = pmqos->init_level;
- min_level = policy->default_min_level;
- max_level = policy->default_max_level;
+ min_level = res->config_data.default_min_level;
+ max_level = res->config_data.default_max_level;
pmqos->curr_level = 0;
pmqos->min_level = 0;
if (scn->locked) {
_I("Lock '%s' scenario for '%s' resource\n",
- name, cdata->res_name);
+ name, config_data->res_name);
pmqos->scenarios[index].locked_time = get_time_ms();
} else {
_I("UnLock '%s' scenario for '%s' resource (%lldms)\n",
- name, cdata->res_name,
+ name, config_data->res_name,
(get_time_ms() - pmqos->scenarios[index].locked_time));
pmqos->scenarios[index].locked_time = 0;
/*
* PASS (Power Aware System Service) Governor
*
- * 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.
#include "pass.h"
#include "pass-hal.h"
-/*
- * pass_hotplug_set_online - Change the minimum number of online cpu
- *
- * @policy: the instance of struct pass_policy
- * @min_num: the minimum number of online cpu
- */
-static void hotplug_set_online(struct pass_policy *policy,
+static void hotplug_set_online(struct pass_resource *res,
unsigned int min_num)
{
- struct pass_resource *res = to_pass_resource(policy);
- struct pass_hotplug *hotplug = policy->hotplug;
+ struct pass_hotplug *hotplug = res->cpuhp.hotplug;
int i;
if (!hotplug || min_num == hotplug->online)
*/
int pass_rescon_set_level(struct pass_resource *res, int new_level)
{
- struct pass_policy *policy;
- struct pass_conf_data *cdata;
struct pass_level *levels;
- struct pass_hotplug *hotplug;
+ struct pass_cpuhp *cpuhp = &res->cpuhp;
int curr_level;
int limit_max_freq;
int limit_min_freq;
if (!res)
return -EINVAL;
- policy = &res->policy;
+ levels = res->config_data.levels;
+ curr_level = res->rescon.curr_level;
- cdata = &res->cdata;
- levels = policy->levels;
- hotplug = policy->hotplug;
- curr_level = policy->curr_level;
+ if (new_level > res->rescon.max_level)
+ new_level = res->rescon.max_level;
- if (new_level > policy->max_level)
- new_level = policy->max_level;
-
- if (new_level < policy->min_level)
- new_level = policy->min_level;
+ if (new_level < res->rescon.min_level)
+ new_level = res->rescon.min_level;
if (new_level == curr_level)
return 0;
limit_min_freq = levels[new_level].limit_min_freq;
fault_around_bytes = levels[new_level].fault_around_bytes;
- policy->prev_level = curr_level;
- policy->curr_level = new_level;
+ res->rescon.prev_level = curr_level;
+ res->rescon.curr_level = new_level;
/* Turn on/off CPUs according the maximum number of online CPU */
- if (hotplug) {
- if (hotplug->governor)
- limit_min_cpu = hotplug->governor(res);
+ if (cpuhp->hotplug) {
+ if (cpuhp->hotplug->governor)
+ limit_min_cpu = cpuhp->hotplug->governor(res);
else
limit_min_cpu = 1;
- hotplug_set_online(policy, limit_min_cpu);
+ hotplug_set_online(res, limit_min_cpu);
}
/* Set maximum frequency */
ret = pass_set_max_freq(res, limit_max_freq);
if (ret < 0) {
_E("cannot set the maximum frequency of %s",
- cdata->res_name);
+ res->config_data.res_name);
return -EINVAL;
}
}
ret = pass_set_min_freq(res, limit_min_freq);
if (ret < 0) {
_E("cannot set the minimum frequency of %s",
- cdata->res_name);
+ res->config_data.res_name);
return -EINVAL;
}
}
ret = pass_set_fault_around_bytes(res, fault_around_bytes);
if (ret < 0) {
_E("cannot set the fault_around_bytes of %s",
- cdata->res_name);
+ res->config_data.res_name);
return -EINVAL;
}
}
/*
_I("[PASS %s] Level %4s '%d->%d' : 'max %d | min %d'Hz/'%d'Core\n",
- res->cdata.res_name,
+ res->config_data.res_name,
(curr_level > new_level ? "DOWN" : "UP"),
curr_level, new_level,
limit_max_freq, limit_min_freq, limit_min_cpu);
int pass_rescon_set_level_scope(struct pass_resource *res, int new_level,
int min_level, int max_level, void *data)
{
- struct pass_policy *policy;
-
if (!res)
return -EINVAL;
- policy = &res->policy;
/*
* FIXME: PMQoS core sends the raw data to the HAL in order to
return -EINVAL;
}
- if (min_level == policy->min_level
- && max_level == policy->max_level)
+ if (min_level == res->rescon.min_level
+ && max_level == res->rescon.max_level)
return 0;
/* Change minimum/maximum pass level */
- policy->min_level = min_level;
- policy->max_level = max_level;
+ res->rescon.min_level = min_level;
+ res->rescon.max_level = max_level;
pass_rescon_set_level(res, new_level);
/*
* PASS (Power Aware System Service)
*
- * Copyright (c) 2012 - 2015 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.
******************************************************/
static int pass_init_resource(struct pass_resource *res)
{
- struct pass_policy *policy = &res->policy;
+ struct pass_cpuhp *cpuhp = &res->cpuhp;
int max_freq = 0;
int ret;
int i;
/* Get configuration of each resource from pass-resource*.conf */
- ret = pass_get_each_resource_config(res, res->cdata.path_conf_file);
+ ret = pass_get_each_resource_config(res, res->config_data.path_conf_file);
if (ret < 0) {
- _E("cannot parse %s\n", res->cdata.path_conf_file);
+ _E("cannot parse %s\n", res->config_data.path_conf_file);
return -1;
}
/* Check whether PASS is initialzied state or not */
- if (policy->governor) {
+ if (res->state) {
_I("PASS is already active state");
return -1;
}
/*
- * Set default value to global pass_policy instance
+ * Set default value to global pass_resource instance
* if variable isn't initialized.
*/
- if (!policy->min_level)
- policy->min_level = PASS_DEFAULT_MIN_LEVEL;
- policy->default_min_level = policy->min_level;
+ if (!res->rescon.min_level)
+ res->rescon.min_level = PASS_DEFAULT_MIN_LEVEL;
+ res->config_data.default_min_level = res->rescon.min_level;
- if (!policy->max_level)
- policy->max_level = policy->num_levels - 1;
- policy->default_max_level = policy->max_level;
+ if (!res->rescon.max_level)
+ res->rescon.max_level = res->config_data.num_levels - 1;
+ res->config_data.default_max_level = res->rescon.max_level;
- if (!policy->init_level)
- policy->init_level = PASS_DEFAULT_MIN_LEVEL;
+ if (!res->rescon.init_level)
+ res->rescon.init_level = PASS_DEFAULT_MIN_LEVEL;
- if (!policy->pass_cpu_threshold)
- policy->pass_cpu_threshold = PASS_DEFAULT_CPU_THRESHOLD;
+ if (!cpuhp->pass_cpu_threshold)
+ cpuhp->pass_cpu_threshold = PASS_DEFAULT_CPU_THRESHOLD;
- if (!policy->up_threshold)
- policy->up_threshold = PASS_DEFAULT_LEVEL_UP_THRESHOLD;
+ if (!cpuhp->up_threshold)
+ cpuhp->up_threshold = PASS_DEFAULT_LEVEL_UP_THRESHOLD;
- if (!policy->down_threshold)
- policy->down_threshold = PASS_DEFAULT_LEVEL_DOWN_THRESHOLD;
+ if (!cpuhp->down_threshold)
+ cpuhp->down_threshold = PASS_DEFAULT_LEVEL_DOWN_THRESHOLD;
- if (!policy->level_up_threshold)
- policy->level_up_threshold = policy->max_level;
+ if (!cpuhp->level_up_threshold)
+ cpuhp->level_up_threshold = 0;
- if (!policy->num_pass_cpu_stats)
- policy->num_pass_cpu_stats = PASS_CPU_STATS_DEFAULT;
+ if (!cpuhp->num_pass_cpu_stats)
+ cpuhp->num_pass_cpu_stats = PASS_CPU_STATS_DEFAULT;
- for (i = 0; i < policy->num_levels; i++) {
- if (max_freq < policy->levels[i].limit_max_freq)
- max_freq = policy->levels[i].limit_max_freq;
- if (policy->levels[i].gov_timeout == 0)
- policy->levels[i].gov_timeout = policy->gov_timeout;
+ for (i = 0; i < res->config_data.num_levels; i++) {
+ if (max_freq < res->config_data.levels[i].limit_max_freq)
+ max_freq = res->config_data.levels[i].limit_max_freq;
+ if (res->config_data.levels[i].gov_timeout == 0)
+ res->config_data.levels[i].gov_timeout =
+ res->config_data.gov_timeout;
}
- policy->freq.max_freq = max_freq;
+ cpuhp->freq.max_freq = max_freq;
/* Allocate memory according to the number of data and cpu */
- policy->pass_cpu_stats = calloc(policy->num_pass_cpu_stats,
+ cpuhp->pass_cpu_stats = calloc(cpuhp->num_pass_cpu_stats,
sizeof(struct pass_cpu_stats));
- for (i = 0; i < policy->num_pass_cpu_stats; i++) {
- policy->pass_cpu_stats[i].load =
- calloc(res->cdata.num_cpus, sizeof(unsigned int));
- policy->pass_cpu_stats[i].nr_running =
- calloc(res->cdata.num_cpus, sizeof(unsigned int));
- policy->pass_cpu_stats[i].runnable_load =
- calloc(res->cdata.num_cpus, sizeof(unsigned int));
+ for (i = 0; i < cpuhp->num_pass_cpu_stats; i++) {
+ cpuhp->pass_cpu_stats[i].load =
+ calloc(res->config_data.num_cpus, sizeof(unsigned int));
+ cpuhp->pass_cpu_stats[i].nr_running =
+ calloc(res->config_data.num_cpus, sizeof(unsigned int));
+ cpuhp->pass_cpu_stats[i].runnable_load =
+ calloc(res->config_data.num_cpus, sizeof(unsigned int));
}
/* Get the instance of PASS governor */
- policy->governor = pass_get_governor(res, policy->gov_type);
- if (!policy->governor) {
+ cpuhp->governor = pass_get_governor(res, res->config_data.gov_type);
+ if (!cpuhp->governor) {
_E("cannot get the instance of PASS governor");
return -1;
}
/* Get the instance of PASS hotplug */
- policy->hotplug = pass_get_hotplug(res, policy->gov_type);
- if (policy->hotplug) {
- policy->hotplug->sequence = calloc(res->cdata.num_cpus,
+ cpuhp->hotplug = pass_get_hotplug(res, res->config_data.gov_type);
+ if (cpuhp->hotplug) {
+ cpuhp->hotplug->sequence = calloc(res->config_data.num_cpus,
sizeof(int));
- for (i = 0; i < res->cdata.num_cpus; i++)
- policy->hotplug->sequence[i] = i + res->cdata.cpu;
+ for (i = 0; i < res->config_data.num_cpus; i++)
+ cpuhp->hotplug->sequence[i] = i + res->config_data.cpu;
- policy->hotplug->num_cpus = res->cdata.num_cpus;
+ cpuhp->hotplug->num_cpus = res->config_data.num_cpus;
}
ret = pass_governor_init(res);
static int pass_exit_resource(struct pass_resource *res)
{
- struct pass_policy *policy = &res->policy;
int ret;
/* Put configuration of each resource from pass-resource*.conf */
return ret;
}
- policy->governor = NULL;
-
return 0;
}
/* Print the information for all h/w resources */
for (i = 0; i < g_pass.num_resources; i++) {
- struct pass_conf_data *cdata = &g_pass.res[i].cdata;
-
- _I("Resource%d type : %d\n", i, cdata->res_type);
- _I("Resource%d name : %s\n", i, cdata->res_name);
- _I("Resource%d thermal name : %s\n", i, cdata->res_thermal_name);
- _I("Resource%d path_conf_file : %s\n", i, cdata->path_conf_file);
- _I("Resource%d path_load_table: %s\n", i, cdata->path_load_table);
- _I("Resource%d number of cpus : %d\n", i, cdata->num_cpus);
- _I("Resource%d first cpu : %d\n\n", i, cdata->cpu);
+ struct pass_resource_config_data *config_data =
+ &g_pass.res[i].config_data;
+
+ _I("Resource%d type : %d\n", i, config_data->res_type);
+ _I("Resource%d name : %s\n", i, config_data->res_name);
+ _I("Resource%d thermal name : %s\n", i, config_data->res_thermal_name);
+ _I("Resource%d path_conf_file : %s\n", i, config_data->path_conf_file);
+ _I("Resource%d path_load_table: %s\n", i, config_data->path_load_table);
+ _I("Resource%d number of cpus : %d\n", i, config_data->num_cpus);
+ _I("Resource%d first cpu : %d\n\n", i, config_data->cpu);
}
/* Initialize pass resources data based on parsed configuration */
for (i = 0; i < g_pass.num_resources; i++) {
struct pass_resource *res = &g_pass.res[i];
- struct pass_conf_data *cdata = &g_pass.res[i].cdata;
+ struct pass_resource_config_data *config_data =
+ &g_pass.res[i].config_data;
ret = pass_get_resource(res);
if (ret < 0) {
_E("Cannot get the pass '%s' resource (%d)\n",
- cdata->res_name, ret);
+ config_data->res_name, ret);
res->state = PASS_UNUSED;
continue;
ret = pass_save_initdata(res);
if (ret < 0) {
_E("Cannot save initdata of '%s' resource (%d)\n",
- cdata->res_name, ret);
+ config_data->res_name, ret);
ret = pass_put_resource(res);
if (ret < 0)
_E("Cannot put the pass '%s' resource (%d)\n",
- cdata->res_name, ret);
+ config_data->res_name, ret);
res->state = PASS_UNUSED;
continue;
ret = pass_init_resource(res);
if (ret < 0) {
_E("Cannot initialize the pass '%s' resource (%d)\n",
- cdata->res_name, ret);
+ config_data->res_name, ret);
ret = pass_restore_initdata(res);
if (ret < 0)
_E("Cannot restore the initdata of '%s' "
- "resource (%d)\n", cdata->res_name, ret);
+ "resource (%d)\n", config_data->res_name, ret);
ret = pass_put_resource(res);
if (ret < 0)
_E("Cannot put the pass '%s' resource (%d)\n",
- cdata->res_name, ret);
+ config_data->res_name, ret);
res->state = PASS_UNUSED;
continue;
for (i = 0; i < g_pass.num_resources; i++) {
struct pass_resource *res = &g_pass.res[i];
- struct pass_conf_data *cdata = &g_pass.res[i].cdata;
+ struct pass_resource_config_data *config_data =
+ &g_pass.res[i].config_data;
if (res->state == PASS_UNUSED)
continue;
ret = pass_exit_resource(res);
if (ret < 0)
_E("Cannot exit the pass '%s' resource (%d)\n",
- cdata->res_name, ret);
+ config_data->res_name, ret);
ret = pass_restore_initdata(res);
if (ret < 0)
_E("Cannot restore initdata of '%s' resource (%d)\n",
- cdata->res_name, ret);
+ config_data->res_name, ret);
ret = pass_put_resource(res);
if (ret < 0) {
_E("Cannot put the pass '%s' resource (%d)\n",
- cdata->res_name, ret);
+ config_data->res_name, ret);
}
res->state = PASS_OFF;
/*
* PASS (Power Aware System Service)
*
- * 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.
#include <pass/log.h>
#define BUFF_MAX 255
-
-/******************************************************
- * PASS Governors *
- ******************************************************/
#define PASS_LEVEL_COND_MAX 3
struct pass_resource;
-struct pass_policy;
struct pass_governor;
-/*
- * PASS state
- */
-enum pass_state {
- PASS_UNUSED = -1,
- PASS_OFF = 0,
- PASS_ON = 1,
-};
-
/*
* PASS Governor type
*
PASS_GOV_END,
};
-enum pass_gov_state {
- PASS_GOV_NONE = 0,
- PASS_GOV_START,
- PASS_GOV_STOP,
+enum pass_state {
+ PASS_UNUSED = -1,
+ PASS_OFF = 0,
+ PASS_ON = 1,
};
-/******************************************************
- * PASS basic data *
- ******************************************************/
-/*
- * struct pass_cpu_stats
- *
- * @path: the path of load_table on kernel interface
- * @time: current time
- * @freq: current cpu frequency
- * @freq: new cpu frequency
- * @nr_runnings: the average number of running threads
- * @nr_running[]: current number of running threads of each core
- * @runnable_load[]: the runnable load of each core
- * @busy_cpu: the number of busy cpu
- * @avg_load: the average load of all CPUs
- * @avg_runnable_load: the average runnable load of all CPUs
- * @avg_thread_load: the Per-thread load
- * @avg_thread_runnable_load: the Per-thread runnable load
- */
struct pass_cpu_stats {
const char *path;
unsigned int avg_thread_runnable_load;
};
-/******************************************************
- * PASS interface *
- ******************************************************/
+struct pass_hotplug {
+ char name[BUFF_MAX];
+ unsigned int num_cpus;
+ unsigned int online;
+ unsigned int *sequence;
+ int (*governor)(struct pass_resource *res);
+};
+
+struct pass_freq_policy {
+ unsigned int max_freq;
+ unsigned int sampling_rate;
+ unsigned int up_threshold;
+};
+
struct pass_level_condition {
int freq;
int nr_running;
int avg_load;
};
+/******************************************************
+ * PASS Basic Unit *
+ ******************************************************/
+
/*
- * struct pass_level - Represent the PASS's level
+ * struct pass_level - Represent 'level' which includes real value of h/w
*
* @limit_max_freq: the limited maximum frequency
* this property is used for the following resoures:
};
/*
- * struct pass_hotplug - store information of cpu hotplug
- * @num_cpus: the possible maximum number of online cpus
- * @online: the current number of online cpu
- * @sequence: the sequence to turn on/off cpu
+ * struct pass_scenario - Represent 'scenario'
+ *
+ * @name: the unique scenario name.
+ * @state: the state of the scenario (either supported or not).
+ * @locked: the locked state of scenario (either locked or unlocked).
+ * @locked_time: the requiired locking time of scenario.
+ * @min_level: the required minimum PASS's level.
+ * @max_level: the required maximum PASS's level.
*/
-struct pass_hotplug {
- char name[BUFF_MAX];
- unsigned int num_cpus;
- unsigned int online;
- unsigned int *sequence;
- int (*governor)(struct pass_resource *res);
-};
-
-
-struct pass_freq_policy {
- unsigned int max_freq;
- unsigned int sampling_rate;
- unsigned int up_threshold;
-};
-
struct pass_scenario {
char name[BUFF_MAX];
enum pass_state state;
unsigned int max_level;
};
+/******************************************************
+ * PASS Module *
+ ******************************************************/
+
+/*
+ * struct pass_rescon - Represent ResCon (Resource-Controller) module
+ *
+ * @init_level: the required initial level when initializing h/w resource..
+ * @curr_level: the current level controlled by resource-controller.
+ * @prev_level: the previous level controlled by resource-controller.
+ * @min_level: the available minimum level controlled by resource-controller.
+ * @max_level: the available maxiumu level controlled by resource-controller.
+ *
+ * ResCon should be always enabled in order to controle h/w resources.
+ */
+struct pass_rescon {
+ unsigned int init_level;
+ unsigned int curr_level;
+ unsigned int prev_level;
+ unsigned int min_level;
+ unsigned int max_level;
+};
+
+/*
+ * struct pass_pmqos - Represent PMQoS module
+ *
+ * @state: the state of PMQoS (either enabled or disabled).
+ * @num_scenarios: the number of scenarios.
+ * @num_locked_scenarios: the number of locked scenarios.
+ * @scenarios: the list of scenarios.
+ * @init_level: the initial level according to first locked scenario.
+ * @curr_level: the current level according to locked scenarios.
+ * @min_level: the available minimum level according to locked scenarios.
+ * @max_level: the availabl maximum level according to locked scenarios.
+ *
+ * PMQoS may be enabled or disabled according to configuration file setting.
+ */
struct pass_pmqos {
enum pass_state state;
+
unsigned int num_scenarios;
unsigned int num_locked_scenarios;
-
struct pass_scenario *scenarios;
unsigned int init_level;
};
/*
- * struct pass_policy
+ * struct pass_cpuhp - Represent CPUHP (CPU Hotplug Manager) module
+ *
+ * @state: the state of CPUHP (either enabled or disabled).
+ * @pass_cpu_threshold:
+ * @up_threshold: the threshold used when increasing the level
+ * @down_threshold: the threshold used when decreasing the level
+ * @num_pass_cpu_stats: the number of history for CPU utilization/nr_runnings
+ * @pass_cpu_stats: the list of CPU utilization/nr_runnings
+ * @last_time: the updated last time of cpu_stats
+ * @governor: the instance of CPUHP Policy governor.
+ * @gov_timeout_id: the periodic timer id
+ *
+ * @hotplug: the instance of CPU Hotplug governor (will be deprecated).
+ * @freq: store cpufreq's variables (will be deprecated).
+ * @level_up_threshold: threshold used when changing level (will be deprecated).
+ *
+ * CPUHP may be o enabled or disabled according to configuration file setting.
*/
-struct pass_policy {
+struct pass_cpuhp {
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;
- unsigned int init_level;
- unsigned int prev_level;
- unsigned int curr_level;
- unsigned int min_level;
- unsigned int max_level;
-
- unsigned int default_min_level;
- unsigned int default_max_level;
-
- unsigned int num_levels;
- unsigned int level_up_threshold;
+ int num_pass_cpu_stats;
+ struct pass_cpu_stats *pass_cpu_stats;
int64_t last_time;
- struct pass_freq_policy freq;
-
- struct pass_level *levels;
- struct pass_cpu_stats *pass_cpu_stats;
- int num_pass_cpu_stats;
-
struct pass_governor *governor;
- double gov_timeout;
guint gov_timeout_id;
- struct pass_hotplug *hotplug;
- /* Private data for PMQoS */
- struct pass_pmqos pmqos;
+ struct pass_hotplug *hotplug;
+ struct pass_freq_policy freq;
+ unsigned int level_up_threshold;
};
/******************************************************
- * PASS resource *
+ * PASS Resource *
******************************************************/
/*
- * struct pass_conf_data - Parsed data for each h/w resource from
- * configuration file (pass.conf).
+ * struct pass_resource_config_data - Parsed data for each h/w resource.
*
- * Mandatory:
+ * Parsed data from resource list configuration (e.g., pass.conf)
+ * [Mandatory]
* @res_type: the unique id for each h/w resource. The id can have
* the one value among following defined resource id.
* - 1: PASS_RESOURCE_CPU_ID
* @path_conf_file: the path for PASS configuration file
* @path_load_table: the path for load_table entry from kernel
*
- * Optional:
+ * [Optional]
* @num_cpus: the number of supported cpus in the same cluster.
* @cpu: the index of first cpu in the same cluster.
+ *
+ *
+ * Parsed data from each resource info configuration (e.g., pass-resource*.conf)
+ * @gov_type: the governor type
+ * @gov_timeout: the sampling rate of timer.
+ * @default_min_level: the default minimum level.
+ * @default_max_level: the default maximum level.
+ * @num_levels: the number of levels.
+ * @levels: the list of levels.
+ *
+ * 'struct pass_resource_config_data's data can't be changed after initialized.
+ * It has the constant attribute after initialization step.
*/
-struct pass_conf_data {
+struct pass_resource_config_data {
+ /* Parsed data from resource list configuration (e.g., pass.conf) */
unsigned int res_type;
char res_name[BUFF_MAX];
char res_thermal_name[BUFF_MAX];
unsigned int num_cpus;
unsigned int cpu;
+
+ /*
+ * Parsed data from each resource info configuration
+ * (e.g., pass-resource*.conf)
+ */
+ enum pass_state state;
+ enum pass_gov_type gov_type;
+ double gov_timeout;
+ unsigned int default_min_level;
+ unsigned int default_max_level;
+
+ unsigned int num_levels;
+ struct pass_level *levels;
};
/*
- * struct pass_resource_initdata - Represent initial data of each h/w resource.
+ * struct pass_resource_init_data - Represent initial data of each h/w resource.
*
* @dvfs: the initial value of dvfs configuration
* - governor: the initial type of current governor
* @tmu: the initial value of tmu configuration
* @memory: the initial value of memory configuration
* - fault_around_bytes: the number of bytes to be mapped around the fault
+ *
+ * 'struct pass_resource_init_data's data can't be changed after initialized.
+ * It has the constant attribute after initialization step.
*/
-struct pass_resource_initdata {
+struct pass_resource_init_data {
struct {
char *governor;
int min_freq;
/*
* struct pass_resource - Represent the each h/w resource.
*
- * @state: represents the state of the corresponding resource.
- * @cdata: the parsed data from configuration file (pass.conf).
+ * @state: the state of h/w resource (either initialized or not).
+ * @config_data: the parsed data from configuration files (pass.conf,
+ * pass-resource*.conf).
+ * @init_data: the initial data to restore when pass service is stopped
* @hal: the hal instance of each h/w resource from pass_get_hal_info().
* - If res_type of cdata is PASS_RESOURCE_CPU_ID, hal.cpu will be used.
* - If res_type of cdata is PASS_RESOURCE_BUS_ID, hal.bus will be used.
* - If res_type of cdata is PASS_RESOURCE_MEMORY_ID, hal.memory will be used.
* - If res_type of cdata is PASS_RESOURCE_NONSTANDARD_ID,
* hal.nonstandard will be used.
- * @policy: the policy data to handle the h/w resource
- * @initdata: the initial data to restore when pass service is stopped
+ * @rescon: represents ResCon (Resource Controller) module.
+ * @cpuhp: represents CPUHP (CPU Hotplug Manager) module.
+ * @pmqos: represents PMQoS module.
*/
struct pass_resource {
enum pass_state state;
- struct pass_conf_data cdata;
- struct pass_policy policy;
- struct pass_resource_initdata initdata;
+
+ struct pass_resource_config_data config_data;
+ struct pass_resource_init_data init_data;
union {
struct pass_resource_cpu *cpu;
struct pass_resource_memory *memory;
struct pass_resource_nonstandard *nonstandard;
} hal;
+
+ struct pass_rescon rescon;
+ struct pass_cpuhp cpuhp;
+ struct pass_pmqos pmqos;
};
+/******************************************************
+ * PASS global structure *
+ ******************************************************/
+
+/*
+ * struct pass - Represent the each h/w resource.
+ *
+ * @state: the state of PASS subsystem (either started or stoped by systemctl)
+ * @num_resources: the number of h/w resources
+ * @res: the list of h/w resources
+ */
struct pass {
enum pass_state state;
unsigned int num_resources;
const typeof(((type *)0)->member) *__mptr = (ptr); \
(type *)((char *)__mptr - offsetof(type, member)); })
-#define to_pass_resource(policy) \
- container_of(policy, struct pass_resource, policy)
-
#endif /* __pass__ */