[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAJ-ks9mykUNSVX=_OFFEV6RokVsRe5zXharG68j1Ag=CeW-77w@mail.gmail.com>
Date: Sun, 9 Mar 2025 11:37:10 -0400
From: Tamir Duberstein <tamird@...il.com>
To: Andreas Hindborg <a.hindborg@...nel.org>
Cc: Miguel Ojeda <ojeda@...nel.org>, Anna-Maria Behnsen <anna-maria@...utronix.de>,
Frederic Weisbecker <frederic@...nel.org>, Thomas Gleixner <tglx@...utronix.de>,
Danilo Krummrich <dakr@...nel.org>, Alex Gaynor <alex.gaynor@...il.com>,
Boqun Feng <boqun.feng@...il.com>, Gary Guo <gary@...yguo.net>,
Björn Roy Baron <bjorn3_gh@...tonmail.com>,
Benno Lossin <benno.lossin@...ton.me>, Alice Ryhl <aliceryhl@...gle.com>,
Trevor Gross <tmgross@...ch.edu>, Lyude Paul <lyude@...hat.com>, Guangbo Cui <2407018371@...com>,
Dirk Behme <dirk.behme@...il.com>, Daniel Almeida <daniel.almeida@...labora.com>,
Markus Elfring <Markus.Elfring@....de>, rust-for-linux@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH v12 04/13] rust: hrtimer: allow timer restart from timer handler
On Sun, Mar 9, 2025 at 11:22 AM Andreas Hindborg <a.hindborg@...nel.org> wrote:
>
> Allow timer handlers to report that they want a timer to be restarted after
> the timer handler has finished executing.
>
> Acked-by: Frederic Weisbecker <frederic@...nel.org>
> Reviewed-by: Benno Lossin <benno.lossin@...ton.me>
> Signed-off-by: Andreas Hindborg <a.hindborg@...nel.org>
> ---
> rust/kernel/time/hrtimer.rs | 18 +++++++++++++++++-
> rust/kernel/time/hrtimer/arc.rs | 4 +---
> 2 files changed, 18 insertions(+), 4 deletions(-)
>
> diff --git a/rust/kernel/time/hrtimer.rs b/rust/kernel/time/hrtimer.rs
> index c6d6eaed31aa..78afb093aee8 100644
> --- a/rust/kernel/time/hrtimer.rs
> +++ b/rust/kernel/time/hrtimer.rs
> @@ -212,7 +212,7 @@ pub trait HrTimerCallback {
> type Pointer<'a>: RawHrTimerCallback;
>
> /// Called by the timer logic when the timer fires.
> - fn run(this: <Self::Pointer<'_> as RawHrTimerCallback>::CallbackTarget<'_>)
> + fn run(this: <Self::Pointer<'_> as RawHrTimerCallback>::CallbackTarget<'_>) -> HrTimerRestart
> where
> Self: Sized;
> }
> @@ -312,6 +312,22 @@ unsafe fn start(this: *const Self, expires: Ktime) {
> }
> }
>
> +/// Restart policy for timers.
> +#[derive(Copy, Clone, PartialEq, Eq, Debug)]
> +#[repr(u32)]
> +pub enum HrTimerRestart {
> + /// Timer should not be restarted.
> + NoRestart = bindings::hrtimer_restart_HRTIMER_NORESTART,
> + /// Timer should be restarted.
> + Restart = bindings::hrtimer_restart_HRTIMER_RESTART,
> +}
Instead of writing this enum by hand, could we use the
`--rustified-enum` option to bindgen? I added `--rustified-enum
hrtimer_restart` in `rust/bindgen_parameters` and the result was
#[repr(u32)]
#[derive(Copy, Clone, Hash, PartialEq, Eq)]
pub enum hrtimer_restart {
HRTIMER_NORESTART = 0,
HRTIMER_RESTART = 1,
}
what do you think? This can be revisited, so either way:
Reviewed-by: Tamir Duberstein <tamird@...il.com>
Powered by blists - more mailing lists