#include "pass-hal.h"
#include "pass-rescon.h"
+#define PASS_DEFAULT_CPU_THRESHOLD 20
+#define PASS_DEFAULT_LEVEL_UP_THRESHOLD 30
+#define PASS_DEFAULT_LEVEL_DOWN_THRESHOLD 80
#define PASS_CPU_STATS_MAX_COUNT 20
struct pass_governor {
return true;
}
-/*****************************************************************************
- * PASS CPU Hotplug *
- ****************************************************************************/
-
/*
* pass_hotplug_stop - Stop PASS hotplug
* @res: the instance of struct pass_resource
return res->config_data.levels[level].limit_min_cpu;
}
-/*
- * 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_resource *res,
+static struct pass_hotplug* get_hotplug(struct pass_resource *res,
enum pass_gov_type type)
{
struct pass_hotplug *hotplug;
return NULL;
}
-/*****************************************************************************
- * PASS governor *
- ****************************************************************************/
-
/*
* pass_calculate_busy_cpu - Count a number of busy cpu among NR_CPUS by using
* runnable_avg_sum/runnable_avg_period
* pass_get_governor - Return specific governor instance according to type
* @type: the type of PASS governor
*/
-struct pass_governor* pass_get_governor(struct pass_resource *res,
+static struct pass_governor* get_governor(struct pass_resource *res,
enum pass_gov_type type)
{
switch (type) {
int pass_governor_init(struct pass_resource *res)
{
struct pass_cpuhp *cpuhp;
+ int max_freq = 0;
+ int i;
if (!res)
return -EINVAL;
cpuhp = &res->cpuhp;
+ if (!cpuhp->pass_cpu_threshold)
+ cpuhp->pass_cpu_threshold = PASS_DEFAULT_CPU_THRESHOLD;
+
+ if (!cpuhp->up_threshold)
+ cpuhp->up_threshold = PASS_DEFAULT_LEVEL_UP_THRESHOLD;
+
+ if (!cpuhp->down_threshold)
+ cpuhp->down_threshold = PASS_DEFAULT_LEVEL_DOWN_THRESHOLD;
+
+ if (!cpuhp->level_up_threshold)
+ cpuhp->level_up_threshold = 0;
+
+ if (!cpuhp->num_pass_cpu_stats)
+ cpuhp->num_pass_cpu_stats = PASS_CPU_STATS_MAX_COUNT;
+
+ 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;
+ cpuhp->freq.max_freq = max_freq;
+
+
+ /* Allocate memory according to the number of data and cpu */
+ cpuhp->pass_cpu_stats = calloc(cpuhp->num_pass_cpu_stats,
+ sizeof(struct pass_cpu_stats));
+
+ 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 CPU Hotplug's policy */
+ cpuhp->hotplug = 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->config_data.num_cpus; i++)
+ cpuhp->hotplug->sequence[i] = i + res->config_data.cpu;
+
+ cpuhp->hotplug->num_cpus = res->config_data.num_cpus;
+ }
+
+ /* Get the instance of CPUHP governor */
+ cpuhp->governor = get_governor(res, res->config_data.gov_type);
+ if (!cpuhp->governor) {
+ _E("cannot get the instance of PASS governor");
+ return -1;
+ }
+
if (!cpuhp->governor || !cpuhp->governor->init)
return -EINVAL;
int pass_governor_exit(struct pass_resource *res);
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,
- 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_resource *res);
int pass_radiation_governor(struct pass_resource *res);
#define DBUS_CORE_PATH "/Org/Tizen/System/Pass/Core"
#define PASS_CONF_PATH "/etc/pass/pass.conf"
#define PASS_DEFAULT_MIN_LEVEL 0
-#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;
******************************************************/
static int pass_init_resource(struct pass_resource *res)
{
- struct pass_cpuhp *cpuhp = &res->cpuhp;
- int max_freq = 0;
int ret;
int i;
if (!res->rescon.init_level)
res->rescon.init_level = PASS_DEFAULT_MIN_LEVEL;
- if (!cpuhp->pass_cpu_threshold)
- cpuhp->pass_cpu_threshold = PASS_DEFAULT_CPU_THRESHOLD;
-
- if (!cpuhp->up_threshold)
- cpuhp->up_threshold = PASS_DEFAULT_LEVEL_UP_THRESHOLD;
-
- if (!cpuhp->down_threshold)
- cpuhp->down_threshold = PASS_DEFAULT_LEVEL_DOWN_THRESHOLD;
-
- if (!cpuhp->level_up_threshold)
- cpuhp->level_up_threshold = 0;
-
- if (!cpuhp->num_pass_cpu_stats)
- cpuhp->num_pass_cpu_stats = PASS_CPU_STATS_DEFAULT;
-
- 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;
+ for (i = 0; i < res->config_data.num_levels; i++)
if (res->config_data.levels[i].gov_timeout == 0)
res->config_data.levels[i].gov_timeout =
res->config_data.gov_timeout;
- }
- cpuhp->freq.max_freq = max_freq;
-
- /* Allocate memory according to the number of data and cpu */
- cpuhp->pass_cpu_stats = calloc(cpuhp->num_pass_cpu_stats,
- sizeof(struct pass_cpu_stats));
-
- 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 */
- 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 */
- 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->config_data.num_cpus; i++)
- cpuhp->hotplug->sequence[i] = i + res->config_data.cpu;
-
- cpuhp->hotplug->num_cpus = res->config_data.num_cpus;
- }
ret = pass_governor_init(res);
if (ret < 0) {