Linux Power Management development
 help / color / mirror / Atom feed
From: Zhongqiu Han <zhongqiu.han@oss.qualcomm.com>
To: Poil Zero <poilandgginchi@gmail.com>,
	Viresh Kumar <viresh.kumar@linaro.org>,
	"Rafael J. Wysocki" <rafael@kernel.org>
Cc: linux-pm@vger.kernel.org, rust-for-linux@vger.kernel.org,
	Zhongqiu Han <zhongqiu.han@oss.qualcomm.com>
Subject: Re: [PATCH] cpufreq: rcpufreq_dt: implement software boost support
Date: Wed, 2 Dec 2026 14:10:32 +0800	[thread overview]
Message-ID: <25793eb0-8693-4357-9e27-e57d8560edaa@oss.qualcomm.com> (raw)
In-Reply-To: <CAGdLfDcMMwScX1wxirX_nyk2aR7NU1AqZ2XrG-5Xb_hcbc8EdA@mail.gmail.com>

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

      reply	other threads:[~2026-12-02  6:10 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-02  3:51 [PATCH] cpufreq: rcpufreq_dt: implement software boost support Poil Zero
2026-12-02  6:10 ` Zhongqiu Han [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=25793eb0-8693-4357-9e27-e57d8560edaa@oss.qualcomm.com \
    --to=zhongqiu.han@oss.qualcomm.com \
    --cc=linux-pm@vger.kernel.org \
    --cc=poilandgginchi@gmail.com \
    --cc=rafael@kernel.org \
    --cc=rust-for-linux@vger.kernel.org \
    --cc=viresh.kumar@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox