From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-10631.protonmail.ch (mail-10631.protonmail.ch [79.135.106.31]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2B1862638A3 for ; Thu, 20 Feb 2025 23:47:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=79.135.106.31 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740095260; cv=none; b=HalBHCCt/BLuziTfxDpUlatVphMlSQ0hIkN41yhFGNf80PPmU7x13K4LggivqX5/bUV5wIHfxmvgZ/hwiDBi/fFWS9ZKEC/TW2SRm4jK+3g6+AKMWLC5tdJM9CB6Bz5TG4HY8+0nKw4XV5uM0LWUa1L8L/+DlZD6SDrKny3Xxzw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740095260; c=relaxed/simple; bh=w4T+ah5JQ4iTdSqvx3oac5Qkn0xWU1VeqbTpWFAvsOg=; h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=ABmALSU6vip2qwUVyyFtYWonHvwx1+GbkPkFzdKxeBuiJRHMqaQ8DXM72JzoH6fLIiTbdA96Vc+Viph54Henhe0UhxUuzgFrMT26nRgTLpxPkfvS0+j0iNk+e0uTt3872tqmpUvS2l+0EZZQKT+75+cvDe2Z4JJQ50+5wEMAgDc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=proton.me; spf=pass smtp.mailfrom=proton.me; dkim=pass (2048-bit key) header.d=proton.me header.i=@proton.me header.b=anElHFl+; arc=none smtp.client-ip=79.135.106.31 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=proton.me Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=proton.me Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=proton.me header.i=@proton.me header.b="anElHFl+" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=proton.me; s=vxt2o2rruvf2dl4kokok72a5ha.protonmail; t=1740095255; x=1740354455; bh=j5eID5FuIaYQp8zzP16hSMfM0CmS/MS5iWnefkVTiRU=; h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References: Feedback-ID:From:To:Cc:Date:Subject:Reply-To:Feedback-ID: Message-ID:BIMI-Selector:List-Unsubscribe:List-Unsubscribe-Post; b=anElHFl+SurPlTO0kvSIz0NlSPmGlTo2bxlUJI3w6AclZrCAhW03nO6Q2heuLAEJK yJsCWW3H/g6MExV5WNF6uJk/IQnlhYknqAAdaNxoAT8lxGcwUnlA60Q+j5RuuxL2P6 ZcjQ7LW8MOToDgT2C8PtRw8FAJiNIG03SQdFXV8HJabqWvwlrr/aiXADJJ1ybj2qlz G/FDYSqNNhBlkJmyeyD2uRnE4lJWZkz7zqRUzuPPSjh6XSE2ChsTD/N6voYytNg/ln 4dLC3ZURK91Zq+RADBydbB3Qxi09DrCWbh4gEEIyMSzb+mOPCDfQte6rQytcK4hPLM NLmpKGZ0uawDA== Date: Thu, 20 Feb 2025 23:47:30 +0000 To: Andreas Hindborg , Miguel Ojeda , Anna-Maria Behnsen , Frederic Weisbecker , Thomas Gleixner , Danilo Krummrich From: Benno Lossin Cc: Alex Gaynor , Boqun Feng , Gary Guo , =?utf-8?Q?Bj=C3=B6rn_Roy_Baron?= , Alice Ryhl , Trevor Gross , Lyude Paul , Guangbo Cui <2407018371@qq.com>, Dirk Behme , Daniel Almeida , Tamir Duberstein , rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v8 05/14] rust: hrtimer: allow timer restart from timer handler Message-ID: <8e32c3e1-0b55-4809-92ad-f968252a05f8@proton.me> In-Reply-To: <20250218-hrtimer-v3-v6-12-rc2-v8-5-48dedb015eb3@kernel.org> References: <20250218-hrtimer-v3-v6-12-rc2-v8-0-48dedb015eb3@kernel.org> <20250218-hrtimer-v3-v6-12-rc2-v8-5-48dedb015eb3@kernel.org> Feedback-ID: 71780778:user:proton X-Pm-Message-ID: 767350196db5980b1a5d90fe6a7915a1a9f9791a Precedence: bulk X-Mailing-List: rust-for-linux@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 18.02.25 14:27, Andreas Hindborg wrote: > This patch allows timer handlers to report that they want a timer to be > restarted after the timer handler has finished executing. >=20 > Also update the `hrtimer` documentation to showcase the new feature. >=20 > Signed-off-by: Andreas Hindborg > --- > rust/kernel/time/hrtimer.rs | 28 +++++++++++++++++++++++++++- > rust/kernel/time/hrtimer/arc.rs | 4 +--- > 2 files changed, 28 insertions(+), 4 deletions(-) >=20 > diff --git a/rust/kernel/time/hrtimer.rs b/rust/kernel/time/hrtimer.rs > index b2a3130bc21d7..e342193f985eb 100644 > --- a/rust/kernel/time/hrtimer.rs > +++ b/rust/kernel/time/hrtimer.rs > @@ -183,7 +183,7 @@ pub trait HrTimerCallback { > type CallbackTargetParameter<'a>; >=20 > /// Called by the timer logic when the timer fires. > - fn run(this: Self::CallbackTargetParameter<'_>) > + fn run(this: Self::CallbackTargetParameter<'_>) -> HrTimerRestart > where > Self: Sized; > } > @@ -278,6 +278,32 @@ unsafe fn start(self_ptr: *const Self, expires: Ktim= e) { > } > } >=20 > +/// Restart policy for timers. > +pub enum HrTimerRestart { > + /// Timer should not be restarted. > + NoRestart, > + /// Timer should be restarted. > + Restart, > +} > + > +impl From for HrTimerRestart { > + fn from(value: u32) -> Self { > + match value { > + bindings::hrtimer_restart_HRTIMER_NORESTART =3D> Self::NoRes= tart, > + _ =3D> Self::Restart, > + } > + } > +} > + > +impl From for bindings::hrtimer_restart { > + fn from(value: HrTimerRestart) -> Self { > + match value { > + HrTimerRestart::NoRestart =3D> bindings::hrtimer_restart_HRT= IMER_NORESTART, > + HrTimerRestart::Restart =3D> bindings::hrtimer_restart_HRTIM= ER_RESTART, > + } > + } > +} Do drivers need these impls? If no, I would prefer a private conversion function just for the abstraction. --- Cheers, Benno > + > /// Use to implement the [`HasHrTimer`] trait. > /// > /// See [`module`] documentation for an example. > diff --git a/rust/kernel/time/hrtimer/arc.rs b/rust/kernel/time/hrtimer/a= rc.rs > index d1c90631d0036..109eded0e73be 100644 > --- a/rust/kernel/time/hrtimer/arc.rs > +++ b/rust/kernel/time/hrtimer/arc.rs > @@ -82,8 +82,6 @@ impl RawHrTimerCallback for Arc > // timer. This `T` is contained in an `Arc`. > let receiver =3D unsafe { ArcBorrow::from_raw(data_ptr) }; >=20 > - T::run(receiver); > - > - bindings::hrtimer_restart_HRTIMER_NORESTART > + T::run(receiver).into() > } > } >=20 > -- > 2.47.0 >=20 >=20