cpufreq: CPPC: Set CPPC Enable register in cpu_init
Subsystems (4)
Sumit Gupta
reviewerPATCH v2 1/1 cpufreq: CPPC: Set CPPC Enable register in cpu_init
As per ACPI 6.x s8.4.6.1.4 (CPPC Enable Register):
"If supported by the platform, OSPM writes a one to this register
to enable CPPC on this processor. If not implemented, OSPM assumes the platform always has CPPC enabled."
The driver never writes this register. CPPC therefore stays disabled on platforms such as NVIDIA GB10 that wait for OSPM to enable it.
Call cppc_set_enable() in cppc_cpufreq_cpu_init(). Fail init if enabling CPPC fails. If init fails after CPPC is enabled, disable it again. The register is optional, so -EOPNOTSUPP is not an error.
This relies on commit ab482f1bac6b ("ACPI: CPPC: Refactor register value get and set ABIs") from v6.16. Before it, cppc_set_enable() returned -EFAULT instead of -EOPNOTSUPP when the Enable register is not implemented. On an older kernel this change would make init fail on every platform without the register, so the stable range starts at v6.16.
---
v1 -> v2:
- Fail init if enabling CPPC fails and disable CPPC again if init fails after enabling it (Christian).
- Move enable after the policy->shared_type check, so cppc_set_perf() is the only failure after it.
- Mention NVIDIA GB10 in the commit message (Christian).
v1: https://lore.kernel.org/lkml/[email protected]/
drivers/cpufreq/cppc_cpufreq.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-)
drivers/cpufreq/cppc_cpufreq.c +13 -1
@@ -714,7 +714,17 @@ static int cppc_cpufreq_cpu_init(struct cpufreq_policy *policy)pr_debug ("Unsupported CPU co-ord type: %d\n" , policy->shared_type); ret = -EFAULT ; - goto out; + goto out_put; + } + +/* +* Enable CPPC. The Enable register is optional - some platforms +* may not support it. +*/ + ret =cppc_set_enable (cpu, true); +if (ret && ret != -EOPNOTSUPP ) { +pr_err ("Failed to enable CPPC for CPU%u (%d)\n" , cpu, ret); + goto out_put; } policy->fast_switch_possible =cppc_allow_fast_switch (policy->cpus);
@@ -742,6 +752,8 @@ static int cppc_cpufreq_cpu_init(struct cpufreq_policy *policy)return 0 ; out: +cppc_set_enable (cpu, false); +out_put:cppc_cpufreq_put_cpu_data (policy);return ret; }
Signature · 1 line
2.34.1
Quoted 19 lines · Sumit Gupta
As per ACPI 6.x s8.4.6.1.4 (CPPC Enable Register):
"If supported by the platform, OSPM writes a one to this register
to enable CPPC on this processor. If not implemented, OSPM assumes the platform always has CPPC enabled."The driver never writes this register. CPPC therefore stays disabled on platforms such as NVIDIA GB10 that wait for OSPM to enable it.
Call
cppc_set_enable()incppc_cpufreq_cpu_init(). Fail init if enabling CPPC fails. If init fails after CPPC is enabled, disable it again. The register is optional, so-EOPNOTSUPPis not an error.This relies on commit
ab482f1bac6b("ACPI: CPPC: Refactor register value get and set ABIs") from v6.16. Before it,cppc_set_enable()returned-EFAULTinstead of-EOPNOTSUPPwhen the Enable register is not implemented. On an older kernel this change would make init fail on every platform without the register, so the stable range starts at v6.16.
Quoted 3 lines
Fixes 5477fb3bd1e8 ("ACPI / CPPC: Add a CPUFreq driver for use with CPPC")Cc [email protected] # v6.16+Signed-off-by Sumit Gupta <[email protected]>
Quoted 45 lines
---
v1 -> v2:
- Fail init if enabling CPPC fails and disable CPPC again if init fails after enabling it (Christian).
- Move enable after thepolicy->shared_typecheck, socppc_set_perf()is the only failure after it.
- Mention NVIDIA GB10 in the commit message (Christian).v1: https://lore.kernel.org/lkml/[email protected]/
drivers/cpufreq/cppc_cpufreq.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-)drivers/cpufreq/cppc_cpufreq.c +13
-1@@ -714,7 +714,17 @@ static int cppc_cpufreq_cpu_init(struct cpufreq_policy *policy)pr_debug ("Unsupported CPU co-ord type: %d\n" , policy->shared_type); ret = -EFAULT ; - goto out; + goto out_put; + } + +/* +* Enable CPPC. The Enable register is optional - some platforms +* may not support it. +*/ + ret =cppc_set_enable (cpu, true); +if (ret && ret != -EOPNOTSUPP ) { +pr_err ("Failed to enable CPPC for CPU%u (%d)\n" , cpu, ret); + goto out_put; } policy->fast_switch_possible =cppc_allow_fast_switch (policy->cpus);@@ -742,6 +752,8 @@ static int cppc_cpufreq_cpu_init(struct cpufreq_policy *policy)return 0 ; out: +cppc_set_enable (cpu, false); +out_put:cppc_cpufreq_put_cpu_data (policy);return ret; }
Quoted 21 lines · Christian Loehle
Quoted 19 lines · Sumit Gupta
As per ACPI 6.x s8.4.6.1.4 (CPPC Enable Register):
"If supported by the platform, OSPM writes a one to this register
to enable CPPC on this processor. If not implemented, OSPM assumes the platform always has CPPC enabled."The driver never writes this register. CPPC therefore stays disabled on platforms such as NVIDIA GB10 that wait for OSPM to enable it.
Call
cppc_set_enable()incppc_cpufreq_cpu_init(). Fail init if enabling CPPC fails. If init fails after CPPC is enabled, disable it again. The register is optional, so-EOPNOTSUPPis not an error.This relies on commit
ab482f1bac6b("ACPI: CPPC: Refactor register value get and set ABIs") from v6.16. Before it,cppc_set_enable()returned-EFAULTinstead of-EOPNOTSUPPwhen the Enable register is not implemented. On an older kernel this change would make init fail on every platform without the register, so the stable range starts at v6.16.
Quoted 5 lines
Quoted 3 lines
Fixes 5477fb3bd1e8 ("ACPI / CPPC: Add a CPUFreq driver for use with CPPC")Cc [email protected] # v6.16+Signed-off-by Sumit Gupta <[email protected]>Reviewed-by Christian Loehle <[email protected]>
Applied as 7.4-rc material, thanks!
Quoted 46 lines
Quoted 45 lines
---
v1 -> v2:
- Fail init if enabling CPPC fails and disable CPPC again if init fails after enabling it (Christian).
- Move enable after thepolicy->shared_typecheck, socppc_set_perf()is the only failure after it.
- Mention NVIDIA GB10 in the commit message (Christian).v1: https://lore.kernel.org/lkml/[email protected]/
drivers/cpufreq/cppc_cpufreq.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-)drivers/cpufreq/cppc_cpufreq.c +13
-1@@ -714,7 +714,17 @@ static int cppc_cpufreq_cpu_init(struct cpufreq_policy *policy)pr_debug ("Unsupported CPU co-ord type: %d\n" , policy->shared_type); ret = -EFAULT ; - goto out; + goto out_put; + } + +/* +* Enable CPPC. The Enable register is optional - some platforms +* may not support it. +*/ + ret =cppc_set_enable (cpu, true); +if (ret && ret != -EOPNOTSUPP ) { +pr_err ("Failed to enable CPPC for CPU%u (%d)\n" , cpu, ret); + goto out_put; } policy->fast_switch_possible =cppc_allow_fast_switch (policy->cpus);@@ -742,6 +752,8 @@ static int cppc_cpufreq_cpu_init(struct cpufreq_policy *policy)return 0 ; out: +cppc_set_enable (cpu, false); +out_put:cppc_cpufreq_put_cpu_data (policy);return ret; }