Skip to content

Commit 423124a

Browse files
committed
Merge back earlier cpufreq material for 6.14
2 parents 7e265fc + 0834667 commit 423124a

File tree

7 files changed

+341
-309
lines changed

7 files changed

+341
-309
lines changed

drivers/cpufreq/acpi-cpufreq.c

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -623,7 +623,14 @@ static int acpi_cpufreq_blacklist(struct cpuinfo_x86 *c)
623623
#endif
624624

625625
#ifdef CONFIG_ACPI_CPPC_LIB
626-
static u64 get_max_boost_ratio(unsigned int cpu)
626+
/*
627+
* get_max_boost_ratio: Computes the max_boost_ratio as the ratio
628+
* between the highest_perf and the nominal_perf.
629+
*
630+
* Returns the max_boost_ratio for @cpu. Returns the CPPC nominal
631+
* frequency via @nominal_freq if it is non-NULL pointer.
632+
*/
633+
static u64 get_max_boost_ratio(unsigned int cpu, u64 *nominal_freq)
627634
{
628635
struct cppc_perf_caps perf_caps;
629636
u64 highest_perf, nominal_perf;
@@ -652,6 +659,9 @@ static u64 get_max_boost_ratio(unsigned int cpu)
652659

653660
nominal_perf = perf_caps.nominal_perf;
654661

662+
if (nominal_freq)
663+
*nominal_freq = perf_caps.nominal_freq;
664+
655665
if (!highest_perf || !nominal_perf) {
656666
pr_debug("CPU%d: highest or nominal performance missing\n", cpu);
657667
return 0;
@@ -664,8 +674,12 @@ static u64 get_max_boost_ratio(unsigned int cpu)
664674

665675
return div_u64(highest_perf << SCHED_CAPACITY_SHIFT, nominal_perf);
666676
}
677+
667678
#else
668-
static inline u64 get_max_boost_ratio(unsigned int cpu) { return 0; }
679+
static inline u64 get_max_boost_ratio(unsigned int cpu, u64 *nominal_freq)
680+
{
681+
return 0;
682+
}
669683
#endif
670684

671685
static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy)
@@ -675,9 +689,9 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy)
675689
struct acpi_cpufreq_data *data;
676690
unsigned int cpu = policy->cpu;
677691
struct cpuinfo_x86 *c = &cpu_data(cpu);
692+
u64 max_boost_ratio, nominal_freq = 0;
678693
unsigned int valid_states = 0;
679694
unsigned int result = 0;
680-
u64 max_boost_ratio;
681695
unsigned int i;
682696
#ifdef CONFIG_SMP
683697
static int blacklisted;
@@ -827,16 +841,20 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy)
827841
}
828842
freq_table[valid_states].frequency = CPUFREQ_TABLE_END;
829843

830-
max_boost_ratio = get_max_boost_ratio(cpu);
844+
max_boost_ratio = get_max_boost_ratio(cpu, &nominal_freq);
831845
if (max_boost_ratio) {
832-
unsigned int freq = freq_table[0].frequency;
846+
unsigned int freq = nominal_freq;
833847

834848
/*
835-
* Because the loop above sorts the freq_table entries in the
836-
* descending order, freq is the maximum frequency in the table.
837-
* Assume that it corresponds to the CPPC nominal frequency and
838-
* use it to set cpuinfo.max_freq.
849+
* The loop above sorts the freq_table entries in the
850+
* descending order. If ACPI CPPC has not advertised
851+
* the nominal frequency (this is possible in CPPC
852+
* revisions prior to 3), then use the first entry in
853+
* the pstate table as a proxy for nominal frequency.
839854
*/
855+
if (!freq)
856+
freq = freq_table[0].frequency;
857+
840858
policy->cpuinfo.max_freq = freq * max_boost_ratio >> SCHED_CAPACITY_SHIFT;
841859
} else {
842860
/*

drivers/cpufreq/amd-pstate-trace.h

Lines changed: 46 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ TRACE_EVENT(amd_pstate_perf,
3232
u64 aperf,
3333
u64 tsc,
3434
unsigned int cpu_id,
35-
bool changed,
3635
bool fast_switch
3736
),
3837

@@ -44,7 +43,6 @@ TRACE_EVENT(amd_pstate_perf,
4443
aperf,
4544
tsc,
4645
cpu_id,
47-
changed,
4846
fast_switch
4947
),
5048

@@ -57,7 +55,6 @@ TRACE_EVENT(amd_pstate_perf,
5755
__field(unsigned long long, aperf)
5856
__field(unsigned long long, tsc)
5957
__field(unsigned int, cpu_id)
60-
__field(bool, changed)
6158
__field(bool, fast_switch)
6259
),
6360

@@ -70,11 +67,10 @@ TRACE_EVENT(amd_pstate_perf,
7067
__entry->aperf = aperf;
7168
__entry->tsc = tsc;
7269
__entry->cpu_id = cpu_id;
73-
__entry->changed = changed;
7470
__entry->fast_switch = fast_switch;
7571
),
7672

77-
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",
73+
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",
7874
(unsigned long)__entry->min_perf,
7975
(unsigned long)__entry->target_perf,
8076
(unsigned long)__entry->capacity,
@@ -83,11 +79,55 @@ TRACE_EVENT(amd_pstate_perf,
8379
(unsigned long long)__entry->aperf,
8480
(unsigned long long)__entry->tsc,
8581
(unsigned int)__entry->cpu_id,
86-
(__entry->changed) ? "true" : "false",
8782
(__entry->fast_switch) ? "true" : "false"
8883
)
8984
);
9085

86+
TRACE_EVENT(amd_pstate_epp_perf,
87+
88+
TP_PROTO(unsigned int cpu_id,
89+
unsigned int highest_perf,
90+
unsigned int epp,
91+
unsigned int min_perf,
92+
unsigned int max_perf,
93+
bool boost
94+
),
95+
96+
TP_ARGS(cpu_id,
97+
highest_perf,
98+
epp,
99+
min_perf,
100+
max_perf,
101+
boost),
102+
103+
TP_STRUCT__entry(
104+
__field(unsigned int, cpu_id)
105+
__field(unsigned int, highest_perf)
106+
__field(unsigned int, epp)
107+
__field(unsigned int, min_perf)
108+
__field(unsigned int, max_perf)
109+
__field(bool, boost)
110+
),
111+
112+
TP_fast_assign(
113+
__entry->cpu_id = cpu_id;
114+
__entry->highest_perf = highest_perf;
115+
__entry->epp = epp;
116+
__entry->min_perf = min_perf;
117+
__entry->max_perf = max_perf;
118+
__entry->boost = boost;
119+
),
120+
121+
TP_printk("cpu%u: [%u<->%u]/%u, epp=%u, boost=%u",
122+
(unsigned int)__entry->cpu_id,
123+
(unsigned int)__entry->min_perf,
124+
(unsigned int)__entry->max_perf,
125+
(unsigned int)__entry->highest_perf,
126+
(unsigned int)__entry->epp,
127+
(bool)__entry->boost
128+
)
129+
);
130+
91131
#endif /* _AMD_PSTATE_TRACE_H */
92132

93133
/* This part must be outside protection */

drivers/cpufreq/amd-pstate-ut.c

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -207,22 +207,20 @@ static void amd_pstate_ut_check_freq(u32 index)
207207
int cpu = 0;
208208
struct cpufreq_policy *policy = NULL;
209209
struct amd_cpudata *cpudata = NULL;
210-
u32 nominal_freq_khz;
211210

212211
for_each_possible_cpu(cpu) {
213212
policy = cpufreq_cpu_get(cpu);
214213
if (!policy)
215214
break;
216215
cpudata = policy->driver_data;
217216

218-
nominal_freq_khz = cpudata->nominal_freq*1000;
219-
if (!((cpudata->max_freq >= nominal_freq_khz) &&
220-
(nominal_freq_khz > cpudata->lowest_nonlinear_freq) &&
217+
if (!((cpudata->max_freq >= cpudata->nominal_freq) &&
218+
(cpudata->nominal_freq > cpudata->lowest_nonlinear_freq) &&
221219
(cpudata->lowest_nonlinear_freq > cpudata->min_freq) &&
222220
(cpudata->min_freq > 0))) {
223221
amd_pstate_ut_cases[index].result = AMD_PSTATE_UT_RESULT_FAIL;
224222
pr_err("%s cpu%d max=%d >= nominal=%d > lowest_nonlinear=%d > min=%d > 0, the formula is incorrect!\n",
225-
__func__, cpu, cpudata->max_freq, nominal_freq_khz,
223+
__func__, cpu, cpudata->max_freq, cpudata->nominal_freq,
226224
cpudata->lowest_nonlinear_freq, cpudata->min_freq);
227225
goto skip_test;
228226
}
@@ -236,13 +234,13 @@ static void amd_pstate_ut_check_freq(u32 index)
236234

237235
if (cpudata->boost_supported) {
238236
if ((policy->max == cpudata->max_freq) ||
239-
(policy->max == nominal_freq_khz))
237+
(policy->max == cpudata->nominal_freq))
240238
amd_pstate_ut_cases[index].result = AMD_PSTATE_UT_RESULT_PASS;
241239
else {
242240
amd_pstate_ut_cases[index].result = AMD_PSTATE_UT_RESULT_FAIL;
243241
pr_err("%s cpu%d policy_max=%d should be equal cpu_max=%d or cpu_nominal=%d !\n",
244242
__func__, cpu, policy->max, cpudata->max_freq,
245-
nominal_freq_khz);
243+
cpudata->nominal_freq);
246244
goto skip_test;
247245
}
248246
} else {

0 commit comments

Comments
 (0)