Skip to contentSkip to conversation

acpi-cpufreq: Honor _PSD table setting in CPU frequency control

PATCH Superseded Wei Huang 2 participants 3 messages Oct 7, 2020 – Oct 16, 2020 CPU frequency scaling framework

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Wei Huang

author
#0 lore raw

PATCH 1/1 acpi-cpufreq: Honor _PSD table setting in CPU frequency control

acpi-cpufreq has a old quirk that overrides the _PSD table supplied by BIOS on AMD CPUs. However the _PSD table of new AMD CPUs (Family 19h+) now accurately reports the P-state dependency of CPU cores. Hence this quirk needs to be fixed in order to support new CPUs' frequency control.

Fixes acd316248205 ("acpi-cpufreq: Add quirk to disable _PSD usage on all AMD CPUs")
---
 drivers/cpufreq/acpi-cpufreq.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/cpufreq/acpi-cpufreq.c +2 -1
index e4ff681faaaa..1e6e2abde428 100644
@@ -691,7 +691,8 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy)
 		cpumask_copy(policy->cpus, topology_core_cpumask(cpu));
 	}
 
-	if (check_amd_hwpstate_cpu(cpu) && !acpi_pstate_strict) {
+	if (check_amd_hwpstate_cpu(cpu) && (c->x86 < 0x19) &&
+	    !acpi_pstate_strict) {
 		cpumask_clear(policy->cpus);
 		cpumask_set_cpu(cpu, policy->cpus);
 		cpumask_copy(data->freqdomain_cpus,
Signature · 1 line
2.26.2
#1 lore raw
Quoted 17 lines · Wei Huang

acpi-cpufreq has a old quirk that overrides the _PSD table supplied by BIOS on AMD CPUs. However the _PSD table of new AMD CPUs (Family 19h+) now accurately reports the P-state dependency of CPU cores. Hence this quirk needs to be fixed in order to support new CPUs' frequency control.

Fixes acd316248205 ("acpi-cpufreq: Add quirk to disable _PSD usage on all AMD CPUs")
---
 drivers/cpufreq/acpi-cpufreq.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/cpufreq/acpi-cpufreq.c +0 -0
index e4ff681faaaa..1e6e2abde428 100644

drivers/cpufreq/acpi-cpufreq.c static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy) · line 694

Quoted 5 lines
drivers/cpufreq/acpi-cpufreq.c +1 -1
@@ -691,7 +691,8 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy)
                cpumask_copy(policy->cpus, topology_core_cpumask(cpu));
        }
 
-       if (check_amd_hwpstate_cpu(cpu) && !acpi_pstate_strict) {
+       if (check_amd_hwpstate_cpu(cpu) && (c->x86 < 0x19) &&

Why don't you use boot_cpu_data instead of *c?

And why don't you do the extra check in check_amd_hwpstate_cpu()?

Also the parens around it are not necessary here and is there any chance for having a proper symbol instead of the raw 0x19 in that check?

Quoted 7 lines
drivers/cpufreq/acpi-cpufreq.c +1 -1
+           !acpi_pstate_strict) {
                cpumask_clear(policy->cpus);
                cpumask_set_cpu(cpu, policy->cpus);
                cpumask_copy(data->freqdomain_cpus,
--

2.26.2

author
#2 lore raw
Quoted 21 lines · Rafael J. Wysocki
Quoted 20 lines · Wei Huang

acpi-cpufreq has a old quirk that overrides the _PSD table supplied by BIOS on AMD CPUs. However the _PSD table of new AMD CPUs (Family 19h+) now accurately reports the P-state dependency of CPU cores. Hence this quirk needs to be fixed in order to support new CPUs' frequency control.

Fixes acd316248205 ("acpi-cpufreq: Add quirk to disable _PSD usage on all AMD CPUs")
---
 drivers/cpufreq/acpi-cpufreq.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/cpufreq/acpi-cpufreq.c +0 -0
index e4ff681faaaa..1e6e2abde428 100644
@@ -691,7 +691,8 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy)
                cpumask_copy(policy->cpus, topology_core_cpumask(cpu));
        }
 
Quoted 4 lines

drivers/cpufreq/acpi-cpufreq.c static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy) · line 694

Quoted 2 lines
drivers/cpufreq/acpi-cpufreq.c +1 -1
-       if (check_amd_hwpstate_cpu(cpu) && !acpi_pstate_strict) {
+       if (check_amd_hwpstate_cpu(cpu) && (c->x86 < 0x19) &&

Why don't you use boot_cpu_data instead of *c?

Thanks for your review. c->x86 contains the same level of information as boot_cpu_data when acpi_cpufreq_cpu_init() starts to execute. But you are right, it is better to use boot_cpu_data, consistent with the rest code in the same function.

Quoted 2 lines

And why don't you do the extra check in check_amd_hwpstate_cpu()?

check_amd_hwpstate_cpu() is called at various locations. This _PSD fix doesn't apply at other callers.

Quoted 2 lines

Also the parens around it are not necessary here and is there any

I will remove it in the next rev.

Quoted 2 lines

chance for having a proper symbol instead of the raw 0x19 in that check?

Unfortunately I didn't find a replacement. Only x86_vendor has an acronym. The rest (fam/model/stepping) use numerical values, including in arch/x86 boot code.

Quoted 8 lines
Quoted 8 lines
drivers/cpufreq/acpi-cpufreq.c +1 -1
+           !acpi_pstate_strict) {
                cpumask_clear(policy->cpus);
                cpumask_set_cpu(cpu, policy->cpus);
                cpumask_copy(data->freqdomain_cpus,
--

2.26.2