Lines Matching refs:cpu
75 int cpu; member
187 static inline void intel_pstate_busy_pid_reset(struct cpudata *cpu) in intel_pstate_busy_pid_reset() argument
189 pid_p_gain_set(&cpu->pid, cpu->pstate_policy->p_gain_pct); in intel_pstate_busy_pid_reset()
190 pid_d_gain_set(&cpu->pid, cpu->pstate_policy->d_gain_pct); in intel_pstate_busy_pid_reset()
191 pid_i_gain_set(&cpu->pid, cpu->pstate_policy->i_gain_pct); in intel_pstate_busy_pid_reset()
193 pid_reset(&cpu->pid, in intel_pstate_busy_pid_reset()
194 cpu->pstate_policy->setpoint, in intel_pstate_busy_pid_reset()
196 cpu->pstate_policy->deadband, in intel_pstate_busy_pid_reset()
202 unsigned int cpu; in intel_pstate_reset_all_pid() local
203 for_each_online_cpu(cpu) { in intel_pstate_reset_all_pid()
204 if (all_cpu_data[cpu]) in intel_pstate_reset_all_pid()
205 intel_pstate_busy_pid_reset(all_cpu_data[cpu]); in intel_pstate_reset_all_pid()
367 static void intel_pstate_get_min_max(struct cpudata *cpu, int *min, int *max) in intel_pstate_get_min_max() argument
369 int max_perf = cpu->pstate.turbo_pstate; in intel_pstate_get_min_max()
372 max_perf = cpu->pstate.max_pstate; in intel_pstate_get_min_max()
376 cpu->pstate.min_pstate, cpu->pstate.turbo_pstate); in intel_pstate_get_min_max()
380 cpu->pstate.min_pstate, max_perf); in intel_pstate_get_min_max()
383 static void intel_pstate_set_pstate(struct cpudata *cpu, int pstate) in intel_pstate_set_pstate() argument
387 intel_pstate_get_min_max(cpu, &min_perf, &max_perf); in intel_pstate_set_pstate()
391 if (pstate == cpu->pstate.current_pstate) in intel_pstate_set_pstate()
394 trace_cpu_frequency(pstate * 100000, cpu->cpu); in intel_pstate_set_pstate()
396 cpu->pstate.current_pstate = pstate; in intel_pstate_set_pstate()
401 static inline void intel_pstate_pstate_increase(struct cpudata *cpu, int steps) in intel_pstate_pstate_increase() argument
404 target = cpu->pstate.current_pstate + steps; in intel_pstate_pstate_increase()
406 intel_pstate_set_pstate(cpu, target); in intel_pstate_pstate_increase()
409 static inline void intel_pstate_pstate_decrease(struct cpudata *cpu, int steps) in intel_pstate_pstate_decrease() argument
412 target = cpu->pstate.current_pstate - steps; in intel_pstate_pstate_decrease()
413 intel_pstate_set_pstate(cpu, target); in intel_pstate_pstate_decrease()
416 static void intel_pstate_get_cpu_pstates(struct cpudata *cpu) in intel_pstate_get_cpu_pstates() argument
418 sprintf(cpu->name, "Intel 2nd generation core"); in intel_pstate_get_cpu_pstates()
420 cpu->pstate.min_pstate = intel_pstate_min_pstate(); in intel_pstate_get_cpu_pstates()
421 cpu->pstate.max_pstate = intel_pstate_max_pstate(); in intel_pstate_get_cpu_pstates()
422 cpu->pstate.turbo_pstate = intel_pstate_turbo_pstate(); in intel_pstate_get_cpu_pstates()
428 intel_pstate_set_pstate(cpu, cpu->pstate.max_pstate); in intel_pstate_get_cpu_pstates()
431 static inline void intel_pstate_calc_busy(struct cpudata *cpu, in intel_pstate_calc_busy() argument
436 sample->freq = cpu->pstate.max_pstate * core_pct * 1000; in intel_pstate_calc_busy()
441 static inline void intel_pstate_sample(struct cpudata *cpu) in intel_pstate_sample() argument
447 cpu->sample_ptr = (cpu->sample_ptr + 1) % SAMPLE_COUNT; in intel_pstate_sample()
448 cpu->samples[cpu->sample_ptr].aperf = aperf; in intel_pstate_sample()
449 cpu->samples[cpu->sample_ptr].mperf = mperf; in intel_pstate_sample()
450 cpu->samples[cpu->sample_ptr].aperf -= cpu->prev_aperf; in intel_pstate_sample()
451 cpu->samples[cpu->sample_ptr].mperf -= cpu->prev_mperf; in intel_pstate_sample()
453 intel_pstate_calc_busy(cpu, &cpu->samples[cpu->sample_ptr]); in intel_pstate_sample()
455 cpu->prev_aperf = aperf; in intel_pstate_sample()
456 cpu->prev_mperf = mperf; in intel_pstate_sample()
459 static inline void intel_pstate_set_sample_time(struct cpudata *cpu) in intel_pstate_set_sample_time() argument
463 sample_time = cpu->pstate_policy->sample_rate_ms; in intel_pstate_set_sample_time()
465 mod_timer_pinned(&cpu->timer, jiffies + delay); in intel_pstate_set_sample_time()
468 static inline int intel_pstate_get_scaled_busy(struct cpudata *cpu) in intel_pstate_get_scaled_busy() argument
473 core_busy = int_tofp(cpu->samples[cpu->sample_ptr].core_pct_busy); in intel_pstate_get_scaled_busy()
474 turbo_pstate = int_tofp(cpu->pstate.turbo_pstate); in intel_pstate_get_scaled_busy()
475 current_pstate = int_tofp(cpu->pstate.current_pstate); in intel_pstate_get_scaled_busy()
481 static inline void intel_pstate_adjust_busy_pstate(struct cpudata *cpu) in intel_pstate_adjust_busy_pstate() argument
488 pid = &cpu->pid; in intel_pstate_adjust_busy_pstate()
489 busy_scaled = intel_pstate_get_scaled_busy(cpu); in intel_pstate_adjust_busy_pstate()
495 intel_pstate_pstate_increase(cpu, steps); in intel_pstate_adjust_busy_pstate()
497 intel_pstate_pstate_decrease(cpu, steps); in intel_pstate_adjust_busy_pstate()
502 struct cpudata *cpu = (struct cpudata *) __data; in intel_pstate_timer_func() local
504 intel_pstate_sample(cpu); in intel_pstate_timer_func()
505 intel_pstate_adjust_busy_pstate(cpu); in intel_pstate_timer_func()
507 if (cpu->pstate.current_pstate == cpu->pstate.min_pstate) { in intel_pstate_timer_func()
508 cpu->min_pstate_count++; in intel_pstate_timer_func()
509 if (!(cpu->min_pstate_count % 5)) { in intel_pstate_timer_func()
510 intel_pstate_set_pstate(cpu, cpu->pstate.max_pstate); in intel_pstate_timer_func()
513 cpu->min_pstate_count = 0; in intel_pstate_timer_func()
515 intel_pstate_set_sample_time(cpu); in intel_pstate_timer_func()
533 struct cpudata *cpu; in intel_pstate_init_cpu() local
543 cpu = all_cpu_data[cpunum]; in intel_pstate_init_cpu()
545 intel_pstate_get_cpu_pstates(cpu); in intel_pstate_init_cpu()
547 cpu->cpu = cpunum; in intel_pstate_init_cpu()
548 cpu->pstate_policy = in intel_pstate_init_cpu()
550 init_timer_deferrable(&cpu->timer); in intel_pstate_init_cpu()
551 cpu->timer.function = intel_pstate_timer_func; in intel_pstate_init_cpu()
552 cpu->timer.data = in intel_pstate_init_cpu()
553 (unsigned long)cpu; in intel_pstate_init_cpu()
554 cpu->timer.expires = jiffies + HZ/100; in intel_pstate_init_cpu()
555 intel_pstate_busy_pid_reset(cpu); in intel_pstate_init_cpu()
556 intel_pstate_sample(cpu); in intel_pstate_init_cpu()
557 intel_pstate_set_pstate(cpu, cpu->pstate.max_pstate); in intel_pstate_init_cpu()
559 add_timer_on(&cpu->timer, cpunum); in intel_pstate_init_cpu()
569 struct cpudata *cpu; in intel_pstate_get() local
571 cpu = all_cpu_data[cpu_num]; in intel_pstate_get()
572 if (!cpu) in intel_pstate_get()
574 sample = &cpu->samples[cpu->sample_ptr]; in intel_pstate_get()
580 struct cpudata *cpu; in intel_pstate_set_policy() local
582 cpu = all_cpu_data[policy->cpu]; in intel_pstate_set_policy()
622 int cpu = policy->cpu; in intel_pstate_cpu_exit() local
624 del_timer(&all_cpu_data[cpu]->timer); in intel_pstate_cpu_exit()
625 kfree(all_cpu_data[cpu]); in intel_pstate_cpu_exit()
626 all_cpu_data[cpu] = NULL; in intel_pstate_cpu_exit()
633 struct cpudata *cpu; in intel_pstate_cpu_init() local
635 rc = intel_pstate_init_cpu(policy->cpu); in intel_pstate_cpu_init()
639 cpu = all_cpu_data[policy->cpu]; in intel_pstate_cpu_init()
647 intel_pstate_get_min_max(cpu, &min_pstate, &max_pstate); in intel_pstate_cpu_init()
652 policy->cpuinfo.min_freq = cpu->pstate.min_pstate * 100000; in intel_pstate_cpu_init()
653 policy->cpuinfo.max_freq = cpu->pstate.turbo_pstate * 100000; in intel_pstate_cpu_init()
655 cpumask_set_cpu(policy->cpu, policy->cpus); in intel_pstate_cpu_init()
698 int cpu, rc = 0; in intel_pstate_init() local
726 for_each_online_cpu(cpu) { in intel_pstate_init()
727 if (all_cpu_data[cpu]) { in intel_pstate_init()
728 del_timer_sync(&all_cpu_data[cpu]->timer); in intel_pstate_init()
729 kfree(all_cpu_data[cpu]); in intel_pstate_init()