* [PATCH] cpufreq: rcpufreq_dt: implement software boost support
@ 2026-12-02 3:51 Poil Zero
2026-12-02 6:10 ` Zhongqiu Han
0 siblings, 1 reply; 2+ messages in thread
From: Poil Zero @ 2026-12-02 3:51 UTC (permalink / raw)
To: Viresh Kumar, Rafael J. Wysocki; +Cc: linux-pm, rust-for-linux
rcpufreq_dt advertises boost support but its set_boost() callback returns
success without updating the policy limits. As a result, enabling boost
can leave boost frequencies outside the policy's usable range.
Use cpufreq_boost_set_sw() through a Rust Policy wrapper so the callback
updates the frequency limits and QoS request. Start with driver-level
boost disabled, as cpufreq-dt does.
Signed-off-by: Poil Zero <poilandgginchi@gmail.com>
---
drivers/cpufreq/rcpufreq_dt.rs | 8 +++++---
rust/kernel/cpufreq.rs | 15 ++++++++++++++-
2 files changed, 19 insertions(+), 4 deletions(-)
diff --git a/drivers/cpufreq/rcpufreq_dt.rs b/drivers/cpufreq/rcpufreq_dt.rs
index 2b1f18b..e0e1814 100644
--- a/drivers/cpufreq/rcpufreq_dt.rs
+++ b/drivers/cpufreq/rcpufreq_dt.rs
@@ -60,7 +60,9 @@ impl opp::ConfigOps for CPUFreqDTDriver {}
impl cpufreq::Driver for CPUFreqDTDriver {
const NAME: &'static CStr = c"cpufreq-dt";
const FLAGS: u16 = cpufreq::flags::NEED_INITIAL_FREQ_CHECK |
cpufreq::flags::IS_COOLING_DEV;
- const BOOST_ENABLED: bool = true;
+ // Keep the initial driver level boost state disabled and let the
userspace enable it if
+ // required, like the C driver does.
+ const BOOST_ENABLED: bool = false;
type PData = Arc<CPUFreqDTDevice>;
@@ -190,8 +192,8 @@ impl cpufreq::Driver for CPUFreqDTDriver {
policy.generic_get()
}
- fn set_boost(_policy: &mut cpufreq::Policy, _state: i32) -> Result {
- Ok(())
+ fn set_boost(policy: &mut cpufreq::Policy, state: i32) -> Result {
+ policy.set_boost_sw(state)
}
fn register_em(policy: &mut cpufreq::Policy) {
diff --git a/rust/kernel/cpufreq.rs b/rust/kernel/cpufreq.rs
index f316711..ad01387 100644
--- a/rust/kernel/cpufreq.rs
+++ b/rust/kernel/cpufreq.rs
@@ -544,6 +544,16 @@ impl Policy {
Ok(unsafe { bindings::cpufreq_generic_get(u32::from(self.cpu())) })
}
+ /// Provides a wrapper to the generic software boost routine.
+ ///
+ /// This recomputes the policy's `cpuinfo` limits from its
frequency table, taking the
+ /// current driver and per-policy boost state into account.
+ #[inline]
+ pub fn set_boost_sw(&mut self, state: i32) -> Result {
+ // SAFETY: By the type invariant, the pointer stored in
`self` is valid.
+ to_result(unsafe {
bindings::cpufreq_boost_set_sw(self.as_mut_ref(), state) })
+ }
+
/// Provides a wrapper to the register with energy model using
the OPP core.
#[cfg(CONFIG_PM_OPP)]
#[inline]
@@ -741,7 +751,10 @@ pub trait Driver {
/// Driver's flags.
const FLAGS: u16;
- /// Boost support.
+ /// Initial state of the driver level boost support.
+ ///
+ /// This maps to `cpufreq_driver.boost_enabled`. Boost support
itself is advertised to the
+ /// core by implementing [`Driver::set_boost`].
const BOOST_ENABLED: bool;
/// Policy specific data.
--
2.43.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] cpufreq: rcpufreq_dt: implement software boost support
2026-12-02 3:51 [PATCH] cpufreq: rcpufreq_dt: implement software boost support Poil Zero
@ 2026-12-02 6:10 ` Zhongqiu Han
0 siblings, 0 replies; 2+ messages in thread
From: Zhongqiu Han @ 2026-12-02 6:10 UTC (permalink / raw)
To: Poil Zero, Viresh Kumar, Rafael J. Wysocki
Cc: linux-pm, rust-for-linux, Zhongqiu Han
On 12/2/2026 11:51 AM, Poil Zero wrote:
> rcpufreq_dt advertises boost support but its set_boost() callback returns
> success without updating the policy limits. As a result, enabling boost
> can leave boost frequencies outside the policy's usable range.
>
> Use cpufreq_boost_set_sw() through a Rust Policy wrapper so the callback
> updates the frequency limits and QoS request. Start with driver-level
> boost disabled, as cpufreq-dt does.
The checkpatch.pl reports the following error:
ERROR: patch seems to be corrupt (line wrapped?)
#30: FILE: drivers/cpufreq/rcpufreq_dt.rs:62:
cpufreq::flags::IS_COOLING_DEV;
total: 1 errors, 0 warnings, 54 lines checked
Did you use git send-email or b4 send to send this patch?
>
> Signed-off-by: Poil Zero <poilandgginchi@gmail.com>
> ---
> drivers/cpufreq/rcpufreq_dt.rs | 8 +++++---
> rust/kernel/cpufreq.rs | 15 ++++++++++++++-
> 2 files changed, 19 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/cpufreq/rcpufreq_dt.rs b/drivers/cpufreq/rcpufreq_dt.rs
> index 2b1f18b..e0e1814 100644
> --- a/drivers/cpufreq/rcpufreq_dt.rs
> +++ b/drivers/cpufreq/rcpufreq_dt.rs
> @@ -60,7 +60,9 @@ impl opp::ConfigOps for CPUFreqDTDriver {}
> impl cpufreq::Driver for CPUFreqDTDriver {
> const NAME: &'static CStr = c"cpufreq-dt";
> const FLAGS: u16 = cpufreq::flags::NEED_INITIAL_FREQ_CHECK |
> cpufreq::flags::IS_COOLING_DEV;
> - const BOOST_ENABLED: bool = true;
> + // Keep the initial driver level boost state disabled and let the
> userspace enable it if
> + // required, like the C driver does.
> + const BOOST_ENABLED: bool = false;
>
> type PData = Arc<CPUFreqDTDevice>;
>
> @@ -190,8 +192,8 @@ impl cpufreq::Driver for CPUFreqDTDriver {
> policy.generic_get()
> }
>
> - fn set_boost(_policy: &mut cpufreq::Policy, _state: i32) -> Result {
> - Ok(())
> + fn set_boost(policy: &mut cpufreq::Policy, state: i32) -> Result {
> + policy.set_boost_sw(state)
> }
>
> fn register_em(policy: &mut cpufreq::Policy) {
> diff --git a/rust/kernel/cpufreq.rs b/rust/kernel/cpufreq.rs
> index f316711..ad01387 100644
> --- a/rust/kernel/cpufreq.rs
> +++ b/rust/kernel/cpufreq.rs
> @@ -544,6 +544,16 @@ impl Policy {
> Ok(unsafe { bindings::cpufreq_generic_get(u32::from(self.cpu())) })
> }
>
> + /// Provides a wrapper to the generic software boost routine.
> + ///
> + /// This recomputes the policy's `cpuinfo` limits from its
> frequency table, taking the
> + /// current driver and per-policy boost state into account.
> + #[inline]
> + pub fn set_boost_sw(&mut self, state: i32) -> Result {
> + // SAFETY: By the type invariant, the pointer stored in
> `self` is valid.
> + to_result(unsafe {
> bindings::cpufreq_boost_set_sw(self.as_mut_ref(), state) })
> + }
> +
> /// Provides a wrapper to the register with energy model using
> the OPP core.
> #[cfg(CONFIG_PM_OPP)]
> #[inline]
> @@ -741,7 +751,10 @@ pub trait Driver {
> /// Driver's flags.
> const FLAGS: u16;
>
> - /// Boost support.
> + /// Initial state of the driver level boost support.
> + ///
> + /// This maps to `cpufreq_driver.boost_enabled`. Boost support
> itself is advertised to the
> + /// core by implementing [`Driver::set_boost`].
> const BOOST_ENABLED: bool;
>
> /// Policy specific data.
--
Thx and BRs,
Zhongqiu Han
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-12-02 6:10 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-02 3:51 [PATCH] cpufreq: rcpufreq_dt: implement software boost support Poil Zero
2026-12-02 6:10 ` Zhongqiu Han
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox