Commit 8eeed0956615294200be783bb67d851280b5b1b9

Authored by Viresh Kumar
Committed by Rafael J. Wysocki
1 parent 09dca5ae75

cpufreq: governors: Get rid of dbs_data->enable field

CPUFREQ_GOV_START/STOP are called only once for all policy->cpus and hence we
don't need to adapt cpufreq_governor_dbs() routine for multiple calls.

So, this patch removes dbs_data->enable field entirely. And rearrange code a
bit.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Tested-by: Fabio Baltieri <fabio.baltieri@linaro.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

Showing 2 changed files with 20 additions and 39 deletions Side-by-side Diff

drivers/cpufreq/cpufreq_governor.c
... ... @@ -182,6 +182,8 @@
182 182 {
183 183 struct od_cpu_dbs_info_s *od_dbs_info = NULL;
184 184 struct cs_cpu_dbs_info_s *cs_dbs_info = NULL;
  185 + struct cs_ops *cs_ops = NULL;
  186 + struct od_ops *od_ops = NULL;
185 187 struct od_dbs_tuners *od_tuners = dbs_data->tuners;
186 188 struct cs_dbs_tuners *cs_tuners = dbs_data->tuners;
187 189 struct cpu_dbs_common_info *cpu_cdbs;
188 190  
... ... @@ -194,10 +196,12 @@
194 196 cs_dbs_info = dbs_data->get_cpu_dbs_info_s(cpu);
195 197 sampling_rate = &cs_tuners->sampling_rate;
196 198 ignore_nice = cs_tuners->ignore_nice;
  199 + cs_ops = dbs_data->gov_ops;
197 200 } else {
198 201 od_dbs_info = dbs_data->get_cpu_dbs_info_s(cpu);
199 202 sampling_rate = &od_tuners->sampling_rate;
200 203 ignore_nice = od_tuners->ignore_nice;
  204 + od_ops = dbs_data->gov_ops;
201 205 }
202 206  
203 207 switch (event) {
204 208  
... ... @@ -207,10 +211,9 @@
207 211  
208 212 mutex_lock(&dbs_data->mutex);
209 213  
210   - dbs_data->enable++;
211 214 for_each_cpu(j, policy->cpus) {
212   - struct cpu_dbs_common_info *j_cdbs;
213   - j_cdbs = dbs_data->get_cpu_cdbs(j);
  215 + struct cpu_dbs_common_info *j_cdbs =
  216 + dbs_data->get_cpu_cdbs(j);
214 217  
215 218 j_cdbs->cpu = j;
216 219 j_cdbs->cur_policy = policy;
... ... @@ -225,13 +228,6 @@
225 228 dbs_data->gov_dbs_timer);
226 229 }
227 230  
228   - /*
229   - * Start the timerschedule work, when this governor is used for
230   - * first time
231   - */
232   - if (dbs_data->enable != 1)
233   - goto second_time;
234   -
235 231 rc = sysfs_create_group(cpufreq_global_kobject,
236 232 dbs_data->attr_group);
237 233 if (rc) {
238 234  
... ... @@ -249,17 +245,19 @@
249 245 * governor, thus we are bound to jiffes/HZ
250 246 */
251 247 if (dbs_data->governor == GOV_CONSERVATIVE) {
252   - struct cs_ops *ops = dbs_data->gov_ops;
253   -
254   - cpufreq_register_notifier(ops->notifier_block,
  248 + cs_dbs_info->down_skip = 0;
  249 + cs_dbs_info->enable = 1;
  250 + cs_dbs_info->requested_freq = policy->cur;
  251 + cpufreq_register_notifier(cs_ops->notifier_block,
255 252 CPUFREQ_TRANSITION_NOTIFIER);
256 253  
257 254 dbs_data->min_sampling_rate = MIN_SAMPLING_RATE_RATIO *
258 255 jiffies_to_usecs(10);
259 256 } else {
260   - struct od_ops *ops = dbs_data->gov_ops;
261   -
262   - od_tuners->io_is_busy = ops->io_busy();
  257 + od_dbs_info->rate_mult = 1;
  258 + od_dbs_info->sample_type = OD_NORMAL_SAMPLE;
  259 + od_ops->powersave_bias_init_cpu(cpu);
  260 + od_tuners->io_is_busy = od_ops->io_busy();
263 261 }
264 262  
265 263 /* Bring kernel and HW constraints together */
... ... @@ -267,18 +265,6 @@
267 265 MIN_LATENCY_MULTIPLIER * latency);
268 266 *sampling_rate = max(dbs_data->min_sampling_rate, latency *
269 267 LATENCY_MULTIPLIER);
270   -
271   -second_time:
272   - if (dbs_data->governor == GOV_CONSERVATIVE) {
273   - cs_dbs_info->down_skip = 0;
274   - cs_dbs_info->enable = 1;
275   - cs_dbs_info->requested_freq = policy->cur;
276   - } else {
277   - struct od_ops *ops = dbs_data->gov_ops;
278   - od_dbs_info->rate_mult = 1;
279   - od_dbs_info->sample_type = OD_NORMAL_SAMPLE;
280   - ops->powersave_bias_init_cpu(cpu);
281   - }
282 268 mutex_unlock(&dbs_data->mutex);
283 269  
284 270 /* Initiate timer time stamp */
285 271  
... ... @@ -297,16 +283,12 @@
297 283  
298 284 mutex_lock(&dbs_data->mutex);
299 285 mutex_destroy(&cpu_cdbs->timer_mutex);
300   - dbs_data->enable--;
301   - if (!dbs_data->enable) {
302   - struct cs_ops *ops = dbs_data->gov_ops;
303 286  
304   - sysfs_remove_group(cpufreq_global_kobject,
305   - dbs_data->attr_group);
306   - if (dbs_data->governor == GOV_CONSERVATIVE)
307   - cpufreq_unregister_notifier(ops->notifier_block,
308   - CPUFREQ_TRANSITION_NOTIFIER);
309   - }
  287 + sysfs_remove_group(cpufreq_global_kobject,
  288 + dbs_data->attr_group);
  289 + if (dbs_data->governor == GOV_CONSERVATIVE)
  290 + cpufreq_unregister_notifier(cs_ops->notifier_block,
  291 + CPUFREQ_TRANSITION_NOTIFIER);
310 292 mutex_unlock(&dbs_data->mutex);
311 293  
312 294 break;
drivers/cpufreq/cpufreq_governor.h
... ... @@ -130,7 +130,6 @@
130 130 #define GOV_CONSERVATIVE 1
131 131 int governor;
132 132 unsigned int min_sampling_rate;
133   - unsigned int enable; /* number of CPUs using this policy */
134 133 struct attribute_group *attr_group;
135 134 void *tuners;
136 135