80 lines
3.2 KiB
Diff
80 lines
3.2 KiB
Diff
From f5b234be445a45b0bcacc37e0aad7a6bc7900eac Mon Sep 17 00:00:00 2001
|
|
From: Dhananjay Ugwekar <Dhananjay.Ugwekar@amd.com>
|
|
Date: Thu, 3 Oct 2024 08:39:54 +0000
|
|
Subject: cpufreq/amd-pstate: Set the initial min_freq to lowest_nonlinear_freq
|
|
|
|
According to the AMD architectural programmer's manual volume 2 [1], in
|
|
section "17.6.4.1 CPPC_CAPABILITY_1" lowest_nonlinear_perf is described
|
|
as "Reports the most energy efficient performance level (in terms of
|
|
performance per watt). Above this threshold, lower performance levels
|
|
generally result in increased energy efficiency. Reducing performance
|
|
below this threshold does not result in total energy savings for a given
|
|
computation, although it reduces instantaneous power consumption". So
|
|
lowest_nonlinear_perf is the most power efficient performance level, and
|
|
going below that would lead to a worse performance/watt.
|
|
|
|
Also, setting the minimum frequency to lowest_nonlinear_freq (instead of
|
|
lowest_freq) allows the CPU to idle at a higher frequency which leads
|
|
to more time being spent in a deeper idle state (as trivial idle tasks
|
|
are completed sooner). This has shown a power benefit in some systems,
|
|
in other systems, power consumption has increased but so has the
|
|
throughput/watt.
|
|
|
|
Use the get_init_min_freq() callback to set the initial lower limit for
|
|
amd-pstate driver to lowest_nonlinear_freq instead of lowest_freq.
|
|
|
|
Link: https://www.amd.com/content/dam/amd/en/documents/processor-tech-docs/programmer-references/24593.pdf [1]
|
|
|
|
Signed-off-by: Dhananjay Ugwekar <Dhananjay.Ugwekar@amd.com>
|
|
Reviewed-by: Mario Limonciello <mario.limonciello@amd.com>
|
|
---
|
|
drivers/cpufreq/amd-pstate.c | 16 +++++++++-------
|
|
1 file changed, 9 insertions(+), 7 deletions(-)
|
|
|
|
--- a/drivers/cpufreq/amd-pstate.c
|
|
+++ b/drivers/cpufreq/amd-pstate.c
|
|
@@ -1025,13 +1025,6 @@ static int amd_pstate_cpu_init(struct cp
|
|
if (cpu_feature_enabled(X86_FEATURE_CPPC))
|
|
policy->fast_switch_possible = true;
|
|
|
|
- ret = freq_qos_add_request(&policy->constraints, &cpudata->req[0],
|
|
- FREQ_QOS_MIN, policy->cpuinfo.min_freq);
|
|
- if (ret < 0) {
|
|
- dev_err(dev, "Failed to add min-freq constraint (%d)\n", ret);
|
|
- goto free_cpudata1;
|
|
- }
|
|
-
|
|
ret = freq_qos_add_request(&policy->constraints, &cpudata->req[1],
|
|
FREQ_QOS_MAX, policy->cpuinfo.max_freq);
|
|
if (ret < 0) {
|
|
@@ -1746,6 +1739,13 @@ static int amd_pstate_epp_resume(struct
|
|
return 0;
|
|
}
|
|
|
|
+static int amd_pstate_get_init_min_freq(struct cpufreq_policy *policy)
|
|
+{
|
|
+ struct amd_cpudata *cpudata = policy->driver_data;
|
|
+
|
|
+ return READ_ONCE(cpudata->lowest_nonlinear_freq);
|
|
+}
|
|
+
|
|
static struct cpufreq_driver amd_pstate_driver = {
|
|
.flags = CPUFREQ_CONST_LOOPS | CPUFREQ_NEED_UPDATE_LIMITS,
|
|
.verify = amd_pstate_verify,
|
|
@@ -1759,6 +1759,7 @@ static struct cpufreq_driver amd_pstate_
|
|
.update_limits = amd_pstate_update_limits,
|
|
.name = "amd-pstate",
|
|
.attr = amd_pstate_attr,
|
|
+ .get_init_min_freq = amd_pstate_get_init_min_freq,
|
|
};
|
|
|
|
static struct cpufreq_driver amd_pstate_epp_driver = {
|
|
@@ -1775,6 +1776,7 @@ static struct cpufreq_driver amd_pstate_
|
|
.set_boost = amd_pstate_set_boost,
|
|
.name = "amd-pstate-epp",
|
|
.attr = amd_pstate_epp_attr,
|
|
+ .get_init_min_freq = amd_pstate_get_init_min_freq,
|
|
};
|
|
|
|
static int __init amd_pstate_set_driver(int mode_idx)
|