AMD Pstate Fixes And Enhancements
Subsystems (5)
Perry Yuan
reviewerv2 cover AMD Pstate Fixes And Enhancements
The patch series adds some fixes and enhancements to the AMD pstate driver.
It enables CPPC v2 for certain processors in the family 17H, as requested
by TR40 processor users who expect improved performance and lower system temperature.
Additionally, it fixes the initialization of nominal_freq for each cpudata
and changes latency and delay values to be read from platform firmware firstly
for more accurate timing.
A new quirk is also added for legacy processors that lack CPPC capabilities which caused the pstate driver to fail loading.
I would greatly appreciate any feedbacks.
Thank you!
Changes from v1:
* pick up the RB flags from Mario
* address review comment of patch #6 for amd_get_nominal_freq()
* rebased the series to linux-pm/bleeding-edge v6.8.0-rc2
* update debug log for patch #5 as Mario suggested.
* fix some typos and format problems
* tested on 7950X platform
V1: https://lore.kernel.org/lkml/[email protected]/
Perry Yuan (6):
ACPI: CPPC: enable AMD CPPC V2 support for family 17h processors cpufreq:amd-pstate: fix the nominal freq value set cpufreq:amd-pstate: initialize nominal_freq of each cpudata cpufreq:amd-pstate: get pstate transition delay and latency value from
ACPI tables
cppc_acpi: print error message if CPPC is unsupported cpufreq:amd-pstate: add quirk for the pstate CPPC capabilities missing
arch/x86/kernel/acpi/cppc.c | 2 +- drivers/acpi/cppc_acpi.c | 4 +- drivers/cpufreq/amd-pstate.c | 108 +++++++++++++++++++++++++++++------ include/linux/amd-pstate.h | 6 ++ 4 files changed, 101 insertions(+), 19 deletions(-)
Signature · 1 line
2.34.1
Perry Yuan
reviewerPATCH v2 1/6 ACPI: CPPC: enable AMD CPPC V2 support for family 17h processors
As there are some AMD processors which only support CPPC V2 firmware and BIOS implementation, the amd_pstate driver will be failed to load when system booting with below kernel warning message:
[ 0.477523] amd_pstate: the _CPC object is not present in SBIOS or ACPI disabled
To make the amd_pstate driver can be loaded on those TR40 processors, it needs to match x86_model from 0x30 to 0x7F for family 17H. With the change, the system can load amd_pstate driver as expected.
--- arch/x86/kernel/acpi/cppc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/kernel/acpi/cppc.c +1 -1
@@ -20,7 +20,7 @@ bool cpc_supported_by_cpu(void) (boot_cpu_data.x86_model >= 0x20 && boot_cpu_data.x86_model <= 0x2f)))return true; else if (boot_cpu_data.x86 == 0x17 && - boot_cpu_data.x86_model >= 0x70 && boot_cpu_data.x86_model <= 0x7f) + boot_cpu_data.x86_model >= 0x30 && boot_cpu_data.x86_model <= 0x7f) return true;return boot_cpu_has (X86_FEATURE_CPPC ); }
Signature · 1 line
2.34.1
Perry Yuan
reviewerPATCH v2 2/6 cpufreq:amd-pstate: fix the nominal freq value set
In reply to Perry YuanAddress an untested error where the nominal_freq was returned in KHz instead of the correct MHz units, this oversight led to a wrong nominal_freq set and resued, it will cause the max frequency of core to be initialized with a wrong frequency value.
--- drivers/cpufreq/amd-pstate.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/cpufreq/amd-pstate.c +1 -2
@@ -640,8 +640,7 @@ static int amd_get_nominal_freq(struct amd_cpudata *cpudata)if (ret)return ret; -/* Switch to khz */ -return cppc_perf.nominal_freq *1000 ; +return cppc_perf.nominal_freq; }static int amd_get_lowest_nonlinear_freq (struct amd_cpudata *cpudata)
Signature · 1 line
2.34.1
Perry Yuan
reviewerPATCH v2 3/6 cpufreq:amd-pstate: initialize nominal_freq of each cpudata
In reply to Perry YuanOptimizes the process of retrieving the nominal frequency by utilizing 'cpudata->nominal_freq' instead of repeatedly accessing the cppc_acpi interface.
To enhance efficiency and reduce the CPU load, shifted to using 'cpudata->nominal_freq'. It allows for the nominal frequency to be accessed directly from the cached data in 'cpudata' of each CPU.
It will also slightly reduce the frequency change latency while using pstate driver passive mode.
--- drivers/cpufreq/amd-pstate.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-)
drivers/cpufreq/amd-pstate.c +12 -12
@@ -619,7 +619,7 @@ static int amd_get_max_freq(struct amd_cpudata *cpudata)if (ret)return ret; - nominal_freq = cppc_perf.nominal_freq; + nominal_freq =READ_ONCE (cpudata->nominal_freq); nominal_perf =READ_ONCE (cpudata->nominal_perf); max_perf =READ_ONCE (cpudata->highest_perf);
@@ -654,7 +654,7 @@ static int amd_get_lowest_nonlinear_freq(struct amd_cpudata *cpudata)if (ret)return ret; - nominal_freq = cppc_perf.nominal_freq; + nominal_freq =READ_ONCE (cpudata->nominal_freq); nominal_perf =READ_ONCE (cpudata->nominal_perf); lowest_nonlinear_perf = cppc_perf.lowest_nonlinear_perf;
@@ -848,13 +848,14 @@ static int amd_pstate_cpu_init(struct cpufreq_policy *policy) goto free_cpudata1; min_freq =amd_get_min_freq (cpudata); - max_freq =amd_get_max_freq (cpudata); nominal_freq =amd_get_nominal_freq (cpudata); + cpudata->nominal_freq = nominal_freq; + max_freq =amd_get_max_freq (cpudata); lowest_nonlinear_freq =amd_get_lowest_nonlinear_freq (cpudata); -if (min_freq <0 || max_freq <0 || min_freq > max_freq) { -dev_err (dev,"min_freq(%d) or max_freq(%d) value is incorrect\n" , - min_freq, max_freq); +if (min_freq <0 || max_freq <0 || min_freq > max_freq || nominal_freq ==0 ) { +dev_err (dev,"min_freq(%d) or max_freq(%d) or nominal_freq(%d) is incorrect\n" , + min_freq, max_freq, nominal_freq); ret = -EINVAL ; goto free_cpudata1; }
@@ -893,7 +894,6 @@ static int amd_pstate_cpu_init(struct cpufreq_policy *policy) cpudata->min_freq = min_freq; cpudata->max_limit_freq = max_freq; cpudata->min_limit_freq = min_freq; - cpudata->nominal_freq = nominal_freq; cpudata->lowest_nonlinear_freq = lowest_nonlinear_freq; policy->driver_data = cpudata;
@@ -1310,12 +1310,13 @@ static int amd_pstate_epp_cpu_init(struct cpufreq_policy *policy) goto free_cpudata1; min_freq =amd_get_min_freq (cpudata); - max_freq =amd_get_max_freq (cpudata); nominal_freq =amd_get_nominal_freq (cpudata); + cpudata->nominal_freq = nominal_freq; + max_freq =amd_get_max_freq (cpudata); lowest_nonlinear_freq =amd_get_lowest_nonlinear_freq (cpudata); -if (min_freq <0 || max_freq <0 || min_freq > max_freq) { -dev_err (dev,"min_freq(%d) or max_freq(%d) value is incorrect\n" , - min_freq, max_freq); +if (min_freq <0 || max_freq <0 || min_freq > max_freq || nominal_freq ==0 ) { +dev_err (dev,"min_freq(%d) or max_freq(%d) or nominal_freq(%d) is incorrect\n" , + min_freq, max_freq, nominal_freq); ret = -EINVAL ; goto free_cpudata1; }
@@ -1328,7 +1329,6 @@ static int amd_pstate_epp_cpu_init(struct cpufreq_policy *policy)/* Initial processor data capability frequencies */ cpudata->max_freq = max_freq; cpudata->min_freq = min_freq; - cpudata->nominal_freq = nominal_freq; cpudata->lowest_nonlinear_freq = lowest_nonlinear_freq; policy->driver_data = cpudata;
Signature · 1 line
2.34.1
Perry Yuan
reviewerPATCH v2 4/6 cpufreq:amd-pstate: get pstate transition delay and latency value from ACPI tables
In reply to Perry Yuanmake 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
--- drivers/cpufreq/amd-pstate.c | 34 ++++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-)
drivers/cpufreq/amd-pstate.c +32 -2
@@ -820,6 +820,36 @@ static void amd_pstate_update_limits(unsigned int cpu)mutex_unlock (&amd_pstate_driver_lock); } +/** +* Get pstate transition delay time from ACPI tables that firmware set +* instead of using hardcode value directly. +*/ +static u32 amd_pstate_get_transition_delay_us (unsigned int cpu) +{ +u32 transition_delay_ns; + + transition_delay_ns =cppc_get_transition_latency (cpu); +if (transition_delay_ns ==CPUFREQ_ETERNAL ) +return AMD_PSTATE_TRANSITION_DELAY ; + +return transition_delay_ns /NSEC_PER_USEC ; +} + +/** +* Get pstate transition latency value from ACPI tables that firmware set +* instead of using hardcode value directly. +*/ +static u32 amd_pstate_get_transition_latency (unsigned int cpu) +{ +u32 transition_latency; + + transition_latency =cppc_get_transition_latency (cpu); +if (transition_latency ==CPUFREQ_ETERNAL ) +return AMD_PSTATE_TRANSITION_LATENCY ; + +return transition_latency; +} +static int amd_pstate_cpu_init (struct cpufreq_policy *policy) {int min_freq, max_freq, nominal_freq, lowest_nonlinear_freq, ret;
@@ -860,8 +890,8 @@ static int amd_pstate_cpu_init(struct cpufreq_policy *policy) goto free_cpudata1; } - policy->cpuinfo.transition_latency =AMD_PSTATE_TRANSITION_LATENCY ; - policy->transition_delay_us =AMD_PSTATE_TRANSITION_DELAY ; + policy->cpuinfo.transition_latency =amd_pstate_get_transition_latency (policy->cpu); + policy->transition_delay_us =amd_pstate_get_transition_delay_us (policy->cpu); policy->min = min_freq; policy->max = max_freq;
Signature · 1 line
2.34.1
Perry Yuan
reviewerPATCH v2 5/6 cppc_acpi: print error message if CPPC is unsupported
In reply to Perry Yuanto be more clear what is wrong with CPPC when pstate driver failed to load which has dependency on the CPPC capabilities.
Add one more debug message to notify user if CPPC is not supported by the CPU, then it will be easy to find out what need to fix for pstate driver loading issue.
[ 0.477523] amd_pstate: the _CPC object is not present in SBIOS or ACPI disabled
Above message is not clear enough to verify whether CPPC is not supported.
--- drivers/acpi/cppc_acpi.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/acpi/cppc_acpi.c +3 -1
@@ -679,8 +679,10 @@ int acpi_cppc_processor_probe(struct acpi_processor *pr)if (!osc_sb_cppc2_support_acked) {pr_debug ("CPPC v2 _OSC not acked\n" ); -if (!cpc_supported_by_cpu ()) +if (!cpc_supported_by_cpu ()) { +pr_debug ("CPPC is not supported by the CPU\n" );return -ENODEV ; + } }/* Parse the ACPI _CPC table for this CPU. */
Signature · 1 line
2.34.1
Perry Yuan
reviewerPATCH v2 6/6 cpufreq:amd-pstate: add quirk for the pstate CPPC capabilities missing
In reply to Perry YuanAdd quirk table to get CPPC capabilities issue fixed by providing correct perf or frequency values while driver loading.
If CPPC capabilities are not defined in the ACPI tables or wrongly defined by platform firmware, it needs to use quick to get those issues fixed with correct workaround values to make pstate driver can be loaded even though there are CPPC capabilities errors.
--- drivers/cpufreq/amd-pstate.c | 49 ++++++++++++++++++++++++++++++++++-- include/linux/amd-pstate.h | 6 +++++ 2 files changed, 53 insertions(+), 2 deletions(-)
drivers/cpufreq/amd-pstate.c +47 -2
@@ -67,6 +67,7 @@ static struct cpufreq_driver amd_pstate_epp_driver;static int cppc_state =AMD_PSTATE_UNDEFINED ;static bool cppc_enabled;static bool amd_pstate_prefcore = true; +static struct quirk_entry *quirks;/* * AMD Energy Preference Performance (EPP)
@@ -111,6 +112,33 @@ static unsigned int epp_values[] = {typedef int (*cppc_mode_transition_fn )(int ); +static struct quirk_entry quirk_amd_7k62 = { + .nominal_freq =2600 , + .lowest_freq =550 , +}; + +static int __init dmi_matched (const struct dmi_system_id *dmi) +{ + quirks = dmi->driver_data; +pr_info ("hardware type %s found\n" , dmi->ident); + +return 1 ; +} + +static const struct dmi_system_id amd_pstate_quirks_table[]__initconst = { + { + .callback = dmi_matched, + .ident ="AMD EPYC 7K62" , + .matches = { +DMI_MATCH (DMI_PRODUCT_VERSION ,"C1" ), +DMI_MATCH (DMI_PRODUCT_SERIAL ,"FX19911000028" ), + }, + .driver_data = &quirk_amd_7k62, + }, + {} +}; +MODULE_DEVICE_TABLE (dmi, amd_pstate_quirks_table); +static inline int get_mode_idx_from_str (const char *str,size_t size) {int i;
@@ -600,13 +628,19 @@ static void amd_pstate_adjust_perf(unsigned int cpu,static int amd_get_min_freq (struct amd_cpudata *cpudata) {struct cppc_perf_caps cppc_perf; +u32 lowest_freq;int ret =cppc_get_perf_caps (cpudata->cpu, &cppc_perf);if (ret)return ret; +if (quirks && quirks->lowest_freq) + lowest_freq = quirks->lowest_freq; +else + lowest_freq = cppc_perf.lowest_freq; +/* Switch to khz */ -return cppc_perf.lowest_freq *1000 ; +return lowest_freq *1000 ; }static int amd_get_max_freq (struct amd_cpudata *cpudata)
@@ -635,12 +669,18 @@ static int amd_get_max_freq(struct amd_cpudata *cpudata)static int amd_get_nominal_freq (struct amd_cpudata *cpudata) {struct cppc_perf_caps cppc_perf; +u32 nominal_freq;int ret =cppc_get_perf_caps (cpudata->cpu, &cppc_perf);if (ret)return ret; -return cppc_perf.nominal_freq; +if (quirks && quirks->nominal_freq) + nominal_freq = quirks->nominal_freq; +else + nominal_freq = cppc_perf.nominal_freq; + +return nominal_freq; }static int amd_get_lowest_nonlinear_freq (struct amd_cpudata *cpudata)
@@ -1672,6 +1712,11 @@ static int __init amd_pstate_init(void)if (cpufreq_get_current_driver ())return -EEXIST ; + quirks =NULL ; + +/* check if this machine need CPPC quirks */ +dmi_check_system (amd_pstate_quirks_table); +switch (cppc_state) {case AMD_PSTATE_UNDEFINED :/* Disable on the following configs by default:
include/linux/amd-pstate.h +6 -0
@@ -124,4 +124,10 @@ static const char * const amd_pstate_mode_string[] = { [AMD_PSTATE_GUIDED] = "guided", NULL, }; + +struct quirk_entry { +u32 nominal_freq; +u32 lowest_freq; +}; +#endif /* _LINUX_AMD_PSTATE_H */
Signature · 1 line
2.34.1
Mario Limonciello
maintainerRe: [PATCH v2 6/6] cpufreq:amd-pstate: add quirk for the pstate CPPC capabilities missing
Quoted 40 lines · Perry Yuan
Add quirk table to get CPPC capabilities issue fixed by providing correct perf or frequency values while driver loading.
If CPPC capabilities are not defined in the ACPI tables or wrongly defined by platform firmware, it needs to use quick to get those issues fixed with correct workaround values to make pstate driver can be loaded even though there are CPPC capabilities errors.
Signed-off-by Perry Yuan <[email protected]>--- drivers/cpufreq/amd-pstate.c | 49 ++++++++++++++++++++++++++++++++++-- include/linux/amd-pstate.h | 6 +++++ 2 files changed, 53 insertions(+), 2 deletions(-)drivers/cpufreq/amd-pstate.c +11
-0@@ -67,6 +67,7 @@ static struct cpufreq_driver amd_pstate_epp_driver;static int cppc_state =AMD_PSTATE_UNDEFINED ;static bool cppc_enabled;static bool amd_pstate_prefcore = true; +static struct quirk_entry *quirks;/* * AMD Energy Preference Performance (EPP) @@ -111,6 +112,33 @@ static unsigned int epp_values[] = {typedef int (*cppc_mode_transition_fn )(int ); +static struct quirk_entry quirk_amd_7k62 = { + .nominal_freq =2600 , + .lowest_freq =550 , +}; + +static int __init dmi_matched (const struct dmi_system_id *dmi) +{ + quirks = dmi->driver_data; +pr_info ("hardware type %s found\n" , dmi->ident); +
drivers/cpufreq/amd-pstate.c static unsigned int epp_values[] = { · line 134
Quoted 10 lines
drivers/cpufreq/amd-pstate.c +10
-0+return 1 ; +} + +static const struct dmi_system_id amd_pstate_quirks_table[]__initconst = { + { + .callback = dmi_matched, + .ident ="AMD EPYC 7K62" , + .matches = { +DMI_MATCH (DMI_PRODUCT_VERSION ,"C1" ), +DMI_MATCH (DMI_PRODUCT_SERIAL ,"FX19911000028" )
I saw your response to v1, but really this is too narrow for upstream. It's literally applying to a SINGLE system.
I feel the rest of the patch is fine, but we shouldn't be adding single system quirks.
Quoted 78 lines
drivers/cpufreq/amd-pstate.c +26
-2+ }, + .driver_data = &quirk_amd_7k62, + }, + {} +}; +MODULE_DEVICE_TABLE (dmi, amd_pstate_quirks_table); +static inline int get_mode_idx_from_str (const char *str,size_t size) {int i;@@ -600,13 +628,19 @@ static void amd_pstate_adjust_perf(unsigned int cpu,static int amd_get_min_freq (struct amd_cpudata *cpudata) {struct cppc_perf_caps cppc_perf; +u32 lowest_freq;int ret =cppc_get_perf_caps (cpudata->cpu, &cppc_perf);if (ret)return ret; +if (quirks && quirks->lowest_freq) + lowest_freq = quirks->lowest_freq; +else + lowest_freq = cppc_perf.lowest_freq; +/* Switch to khz */ -return cppc_perf.lowest_freq *1000 ; +return lowest_freq *1000 ; }static int amd_get_max_freq (struct amd_cpudata *cpudata)@@ -635,12 +669,18 @@ static int amd_get_max_freq(struct amd_cpudata *cpudata)static int amd_get_nominal_freq (struct amd_cpudata *cpudata) {struct cppc_perf_caps cppc_perf; +u32 nominal_freq;int ret =cppc_get_perf_caps (cpudata->cpu, &cppc_perf);if (ret)return ret; -return cppc_perf.nominal_freq; +if (quirks && quirks->nominal_freq) + nominal_freq = quirks->nominal_freq; +else + nominal_freq = cppc_perf.nominal_freq; + +return nominal_freq; }static int amd_get_lowest_nonlinear_freq (struct amd_cpudata *cpudata)@@ -1672,6 +1712,11 @@ static int __init amd_pstate_init(void)if (cpufreq_get_current_driver ())return -EEXIST ; + quirks =NULL ; + +/* check if this machine need CPPC quirks */ +dmi_check_system (amd_pstate_quirks_table); +switch (cppc_state) {case AMD_PSTATE_UNDEFINED :/* Disable on the following configs by default: include/linux/amd-pstate.h +6
-0@@ -124,4 +124,10 @@ static const char * const amd_pstate_mode_string[] = { [AMD_PSTATE_GUIDED] = "guided", NULL, }; + +struct quirk_entry { +u32 nominal_freq; +u32 lowest_freq; +}; +#endif /* _LINUX_AMD_PSTATE_H */
Re: [PATCH v2 5/6] cppc_acpi: print error message if CPPC is unsupported
In reply to Perry YuanQuoted 7 lines · Perry Yuan
to be more clear what is wrong with CPPC when pstate driver failed to load which has dependency on the CPPC capabilities.
Add one more debug message to notify user if CPPC is not supported by the CPU, then it will be easy to find out what need to fix for pstate driver loading issue.
Quoted 5 lines
[ 0.477523] amd_pstate: the _CPC object is not present in SBIOS or ACPI disabledAbove message is not clear enough to verify whether CPPC is not supported.
Signed-off-by Perry Yuan <[email protected]>
Quoted 20 lines
--- drivers/acpi/cppc_acpi.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)drivers/acpi/cppc_acpi.c +3
-1@@ -679,8 +679,10 @@ int acpi_cppc_processor_probe(struct acpi_processor *pr)if (!osc_sb_cppc2_support_acked) {pr_debug ("CPPC v2 _OSC not acked\n" ); -if (!cpc_supported_by_cpu ()) +if (!cpc_supported_by_cpu ()) { +pr_debug ("CPPC is not supported by the CPU\n" );return -ENODEV ; + } }/* Parse the ACPI _CPC table for this CPU. */
Yuan, Perry
reviewerRE: [PATCH v2 6/6] cpufreq:amd-pstate: add quirk for the pstate CPPC capabilities missing
In reply to Mario Limonciello[AMD Official Use Only - General]
Hi Mario,
Quoted 66 lines
-----Original Message-----
From: Limonciello, Mario <[email protected]>
Sent: Friday, February 2, 2024 11:17 PM
To: Yuan, Perry <[email protected]>; [email protected]; [email protected]; Huang, Ray <[email protected]>; Shenoy, Gautham Ranjal <[email protected]>; Petkov, Borislav <[email protected]>
Cc: Deucher, Alexander <[email protected]>; Huang, Shimmer <[email protected]>; Du, Xiaojian <[email protected]>; Meng, Li (Jassmine) <[email protected]>; [email protected]; linux- [email protected]
Subject: Re: [PATCH v2 6/6] cpufreq:amd-pstate: add quirk for the pstate CPPC capabilities missingQuoted 11 lines · Perry Yuan
Add quirk table to get CPPC capabilities issue fixed by providing correct perf or frequency values while driver loading.
If CPPC capabilities are not defined in the ACPI tables or wrongly defined by platform firmware, it needs to use quick to get those issues fixed with correct workaround values to make pstate driver can be loaded even though there are CPPC capabilities errors.
Signed-off-by Perry Yuan <[email protected]>--- drivers/cpufreq/amd-pstate.c | 49++++++++++++++++++++++++++++++++++--
Quoted 22 lines
include/linux/amd-pstate.h | 6 +++++ 2 files changed, 53 insertions(+), 2 deletions(-)(quoted diff) +0
-0
b/drivers/cpufreq/amd-pstate.cindex77effc3caf6c..4d426516abb9100644drivers/cpufreq/amd-pstate.c +1
-0@@ -67,6 +67,7 @@ static struct cpufreq_driver amd_pstate_epp_driver;static int cppc_state =AMD_PSTATE_UNDEFINED ;static bool cppc_enabled;static bool amd_pstate_prefcore = true; +static struct quirk_entry *quirks;/* * AMD Energy Preference Performance (EPP) @@ -111,6 +112,33 @@ static unsigned int epp_values[] = {
typedef int (*cppc_mode_transition_fn)(int);drivers/cpufreq/amd-pstate.c +3
-0+static struct quirk_entry quirk_amd_7k62 = { + .nominal_freq =2600 , + .lowest_freq =550 ,drivers/cpufreq/amd-pstate.c static unsigned int epp_values[] = {
Quoted 10 lines
drivers/cpufreq/amd-pstate.c +10
-0+}; + +static int __init dmi_matched (const struct dmi_system_id *dmi) { + quirks = dmi->driver_data; +pr_info ("hardware type %s found\n" , dmi->ident); + +return 1 ; +} + +static const struct dmi_system_id amd_pstate_quirks_table[]__initconst = {
drivers/cpufreq/amd-pstate.c static unsigned int epp_values[] = {
Quoted 6 lines
drivers/cpufreq/amd-pstate.c +6
-0+ { + .callback = dmi_matched, + .ident = "AMD EPYC 7K62", + .matches = { +DMI_MATCH (DMI_PRODUCT_VERSION ,"C1" ), + DMI_MATCH(DMI_PRODUCT_SERIAL,
Quoted 7 lines
"FX19911000028")
I saw your response to v1, but really this is too narrow for upstream. It's literally applying to a SINGLE system.
I feel the rest of the patch is fine, but we shouldn't be adding single system quirks.
How about change to match the BIOS version ?
Actually, the issue should be impacting all the systems which have the same broken BIOS.
Perry.
Quoted 81 lines
drivers/cpufreq/amd-pstate.c static void amd_pstate_adjust_perf(unsigned int
Quoted 12 lines
drivers/cpufreq/amd-pstate.c +7
-0+ }, + .driver_data = &quirk_amd_7k62, + }, + {} +}; +MODULE_DEVICE_TABLE (dmi, amd_pstate_quirks_table); +static inline int get_mode_idx_from_str (const char *str,size_t size) {int i;@@ -600,13 +628,19 @@ static void amd_pstate_adjust_perf(unsigned intcpu,
include/linux/amd-pstate.h static const char * const
Quoted 57 lines
drivers/cpufreq/amd-pstate.c +15
-2static int amd_get_min_freq (struct amd_cpudata *cpudata) {struct cppc_perf_caps cppc_perf; +u32 lowest_freq;int ret =cppc_get_perf_caps (cpudata->cpu, &cppc_perf);if (ret)return ret; +if (quirks && quirks->lowest_freq) + lowest_freq = quirks->lowest_freq; +else + lowest_freq = cppc_perf.lowest_freq; +/* Switch to khz */ -return cppc_perf.lowest_freq *1000 ; +return lowest_freq *1000 ; } static int amd_get_max_freq(struct amd_cpudata *cpudata) @@ -635,12 +669,18 @@ static int amd_get_max_freq(struct amd_cpudata *cpudata) static int amd_get_nominal_freq(struct amd_cpudata *cpudata) {struct cppc_perf_caps cppc_perf; +u32 nominal_freq;int ret =cppc_get_perf_caps (cpudata->cpu, &cppc_perf);if (ret)return ret; -return cppc_perf.nominal_freq; +if (quirks && quirks->nominal_freq) + nominal_freq = quirks->nominal_freq; +else + nominal_freq = cppc_perf.nominal_freq; + +return nominal_freq; } static int amd_get_lowest_nonlinear_freq(struct amd_cpudata*cpudata) @@ -1672,6 +1712,11 @@ static int
__initamd_pstate_init(void)if (cpufreq_get_current_driver()) return -EEXIST;drivers/cpufreq/amd-pstate.c +5
-0+ quirks =NULL ; + +/* check if this machine need CPPC quirks */ +dmi_check_system (amd_pstate_quirks_table); +switch (cppc_state) {case AMD_PSTATE_UNDEFINED :/* Disable on the following configs by default: include/linux/amd-pstate.h +0
-0@@ -124,4 +124,10 @@ static const char * constamd_pstate_mode_string[] = {
Quoted 10 lines
include/linux/amd-pstate.h +6
-0[AMD_PSTATE_GUIDED] = "guided", NULL, }; + +struct quirk_entry { +u32 nominal_freq; +u32 lowest_freq; +}; +#endif /* _LINUX_AMD_PSTATE_H */
Mario Limonciello
maintainerRe: [PATCH v2 6/6] cpufreq:amd-pstate: add quirk for the pstate CPPC capabilities missing
Quoted 72 lines · Perry
[AMD Official Use Only - General]
Hi Mario,
Quoted 68 lines
-----Original Message-----
From: Limonciello, Mario <[email protected]>
Sent: Friday, February 2, 2024 11:17 PM
To: Yuan, Perry <[email protected]>; [email protected]; [email protected]; Huang, Ray <[email protected]>; Shenoy, Gautham Ranjal <[email protected]>; Petkov, Borislav <[email protected]>
Cc: Deucher, Alexander <[email protected]>; Huang, Shimmer <[email protected]>; Du, Xiaojian <[email protected]>; Meng, Li (Jassmine) <[email protected]>; [email protected]; linux- [email protected]
Subject: Re: [PATCH v2 6/6] cpufreq:amd-pstate: add quirk for the pstate CPPC capabilities missingQuoted 11 lines · Perry Yuan
Add quirk table to get CPPC capabilities issue fixed by providing correct perf or frequency values while driver loading.
If CPPC capabilities are not defined in the ACPI tables or wrongly defined by platform firmware, it needs to use quick to get those issues fixed with correct workaround values to make pstate driver can be loaded even though there are CPPC capabilities errors.
Signed-off-by Perry Yuan <[email protected]>--- drivers/cpufreq/amd-pstate.c | 49++++++++++++++++++++++++++++++++++--
Quoted 22 lines
include/linux/amd-pstate.h | 6 +++++ 2 files changed, 53 insertions(+), 2 deletions(-)(quoted diff) +0
-0
b/drivers/cpufreq/amd-pstate.cindex77effc3caf6c..4d426516abb9100644drivers/cpufreq/amd-pstate.c +1
-0@@ -67,6 +67,7 @@ static struct cpufreq_driver amd_pstate_epp_driver;static int cppc_state =AMD_PSTATE_UNDEFINED ;static bool cppc_enabled;static bool amd_pstate_prefcore = true; +static struct quirk_entry *quirks;/* * AMD Energy Preference Performance (EPP) @@ -111,6 +112,33 @@ static unsigned int epp_values[] = {
typedef int (*cppc_mode_transition_fn)(int);drivers/cpufreq/amd-pstate.c +3
-0+static struct quirk_entry quirk_amd_7k62 = { + .nominal_freq =2600 , + .lowest_freq =550 ,drivers/cpufreq/amd-pstate.c static unsigned int epp_values[] = {
Quoted 10 lines
drivers/cpufreq/amd-pstate.c +10
-0+}; + +static int __init dmi_matched (const struct dmi_system_id *dmi) { + quirks = dmi->driver_data; +pr_info ("hardware type %s found\n" , dmi->ident); + +return 1 ; +} + +static const struct dmi_system_id amd_pstate_quirks_table[]__initconst = {
drivers/cpufreq/amd-pstate.c static unsigned int epp_values[] = {
Quoted 6 lines
drivers/cpufreq/amd-pstate.c +6
-0+ { + .callback = dmi_matched, + .ident = "AMD EPYC 7K62", + .matches = { +DMI_MATCH (DMI_PRODUCT_VERSION ,"C1" ), + DMI_MATCH(DMI_PRODUCT_SERIAL,"FX19911000028")
Quoted 9 lines
Quoted 5 lines
I saw your response to v1, but really this is too narrow for upstream. It's literally applying to a SINGLE system.
I feel the rest of the patch is fine, but we shouldn't be adding single system quirks.
How about change to match the BIOS version ?
Actually, the issue should be impacting all the systems which have the same broken BIOS.
Yeah it does sound like a BIOS defect; so this is a reasonable alternative. Just make sure that you only apply it to the necessary systems with this change.
Quoted 85 lines
Perry.
Quoted 81 lines
drivers/cpufreq/amd-pstate.c static void amd_pstate_adjust_perf(unsigned int
Quoted 12 lines
drivers/cpufreq/amd-pstate.c +7
-0+ }, + .driver_data = &quirk_amd_7k62, + }, + {} +}; +MODULE_DEVICE_TABLE (dmi, amd_pstate_quirks_table); +static inline int get_mode_idx_from_str (const char *str,size_t size) {int i;@@ -600,13 +628,19 @@ static void amd_pstate_adjust_perf(unsigned intcpu,
include/linux/amd-pstate.h static const char * const
Quoted 57 lines
drivers/cpufreq/amd-pstate.c +15
-2static int amd_get_min_freq (struct amd_cpudata *cpudata) {struct cppc_perf_caps cppc_perf; +u32 lowest_freq;int ret =cppc_get_perf_caps (cpudata->cpu, &cppc_perf);if (ret)return ret; +if (quirks && quirks->lowest_freq) + lowest_freq = quirks->lowest_freq; +else + lowest_freq = cppc_perf.lowest_freq; +/* Switch to khz */ -return cppc_perf.lowest_freq *1000 ; +return lowest_freq *1000 ; } static int amd_get_max_freq(struct amd_cpudata *cpudata) @@ -635,12 +669,18 @@ static int amd_get_max_freq(struct amd_cpudata *cpudata) static int amd_get_nominal_freq(struct amd_cpudata *cpudata) {struct cppc_perf_caps cppc_perf; +u32 nominal_freq;int ret =cppc_get_perf_caps (cpudata->cpu, &cppc_perf);if (ret)return ret; -return cppc_perf.nominal_freq; +if (quirks && quirks->nominal_freq) + nominal_freq = quirks->nominal_freq; +else + nominal_freq = cppc_perf.nominal_freq; + +return nominal_freq; } static int amd_get_lowest_nonlinear_freq(struct amd_cpudata*cpudata) @@ -1672,6 +1712,11 @@ static int
__initamd_pstate_init(void)if (cpufreq_get_current_driver()) return -EEXIST;drivers/cpufreq/amd-pstate.c +5
-0+ quirks =NULL ; + +/* check if this machine need CPPC quirks */ +dmi_check_system (amd_pstate_quirks_table); +switch (cppc_state) {case AMD_PSTATE_UNDEFINED :/* Disable on the following configs by default: include/linux/amd-pstate.h +0
-0@@ -124,4 +124,10 @@ static const char * constamd_pstate_mode_string[] = {
Quoted 10 lines
include/linux/amd-pstate.h +6
-0[AMD_PSTATE_GUIDED] = "guided", NULL, }; + +struct quirk_entry { +u32 nominal_freq; +u32 lowest_freq; +}; +#endif /* _LINUX_AMD_PSTATE_H */
Yuan, Perry
reviewerRE: [PATCH v2 6/6] cpufreq:amd-pstate: add quirk for the pstate CPPC capabilities missing
[AMD Official Use Only - General]
Quoted 98 lines
-----Original Message-----
From: Limonciello, Mario <[email protected]>
Sent: Friday, February 2, 2024 11:55 PM
To: Yuan, Perry <[email protected]>; [email protected]; [email protected]; Huang, Ray <[email protected]>; Shenoy, Gautham Ranjal <[email protected]>; Petkov, Borislav <[email protected]>
Cc: Deucher, Alexander <[email protected]>; Huang, Shimmer <[email protected]>; Du, Xiaojian <[email protected]>; Meng, Li (Jassmine) <[email protected]>; [email protected]; linux- [email protected]
Subject: Re: [PATCH v2 6/6] cpufreq:amd-pstate: add quirk for the pstate CPPC capabilities missingQuoted 12 lines · Perry
[AMD Official Use Only - General]
Hi Mario,
Quoted 8 lines
-----Original Message-----
From: Limonciello, Mario <[email protected]>
Sent: Friday, February 2, 2024 11:17 PM
To: Yuan, Perry <[email protected]>; [email protected]; [email protected]; Huang, Ray <[email protected]>; Shenoy, Gautham Ranjal <[email protected]>; Petkov, Borislav <[email protected]>
Cc: Deucher, Alexander <[email protected]>; Huang,Shimmer
Quoted 1 line
Quoted 1 line
<[email protected]>; Du, Xiaojian <[email protected]>;
Meng, Li
Quoted 21 lines
Quoted 21 lines
(Jassmine) <[email protected]>; [email protected]; linux- [email protected]
Subject: Re: [PATCH v2 6/6] cpufreq:amd-pstate: add quirk for the pstate CPPC capabilities missingQuoted 11 lines · Perry Yuan
Add quirk table to get CPPC capabilities issue fixed by providing correct perf or frequency values while driver loading.
If CPPC capabilities are not defined in the ACPI tables or wrongly defined by platform firmware, it needs to use quick to get those issues fixed with correct workaround values to make pstate driver can be loaded even though there are CPPC capabilities errors.
Signed-off-by Perry Yuan <[email protected]>--- drivers/cpufreq/amd-pstate.c | 49++++++++++++++++++++++++++++++++++--
Quoted 3 lines
include/linux/amd-pstate.h | 6 +++++ 2 files changed, 53 insertions(+), 2 deletions(-)Quoted 6 lines
Quoted 6 lines
drivers/cpufreq/amd-pstate.c static struct cpufreq_driver
Quoted 6 lines
(quoted diff) +0
-0
b/drivers/cpufreq/amd-pstate.cindex77effc3caf6c..4d426516abb9100644drivers/cpufreq/amd-pstate.c +0
-0@@ -67,6 +67,7 @@ static struct cpufreq_driver
amd_pstate_epp_driver;Quoted 40 lines
Quoted 39 lines
Quoted 15 lines
drivers/cpufreq/amd-pstate.c +1
-0static int cppc_state =AMD_PSTATE_UNDEFINED ;static bool cppc_enabled;static bool amd_pstate_prefcore = true; +static struct quirk_entry *quirks;/* * AMD Energy Preference Performance (EPP) @@ -111,6 +112,33 @@ static unsigned int epp_values[] = {
typedef int (*cppc_mode_transition_fn)(int);drivers/cpufreq/amd-pstate.c +4
-0+static struct quirk_entry quirk_amd_7k62 = { + .nominal_freq =2600 , + .lowest_freq =550 , +};drivers/cpufreq/amd-pstate.c static unsigned int epp_values[] = {
Quoted 10 lines
drivers/cpufreq/amd-pstate.c +10
-0+ +static int __init dmi_matched (const struct dmi_system_id *dmi) { + quirks = dmi->driver_data; +pr_info ("hardware type %s found\n" , dmi->ident); + +return 1 ; +} + +static const struct dmi_system_id amd_pstate_quirks_table[] +__initconst = {
drivers/cpufreq/amd-pstate.c static unsigned int epp_values[] = {
Quoted 6 lines
drivers/cpufreq/amd-pstate.c +6
-0+ { + .callback = dmi_matched, + .ident = "AMD EPYC 7K62", + .matches = { +DMI_MATCH (DMI_PRODUCT_VERSION ,"C1" ), + DMI_MATCH(DMI_PRODUCT_SERIAL,"FX19911000028")
I saw your response to v1, but really this is too narrow for upstream. It's literally applying to a SINGLE system.
I feel the rest of the patch is fine, but we shouldn't be adding single system quirks.
Quoted 8 lines
Quoted 2 lines
How about change to match the BIOS version ?
Actually, the issue should be impacting all the systems which have thesame broken BIOS.
Quoted 1 line
Yeah it does sound like a BIOS defect; so this is a reasonable alternative. Just make sure that you only apply it to the necessary systems with this change.
Agreed, let me change to match BIOS version in V3. Thanks for the feedback!
Perry.
Quoted 88 lines
Quoted 57 lines
Perry.
Quoted 54 lines
Quoted 12 lines
drivers/cpufreq/amd-pstate.c +7
-0+ }, + .driver_data = &quirk_amd_7k62, + }, + {} +}; +MODULE_DEVICE_TABLE (dmi, amd_pstate_quirks_table); +static inline int get_mode_idx_from_str (const char *str,size_t size) {int i;@@ -600,13 +628,19 @@ static void amd_pstate_adjust_perf(unsignedQuoted 1 line
int
cpu,
Quoted 40 lines
static int amd_get_min_freq(struct amd_cpudata *cpudata) { struct cppc_perf_caps cppc_perf;drivers/cpufreq/amd-pstate.c +15
-3+u32 lowest_freq;int ret =cppc_get_perf_caps (cpudata->cpu, &cppc_perf);if (ret)return ret; +if (quirks && quirks->lowest_freq) + lowest_freq = quirks->lowest_freq; +else + lowest_freq = cppc_perf.lowest_freq; +/* Switch to khz */ -return cppc_perf.lowest_freq *1000 ; +return lowest_freq *1000 ; } static int amd_get_max_freq(struct amd_cpudata *cpudata) @@ -635,12 +669,18 @@ static int amd_get_max_freq(struct amd_cpudata *cpudata) static int amd_get_nominal_freq(struct amd_cpudata *cpudata) {struct cppc_perf_caps cppc_perf; +u32 nominal_freq;int ret =cppc_get_perf_caps (cpudata->cpu, &cppc_perf);if (ret)return ret; -return cppc_perf.nominal_freq; +if (quirks && quirks->nominal_freq) + nominal_freq = quirks->nominal_freq; +else + nominal_freq = cppc_perf.nominal_freq; + +return nominal_freq; }Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
static int amd_get_lowest_nonlinear_freq(struct
amd_cpudata
*cpudata) @@ -1672,6 +1712,11 @@ static int__init
amd_pstate_init(void)Quoted 28 lines
Quoted 27 lines
include/linux/amd-pstate.h static const char * const
Quoted 16 lines
if (cpufreq_get_current_driver()) return -EEXIST;drivers/cpufreq/amd-pstate.c +5
-0+ quirks =NULL ; + +/* check if this machine need CPPC quirks */ +dmi_check_system (amd_pstate_quirks_table); +switch (cppc_state) {case AMD_PSTATE_UNDEFINED :/* Disable on the following configs by default: include/linux/amd-pstate.h +0
-0@@ -124,4 +124,10 @@ static const char * constamd_pstate_mode_string[] = {
Quoted 10 lines
include/linux/amd-pstate.h +6
-0[AMD_PSTATE_GUIDED] = "guided", NULL, }; + +struct quirk_entry { +u32 nominal_freq; +u32 lowest_freq; +}; +#endif /* _LINUX_AMD_PSTATE_H */