* [PATCH 01/15] cpufreq: staticize cpufreq_boost_trigger_state()
2025-01-24 8:58 [PATCH 00/15] cpufreq: simplify boost handling Viresh Kumar
@ 2025-01-24 8:58 ` Viresh Kumar
2025-01-24 8:58 ` [PATCH 02/15] cpufreq: Export cpufreq_boost_set_sw() Viresh Kumar
` (14 subsequent siblings)
15 siblings, 0 replies; 23+ messages in thread
From: Viresh Kumar @ 2025-01-24 8:58 UTC (permalink / raw)
To: Rafael J. Wysocki, Viresh Kumar
Cc: linux-pm, Vincent Guittot, Lifeng Zheng, linux-kernel
cpufreq_boost_trigger_state() is only used by cpufreq core, mark it
static.
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
---
drivers/cpufreq/cpufreq.c | 3 ++-
include/linux/cpufreq.h | 5 -----
2 files changed, 2 insertions(+), 6 deletions(-)
diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
index faca6a143263..0782a6d89df2 100644
--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -87,6 +87,7 @@ static int cpufreq_set_policy(struct cpufreq_policy *policy,
struct cpufreq_governor *new_gov,
unsigned int new_pol);
static bool cpufreq_boost_supported(void);
+static int cpufreq_boost_trigger_state(int state);
/*
* Two notifier lists: the "policy" list is involved in the
@@ -2805,7 +2806,7 @@ static int cpufreq_boost_set_sw(struct cpufreq_policy *policy, int state)
return 0;
}
-int cpufreq_boost_trigger_state(int state)
+static int cpufreq_boost_trigger_state(int state)
{
struct cpufreq_policy *policy;
unsigned long flags;
diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h
index d237ef91d1f1..0e708830d30d 100644
--- a/include/linux/cpufreq.h
+++ b/include/linux/cpufreq.h
@@ -778,7 +778,6 @@ int cpufreq_frequency_table_get_index(struct cpufreq_policy *policy,
ssize_t cpufreq_show_cpus(const struct cpumask *mask, char *buf);
#ifdef CONFIG_CPU_FREQ
-int cpufreq_boost_trigger_state(int state);
bool cpufreq_boost_enabled(void);
int cpufreq_enable_boost_support(void);
bool policy_has_boost_freq(struct cpufreq_policy *policy);
@@ -1150,10 +1149,6 @@ static inline int of_perf_domain_get_sharing_cpumask(int pcpu, const char *list_
return 0;
}
#else
-static inline int cpufreq_boost_trigger_state(int state)
-{
- return 0;
-}
static inline bool cpufreq_boost_enabled(void)
{
return false;
--
2.31.1.272.g89b43f80a514
^ permalink raw reply related [flat|nested] 23+ messages in thread* [PATCH 02/15] cpufreq: Export cpufreq_boost_set_sw()
2025-01-24 8:58 [PATCH 00/15] cpufreq: simplify boost handling Viresh Kumar
2025-01-24 8:58 ` [PATCH 01/15] cpufreq: staticize cpufreq_boost_trigger_state() Viresh Kumar
@ 2025-01-24 8:58 ` Viresh Kumar
2025-01-24 8:58 ` [PATCH 03/15] cpufreq: Introduce policy->boost_supported flag Viresh Kumar
` (13 subsequent siblings)
15 siblings, 0 replies; 23+ messages in thread
From: Viresh Kumar @ 2025-01-24 8:58 UTC (permalink / raw)
To: Rafael J. Wysocki, Viresh Kumar
Cc: linux-pm, Vincent Guittot, Lifeng Zheng, linux-kernel
This will be used directly by cpufreq driver going forward, export it.
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
---
drivers/cpufreq/cpufreq.c | 3 ++-
include/linux/cpufreq.h | 6 ++++++
2 files changed, 8 insertions(+), 1 deletion(-)
diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
index 0782a6d89df2..8b0754b506fa 100644
--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -2786,7 +2786,7 @@ EXPORT_SYMBOL_GPL(cpufreq_update_limits);
/*********************************************************************
* BOOST *
*********************************************************************/
-static int cpufreq_boost_set_sw(struct cpufreq_policy *policy, int state)
+int cpufreq_boost_set_sw(struct cpufreq_policy *policy, int state)
{
int ret;
@@ -2805,6 +2805,7 @@ static int cpufreq_boost_set_sw(struct cpufreq_policy *policy, int state)
return 0;
}
+EXPORT_SYMBOL_GPL(cpufreq_boost_set_sw);
static int cpufreq_boost_trigger_state(int state)
{
diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h
index 0e708830d30d..c7d1fe5ebf7a 100644
--- a/include/linux/cpufreq.h
+++ b/include/linux/cpufreq.h
@@ -781,6 +781,7 @@ ssize_t cpufreq_show_cpus(const struct cpumask *mask, char *buf);
bool cpufreq_boost_enabled(void);
int cpufreq_enable_boost_support(void);
bool policy_has_boost_freq(struct cpufreq_policy *policy);
+int cpufreq_boost_set_sw(struct cpufreq_policy *policy, int state);
/* Find lowest freq at or above target in a table in ascending order */
static inline int cpufreq_table_find_index_al(struct cpufreq_policy *policy,
@@ -1164,6 +1165,11 @@ static inline bool policy_has_boost_freq(struct cpufreq_policy *policy)
return false;
}
+static inline int cpufreq_boost_set_sw(struct cpufreq_policy *policy, int state)
+{
+ return -EOPNOTSUPP;
+}
+
static inline int
cpufreq_table_set_inefficient(struct cpufreq_policy *policy,
unsigned int frequency)
--
2.31.1.272.g89b43f80a514
^ permalink raw reply related [flat|nested] 23+ messages in thread* [PATCH 03/15] cpufreq: Introduce policy->boost_supported flag
2025-01-24 8:58 [PATCH 00/15] cpufreq: simplify boost handling Viresh Kumar
2025-01-24 8:58 ` [PATCH 01/15] cpufreq: staticize cpufreq_boost_trigger_state() Viresh Kumar
2025-01-24 8:58 ` [PATCH 02/15] cpufreq: Export cpufreq_boost_set_sw() Viresh Kumar
@ 2025-01-24 8:58 ` Viresh Kumar
2025-01-24 8:58 ` [PATCH 04/15] cpufreq: acpi: Set policy->boost_supported Viresh Kumar
` (12 subsequent siblings)
15 siblings, 0 replies; 23+ messages in thread
From: Viresh Kumar @ 2025-01-24 8:58 UTC (permalink / raw)
To: Rafael J. Wysocki, Viresh Kumar
Cc: linux-pm, Vincent Guittot, Lifeng Zheng, linux-kernel
It is possible to have a scenario where not all cpufreq policies support
boost frequencies. And letting sysfs (or other parts of the kernel)
enable boost feature for that policy isn't correct.
Add a new flag, boost_supported, which will be set to true by the
cpufreq core only if the freq table contains valid boost frequencies.
Some cpufreq drivers though don't have boost frequencies in the
freq-table, they can set this flag from their ->init() callbacks.
Once all the drivers are updated to set the flag correctly, we can check
it before enabling boost feature for a policy.
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
---
drivers/cpufreq/freq_table.c | 4 ++++
include/linux/cpufreq.h | 3 +++
2 files changed, 7 insertions(+)
diff --git a/drivers/cpufreq/freq_table.c b/drivers/cpufreq/freq_table.c
index 16e56f2fcee4..185070052b41 100644
--- a/drivers/cpufreq/freq_table.c
+++ b/drivers/cpufreq/freq_table.c
@@ -359,6 +359,10 @@ int cpufreq_table_validate_and_sort(struct cpufreq_policy *policy)
if (ret)
return ret;
+ /* Driver's may have set this field already */
+ if (policy_has_boost_freq(policy))
+ policy->boost_supported = true;
+
return set_freq_table_sorted(policy);
}
diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h
index c7d1fe5ebf7a..b017af4398b9 100644
--- a/include/linux/cpufreq.h
+++ b/include/linux/cpufreq.h
@@ -144,6 +144,9 @@ struct cpufreq_policy {
/* Per policy boost enabled flag. */
bool boost_enabled;
+ /* Per policy boost supported flag. */
+ bool boost_supported;
+
/* Cached frequency lookup from cpufreq_driver_resolve_freq. */
unsigned int cached_target_freq;
unsigned int cached_resolved_idx;
--
2.31.1.272.g89b43f80a514
^ permalink raw reply related [flat|nested] 23+ messages in thread* [PATCH 04/15] cpufreq: acpi: Set policy->boost_supported
2025-01-24 8:58 [PATCH 00/15] cpufreq: simplify boost handling Viresh Kumar
` (2 preceding siblings ...)
2025-01-24 8:58 ` [PATCH 03/15] cpufreq: Introduce policy->boost_supported flag Viresh Kumar
@ 2025-01-24 8:58 ` Viresh Kumar
2025-01-24 8:58 ` [PATCH 05/15] cpufreq: amd: " Viresh Kumar
` (11 subsequent siblings)
15 siblings, 0 replies; 23+ messages in thread
From: Viresh Kumar @ 2025-01-24 8:58 UTC (permalink / raw)
To: Rafael J. Wysocki, Viresh Kumar
Cc: linux-pm, Vincent Guittot, Lifeng Zheng, linux-kernel
With a later commit, the cpufreq core will call the ->set_boost()
callback only if the policy supports boost frequency. The
boost_supported flag is set by the cpufreq core if policy->freq_table is
set and one or more boost frequencies are present.
For other drivers, the flag must be set explicitly.
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
---
drivers/cpufreq/acpi-cpufreq.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/cpufreq/acpi-cpufreq.c b/drivers/cpufreq/acpi-cpufreq.c
index 3b7e63e8cbd4..6f16cc25ab70 100644
--- a/drivers/cpufreq/acpi-cpufreq.c
+++ b/drivers/cpufreq/acpi-cpufreq.c
@@ -891,6 +891,9 @@ 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)
+ policy->boost_supported = true;
+
return result;
err_unreg:
--
2.31.1.272.g89b43f80a514
^ permalink raw reply related [flat|nested] 23+ messages in thread* [PATCH 05/15] cpufreq: amd: Set policy->boost_supported
2025-01-24 8:58 [PATCH 00/15] cpufreq: simplify boost handling Viresh Kumar
` (3 preceding siblings ...)
2025-01-24 8:58 ` [PATCH 04/15] cpufreq: acpi: Set policy->boost_supported Viresh Kumar
@ 2025-01-24 8:58 ` Viresh Kumar
2025-01-30 9:15 ` Dhananjay Ugwekar
2025-01-24 8:58 ` [PATCH 06/15] cpufreq: cppc: " Viresh Kumar
` (10 subsequent siblings)
15 siblings, 1 reply; 23+ messages in thread
From: Viresh Kumar @ 2025-01-24 8:58 UTC (permalink / raw)
To: Rafael J. Wysocki, Huang Rui, Gautham R. Shenoy,
Mario Limonciello, Perry Yuan, Viresh Kumar
Cc: linux-pm, Vincent Guittot, Lifeng Zheng, linux-kernel
With a later commit, the cpufreq core will call the ->set_boost()
callback only if the policy supports boost frequency. The
boost_supported flag is set by the cpufreq core if policy->freq_table is
set and one or more boost frequencies are present.
For other drivers, the flag must be set explicitly.
The policy->boost_enabled flag is set by the cpufreq core once the
policy is initialized, don't set it anymore.
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
---
drivers/cpufreq/amd-pstate.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c
index d7630bab2516..8d3cc494c92c 100644
--- a/drivers/cpufreq/amd-pstate.c
+++ b/drivers/cpufreq/amd-pstate.c
@@ -995,7 +995,7 @@ static int amd_pstate_cpu_init(struct cpufreq_policy *policy)
policy->cpuinfo.min_freq = min_freq;
policy->cpuinfo.max_freq = max_freq;
- policy->boost_enabled = READ_ONCE(cpudata->boost_supported);
+ policy->boost_supported = READ_ONCE(cpudata->boost_supported);
/* It will be updated by governor */
policy->cur = policy->cpuinfo.min_freq;
@@ -1480,7 +1480,7 @@ static int amd_pstate_epp_cpu_init(struct cpufreq_policy *policy)
policy->min = policy->cpuinfo.min_freq;
policy->max = policy->cpuinfo.max_freq;
- policy->boost_enabled = READ_ONCE(cpudata->boost_supported);
+ policy->boost_supported = READ_ONCE(cpudata->boost_supported);
/*
* Set the policy to provide a valid fallback value in case
--
2.31.1.272.g89b43f80a514
^ permalink raw reply related [flat|nested] 23+ messages in thread* Re: [PATCH 05/15] cpufreq: amd: Set policy->boost_supported
2025-01-24 8:58 ` [PATCH 05/15] cpufreq: amd: " Viresh Kumar
@ 2025-01-30 9:15 ` Dhananjay Ugwekar
0 siblings, 0 replies; 23+ messages in thread
From: Dhananjay Ugwekar @ 2025-01-30 9:15 UTC (permalink / raw)
To: Viresh Kumar, Rafael J. Wysocki, Huang Rui, Gautham R. Shenoy,
Mario Limonciello, Perry Yuan
Cc: linux-pm, Vincent Guittot, Lifeng Zheng, linux-kernel
Hello Viresh,
On 1/24/2025 2:28 PM, Viresh Kumar wrote:
> With a later commit, the cpufreq core will call the ->set_boost()
> callback only if the policy supports boost frequency. The
> boost_supported flag is set by the cpufreq core if policy->freq_table is
> set and one or more boost frequencies are present.
>
> For other drivers, the flag must be set explicitly.
>
> The policy->boost_enabled flag is set by the cpufreq core once the
> policy is initialized, don't set it anymore.
This patch uncovers a bug in the amd_pstate mode switch path (e.g when
we do "echo passive > /sys/devices/system/cpu/amd_pstate/status").
I have posted a fix for it at
https://lore.kernel.org/all/20250130085251.155146-1-dhananjay.ugwekar@amd.com/T/#u
Can we try to merge this fix before your patch?, so we fix the bug
before it is uncovered. Currently, the fix is based on top of superm1/bleeding-edge
(amd-pstate maintainer's dev tree). It wont apply cleanly on your tree i.e.
vireshk/pm/cpufreq/boost. I can rebase it on your tree and repost, if needed.
Thanks,
Dhananjay
>
> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
> ---
> drivers/cpufreq/amd-pstate.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c
> index d7630bab2516..8d3cc494c92c 100644
> --- a/drivers/cpufreq/amd-pstate.c
> +++ b/drivers/cpufreq/amd-pstate.c
> @@ -995,7 +995,7 @@ static int amd_pstate_cpu_init(struct cpufreq_policy *policy)
> policy->cpuinfo.min_freq = min_freq;
> policy->cpuinfo.max_freq = max_freq;
>
> - policy->boost_enabled = READ_ONCE(cpudata->boost_supported);
> + policy->boost_supported = READ_ONCE(cpudata->boost_supported);
>
> /* It will be updated by governor */
> policy->cur = policy->cpuinfo.min_freq;
> @@ -1480,7 +1480,7 @@ static int amd_pstate_epp_cpu_init(struct cpufreq_policy *policy)
> policy->min = policy->cpuinfo.min_freq;
> policy->max = policy->cpuinfo.max_freq;
>
> - policy->boost_enabled = READ_ONCE(cpudata->boost_supported);
> + policy->boost_supported = READ_ONCE(cpudata->boost_supported);
>
> /*
> * Set the policy to provide a valid fallback value in case
^ permalink raw reply [flat|nested] 23+ messages in thread
* [PATCH 06/15] cpufreq: cppc: Set policy->boost_supported
2025-01-24 8:58 [PATCH 00/15] cpufreq: simplify boost handling Viresh Kumar
` (4 preceding siblings ...)
2025-01-24 8:58 ` [PATCH 05/15] cpufreq: amd: " Viresh Kumar
@ 2025-01-24 8:58 ` Viresh Kumar
2025-02-06 3:58 ` zhenglifeng (A)
2025-02-06 6:27 ` zhenglifeng (A)
2025-01-24 8:58 ` [PATCH 07/15] cpufreq: Restrict enabling boost on policies with no boost frequencies Viresh Kumar
` (9 subsequent siblings)
15 siblings, 2 replies; 23+ messages in thread
From: Viresh Kumar @ 2025-01-24 8:58 UTC (permalink / raw)
To: Rafael J. Wysocki, Viresh Kumar
Cc: linux-pm, Vincent Guittot, Lifeng Zheng, linux-kernel
With a later commit, the cpufreq core will call the ->set_boost()
callback only if the policy supports boost frequency. The
boost_supported flag is set by the cpufreq core if policy->freq_table is
set and one or more boost frequencies are present.
For other drivers, the flag must be set explicitly.
With this, the local variable boost_supported isn't required anymore.
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
---
drivers/cpufreq/cppc_cpufreq.c | 9 +--------
1 file changed, 1 insertion(+), 8 deletions(-)
diff --git a/drivers/cpufreq/cppc_cpufreq.c b/drivers/cpufreq/cppc_cpufreq.c
index 7fa89b601d2a..08117fb9c1eb 100644
--- a/drivers/cpufreq/cppc_cpufreq.c
+++ b/drivers/cpufreq/cppc_cpufreq.c
@@ -34,8 +34,6 @@
*/
static LIST_HEAD(cpu_data_list);
-static bool boost_supported;
-
static struct cpufreq_driver cppc_cpufreq_driver;
#ifdef CONFIG_ACPI_CPPC_CPUFREQ_FIE
@@ -653,7 +651,7 @@ static int cppc_cpufreq_cpu_init(struct cpufreq_policy *policy)
* is supported.
*/
if (caps->highest_perf > caps->nominal_perf)
- boost_supported = true;
+ policy->boost_supported = true;
/* Set policy->cur to max now. The governors will adjust later. */
policy->cur = cppc_perf_to_khz(caps, caps->highest_perf);
@@ -791,11 +789,6 @@ static int cppc_cpufreq_set_boost(struct cpufreq_policy *policy, int state)
struct cppc_perf_caps *caps = &cpu_data->perf_caps;
int ret;
- if (!boost_supported) {
- pr_err("BOOST not supported by CPU or firmware\n");
- return -EINVAL;
- }
-
if (state)
policy->max = cppc_perf_to_khz(caps, caps->highest_perf);
else
--
2.31.1.272.g89b43f80a514
^ permalink raw reply related [flat|nested] 23+ messages in thread* Re: [PATCH 06/15] cpufreq: cppc: Set policy->boost_supported
2025-01-24 8:58 ` [PATCH 06/15] cpufreq: cppc: " Viresh Kumar
@ 2025-02-06 3:58 ` zhenglifeng (A)
2025-02-06 5:27 ` Viresh Kumar
2025-02-06 6:27 ` zhenglifeng (A)
1 sibling, 1 reply; 23+ messages in thread
From: zhenglifeng (A) @ 2025-02-06 3:58 UTC (permalink / raw)
To: Viresh Kumar, Rafael J. Wysocki; +Cc: linux-pm, Vincent Guittot, linux-kernel
On 2025/1/24 16:58, Viresh Kumar wrote:
> With a later commit, the cpufreq core will call the ->set_boost()
> callback only if the policy supports boost frequency. The
> boost_supported flag is set by the cpufreq core if policy->freq_table is
> set and one or more boost frequencies are present.
>
> For other drivers, the flag must be set explicitly.
>
> With this, the local variable boost_supported isn't required anymore.
>
> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
> ---
> drivers/cpufreq/cppc_cpufreq.c | 9 +--------
> 1 file changed, 1 insertion(+), 8 deletions(-)
>
> diff --git a/drivers/cpufreq/cppc_cpufreq.c b/drivers/cpufreq/cppc_cpufreq.c
> index 7fa89b601d2a..08117fb9c1eb 100644
> --- a/drivers/cpufreq/cppc_cpufreq.c
> +++ b/drivers/cpufreq/cppc_cpufreq.c
> @@ -34,8 +34,6 @@
> */
> static LIST_HEAD(cpu_data_list);
>
> -static bool boost_supported;
> -
> static struct cpufreq_driver cppc_cpufreq_driver;
>
> #ifdef CONFIG_ACPI_CPPC_CPUFREQ_FIE
> @@ -653,7 +651,7 @@ static int cppc_cpufreq_cpu_init(struct cpufreq_policy *policy)
> * is supported.
> */
> if (caps->highest_perf > caps->nominal_perf)
> - boost_supported = true;
> + policy->boost_supported = true;
>
> /* Set policy->cur to max now. The governors will adjust later. */
> policy->cur = cppc_perf_to_khz(caps, caps->highest_perf);
> @@ -791,11 +789,6 @@ static int cppc_cpufreq_set_boost(struct cpufreq_policy *policy, int state)
> struct cppc_perf_caps *caps = &cpu_data->perf_caps;
> int ret;
>
> - if (!boost_supported) {
> - pr_err("BOOST not supported by CPU or firmware\n");
> - return -EINVAL;
> - }
> -
> if (state)
> policy->max = cppc_perf_to_khz(caps, caps->highest_perf);
> else
I have a little question. With the old boost_supported flag as false, it
will fail when you operate the global boost flag. But if you replace it
with the per-policy boost_supported flag, the global boost_enabled flag can
be set to true without any error, even no policy's boost_enabled flag
changed. Is this interface behavior change OK?
^ permalink raw reply [flat|nested] 23+ messages in thread* Re: [PATCH 06/15] cpufreq: cppc: Set policy->boost_supported
2025-02-06 3:58 ` zhenglifeng (A)
@ 2025-02-06 5:27 ` Viresh Kumar
0 siblings, 0 replies; 23+ messages in thread
From: Viresh Kumar @ 2025-02-06 5:27 UTC (permalink / raw)
To: zhenglifeng (A)
Cc: Rafael J. Wysocki, linux-pm, Vincent Guittot, linux-kernel
On 06-02-25, 11:58, zhenglifeng (A) wrote:
> On 2025/1/24 16:58, Viresh Kumar wrote:
> > diff --git a/drivers/cpufreq/cppc_cpufreq.c b/drivers/cpufreq/cppc_cpufreq.c
> > index 7fa89b601d2a..08117fb9c1eb 100644
> > --- a/drivers/cpufreq/cppc_cpufreq.c
> > +++ b/drivers/cpufreq/cppc_cpufreq.c
> > @@ -34,8 +34,6 @@
> > */
> > static LIST_HEAD(cpu_data_list);
> >
> > -static bool boost_supported;
> > -
> > static struct cpufreq_driver cppc_cpufreq_driver;
> >
> > #ifdef CONFIG_ACPI_CPPC_CPUFREQ_FIE
> > @@ -653,7 +651,7 @@ static int cppc_cpufreq_cpu_init(struct cpufreq_policy *policy)
> > * is supported.
> > */
> > if (caps->highest_perf > caps->nominal_perf)
> > - boost_supported = true;
> > + policy->boost_supported = true;
> >
> > /* Set policy->cur to max now. The governors will adjust later. */
> > policy->cur = cppc_perf_to_khz(caps, caps->highest_perf);
> > @@ -791,11 +789,6 @@ static int cppc_cpufreq_set_boost(struct cpufreq_policy *policy, int state)
> > struct cppc_perf_caps *caps = &cpu_data->perf_caps;
> > int ret;
> >
> > - if (!boost_supported) {
> > - pr_err("BOOST not supported by CPU or firmware\n");
> > - return -EINVAL;
> > - }
> > -
> > if (state)
> > policy->max = cppc_perf_to_khz(caps, caps->highest_perf);
> > else
>
> I have a little question. With the old boost_supported flag as false, it
> will fail when you operate the global boost flag. But if you replace it
> with the per-policy boost_supported flag, the global boost_enabled flag can
> be set to true without any error, even no policy's boost_enabled flag
> changed. Is this interface behavior change OK?
Right, so earlier even if a single policy didn't support boost, the code disabled
boost for all of them. Or it was rather racy, as the last policy to be
initialized will decide if boost will be supported or not. This is surely
incorrect.
The global boost flag can be enabled disabled without worrying about any
individual policy. If the policy supports boost, it will follow the global boost
here, else it shouldn't take part in the change.
So yes, the new interface does the right thing here.
--
viresh
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH 06/15] cpufreq: cppc: Set policy->boost_supported
2025-01-24 8:58 ` [PATCH 06/15] cpufreq: cppc: " Viresh Kumar
2025-02-06 3:58 ` zhenglifeng (A)
@ 2025-02-06 6:27 ` zhenglifeng (A)
1 sibling, 0 replies; 23+ messages in thread
From: zhenglifeng (A) @ 2025-02-06 6:27 UTC (permalink / raw)
To: Viresh Kumar, Rafael J. Wysocki; +Cc: linux-pm, Vincent Guittot, linux-kernel
On 2025/1/24 16:58, Viresh Kumar wrote:
> With a later commit, the cpufreq core will call the ->set_boost()
> callback only if the policy supports boost frequency. The
> boost_supported flag is set by the cpufreq core if policy->freq_table is
> set and one or more boost frequencies are present.
>
> For other drivers, the flag must be set explicitly.
>
> With this, the local variable boost_supported isn't required anymore.
>
> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
> ---
> drivers/cpufreq/cppc_cpufreq.c | 9 +--------
> 1 file changed, 1 insertion(+), 8 deletions(-)
>
> diff --git a/drivers/cpufreq/cppc_cpufreq.c b/drivers/cpufreq/cppc_cpufreq.c
> index 7fa89b601d2a..08117fb9c1eb 100644
> --- a/drivers/cpufreq/cppc_cpufreq.c
> +++ b/drivers/cpufreq/cppc_cpufreq.c
> @@ -34,8 +34,6 @@
> */
> static LIST_HEAD(cpu_data_list);
>
> -static bool boost_supported;
> -
> static struct cpufreq_driver cppc_cpufreq_driver;
>
> #ifdef CONFIG_ACPI_CPPC_CPUFREQ_FIE
> @@ -653,7 +651,7 @@ static int cppc_cpufreq_cpu_init(struct cpufreq_policy *policy)
> * is supported.
> */
> if (caps->highest_perf > caps->nominal_perf)
> - boost_supported = true;
> + policy->boost_supported = true;
>
> /* Set policy->cur to max now. The governors will adjust later. */
> policy->cur = cppc_perf_to_khz(caps, caps->highest_perf);
> @@ -791,11 +789,6 @@ static int cppc_cpufreq_set_boost(struct cpufreq_policy *policy, int state)
> struct cppc_perf_caps *caps = &cpu_data->perf_caps;
> int ret;
>
> - if (!boost_supported) {
> - pr_err("BOOST not supported by CPU or firmware\n");
> - return -EINVAL;
> - }
> -
> if (state)
> policy->max = cppc_perf_to_khz(caps, caps->highest_perf);
> else
Reviewed-by: Lifeng Zheng <zhenglifeng1@huawei.com>
^ permalink raw reply [flat|nested] 23+ messages in thread
* [PATCH 07/15] cpufreq: Restrict enabling boost on policies with no boost frequencies
2025-01-24 8:58 [PATCH 00/15] cpufreq: simplify boost handling Viresh Kumar
` (5 preceding siblings ...)
2025-01-24 8:58 ` [PATCH 06/15] cpufreq: cppc: " Viresh Kumar
@ 2025-01-24 8:58 ` Viresh Kumar
2025-01-24 8:58 ` [PATCH 08/15] cpufreq: apple: Set .set_boost directly Viresh Kumar
` (8 subsequent siblings)
15 siblings, 0 replies; 23+ messages in thread
From: Viresh Kumar @ 2025-01-24 8:58 UTC (permalink / raw)
To: Rafael J. Wysocki, Viresh Kumar
Cc: linux-pm, Vincent Guittot, Lifeng Zheng, linux-kernel
It is possible to have a scenario where not all cpufreq policies support
boost frequencies. And letting sysfs (or other parts of the kernel)
enable boost feature for that policy isn't correct.
Now that all drivers (that required a change) are updated to set the
policy->boost_supported properly, check this flag before enabling boost
feature for a policy.
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
---
drivers/cpufreq/cpufreq.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
index 8b0754b506fa..1e6ab42b405f 100644
--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -631,6 +631,9 @@ static ssize_t store_local_boost(struct cpufreq_policy *policy,
if (!cpufreq_driver->boost_enabled)
return -EINVAL;
+ if (!policy->boost_supported)
+ return -EINVAL;
+
if (policy->boost_enabled == enable)
return count;
@@ -1586,7 +1589,8 @@ static int cpufreq_online(unsigned int cpu)
policy->cdev = of_cpufreq_cooling_register(policy);
/* Let the per-policy boost flag mirror the cpufreq_driver boost during init */
- if (policy->boost_enabled != cpufreq_boost_enabled()) {
+ if (policy->boost_supported &&
+ policy->boost_enabled != cpufreq_boost_enabled()) {
policy->boost_enabled = cpufreq_boost_enabled();
ret = cpufreq_driver->set_boost(policy, policy->boost_enabled);
if (ret) {
@@ -2822,6 +2826,9 @@ static int cpufreq_boost_trigger_state(int state)
cpus_read_lock();
for_each_active_policy(policy) {
+ if (!policy->boost_supported)
+ continue;
+
policy->boost_enabled = state;
ret = cpufreq_driver->set_boost(policy, state);
if (ret) {
--
2.31.1.272.g89b43f80a514
^ permalink raw reply related [flat|nested] 23+ messages in thread* [PATCH 08/15] cpufreq: apple: Set .set_boost directly
2025-01-24 8:58 [PATCH 00/15] cpufreq: simplify boost handling Viresh Kumar
` (6 preceding siblings ...)
2025-01-24 8:58 ` [PATCH 07/15] cpufreq: Restrict enabling boost on policies with no boost frequencies Viresh Kumar
@ 2025-01-24 8:58 ` Viresh Kumar
2025-01-24 8:58 ` [PATCH 09/15] cpufreq: loongson: " Viresh Kumar
` (7 subsequent siblings)
15 siblings, 0 replies; 23+ messages in thread
From: Viresh Kumar @ 2025-01-24 8:58 UTC (permalink / raw)
To: Rafael J. Wysocki, Hector Martin, Sven Peter, Alyssa Rosenzweig,
Viresh Kumar
Cc: linux-pm, Vincent Guittot, Lifeng Zheng, asahi, linux-arm-kernel,
linux-kernel
The boost feature can be controlled at two levels currently, driver
level (applies to all policies) and per-policy.
Currently the driver enables driver level boost support from the
per-policy ->init() callback, which isn't really efficient as that gets
called for each policy and then there is online/offline path too where
this gets done unnecessarily.
Instead set the .set_boost field directly and always enable the boost
support. If a policy doesn't support boost feature, the core will not
enable it for that policy.
Keep the initial state of driver level boost to disabled and let the
user enable it if required as ideally the boost frequencies must be used
only when really required.
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
---
drivers/cpufreq/apple-soc-cpufreq.c | 10 +---------
1 file changed, 1 insertion(+), 9 deletions(-)
diff --git a/drivers/cpufreq/apple-soc-cpufreq.c b/drivers/cpufreq/apple-soc-cpufreq.c
index 6ff604a0fe79..4994c86feb57 100644
--- a/drivers/cpufreq/apple-soc-cpufreq.c
+++ b/drivers/cpufreq/apple-soc-cpufreq.c
@@ -310,15 +310,6 @@ static int apple_soc_cpufreq_init(struct cpufreq_policy *policy)
policy->fast_switch_possible = true;
policy->suspend_freq = freq_table[0].frequency;
- if (policy_has_boost_freq(policy)) {
- ret = cpufreq_enable_boost_support();
- if (ret) {
- dev_warn(cpu_dev, "failed to enable boost: %d\n", ret);
- } else {
- apple_soc_cpufreq_driver.boost_enabled = true;
- }
- }
-
return 0;
out_free_cpufreq_table:
@@ -353,6 +344,7 @@ static struct cpufreq_driver apple_soc_cpufreq_driver = {
.target_index = apple_soc_cpufreq_set_target,
.fast_switch = apple_soc_cpufreq_fast_switch,
.register_em = cpufreq_register_em_with_opp,
+ .set_boost = cpufreq_boost_set_sw,
.suspend = cpufreq_generic_suspend,
};
--
2.31.1.272.g89b43f80a514
^ permalink raw reply related [flat|nested] 23+ messages in thread* [PATCH 09/15] cpufreq: loongson: Set .set_boost directly
2025-01-24 8:58 [PATCH 00/15] cpufreq: simplify boost handling Viresh Kumar
` (7 preceding siblings ...)
2025-01-24 8:58 ` [PATCH 08/15] cpufreq: apple: Set .set_boost directly Viresh Kumar
@ 2025-01-24 8:58 ` Viresh Kumar
2025-01-24 8:58 ` [PATCH 10/15] cpufreq: powernv: " Viresh Kumar
` (6 subsequent siblings)
15 siblings, 0 replies; 23+ messages in thread
From: Viresh Kumar @ 2025-01-24 8:58 UTC (permalink / raw)
To: Rafael J. Wysocki, Huacai Chen, WANG Xuerui, Viresh Kumar
Cc: linux-pm, Vincent Guittot, Lifeng Zheng, loongarch, linux-kernel
The boost feature can be controlled at two levels currently, driver
level (applies to all policies) and per-policy.
Currently the driver enables driver level boost support from the
per-policy ->init() callback, which isn't really efficient as that gets
called for each policy and then there is online/offline path too where
this gets done unnecessarily.
Instead set the .set_boost field directly and always enable the boost
support. If a policy doesn't support boost feature, the core will not
enable it for that policy.
Keep the initial state of driver level boost to disabled and let the
user enable it if required as ideally the boost frequencies must be used
only when really required.
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
---
drivers/cpufreq/loongson3_cpufreq.c | 10 +---------
1 file changed, 1 insertion(+), 9 deletions(-)
diff --git a/drivers/cpufreq/loongson3_cpufreq.c b/drivers/cpufreq/loongson3_cpufreq.c
index ea516b939c44..1e8715ea1b77 100644
--- a/drivers/cpufreq/loongson3_cpufreq.c
+++ b/drivers/cpufreq/loongson3_cpufreq.c
@@ -299,15 +299,6 @@ static int loongson3_cpufreq_cpu_init(struct cpufreq_policy *policy)
per_cpu(freq_data, i) = per_cpu(freq_data, cpu);
}
- if (policy_has_boost_freq(policy)) {
- ret = cpufreq_enable_boost_support();
- if (ret < 0) {
- pr_warn("cpufreq: Failed to enable boost: %d\n", ret);
- return ret;
- }
- loongson3_cpufreq_driver.boost_enabled = true;
- }
-
return 0;
}
@@ -338,6 +329,7 @@ static struct cpufreq_driver loongson3_cpufreq_driver = {
.get = loongson3_cpufreq_get,
.target_index = loongson3_cpufreq_target,
.verify = cpufreq_generic_frequency_table_verify,
+ .set_boost = cpufreq_boost_set_sw,
.suspend = cpufreq_generic_suspend,
};
--
2.31.1.272.g89b43f80a514
^ permalink raw reply related [flat|nested] 23+ messages in thread* [PATCH 10/15] cpufreq: powernv: Set .set_boost directly
2025-01-24 8:58 [PATCH 00/15] cpufreq: simplify boost handling Viresh Kumar
` (8 preceding siblings ...)
2025-01-24 8:58 ` [PATCH 09/15] cpufreq: loongson: " Viresh Kumar
@ 2025-01-24 8:58 ` Viresh Kumar
2025-01-24 8:58 ` [PATCH 11/15] cpufreq: scmi: " Viresh Kumar
` (5 subsequent siblings)
15 siblings, 0 replies; 23+ messages in thread
From: Viresh Kumar @ 2025-01-24 8:58 UTC (permalink / raw)
To: Rafael J. Wysocki, Viresh Kumar, Michael Ellerman,
Nicholas Piggin, Christophe Leroy, Naveen N Rao,
Madhavan Srinivasan
Cc: linux-pm, Vincent Guittot, Lifeng Zheng, linuxppc-dev,
linux-kernel
The boost feature can be controlled at two levels currently, driver
level (applies to all policies) and per-policy.
Currently the driver enables driver level boost support from the
per-policy ->init() callback, which isn't really efficient as that gets
called for each policy and then there is online/offline path too where
this gets done unnecessarily.
Instead set the .set_boost field directly and always enable the boost
support. If a policy doesn't support boost feature, the core will not
enable it for that policy.
Keep the initial state of driver level boost to disabled and let the
user enable it if required as ideally the boost frequencies must be used
only when really required.
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
---
drivers/cpufreq/powernv-cpufreq.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/drivers/cpufreq/powernv-cpufreq.c b/drivers/cpufreq/powernv-cpufreq.c
index 0c3e907c58bc..4d3e891ff508 100644
--- a/drivers/cpufreq/powernv-cpufreq.c
+++ b/drivers/cpufreq/powernv-cpufreq.c
@@ -1125,7 +1125,7 @@ static int __init powernv_cpufreq_init(void)
goto out;
if (powernv_pstate_info.wof_enabled)
- powernv_cpufreq_driver.boost_enabled = true;
+ powernv_cpufreq_driver.set_boost = cpufreq_boost_set_sw;
else
powernv_cpu_freq_attr[SCALING_BOOST_FREQS_ATTR_INDEX] = NULL;
@@ -1135,9 +1135,6 @@ static int __init powernv_cpufreq_init(void)
goto cleanup;
}
- if (powernv_pstate_info.wof_enabled)
- cpufreq_enable_boost_support();
-
register_reboot_notifier(&powernv_cpufreq_reboot_nb);
opal_message_notifier_register(OPAL_MSG_OCC, &powernv_cpufreq_opal_nb);
--
2.31.1.272.g89b43f80a514
^ permalink raw reply related [flat|nested] 23+ messages in thread* [PATCH 11/15] cpufreq: scmi: Set .set_boost directly
2025-01-24 8:58 [PATCH 00/15] cpufreq: simplify boost handling Viresh Kumar
` (9 preceding siblings ...)
2025-01-24 8:58 ` [PATCH 10/15] cpufreq: powernv: " Viresh Kumar
@ 2025-01-24 8:58 ` Viresh Kumar
2025-01-28 11:27 ` Sudeep Holla
2025-01-24 8:58 ` [PATCH 12/15] cpufreq: dt: " Viresh Kumar
` (4 subsequent siblings)
15 siblings, 1 reply; 23+ messages in thread
From: Viresh Kumar @ 2025-01-24 8:58 UTC (permalink / raw)
To: Rafael J. Wysocki, Sudeep Holla, Cristian Marussi, Viresh Kumar
Cc: linux-pm, Vincent Guittot, Lifeng Zheng, arm-scmi,
linux-arm-kernel, linux-kernel
The boost feature can be controlled at two levels currently, driver
level (applies to all policies) and per-policy.
Currently the driver enables driver level boost support from the
per-policy ->init() callback, which isn't really efficient as that gets
called for each policy and then there is online/offline path too where
this gets done unnecessarily.
Instead set the .set_boost field directly and always enable the boost
support. If a policy doesn't support boost feature, the core will not
enable it for that policy.
Keep the initial state of driver level boost to disabled and let the
user enable it if required as ideally the boost frequencies must be used
only when really required.
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
---
drivers/cpufreq/scmi-cpufreq.c | 11 +----------
1 file changed, 1 insertion(+), 10 deletions(-)
diff --git a/drivers/cpufreq/scmi-cpufreq.c b/drivers/cpufreq/scmi-cpufreq.c
index 4a3ee59cb771..ff2897789797 100644
--- a/drivers/cpufreq/scmi-cpufreq.c
+++ b/drivers/cpufreq/scmi-cpufreq.c
@@ -297,16 +297,6 @@ static int scmi_cpufreq_init(struct cpufreq_policy *policy)
policy->transition_delay_us =
scmi_get_rate_limit(domain, policy->fast_switch_possible);
- if (policy_has_boost_freq(policy)) {
- ret = cpufreq_enable_boost_support();
- if (ret) {
- dev_warn(cpu_dev, "failed to enable boost: %d\n", ret);
- goto out_free_table;
- } else {
- scmi_cpufreq_driver.boost_enabled = true;
- }
- }
-
ret = freq_qos_add_request(&policy->constraints, &priv->limits_freq_req, FREQ_QOS_MAX,
FREQ_QOS_MAX_DEFAULT_VALUE);
if (ret < 0) {
@@ -394,6 +384,7 @@ static struct cpufreq_driver scmi_cpufreq_driver = {
.init = scmi_cpufreq_init,
.exit = scmi_cpufreq_exit,
.register_em = scmi_cpufreq_register_em,
+ .set_boost = cpufreq_boost_set_sw,
};
static int scmi_cpufreq_probe(struct scmi_device *sdev)
--
2.31.1.272.g89b43f80a514
^ permalink raw reply related [flat|nested] 23+ messages in thread* Re: [PATCH 11/15] cpufreq: scmi: Set .set_boost directly
2025-01-24 8:58 ` [PATCH 11/15] cpufreq: scmi: " Viresh Kumar
@ 2025-01-28 11:27 ` Sudeep Holla
0 siblings, 0 replies; 23+ messages in thread
From: Sudeep Holla @ 2025-01-28 11:27 UTC (permalink / raw)
To: Viresh Kumar
Cc: Rafael J. Wysocki, Cristian Marussi, Sudeep Holla, linux-pm,
Vincent Guittot, Lifeng Zheng, arm-scmi, linux-arm-kernel,
linux-kernel
On Fri, Jan 24, 2025 at 02:28:15PM +0530, Viresh Kumar wrote:
> The boost feature can be controlled at two levels currently, driver
> level (applies to all policies) and per-policy.
>
> Currently the driver enables driver level boost support from the
> per-policy ->init() callback, which isn't really efficient as that gets
> called for each policy and then there is online/offline path too where
> this gets done unnecessarily.
>
> Instead set the .set_boost field directly and always enable the boost
> support. If a policy doesn't support boost feature, the core will not
> enable it for that policy.
>
> Keep the initial state of driver level boost to disabled and let the
> user enable it if required as ideally the boost frequencies must be used
> only when really required.
>
Acked-by: Sudeep Holla <sudeep.holla@arm.com>
--
Regards,
Sudeep
^ permalink raw reply [flat|nested] 23+ messages in thread
* [PATCH 12/15] cpufreq: dt: Set .set_boost directly
2025-01-24 8:58 [PATCH 00/15] cpufreq: simplify boost handling Viresh Kumar
` (10 preceding siblings ...)
2025-01-24 8:58 ` [PATCH 11/15] cpufreq: scmi: " Viresh Kumar
@ 2025-01-24 8:58 ` Viresh Kumar
2025-01-24 8:58 ` [PATCH 13/15] cpufreq: qcom: " Viresh Kumar
` (3 subsequent siblings)
15 siblings, 0 replies; 23+ messages in thread
From: Viresh Kumar @ 2025-01-24 8:58 UTC (permalink / raw)
To: Rafael J. Wysocki, Viresh Kumar
Cc: linux-pm, Vincent Guittot, Lifeng Zheng, linux-kernel
The boost feature can be controlled at two levels currently, driver
level (applies to all policies) and per-policy.
Currently the driver enables driver level boost support from the
per-policy ->init() callback, which isn't really efficient as that gets
called for each policy and then there is online/offline path too where
this gets done unnecessarily.
Instead set the .set_boost field directly and always enable the boost
support. If a policy doesn't support boost feature, the core will not
enable it for that policy.
Keep the initial state of driver level boost to disabled and let the
user enable it if required as ideally the boost frequencies must be used
only when really required.
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
---
drivers/cpufreq/cpufreq-dt.c | 14 +-------------
1 file changed, 1 insertion(+), 13 deletions(-)
diff --git a/drivers/cpufreq/cpufreq-dt.c b/drivers/cpufreq/cpufreq-dt.c
index 072ccf0c2e41..778916f89a51 100644
--- a/drivers/cpufreq/cpufreq-dt.c
+++ b/drivers/cpufreq/cpufreq-dt.c
@@ -114,20 +114,7 @@ static int cpufreq_init(struct cpufreq_policy *policy)
policy->cpuinfo.transition_latency = transition_latency;
policy->dvfs_possible_from_any_cpu = true;
- /* Support turbo/boost mode */
- if (policy_has_boost_freq(policy)) {
- /* This gets disabled by core on driver unregister */
- ret = cpufreq_enable_boost_support();
- if (ret)
- goto out_clk_put;
- }
-
return 0;
-
-out_clk_put:
- clk_put(cpu_clk);
-
- return ret;
}
static int cpufreq_online(struct cpufreq_policy *policy)
@@ -162,6 +149,7 @@ static struct cpufreq_driver dt_cpufreq_driver = {
.offline = cpufreq_offline,
.register_em = cpufreq_register_em_with_opp,
.name = "cpufreq-dt",
+ .set_boost = cpufreq_boost_set_sw,
.suspend = cpufreq_generic_suspend,
};
--
2.31.1.272.g89b43f80a514
^ permalink raw reply related [flat|nested] 23+ messages in thread* [PATCH 13/15] cpufreq: qcom: Set .set_boost directly
2025-01-24 8:58 [PATCH 00/15] cpufreq: simplify boost handling Viresh Kumar
` (11 preceding siblings ...)
2025-01-24 8:58 ` [PATCH 12/15] cpufreq: dt: " Viresh Kumar
@ 2025-01-24 8:58 ` Viresh Kumar
2025-01-24 8:58 ` [PATCH 14/15] cpufreq: staticize policy_has_boost_freq() Viresh Kumar
` (2 subsequent siblings)
15 siblings, 0 replies; 23+ messages in thread
From: Viresh Kumar @ 2025-01-24 8:58 UTC (permalink / raw)
To: Rafael J. Wysocki, Viresh Kumar
Cc: linux-pm, Vincent Guittot, Lifeng Zheng, linux-arm-msm,
linux-kernel
The boost feature can be controlled at two levels currently, driver
level (applies to all policies) and per-policy.
Currently the driver enables driver level boost support from the
per-policy ->init() callback, which isn't really efficient as that gets
called for each policy and then there is online/offline path too where
this gets done unnecessarily.
Instead set the .set_boost field directly and always enable the boost
support. If a policy doesn't support boost feature, the core will not
enable it for that policy.
Keep the initial state of driver level boost to disabled and let the
user enable it if required as ideally the boost frequencies must be used
only when really required.
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
---
drivers/cpufreq/qcom-cpufreq-hw.c | 7 +------
1 file changed, 1 insertion(+), 6 deletions(-)
diff --git a/drivers/cpufreq/qcom-cpufreq-hw.c b/drivers/cpufreq/qcom-cpufreq-hw.c
index 7d83d7d2ccc8..4b3b3dbc7d38 100644
--- a/drivers/cpufreq/qcom-cpufreq-hw.c
+++ b/drivers/cpufreq/qcom-cpufreq-hw.c
@@ -566,12 +566,6 @@ static int qcom_cpufreq_hw_cpu_init(struct cpufreq_policy *policy)
return -ENODEV;
}
- if (policy_has_boost_freq(policy)) {
- ret = cpufreq_enable_boost_support();
- if (ret)
- dev_warn(cpu_dev, "failed to enable boost: %d\n", ret);
- }
-
return qcom_cpufreq_hw_lmh_init(policy, index);
}
@@ -610,6 +604,7 @@ static struct cpufreq_driver cpufreq_qcom_hw_driver = {
.fast_switch = qcom_cpufreq_hw_fast_switch,
.name = "qcom-cpufreq-hw",
.ready = qcom_cpufreq_ready,
+ .set_boost = cpufreq_boost_set_sw,
};
static unsigned long qcom_cpufreq_hw_recalc_rate(struct clk_hw *hw, unsigned long parent_rate)
--
2.31.1.272.g89b43f80a514
^ permalink raw reply related [flat|nested] 23+ messages in thread* [PATCH 14/15] cpufreq: staticize policy_has_boost_freq()
2025-01-24 8:58 [PATCH 00/15] cpufreq: simplify boost handling Viresh Kumar
` (12 preceding siblings ...)
2025-01-24 8:58 ` [PATCH 13/15] cpufreq: qcom: " Viresh Kumar
@ 2025-01-24 8:58 ` Viresh Kumar
2025-01-24 8:58 ` [PATCH 15/15] cpufreq: Remove cpufreq_enable_boost_support() Viresh Kumar
2025-01-24 11:05 ` [PATCH 00/15] cpufreq: simplify boost handling Rafael J. Wysocki
15 siblings, 0 replies; 23+ messages in thread
From: Viresh Kumar @ 2025-01-24 8:58 UTC (permalink / raw)
To: Rafael J. Wysocki, Viresh Kumar
Cc: linux-pm, Vincent Guittot, Lifeng Zheng, linux-kernel
policy_has_boost_freq() isn't used outside of freq_table.c now, mark it
static.
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
---
drivers/cpufreq/freq_table.c | 3 +--
include/linux/cpufreq.h | 6 ------
2 files changed, 1 insertion(+), 8 deletions(-)
diff --git a/drivers/cpufreq/freq_table.c b/drivers/cpufreq/freq_table.c
index 185070052b41..c03a91502f84 100644
--- a/drivers/cpufreq/freq_table.c
+++ b/drivers/cpufreq/freq_table.c
@@ -14,7 +14,7 @@
* FREQUENCY TABLE HELPERS *
*********************************************************************/
-bool policy_has_boost_freq(struct cpufreq_policy *policy)
+static bool policy_has_boost_freq(struct cpufreq_policy *policy)
{
struct cpufreq_frequency_table *pos, *table = policy->freq_table;
@@ -27,7 +27,6 @@ bool policy_has_boost_freq(struct cpufreq_policy *policy)
return false;
}
-EXPORT_SYMBOL_GPL(policy_has_boost_freq);
int cpufreq_frequency_table_cpuinfo(struct cpufreq_policy *policy,
struct cpufreq_frequency_table *table)
diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h
index b017af4398b9..466d186166da 100644
--- a/include/linux/cpufreq.h
+++ b/include/linux/cpufreq.h
@@ -783,7 +783,6 @@ ssize_t cpufreq_show_cpus(const struct cpumask *mask, char *buf);
#ifdef CONFIG_CPU_FREQ
bool cpufreq_boost_enabled(void);
int cpufreq_enable_boost_support(void);
-bool policy_has_boost_freq(struct cpufreq_policy *policy);
int cpufreq_boost_set_sw(struct cpufreq_policy *policy, int state);
/* Find lowest freq at or above target in a table in ascending order */
@@ -1163,11 +1162,6 @@ static inline int cpufreq_enable_boost_support(void)
return -EINVAL;
}
-static inline bool policy_has_boost_freq(struct cpufreq_policy *policy)
-{
- return false;
-}
-
static inline int cpufreq_boost_set_sw(struct cpufreq_policy *policy, int state)
{
return -EOPNOTSUPP;
--
2.31.1.272.g89b43f80a514
^ permalink raw reply related [flat|nested] 23+ messages in thread* [PATCH 15/15] cpufreq: Remove cpufreq_enable_boost_support()
2025-01-24 8:58 [PATCH 00/15] cpufreq: simplify boost handling Viresh Kumar
` (13 preceding siblings ...)
2025-01-24 8:58 ` [PATCH 14/15] cpufreq: staticize policy_has_boost_freq() Viresh Kumar
@ 2025-01-24 8:58 ` Viresh Kumar
2025-01-24 11:05 ` [PATCH 00/15] cpufreq: simplify boost handling Rafael J. Wysocki
15 siblings, 0 replies; 23+ messages in thread
From: Viresh Kumar @ 2025-01-24 8:58 UTC (permalink / raw)
To: Rafael J. Wysocki, Viresh Kumar
Cc: linux-pm, Vincent Guittot, Lifeng Zheng, linux-kernel
Remove the now unused helper, cpufreq_enable_boost_support().
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
---
drivers/cpufreq/cpufreq.c | 15 ---------------
include/linux/cpufreq.h | 6 ------
2 files changed, 21 deletions(-)
diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
index 1e6ab42b405f..00d86dd7945a 100644
--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -2876,21 +2876,6 @@ static void remove_boost_sysfs_file(void)
sysfs_remove_file(cpufreq_global_kobject, &boost.attr);
}
-int cpufreq_enable_boost_support(void)
-{
- if (!cpufreq_driver)
- return -EINVAL;
-
- if (cpufreq_boost_supported())
- return 0;
-
- cpufreq_driver->set_boost = cpufreq_boost_set_sw;
-
- /* This will get removed on driver unregister */
- return create_boost_sysfs_file();
-}
-EXPORT_SYMBOL_GPL(cpufreq_enable_boost_support);
-
bool cpufreq_boost_enabled(void)
{
return cpufreq_driver->boost_enabled;
diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h
index 466d186166da..cefd853abfd1 100644
--- a/include/linux/cpufreq.h
+++ b/include/linux/cpufreq.h
@@ -782,7 +782,6 @@ ssize_t cpufreq_show_cpus(const struct cpumask *mask, char *buf);
#ifdef CONFIG_CPU_FREQ
bool cpufreq_boost_enabled(void);
-int cpufreq_enable_boost_support(void);
int cpufreq_boost_set_sw(struct cpufreq_policy *policy, int state);
/* Find lowest freq at or above target in a table in ascending order */
@@ -1157,11 +1156,6 @@ static inline bool cpufreq_boost_enabled(void)
return false;
}
-static inline int cpufreq_enable_boost_support(void)
-{
- return -EINVAL;
-}
-
static inline int cpufreq_boost_set_sw(struct cpufreq_policy *policy, int state)
{
return -EOPNOTSUPP;
--
2.31.1.272.g89b43f80a514
^ permalink raw reply related [flat|nested] 23+ messages in thread* Re: [PATCH 00/15] cpufreq: simplify boost handling
2025-01-24 8:58 [PATCH 00/15] cpufreq: simplify boost handling Viresh Kumar
` (14 preceding siblings ...)
2025-01-24 8:58 ` [PATCH 15/15] cpufreq: Remove cpufreq_enable_boost_support() Viresh Kumar
@ 2025-01-24 11:05 ` Rafael J. Wysocki
2025-01-27 3:32 ` Viresh Kumar
15 siblings, 1 reply; 23+ messages in thread
From: Rafael J. Wysocki @ 2025-01-24 11:05 UTC (permalink / raw)
To: Viresh Kumar
Cc: Rafael J. Wysocki, Alyssa Rosenzweig, Christophe Leroy,
Cristian Marussi, Gautham R. Shenoy, Hector Martin, Huacai Chen,
Huang Rui, Madhavan Srinivasan, Mario Limonciello,
Michael Ellerman, Naveen N Rao, Nicholas Piggin, Perry Yuan,
Sudeep Holla, Sven Peter, WANG Xuerui, linux-pm, Vincent Guittot,
Lifeng Zheng, arm-scmi, asahi, linux-arm-kernel, linux-arm-msm,
linux-kernel, linuxppc-dev, loongarch
On Fri, Jan 24, 2025 at 9:58 AM Viresh Kumar <viresh.kumar@linaro.org> wrote:
>
> Hello,
>
> The boost feature can be controlled at two levels currently, driver
> level (applies to all policies) and per-policy.
>
> Currently most of the drivers enables driver level boost support from the
> per-policy ->init() callback, which isn't really efficient as that gets called
> for each policy and then there is online/offline path too where this gets done
> unnecessarily.
>
> Also it is possible to have a scenario where not all cpufreq policies support
> boost frequencies. And letting sysfs (or other parts of the kernel) enable boost
> feature for that policy isn't correct.
>
> Simplify and cleanup handling of boost to solve these issues.
I guess this depends on the previous series?
> Pushed here:
>
> git://git.kernel.org/pub/scm/linux/kernel/git/vireshk/pm.git cpufreq/boost
>
> Rebased over few dependencies from PM tree, will push to the arm-cpufreq tree
> after merge window is closed.
>
> Viresh Kumar (15):
> cpufreq: staticize cpufreq_boost_trigger_state()
> cpufreq: Export cpufreq_boost_set_sw()
> cpufreq: Introduce policy->boost_supported flag
> cpufreq: acpi: Set policy->boost_supported
> cpufreq: amd: Set policy->boost_supported
> cpufreq: cppc: Set policy->boost_supported
> cpufreq: Restrict enabling boost on policies with no boost frequencies
> cpufreq: apple: Set .set_boost directly
> cpufreq: loongson: Set .set_boost directly
> cpufreq: powernv: Set .set_boost directly
> cpufreq: scmi: Set .set_boost directly
> cpufreq: dt: Set .set_boost directly
> cpufreq: qcom: Set .set_boost directly
> cpufreq: staticize policy_has_boost_freq()
> cpufreq: Remove cpufreq_enable_boost_support()
>
> drivers/cpufreq/acpi-cpufreq.c | 3 +++
> drivers/cpufreq/amd-pstate.c | 4 ++--
> drivers/cpufreq/apple-soc-cpufreq.c | 10 +---------
> drivers/cpufreq/cppc_cpufreq.c | 9 +--------
> drivers/cpufreq/cpufreq-dt.c | 14 +-------------
> drivers/cpufreq/cpufreq.c | 30 ++++++++++++-----------------
> drivers/cpufreq/freq_table.c | 7 +++++--
> drivers/cpufreq/loongson3_cpufreq.c | 10 +---------
> drivers/cpufreq/powernv-cpufreq.c | 5 +----
> drivers/cpufreq/qcom-cpufreq-hw.c | 7 +------
> drivers/cpufreq/scmi-cpufreq.c | 11 +----------
> include/linux/cpufreq.h | 20 ++++++-------------
> 12 files changed, 35 insertions(+), 95 deletions(-)
>
> --
> 2.31.1.272.g89b43f80a514
>
^ permalink raw reply [flat|nested] 23+ messages in thread* Re: [PATCH 00/15] cpufreq: simplify boost handling
2025-01-24 11:05 ` [PATCH 00/15] cpufreq: simplify boost handling Rafael J. Wysocki
@ 2025-01-27 3:32 ` Viresh Kumar
0 siblings, 0 replies; 23+ messages in thread
From: Viresh Kumar @ 2025-01-27 3:32 UTC (permalink / raw)
To: Rafael J. Wysocki
Cc: Alyssa Rosenzweig, Christophe Leroy, Cristian Marussi,
Gautham R. Shenoy, Hector Martin, Huacai Chen, Huang Rui,
Madhavan Srinivasan, Mario Limonciello, Michael Ellerman,
Naveen N Rao, Nicholas Piggin, Perry Yuan, Sudeep Holla,
Sven Peter, WANG Xuerui, linux-pm, Vincent Guittot, Lifeng Zheng,
arm-scmi, asahi, linux-arm-kernel, linux-arm-msm, linux-kernel,
linuxppc-dev, loongarch
On 24-01-25, 12:05, Rafael J. Wysocki wrote:
> On Fri, Jan 24, 2025 at 9:58 AM Viresh Kumar <viresh.kumar@linaro.org> wrote:
> >
> > Hello,
> >
> > The boost feature can be controlled at two levels currently, driver
> > level (applies to all policies) and per-policy.
> >
> > Currently most of the drivers enables driver level boost support from the
> > per-policy ->init() callback, which isn't really efficient as that gets called
> > for each policy and then there is online/offline path too where this gets done
> > unnecessarily.
> >
> > Also it is possible to have a scenario where not all cpufreq policies support
> > boost frequencies. And letting sysfs (or other parts of the kernel) enable boost
> > feature for that policy isn't correct.
> >
> > Simplify and cleanup handling of boost to solve these issues.
>
> I guess this depends on the previous series?
Yes my series and the boost related patches in your tree.
--
viresh
^ permalink raw reply [flat|nested] 23+ messages in thread