Loading drivers/cpufreq/acpi-cpufreq.c +27 −9 Original line number Diff line number Diff line Loading @@ -623,7 +623,14 @@ static int acpi_cpufreq_blacklist(struct cpuinfo_x86 *c) #endif #ifdef CONFIG_ACPI_CPPC_LIB static u64 get_max_boost_ratio(unsigned int cpu) /* * get_max_boost_ratio: Computes the max_boost_ratio as the ratio * between the highest_perf and the nominal_perf. * * Returns the max_boost_ratio for @cpu. Returns the CPPC nominal * frequency via @nominal_freq if it is non-NULL pointer. */ static u64 get_max_boost_ratio(unsigned int cpu, u64 *nominal_freq) { struct cppc_perf_caps perf_caps; u64 highest_perf, nominal_perf; Loading Loading @@ -652,6 +659,9 @@ static u64 get_max_boost_ratio(unsigned int cpu) nominal_perf = perf_caps.nominal_perf; if (nominal_freq) *nominal_freq = perf_caps.nominal_freq; if (!highest_perf || !nominal_perf) { pr_debug("CPU%d: highest or nominal performance missing\n", cpu); return 0; Loading @@ -664,8 +674,12 @@ static u64 get_max_boost_ratio(unsigned int cpu) return div_u64(highest_perf << SCHED_CAPACITY_SHIFT, nominal_perf); } #else static inline u64 get_max_boost_ratio(unsigned int cpu) { return 0; } static inline u64 get_max_boost_ratio(unsigned int cpu, u64 *nominal_freq) { return 0; } #endif static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy) Loading @@ -675,9 +689,9 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy) struct acpi_cpufreq_data *data; unsigned int cpu = policy->cpu; struct cpuinfo_x86 *c = &cpu_data(cpu); u64 max_boost_ratio, nominal_freq = 0; unsigned int valid_states = 0; unsigned int result = 0; u64 max_boost_ratio; unsigned int i; #ifdef CONFIG_SMP static int blacklisted; Loading Loading @@ -827,16 +841,20 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy) } freq_table[valid_states].frequency = CPUFREQ_TABLE_END; max_boost_ratio = get_max_boost_ratio(cpu); max_boost_ratio = get_max_boost_ratio(cpu, &nominal_freq); if (max_boost_ratio) { unsigned int freq = freq_table[0].frequency; unsigned int freq = nominal_freq; /* * Because the loop above sorts the freq_table entries in the * descending order, freq is the maximum frequency in the table. * Assume that it corresponds to the CPPC nominal frequency and * use it to set cpuinfo.max_freq. * The loop above sorts the freq_table entries in the * descending order. If ACPI CPPC has not advertised * the nominal frequency (this is possible in CPPC * revisions prior to 3), then use the first entry in * the pstate table as a proxy for nominal frequency. */ if (!freq) freq = freq_table[0].frequency; policy->cpuinfo.max_freq = freq * max_boost_ratio >> SCHED_CAPACITY_SHIFT; } else { /* Loading drivers/cpufreq/amd-pstate-trace.h +46 −6 Original line number Diff line number Diff line Loading @@ -32,7 +32,6 @@ TRACE_EVENT(amd_pstate_perf, u64 aperf, u64 tsc, unsigned int cpu_id, bool changed, bool fast_switch ), Loading @@ -44,7 +43,6 @@ TRACE_EVENT(amd_pstate_perf, aperf, tsc, cpu_id, changed, fast_switch ), Loading @@ -57,7 +55,6 @@ TRACE_EVENT(amd_pstate_perf, __field(unsigned long long, aperf) __field(unsigned long long, tsc) __field(unsigned int, cpu_id) __field(bool, changed) __field(bool, fast_switch) ), Loading @@ -70,11 +67,10 @@ TRACE_EVENT(amd_pstate_perf, __entry->aperf = aperf; __entry->tsc = tsc; __entry->cpu_id = cpu_id; __entry->changed = changed; __entry->fast_switch = fast_switch; ), TP_printk("amd_min_perf=%lu amd_des_perf=%lu amd_max_perf=%lu freq=%llu mperf=%llu aperf=%llu tsc=%llu cpu_id=%u changed=%s fast_switch=%s", TP_printk("amd_min_perf=%lu amd_des_perf=%lu amd_max_perf=%lu freq=%llu mperf=%llu aperf=%llu tsc=%llu cpu_id=%u fast_switch=%s", (unsigned long)__entry->min_perf, (unsigned long)__entry->target_perf, (unsigned long)__entry->capacity, Loading @@ -83,11 +79,55 @@ TRACE_EVENT(amd_pstate_perf, (unsigned long long)__entry->aperf, (unsigned long long)__entry->tsc, (unsigned int)__entry->cpu_id, (__entry->changed) ? "true" : "false", (__entry->fast_switch) ? "true" : "false" ) ); TRACE_EVENT(amd_pstate_epp_perf, TP_PROTO(unsigned int cpu_id, unsigned int highest_perf, unsigned int epp, unsigned int min_perf, unsigned int max_perf, bool boost ), TP_ARGS(cpu_id, highest_perf, epp, min_perf, max_perf, boost), TP_STRUCT__entry( __field(unsigned int, cpu_id) __field(unsigned int, highest_perf) __field(unsigned int, epp) __field(unsigned int, min_perf) __field(unsigned int, max_perf) __field(bool, boost) ), TP_fast_assign( __entry->cpu_id = cpu_id; __entry->highest_perf = highest_perf; __entry->epp = epp; __entry->min_perf = min_perf; __entry->max_perf = max_perf; __entry->boost = boost; ), TP_printk("cpu%u: [%u<->%u]/%u, epp=%u, boost=%u", (unsigned int)__entry->cpu_id, (unsigned int)__entry->min_perf, (unsigned int)__entry->max_perf, (unsigned int)__entry->highest_perf, (unsigned int)__entry->epp, (bool)__entry->boost ) ); #endif /* _AMD_PSTATE_TRACE_H */ /* This part must be outside protection */ Loading drivers/cpufreq/amd-pstate-ut.c +5 −7 Original line number Diff line number Diff line Loading @@ -207,7 +207,6 @@ static void amd_pstate_ut_check_freq(u32 index) int cpu = 0; struct cpufreq_policy *policy = NULL; struct amd_cpudata *cpudata = NULL; u32 nominal_freq_khz; for_each_possible_cpu(cpu) { policy = cpufreq_cpu_get(cpu); Loading @@ -215,14 +214,13 @@ static void amd_pstate_ut_check_freq(u32 index) break; cpudata = policy->driver_data; nominal_freq_khz = cpudata->nominal_freq*1000; if (!((cpudata->max_freq >= nominal_freq_khz) && (nominal_freq_khz > cpudata->lowest_nonlinear_freq) && if (!((cpudata->max_freq >= cpudata->nominal_freq) && (cpudata->nominal_freq > cpudata->lowest_nonlinear_freq) && (cpudata->lowest_nonlinear_freq > cpudata->min_freq) && (cpudata->min_freq > 0))) { amd_pstate_ut_cases[index].result = AMD_PSTATE_UT_RESULT_FAIL; pr_err("%s cpu%d max=%d >= nominal=%d > lowest_nonlinear=%d > min=%d > 0, the formula is incorrect!\n", __func__, cpu, cpudata->max_freq, nominal_freq_khz, __func__, cpu, cpudata->max_freq, cpudata->nominal_freq, cpudata->lowest_nonlinear_freq, cpudata->min_freq); goto skip_test; } Loading @@ -236,13 +234,13 @@ static void amd_pstate_ut_check_freq(u32 index) if (cpudata->boost_supported) { if ((policy->max == cpudata->max_freq) || (policy->max == nominal_freq_khz)) (policy->max == cpudata->nominal_freq)) amd_pstate_ut_cases[index].result = AMD_PSTATE_UT_RESULT_PASS; else { amd_pstate_ut_cases[index].result = AMD_PSTATE_UT_RESULT_FAIL; pr_err("%s cpu%d policy_max=%d should be equal cpu_max=%d or cpu_nominal=%d !\n", __func__, cpu, policy->max, cpudata->max_freq, nominal_freq_khz); cpudata->nominal_freq); goto skip_test; } } else { Loading drivers/cpufreq/amd-pstate.c +227 −256 File changed.Preview size limit exceeded, changes collapsed. Show changes drivers/cpufreq/amd-pstate.h +0 −3 Original line number Diff line number Diff line Loading @@ -57,7 +57,6 @@ struct amd_aperf_mperf { * @hw_prefcore: check whether HW supports preferred core featue. * Only when hw_prefcore and early prefcore param are true, * AMD P-State driver supports preferred core featue. * @epp_policy: Last saved policy used to set energy-performance preference * @epp_cached: Cached CPPC energy-performance preference value * @policy: Cpufreq policy value * @cppc_cap1_cached Cached MSR_AMD_CPPC_CAP1 register value Loading Loading @@ -94,13 +93,11 @@ struct amd_cpudata { bool hw_prefcore; /* EPP feature related attributes*/ s16 epp_policy; s16 epp_cached; u32 policy; u64 cppc_cap1_cached; bool suspended; s16 epp_default; bool boost_state; }; /* Loading Loading
drivers/cpufreq/acpi-cpufreq.c +27 −9 Original line number Diff line number Diff line Loading @@ -623,7 +623,14 @@ static int acpi_cpufreq_blacklist(struct cpuinfo_x86 *c) #endif #ifdef CONFIG_ACPI_CPPC_LIB static u64 get_max_boost_ratio(unsigned int cpu) /* * get_max_boost_ratio: Computes the max_boost_ratio as the ratio * between the highest_perf and the nominal_perf. * * Returns the max_boost_ratio for @cpu. Returns the CPPC nominal * frequency via @nominal_freq if it is non-NULL pointer. */ static u64 get_max_boost_ratio(unsigned int cpu, u64 *nominal_freq) { struct cppc_perf_caps perf_caps; u64 highest_perf, nominal_perf; Loading Loading @@ -652,6 +659,9 @@ static u64 get_max_boost_ratio(unsigned int cpu) nominal_perf = perf_caps.nominal_perf; if (nominal_freq) *nominal_freq = perf_caps.nominal_freq; if (!highest_perf || !nominal_perf) { pr_debug("CPU%d: highest or nominal performance missing\n", cpu); return 0; Loading @@ -664,8 +674,12 @@ static u64 get_max_boost_ratio(unsigned int cpu) return div_u64(highest_perf << SCHED_CAPACITY_SHIFT, nominal_perf); } #else static inline u64 get_max_boost_ratio(unsigned int cpu) { return 0; } static inline u64 get_max_boost_ratio(unsigned int cpu, u64 *nominal_freq) { return 0; } #endif static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy) Loading @@ -675,9 +689,9 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy) struct acpi_cpufreq_data *data; unsigned int cpu = policy->cpu; struct cpuinfo_x86 *c = &cpu_data(cpu); u64 max_boost_ratio, nominal_freq = 0; unsigned int valid_states = 0; unsigned int result = 0; u64 max_boost_ratio; unsigned int i; #ifdef CONFIG_SMP static int blacklisted; Loading Loading @@ -827,16 +841,20 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy) } freq_table[valid_states].frequency = CPUFREQ_TABLE_END; max_boost_ratio = get_max_boost_ratio(cpu); max_boost_ratio = get_max_boost_ratio(cpu, &nominal_freq); if (max_boost_ratio) { unsigned int freq = freq_table[0].frequency; unsigned int freq = nominal_freq; /* * Because the loop above sorts the freq_table entries in the * descending order, freq is the maximum frequency in the table. * Assume that it corresponds to the CPPC nominal frequency and * use it to set cpuinfo.max_freq. * The loop above sorts the freq_table entries in the * descending order. If ACPI CPPC has not advertised * the nominal frequency (this is possible in CPPC * revisions prior to 3), then use the first entry in * the pstate table as a proxy for nominal frequency. */ if (!freq) freq = freq_table[0].frequency; policy->cpuinfo.max_freq = freq * max_boost_ratio >> SCHED_CAPACITY_SHIFT; } else { /* Loading
drivers/cpufreq/amd-pstate-trace.h +46 −6 Original line number Diff line number Diff line Loading @@ -32,7 +32,6 @@ TRACE_EVENT(amd_pstate_perf, u64 aperf, u64 tsc, unsigned int cpu_id, bool changed, bool fast_switch ), Loading @@ -44,7 +43,6 @@ TRACE_EVENT(amd_pstate_perf, aperf, tsc, cpu_id, changed, fast_switch ), Loading @@ -57,7 +55,6 @@ TRACE_EVENT(amd_pstate_perf, __field(unsigned long long, aperf) __field(unsigned long long, tsc) __field(unsigned int, cpu_id) __field(bool, changed) __field(bool, fast_switch) ), Loading @@ -70,11 +67,10 @@ TRACE_EVENT(amd_pstate_perf, __entry->aperf = aperf; __entry->tsc = tsc; __entry->cpu_id = cpu_id; __entry->changed = changed; __entry->fast_switch = fast_switch; ), TP_printk("amd_min_perf=%lu amd_des_perf=%lu amd_max_perf=%lu freq=%llu mperf=%llu aperf=%llu tsc=%llu cpu_id=%u changed=%s fast_switch=%s", TP_printk("amd_min_perf=%lu amd_des_perf=%lu amd_max_perf=%lu freq=%llu mperf=%llu aperf=%llu tsc=%llu cpu_id=%u fast_switch=%s", (unsigned long)__entry->min_perf, (unsigned long)__entry->target_perf, (unsigned long)__entry->capacity, Loading @@ -83,11 +79,55 @@ TRACE_EVENT(amd_pstate_perf, (unsigned long long)__entry->aperf, (unsigned long long)__entry->tsc, (unsigned int)__entry->cpu_id, (__entry->changed) ? "true" : "false", (__entry->fast_switch) ? "true" : "false" ) ); TRACE_EVENT(amd_pstate_epp_perf, TP_PROTO(unsigned int cpu_id, unsigned int highest_perf, unsigned int epp, unsigned int min_perf, unsigned int max_perf, bool boost ), TP_ARGS(cpu_id, highest_perf, epp, min_perf, max_perf, boost), TP_STRUCT__entry( __field(unsigned int, cpu_id) __field(unsigned int, highest_perf) __field(unsigned int, epp) __field(unsigned int, min_perf) __field(unsigned int, max_perf) __field(bool, boost) ), TP_fast_assign( __entry->cpu_id = cpu_id; __entry->highest_perf = highest_perf; __entry->epp = epp; __entry->min_perf = min_perf; __entry->max_perf = max_perf; __entry->boost = boost; ), TP_printk("cpu%u: [%u<->%u]/%u, epp=%u, boost=%u", (unsigned int)__entry->cpu_id, (unsigned int)__entry->min_perf, (unsigned int)__entry->max_perf, (unsigned int)__entry->highest_perf, (unsigned int)__entry->epp, (bool)__entry->boost ) ); #endif /* _AMD_PSTATE_TRACE_H */ /* This part must be outside protection */ Loading
drivers/cpufreq/amd-pstate-ut.c +5 −7 Original line number Diff line number Diff line Loading @@ -207,7 +207,6 @@ static void amd_pstate_ut_check_freq(u32 index) int cpu = 0; struct cpufreq_policy *policy = NULL; struct amd_cpudata *cpudata = NULL; u32 nominal_freq_khz; for_each_possible_cpu(cpu) { policy = cpufreq_cpu_get(cpu); Loading @@ -215,14 +214,13 @@ static void amd_pstate_ut_check_freq(u32 index) break; cpudata = policy->driver_data; nominal_freq_khz = cpudata->nominal_freq*1000; if (!((cpudata->max_freq >= nominal_freq_khz) && (nominal_freq_khz > cpudata->lowest_nonlinear_freq) && if (!((cpudata->max_freq >= cpudata->nominal_freq) && (cpudata->nominal_freq > cpudata->lowest_nonlinear_freq) && (cpudata->lowest_nonlinear_freq > cpudata->min_freq) && (cpudata->min_freq > 0))) { amd_pstate_ut_cases[index].result = AMD_PSTATE_UT_RESULT_FAIL; pr_err("%s cpu%d max=%d >= nominal=%d > lowest_nonlinear=%d > min=%d > 0, the formula is incorrect!\n", __func__, cpu, cpudata->max_freq, nominal_freq_khz, __func__, cpu, cpudata->max_freq, cpudata->nominal_freq, cpudata->lowest_nonlinear_freq, cpudata->min_freq); goto skip_test; } Loading @@ -236,13 +234,13 @@ static void amd_pstate_ut_check_freq(u32 index) if (cpudata->boost_supported) { if ((policy->max == cpudata->max_freq) || (policy->max == nominal_freq_khz)) (policy->max == cpudata->nominal_freq)) amd_pstate_ut_cases[index].result = AMD_PSTATE_UT_RESULT_PASS; else { amd_pstate_ut_cases[index].result = AMD_PSTATE_UT_RESULT_FAIL; pr_err("%s cpu%d policy_max=%d should be equal cpu_max=%d or cpu_nominal=%d !\n", __func__, cpu, policy->max, cpudata->max_freq, nominal_freq_khz); cpudata->nominal_freq); goto skip_test; } } else { Loading
drivers/cpufreq/amd-pstate.c +227 −256 File changed.Preview size limit exceeded, changes collapsed. Show changes
drivers/cpufreq/amd-pstate.h +0 −3 Original line number Diff line number Diff line Loading @@ -57,7 +57,6 @@ struct amd_aperf_mperf { * @hw_prefcore: check whether HW supports preferred core featue. * Only when hw_prefcore and early prefcore param are true, * AMD P-State driver supports preferred core featue. * @epp_policy: Last saved policy used to set energy-performance preference * @epp_cached: Cached CPPC energy-performance preference value * @policy: Cpufreq policy value * @cppc_cap1_cached Cached MSR_AMD_CPPC_CAP1 register value Loading Loading @@ -94,13 +93,11 @@ struct amd_cpudata { bool hw_prefcore; /* EPP feature related attributes*/ s16 epp_policy; s16 epp_cached; u32 policy; u64 cppc_cap1_cached; bool suspended; s16 epp_default; bool boost_state; }; /* Loading