Skip to content

Commit 22c62b9

Browse files
anna-marialxKAGA-KOKO
authored andcommitted
timekeeping: Introduce auxiliary timekeepers
Provide timekeepers for auxiliary clocks and initialize them during boot. Signed-off-by: Anna-Maria Behnsen <anna-maria@linutronix.de> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Acked-by: John Stultz <jstultz@google.com> Link: https://lore.kernel.org/all/20250519083026.350061049@linutronix.de
1 parent 6168024 commit 22c62b9

1 file changed

Lines changed: 20 additions & 2 deletions

File tree

kernel/time/timekeeping.c

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,11 @@ struct tk_data {
5353
raw_spinlock_t lock;
5454
} ____cacheline_aligned;
5555

56-
static struct tk_data tk_core;
56+
static struct tk_data timekeeper_data[TIMEKEEPERS_MAX];
57+
58+
/* The core timekeeper */
59+
#define tk_core (timekeeper_data[TIMEKEEPER_CORE])
60+
5761

5862
/* flag for if timekeeping is suspended */
5963
int __read_mostly timekeeping_suspended;
@@ -113,6 +117,12 @@ static struct tk_fast tk_fast_raw ____cacheline_aligned = {
113117
.base[1] = FAST_TK_INIT,
114118
};
115119

120+
#ifdef CONFIG_POSIX_AUX_CLOCKS
121+
static __init void tk_aux_setup(void);
122+
#else
123+
static inline void tk_aux_setup(void) { }
124+
#endif
125+
116126
unsigned long timekeeper_lock_irqsave(void)
117127
{
118128
unsigned long flags;
@@ -1589,7 +1599,6 @@ void ktime_get_raw_ts64(struct timespec64 *ts)
15891599
}
15901600
EXPORT_SYMBOL(ktime_get_raw_ts64);
15911601

1592-
15931602
/**
15941603
* timekeeping_valid_for_hres - Check if timekeeping is suitable for hres
15951604
*/
@@ -1701,6 +1710,7 @@ void __init timekeeping_init(void)
17011710
struct clocksource *clock;
17021711

17031712
tkd_basic_setup(&tk_core, TIMEKEEPER_CORE, true);
1713+
tk_aux_setup();
17041714

17051715
read_persistent_wall_and_boot_offset(&wall_time, &boot_offset);
17061716
if (timespec64_valid_settod(&wall_time) &&
@@ -2630,3 +2640,11 @@ void hardpps(const struct timespec64 *phase_ts, const struct timespec64 *raw_ts)
26302640
}
26312641
EXPORT_SYMBOL(hardpps);
26322642
#endif /* CONFIG_NTP_PPS */
2643+
2644+
#ifdef CONFIG_POSIX_AUX_CLOCKS
2645+
static __init void tk_aux_setup(void)
2646+
{
2647+
for (int i = TIMEKEEPER_AUX_FIRST; i <= TIMEKEEPER_AUX_LAST; i++)
2648+
tkd_basic_setup(&timekeeper_data[i], i, false);
2649+
}
2650+
#endif /* CONFIG_POSIX_AUX_CLOCKS */

0 commit comments

Comments
 (0)