git: 9273fe8ed2ad - main - linuxkpi: Add `hrtimer_setup()`
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Mon, 07 Sep 2026 20:32:30 UTC
The branch main has been updated by dumbbell:
URL: https://cgit.FreeBSD.org/src/commit/?id=9273fe8ed2addad2179227d444f9f8ab63b942a1
commit 9273fe8ed2addad2179227d444f9f8ab63b942a1
Author: Jean-Sébastien Pédron <dumbbell@FreeBSD.org>
AuthorDate: 2026-08-15 18:31:05 +0000
Commit: Jean-Sébastien Pédron <dumbbell@FreeBSD.org>
CommitDate: 2026-09-07 20:31:39 +0000
linuxkpi: Add `hrtimer_setup()`
`hrtimer_setup()` replaces `hrtimer_init()` in Linux 6.15. The API and
the role are the same, except:
* it takes the `function` callback as argument
* if `function` is NULL, it assigns a default callback
At the same time, we hide `hrtimer_init()` if LINUXKPI_VERSION is
greater than or equal to 61500 because it was dropped in Linux 6.15.
Reviewed by: bz
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D58757
---
sys/compat/linuxkpi/common/include/linux/hrtimer.h | 19 +++++++++++++++++++
sys/compat/linuxkpi/common/src/linux_hrtimer.c | 17 +++++++++++++++++
2 files changed, 36 insertions(+)
diff --git a/sys/compat/linuxkpi/common/include/linux/hrtimer.h b/sys/compat/linuxkpi/common/include/linux/hrtimer.h
index 88f9487d0b85..14977431ade6 100644
--- a/sys/compat/linuxkpi/common/include/linux/hrtimer.h
+++ b/sys/compat/linuxkpi/common/include/linux/hrtimer.h
@@ -55,11 +55,20 @@ struct hrtimer {
#define hrtimer_try_to_cancel(hrtimer) linux_hrtimer_try_to_cancel(hrtimer)
#define hrtimer_cancel(hrtimer) linux_hrtimer_cancel(hrtimer)
+/* hrtimer_init() is replaced by hrtimer_setup() in Linux 6.15. */
+#if defined(LINUXKPI_VERSION) && LINUXKPI_VERSION < 61500
#define hrtimer_init(hrtimer, clock, mode) do { \
CTASSERT((clock) == CLOCK_MONOTONIC); \
CTASSERT((mode) == HRTIMER_MODE_REL); \
linux_hrtimer_init(hrtimer); \
} while (0)
+#endif
+
+#define hrtimer_setup(hrtimer, restart, clock, mode) do { \
+ CTASSERT((clock) == CLOCK_MONOTONIC); \
+ CTASSERT((mode) == HRTIMER_MODE_REL); \
+ linuxkpi_hrtimer_setup(hrtimer, restart); \
+} while (0)
#define hrtimer_set_expires(hrtimer, time) \
linux_hrtimer_set_expires(hrtimer, time)
@@ -81,10 +90,20 @@ struct hrtimer {
bool linux_hrtimer_active(struct hrtimer *);
int linux_hrtimer_try_to_cancel(struct hrtimer *);
int linux_hrtimer_cancel(struct hrtimer *);
+/*
+ * The corresponding `hrtimer_init()` was dropped in Linux 6.15, thus the "#if
+ * LINUXKPI_VERSION < 61500" above. We keep this prototype here though because
+ * the underlying `linux_hrtimer_init()` is used by `linuxkpi_hrtimer_setup()`.
+ */
void linux_hrtimer_init(struct hrtimer *);
+void linuxkpi_hrtimer_setup(struct hrtimer *hrtimer,
+ enum hrtimer_restart (*function)(struct hrtimer *));
void linux_hrtimer_set_expires(struct hrtimer *, ktime_t);
void linux_hrtimer_start(struct hrtimer *, ktime_t);
void linux_hrtimer_start_range_ns(struct hrtimer *, ktime_t, int64_t);
void linux_hrtimer_forward_now(struct hrtimer *, ktime_t);
+enum hrtimer_restart linuxkpi_hrtimer_dummy_timeout(struct hrtimer *unused);
+#define hrtimer_dummy_timeout(hrtimer) linuxkpi_hrtimer_dummy_timeout(hrtimer)
+
#endif /* _LINUXKPI_LINUX_HRTIMER_H_ */
diff --git a/sys/compat/linuxkpi/common/src/linux_hrtimer.c b/sys/compat/linuxkpi/common/src/linux_hrtimer.c
index dca5d5cf709b..bbd99dec2d83 100644
--- a/sys/compat/linuxkpi/common/src/linux_hrtimer.c
+++ b/sys/compat/linuxkpi/common/src/linux_hrtimer.c
@@ -105,6 +105,23 @@ linux_hrtimer_init(struct hrtimer *hrtimer)
callout_init_mtx(&hrtimer->callout, &hrtimer->mtx, 0);
}
+enum hrtimer_restart
+linuxkpi_hrtimer_dummy_timeout(struct hrtimer *unused __unused)
+{
+ return (HRTIMER_NORESTART);
+}
+
+void
+linuxkpi_hrtimer_setup(struct hrtimer *hrtimer,
+ enum hrtimer_restart (*function)(struct hrtimer *))
+{
+ linux_hrtimer_init(hrtimer);
+ if (function != NULL)
+ hrtimer->function = function;
+ else
+ hrtimer->function = linuxkpi_hrtimer_dummy_timeout;
+}
+
void
linux_hrtimer_set_expires(struct hrtimer *hrtimer, ktime_t time)
{