Lines Matching +full:reference +full:- +full:sync

1 // SPDX-License-Identifier: GPL-2.0
9 //! Reference: <https://docs.kernel.org/power/opp.html>
19 sync::aref::{ARef, AlwaysRefCounted},
40 pub(crate) fn new(table: &Table) -> Result<Self> {
55 /// Returns a reference to the underlying [`cpufreq::Table`].
57 fn table(&self) -> &cpufreq::Table {
67 fn deref(&self) -> &Self::Target {
90 /// Creates a null-terminated slice of pointers to [`CString`]s.
91 fn to_c_str_array(names: &[CString]) -> Result<KVec<*const c_char>> {
92 // Allocated a null-terminated vector of pointers.
123 fn from(volt: MicroVolt) -> Self {
148 fn from(power: MicroWatt) -> Self {
166 /// use kernel::sync::aref::ARef;
168 /// fn create_opp(dev: &ARef<Device>, freq: Hertz, volt: MicroVolt, level: u32) -> Result<Token> {
182 fn new(dev: &ARef<Device>, mut data: Data) -> Result<Self> {
215 /// use kernel::sync::aref::ARef;
217 /// fn create_opp(dev: &ARef<Device>, freq: Hertz, volt: MicroVolt, level: u32) -> Result<Token> {
231 pub fn new(freq: Hertz, volt: MicroVolt, level: u32, turbo: bool) -> Self {
245 pub fn add_opp(self, dev: &ARef<Device>) -> Result<Token> {
251 fn freq(&self) -> Hertz {
266 /// use kernel::sync::aref::ARef;
268 /// fn find_opp(table: &Table, freq: Hertz) -> Result<ARef<OPP>> {
296 fn config_clks(_dev: &Device, _table: &Table, _opp: &OPP, _scaling_down: bool) -> Result {
308 ) -> Result {
332 /// The following example demonstrates how to set OPP property-name configuration for a [`Device`].
339 /// use kernel::sync::aref::ARef;
348 /// fn configure(dev: &ARef<Device>) -> Result<ConfigToken> {
375 pub fn new() -> Self {
380 pub fn set_clk_names(mut self, names: KVec<CString>) -> Result<Self> {
394 pub fn set_prop_name(mut self, name: CString) -> Result<Self> {
404 pub fn set_regulator_names(mut self, names: KVec<CString>) -> Result<Self> {
419 pub fn set_required_dev(mut self, dev: ARef<Device>, index: u32) -> Result<Self> {
429 pub fn set_supported_hw(mut self, hw: KVec<u32>) -> Result<Self> {
445 pub fn set(self, dev: &Device) -> Result<ConfigToken> {
507 let _: &dyn Fn() -> _ = &set_config;
521 ) -> c_int {
546 ) -> c_int {
564 /// A reference-counted OPP table.
570 /// The pointer stored in `Self` is non-null and valid for the lifetime of the [`Table`].
572 /// Instances of this type are reference-counted.
586 /// use kernel::sync::aref::ARef;
588 /// fn get_table(dev: &ARef<Device>, mask: &mut Cpumask, freq: Hertz) -> Result<Table> {
617 unsafe impl Sync for Table {}
620 /// Creates a new reference-counted [`Table`] from a raw pointer.
624 /// Callers must ensure that `ptr` is valid and non-null.
625 unsafe fn from_raw_table(ptr: *mut bindings::opp_table, dev: &ARef<Device>) -> Self {
628 // INVARIANT: The reference-count is decremented when [`Table`] goes out of scope.
640 /// Creates a new reference-counted [`Table`] instance for a [`Device`].
641 pub fn from_dev(dev: &Device) -> Result<Self> {
645 // INVARIANT: The reference-count is incremented by the C code and is decremented when
658 /// Creates a new reference-counted [`Table`] instance for a [`Device`] based on device tree
661 pub fn from_of(dev: &ARef<Device>, index: i32) -> Result<Self> {
665 // INVARIANT: The reference-count is incremented by the C code and is decremented when
681 // requirements. We took the reference from [`from_of`] earlier, it is safe to drop the
686 /// Creates a new reference-counted [`Table`] instance for a [`Cpumask`] based on device tree
689 pub fn from_of_cpumask(dev: &Device, cpumask: &mut Cpumask) -> Result<Self> {
693 // INVARIANT: The reference-count is incremented by the C code and is decremented when
708 // SAFETY: The cpumask is valid and we took the reference from [`from_of_cpumask`] earlier,
714 pub fn opp_count(&self) -> Result<u32> {
724 pub fn max_clock_latency_ns(&self) -> usize {
732 pub fn max_volt_latency_ns(&self) -> usize {
740 pub fn max_transition_latency_ns(&self) -> usize {
748 pub fn suspend_freq(&self) -> Hertz {
756 pub fn sync_regulators(&self) -> Result {
764 pub fn sharing_cpus(dev: &Device, cpumask: &mut Cpumask) -> Result {
771 pub fn set_sharing_cpus(&mut self, cpumask: &mut Cpumask) -> Result {
789 pub fn of_sharing_cpus(dev: &Device, cpumask: &mut Cpumask) -> Result {
805 ) -> Result {
822 pub fn cpufreq_table(&mut self) -> Result<FreqTable> {
828 pub fn set_rate(&self, freq: Hertz) -> Result {
836 pub fn set_opp(&self, opp: &OPP) -> Result {
849 ) -> Result<ARef<OPP>> {
888 pub fn opp_from_level(&self, mut level: u32, stype: SearchType) -> Result<ARef<OPP>> {
914 pub fn opp_from_bw(&self, mut bw: u32, index: i32, stype: SearchType) -> Result<ARef<OPP>> {
940 pub fn enable_opp(&self, freq: Hertz) -> Result {
948 pub fn disable_opp(&self, freq: Hertz) -> Result {
956 pub fn of_register_em(&mut self, cpumask: &mut Cpumask) -> Result {
979 // SAFETY: By the type invariants, we know that `self` owns a reference, so it is safe
999 /// A reference-counted Operating performance point (OPP).
1005 /// The pointer stored in `Self` is non-null and valid for the lifetime of the [`OPP`].
1007 /// Instances of this type are reference-counted. The reference count is incremented by the
1009 /// represents a pointer that owns a reference count on the [`OPP`].
1011 /// A reference to the [`OPP`], &[`OPP`], isn't refcounted by the Rust code.
1023 /// fn configure_opp(table: &Table, freq: Hertz) -> Result {
1041 unsafe impl Sync for OPP {}
1047 // SAFETY: The existence of a shared reference means that the refcount is nonzero.
1059 /// Creates an owned reference to a [`OPP`] from a valid pointer.
1070 pub unsafe fn from_raw_opp_owned(ptr: *mut bindings::dev_pm_opp) -> Result<ARef<Self>> {
1075 // INVARIANT: The reference-count is decremented when [`OPP`] goes out of scope.
1079 /// Creates a reference to a [`OPP`] from a valid pointer.
1081 /// The refcount is not updated by the Rust API unless the returned reference is converted to
1088 pub unsafe fn from_raw_opp<'a>(ptr: *mut bindings::dev_pm_opp) -> Result<&'a Self> {
1095 fn as_raw(&self) -> *mut bindings::dev_pm_opp {
1101 pub fn freq(&self, index: Option<u32>) -> Hertz {
1104 // SAFETY: By the type invariants, we know that `self` owns a reference, so it is safe to
1111 pub fn voltage(&self) -> MicroVolt {
1112 // SAFETY: By the type invariants, we know that `self` owns a reference, so it is safe to
1119 pub fn level(&self) -> u32 {
1120 // SAFETY: By the type invariants, we know that `self` owns a reference, so it is safe to
1127 pub fn power(&self) -> MicroWatt {
1128 // SAFETY: By the type invariants, we know that `self` owns a reference, so it is safe to
1135 pub fn required_pstate(&self, index: u32) -> u32 {
1136 // SAFETY: By the type invariants, we know that `self` owns a reference, so it is safe to
1143 pub fn is_turbo(&self) -> bool {
1144 // SAFETY: By the type invariants, we know that `self` owns a reference, so it is safe to