Guest User

enable-rcpufreq_dt-setpolicy.patch

a guest
Sep 30th, 2026
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 1.64 KB | Source Code | 0 0
  1. diff --git a/drivers/cpufreq/rcpufreq_dt.rs b/drivers/cpufreq/rcpufreq_dt.rs
  2. index d7ead60bf8c2..0e069c0054dd 100644
  3. --- a/drivers/cpufreq/rcpufreq_dt.rs
  4. +++ b/drivers/cpufreq/rcpufreq_dt.rs
  5. @@ -177,13 +177,30 @@ fn verify(data: &mut cpufreq::PolicyData) -> Result {
  6.          data.generic_verify()
  7.      }
  8.  
  9. -    fn target_index(policy: &mut cpufreq::Policy, index: cpufreq::TableIndex) -> Result {
  10. +    // EXPERIMENT ONLY: replaces `target_index` -- `cpufreq_register_driver()` rejects a
  11. +    // driver offering both (cpufreq.c:2928, `!!setpolicy == (target_index || target)`).
  12. +    //
  13. +    // Ported from `longrun_set_policy()` (drivers/cpufreq/longrun.c): apply the policy's
  14. +    // [min, max] window. longrun writes both bounds to MSRs and branches on
  15. +    // `policy->policy`; cpufreq-dt has a single OPP rate and the Rust `Policy` API exposes
  16. +    // no `policy->policy` accessor, so clamp the current rate into the window instead.
  17. +    fn setpolicy(policy: &mut cpufreq::Policy) -> Result {
  18. +        // `Policy::data()` borrows `policy` mutably, so read the limits first.
  19. +        let (min, max, cur) = (policy.min(), policy.max(), policy.cur());
  20. +
  21.          let Some(data) = policy.data::<Self::PData>() else {
  22.              return Err(ENOENT);
  23.          };
  24.  
  25. -        let freq = data.freq_table.freq(index)?;
  26. -        data.opp_table.set_rate(freq)
  27. +        let target = if cur.as_hz() < min.as_hz() {
  28. +            min
  29. +        } else if cur.as_hz() > max.as_hz() {
  30. +            max
  31. +        } else {
  32. +            cur
  33. +        };
  34. +
  35. +        data.opp_table.set_rate(target)
  36.      }
  37.  
  38.      fn get(policy: &mut cpufreq::Policy) -> Result<u32> {
  39.  
Add Comment
Please, Sign In to add comment