]> git.ipfire.org Git - thirdparty/chrony.git/commitdiff
refclock: drop filter length adjustment for polling drivers
authorMiroslav Lichvar <mlichvar@redhat.com>
Wed, 11 Dec 2024 10:16:30 +0000 (11:16 +0100)
committerMiroslav Lichvar <mlichvar@redhat.com>
Wed, 11 Dec 2024 10:45:13 +0000 (11:45 +0100)
In the refclock initialization, if the driver provides a poll()
function and 2^(poll-dpoll) is smaller than the configured length of the
median filter (64 by default), the filter is shortened to 2^(poll-dpoll)
samples, assuming the driver provides samples only in the poll()
function and at most one per call, to avoid wasting memory and before
commit 12237bf28393 ("refclock: stop requiring 4 samples in median
filter") also simplify configuration (for polling drivers only)

But this assumption is not always correct. The PHC driver can read
external PPS timestamps independently from the driver polling and the
RTC driver can timestamp interrupts. If the dpoll was too large to cover
the sample rate, some samples would be lost.

Drop the adjustment of the filter length to avoid this unexpected impact
on filtering and make it work as documented.

refclock.c

index a0e716c492ad40ffdce325dad6100b5752e38e8b..2cc4f621fd3a9344c119533753b07a28e81ed1df 100644 (file)
@@ -231,17 +231,8 @@ RCL_AddRefclock(RefclockParameters *params)
   }
 
   if (inst->driver->poll) {
-    int max_samples;
-
     if (inst->driver_poll > inst->poll)
       inst->driver_poll = inst->poll;
-
-    /* Adjust the filter length to save memory if the expected number
-       of samples is smaller */
-    max_samples = 1 << (inst->poll - inst->driver_poll);
-    if (max_samples < params->filter_length) {
-      params->filter_length = max_samples;
-    }
   }
 
   if (inst->driver->init && !inst->driver->init(inst))