Lines Matching full:policy
299 if (epp > 0 && cpudata->policy == CPUFREQ_POLICY_PERFORMANCE) { in amd_pstate_set_energy_pref_index()
300 pr_debug("EPP cannot be set under performance policy\n"); in amd_pstate_set_energy_pref_index()
480 struct cpufreq_policy *policy = cpufreq_cpu_get(cpudata->cpu); in amd_pstate_update() local
492 policy->cur = div_u64(des_perf * max_freq, max_perf); in amd_pstate_update()
527 cpufreq_cpu_put(policy); in amd_pstate_update()
530 static int amd_pstate_verify(struct cpufreq_policy_data *policy) in amd_pstate_verify() argument
532 cpufreq_verify_within_cpu_limits(policy); in amd_pstate_verify()
537 static int amd_pstate_update_min_max_limit(struct cpufreq_policy *policy) in amd_pstate_update_min_max_limit() argument
540 struct amd_cpudata *cpudata = policy->driver_data; in amd_pstate_update_min_max_limit()
542 if (cpudata->boost_supported && !policy->boost_enabled) in amd_pstate_update_min_max_limit()
547 max_limit_perf = div_u64(policy->max * max_perf, policy->cpuinfo.max_freq); in amd_pstate_update_min_max_limit()
548 min_limit_perf = div_u64(policy->min * max_perf, policy->cpuinfo.max_freq); in amd_pstate_update_min_max_limit()
559 WRITE_ONCE(cpudata->max_limit_freq, policy->max); in amd_pstate_update_min_max_limit()
560 WRITE_ONCE(cpudata->min_limit_freq, policy->min); in amd_pstate_update_min_max_limit()
565 static int amd_pstate_update_freq(struct cpufreq_policy *policy, in amd_pstate_update_freq() argument
569 struct amd_cpudata *cpudata = policy->driver_data; in amd_pstate_update_freq()
575 if (policy->min != cpudata->min_limit_freq || policy->max != cpudata->max_limit_freq) in amd_pstate_update_freq()
576 amd_pstate_update_min_max_limit(policy); in amd_pstate_update_freq()
582 freqs.old = policy->cur; in amd_pstate_update_freq()
588 WARN_ON(fast_switch && !policy->fast_switch_enabled); in amd_pstate_update_freq()
595 cpufreq_freq_transition_begin(policy, &freqs); in amd_pstate_update_freq()
598 max_perf, fast_switch, policy->governor->flags); in amd_pstate_update_freq()
601 cpufreq_freq_transition_end(policy, &freqs, false); in amd_pstate_update_freq()
606 static int amd_pstate_target(struct cpufreq_policy *policy, in amd_pstate_target() argument
610 return amd_pstate_update_freq(policy, target_freq, false); in amd_pstate_target()
613 static unsigned int amd_pstate_fast_switch(struct cpufreq_policy *policy, in amd_pstate_fast_switch() argument
616 if (!amd_pstate_update_freq(policy, target_freq, true)) in amd_pstate_fast_switch()
618 return policy->cur; in amd_pstate_fast_switch()
628 struct cpufreq_policy *policy = cpufreq_cpu_get(cpu); in amd_pstate_adjust_perf() local
631 if (!policy) in amd_pstate_adjust_perf()
634 cpudata = policy->driver_data; in amd_pstate_adjust_perf()
636 if (policy->min != cpudata->min_limit_freq || policy->max != cpudata->max_limit_freq) in amd_pstate_adjust_perf()
637 amd_pstate_update_min_max_limit(policy); in amd_pstate_adjust_perf()
661 policy->governor->flags); in amd_pstate_adjust_perf()
662 cpufreq_cpu_put(policy); in amd_pstate_adjust_perf()
665 static int amd_pstate_cpu_boost_update(struct cpufreq_policy *policy, bool on) in amd_pstate_cpu_boost_update() argument
667 struct amd_cpudata *cpudata = policy->driver_data; in amd_pstate_cpu_boost_update()
689 cpufreq_cpu_release(policy); in amd_pstate_cpu_boost_update()
697 policy->cpuinfo.max_freq = max_freq; in amd_pstate_cpu_boost_update()
698 else if (policy->cpuinfo.max_freq > nominal_freq * 1000) in amd_pstate_cpu_boost_update()
699 policy->cpuinfo.max_freq = nominal_freq * 1000; in amd_pstate_cpu_boost_update()
701 policy->max = policy->cpuinfo.max_freq; in amd_pstate_cpu_boost_update()
704 ret = freq_qos_update_request(&cpudata->req[1], policy->cpuinfo.max_freq); in amd_pstate_cpu_boost_update()
712 static int amd_pstate_set_boost(struct cpufreq_policy *policy, int state) in amd_pstate_set_boost() argument
714 struct amd_cpudata *cpudata = policy->driver_data; in amd_pstate_set_boost()
722 ret = amd_pstate_cpu_boost_update(policy, state); in amd_pstate_set_boost()
724 policy->boost_enabled = !ret ? state : false; in amd_pstate_set_boost()
725 refresh_frequency_limits(policy); in amd_pstate_set_boost()
803 struct cpufreq_policy *policy = cpufreq_cpu_get(cpu); in amd_pstate_update_limits() local
809 if (!policy) in amd_pstate_update_limits()
812 cpudata = policy->driver_data; in amd_pstate_update_limits()
832 cpufreq_cpu_put(policy); in amd_pstate_update_limits()
948 static int amd_pstate_cpu_init(struct cpufreq_policy *policy) in amd_pstate_cpu_init() argument
958 amd_perf_ctl_reset(policy->cpu); in amd_pstate_cpu_init()
959 dev = get_cpu_device(policy->cpu); in amd_pstate_cpu_init()
967 cpudata->cpu = policy->cpu; in amd_pstate_cpu_init()
986 policy->cpuinfo.transition_latency = amd_pstate_get_transition_latency(policy->cpu); in amd_pstate_cpu_init()
987 policy->transition_delay_us = amd_pstate_get_transition_delay_us(policy->cpu); in amd_pstate_cpu_init()
989 policy->min = min_freq; in amd_pstate_cpu_init()
990 policy->max = max_freq; in amd_pstate_cpu_init()
992 policy->cpuinfo.min_freq = min_freq; in amd_pstate_cpu_init()
993 policy->cpuinfo.max_freq = max_freq; in amd_pstate_cpu_init()
995 policy->boost_enabled = READ_ONCE(cpudata->boost_supported); in amd_pstate_cpu_init()
998 policy->cur = policy->cpuinfo.min_freq; in amd_pstate_cpu_init()
1001 policy->fast_switch_possible = true; in amd_pstate_cpu_init()
1003 ret = freq_qos_add_request(&policy->constraints, &cpudata->req[0], in amd_pstate_cpu_init()
1004 FREQ_QOS_MIN, policy->cpuinfo.min_freq); in amd_pstate_cpu_init()
1010 ret = freq_qos_add_request(&policy->constraints, &cpudata->req[1], in amd_pstate_cpu_init()
1011 FREQ_QOS_MAX, policy->cpuinfo.max_freq); in amd_pstate_cpu_init()
1020 policy->driver_data = cpudata; in amd_pstate_cpu_init()
1034 static void amd_pstate_cpu_exit(struct cpufreq_policy *policy) in amd_pstate_cpu_exit() argument
1036 struct amd_cpudata *cpudata = policy->driver_data; in amd_pstate_cpu_exit()
1040 policy->fast_switch_possible = false; in amd_pstate_cpu_exit()
1044 static int amd_pstate_cpu_resume(struct cpufreq_policy *policy) in amd_pstate_cpu_resume() argument
1055 static int amd_pstate_cpu_suspend(struct cpufreq_policy *policy) in amd_pstate_cpu_suspend() argument
1073 static ssize_t show_amd_pstate_max_freq(struct cpufreq_policy *policy, in show_amd_pstate_max_freq() argument
1077 struct amd_cpudata *cpudata = policy->driver_data; in show_amd_pstate_max_freq()
1086 static ssize_t show_amd_pstate_lowest_nonlinear_freq(struct cpufreq_policy *policy, in show_amd_pstate_lowest_nonlinear_freq() argument
1090 struct amd_cpudata *cpudata = policy->driver_data; in show_amd_pstate_lowest_nonlinear_freq()
1103 static ssize_t show_amd_pstate_highest_perf(struct cpufreq_policy *policy, in show_amd_pstate_highest_perf() argument
1107 struct amd_cpudata *cpudata = policy->driver_data; in show_amd_pstate_highest_perf()
1114 static ssize_t show_amd_pstate_prefcore_ranking(struct cpufreq_policy *policy, in show_amd_pstate_prefcore_ranking() argument
1118 struct amd_cpudata *cpudata = policy->driver_data; in show_amd_pstate_prefcore_ranking()
1125 static ssize_t show_amd_pstate_hw_prefcore(struct cpufreq_policy *policy, in show_amd_pstate_hw_prefcore() argument
1129 struct amd_cpudata *cpudata = policy->driver_data; in show_amd_pstate_hw_prefcore()
1137 struct cpufreq_policy *policy, char *buf) in show_energy_performance_available_preferences() argument
1141 struct amd_cpudata *cpudata = policy->driver_data; in show_energy_performance_available_preferences()
1143 if (cpudata->policy == CPUFREQ_POLICY_PERFORMANCE) in show_energy_performance_available_preferences()
1156 struct cpufreq_policy *policy, const char *buf, size_t count) in store_energy_performance_preference() argument
1158 struct amd_cpudata *cpudata = policy->driver_data; in store_energy_performance_preference()
1178 struct cpufreq_policy *policy, char *buf) in show_energy_performance_preference() argument
1180 struct amd_cpudata *cpudata = policy->driver_data; in show_energy_performance_preference()
1412 static int amd_pstate_epp_cpu_init(struct cpufreq_policy *policy) in amd_pstate_epp_cpu_init() argument
1423 amd_perf_ctl_reset(policy->cpu); in amd_pstate_epp_cpu_init()
1424 dev = get_cpu_device(policy->cpu); in amd_pstate_epp_cpu_init()
1432 cpudata->cpu = policy->cpu; in amd_pstate_epp_cpu_init()
1452 policy->cpuinfo.min_freq = min_freq; in amd_pstate_epp_cpu_init()
1453 policy->cpuinfo.max_freq = max_freq; in amd_pstate_epp_cpu_init()
1455 policy->cur = policy->cpuinfo.min_freq; in amd_pstate_epp_cpu_init()
1457 policy->driver_data = cpudata; in amd_pstate_epp_cpu_init()
1461 policy->min = policy->cpuinfo.min_freq; in amd_pstate_epp_cpu_init()
1462 policy->max = policy->cpuinfo.max_freq; in amd_pstate_epp_cpu_init()
1464 policy->boost_enabled = READ_ONCE(cpudata->boost_supported); in amd_pstate_epp_cpu_init()
1467 * Set the policy to provide a valid fallback value in case in amd_pstate_epp_cpu_init()
1472 policy->policy = CPUFREQ_POLICY_PERFORMANCE; in amd_pstate_epp_cpu_init()
1474 policy->policy = CPUFREQ_POLICY_POWERSAVE; in amd_pstate_epp_cpu_init()
1495 static void amd_pstate_epp_cpu_exit(struct cpufreq_policy *policy) in amd_pstate_epp_cpu_exit() argument
1497 struct amd_cpudata *cpudata = policy->driver_data; in amd_pstate_epp_cpu_exit()
1501 policy->driver_data = NULL; in amd_pstate_epp_cpu_exit()
1504 pr_debug("CPU %d exiting\n", policy->cpu); in amd_pstate_epp_cpu_exit()
1507 static int amd_pstate_epp_update_limit(struct cpufreq_policy *policy) in amd_pstate_epp_update_limit() argument
1509 struct amd_cpudata *cpudata = policy->driver_data; in amd_pstate_epp_update_limit()
1514 if (cpudata->boost_supported && !policy->boost_enabled) in amd_pstate_epp_update_limit()
1519 max_limit_perf = div_u64(policy->max * max_perf, policy->cpuinfo.max_freq); in amd_pstate_epp_update_limit()
1520 min_limit_perf = div_u64(policy->min * max_perf, policy->cpuinfo.max_freq); in amd_pstate_epp_update_limit()
1537 if (cpudata->policy == CPUFREQ_POLICY_PERFORMANCE) in amd_pstate_epp_update_limit()
1551 cpudata->epp_policy = cpudata->policy; in amd_pstate_epp_update_limit()
1563 if (cpudata->policy == CPUFREQ_POLICY_PERFORMANCE) in amd_pstate_epp_update_limit()
1576 static int amd_pstate_epp_set_policy(struct cpufreq_policy *policy) in amd_pstate_epp_set_policy() argument
1578 struct amd_cpudata *cpudata = policy->driver_data; in amd_pstate_epp_set_policy()
1581 if (!policy->cpuinfo.max_freq) in amd_pstate_epp_set_policy()
1584 pr_debug("set_policy: cpuinfo.max %u policy->max %u\n", in amd_pstate_epp_set_policy()
1585 policy->cpuinfo.max_freq, policy->max); in amd_pstate_epp_set_policy()
1587 cpudata->policy = policy->policy; in amd_pstate_epp_set_policy()
1589 ret = amd_pstate_epp_update_limit(policy); in amd_pstate_epp_set_policy()
1594 * policy->cur is never updated with the amd_pstate_epp driver, but it in amd_pstate_epp_set_policy()
1597 policy->cur = policy->min; in amd_pstate_epp_set_policy()
1624 static int amd_pstate_epp_cpu_online(struct cpufreq_policy *policy) in amd_pstate_epp_cpu_online() argument
1626 struct amd_cpudata *cpudata = policy->driver_data; in amd_pstate_epp_cpu_online()
1638 static void amd_pstate_epp_offline(struct cpufreq_policy *policy) in amd_pstate_epp_offline() argument
1640 struct amd_cpudata *cpudata = policy->driver_data; in amd_pstate_epp_offline()
1667 static int amd_pstate_epp_cpu_offline(struct cpufreq_policy *policy) in amd_pstate_epp_cpu_offline() argument
1669 struct amd_cpudata *cpudata = policy->driver_data; in amd_pstate_epp_cpu_offline()
1677 amd_pstate_epp_offline(policy); in amd_pstate_epp_cpu_offline()
1682 static int amd_pstate_epp_verify_policy(struct cpufreq_policy_data *policy) in amd_pstate_epp_verify_policy() argument
1684 cpufreq_verify_within_cpu_limits(policy); in amd_pstate_epp_verify_policy()
1685 pr_debug("policy_max =%d, policy_min=%d\n", policy->max, policy->min); in amd_pstate_epp_verify_policy()
1689 static int amd_pstate_epp_suspend(struct cpufreq_policy *policy) in amd_pstate_epp_suspend() argument
1691 struct amd_cpudata *cpudata = policy->driver_data; in amd_pstate_epp_suspend()
1709 static int amd_pstate_epp_resume(struct cpufreq_policy *policy) in amd_pstate_epp_resume() argument
1711 struct amd_cpudata *cpudata = policy->driver_data; in amd_pstate_epp_resume()