Skip to content

Commit 32f80b9

Browse files
superm1rafaeljw
authored andcommitted
cpufreq: amd-pstate: Set a fallback policy based on preferred_profile
If a user's configuration doesn't explicitly specify the cpufreq scaling governor then the code currently explicitly falls back to 'powersave'. This default is fine for notebooks and desktops, but servers and undefined machines should default to 'performance'. Look at the 'preferred_profile' field from the FADT to set this policy accordingly. Link: https://uefi.org/htmlspecs/ACPI_Spec_6_4_html/05_ACPI_Software_Programming_Model/ACPI_Software_Programming_Model.html#fixed-acpi-description-table-fadt Acked-by: Huang Rui <[email protected]> Suggested-by: Wyes Karny <[email protected]> Reviewed-by: Gautham R. Shenoy <[email protected]> Signed-off-by: Mario Limonciello <[email protected]> Reviewed-by: Perry Yuan <[email protected]> Signed-off-by: Rafael J. Wysocki <[email protected]>
1 parent 965262e commit 32f80b9

File tree

1 file changed

+26
-2
lines changed

1 file changed

+26
-2
lines changed

drivers/cpufreq/amd-pstate.c

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1071,6 +1071,26 @@ static const struct attribute_group amd_pstate_global_attr_group = {
10711071
.attrs = pstate_global_attributes,
10721072
};
10731073

1074+
static bool amd_pstate_acpi_pm_profile_server(void)
1075+
{
1076+
switch (acpi_gbl_FADT.preferred_profile) {
1077+
case PM_ENTERPRISE_SERVER:
1078+
case PM_SOHO_SERVER:
1079+
case PM_PERFORMANCE_SERVER:
1080+
return true;
1081+
}
1082+
return false;
1083+
}
1084+
1085+
static bool amd_pstate_acpi_pm_profile_undefined(void)
1086+
{
1087+
if (acpi_gbl_FADT.preferred_profile == PM_UNSPECIFIED)
1088+
return true;
1089+
if (acpi_gbl_FADT.preferred_profile >= NR_PM_PROFILES)
1090+
return true;
1091+
return false;
1092+
}
1093+
10741094
static int amd_pstate_epp_cpu_init(struct cpufreq_policy *policy)
10751095
{
10761096
int min_freq, max_freq, nominal_freq, lowest_nonlinear_freq, ret;
@@ -1128,10 +1148,14 @@ static int amd_pstate_epp_cpu_init(struct cpufreq_policy *policy)
11281148
policy->max = policy->cpuinfo.max_freq;
11291149

11301150
/*
1131-
* Set the policy to powersave to provide a valid fallback value in case
1151+
* Set the policy to provide a valid fallback value in case
11321152
* the default cpufreq governor is neither powersave nor performance.
11331153
*/
1134-
policy->policy = CPUFREQ_POLICY_POWERSAVE;
1154+
if (amd_pstate_acpi_pm_profile_server() ||
1155+
amd_pstate_acpi_pm_profile_undefined())
1156+
policy->policy = CPUFREQ_POLICY_PERFORMANCE;
1157+
else
1158+
policy->policy = CPUFREQ_POLICY_POWERSAVE;
11351159

11361160
if (boot_cpu_has(X86_FEATURE_CPPC)) {
11371161
ret = rdmsrl_on_cpu(cpudata->cpu, MSR_AMD_CPPC_REQ, &value);

0 commit comments

Comments
 (0)