What the Raspberry Pi time-server guides get wrong on a Pi 4, with the measurements. The headline artifact is a four-line pps-gpio patch: PREEMPT_RT force-threads IRQ handlers, and pps-gpio takes its timestamp inside its handler, so the realtime kernel puts a scheduler between the electrical edge and the clock. IRQF_NO_THREAD takes RMS offset from 2468 ns to 199 ns. - kernel/ the patch - dashboard/ live status page (position hidden by default) - docs-site/ the write-up (Astro/Starlight, brass, no tutorial section)
19 lines
658 B
Diff
19 lines
658 B
Diff
diff --git a/drivers/pps/clients/pps-gpio.c b/drivers/pps/clients/pps-gpio.c
|
|
index 65d17781d..5ba2aaebe 100644
|
|
--- a/drivers/pps/clients/pps-gpio.c
|
|
+++ b/drivers/pps/clients/pps-gpio.c
|
|
@@ -156,6 +156,13 @@ get_irqf_trigger_flags(const struct pps_gpio_device_data *data)
|
|
IRQF_TRIGGER_FALLING : IRQF_TRIGGER_RISING);
|
|
}
|
|
|
|
+ /* The handler timestamps the pulse, so it has to run in hard-irq
|
|
+ * context. Under PREEMPT_RT it would otherwise be force-threaded and
|
|
+ * the timestamp taken after thread wakeup latency, adding microseconds
|
|
+ * of jitter to an edge that should be good to nanoseconds.
|
|
+ */
|
|
+ flags |= IRQF_NO_THREAD;
|
|
+
|
|
return flags;
|
|
}
|
|
|