AMD Pstate Enhancement And Issue Fixs
Subsystems (7)
Perry Yuan
reviewerv5 cover AMD Pstate Enhancement And Issue Fixs
This patchsets adds support for precision boost hardware control for AMD processors.
Meanwhile the patchset fixs lowest perf query and desired perf scope issues. Update transition delay and latency default value to meet SMU firmware requirement. and do some code cleanups,
It also exports cpufreq cpu release and acquire for coming amd-pstate epp mode driver
The patch series are tested on the AMD mobile and EYPC server systems
v4->v5:
- drop the amd precision boost mode control patch
- combine acpi_cpc_valid() changes into single patch
- pick up Reviewed-by flags by Huang Ray
v3->v4:
- check cached bit for core performance boost from hardware configuration register
- pick up the Acked-by flags from Viresh and Sudeep
v2->v3:
- drop cpufreq cpu release and acquire export patch
- remove the clamp_t in the amd_pstate_adjust_perf()
v1->v2:
- add two new patches to remove the acpi_disabled check
- fix some typos in the commit info
- move the clamp_t() into amd_pstate_update() function
- rebased to 5.19-rc5
Perry Yuan (7):
cpufreq: amd-pstate: cleanup the unused and duplicated headers
declaration
cpufreq: amd-pstate: simplify cpudata pointer assignment
cpufreq: amd-pstate: fix white-space
cpufreq: amd_pstate: fix wrong lowest perf fetch
cpufreq: amd_pstate: map desired perf into pstate scope for powersave
governor
cpufreq: amd-pstate: update pstate frequency transition delay time
cpufreq: amd-pstate: add ACPI disabled check in acpi_cpc_valid()
drivers/acpi/cppc_acpi.c | 3 +++ drivers/base/arch_topology.c | 2 +- drivers/cpufreq/amd-pstate.c | 32 ++++++++++---------------------- drivers/cpufreq/cppc_cpufreq.c | 2 +- 4 files changed, 15 insertions(+), 24 deletions(-)
Signature · 1 line
2.34.1
Perry Yuan
reviewerPATCH v5 1/7 cpufreq: amd-pstate: cleanup the unused and duplicated headers declaration
Cleanup the headers declaration which are not used actually and some duplicated declaration which is declarated in some other headers already, it will help to simplify the header part.
--- drivers/cpufreq/amd-pstate.c | 5 ----- 1 file changed, 5 deletions(-)
drivers/cpufreq/amd-pstate.c +0 -5
@@ -31,19 +31,14 @@#include <linux/compiler.h> #include <linux/dmi.h> #include <linux/slab.h> -#include <linux/acpi.h> #include <linux/io.h> #include <linux/delay.h> #include <linux/uaccess.h> #include <linux/static_call.h> -#include <acpi/processor.h> #include <acpi/cppc_acpi.h> #include <asm/msr.h> -#include <asm/processor.h> -#include <asm/cpufeature.h> -#include <asm/cpu_device_id.h> #include "amd-pstate-trace.h" #define AMD_PSTATE_TRANSITION_LATENCY 0x20000
Signature · 1 line
2.34.1
Re: [PATCH v5 1/7] cpufreq: amd-pstate: cleanup the unused and duplicated headers declaration
Hi Perry,
Quoted 3 lines · Perry Yuan
Cleanup the headers declaration which are not used actually and some duplicated declaration which is declarated in some other headers already, it will help to simplify the header part.
We usually don't get rid of indirectly included headers as long as definitions from header are used in the code. This avoids problems if for some reason the included header gets dropped - it'll leave the code in an uncompilable state.
More below.
Quoted 17 lines
Reviewed-by Huang Rui <[email protected]>Acked-by Viresh Kumar <[email protected]>Signed-off-by Perry Yuan <[email protected]>--- drivers/cpufreq/amd-pstate.c | 5 ----- 1 file changed, 5 deletions(-)drivers/cpufreq/amd-pstate.c +0
-1@@ -31,19 +31,14 @@#include <linux/compiler.h> #include <linux/dmi.h> #include <linux/slab.h> -#include <linux/acpi.h>
drivers/cpufreq/amd-pstate.c line 44
Quoted 10 lines
drivers/cpufreq/amd-pstate.c +0
-2#include <linux/io.h> #include <linux/delay.h> #include <linux/uaccess.h> #include <linux/static_call.h> -#include <acpi/processor.h> #include <acpi/cppc_acpi.h> #include <asm/msr.h> -#include <asm/processor.h>
On a quick scan, I noticed that "boot_cpu_data" and "boot_cpu_has()" in the module init function are defined in "asm/processor.h" that is being removed here. It may compile for now but makes the code more fragile as explained above.
Please ensure that only the header files that have no definitions used in this file (amd-pstate.c) are dropped.
Quoted 5 lines
drivers/cpufreq/amd-pstate.c +0
-2-#include <asm/cpufeature.h> -#include <asm/cpu_device_id.h> #include "amd-pstate-trace.h" #define AMD_PSTATE_TRANSITION_LATENCY 0x20000
Yuan, Perry
reviewerRE: [PATCH v5 1/7] cpufreq: amd-pstate: cleanup the unused and duplicated headers declaration
[AMD Official Use Only - General]
Hi Punit,
Quoted 64 lines
-----Original Message-----
From: Punit Agrawal <[email protected]>
Sent: Monday, August 15, 2022 11:05 PM
To: Yuan, Perry <[email protected]>
Cc: [email protected]; Huang, Ray <[email protected]>; [email protected]; Sharma, Deepak <[email protected]>; Limonciello, Mario <[email protected]>; Fontenot, Nathan <[email protected]>; Deucher, Alexander <[email protected]>; Su, Jinzhou (Joe) <[email protected]>; Huang, Shimmer <[email protected]>; Du, Xiaojian <[email protected]>; Meng, Li (Jassmine) <[email protected]>; linux- [email protected]; [email protected]
Subject: Re: [PATCH v5 1/7] cpufreq: amd-pstate: cleanup the unused and duplicated headers declaration[CAUTION: External Email]
Hi Perry,
Quoted 3 lines · Perry Yuan
Cleanup the headers declaration which are not used actually and some duplicated declaration which is declarated in some other headers already, it will help to simplify the header part.
We usually don't get rid of indirectly included headers as long as definitions from header are used in the code. This avoids problems if for some reason the included header gets dropped - it'll leave the code in an uncompilable state.
More below.
Quoted 17 lines
Reviewed-by Huang Rui <[email protected]>Acked-by Viresh Kumar <[email protected]>Signed-off-by Perry Yuan <[email protected]>--- drivers/cpufreq/amd-pstate.c | 5 ----- 1 file changed, 5 deletions(-)(quoted diff) +0
-0
b/drivers/cpufreq/amd-pstate.cindex9ac75c1cde9c..19a078e232dd100644drivers/cpufreq/amd-pstate.c +0
-1@@ -31,19 +31,14 @@#include <linux/compiler.h> #include <linux/dmi.h> #include <linux/slab.h> -#include <linux/acpi.h> drivers/cpufreq/amd-pstate.c line 44
Quoted 10 lines
drivers/cpufreq/amd-pstate.c +0
-2#include <linux/io.h> #include <linux/delay.h> #include <linux/uaccess.h> #include <linux/static_call.h> -#include <acpi/processor.h> #include <acpi/cppc_acpi.h> #include <asm/msr.h> -#include <asm/processor.h> On a quick scan, I noticed that "
boot_cpu_data" and "boot_cpu_has()" in the module init function are defined in "asm/processor.h" that is being removed here. It may compile for now but makes the code more fragile as explained above.
Quoted 2 lines
Please ensure that only the header files that have no definitions used in this file (
amd-pstate.c) are dropped.
Here is the part of the headers we are working on.
==============================================
#include <linux/static_call.h>
#include <acpi/cppc_acpi.h>
#include <asm/msr.h>
#include "amd-pstate-trace.h"
============================================
I have tested the latest Linux-pm/bleeding-edge branch to verify the changes working. As I know the "asm/processor.h" is included by the "acpi/cppc_acpi.h" subpath
#include <acpi/cppc_acpi.h>
#include <linux/acpi.h>
#include <acpi/acpi.h>
#include <asm/acpi.h>
#include <asm/processor.h>To make it comfortable for us, I will send V6 for this patch (1/7)
Perry.
Quoted 6 lines
Quoted 6 lines
drivers/cpufreq/amd-pstate.c +0
-2-#include <asm/cpufeature.h> -#include <asm/cpu_device_id.h> #include "amd-pstate-trace.h" #define AMD_PSTATE_TRANSITION_LATENCY 0x20000
Perry Yuan
reviewerPATCH v5 2/7 cpufreq: amd-pstate: simplify cpudata pointer assignment
In reply to Perry Yuanmove the cpudata assignment to cpudata declaration which will simplify the functions.
No functional change intended.
--- drivers/cpufreq/amd-pstate.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-)
drivers/cpufreq/amd-pstate.c +3 -9
@@ -550,9 +550,7 @@ static int amd_pstate_cpu_init(struct cpufreq_policy *policy)static int amd_pstate_cpu_exit (struct cpufreq_policy *policy) { -struct amd_cpudata *cpudata; - - cpudata = policy->driver_data; +struct amd_cpudata *cpudata = policy->driver_data;freq_qos_remove_request (&cpudata->req[1 ]);freq_qos_remove_request (&cpudata->req[0 ]);
@@ -594,9 +592,7 @@ static ssize_t show_amd_pstate_max_freq(struct cpufreq_policy *policy, char *buf) {int max_freq; -struct amd_cpudata *cpudata; - - cpudata = policy->driver_data; +struct amd_cpudata *cpudata = policy->driver_data; max_freq =amd_get_max_freq (cpudata);if (max_freq <0 )
@@ -609,9 +605,7 @@ static ssize_t show_amd_pstate_lowest_nonlinear_freq(struct cpufreq_policy *poli char *buf) {int freq; -struct amd_cpudata *cpudata; - - cpudata = policy->driver_data; +struct amd_cpudata *cpudata = policy->driver_data; freq =amd_get_lowest_nonlinear_freq (cpudata);if (freq <0 )
Signature · 1 line
2.34.1
Perry Yuan
reviewerPATCH v5 3/7 cpufreq: amd-pstate: fix white-space
In reply to Perry YuanRemove the white space and correct mixed-up indentation
--- drivers/cpufreq/amd-pstate.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/cpufreq/amd-pstate.c +2 -2
@@ -115,7 +115,7 @@ struct amd_cpudata {struct amd_aperf_mperf cur;struct amd_aperf_mperf prev; -u64 freq; +u64 freq;bool boost_supported; };
@@ -651,7 +651,7 @@ static struct cpufreq_driver amd_pstate_driver = { .resume = amd_pstate_cpu_resume, .set_boost = amd_pstate_set_boost, .name = "amd-pstate", - .attr = amd_pstate_attr, + .attr = amd_pstate_attr, };static int __init amd_pstate_init (void )
Signature · 1 line
2.34.1
Re: [PATCH v5 3/7] cpufreq: amd-pstate: fix white-space
Quoted 23 lines · Perry Yuan
Remove the white space and correct mixed-up indentation
Acked-by Viresh Kumar <[email protected]>Signed-off-by Perry Yuan <[email protected]>--- drivers/cpufreq/amd-pstate.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/cpufreq/amd-pstate.c +1
-1@@ -115,7 +115,7 @@ struct amd_cpudata {struct amd_aperf_mperf cur;struct amd_aperf_mperf prev; -u64 freq; +u64 freq;bool boost_supported; };
drivers/cpufreq/amd-pstate.c static struct cpufreq_driver amd_pstate_driver = {
Quoted 9 lines
drivers/cpufreq/amd-pstate.c +1
-2@@ -651,7 +651,7 @@ static struct cpufreq_driver amd_pstate_driver = { .resume = amd_pstate_cpu_resume, .set_boost = amd_pstate_set_boost, .name = "amd-pstate", - .attr = amd_pstate_attr, + .attr = amd_pstate_attr, };static int __init amd_pstate_init (void ) --
Applied as 6.1 material along with patches [3-6/7].
The [7/7] was applied earlier and there was a change request for patch [1/7].
Perry Yuan
reviewerPATCH v5 4/7 cpufreq: amd_pstate: fix wrong lowest perf fetch
In reply to Perry YuanFix the wrong lowest perf value reading which is used for new des_perf calculation by governor requested, the incorrect min_perf will get incorrect des_perf to be set , that will cause the system frequency changing unexpectedly.
--- drivers/cpufreq/amd-pstate.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/cpufreq/amd-pstate.c +1 -1
@@ -307,7 +307,7 @@ static int amd_pstate_target(struct cpufreq_policy *policy,return -ENODEV ; cap_perf =READ_ONCE (cpudata->highest_perf); - min_perf =READ_ONCE (cpudata->lowest_nonlinear_perf); + min_perf =READ_ONCE (cpudata->lowest_perf); max_perf = cap_perf; freqs.old = policy->cur;
Signature · 1 line
2.34.1
Re: [PATCH v5 4/7] cpufreq: amd_pstate: fix wrong lowest perf fetch
Hi Perry,
Quoted 18 lines · Perry Yuan
Fix the wrong lowest perf value reading which is used for new
des_perfcalculation by governor requested, the incorrectmin_perfwill get incorrectdes_perfto be set , that will cause the system frequency changing unexpectedly.Reviewed-by Huang Rui <[email protected]>Acked-by Viresh Kumar <[email protected]>Signed-off-by Perry Yuan <[email protected]>Signed-off-by Su Jinzhou <[email protected]>--- drivers/cpufreq/amd-pstate.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/cpufreq/amd-pstate.c +0
-0
drivers/cpufreq/amd-pstate.c static int amd_pstate_target(struct cpufreq_policy *policy, · line 313
Quoted 8 lines
drivers/cpufreq/amd-pstate.c +1
-1@@ -307,7 +307,7 @@ static int amd_pstate_target(struct cpufreq_policy *policy,return -ENODEV ; cap_perf =READ_ONCE (cpudata->highest_perf); - min_perf =READ_ONCE (cpudata->lowest_nonlinear_perf); + min_perf =READ_ONCE (cpudata->lowest_perf); max_perf = cap_perf; freqs.old = policy->cur;
This looks to be a pretty big change (lowest nonlinear vs lowest). Does the patch need to be backported to older kernels?
Yuan, Perry
reviewerRE: [PATCH v5 4/7] cpufreq: amd_pstate: fix wrong lowest perf fetch
[AMD Official Use Only - General]
Hi Agrawal,
Quoted 46 lines
-----Original Message-----
From: Punit Agrawal <[email protected]>
Sent: Monday, August 15, 2022 11:05 PM
To: Yuan, Perry <[email protected]>
Cc: [email protected]; Huang, Ray <[email protected]>; [email protected]; Sharma, Deepak <[email protected]>; Limonciello, Mario <[email protected]>; Fontenot, Nathan <[email protected]>; Deucher, Alexander <[email protected]>; Su, Jinzhou (Joe) <[email protected]>; Huang, Shimmer <[email protected]>; Du, Xiaojian <[email protected]>; Meng, Li (Jassmine) <[email protected]>; linux- [email protected]; [email protected]
Subject: Re: [PATCH v5 4/7] cpufreq:amd_pstate: fix wrong lowest perf fetch[CAUTION: External Email]
Hi Perry,
drivers/cpufreq/amd-pstate.c static int amd_pstate_target(struct cpufreq_policy
Quoted 18 lines · Perry Yuan
Fix the wrong lowest perf value reading which is used for new
des_perfcalculation by governor requested, the incorrectmin_perfwill get incorrectdes_perfto be set , that will cause the system frequency changing unexpectedly.Reviewed-by Huang Rui <[email protected]>Acked-by Viresh Kumar <[email protected]>Signed-off-by Perry Yuan <[email protected]>Signed-off-by Su Jinzhou <[email protected]>--- drivers/cpufreq/amd-pstate.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)(quoted diff) +0
-0
b/drivers/cpufreq/amd-pstate.cindex5cdef6638681..183cdd4ba00e100644drivers/cpufreq/amd-pstate.c +0
-0@@ -307,7 +307,7 @@ static int amd_pstate_target(struct cpufreq_policy*policy,
Quoted 7 lines
drivers/cpufreq/amd-pstate.c +1
-1return -ENODEV ; cap_perf =READ_ONCE (cpudata->highest_perf); - min_perf =READ_ONCE (cpudata->lowest_nonlinear_perf); + min_perf =READ_ONCE (cpudata->lowest_perf); max_perf = cap_perf;
Quoted 4 lines
drivers/cpufreq/amd-pstate.c static int amd_pstate_target(struct cpufreq_policy *policy, · line 313
Quoted 1 line
drivers/cpufreq/amd-pstate.c +0
-0freqs.old = policy->cur;This looks to be a pretty big change (lowest nonlinear vs lowest). Does the patch need to be backported to older kernels?
The patch fixes the min perf initial value, the correct min perf is lowest_perf which is captured through MSR_AMD_CPPC_CAP1 register or the cppc_get_perf_caps(). Yes, the patch will need to be backported to other kernel branch as issue fix.
Sorry to response late.
Perry.
Re: [PATCH v5 4/7] cpufreq: amd_pstate: fix wrong lowest perf fetch
"Yuan, Perry" <[email protected]> writes:
[...]
Quoted 28 lines
Quoted 28 lines
drivers/cpufreq/amd-pstate.c static int amd_pstate_target(struct cpufreq_policy
Quoted 18 lines · Perry Yuan
Fix the wrong lowest perf value reading which is used for new
des_perfcalculation by governor requested, the incorrectmin_perfwill get incorrectdes_perfto be set , that will cause the system frequency changing unexpectedly.Reviewed-by Huang Rui <[email protected]>Acked-by Viresh Kumar <[email protected]>Signed-off-by Perry Yuan <[email protected]>Signed-off-by Su Jinzhou <[email protected]>--- drivers/cpufreq/amd-pstate.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)(quoted diff) +0
-0
b/drivers/cpufreq/amd-pstate.cindex5cdef6638681..183cdd4ba00e100644drivers/cpufreq/amd-pstate.c +0
-0@@ -307,7 +307,7 @@ static int amd_pstate_target(struct cpufreq_policy*policy,
Quoted 7 lines
drivers/cpufreq/amd-pstate.c +1
-1return -ENODEV ; cap_perf =READ_ONCE (cpudata->highest_perf); - min_perf =READ_ONCE (cpudata->lowest_nonlinear_perf); + min_perf =READ_ONCE (cpudata->lowest_perf); max_perf = cap_perf;
Quoted 7 lines
Quoted 4 lines
drivers/cpufreq/amd-pstate.c static int amd_pstate_target(struct cpufreq_policy *policy, · line 313
Quoted 1 line
drivers/cpufreq/amd-pstate.c +0
-0freqs.old = policy->cur;This looks to be a pretty big change (lowest nonlinear vs lowest). Does the patch need to be backported to older kernels?
The patch fixes the min perf initial value, the correct min perf is
lowest_perfwhich is captured throughMSR_AMD_CPPC_CAP1register or thecppc_get_perf_caps(). Yes, the patch will need to be backported to other kernel branch as issue fix.
Great, thanks for confirming!
[...]
Perry Yuan
reviewerPATCH v5 5/7 cpufreq: amd_pstate: map desired perf into pstate scope for powersave governor
In reply to Perry YuanThe patch will fix the invalid desired perf value for powersave governor. This issue is found when testing on one AMD EPYC system, the actual des_perf is smaller than the min_perf value, that is invalid value. because the min_perf is the lowest_perf system can support in idle state.
--- drivers/cpufreq/amd-pstate.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/cpufreq/amd-pstate.c +1 -2
@@ -264,6 +264,7 @@ static void amd_pstate_update(struct amd_cpudata *cpudata, u32 min_perf,u64 prev =READ_ONCE (cpudata->cppc_req_cached);u64 value = prev; + des_perf = clamp_t(unsigned long, des_perf, min_perf, max_perf); value &= ~AMD_CPPC_MIN_PERF (~0L ); value |=AMD_CPPC_MIN_PERF (min_perf);
@@ -352,8 +353,6 @@ static void amd_pstate_adjust_perf(unsigned int cpu,if (max_perf < min_perf) max_perf = min_perf; - des_perf = clamp_t(unsigned long, des_perf, min_perf, max_perf); -amd_pstate_update (cpudata, min_perf, des_perf, max_perf, true); }
Signature · 1 line
2.34.1
Perry Yuan
reviewerPATCH v5 6/7 cpufreq: amd-pstate: update pstate frequency transition delay time
In reply to Perry YuanChange the default transition latency to be 20ms that is more reasonable transition delay for AMD processors in non-EPP driver mode.
Update transition delay time to 1ms, in the AMD CPU autonomous mode and non-autonomous mode, CPPC firmware will decide frequency at 1ms timescale based on the workload utilization.
--- drivers/cpufreq/amd-pstate.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/cpufreq/amd-pstate.c +2 -2
@@ -41,8 +41,8 @@#include <asm/msr.h> #include "amd-pstate-trace.h" -#define AMD_PSTATE_TRANSITION_LATENCY 0x20000 -#define AMD_PSTATE_TRANSITION_DELAY 500 +#define AMD_PSTATE_TRANSITION_LATENCY 20000 +#define AMD_PSTATE_TRANSITION_DELAY 1000/* * TODO: We need more time to fine tune processors with shared memory solution
Signature · 1 line
2.34.1
Re: [PATCH v5 6/7] cpufreq: amd-pstate: update pstate frequency transition delay time
Quoted 18 lines · Perry Yuan
Change the default transition latency to be 20ms that is more reasonable transition delay for AMD processors in non-EPP driver mode.
Update transition delay time to 1ms, in the AMD CPU autonomous mode and non-autonomous mode, CPPC firmware will decide frequency at 1ms timescale based on the workload utilization.
Acked-by Viresh Kumar <[email protected]>Signed-off-by Perry Yuan <[email protected]>--- drivers/cpufreq/amd-pstate.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/cpufreq/amd-pstate.c +0
-0
drivers/cpufreq/amd-pstate.c line 45
Quoted 7 lines
drivers/cpufreq/amd-pstate.c +2
-2@@ -41,8 +41,8 @@#include <asm/msr.h> #include "amd-pstate-trace.h" -#define AMD_PSTATE_TRANSITION_LATENCY 0x20000 -#define AMD_PSTATE_TRANSITION_DELAY 500 +#define AMD_PSTATE_TRANSITION_LATENCY 20000 +#define AMD_PSTATE_TRANSITION_DELAY 1000
How were these values derived? If from documentation, it'll be good to add a link to the relevant documentation. And if they were derived from testing, please mention this in the commit log (along with some details of the tests used to determine the value).
Quoted 3 lines
drivers/cpufreq/amd-pstate.c +0
-0/* * TODO: We need more time to fine tune processors with shared memory solution
Yuan, Perry
reviewerRE: [PATCH v5 6/7] cpufreq: amd-pstate: update pstate frequency transition delay time
[AMD Official Use Only - General]
Hi Punit
Quoted 40 lines
-----Original Message-----
From: Punit Agrawal <[email protected]>
Sent: Monday, August 15, 2022 11:06 PM
To: Yuan, Perry <[email protected]>
Cc: [email protected]; Huang, Ray <[email protected]>; [email protected]; Sharma, Deepak <[email protected]>; Limonciello, Mario <[email protected]>; Fontenot, Nathan <[email protected]>; Deucher, Alexander <[email protected]>; Su, Jinzhou (Joe) <[email protected]>; Huang, Shimmer <[email protected]>; Du, Xiaojian <[email protected]>; Meng, Li (Jassmine) <[email protected]>; linux- [email protected]; [email protected]
Subject: Re: [PATCH v5 6/7] cpufreq: amd-pstate: update pstate frequency transition delay time[CAUTION: External Email]
Quoted 21 lines · Perry Yuan
Change the default transition latency to be 20ms that is more reasonable transition delay for AMD processors in non-EPP driver mode.
Update transition delay time to 1ms, in the AMD CPU autonomous mode and non-autonomous mode, CPPC firmware will decide frequency at 1ms timescale based on the workload utilization.
Acked-by Viresh Kumar <[email protected]>Signed-off-by Perry Yuan <[email protected]>--- drivers/cpufreq/amd-pstate.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)(quoted diff) +0
-0
b/drivers/cpufreq/amd-pstate.cindexe40177d14310..9cb051d61422100644drivers/cpufreq/amd-pstate.c +0
-0@@ -41,8 +41,8 @@#include <asm/msr.h> #include "amd-pstate-trace.h"
Quoted 9 lines
drivers/cpufreq/amd-pstate.c line 45
Quoted 4 lines
drivers/cpufreq/amd-pstate.c +2
-2-#define AMD_PSTATE_TRANSITION_LATENCY 0x20000 -#define AMD_PSTATE_TRANSITION_DELAY 500 +#define AMD_PSTATE_TRANSITION_LATENCY 20000 +#define AMD_PSTATE_TRANSITION_DELAY 1000How were these values derived? If from documentation, it'll be good to add a link to the relevant documentation. And if they were derived from testing, please mention this in the commit log (along with some details of the tests used to determine the value).
The values are calculated from the CPU PM firmware and hardware design.
There are some latency and delay values defined in the PM firmware, I have no documents about the detail for now.
Perry.
Quoted 5 lines
Quoted 5 lines
drivers/cpufreq/amd-pstate.c +0
-0/* * TODO: We need more time to fine tune processors with shared memory solution
Re: [PATCH v5 6/7] cpufreq: amd-pstate: update pstate frequency transition delay time
Hi Perry,
Quoted 54 lines · Perry
[AMD Official Use Only - General]
Hi Punit
Quoted 40 lines
-----Original Message-----
From: Punit Agrawal <[email protected]>
Sent: Monday, August 15, 2022 11:06 PM
To: Yuan, Perry <[email protected]>
Cc: [email protected]; Huang, Ray <[email protected]>; [email protected]; Sharma, Deepak <[email protected]>; Limonciello, Mario <[email protected]>; Fontenot, Nathan <[email protected]>; Deucher, Alexander <[email protected]>; Su, Jinzhou (Joe) <[email protected]>; Huang, Shimmer <[email protected]>; Du, Xiaojian <[email protected]>; Meng, Li (Jassmine) <[email protected]>; linux- [email protected]; [email protected]
Subject: Re: [PATCH v5 6/7] cpufreq: amd-pstate: update pstate frequency transition delay time[CAUTION: External Email]
Quoted 21 lines · Perry Yuan
Change the default transition latency to be 20ms that is more reasonable transition delay for AMD processors in non-EPP driver mode.
Update transition delay time to 1ms, in the AMD CPU autonomous mode and non-autonomous mode, CPPC firmware will decide frequency at 1ms timescale based on the workload utilization.
Acked-by Viresh Kumar <[email protected]>Signed-off-by Perry Yuan <[email protected]>--- drivers/cpufreq/amd-pstate.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)(quoted diff) +0
-0
b/drivers/cpufreq/amd-pstate.cindexe40177d14310..9cb051d61422100644drivers/cpufreq/amd-pstate.c +0
-0@@ -41,8 +41,8 @@#include <asm/msr.h> #include "amd-pstate-trace.h" Quoted 9 lines
drivers/cpufreq/amd-pstate.c line 45
Quoted 4 lines
drivers/cpufreq/amd-pstate.c +2
-2-#define AMD_PSTATE_TRANSITION_LATENCY 0x20000 -#define AMD_PSTATE_TRANSITION_DELAY 500 +#define AMD_PSTATE_TRANSITION_LATENCY 20000 +#define AMD_PSTATE_TRANSITION_DELAY 1000How were these values derived? If from documentation, it'll be good to add a link to the relevant documentation. And if they were derived from testing, please mention this in the commit log (along with some details of the tests used to determine the value).
Quoted 2 lines
The values are calculated from the CPU PM firmware and hardware design.
There are some latency and delay values defined in the PM firmware, I have no documents about the detail for now.
In that case, please mention that the values are calculated from firmware / hardware design in the commit log (and include a reference to the firmware sources if available).
Thanks!
[...]
Perry Yuan
reviewerPATCH v5 7/7 cpufreq: amd-pstate: add ACPI disabled check in acpi_cpc_valid()
In reply to Perry YuanAdd acpi function check in case ACPI is not enabled, that will cause pstate driver failed to call cppc acpi to change perf or update epp value for shared memory solution processors.
When CPPC or ACPI is invalid, warning log will be needed to tell user that AMD pstate driver failed to load and what is wrong.
--- drivers/acpi/cppc_acpi.c | 3 +++ drivers/base/arch_topology.c | 2 +- drivers/cpufreq/amd-pstate.c | 2 +- drivers/cpufreq/cppc_cpufreq.c | 2 +- 4 files changed, 6 insertions(+), 3 deletions(-)
drivers/acpi/cppc_acpi.c +3 -0
@@ -424,6 +424,9 @@ bool acpi_cpc_valid(void)struct cpc_desc *cpc_ptr;int cpu; +if (acpi_disabled) +return false; +for_each_present_cpu (cpu) { cpc_ptr =per_cpu (cpc_desc_ptr, cpu);if (!cpc_ptr)
drivers/base/arch_topology.c +1 -1
@@ -352,7 +352,7 @@ void topology_init_cpu_capacity_cppc(void)struct cppc_perf_caps perf_caps;int cpu; -if (likely (acpi_disabled || !acpi_cpc_valid ())) +if (likely (!acpi_cpc_valid ()))return ; raw_capacity = kcalloc(num_possible_cpus(), sizeof(*raw_capacity),
drivers/cpufreq/amd-pstate.c +1 -1
@@ -661,7 +661,7 @@ static int __init amd_pstate_init(void)return -ENODEV ;if (!acpi_cpc_valid ()) { -pr_debug ("the _CPC object is not present in SBIOS\n" ); +pr_warn_once ("the _CPC object is not present in SBIOS or ACPI disabled\n" );return -ENODEV ; }
drivers/cpufreq/cppc_cpufreq.c +1 -1
@@ -947,7 +947,7 @@ static int __init cppc_cpufreq_init(void) {int ret; -if ((acpi_disabled) || !acpi_cpc_valid ()) +if (!acpi_cpc_valid ())return -ENODEV ;cppc_check_hisi_workaround ();
Signature · 1 line
2.34.1
Re: [PATCH v5 7/7] cpufreq: amd-pstate: add ACPI disabled check in acpi_cpc_valid()
Quoted 61 lines · Perry Yuan
Add acpi function check in case ACPI is not enabled, that will cause pstate driver failed to call cppc acpi to change perf or update epp value for shared memory solution processors.
When CPPC or ACPI is invalid, warning log will be needed to tell user that AMD pstate driver failed to load and what is wrong.
Signed-off-by Perry Yuan <[email protected]>--- drivers/acpi/cppc_acpi.c | 3 +++ drivers/base/arch_topology.c | 2 +- drivers/cpufreq/amd-pstate.c | 2 +- drivers/cpufreq/cppc_cpufreq.c | 2 +- 4 files changed, 6 insertions(+), 3 deletions(-)drivers/acpi/cppc_acpi.c +3
-0@@ -424,6 +424,9 @@ bool acpi_cpc_valid(void)struct cpc_desc *cpc_ptr;int cpu; +if (acpi_disabled) +return false; +for_each_present_cpu (cpu) { cpc_ptr =per_cpu (cpc_desc_ptr, cpu);if (!cpc_ptr)drivers/base/arch_topology.c +1
-1@@ -352,7 +352,7 @@ void topology_init_cpu_capacity_cppc(void)struct cppc_perf_caps perf_caps;int cpu; -if (likely (acpi_disabled || !acpi_cpc_valid ())) +if (likely (!acpi_cpc_valid ()))return ; raw_capacity = kcalloc(num_possible_cpus(), sizeof(*raw_capacity),drivers/cpufreq/amd-pstate.c +1
-1@@ -661,7 +661,7 @@ static int __init amd_pstate_init(void)return -ENODEV ;if (!acpi_cpc_valid ()) { -pr_debug ("the _CPC object is not present in SBIOS\n" ); +pr_warn_once ("the _CPC object is not present in SBIOS or ACPI disabled\n" );return -ENODEV ; }drivers/cpufreq/cppc_cpufreq.c +0
-0
drivers/cpufreq/cppc_cpufreq.c static int __init cppc_cpufreq_init(void)
Quoted 9 lines
drivers/cpufreq/cppc_cpufreq.c +1
-2@@ -947,7 +947,7 @@ static int __init cppc_cpufreq_init(void) {int ret; -if ((acpi_disabled) || !acpi_cpc_valid ()) +if (!acpi_cpc_valid ())return -ENODEV ;cppc_check_hisi_workaround (); --
Applied as 6.1 material with modified subject and changelog, thanks!