From: Anna-Maria Behnsen <anna-maria@linutronix.de>
Provide time keepers for independent PTP clocks and initialize them during
boot.
Signed-off-by: Anna-Maria Behnsen <anna-maria@linutronix.de>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
kernel/time/timekeeping.c | 22 ++++++++++++++++++++--
1 file changed, 20 insertions(+), 2 deletions(-)
---
--- a/kernel/time/timekeeping.c
+++ b/kernel/time/timekeeping.c
@@ -53,7 +53,11 @@ struct tk_data {
raw_spinlock_t lock;
} ____cacheline_aligned;
-static struct tk_data tk_core;
+static struct tk_data timekeeper_data[TIMEKEEPERS_MAX];
+
+/* The core timekeeper */
+#define tk_core (timekeeper_data[TIMEKEEPER_CORE])
+
/* flag for if timekeeping is suspended */
int __read_mostly timekeeping_suspended;
@@ -113,6 +117,12 @@ static struct tk_fast tk_fast_raw ____c
.base[1] = FAST_TK_INIT,
};
+#ifdef CONFIG_POSIX_PTP_CLOCKS
+static __init void tk_ptp_setup(void);
+#else
+static inline void tk_ptp_setup(void) { }
+#endif
+
unsigned long timekeeper_lock_irqsave(void)
{
unsigned long flags;
@@ -1584,7 +1594,6 @@ void ktime_get_raw_ts64(struct timespec6
}
EXPORT_SYMBOL(ktime_get_raw_ts64);
-
/**
* timekeeping_valid_for_hres - Check if timekeeping is suitable for hres
*/
@@ -1696,6 +1705,7 @@ void __init timekeeping_init(void)
struct clocksource *clock;
tkd_basic_setup(&tk_core, TIMEKEEPER_CORE, true);
+ tk_ptp_setup();
read_persistent_wall_and_boot_offset(&wall_time, &boot_offset);
if (timespec64_valid_settod(&wall_time) &&
@@ -2625,3 +2635,11 @@ void hardpps(const struct timespec64 *ph
}
EXPORT_SYMBOL(hardpps);
#endif /* CONFIG_NTP_PPS */
+
+#ifdef CONFIG_POSIX_PTP_CLOCKS
+static __init void tk_ptp_setup(void)
+{
+ for (int i = TIMEKEEPER_PTP; i <= TIMEKEEPER_PTP_LAST; i++)
+ tkd_basic_setup(&timekeeper_data[i], i, false);
+}
+#endif /* CONFIG_POSIX_PTP_CLOCKS */