Skip to contentSkip to conversation

cpufreq: Allow drivers to advertise boost enabled

PATCH Applied Mario Limonciello 4 participants 7 messages Jun 26, 2024 – Jul 1, 2024 CPU frequency scaling framework

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/2 cpufreq: Allow drivers to advertise boost enabled

The behavior introduced in commit f37a4d6b4a2c ("cpufreq: Fix per-policy boost behavior on SoCs using cpufreq_boost_set_sw()") sets up the boost policy incorrectly when boost has been enabled by the platform firmware initially even if a driver sets the policy up.

This is because policy_has_boost_freq() assumes that there is a frequency table set up by the driver and that the boost frequencies are advertised in that table. This assumption doesn't work for acpi-cpufreq or amd-pstate. Only use this check to enable boost if it's not already enabled instead of also disabling it if alreayd enabled.

Fixes f37a4d6b4a2c ("cpufreq: Fix per-policy boost behavior on SoCs using cpufreq_boost_set_sw()")

---
Cc: Sibi Sankar <[email protected]>
Cc: Dietmar Eggemann <[email protected]>
Cc: Viresh Kumar <[email protected]>
Cc: Dhruva Gole <[email protected]>
Cc: Yipeng Zou <[email protected]>
Cc: Rafael J. Wysocki <[email protected]> v1->v2
* Pick up tags

---
 drivers/cpufreq/cpufreq.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/cpufreq/cpufreq.c +2 -1
index 1fdabb660231..270ea04fb616 100644
@@ -1430,7 +1430,8 @@ static int cpufreq_online(unsigned int cpu)
 		}
 
 		/* Let the per-policy boost flag mirror the cpufreq_driver boost during init */
-		policy->boost_enabled = cpufreq_boost_enabled() && policy_has_boost_freq(policy);
+		if (cpufreq_boost_enabled() && policy_has_boost_freq(policy))
+			policy->boost_enabled = true;
 
 		/*
 		 * The initialization has succeeded and the policy is online.
Signature · 1 line
2.43.0
#1 lore raw

PATCH v2 2/2 cpufreq: acpi: Mark boost policy as enabled when setting boost

When boost is set for CPUs using acpi-cpufreq the policy is not updated which can cause boost to be incorrectly not reported.

---
Cc: Sibi Sankar <[email protected]>
Cc: Dietmar Eggemann <[email protected]>
Cc: Viresh Kumar <[email protected]>
Cc: Dhruva Gole <[email protected]>
Cc: Yipeng Zou <[email protected]>
Cc: Rafael J. Wysocki <[email protected]> v1->v2:
* Move to init as suggested by Viresh

---
 drivers/cpufreq/acpi-cpufreq.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/cpufreq/acpi-cpufreq.c +3 -1
index 2fc82831bddd..fa2664f9f259 100644
@@ -888,8 +888,10 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy)
 	if (perf->states[0].core_frequency * 1000 != freq_table[0].frequency)
 		pr_warn(FW_WARN "P-state 0 is not max freq\n");
 
-	if (acpi_cpufreq_driver.set_boost)
+	if (acpi_cpufreq_driver.set_boost) {
 		set_boost(policy, acpi_cpufreq_driver.boost_enabled);
+		policy->boost_enabled = acpi_cpufreq_driver.boost_enabled;
+	}
 
 	return result;
 
Signature · 1 line
2.43.0
Reviewed-by on v2 2/2
#2 lore raw

Re: [PATCH v2 2/2] cpufreq: acpi: Mark boost policy as enabled when setting boost

Quoted 6 lines · Mario Limonciello

When boost is set for CPUs using acpi-cpufreq the policy is not updated which can cause boost to be incorrectly not reported.

Quoted 9 lines

---
Cc: Sibi Sankar <[email protected]>
Cc: Dietmar Eggemann <[email protected]>
Cc: Viresh Kumar <[email protected]>
Cc: Dhruva Gole <[email protected]>
Cc: Yipeng Zou <[email protected]>
Cc: Rafael J. Wysocki <[email protected]> v1->v2:
* Move to init as suggested by Viresh

Quoted 22 lines
---
 drivers/cpufreq/acpi-cpufreq.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/cpufreq/acpi-cpufreq.c +3 -1
index 2fc82831bddd..fa2664f9f259 100644
@@ -888,8 +888,10 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy)
 	if (perf->states[0].core_frequency * 1000 != freq_table[0].frequency)
 		pr_warn(FW_WARN "P-state 0 is not max freq\n");
 
-	if (acpi_cpufreq_driver.set_boost)
+	if (acpi_cpufreq_driver.set_boost) {
 		set_boost(policy, acpi_cpufreq_driver.boost_enabled);
+		policy->boost_enabled = acpi_cpufreq_driver.boost_enabled;
+	}
 
 	return result;
 
Signature · 1 line
2.43.0
maintainer Acked-by on v2 2/2
#3 lore raw

Re: [PATCH v2 2/2] cpufreq: acpi: Mark boost policy as enabled when setting boost

In reply to Mario Limonciello
Quoted 6 lines · Mario Limonciello

When boost is set for CPUs using acpi-cpufreq the policy is not updated which can cause boost to be incorrectly not reported.

Quoted 7 lines

---
Cc: Sibi Sankar <[email protected]>
Cc: Dietmar Eggemann <[email protected]>
Cc: Viresh Kumar <[email protected]>
Cc: Dhruva Gole <[email protected]>
Cc: Yipeng Zou <[email protected]>
Cc: Rafael J. Wysocki <[email protected]>

The below version log needs to go ...

Quoted 3 lines

v1->v2:
* Move to init as suggested by Viresh
---

... here.

Quoted 8 lines
 drivers/cpufreq/acpi-cpufreq.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/cpufreq/acpi-cpufreq.c +0 -0
index 2fc82831bddd..fa2664f9f259 100644

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

Quoted 10 lines
drivers/cpufreq/acpi-cpufreq.c +3 -1
@@ -888,8 +888,10 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy)
 	if (perf->states[0].core_frequency * 1000 != freq_table[0].frequency)
 		pr_warn(FW_WARN "P-state 0 is not max freq\n");
 
-	if (acpi_cpufreq_driver.set_boost)
+	if (acpi_cpufreq_driver.set_boost) {
 		set_boost(policy, acpi_cpufreq_driver.boost_enabled);
+		policy->boost_enabled = acpi_cpufreq_driver.boost_enabled;
+	}
 
 	return result;
Signature · 1 line
viresh
#4 lore raw
In reply to Mario Limonciello
Quoted 12 lines · Mario Limonciello

The behavior introduced in commit f37a4d6b4a2c ("cpufreq: Fix per-policy boost behavior on SoCs using cpufreq_boost_set_sw()") sets up the boost policy incorrectly when boost has been enabled by the platform firmware initially even if a driver sets the policy up.

This is because policy_has_boost_freq() assumes that there is a frequency table set up by the driver and that the boost frequencies are advertised in that table. This assumption doesn't work for acpi-cpufreq or amd-pstate. Only use this check to enable boost if it's not already enabled instead of also disabling it if alreayd enabled.

Quoted 5 lines
Fixes f37a4d6b4a2c ("cpufreq: Fix per-policy boost behavior on SoCs using cpufreq_boost_set_sw()")
CC stable I suppose?
Quoted 31 lines

---
Cc: Sibi Sankar <[email protected]>
Cc: Dietmar Eggemann <[email protected]>
Cc: Viresh Kumar <[email protected]>
Cc: Dhruva Gole <[email protected]>
Cc: Yipeng Zou <[email protected]>
Cc: Rafael J. Wysocki <[email protected]> v1->v2
* Pick up tags

---
 drivers/cpufreq/cpufreq.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/cpufreq/cpufreq.c +2 -2
index 1fdabb660231..270ea04fb616 100644
@@ -1430,7 +1430,8 @@ static int cpufreq_online(unsigned int cpu)
                }
 
                /* Let the per-policy boost flag mirror the cpufreq_driver boost during init */
-               policy->boost_enabled = cpufreq_boost_enabled() && policy_has_boost_freq(policy);
+               if (cpufreq_boost_enabled() && policy_has_boost_freq(policy))
+                       policy->boost_enabled = true;
 
                /*
                 * The initialization has succeeded and the policy is online.
--
#5 lore raw
Quoted 14 lines · Rafael J. Wysocki
Quoted 12 lines · Mario Limonciello

The behavior introduced in commit f37a4d6b4a2c ("cpufreq: Fix per-policy boost behavior on SoCs using cpufreq_boost_set_sw()") sets up the boost policy incorrectly when boost has been enabled by the platform firmware initially even if a driver sets the policy up.

This is because policy_has_boost_freq() assumes that there is a frequency table set up by the driver and that the boost frequencies are advertised in that table. This assumption doesn't work for acpi-cpufreq or amd-pstate. Only use this check to enable boost if it's not already enabled instead of also disabling it if alreayd enabled.

Quoted 7 lines
Quoted 5 lines
Fixes f37a4d6b4a2c ("cpufreq: Fix per-policy boost behavior on SoCs using cpufreq_boost_set_sw()")
CC stable I suppose?

Yes, I didn't realize f37a4d6b4a2c came in 6.9, I had assumed it was 6.10. But since it's 6.9, yes if you can please add stable tag when committing.

Quoted 32 lines
Quoted 32 lines

---
Cc: Sibi Sankar <[email protected]>
Cc: Dietmar Eggemann <[email protected]>
Cc: Viresh Kumar <[email protected]>
Cc: Dhruva Gole <[email protected]>
Cc: Yipeng Zou <[email protected]>
Cc: Rafael J. Wysocki <[email protected]> v1->v2
* Pick up tags

---
  drivers/cpufreq/cpufreq.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)
drivers/cpufreq/cpufreq.c +2 -2
index 1fdabb660231..270ea04fb616 100644
@@ -1430,7 +1430,8 @@ static int cpufreq_online(unsigned int cpu)
                 }
 
                 /* Let the per-policy boost flag mirror the cpufreq_driver boost during init */
-               policy->boost_enabled = cpufreq_boost_enabled() && policy_has_boost_freq(policy);
+               if (cpufreq_boost_enabled() && policy_has_boost_freq(policy))
+                       policy->boost_enabled = true;
 
                 /*
                  * The initialization has succeeded and the policy is online.
--
maintainer Applied
#6 lore raw
Quoted 22 lines · Mario Limonciello
Quoted 20 lines · Rafael J. Wysocki
Quoted 17 lines · Mario Limonciello

The behavior introduced in commit f37a4d6b4a2c ("cpufreq: Fix per-policy boost behavior on SoCs using cpufreq_boost_set_sw()") sets up the boost policy incorrectly when boost has been enabled by the platform firmware initially even if a driver sets the policy up.

This is because policy_has_boost_freq() assumes that there is a frequency table set up by the driver and that the boost frequencies are advertised in that table. This assumption doesn't work for acpi-cpufreq or amd-pstate. Only use this check to enable boost if it's not already enabled instead of also disabling it if alreayd enabled.

Fixes f37a4d6b4a2c ("cpufreq: Fix per-policy boost behavior on SoCs using cpufreq_boost_set_sw()")
Quoted 5 lines
Quoted 1 line
CC stable I suppose?

Yes, I didn't realize f37a4d6b4a2c came in 6.9, I had assumed it was 6.10. But since it's 6.9, yes if you can please add stable tag when committing.

Applied as 6.10-rc material along with the [2/2].

I've added a Fixes: tag to the second patch and "Cc: stable" tags to both patches.

Thanks!

Quoted 33 lines
Quoted 32 lines
Quoted 32 lines

---
Cc: Sibi Sankar <[email protected]>
Cc: Dietmar Eggemann <[email protected]>
Cc: Viresh Kumar <[email protected]>
Cc: Dhruva Gole <[email protected]>
Cc: Yipeng Zou <[email protected]>
Cc: Rafael J. Wysocki <[email protected]> v1->v2
* Pick up tags

---
  drivers/cpufreq/cpufreq.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)
drivers/cpufreq/cpufreq.c +2 -2
index 1fdabb660231..270ea04fb616 100644
@@ -1430,7 +1430,8 @@ static int cpufreq_online(unsigned int cpu)
                 }
 
                 /* Let the per-policy boost flag mirror the cpufreq_driver boost during init */
-               policy->boost_enabled = cpufreq_boost_enabled() && policy_has_boost_freq(policy);
+               if (cpufreq_boost_enabled() && policy_has_boost_freq(policy))
+                       policy->boost_enabled = true;
 
                 /*
                  * The initialization has succeeded and the policy is online.
--