4 * Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd.
6 * Licensed under the Apache License, Version 2.0 (the License);
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
24 #include "pass-util.h"
26 /******************************************************
28 ******************************************************/
29 #define PASS_NAME_LEN 128
30 #define PASS_LEVEL_COND_MAX 3
31 #define PASS_CPU_STATS_DEFAULT 20
32 #define PASS_MIN_GOV_TIMEOUT 0.2
34 #define PASS_CONF_PATH "/etc/deviced/pass.conf"
72 * struct pass_governor
74 struct pass_governor {
75 char name[PASS_NAME_LEN];
76 int (*init)(struct pass_policy *);
77 int (*exit)(struct pass_policy *);
78 int (*update)(struct pass_policy *, enum pass_gov_state state);
79 int (*governor)(struct pass_policy *);
80 Ecore_Timer *gov_timer_id;
84 /******************************************************
86 ******************************************************/
89 * struct pass_cpu_stats
92 * @freq: current cpu frequency
93 * @freq: new cpu frequency
94 * @nr_runnings: the average number of running threads
95 * @nr_running[]: current number of running threads of each core
96 * @runnable_load[]: the runnable load of each core
97 * @busy_cpu: the number of busy cpu
98 * @avg_load: the average load of all CPUs
99 * @avg_runnable_load: the average runnable load of all CPUs
100 * @avg_thread_load: the Per-thread load
101 * @avg_thread_runnable_load: the Per-thread runnable load
103 struct pass_cpu_stats {
106 unsigned int freq_new;
107 unsigned int nr_runnings;
110 unsigned int *nr_running;
111 unsigned int *runnable_load;
113 unsigned int num_busy_cpu;
114 unsigned int avg_load;
115 unsigned int avg_runnable_load;
116 unsigned int avg_thread_load;
117 unsigned int avg_thread_runnable_load;
120 /******************************************************
122 ******************************************************/
123 struct pass_level_condition {
131 /* Constraints condition for powersaving */
135 /* Governor timer's timeout for each pass level */
138 /* Condition to determine up/down of pass level */
139 struct pass_level_condition comm_cond;
140 struct pass_level_condition up_cond[PASS_LEVEL_COND_MAX];
141 struct pass_level_condition down_cond[PASS_LEVEL_COND_MAX];
142 struct pass_level_condition left_cond[PASS_LEVEL_COND_MAX];
143 struct pass_level_condition right_cond[PASS_LEVEL_COND_MAX];
151 * struct pass_hotplug - store information of cpu hotplug
152 * @max_online: the possible maximum number of online cpu
153 * @online: the current number of online cpu
154 * @sequence: the sequence to turn on/off cpu
156 struct pass_hotplug {
157 char name[PASS_NAME_LEN];
158 unsigned int max_online;
160 unsigned int *sequence;
161 int (*governor)(struct pass_policy *);
165 struct pass_cpufreq_policy {
166 unsigned int max_freq;
167 unsigned int num_nr_cpus;
168 unsigned int sampling_rate;
169 unsigned int up_threshold;
172 struct pass_busfreq_policy {
176 struct pass_gpufreq_policy {
180 struct pass_scenario {
181 char name[PASS_NAME_LEN];
182 enum pass_state state;
183 enum pass_state locked;
186 unsigned int cpufreq_min_level;
187 unsigned int cpufreq_max_level;
189 unsigned int busfreq_min_level;
190 unsigned int busfreq_max_level;
192 unsigned int gpufreq_min_level;
193 unsigned int gpufreq_max_level;
196 struct pass_scenario_policy {
197 enum pass_state state;
198 unsigned int num_scenarios;
200 struct pass_scenario *list;
207 enum pass_state state;
208 enum pass_gov_type gov_type;
209 enum pass_gov_state gov_state;
210 unsigned int pass_cpu_threshold;
211 unsigned int up_threshold;
212 unsigned int down_threshold;
214 unsigned int init_level;
215 unsigned int prev_level;
216 unsigned int curr_level;
217 unsigned int min_level;
218 unsigned int max_level;
220 unsigned int default_min_level;
221 unsigned int default_max_level;
223 unsigned int num_levels;
224 unsigned int level_up_threshold;
226 struct pass_cpufreq_policy cpufreq;
227 struct pass_busfreq_policy busfreq;
228 struct pass_gpufreq_policy gpufreq;
229 struct pass_scenario_policy scenario;
231 struct pass_table *pass_table;
232 struct pass_cpu_stats *pass_cpu_stats;
233 int num_pass_cpu_stats;
235 struct pass_governor *governor;
237 struct pass_hotplug *hotplug;
239 #endif /* __pass__ */