pub struct Policy(/* private fields */);
Expand description
CPU frequency policy.
Rust abstraction for the C struct cpufreq_policy
.
§Invariants
A Policy
instance always corresponds to a valid C struct cpufreq_policy
.
The callers must ensure that the struct cpufreq_policy
is valid for access and remains valid
for the lifetime of the returned reference.
§Examples
The following example demonstrates how to create a CPU frequency table.
use kernel::cpufreq::{ETERNAL_LATENCY_NS, Policy};
fn update_policy(policy: &mut Policy) {
policy
.set_dvfs_possible_from_any_cpu(true)
.set_fast_switch_possible(true)
.set_transition_latency_ns(ETERNAL_LATENCY_NS);
pr_info!("The policy details are: {:?}\n", (policy.cpu(), policy.cur()));
}
Implementations§
Source§impl Policy
impl Policy
Sourcepub unsafe fn from_raw<'a>(ptr: *const cpufreq_policy) -> &'a Self
pub unsafe fn from_raw<'a>(ptr: *const cpufreq_policy) -> &'a Self
Creates a reference to an existing struct cpufreq_policy
pointer.
§Safety
The caller must ensure that ptr
is valid for reading and remains valid for the lifetime
of the returned reference.
Sourcepub unsafe fn from_raw_mut<'a>(ptr: *mut cpufreq_policy) -> &'a mut Self
pub unsafe fn from_raw_mut<'a>(ptr: *mut cpufreq_policy) -> &'a mut Self
Creates a mutable reference to an existing struct cpufreq_policy
pointer.
§Safety
The caller must ensure that ptr
is valid for writing and remains valid for the lifetime
of the returned reference.
Sourcepub fn suspend_freq(&self) -> Hertz
pub fn suspend_freq(&self) -> Hertz
Returns the suspend frequency for the Policy
.
Sourcepub fn set_suspend_freq(&mut self, freq: Hertz) -> &mut Self
pub fn set_suspend_freq(&mut self, freq: Hertz) -> &mut Self
Sets the suspend frequency for the Policy
.
Sourcepub fn generic_suspend(&mut self) -> Result<()>
pub fn generic_suspend(&mut self) -> Result<()>
Provides a wrapper to the generic suspend routine.
Sourcepub fn generic_get(&self) -> Result<u32>
pub fn generic_get(&self) -> Result<u32>
Provides a wrapper to the generic get routine.
Sourcepub fn register_em_opp(&mut self)
pub fn register_em_opp(&mut self)
Provides a wrapper to the register with energy model using the OPP core.
Sourcepub fn cpus(&mut self) -> &mut Cpumask
pub fn cpus(&mut self) -> &mut Cpumask
Gets cpumask::Cpumask
for a cpufreq Policy
.
Sourcepub fn set_dvfs_possible_from_any_cpu(&mut self, val: bool) -> &mut Self
pub fn set_dvfs_possible_from_any_cpu(&mut self, val: bool) -> &mut Self
Allows / disallows frequency switching code to run on any CPU.
Sourcepub fn fast_switch_possible(&self) -> bool
pub fn fast_switch_possible(&self) -> bool
Returns if fast switching of frequencies is possible or not.
Sourcepub fn set_fast_switch_possible(&mut self, val: bool) -> &mut Self
pub fn set_fast_switch_possible(&mut self, val: bool) -> &mut Self
Enables / disables fast frequency switching.
Sourcepub fn set_transition_latency_ns(&mut self, latency_ns: u32) -> &mut Self
pub fn set_transition_latency_ns(&mut self, latency_ns: u32) -> &mut Self
Sets transition latency (in nanoseconds) for the Policy
.
Sourcepub fn set_cpuinfo_min_freq(&mut self, min_freq: Hertz) -> &mut Self
pub fn set_cpuinfo_min_freq(&mut self, min_freq: Hertz) -> &mut Self
Sets cpuinfo min_freq
.
Sourcepub fn set_cpuinfo_max_freq(&mut self, max_freq: Hertz) -> &mut Self
pub fn set_cpuinfo_max_freq(&mut self, max_freq: Hertz) -> &mut Self
Sets cpuinfo max_freq
.
Sourcepub fn set_transition_delay_us(&mut self, transition_delay_us: u32) -> &mut Self
pub fn set_transition_delay_us(&mut self, transition_delay_us: u32) -> &mut Self
Set transition_delay_us
, i.e. the minimum time between successive frequency change
requests.