mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Mark Brown <broonie@kernel.org>
To: Andreas Hindborg <a.hindborg@kernel.org>
Cc: FUJITA Tomonori <fujita.tomonori@gmail.com>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	Linux Next Mailing List <linux-next@vger.kernel.org>
Subject: linux-next: manual merge of the rust-xarray tree with the rust-timekeeping tree
Date: Thu, 26 Nov 2026 13:54:21 +0000	[thread overview]
Message-ID: <awg6DVNXrqmlwbfu@sirena.org.uk> (raw)

[-- Attachment #1: Type: text/plain, Size: 4533 bytes --]

Hi all,

Today's linux-next merge of the rust-xarray tree got a conflict in:

  rust/kernel/time/hrtimer.rs

between commits:

  8a914f7625e4e ("rust: time: remove leftover "clock source" wording from doc comments")
  6b391eec2ddeb ("rust: hrtimer: Remove HrTimer::expires()")

from the rust-timekeeping tree and commit:

  5c057c3a0b980 ("rust: hrtimer: add active() method to query timer state")

from the rust-xarray tree.

I fixed it up (see below) and can carry the fix as necessary. This
is now fixed as far as linux-next is concerned, but any non trivial
conflicts should be mentioned to your upstream maintainer when your tree
is submitted for merging.  You may also want to consider cooperating
with the maintainer of the conflicting tree to minimise any particularly
complex conflicts.

diff --cc rust/kernel/time/hrtimer.rs
index d1ca2441f9bbf,e960821ace3bd..0000000000000
--- a/rust/kernel/time/hrtimer.rs
+++ b/rust/kernel/time/hrtimer.rs
@@@ -569,6 -572,91 +571,68 @@@ impl<T> HrTimer<T> 
      {
          self.forward(HrTimerInstant::<T>::now(), interval)
      }
+ 
 -    /// Return the time expiry for this [`HrTimer`].
 -    ///
 -    /// This value should only be used as a snapshot, as the actual expiry time could change after
 -    /// this function is called.
 -    pub fn expires(&self) -> HrTimerInstant<T>
 -    where
 -        T: HasHrTimer<T>,
 -    {
 -        // SAFETY: `self` is an immutable reference and thus always points to a valid `HrTimer`.
 -        let c_timer_ptr = unsafe { HrTimer::raw_get(self) };
 -
 -        // SAFETY:
 -        // - Timers cannot have negative ktime_t values as their expiration time.
 -        // - There's no actual locking here, a racy read is fine and expected
 -        unsafe {
 -            Instant::from_ktime(
 -                // This `read_volatile` is intended to correspond to a READ_ONCE call.
 -                // FIXME(read_once): Replace with `read_once` when available on the Rust side.
 -                core::ptr::read_volatile(&raw const ((*c_timer_ptr).node.expires)),
 -            )
 -        }
 -    }
 -
+     /// Query the state of the timer.
+     ///
+     /// Returns [`true`] if the timer is in the started or running states.
+     ///
+     /// This method synchronizes internally and does not require exclusive access to the timer.
+     ///
+     /// The returned value is a snapshot. A concurrent event can change the state of the timer
+     /// right after this method returns, so callers that need the state to be stable must serialize
+     /// against such events by other means.
+     ///
+     /// # Examples
+     ///
+     /// ```
+     /// # use kernel::{
+     /// #     impl_has_hr_timer,
+     /// #     prelude::*,
+     /// #     time::{
+     /// #         hrtimer::{
+     /// #             HasHrTimer, HrTimer, HrTimerCallback, HrTimerCallbackContext,
+     /// #             HrTimerRestart, RelativeMode,
+     /// #         },
+     /// #         Monotonic,
+     /// #     },
+     /// # };
+     /// # use pin_init::stack_pin_init;
+     /// #[pin_data]
+     /// struct ExampleTimer {
+     ///     #[pin]
+     ///     timer: HrTimer<Self>,
+     /// }
+     ///
+     /// impl ExampleTimer {
+     ///     fn new() -> impl PinInit<Self> {
+     ///         pin_init!(Self { timer <- HrTimer::new() })
+     ///     }
+     /// }
+     ///
+     /// impl HrTimerCallback for ExampleTimer {
+     ///     type Pointer<'a> = Pin<&'a Self>;
+     ///     fn run(_this: Pin<&Self>, _ctx: HrTimerCallbackContext<'_, Self>) -> HrTimerRestart {
+     ///         HrTimerRestart::NoRestart
+     ///     }
+     /// }
+     ///
+     /// impl_has_hr_timer! {
+     ///     impl HasHrTimer<Self> for ExampleTimer {
+     ///         mode: RelativeMode<Monotonic>, field: self.timer
+     ///     }
+     /// }
+     ///
+     /// stack_pin_init!(let has_timer = ExampleTimer::new());
+     /// assert!(!has_timer.timer.active());
+     /// # Ok::<(), kernel::error::Error>(())
+     /// ```
+     #[inline]
+     pub fn active(&self) -> bool {
+         // SAFETY: By type invariant, `self.timer` is valid. `hrtimer_active`
+         // synchronizes internally and is safe to call without exclusive
+         // access to the timer.
+         unsafe { bindings::hrtimer_active(self.timer.get()) }
+     }
  }
  
  /// Implemented by pointer types that point to structs that contain a [`HrTimer`].

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

                 reply	other threads:[~2026-11-26 13:54 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=awg6DVNXrqmlwbfu@sirena.org.uk \
    --to=broonie@kernel.org \
    --cc=a.hindborg@kernel.org \
    --cc=fujita.tomonori@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-next@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®