Skip to content

Commit 069a2bb

Browse files
Perry Yuanrafaeljw
authored andcommitted
cpufreq: amd-pstate: get transition delay and latency value from ACPI tables
Make pstate driver initially retrieve the P-state transition delay and latency values from the BIOS ACPI tables which has more reasonable delay and latency values according to the platform design and requirements. Previously there values were hardcoded at specific value which may have conflicted with platform and it might not reflect the most accurate or optimized setting for the processor. [054h 0084 8] Preserve Mask : FFFFFFFF00000000 [05Ch 0092 8] Write Mask : 0000000000000001 [064h 0100 4] Command Latency : 00000FA0 [068h 0104 4] Maximum Access Rate : 0000EA60 [06Ch 0108 2] Minimum Turnaround Time : 0000 Reviewed-by: Gautham R. Shenoy <[email protected]> Reviewed-by: Mario Limonciello <[email protected]> Tested-by: Dhananjay Ugwekar <[email protected]> Signed-off-by: Perry Yuan <[email protected]> Acked-by: Huang Rui <[email protected]> Signed-off-by: Rafael J. Wysocki <[email protected]>
1 parent 2ddb8a3 commit 069a2bb

File tree

1 file changed

+32
-2
lines changed

1 file changed

+32
-2
lines changed

drivers/cpufreq/amd-pstate.c

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -756,6 +756,36 @@ static void amd_pstate_update_limits(unsigned int cpu)
756756
mutex_unlock(&amd_pstate_driver_lock);
757757
}
758758

759+
/**
760+
* Get pstate transition delay time from ACPI tables that firmware set
761+
* instead of using hardcode value directly.
762+
*/
763+
static u32 amd_pstate_get_transition_delay_us(unsigned int cpu)
764+
{
765+
u32 transition_delay_ns;
766+
767+
transition_delay_ns = cppc_get_transition_latency(cpu);
768+
if (transition_delay_ns == CPUFREQ_ETERNAL)
769+
return AMD_PSTATE_TRANSITION_DELAY;
770+
771+
return transition_delay_ns / NSEC_PER_USEC;
772+
}
773+
774+
/**
775+
* Get pstate transition latency value from ACPI tables that firmware
776+
* set instead of using hardcode value directly.
777+
*/
778+
static u32 amd_pstate_get_transition_latency(unsigned int cpu)
779+
{
780+
u32 transition_latency;
781+
782+
transition_latency = cppc_get_transition_latency(cpu);
783+
if (transition_latency == CPUFREQ_ETERNAL)
784+
return AMD_PSTATE_TRANSITION_LATENCY;
785+
786+
return transition_latency;
787+
}
788+
759789
/**
760790
* amd_pstate_init_freq: Initialize the max_freq, min_freq,
761791
* nominal_freq and lowest_nonlinear_freq for
@@ -848,8 +878,8 @@ static int amd_pstate_cpu_init(struct cpufreq_policy *policy)
848878
goto free_cpudata1;
849879
}
850880

851-
policy->cpuinfo.transition_latency = AMD_PSTATE_TRANSITION_LATENCY;
852-
policy->transition_delay_us = AMD_PSTATE_TRANSITION_DELAY;
881+
policy->cpuinfo.transition_latency = amd_pstate_get_transition_latency(policy->cpu);
882+
policy->transition_delay_us = amd_pstate_get_transition_delay_us(policy->cpu);
853883

854884
policy->min = min_freq;
855885
policy->max = max_freq;

0 commit comments

Comments
 (0)