Lines Matching +full:self +full:- +full:power

1 // SPDX-License-Identifier: GPL-2.0
11 //! generic, they are used only at compile-time, so they shouldn't exist in the final binary.
37 //! use kernel::workqueue::{self, impl_has_work, new_work, Work, WorkItem};
47 //! impl HasWork<Self> for MyStruct { self.work }
51 //! fn new(value: i32) -> Result<Arc<Self>> {
54 //! work <- new_work!("MyStruct::work"),
79 //! use kernel::workqueue::{self, impl_has_work, new_work, Work, WorkItem};
92 //! impl HasWork<Self, 1> for MyStruct { self.work_1 }
93 //! impl HasWork<Self, 2> for MyStruct { self.work_2 }
97 //! fn new(value_1: i32, value_2: i32) -> Result<Arc<Self>> {
101 //! work_1 <- new_work!("MyStruct::work_1"),
102 //! work_2 <- new_work!("MyStruct::work_2"),
140 /// Creates a [`Work`] initialiser with the given name and a newly-created lock class.
158 // SAFETY: Accesses to workqueues used by [`Queue`] are thread-safe.
160 // SAFETY: Accesses to workqueues used by [`Queue`] are thread-safe.
170 pub unsafe fn from_raw<'a>(ptr: *const bindings::workqueue_struct) -> &'a Queue { in from_raw()
181 pub fn enqueue<W, const ID: u64>(&self, w: W) -> W::EnqueueOutput in enqueue() argument
185 let queue_ptr = self.0.get(); in enqueue()
213 &self, in try_spawn()
216 ) -> Result<(), AllocError> { in try_spawn()
218 work <- new_work!("Queue::try_spawn"), in try_spawn()
222 self.enqueue(KBox::pin_init(init, flags).map_err(|_| AllocError)?); in try_spawn()
238 fn project(self: Pin<&mut Self>) -> &mut Option<T> { in project()
240 unsafe { &mut self.get_unchecked_mut().func } in project()
245 type Pointer = Pin<KBox<Self>>;
247 fn run(mut this: Pin<KBox<Self>>) { in run() argument
256 /// This is the low-level trait that is designed for being as general as possible.
296 unsafe fn __enqueue<F>(self, queue_work_on: F) -> Self::EnqueueOutput in __enqueue() argument
298 F: FnOnce(*mut bindings::work_struct) -> bool; in __enqueue()
334 /// The pointer type that this struct is wrapped in. This will typically be `Arc<Self>` or
335 /// `Pin<KBox<Self>>`.
339 fn run(this: Self::Pointer); in run()
372 pub fn new(name: &'static CStr, key: &'static LockClassKey) -> impl PinInit<Self> in new()
376 pin_init!(Self { in new()
377 work <- Opaque::ffi_init(|slot| { in new()
401 pub unsafe fn raw_get(ptr: *const Self) -> *mut bindings::work_struct { in raw_get()
423 /// impl HasWork<MyWorkItem, 1> for MyWorkItem { self.work_field }
432 /// The [`OFFSET`] constant must be the offset of a field in `Self` of type [`Work<T, ID>`]. The
448 fn get_work_offset(&self) -> usize { in get_work_offset()
449 Self::OFFSET in get_work_offset()
456 /// The provided pointer must point at a valid struct of type `Self`.
458 unsafe fn raw_get_work(ptr: *mut Self) -> *mut Work<T, ID> { in raw_get_work()
460 unsafe { (ptr as *mut u8).add(Self::OFFSET) as *mut Work<T, ID> } in raw_get_work()
467 /// The pointer must point at a [`Work<T, ID>`] field in a struct of type `Self`.
469 unsafe fn work_container_of(ptr: *mut Work<T, ID>) -> *mut Self in work_container_of()
471 Self: Sized, in work_container_of()
475 unsafe { (ptr as *mut u8).sub(Self::OFFSET) as *mut Self } in work_container_of()
485 /// use kernel::workqueue::{self, impl_has_work, Work};
494 /// for MyStruct<'a, T, N> { self.work_field }
501 for $self:ty
502 { self.$field:ident }
506 unsafe impl$(<$($generics)+>)? $crate::workqueue::HasWork<$work_type $(, $id)?> for $self {
507 const OFFSET: usize = ::core::mem::offset_of!(Self, $field) as usize;
510 … unsafe fn raw_get_work(ptr: *mut Self) -> *mut $crate::workqueue::Work<$work_type $(, $id)?> {
522 impl{T} HasWork<Self> for ClosureWork<T> { self.work }
527 // - `__enqueue` gets the `work_struct` from the `Work` field, using `T::raw_get_work`.
528 // - The only safe way to create a `Work` object is through `Work::new`.
529 // - `Work::new` makes sure that `T::Pointer::run` is passed to `init_work_with_key`.
530 // - Finally `Work` and `RawWorkItem` guarantee that the correct `Work` field
536 T: WorkItem<ID, Pointer = Self>,
560 T: WorkItem<ID, Pointer = Self>,
563 type EnqueueOutput = Result<(), Self>;
565 unsafe fn __enqueue<F>(self, queue_work_on: F) -> Self::EnqueueOutput in __enqueue() argument
567 F: FnOnce(*mut bindings::work_struct) -> bool, in __enqueue()
570 let ptr = Arc::into_raw(self).cast_mut(); in __enqueue()
589 T: WorkItem<ID, Pointer = Self>,
609 T: WorkItem<ID, Pointer = Self>,
614 unsafe fn __enqueue<F>(self, queue_work_on: F) -> Self::EnqueueOutput in __enqueue() argument
616 F: FnOnce(*mut bindings::work_struct) -> bool, in __enqueue()
618 // SAFETY: We're not going to move `self` or any of its fields, so its okay to temporarily in __enqueue()
620 let boxed = unsafe { Pin::into_inner_unchecked(self) }; in __enqueue()
638 /// It is the one used by `schedule[_delayed]_work[_on]()`. Multi-CPU multi-threaded. There are
642 pub fn system() -> &'static Queue { in system()
647 /// Returns the system high-priority work queue (`system_highpri_wq`).
651 pub fn system_highpri() -> &'static Queue { in system_highpri()
656 /// Returns the system work queue for potentially long-running work items (`system_long_wq`).
660 pub fn system_long() -> &'static Queue { in system_long()
670 pub fn system_unbound() -> &'static Queue { in system_unbound()
681 pub fn system_freezable() -> &'static Queue { in system_freezable()
686 /// Returns the system power-efficient work queue (`system_power_efficient_wq`).
688 /// It is inclined towards saving power and is converted to "unbound" variants if the
691 pub fn system_power_efficient() -> &'static Queue { in system_power_efficient()
696 /// Returns the system freezable power-efficient work queue (`system_freezable_power_efficient_wq`).
702 pub fn system_freezable_power_efficient() -> &'static Queue { in system_freezable_power_efficient()