Skip to content

Commit 5d9a354

Browse files
dhananjay-AMDsuperm1
authored andcommitted
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. Modify the initial policy_data->min set by cpufreq-core to lowest_nonlinear_freq, in the ->verify() callback. Also set the cpudata->req[0] to FREQ_QOS_MIN_DEFAULT_VALUE (i.e. 0), so that it also gets overriden by the check in verify function. Link: https://www.amd.com/content/dam/amd/en/documents/processor-tech-docs/programmer-references/24593.pdf [1] Signed-off-by: Dhananjay Ugwekar <[email protected]> Reviewed-by: Mario Limonciello <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mario Limonciello <[email protected]>
1 parent 205cb21 commit 5d9a354

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

drivers/cpufreq/amd-pstate.c

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -529,8 +529,27 @@ static void amd_pstate_update(struct amd_cpudata *cpudata, u32 min_perf,
529529

530530
static int amd_pstate_verify(struct cpufreq_policy_data *policy_data)
531531
{
532+
/*
533+
* Initialize lower frequency limit (i.e.policy->min) with
534+
* lowest_nonlinear_frequency which is the most energy efficient
535+
* frequency. Override the initial value set by cpufreq core and
536+
* amd-pstate qos_requests.
537+
*/
538+
if (policy_data->min == FREQ_QOS_MIN_DEFAULT_VALUE) {
539+
struct cpufreq_policy *policy = cpufreq_cpu_get(policy_data->cpu);
540+
struct amd_cpudata *cpudata;
541+
542+
if (!policy)
543+
return -EINVAL;
544+
545+
cpudata = policy->driver_data;
546+
policy_data->min = cpudata->lowest_nonlinear_freq;
547+
cpufreq_cpu_put(policy);
548+
}
549+
532550
cpufreq_verify_within_cpu_limits(policy_data);
533551
pr_debug("policy_max =%d, policy_min=%d\n", policy_data->max, policy_data->min);
552+
534553
return 0;
535554
}
536555

@@ -979,7 +998,7 @@ static int amd_pstate_cpu_init(struct cpufreq_policy *policy)
979998
policy->fast_switch_possible = true;
980999

9811000
ret = freq_qos_add_request(&policy->constraints, &cpudata->req[0],
982-
FREQ_QOS_MIN, policy->cpuinfo.min_freq);
1001+
FREQ_QOS_MIN, FREQ_QOS_MIN_DEFAULT_VALUE);
9831002
if (ret < 0) {
9841003
dev_err(dev, "Failed to add min-freq constraint (%d)\n", ret);
9851004
goto free_cpudata1;

0 commit comments

Comments
 (0)