cpufreq_schedutil_plus.c 874 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. //SPDX-License-Identifier: GPL-2.0
  2. /*
  3. * Copyright (c) 2019 MediaTek Inc.
  4. */
  5. #include "../../drivers/misc/mediatek/base/power/include/mtk_upower.h"
  6. static unsigned int get_next_freq(struct sugov_policy *sg_policy,
  7. unsigned long util, unsigned long max)
  8. {
  9. struct cpufreq_policy *policy = sg_policy->policy;
  10. int idx, target_idx = 0;
  11. int cap;
  12. int cpu = policy->cpu;
  13. struct upower_tbl *tbl;
  14. unsigned int freq = arch_scale_freq_invariant() ?
  15. policy->cpuinfo.max_freq : policy->cur;
  16. util = util * capacity_margin / SCHED_CAPACITY_SCALE;
  17. tbl = upower_get_core_tbl(cpu);
  18. for (idx = 0; idx < tbl->row_num ; idx++) {
  19. cap = tbl->row[idx].cap;
  20. if (!cap)
  21. break;
  22. target_idx = idx;
  23. if (cap > util)
  24. break;
  25. }
  26. freq = mt_cpufreq_get_cpu_freq(cpu, target_idx);
  27. sg_policy->cached_raw_freq = freq;
  28. return cpufreq_driver_resolve_freq(policy, freq);
  29. }