Skip to content

Commit eb8b6c3

Browse files
Perry Yuanrafaeljw
authored andcommitted
cpufreq: amd-pstate: Add quirk for the pstate CPPC capabilities missing
Add quirks table to get CPPC capabilities issue fixed by providing correct perf or frequency values while driver loading. If CPPC capabilities are not defined in the ACPI tables or wrongly defined by platform firmware, it needs to use quick to get those issues fixed with correct workaround values to make pstate driver can be loaded even though there are CPPC capabilities errors. The workaround will match the broken BIOS which lack of CPPC capabilities nominal_freq and lowest_freq definition in the ACPI table. $ cat /sys/devices/system/cpu/cpu0/acpi_cppc/lowest_freq 0 $ cat /sys/devices/system/cpu/cpu0/acpi_cppc/nominal_freq 0 Acked-by: Huang Rui <[email protected]> Reviewed-by: Mario Limonciello <[email protected]> Reviewed-by: Gautham R. Shenoy <[email protected]> Tested-by: Dhananjay Ugwekar <[email protected]> Signed-off-by: Perry Yuan <[email protected]> Signed-off-by: Rafael J. Wysocki <[email protected]>
1 parent 5f8f9bc commit eb8b6c3

File tree

2 files changed

+57
-2
lines changed

2 files changed

+57
-2
lines changed

drivers/cpufreq/amd-pstate.c

Lines changed: 51 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ static struct cpufreq_driver amd_pstate_epp_driver;
6767
static int cppc_state = AMD_PSTATE_UNDEFINED;
6868
static bool cppc_enabled;
6969
static bool amd_pstate_prefcore = true;
70+
static struct quirk_entry *quirks;
7071

7172
/*
7273
* AMD Energy Preference Performance (EPP)
@@ -111,6 +112,41 @@ static unsigned int epp_values[] = {
111112

112113
typedef int (*cppc_mode_transition_fn)(int);
113114

115+
static struct quirk_entry quirk_amd_7k62 = {
116+
.nominal_freq = 2600,
117+
.lowest_freq = 550,
118+
};
119+
120+
static int __init dmi_matched_7k62_bios_bug(const struct dmi_system_id *dmi)
121+
{
122+
/**
123+
* match the broken bios for family 17h processor support CPPC V2
124+
* broken BIOS lack of nominal_freq and lowest_freq capabilities
125+
* definition in ACPI tables
126+
*/
127+
if (boot_cpu_has(X86_FEATURE_ZEN2)) {
128+
quirks = dmi->driver_data;
129+
pr_info("Overriding nominal and lowest frequencies for %s\n", dmi->ident);
130+
return 1;
131+
}
132+
133+
return 0;
134+
}
135+
136+
static const struct dmi_system_id amd_pstate_quirks_table[] __initconst = {
137+
{
138+
.callback = dmi_matched_7k62_bios_bug,
139+
.ident = "AMD EPYC 7K62",
140+
.matches = {
141+
DMI_MATCH(DMI_BIOS_VERSION, "5.14"),
142+
DMI_MATCH(DMI_BIOS_RELEASE, "12/12/2019"),
143+
},
144+
.driver_data = &quirk_amd_7k62,
145+
},
146+
{}
147+
};
148+
MODULE_DEVICE_TABLE(dmi, amd_pstate_quirks_table);
149+
114150
static inline int get_mode_idx_from_str(const char *str, size_t size)
115151
{
116152
int i;
@@ -812,8 +848,16 @@ static int amd_pstate_init_freq(struct amd_cpudata *cpudata)
812848
if (ret)
813849
return ret;
814850

815-
min_freq = cppc_perf.lowest_freq * 1000;
816-
nominal_freq = cppc_perf.nominal_freq;
851+
if (quirks && quirks->lowest_freq)
852+
min_freq = quirks->lowest_freq * 1000;
853+
else
854+
min_freq = cppc_perf.lowest_freq * 1000;
855+
856+
if (quirks && quirks->nominal_freq)
857+
nominal_freq = quirks->nominal_freq ;
858+
else
859+
nominal_freq = cppc_perf.nominal_freq;
860+
817861
nominal_perf = READ_ONCE(cpudata->nominal_perf);
818862

819863
highest_perf = READ_ONCE(cpudata->highest_perf);
@@ -1662,6 +1706,11 @@ static int __init amd_pstate_init(void)
16621706
if (cpufreq_get_current_driver())
16631707
return -EEXIST;
16641708

1709+
quirks = NULL;
1710+
1711+
/* check if this machine need CPPC quirks */
1712+
dmi_check_system(amd_pstate_quirks_table);
1713+
16651714
switch (cppc_state) {
16661715
case AMD_PSTATE_UNDEFINED:
16671716
/* Disable on the following configs by default:

include/linux/amd-pstate.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,4 +128,10 @@ static const char * const amd_pstate_mode_string[] = {
128128
[AMD_PSTATE_GUIDED] = "guided",
129129
NULL,
130130
};
131+
132+
struct quirk_entry {
133+
u32 nominal_freq;
134+
u32 lowest_freq;
135+
};
136+
131137
#endif /* _LINUX_AMD_PSTATE_H */

0 commit comments

Comments
 (0)