[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250513145136.968343429@linutronix.de>
Date: Tue, 13 May 2025 17:13:04 +0200 (CEST)
From: Thomas Gleixner <tglx@...utronix.de>
To: LKML <linux-kernel@...r.kernel.org>
Cc: netdev@...r.kernel.org,
Richard Cochran <richardcochran@...il.com>,
Christopher Hall <christopher.s.hall@...el.com>,
David Zage <david.zage@...el.com>,
John Stultz <jstultz@...gle.com>,
Frederic Weisbecker <frederic@...nel.org>,
Anna-Maria Behnsen <anna-maria@...utronix.de>,
Miroslav Lichvar <mlichvar@...hat.com>,
Werner Abt <werner.abt@...nberg-usa.com>,
David Woodhouse <dwmw2@...radead.org>,
Stephen Boyd <sboyd@...nel.org>,
Thomas Weißschuh <thomas.weissschuh@...utronix.de>,
Kurt Kanzenbach <kurt@...utronix.de>,
Nam Cao <namcao@...utronix.de>,
Alex Gieringer <gieri@...utronix.de>
Subject: [patch 05/26] time: Introduce PTP clocks
From: Anna-Maria Behnsen <anna-maria@...utronix.de>
To support per PTP clock timekeeping and the related user space interfaces,
it's required to define a clock ID range for them.
Reserve 8 PTP clock IDs after the regular timekeeping clock ID space.
This is the maximum number of PTP clocks the kernel can support. The actual
number of supported clocks depends obviously on the presence of PTP devices
and might be constraint by the available VDSO space.
Add the corresponding timekeeper IDs as well.
Signed-off-by: Anna-Maria Behnsen <anna-maria@...utronix.de>
Signed-off-by: Thomas Gleixner <tglx@...utronix.de>
---
include/linux/timekeeper_internal.h | 6 ++++++
include/uapi/linux/time.h | 10 ++++++++++
kernel/time/Kconfig | 3 +++
3 files changed, 19 insertions(+)
---
--- a/include/linux/timekeeper_internal.h
+++ b/include/linux/timekeeper_internal.h
@@ -14,10 +14,16 @@
/**
* timekeeper_ids - IDs for various time keepers in the kernel
* @TIMEKEEPER_CORE: The central core timekeeper managing system time
+ * @TIMEKEEPER_PTP: The first PTP timekeeper
+ * @TIMEKEEPER_PTP_LAST:The last PTP timekeeper
* @TIMEKEEPERS_MAX: The maximum number of timekeepers managed
*/
enum timekeeper_ids {
TIMEKEEPER_CORE,
+#ifdef CONFIG_POSIX_PTP_CLOCKS
+ TIMEKEEPER_PTP,
+ TIMEKEEPER_PTP_LAST = TIMEKEEPER_PTP + MAX_PTP_CLOCKS - 1,
+#endif
TIMEKEEPERS_MAX,
};
--- a/include/uapi/linux/time.h
+++ b/include/uapi/linux/time.h
@@ -64,6 +64,16 @@ struct timezone {
#define CLOCK_TAI 11
#define MAX_CLOCKS 16
+
+/*
+ * PTP clock support. PTP clocks are dynamically configured by associating
+ * a clock ID to a PTP device. The kernel can support up to 16 PTP clocks,
+ * but the actual limit depends on architecture constraints vs. VDSO.
+ */
+#define CLOCK_PTP MAX_CLOCKS
+#define MAX_PTP_CLOCKS 8
+#define CLOCK_PTP_LAST (CLOCK_PTP + MAX_PTP_CLOCKS - 1)
+
#define CLOCKS_MASK (CLOCK_REALTIME | CLOCK_MONOTONIC)
#define CLOCKS_MONO CLOCK_MONOTONIC
--- a/kernel/time/Kconfig
+++ b/kernel/time/Kconfig
@@ -57,6 +57,9 @@ config POSIX_CPU_TIMERS_TASK_WORK
bool
default y if POSIX_TIMERS && HAVE_POSIX_CPU_TIMERS_TASK_WORK
+config POSIX_PTP_CLOCKS
+ def_bool POSIX_TIMERS && PTP_1588_CLOCK
+
config LEGACY_TIMER_TICK
bool
help
Powered by blists - more mailing lists