Re: [PATCH v3 02/13] rust: hrtimer: introduce hrtimer support

From: Andreas Hindborg
Date: Wed Nov 20 2024 - 10:52:26 EST


"Thomas Gleixner" <tglx@xxxxxxxxxxxxx> writes:

> Andreas!
>
> On Thu, Oct 17 2024 at 15:04, Andreas Hindborg wrote:
>> +impl<T> Timer<T> {
>> + /// Return an initializer for a new timer instance.
>> + pub fn new() -> impl PinInit<Self>
>> + where
>> + T: TimerCallback,
>> + {
>> + pin_init!(Self {
>> + // INVARIANTS: We initialize `timer` with `hrtimer_init` below.
>> + timer <- Opaque::ffi_init(move |place: *mut bindings::hrtimer| {
>> + // SAFETY: By design of `pin_init!`, `place` is a pointer live
>> + // allocation. hrtimer_init will initialize `place` and does not
>> + // require `place` to be initialized prior to the call.
>> + unsafe {
>> + bindings::hrtimer_init(
>> + place,
>> + bindings::CLOCK_MONOTONIC as i32,
>> + bindings::hrtimer_mode_HRTIMER_MODE_REL,
>> + );
>> + }
>> +
>> + // SAFETY: `place` is pointing to a live allocation, so the deref
>> + // is safe.
>> + let function =
>> + unsafe { core::ptr::addr_of_mut!((*place).function) };
>
> I assume you are sending a new version of this series due to the
> reported build issue.
>
> If so, can you please rebase against
>
> git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git timers/core
>
> It contains the new hrtimer_setup() function, which initializes the
> timer including the callback function pointer.

Yes, I was going to rebase on `hrtimer_setup()`. I'll get it from tip or
upstream if it makes it in before I send the next one 👍


Best regards,
Andreas Hindborg