Add baseline_patch/patches/baseline_recalc_on_switch.patch

This commit is contained in:
Mika 2025-12-10 14:36:40 +00:00
commit f17e6de7c0

View file

@ -0,0 +1,36 @@
diff --git a/kernel/time/clocksource.c b/kernel/time/clocksource.c
index 1a2b3c4d5e6f..7f6e5d4c3b2a 100644
--- a/kernel/time/clocksource.c
+++ b/kernel/time/clocksource.c
@@
struct clocksource *curr_clocksource;
static bool baseline_recalc_on_switch(struct clocksource *cs);
static void clocksource_select(void)
{
@@
- clock->read(clock);
+ /*
+ * Guarantee a fresh baseline so the first read() after a
+ * clocksource switch does not inherit stale offsets.
+ */
+ if (clock->rebaseline && baseline_recalc_on_switch(clock))
+ clock->rebaseline = false;
+
+ clock->read(clock);
}
static bool baseline_recalc_on_switch(struct clocksource *cs)
{
- return false;
+ u64 now;
+
+ if (!cs || !cs->read)
+ return false;
+
+ now = cs->read(cs);
+ cs->switch_time = now;
+
+ return true;
}