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 +224 −248 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 drivers/cpufreq/intel_pstate.c +34 −26 Original line number Diff line number Diff line Loading @@ -28,6 +28,7 @@ #include <linux/pm_qos.h> #include <linux/bitfield.h> #include <trace/events/power.h> #include <linux/units.h> #include <asm/cpu.h> #include <asm/div64.h> Loading Loading @@ -302,11 +303,11 @@ static bool hwp_is_hybrid; static struct cpufreq_driver *intel_pstate_driver __read_mostly; #define HYBRID_SCALING_FACTOR 78741 #define HYBRID_SCALING_FACTOR_ADL 78741 #define HYBRID_SCALING_FACTOR_MTL 80000 #define HYBRID_SCALING_FACTOR_LNL 86957 static int hybrid_scaling_factor = HYBRID_SCALING_FACTOR; static int hybrid_scaling_factor; static inline int core_get_scaling(void) { Loading Loading @@ -414,18 +415,15 @@ static int intel_pstate_get_cppc_guaranteed(int cpu) static int intel_pstate_cppc_get_scaling(int cpu) { struct cppc_perf_caps cppc_perf; int ret; ret = cppc_get_perf_caps(cpu, &cppc_perf); /* * If the nominal frequency and the nominal performance are not * zero and the ratio between them is not 100, return the hybrid * scaling factor. * Compute the perf-to-frequency scaling factor for the given CPU if * possible, unless it would be 0. */ if (!ret && cppc_perf.nominal_perf && cppc_perf.nominal_freq && cppc_perf.nominal_perf * 100 != cppc_perf.nominal_freq) return hybrid_scaling_factor; if (!cppc_get_perf_caps(cpu, &cppc_perf) && cppc_perf.nominal_perf && cppc_perf.nominal_freq) return div_u64(cppc_perf.nominal_freq * KHZ_PER_MHZ, cppc_perf.nominal_perf); return core_get_scaling(); } Loading Loading @@ -2211,24 +2209,30 @@ static void hybrid_get_type(void *data) static int hwp_get_cpu_scaling(int cpu) { if (hybrid_scaling_factor) { u8 cpu_type = 0; smp_call_function_single(cpu, hybrid_get_type, &cpu_type, 1); /* P-cores have a smaller perf level-to-freqency scaling factor. */ /* * Return the hybrid scaling factor for P-cores and use the * default core scaling for E-cores. */ if (cpu_type == 0x40) return hybrid_scaling_factor; /* Use default core scaling for E-cores */ if (cpu_type == 0x20) return core_get_scaling(); } /* Use core scaling on non-hybrid systems. */ if (!cpu_feature_enabled(X86_FEATURE_HYBRID_CPU)) return core_get_scaling(); /* * If reached here, this system is either non-hybrid (like Tiger * Lake) or hybrid-capable (like Alder Lake or Raptor Lake) with * no E cores (in which case CPUID for hybrid support is 0). * * The CPPC nominal_frequency field is 0 for non-hybrid systems, * so the default core scaling will be used for them. * The system is hybrid, but the hybrid scaling factor is not known or * the CPU type is not one of the above, so use CPPC to compute the * scaling factor for this CPU. */ return intel_pstate_cppc_get_scaling(cpu); } Loading Loading @@ -2709,7 +2713,7 @@ static int intel_pstate_init_cpu(unsigned int cpunum) } cpu->epp_powersave = -EINVAL; cpu->epp_policy = 0; cpu->epp_policy = CPUFREQ_POLICY_UNKNOWN; intel_pstate_get_cpu_pstates(cpu); Loading Loading @@ -3665,8 +3669,12 @@ static const struct x86_cpu_id intel_epp_default[] = { }; static const struct x86_cpu_id intel_hybrid_scaling_factor[] = { X86_MATCH_VFM(INTEL_ALDERLAKE, HYBRID_SCALING_FACTOR_ADL), X86_MATCH_VFM(INTEL_ALDERLAKE_L, HYBRID_SCALING_FACTOR_ADL), X86_MATCH_VFM(INTEL_RAPTORLAKE, HYBRID_SCALING_FACTOR_ADL), X86_MATCH_VFM(INTEL_RAPTORLAKE_P, HYBRID_SCALING_FACTOR_ADL), X86_MATCH_VFM(INTEL_RAPTORLAKE_S, HYBRID_SCALING_FACTOR_ADL), X86_MATCH_VFM(INTEL_METEORLAKE_L, HYBRID_SCALING_FACTOR_MTL), X86_MATCH_VFM(INTEL_ARROWLAKE, HYBRID_SCALING_FACTOR_MTL), X86_MATCH_VFM(INTEL_LUNARLAKE_M, HYBRID_SCALING_FACTOR_LNL), {} }; Loading 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 +224 −248 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
drivers/cpufreq/intel_pstate.c +34 −26 Original line number Diff line number Diff line Loading @@ -28,6 +28,7 @@ #include <linux/pm_qos.h> #include <linux/bitfield.h> #include <trace/events/power.h> #include <linux/units.h> #include <asm/cpu.h> #include <asm/div64.h> Loading Loading @@ -302,11 +303,11 @@ static bool hwp_is_hybrid; static struct cpufreq_driver *intel_pstate_driver __read_mostly; #define HYBRID_SCALING_FACTOR 78741 #define HYBRID_SCALING_FACTOR_ADL 78741 #define HYBRID_SCALING_FACTOR_MTL 80000 #define HYBRID_SCALING_FACTOR_LNL 86957 static int hybrid_scaling_factor = HYBRID_SCALING_FACTOR; static int hybrid_scaling_factor; static inline int core_get_scaling(void) { Loading Loading @@ -414,18 +415,15 @@ static int intel_pstate_get_cppc_guaranteed(int cpu) static int intel_pstate_cppc_get_scaling(int cpu) { struct cppc_perf_caps cppc_perf; int ret; ret = cppc_get_perf_caps(cpu, &cppc_perf); /* * If the nominal frequency and the nominal performance are not * zero and the ratio between them is not 100, return the hybrid * scaling factor. * Compute the perf-to-frequency scaling factor for the given CPU if * possible, unless it would be 0. */ if (!ret && cppc_perf.nominal_perf && cppc_perf.nominal_freq && cppc_perf.nominal_perf * 100 != cppc_perf.nominal_freq) return hybrid_scaling_factor; if (!cppc_get_perf_caps(cpu, &cppc_perf) && cppc_perf.nominal_perf && cppc_perf.nominal_freq) return div_u64(cppc_perf.nominal_freq * KHZ_PER_MHZ, cppc_perf.nominal_perf); return core_get_scaling(); } Loading Loading @@ -2211,24 +2209,30 @@ static void hybrid_get_type(void *data) static int hwp_get_cpu_scaling(int cpu) { if (hybrid_scaling_factor) { u8 cpu_type = 0; smp_call_function_single(cpu, hybrid_get_type, &cpu_type, 1); /* P-cores have a smaller perf level-to-freqency scaling factor. */ /* * Return the hybrid scaling factor for P-cores and use the * default core scaling for E-cores. */ if (cpu_type == 0x40) return hybrid_scaling_factor; /* Use default core scaling for E-cores */ if (cpu_type == 0x20) return core_get_scaling(); } /* Use core scaling on non-hybrid systems. */ if (!cpu_feature_enabled(X86_FEATURE_HYBRID_CPU)) return core_get_scaling(); /* * If reached here, this system is either non-hybrid (like Tiger * Lake) or hybrid-capable (like Alder Lake or Raptor Lake) with * no E cores (in which case CPUID for hybrid support is 0). * * The CPPC nominal_frequency field is 0 for non-hybrid systems, * so the default core scaling will be used for them. * The system is hybrid, but the hybrid scaling factor is not known or * the CPU type is not one of the above, so use CPPC to compute the * scaling factor for this CPU. */ return intel_pstate_cppc_get_scaling(cpu); } Loading Loading @@ -2709,7 +2713,7 @@ static int intel_pstate_init_cpu(unsigned int cpunum) } cpu->epp_powersave = -EINVAL; cpu->epp_policy = 0; cpu->epp_policy = CPUFREQ_POLICY_UNKNOWN; intel_pstate_get_cpu_pstates(cpu); Loading Loading @@ -3665,8 +3669,12 @@ static const struct x86_cpu_id intel_epp_default[] = { }; static const struct x86_cpu_id intel_hybrid_scaling_factor[] = { X86_MATCH_VFM(INTEL_ALDERLAKE, HYBRID_SCALING_FACTOR_ADL), X86_MATCH_VFM(INTEL_ALDERLAKE_L, HYBRID_SCALING_FACTOR_ADL), X86_MATCH_VFM(INTEL_RAPTORLAKE, HYBRID_SCALING_FACTOR_ADL), X86_MATCH_VFM(INTEL_RAPTORLAKE_P, HYBRID_SCALING_FACTOR_ADL), X86_MATCH_VFM(INTEL_RAPTORLAKE_S, HYBRID_SCALING_FACTOR_ADL), X86_MATCH_VFM(INTEL_METEORLAKE_L, HYBRID_SCALING_FACTOR_MTL), X86_MATCH_VFM(INTEL_ARROWLAKE, HYBRID_SCALING_FACTOR_MTL), X86_MATCH_VFM(INTEL_LUNARLAKE_M, HYBRID_SCALING_FACTOR_LNL), {} }; Loading